import{y as B,z as F,i as s,j as M,a as y,c as i,o as r,f as o,d,w as N,F as q,h as A,b as L,u as p,e as c,t as k,g as P,n as j}from"./vue.esm-bundler-DZdE0M9V.js";import{t as m}from"./Translator-Bios5QX5.js";import{_ as O}from"./DynamicIcon-D-LZibaK.js";import{A as w}from"./Arr-MwYQQ3qa.js";import T from"./CreatePageButton-BY0mRMhm.js";import"./Notify-D1wJq1es.js";import"./Str-Ckn63bs5.js";import"./index-D0R5Hqh1.js";import"./Rest-DEQMhckH.js";import"./Badge-CAEsoWyQ.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const U={class:"fct-form-group"},z={class:"input-prepend"},E={class:"input-info-note flex gap-2 mt-2 flex-wrap items-center"},H=["innerHTML"],$={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:B({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=F(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 M(()=>{u.value[t.value.toString()]=f.field.preview_link}),(l,n)=>{const x=y("el-option"),C=y("el-select");return r(),i("div",U,[o("div",{class:j(["fct-input-group w-full",{focused:g.value}])},[o("div",z,[d(C,{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:N(()=>[(r(!0),i(q,null,A(v.value,(e,V)=>(r(),L(x,{key:V,label:e.label,value:Number(e.value)},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"]),o("div",E,[a.field.note?(r(),i("div",{key:0,class:"form-note mr-1 !mt-0",innerHTML:a.field.note},null,8,H)):c("",!0),o("div",$,[h()?(r(),i("a",{key:0,class:"preview-link !outline-none !shadow-none",href:h(),target:"_blank"},[o("p",K,k(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(k(p(m)("Preview"))+" ",1),d(O,{class:"w-3 h-3 mb-1",name:"Redirect"})])],8,R)):c("",!0)])])]),o("div",I,[d(T,{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};
