import{d as I,m as _,j as L,r as u,G as $,o as n,e as d,a as t,q as U,ag as O,y as D,ac as i,f as x,n as V,F,g as K,c as g,w as y,t as r,b as w,ah as E,aa as T}from"./BvNnk7SS.js";import{_ as P}from"./a7ZBoMfv.js";import{u as S}from"./CIaRsw82.js";const h=T(P),q={class:"flex items-center gap2"},R={class:"flex-1 text-left"},W={class:"text-sm"},j={class:"op50 font-mono text-xs"},z={class:"flex-1 text-left"},A={class:"text-sm"},G={class:"flex-1 text-left"},H={class:"text-sm"},Z=I({__name:"UiEditorLinkInput",props:_({hasDeleteButton:{type:Boolean,default:!1},dropdownClasses:{default:"DROPDOWN_MENU absolute mt2 w-xs"},toggleOnFocus:{type:Boolean,default:!0},focus:{type:Boolean}},{modelValue:{required:!1},modelModifiers:{}}),emits:_(["change","submit"],["update:modelValue"]),setup(k,{emit:C}){const N=k,M=C,v=L(k,"modelValue"),p=u(!1),m=u(null),s=u(v.value),f=u([]);function a(o){v.value=o||"",s.value=o||"",m.value?.blur(),M("submit",o)}const{onSearchPage:B}=S();async function b(){try{f.value=await B(s.value)}catch(o){console.warn(o)}}return $(()=>N.focus,()=>{N.focus&&m.value?.focus()},{immediate:!0}),(o,e)=>{const c=h;return n(),d("div",null,[t("div",q,[U(t("input",{ref_key:"input",ref:m,"onUpdate:modelValue":e[0]||(e[0]=l=>s.value=l),placeholder:"Paste a link or search pages...",class:"INLINE_MENU_LINK_INPUT",onKeyup:e[1]||(e[1]=l=>b()),onKeypress:e[2]||(e[2]=D(i(l=>a(s.value),["prevent"]),["enter"])),onFocus:e[3]||(e[3]=l=>p.value=!0),onBlur:e[4]||(e[4]=l=>p.value=!1)},null,544),[[O,s.value]]),o.hasDeleteButton&&v.value?.length?(n(),d("button",{key:0,class:"flex INLINE_MENU_LINK_REMOVE_BUTTON op80 hover:op100 transition",onClick:e[5]||(e[5]=l=>a()),onMousedown:e[6]||(e[6]=i(()=>{},["prevent"]))},e[9]||(e[9]=[t("div",{class:"ICON_DELETE"},null,-1)]),32)):x("",!0)]),(!o.toggleOnFocus||p.value)&&s.value?.length?(n(),d("div",{key:0,class:V(o.dropdownClasses)},[(n(!0),d(F,null,K(f.value,l=>(n(),g(c,{key:l._id,class:"items-start",onClick:i(J=>a(l._path),["prevent"])},{default:y(()=>[e[10]||(e[10]=t("div",{class:"i-lucide-file op50 mt0.5"},null,-1)),t("div",R,[t("div",W,r(l._path),1),t("div",j,r(l._id.replaceAll(":","/")),1)])]),_:2},1032,["onClick"]))),128)),s.value?.includes("://")||s.value?.startsWith("http")?(n(),g(c,{key:0,class:"items-start disabled:op80",disabled:!/^https?:\/\/.*\..+$/.test(s.value),onClick:e[7]||(e[7]=i(l=>a(s.value),["prevent"]))},{default:y(()=>[e[12]||(e[12]=t("div",{class:"op50 mt0.5 i-lucide-globe"},null,-1)),t("div",z,[t("div",A,r(s.value),1),e[11]||(e[11]=t("div",{class:"font-mono op50 text-xs"}," Lien externe ",-1))])]),_:1},8,["disabled"])):f.value?.length?x("",!0):(n(),g(c,{key:1,class:"items-start",onClick:e[8]||(e[8]=i(l=>a(w(E)(s.value)),["prevent"]))},{default:y(()=>[e[14]||(e[14]=t("div",{class:"op50 mt0.5 i-lucide-file-plus"},null,-1)),t("div",G,[t("div",H,r(w(E)(s.value)),1),e[13]||(e[13]=t("div",{class:"font-mono op50 text-xs"}," Nouvelle page ",-1))])]),_:1}))],2)):x("",!0)])}}});export{Z as _};
