import{A as V,B as A,h as s,i as F,r as k,e as i,o as r,d as o,a as d,w as M,F as N,g as q,c as L,u as p,b as c,t as y,f as P,n as O}from"./vue.esm-bundler.js?ver=1.3.20";import{t as m}from"./Translator.js?ver=1.3.20";import{_ as T}from"./DynamicIcon.js?ver=1.3.20";import{A as w}from"./Arr.js?ver=1.3.20";import U from"./CreatePageButton.js?ver=1.3.20";import"./Notify.js?ver=1.3.20";import"./Str.js?ver=1.3.20";import"./index.js?ver=1.3.20";import"./Rest.js?ver=1.3.20";import"./IconButton.js?ver=1.3.20";import"./_plugin-vue_export-helper.js?ver=1.3.20";const j={class:"fct-form-group"},E={class:"input-prepend"},H={class:"input-info-note flex gap-2 mt-2 flex-wrap items-center"},$=["innerHTML"],z={class:"flex gap-2"},D=["href"],K={class:"flex gap-1 items-end m-0 underline"},R=["href"],G={class:"flex gap-1 items-end m-0 underline"},I={class:"input-append"},ae={__name:"PageSelector",props:V({name:{type:String,required:!0},field:{type:Object},fieldKey:{type:String},value:{required:!0},variant:{type:String},nesting:{type:Boolean,default:!1},statePath:{type:String},form:{type:Object,required:!0},callback:{type:Function,required:!0},label:{type:String},attribute:{required:!0}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(a){const t=A(a,"modelValue",{get:l=>l?typeof l=="string"?Number(l):l:""}),f=a,v=s(f.field.options);s(t.value);const u=s({}),g=s(!1),_=()=>t.value?w.get(u.value,t.value.toString(),""):"",b=l=>{g.value=l},S=w.get(window,"fluentCartAdminApp.admin_url","").toString().replace("admin.php?page=fluent-cart#/","post.php?action=edit&post="),h=()=>t.value?S+t.value:"";return F(()=>{u.value[t.value.toString()]=f.field.preview_link}),(l,n)=>{const x=k("el-option"),B=k("el-select");return r(),i("div",j,[o("div",{class:O(["fct-input-group w-full",{focused:g.value}])},[o("div",E,[d(B,{filterable:"",modelValue:t.value,"onUpdate:modelValue":n[0]||(n[0]=e=>t.value=e),onFocus:n[1]||(n[1]=e=>b(!0)),onBlur:n[2]||(n[2]=e=>b(!1)),placeholder:p(m)("Select"),clearable:"",onChange:n[3]||(n[3]=e=>{e||(t.value="")})},{default:M(()=>[(r(!0),i(N,null,q(v.value,(e,C)=>(r(),L(x,{key:C,label:e.label,value:Number(e.value)},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"]),o("div",H,[a.field.note?(r(),i("div",{key:0,class:"form-note mr-1 !mt-0",innerHTML:a.field.note},null,8,$)):c("",!0),o("div",z,[h()?(r(),i("a",{key:0,class:"preview-link !outline-none !shadow-none",href:h(),target:"_blank"},[o("p",K,y(p(m)("Edit")),1)],8,D)):c("",!0),_()?(r(),i("a",{key:1,class:"preview-link !outline-none !shadow-none",href:_(),target:"_blank"},[o("p",G,[P(y(p(m)("Preview"))+" ",1),d(T,{class:"w-3 h-3 mb-1",name:"Redirect"})])],8,R)):c("",!0)])])]),o("div",I,[d(U,{title:a.field.page_title,onOnPageCreated:n[4]||(n[4]=e=>{v.value.push({label:e.label,value:e.value}),u.value[e.value.toString()]=e.page_link,t.value=e.value}),content:a.field.page_key},null,8,["title","content"])])],2)])}}};export{ae as default};
