@opengis/form 0.0.127 → 0.0.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function(de,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@opengis/core"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","@opengis/core","lucide-vue-next"],e):(de=typeof globalThis<"u"?globalThis:de||self,e(de.FormBuilder={},de.Vue,de.OpenGISCore,de.lucide))})(this,function(de,e,me,z){"use strict";const Jn=e.defineComponent({__name:"vs-info-tooltip",props:{text:{}},setup(r){const t=r,n=e.ref(!1),o=e.ref({top:"0px",left:"0px"});function l(s){if(!t.text)return;const c=s.currentTarget.getBoundingClientRect();o.value={top:`${c.bottom+4}px`,left:`${Math.min(c.left,window.innerWidth-230)}px`},n.value=!0}function a(){n.value=!1}return(s,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("span",{class:"inline-flex items-center",onMouseenter:l,onMouseleave:a},[e.renderSlot(s.$slots,"default",{},()=>[e.createVNode(e.unref(z.Info),{class:"h-4 w-4 text-gray-400 cursor-help"})])],32),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.value&&s.text?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle(o.value),class:"fixed z-[9999] max-w-xs p-2 bg-gray-900 text-white text-xs rounded-lg shadow-lg pointer-events-none"},e.toDisplayString(s.text),5)):e.createCommentVNode("",!0)]))],64))}}),mo={class:"w-full relative"},ho={key:0,class:"text-[14px] font-medium text-gray-900 mb-2 flex items-center gap-1"},go={class:"opacity-100"},yo={key:0,class:"text-red-500 text-[14px]"},bo={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},ko=e.defineComponent({__name:"vs-layout-default",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(r){const t=r,n=e.computed(()=>typeof t.item?.label=="string"&&t.item.label?t.item.label:t.item?.ua||t.label||t.ua),o=e.computed(()=>!!n.value),l=e.computed(()=>!!t.item?.rules?.includes("required")),a=e.computed(()=>t.item?.info||"");return(s,c)=>(e.openBlock(),e.createElementBlock("div",mo,[o.value?(e.openBlock(),e.createElementBlock("div",ho,[e.createElementVNode("span",go,e.toDisplayString(n.value),1),l.value?(e.openBlock(),e.createElementBlock("span",yo,"*")):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(Jn,{key:1,text:a.value},null,8,["text"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"default",e.mergeProps(s.$attrs,{class:{"opacity-60":s.item.disabled}})),s.error?(e.openBlock(),e.createElementBlock("span",bo,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0)]))}}),xo={class:"w-full relative flex flex-row items-center gap-2"},wo={key:0,class:"text-red-500 text-[14px]"},_o={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},Co=e.defineComponent({__name:"vs-layout-horizontal",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{default:()=>({container:12,label:3})}},setup(r){const t=r,n=e.computed(()=>t.item?.label||t.label||t.ua),o=e.computed(()=>t.item?.info||""),l=e.computed(()=>t.columns??{container:12,label:3}),a=e.computed(()=>{const{container:d,label:p}=l.value;return!d||d<=0?0:Math.min(Math.max(p??0,0),d)/d}),s=e.computed(()=>t.item?.type==="html"||a.value<=0?!1:!!n.value),c=e.computed(()=>{if(!s.value)return{};const d=`${a.value*100}%`;return{flexBasis:d,maxWidth:d}}),i=e.computed(()=>{const{container:d,label:p}=l.value;if(!d||d<=0)return{};if(t.item?.type==="html")return{flexBasis:"100%",maxWidth:"100%"};if(!s.value)return{flexBasis:"100%",maxWidth:"100%"};const m=Math.max(d-Math.max(p??0,0),0)/d;if(!m)return{};const x=`${m*100}%`;return{flexBasis:x,maxWidth:x}});return(d,p)=>(e.openBlock(),e.createElementBlock("div",xo,[s.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"text-sm text-gray-900 font-medium flex shrink-0 items-center gap-1",style:e.normalizeStyle(c.value)},[e.createTextVNode(e.toDisplayString(n.value)+" ",1),d.item?.rules?.includes("required")&&n.value?(e.openBlock(),e.createElementBlock("span",wo,"*")):e.createCommentVNode("",!0),o.value?(e.openBlock(),e.createBlock(Jn,{key:1,text:o.value},null,8,["text"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"flex-1 min-w-0",style:e.normalizeStyle(i.value)},[e.renderSlot(d.$slots,"default",e.normalizeProps(e.guardReactiveProps(d.$attrs)))],4),d.error?(e.openBlock(),e.createElementBlock("span",_o,e.toDisplayString(d.error),1)):e.createCommentVNode("",!0)]))}}),vo={class:"w-full relative"},Eo={key:0,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},Bo=e.defineComponent({__name:"vs-layout-inline",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("div",vo,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(t.$attrs))),t.error?(e.openBlock(),e.createElementBlock("span",Eo,e.toDisplayString(t.error),1)):e.createCommentVNode("",!0)]))}}),Vo={class:"flex-1 min-w-0"},So={key:0,class:"text-sm font-medium text-slate-700 dark:text-slate-200 flex items-center gap-1"},$o={class:"truncate"},No={key:0,class:"text-red-500 text-[14px]"},Ao=["innerHTML"],Fo={key:0,class:"mt-1 text-xs text-red-500"},Do={default:ko,horizontal:Co,inline:Bo,settings:e.defineComponent({__name:"vs-layout-settings",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(r){const t=r,n=e.ref("uk");e.computed(()=>(t.item??{})?.[n.value]??t.ua??t.label??"");const o=e.computed(()=>t.item?.description??""),l=e.computed(()=>Array.isArray(t.item?.rules)&&t.item.rules.includes("required")),a=e.computed(()=>(typeof t.error=="string"?t.error:"")??""),s=()=>{const c=typeof localStorage<"u"?localStorage.getItem("locale"):null;n.value=c||"uk"};return e.onMounted(()=>{try{typeof localStorage<"u"&&localStorage.locale&&(n.value=localStorage.locale)}catch{}window.addEventListener("storage",s)}),e.onUnmounted(()=>{window.removeEventListener("storage",s)}),(c,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-full relative",{"opacity-60":c.item?.disabled}])},[e.createElementVNode("div",{class:e.normalizeClass(["gap-2 md:flex-row md:items-center md:justify-between",[["switcher","native-select"].includes(c.item.type)?"flex flex-col":""]])},[e.createElementVNode("div",Vo,[c.ua||c.label?(e.openBlock(),e.createElementBlock("p",So,[e.createElementVNode("span",$o,e.toDisplayString(c.item[n.value]||c.ua||c.label),1),l.value?(e.openBlock(),e.createElementBlock("span",No,"*")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),o.value?(e.openBlock(),e.createElementBlock("p",{key:1,class:"text-xs text-slate-500 dark:text-slate-400",innerHTML:o.value},null,8,Ao)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["w-full",["select","native-select"].includes(c.item.type)?"md:w-[30%]":"md:w-auto"])},[e.renderSlot(c.$slots,"default",e.normalizeProps(e.guardReactiveProps(c.$attrs)))],2)],2),a.value?(e.openBlock(),e.createElementBlock("p",Fo,e.toDisplayString(a.value),1)):e.createCommentVNode("",!0)],2))}})};function Fe(r){return{inputClass:e.computed(()=>{const n=`disabled:opacity-50 disabled:cursor-not-allowed outline-none focus:ring-2 focus:ring-ring focus:ring-${r?.primaryColor||"blue"}-500 border border-solid border-stone-200 rounded-md text-sm text-stone-800 placeholder:text-stone-400 `;return r?.size==="sm"?`${n}h-[32px]`:`${n}h-[38px]`})}}const Mo=["placeholder","disabled"],Lo=e.defineComponent({__name:"vs-input-password",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,{inputClass:n}=Fe(t.style),o=e.useModel(r,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");return(s,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"password","onUpdate:modelValue":c[0]||(c[0]=i=>o.value=i),placeholder:a.value,disabled:l.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":s.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Mo)),[[e.vModelText,o.value]])}}),To=["placeholder","disabled","maxlength","minlength"],St=e.defineComponent({__name:"vs-input-text",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,{inputClass:n}=Fe(t.style),o=e.useModel(r,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??""),s=e.computed(()=>t.maxlength??void 0),c=e.computed(()=>t.minlength??void 0);function i(){typeof o.value=="string"&&(o.value=o.value.trim())}return(d,p)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"text","onUpdate:modelValue":p[0]||(p[0]=m=>o.value=m),placeholder:a.value,disabled:l.value,maxlength:s.value,minlength:c.value,onBlur:i,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[d.customClass,e.unref(n),{"!border-red-600":d.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,To)),[[e.vModelText,o.value]])}}),Io=["placeholder","disabled","min","max"],Qn=e.defineComponent({__name:"vs-input-number",props:e.mergeModels({min:{},max:{},style:{default:()=>({})},customClass:{},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,{inputClass:n}=Fe(t.style),o=e.useModel(r,"modelValue"),l=e.computed(()=>!!t.disabled);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"number",step:"any","onUpdate:modelValue":s[0]||(s[0]=c=>o.value=c),placeholder:a.placeholder,disabled:l.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"},min:a.min,max:a.max},null,10,Io)),[[e.vModelText,o.value]])}}),Ro={class:"flex items-center gap-[4px]"},Oo=["value","id","disabled"],zo=["for"],Po={class:"text-[14px] text-gray-700 flex items-center dark:text-neutral-400"},jo=e.defineComponent({__name:"vs-checkbox-default",props:{value:{default:""},label:{default:""},disabled:{type:Boolean,default:!1},id:{},modelValue:{default:""},info:{},error:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=t,o=r,l=e.computed({get:()=>o.modelValue,set:s=>n("update:modelValue",s)}),a=e.computed(()=>!!o.disabled);return(s,c)=>(e.openBlock(),e.createElementBlock("div",Ro,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",value:s.value,"onUpdate:modelValue":c[0]||(c[0]=i=>l.value=i),class:e.normalizeClass(["shrink-0 border border-solid hidden border-gray-700 w-3.5 h-3.5 rounded text-blue-600 focus:ring-offset-0 dark:bg-neutral-800 dark:border-neutral-700 cursor-pointer",{"!cursor-not-allowed":a.value}]),id:s.id,disabled:a.value},null,10,Oo),[[e.vModelCheckbox,l.value]]),e.createElementVNode("label",{for:s.id,class:e.normalizeClass(["flex flex-1 checkbox-label items-center gap-x-2 cursor-pointer text-sm text-gray-800 dark:text-neutral-300",{"!cursor-not-allowed":a.value}])},[e.createElementVNode("div",{class:e.normalizeClass(["h-[16px] text-white w-[16px] flex items-center justify-center shrink-0 border rounded",[l.value?"bg-blue-600 border-blue-600":"bg-white border-gray-600",s.error?"border-red-600":""]])},[e.createVNode(e.unref(z.Check),{class:"h-4 w-4"})],2),e.createElementVNode("span",Po,[e.renderSlot(s.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(s.label),1)])])],10,zo)]))}}),Uo=["name","value","disabled"],Ho={class:"flex items-center gap-[6px] text-[14px]"},qo={key:0,class:"text-[16px]"},Ko=["src"],Go=e.defineComponent({__name:"vs-checkbox-buttons",props:{value:{type:[String,Number,Boolean],default:""},label:{default:""},modelValue:{default:""},disabled:{type:Boolean},id:{},icon:{},imgUrl:{},style:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,o=t,l=e.computed({get:()=>n.modelValue,set:c=>{o("update:modelValue",c)}}),a=e.computed(()=>Array.isArray(l.value)?l.value.includes(n.value):l.value===!0||l.value===n.value),s=e.computed(()=>n.style?.size==="xs"?"p-1.5 text-xs":n.style?.size==="lg"?"p-3.5 text-[20px]":"p-2.5 text-xs");return(c,i)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["group relative flex justify-center items-center gap-x-3 text-center bg-white text-gray-800 ring-ring ring-2 cursor-pointer rounded-lg",[s.value,a.value?"ring-blue-500":"border border-gray-200 ring-transparent"]])},[e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"hidden",name:c.id,value:c.value,"onUpdate:modelValue":i[0]||(i[0]=d=>l.value=d),disabled:c.disabled},null,8,Uo),[[e.vModelCheckbox,l.value]]),e.createElementVNode("span",Ho,[c.icon||c.imgUrl?(e.openBlock(),e.createElementBlock("span",qo,[c.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(c.icon)},null,2)):e.createCommentVNode("",!0),c.imgUrl?(e.openBlock(),e.createElementBlock("img",{key:1,src:c.imgUrl,width:"16",height:"16",alt:"icon"},null,8,Ko)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(c.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(c.label),1)])])],2))}}),Wo={class:"flex items-center"},wn=e.defineComponent({__name:"vs-input-checkbox-item",props:{value:{default:""},label:{default:""},disabled:{type:Boolean,default:!1},view:{default:"default"},modelValue:{type:[Boolean,Array],default:!1},icon:{},imgUrl:{},slots:{},option:{},style:{},error:{default:""}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,o=t,l=`radio-${Math.floor(Math.random()*1e4)}`,a=e.computed({get:()=>Array.isArray(n.modelValue)?Array.isArray(n.modelValue)&&n.modelValue.includes(n.value):n.modelValue,set:c=>{if(Array.isArray(n.modelValue)){let i=[...n.modelValue];c?i.includes(n.value)||i.push(n.value):i=i.filter(d=>d!==n.value),o("update:modelValue",i)}else o("update:modelValue",c)}}),s=e.ref(`vs-checkbox-${n.view||"default"}`);return(c,i)=>(e.openBlock(),e.createElementBlock("div",Wo,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value==="vs-checkbox-buttons"?e.unref(Go):e.unref(jo)),{value:c.value,label:c.label,info:c.option?.info,disabled:c.disabled,modelValue:a.value,"onUpdate:modelValue":i[0]||(i[0]=d=>a.value=d),id:l,icon:c.icon,imgUrl:c.imgUrl,style:e.normalizeStyle(c.style),error:c.error},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:1},8,["value","label","info","disabled","modelValue","icon","imgUrl","style","error"]))]))}}),Yo={key:0,class:"flex items-start gap-x-1"},Zo={key:0,class:"text-red-500 text-[14px]"},Xo=["title"],Jo=["disabled"],_n=e.defineComponent({__name:"vs-input-switcher",props:e.mergeModels({rules:{default:()=>[]},view:{default:"checkbox"},label:{default:""},i:{default:""},text:{default:""},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue");return(o,l)=>t.view==="checkbox"?(e.openBlock(),e.createElementBlock("div",Yo,[e.createVNode(wn,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),label:o.text,error:o.error||""},null,8,["modelValue","label","error"]),o.rules?.includes("required")?(e.openBlock(),e.createElementBlock("span",Zo,"*")):e.createCommentVNode("",!0),o.i?(e.openBlock(),e.createElementBlock("button",{key:1,class:"cursor-pointer",title:o.i,onClick:l[1]||(l[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(e.unref(z.Info),{class:"h-4 w-4 text-gray-500"})],8,Xo)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["inline-flex h-5 w-9 shrink-0 px-[2px] cursor-pointer items-center rounded-full shadow-sm disabled:cursor-not-allowed disabled:opacity-50",[n.value?`bg-${o.style?.primaryColor||"blue"}-500`:"bg-stone-200",o.customClass]]),disabled:o.disabled,onClick:l[2]||(l[2]=a=>n.value=!n.value)},[e.createElementVNode("span",{"data-state":"checked",class:e.normalizeClass(["pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform",[n.value?"translate-x-4":"translate-x-0"]])},null,2)],10,Jo))}}),Qo=["id","innerHTML"],Cn=e.defineComponent({__name:"vs-input-static",props:{text:{default:""},html:{default:""},style:{},customClass:{default:""},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{id:t.name,class:e.normalizeClass(["text-gray-900",t.customClass]),innerHTML:t.html?t.html:t.text},null,10,Qo))}}),el=["placeholder","disabled","name"],vn=e.defineComponent({__name:"vs-input-mask",props:e.mergeModels({name:{},mask:{default:""},unmask:{type:Boolean,default:!1},placeholder:{default:"_"},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,{inputClass:n}=Fe(t.style),o=e.useModel(r,"modelValue"),l=e.ref(null);let a=null;function s(c){const i={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},d=new Set;let p=!1;for(let x=0;x<c.length;x+=1){const f=c[x];f==="{"?p=!0:f==="}"?p=!1:p&&d.add(f)}const m={};return Object.keys(i).forEach(x=>{d.has(x)||(m[x]=i[x])}),{mask:c,definitions:m,lazy:!1}}return e.onMounted(async()=>{if(l.value){const{default:c}=await Promise.resolve().then(()=>Hn),i=s(t.mask||"");a=c(l.value,i),a.on("accept",()=>{o.value=t.unmask?a.unmaskedValue:a.value}),a.on("complete",()=>{o.value=t.unmask?a.unmaskedValue:a.value}),a.value=o.value!=null?String(o.value):""}}),e.onBeforeUnmount(()=>{a?.destroy()}),e.watch(()=>t.mask,c=>{if(a){const i=s(c||"");a.updateOptions(i)}}),e.watch(o,c=>{a&&a.unmaskedValue!==c&&(a.value=c!=null?String(c):"")}),(c,i)=>(e.openBlock(),e.createElementBlock("input",{type:"text",ref_key:"inputEl",ref:l,placeholder:c.placeholder,disabled:c.disabled,name:c.name,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,10,el))}}),tl={class:"relative w-full bg-white rounded-lg"},nl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},rl=["placeholder","disabled"],En=e.defineComponent({__name:"vs-input-email",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,{inputClass:n}=Fe(t.style),o=e.useModel(r,"modelValue");return(l,a)=>(e.openBlock(),e.createElementBlock("div",tl,[e.createElementVNode("div",nl,[e.createVNode(e.unref(z.Mail),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),e.withDirectives(e.createElementVNode("input",{type:"email","onUpdate:modelValue":a[0]||(a[0]=s=>o.value=s),placeholder:l.placeholder,disabled:l.disabled,class:e.normalizeClass(["!pl-8 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":l.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,rl),[[e.vModelText,o.value]])]))}}),ol={class:"relative w-full bg-white rounded-lg"},ll={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},al=["value","placeholder","disabled"],Bn=e.defineComponent({__name:"vs-input-tel",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,{inputClass:n}=Fe(t.style),o=e.useModel(r,"modelValue"),l=e.computed(()=>o.value?o.value.startsWith("+")?o.value.slice(1):o.value:""),a=c=>{let{value:i}=c.target;i=i.replace(/^\+/,""),o.value=i?`+${i}`:""},s=c=>{const i=c,{data:d,inputType:p}=i;p&&p.startsWith("delete")||d&&/\D/.test(d)&&i.preventDefault()};return e.watch(()=>o.value,c=>{c&&!c.startsWith("+")?o.value=`+${c.replace(/^\+/,"")}`:c||(o.value="")},{immediate:!0}),(c,i)=>(e.openBlock(),e.createElementBlock("div",ol,[e.createElementVNode("div",ll,[e.createVNode(e.unref(z.Phone),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),i[0]||(i[0]=e.createElementVNode("div",{class:"absolute bottom-2/4 translate-y-2/4 left-[30px] text-gray-500 select-none pointer-events-none"}," + ",-1)),e.createElementVNode("input",{type:"tel",value:l.value,onInput:a,onBeforeinput:s,pattern:"^\\+[1-9]\\d{1,14}$",maxlength:"15",placeholder:c.placeholder,disabled:c.disabled,class:e.normalizeClass(["!pl-10 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":c.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,al)]))}}),sl=["value","disabled"],il={class:"text-[13px] text-gray-700"},cl=e.defineComponent({__name:"vs-input-radio-default",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.computed(()=>!!t.disabled);return(l,a)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex items-center gap-0",[t.customClass,o.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=s=>n.value=s),type:"radio",value:t.value,disabled:o.value,class:"hidden"},null,8,sl),[[e.vModelRadio,n.value]]),e.createElementVNode("span",{class:e.normalizeClass(["w-[16px] shrink-0 h-[16px] border rounded-full flex items-center justify-center mr-[10px]",[`border-${t.style?.primaryColor||"blue"}-500`,o.value?"opacity-50 cursor-not-allowed":""]])},[n.value==t.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["w-[12px] h-[12px] shrink-0 rounded-full",[`bg-${t.style?.primaryColor||"blue"}-500`]])},null,2)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",il,e.toDisplayString(t.text),1)],2))}}),dl=["value","disabled"],ul={class:"text-[13px] text-gray-700"},pl={"vs-input-radio-default":cl,"vs-input-radio-buttons":e.defineComponent({__name:"vs-input-radio-buttons",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.computed(()=>!!t.disabled);return(l,a)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex items-center border rounded-lg px-2 py-1",[n.value==t.value?`ring-2 ring-ring ring-${t.style?.primaryColor||"blue"}-500`:"",t.customClass,o.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=s=>n.value=s),type:"radio",value:t.value,disabled:o.value,class:"hidden"},null,8,dl),[[e.vModelRadio,n.value]]),e.createElementVNode("span",ul,e.toDisplayString(t.text),1)],2))}})},Vn=e.defineComponent({__name:"vs-input-radio",props:e.mergeModels({options:{},position:{default:"vertical"},view:{default:"default"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.computed(()=>pl[`vs-input-radio-${t.view}`]);return(l,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([l.position==="horizontal"?"flex items-center flex-wrap gap-2":""])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,s=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.value),e.mergeProps({key:s?.id,text:s.text,value:s.id.toString(),checked:n.value===s.id,modelValue:n.value,"onUpdate:modelValue":a[0]||(a[0]=c=>n.value=c)},{ref_for:!0},l.$attrs),null,16,["text","value","checked","modelValue"]))),128))],2))}}),fl={key:1,class:"w-full flex flex-col gap-4"},ml={key:0,class:"text-sm font-medium text-muted-foreground my-2"},hl="Без категорії",gl=e.defineComponent({__name:"vs-input-checkbox",props:{options:{default:()=>[]},position:{default:"vertical"},slots:{default:null},colSpan:{default:0},data:{},view:{},group:{default:void 0},values:{default:()=>[]},style:{},customClass:{},disabled:{type:Boolean},modelValue:{default:!1},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,o=t,l=e.ref([]),a=e.reactive({}),s=f=>f?.value||f?.id||f?.text||f,c=f=>f.text||String(f),i=f=>`lg:col-span-${f||12}`,d=e.computed(()=>[n.position==="vertical"?"flex flex-col":"",n.colSpan?"grid":"flex justify-start"]),p=f=>f==null||f===""?null:typeof f=="string"||typeof f=="number"?f:String(f),m=e.computed(()=>{if(!n.group)return[];const f=new Map;l.value.forEach(w=>{const b=w[n.group],k=p(b);f.has(k)||f.set(k,[]),f.get(k)?.push(w)});const u=[];n.values?.length&&n.values.forEach(w=>{const b=p(w);u.push(b)});const h=new Set,g=w=>{const b=f.get(w)||[];if(!b.length)return null;const k=w===null?"group-null":`group-${String(w)}`,B=w===null?hl:String(w);return h.add(w),{key:k,label:B,options:b}},C=[];return u.forEach(w=>{const b=g(w);b&&C.push(b)}),f.forEach((w,b)=>{if(h.has(b))return;const k=g(b);k&&C.push(k)}),C}),x=async()=>{try{const f=await fetch(`/api/suggest/${n.data}`).then(u=>u.json());l.value=f?.data||f}catch(f){console.error(f)}};return e.watch(()=>n.modelValue,f=>{if(typeof f=="boolean"&&l.value.length===1){const u=s(l.value[0]);a[u]=f}else if(Array.isArray(f)){const u=new Set(f);l.value.forEach(h=>{if(!h.disabled){const g=s(h);a[g]=u.has(g)}})}},{immediate:!0}),e.watch(a,()=>{if(!l.value.length){o("update:modelValue",null);return}const f=Object.entries(a).filter(([,u])=>u).map(([u])=>u);o("update:modelValue",f.length===0?[]:f)},{deep:!0}),e.onMounted(()=>{if(n.data)x().then(()=>{if(typeof n.modelValue=="boolean"&&l.value.length===1){const f=s(l.value[0]);a[f]=n.modelValue}else if(Array.isArray(n.modelValue)){const f=new Set(n.modelValue);l.value.forEach(u=>{if(!u.disabled){const h=s(u);a[h]=f.has(h)}})}});else if(l.value=n.options,typeof n.modelValue=="boolean"&&l.value.length===1){const f=s(l.value[0]);a[f]=n.modelValue}else if(Array.isArray(n.modelValue)){const f=new Set(n.modelValue);l.value.forEach(u=>{if(!u.disabled){const h=s(u);a[h]=f.has(h)}})}}),(f,u)=>n.group?(e.openBlock(),e.createElementBlock("div",fl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,h=>(e.openBlock(),e.createElementBlock("div",{key:h.key,class:"flex flex-col gap-2"},[h.label?(e.openBlock(),e.createElementBlock("span",ml,e.toDisplayString(h.label),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-0 w-full gap-[12px]",d.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.options,g=>(e.openBlock(),e.createBlock(wn,{modelValue:a[s(g)],"onUpdate:modelValue":C=>a[s(g)]=C,value:s(g),class:e.normalizeClass(i(f.colSpan)),disabled:n.disabled||g.disabled,label:c(g),key:`${h.key}-${s(g)}`,icon:g?.icon,imgUrl:g?.imgUrl,option:g,view:f.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","icon","imgUrl","option","view"]))),128))],2)]))),128))])):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["p-0 w-full gap-[10px]",d.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,h=>(e.openBlock(),e.createBlock(wn,{modelValue:a[s(h)],"onUpdate:modelValue":g=>a[s(h)]=g,value:s(h),class:e.normalizeClass(i(f.colSpan)),disabled:n.disabled||h.disabled,label:c(h),key:s(h),icon:h?.icon,imgUrl:h?.imgUrl,option:h,view:f.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","icon","imgUrl","option","view"]))),128))],2))}}),fe=(r,t)=>{const n=r.__vccOpts||r;for(const[o,l]of t)n[o]=l;return n},er=fe(gl,[["__scopeId","data-v-8e66207e"]]),yl=["type","placeholder","disabled"],bl=e.defineComponent({__name:"vs-input-date1",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},mode:{default:"date"}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r;function o(p){return p?n.mode==="datetime"?(p.includes("T")?p:null)||p+(p.includes(" ")?"":"T00:00"):p?.split(" ")[0]:null}const{inputClass:l}=Fe(n.style),a=t,s=e.computed({get:()=>o(n.modelValue),set:p=>a("update:modelValue",p)}),c=e.computed(()=>n.mode==="datetime"?"datetime-local":n.mode),i=e.computed(()=>!!n.disabled),d=e.computed(()=>n.placeholder??"");return(p,m)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:c.value,"onUpdate:modelValue":m[0]||(m[0]=x=>s.value=x),placeholder:d.value,disabled:i.value,ref:"date",class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[p.modelValue?"":"text-opacity-50",e.unref(l)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,yl)),[[e.vModelDynamic,s.value]])}}),kl=(r,t)=>{if(!t||!Object.keys(t).length)return r;const[n,o=""]=r.split("?"),l=new URLSearchParams(o);Object.entries(t).forEach(([s,c])=>{c==null||c===""||l.set(s,String(c))});const a=l.toString();return a?`${n}?${a}`:n},tr=async(r,t={})=>{try{const n=new FormData;n.append("unique","true"),n.append("file",r);const{api:o,id:l="1",form:a="form",table:s="table",customParams:c}=t,i=o||`/file/upload/uploads?id=${l||""}&form=${a||""}&table=${s||""}`,d=kl(i,c);return(await fetch(d,{method:"POST",body:n}).then(m=>m.json()))?.result}catch(n){return me.notify({type:"error",title:"Помилка!",message:"Сталась помилка під час завантаження файлу",position:"right-bottom"}),console.error("Сталась помилка завантаження файлу",n),null}},xl=async r=>{try{return await fetch(`file/delete${r}`),!0}catch(t){return console.error(t),!1}},nr=async r=>{try{const t=await fetch(`/file/download/files/uploads${r}`),n=await t.arrayBuffer(),o=t.headers["content-type"],l=new TextDecoder("utf-8").decode(n),a=new Blob([l],{type:o}),s=document.createElement("a");s.setAttribute("download",r),s.href=window.URL.createObjectURL(a),s.click()}catch(t){console.error(t.message)}},wl=r=>{if(!r)return"";const t=r?.split(".");return t[t.length-1]},_l=r=>{const t=wl(r),n={imageFormat:["tiff","jpg","jpeg","png","svg","ico","webp"],sheetsFormat:["xls","csv","xlsx"],archivesFormat:["zip","rar"],textsFormat:["json","geojson","txt","yml","yaml","shp"],documentsFormat:["pdf"]};return n.imageFormat.includes(t)?"img":n.sheetsFormat.includes(t)?z.Table:n.textsFormat.includes(t)?z.FileCode:n.documentsFormat.includes(t)?z.FileText:n.archivesFormat.includes(t)?z.FileArchive:z.FileText},Cl=["title"],vl={class:"absolute hidden top-0 right-0 flex items-center gap-x-2 w-full h-full justify-center"},Sn=fe(e.defineComponent({__name:"vs-input-file-list-item",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{value:{},valueModifiers:{},item:{},itemModifiers:{}}),emits:["update:value","update:item"],setup(r){const t=e.useModel(r,"value"),n=e.useModel(r,"item"),o=r;return(l,a)=>(e.openBlock(),e.createElementBlock("div",{title:n.value,class:"h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg overflow-hidden relative item-file"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(_l)(n.value)),{src:n.value,alt:"file",class:"w-full h-full object-cover cursor-pointer",onClick:a[0]||(a[0]=s=>e.unref(nr)(n.value))},null,8,["src"])),e.createElementVNode("div",vl,[e.createElementVNode("button",{type:"button",onClick:a[1]||(a[1]=s=>{e.unref(xl)(n.value),t.value=o.multiple?t.value?.filter(c=>c!==n.value):""}),class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-red-500"},[e.createVNode(e.unref(z.Trash2),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:a[2]||(a[2]=s=>e.unref(nr)(n.value)),class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-blue-500"},[e.createVNode(e.unref(z.Download),{class:"w-4 h-4"})])])],8,Cl))}}),[["__scopeId","data-v-dc557562"]]),El={class:"flex items-center gap-x-2"},Bl=["accept","multiple","disabled"],Vl={key:1,class:"flex items-center flex-wrap gap-2"},Sl={key:1,class:"loader"},$l={key:1,class:"loader"},rr=fe(e.defineComponent({__name:"vs-input-file",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["change"],["update:modelValue"]),setup(r,{emit:t}){const n=r,o=e.useModel(r,"modelValue"),l=t,a=e.ref(null),s=e.ref(!1),c=e.inject("values"),i=e.computed(()=>n.format?n.format.split(",").map(w=>w.trim().toLowerCase()).filter(Boolean):[]),d=w=>Array.isArray(o.value)&&o.value[w]||"",p=w=>{if(n.max_size&&w.size>n.max_size*1024*1024){const b=(w.size/1048576).toFixed(2);return me.notify({type:"error",title:"Помилка!",message:`Файл "${w.name}" занадто великий. Максимальний розмір: ${n.max_size} МБ, розмір файлу: ${b} МБ`,position:"right-bottom"}),!1}return!0},m=w=>{if(!i.value.length)return!0;const b=`.${w.name.split(".").pop()?.toLowerCase()||""}`,k=i.value.includes(b);return k||me.notify({type:"error",title:"Помилка!",message:`Неприпустимий формат файлу "${w.name}". Дозволені формати: ${i.value.join(", ")}`,position:"right-bottom"}),k},x=e.computed(()=>{const w={},b=[];if(!n.customParams?.length)return{params:w,missingSources:b};const k=c?.value??{};return n.customParams.forEach(B=>{if(!B)return;const[M,$]=B.split("="),E=M?.trim(),N=$?.trim();if(!E||!N)return;const v=k[N];if(v==null||v===""){b.push(N);return}w[E]=v}),{params:w,missingSources:b}}),f=()=>{const{params:w}=x.value;return{api:n.api,customParams:Object.keys(w).length?w:void 0}},u=()=>{const w=x.value.missingSources;if(!w.length)return!0;const b=w.join(", ");return me.notify({type:"warning",title:"Заповніть поля",message:`Поля (${b}) необхідні для завантаження файлу`,position:"right-bottom"}),!1},h=w=>{me.notify({type:"error",title:"Помилка завантаження",message:w||"Не вдалося завантажити файл. Спробуйте ще раз.",position:"right-bottom"})},g=()=>{n.disabled||s.value||u()&&a.value?.click()},C=async w=>{const{files:b}=w.target;if(!b||b.length===0)return;if(!u()){a.value&&(a.value.value="");return}const k=Array.from(b);if(n.max_size&&k.filter($=>!p($)).length>0){a.value&&(a.value.value="");return}if(k.filter(M=>!m(M)).length>0){a.value&&(a.value.value="");return}s.value=!0;try{if(n.multiple){const M=Array.from(b).map(async v=>await tr(v,f())),$=await Promise.all(M),N=$.filter(v=>v!==null).map(v=>v?.file_path).filter(Boolean);if(N.length===0){h();return}N.length<$.length&&h("Деякі файли не вдалося завантажити. Перевірте їх та спробуйте знову."),o.value=[...o.value||[],...N],l("change",o.value)}else{const M=b[0],$=await tr(M,f());if(!$?.file_path){h();return}o.value=$?.file_path,l("change",o.value||"")}}catch(M){const $=M?.message||void 0;h($)}finally{s.value=!1,a.value&&(a.value.value="")}};return(w,b)=>(e.openBlock(),e.createElementBlock("div",El,[e.createElementVNode("input",{class:"hidden",ref_key:"fileInput",ref:a,type:"file",accept:n.format,multiple:w.multiple,onChange:C,disabled:s.value||w.disabled},null,40,Bl),!w.multiple&&o.value?(e.openBlock(),e.createBlock(Sn,{key:0,item:o.value,"onUpdate:item":b[0]||(b[0]=k=>o.value=k),value:o.value,"onUpdate:value":b[1]||(b[1]=k=>o.value=k)},null,8,["item","value"])):w.multiple?(e.openBlock(),e.createElementBlock("div",Vl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(k,B)=>(e.openBlock(),e.createBlock(Sn,{multiple:w.multiple,key:B,value:o.value,"onUpdate:value":b[2]||(b[2]=M=>o.value=M),item:d(B)},null,8,["multiple","value","item"]))),128)),e.createElementVNode("div",{onClick:g,class:e.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 hover:text-blue-500 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",w.disabled||s.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500 hover:bg-blue-50"])},[s.value?(e.openBlock(),e.createElementBlock("div",Sl)):(e.openBlock(),e.createBlock(e.unref(z.Plus),{key:0,class:"h-4 w-4"}))],2)])):e.createCommentVNode("",!0),w.multiple?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:2,onClick:g,class:e.normalizeClass([w.disabled||s.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500","relative h-[120px] w-[120px] border text-gray-300 hover:text-blue-500 border-dashed border-gray-300 rounded-lg flex items-center justify-center cursor-pointer hover:border-blue-500 transition-all duration-300 hover:bg-blue-50"])},[s.value?(e.openBlock(),e.createElementBlock("div",$l)):(e.openBlock(),e.createBlock(e.unref(z.Plus),{key:0,class:"h-4 w-4"}))],2))]))}}),[["__scopeId","data-v-63366cf6"]]),Nl={class:"vs-input-file2 flex flex-col gap-4"},Al={class:"flex items-center gap-x-2"},Fl=["accept","disabled"],Dl={key:0,class:"absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-lg bg-white/90 text-xs font-medium text-slate-600"},Ml={key:0,class:"rounded-lg border border-[#CFD9E0] bg-white p-4 shadow-sm"},Ll={class:"flex items-center justify-between text-sm"},Tl={class:"truncate pr-4"},Il={class:"font-medium text-slate-800 truncate"},Rl={class:"text-slate-500"},Ol={class:"text-slate-500 whitespace-nowrap"},zl={class:"mt-3 h-2 rounded-full bg-slate-100 overflow-hidden"},Pl={class:"mt-3 flex flex-wrap gap-2 text-sm"},jl={key:0,class:"mt-2 text-sm text-rose-600"},Ul=e.defineComponent({__name:"vs-input-file2",props:e.mergeModels({format:{},max_size:{},api:{},chunkSize:{default:5*1024*1024},subdir:{default:""},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.ref(null),l=e.ref(null),a=e.ref(""),s=e.ref(0),c=e.ref(!1),i=e.ref(""),d=e.ref(null),p=e.inject("values"),m=e.computed(()=>t.format?t.format.split(",").map(D=>D.trim().toLowerCase()).filter(Boolean):[]),x=e.computed(()=>!l.value||!l.value.size?0:Math.min(100,Math.round(s.value/l.value.size*100))),f=e.computed(()=>l.value?`${g(s.value)} / ${g(l.value.size)}`:""),u=e.computed(()=>t.disabled?"opacity-50 cursor-not-allowed":c.value?"cursor-default text-blue-500":"cursor-pointer hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500"),h=()=>{t.disabled||c.value||k()&&o.value?.click()},g=D=>{if(!Number.isFinite(D))return"0 B";const I=["B","KB","MB","GB"];let A=0,T=D;for(;T>=1024&&A<I.length-1;)T/=1024,A+=1;return`${T.toFixed(A===0?0:1)} ${I[A]}`},C=D=>{if(!t.max_size)return!0;const I=t.max_size*1024*1024;return D.size>I?(me.notify({type:"error",title:"Файл занадто великий",message:`Максимальний розмір ${t.max_size} МБ`,position:"right-bottom"}),!1):!0},w=D=>{if(!m.value.length)return!0;const I=`.${D.name.split(".").pop()?.toLowerCase()||""}`;return m.value.includes(I)?!0:(me.notify({type:"error",title:"Непідтримуваний формат",message:`Дозволені формати: ${m.value.join(", ")}`,position:"right-bottom"}),!1)},b=e.computed(()=>{const D={},I=[];if(!t.customParams?.length)return{params:D,missing:I};const A=p?.value??{};return t.customParams.forEach(T=>{if(!T)return;const[L,U]=T.split("="),H=L?.trim(),W=U?.trim();if(!H||!W)return;const Q=A[W];Q==null||Q===""?I.push(W):D[H]=Q}),{params:D,missing:I}}),k=()=>b.value.missing.length?(me.notify({type:"warning",title:"Заповніть поля",message:`Потрібні значення: ${b.value.missing.join(", ")}`,position:"right-bottom"}),!1):!0,B=D=>{const I=D.target,A=I.files?.[0];if(A){if(!k()){I.value="";return}if(!C(A)||!w(A)){I.value="";return}l.value=A,s.value=0,a.value="",i.value=""}},M=async()=>{if(!l.value){h();return}try{i.value="";const D={id:a.value||"",fileName:l.value.name,subdir:t.subdir,size:l.value.size,...b.value.params},I=await fetch("/api/file/upload2/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(!I.ok)throw new Error("Не вдалося ініціалізувати завантаження");const A=await I.json();a.value=A.id||a.value,s.value=A.uploaded||0,await $()}catch(D){i.value=D?.message||"Помилка при старті завантаження"}},$=async()=>{if(!(!l.value||!a.value)){c.value=!0;try{for(;s.value<l.value.size;){const D=s.value,I=Math.min(D+t.chunkSize,l.value.size),A=l.value.slice(D,I);d.value=new AbortController;const T=await fetch(`/api/file/upload2/${a.value}`,{method:"PATCH",headers:{"Content-Range":`bytes ${D}-${I-1}/${l.value.size}`},body:A,signal:d.value.signal});if(!T.ok)throw new Error("Помилка завантаження частини");const L=await T.json().catch(()=>({}));if(L.uploaded!=null?s.value=Number(L.uploaded):s.value=I,L.finished||s.value>=l.value.size){c.value=!1,n.value=L.file_path||L.url||a.value,me.notify({type:"success",title:"Файл завантажено",message:l.value.name,position:"right-bottom"}),S();return}}}catch(D){if(D?.name==="AbortError")return;i.value=D?.message||"Помилка при завантаженні",c.value=!1}finally{d.value=null,c.value=!1}}},E=()=>{c.value&&(d.value?.abort(),d.value=null,c.value=!1)},N=async()=>{if(l.value){if(!a.value){await M();return}await $()}},v=()=>{d.value?.abort(),d.value=null,S()},S=()=>{const D=o.value;D&&(D.value=""),l.value=null,a.value="",s.value=0,i.value=""};return(D,I)=>(e.openBlock(),e.createElementBlock("div",Nl,[e.createElementVNode("div",Al,[e.createElementVNode("input",{ref_key:"fileInput",ref:o,type:"file",class:"hidden",accept:t.format,disabled:c.value||t.disabled,onChange:B},null,40,Fl),n.value?(e.openBlock(),e.createBlock(Sn,{key:0,item:n.value,"onUpdate:item":I[0]||(I[0]=A=>n.value=A),value:n.value,"onUpdate:value":I[1]||(I[1]=A=>n.value=A)},null,8,["item","value"])):(e.openBlock(),e.createElementBlock("div",{key:1,onClick:h,class:e.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",u.value])},[c.value?(e.openBlock(),e.createElementBlock("div",Dl,[I[2]||(I[2]=e.createElementVNode("div",{class:"loader"},null,-1)),e.createElementVNode("span",null,e.toDisplayString(x.value)+"%",1)])):(e.openBlock(),e.createBlock(e.unref(z.Plus),{key:1,class:"h-4 w-4"}))],2))]),l.value&&!n.value?(e.openBlock(),e.createElementBlock("div",Ml,[e.createElementVNode("div",Ll,[e.createElementVNode("div",Tl,[e.createElementVNode("div",Il,e.toDisplayString(l.value.name),1),e.createElementVNode("div",Rl,e.toDisplayString(g(l.value.size)),1)]),e.createElementVNode("div",Ol,e.toDisplayString(f.value),1)]),e.createElementVNode("div",zl,[e.createElementVNode("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-300",style:e.normalizeStyle({width:`${x.value}%`})},null,4)]),e.createElementVNode("div",Pl,[!c.value&&s.value>0&&s.value<(l.value?.size||0)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:N}," Resume ")):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:E}," Pause ")):e.createCommentVNode("",!0),!c.value&&s.value===0?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:M}," Upload ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"rounded border border-rose-200 px-3 py-1 text-rose-600",onClick:v}," Cancel ")]),i.value?(e.openBlock(),e.createElementBlock("p",jl,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]))}}),$n=fe(Ul,[["__scopeId","data-v-a2e59d0a"]]),Hl={class:"flex items-center justify-center h-[30px] w-[30px]"},ql={class:"max-w-[55vw]"},Kl={class:"text-sm font-semibold text-gray-800 truncate dark:text-neutral-200"},Gl={class:"flex items-center text-xs text-gray-500 truncate dark:text-neutral-500"},Wl={class:"px-[5px]"},Yl={class:""},Kt=e.defineComponent({__name:"vs-widget-file-info",props:{item:{default:null}},setup(r){const t=r,n=e.computed(()=>{try{return new Date(t.item.cdate).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}});function o(l){if(l<1024)return`${l} B`;const a=l/1024;return a<1024?`${a.toFixed(2)} KB`:`${(a/1024).toFixed(2)} MB`}return(l,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",Hl,[e.createVNode(e.unref(z.FileText),{class:"icon icon-tabler icons-tabler-outline icon-tabler-file h-4 w-4"})]),e.createElementVNode("div",ql,[e.createElementVNode("p",Kl,e.toDisplayString(l.item?.uploaded_name),1),e.createElementVNode("p",Gl,[e.createElementVNode("span",null,e.toDisplayString(l.item?.username),1),e.withDirectives(e.createElementVNode("span",Wl,"|",512),[[e.vShow,l.item?.username]]),e.createElementVNode("span",null,e.toDisplayString(n.value),1),a[0]||(a[0]=e.createElementVNode("span",{class:"px-[5px]"},"|",-1)),e.createElementVNode("span",Yl,e.toDisplayString(o(l.item?.size)),1)])])],64))}}),Zl={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-md w-full"},Xl={key:0,class:"flex w-full gap-x-3 items-center"},Jl={key:1,class:"flex gap-x-3 w-full items-center"},Ql={key:2,class:"flex gap-x-3 w-full items-center"},ea=["href"],ta={key:3,class:"flex gap-x-3 w-full items-center"},na={class:"lg:absolute lg:top-3 lg:end-1 opacity-100"},ra={class:"p-0.5 sm:p-1 inline-flex items-center gap-0.5 bg-white rounded-lg dark:bg-neutral-800 dark:border-neutral-700"},oa={class:"inline-block"},la={class:"inline-block"},aa=e.defineComponent({__name:"vs-widget-file-item",props:{item:{default:null},index:{default:0},prefix:{default:"/api"}},emits:["update","openModal","openLightbox"],setup(r,{emit:t}){const n=r,o=t;function l(p){return["pdf","json"].includes(p.ext)}function a(p){return["ppt","pptx","doc","docx","xls","xlsx"].includes(p.ext)}function s(p){const m=document.createElement("a");m.setAttribute("download",p?.uploaded_name),m.href=p?.file_path,m.click()}async function c(){try{await fetch(`${n.prefix}/widget/file/${n.item.entity_id}/${n.item.file_id}`),o("update")}catch(p){console.error(p)}}function i(){o("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:c,updateListOnConfirm:!0})}function d(p){(n.item.ext==="jpg"||n.item.ext==="png")&&o("openLightbox",{item:n.item,index:p})}return(p,m)=>(e.openBlock(),e.createElementBlock("div",Zl,[p.item.ext==="jpg"||p.item.ext==="png"?(e.openBlock(),e.createElementBlock("div",Xl,[e.createElementVNode("div",{class:"max-w-[55vw] cursor-pointer flex gap-x-3 w-full items-center",onClick:m[0]||(m[0]=x=>d(p.index))},[e.createVNode(Kt,{item:p.item},null,8,["item"])])])):l(p.item)?(e.openBlock(),e.createElementBlock("div",Jl,[e.createVNode(Kt,{item:p.item},null,8,["item"])])):a(p.item)?(e.openBlock(),e.createElementBlock("div",Ql,[e.createElementVNode("a",{href:`/api/file-preview?id=${p.item.file_id}`,target:"_blank",class:"flex gap-x-3 w-full items-center"},[e.createVNode(Kt,{item:p.item},null,8,["item"])],8,ea)])):(e.openBlock(),e.createElementBlock("div",ta,[e.createVNode(Kt,{item:p.item},null,8,["item"])])),e.createElementVNode("div",na,[e.createElementVNode("div",ra,[e.createElementVNode("div",oa,[e.createElementVNode("button",{class:"inline-flex p-[6px] justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:m[1]||(m[1]=x=>s(p.item))},[e.createVNode(e.unref(z.Download),{class:"h-4 w-4"})])]),m[3]||(m[3]=e.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),e.createElementVNode("div",la,[e.createElementVNode("button",{type:"button",class:"size-[30px] inline-flex justify-center items-center gap-x-2 rounded-lg border border-transparent text-red-600 hover:bg-red-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-red-100 dark:text-red-500 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",onClick:m[2]||(m[2]=x=>i())},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})])])])])]))}}),sa={class:"flex flex-col widget-file xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700 w-full"},ia={class:"flex w-full mb-[12px] items-center gap-x-2"},ca={class:"font-semibold text-gray-800 dark:text-neutral-200 text-[14px]"},da={class1:"ml-auto"},ua={class:"py-1.5 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg bg-gray-100 cursor-pointer hover:bg-gray-200 text-gray-800 shadow-2xs hover:bg-gray-50 focus:outline-hidden focus:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},pa={key:0,class:"py-4 mb-4 space-y-4 border-gray-200 border-y dark:border-neutral-700"},fa={class:"relative"},ma={class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-[1] ps-3.5"},ha={key:1,class:"space-y-3 max-h-[300px] overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},ga={key:0},or=e.defineComponent({__name:"vs-input-file-list",props:{id:{default:""},prefix:{default:"/api"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update"],setup(r,{emit:t}){const n=r,o=e.inject("form"),l=e.computed(()=>o.value.formId),a=e.ref(!1),s=e.ref(0),c=t,i=e.ref(!1),d=e.ref({}),p=e.ref([]),m=e.ref(""),x=e.computed(()=>Array.isArray(p.value)?p.value.filter(b=>b.ext==="jpg"||b.ext==="png").map(b=>b?.file_path):[]),f=e.computed(()=>m.value===""?p.value:p.value.filter(b=>b?.uploaded_name?.includes(m.value))),u=b=>{const k=x.value.findIndex(B=>B===b.item.file_path);k!==-1&&(a.value=!0,s.value=k)},h=async()=>{try{const b=await fetch(`${n.prefix}/widget/file/${l.value}`).then(k=>k.json());p.value=b?.rows}catch(b){console.error(b)}},g=async b=>{await Promise.all(Array.from(b.target.files).map(async k=>{const B=new FormData;B.append("file",k);try{const M=`${n.prefix}/widget/file/${l.value}`,$=await fetch(M,{method:"POST",body:B});return $.ok?(c("update","file-list"),k):(me.notify({type:$.status>=400&&$.status<500?"warning":"error",title:"Error",message:`Error code: ${$.status}`}),null)}catch(M){return me.notify({type:"error",title:"Error",message:M.message||"Unknown error"}),console.error(M),null}})),await h()},C=b=>{const k={...b};return b.cancel||(k.cancel=()=>{i.value=!1}),b.updateListOnConfirm&&(k.confirm=async()=>{await b.confirm(),i.value=!1,h()}),k},w=b=>{d.value=C(b),i.value=!0};return e.watch(l,b=>{b&&h()}),e.onMounted(()=>{l.value&&h()}),(b,k)=>{const B=e.resolveComponent("Lightbox"),M=e.resolveComponent("MessageBox");return e.openBlock(),e.createElementBlock("div",sa,[e.createElementVNode("div",ia,[e.createElementVNode("h2",ca," Файлів: "+e.toDisplayString(p.value?.length),1),e.createElementVNode("div",da,[e.createElementVNode("label",null,[e.createElementVNode("input",{type:"file",class:"hidden",onChange:k[0]||(k[0]=$=>g($))},null,32),e.createElementVNode("div",ua,[e.createVNode(e.unref(z.Upload),{class:"h-4 w-4"})])])])]),p.value?.length>4?(e.openBlock(),e.createElementBlock("div",pa,[e.createElementVNode("div",null,[e.createElementVNode("div",fa,[e.createElementVNode("div",ma,[e.createVNode(e.unref(z.Search),{class:"flex-shrink-0 text-gray-500 size-4 dark:text-neutral-400"})]),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":k[1]||(k[1]=$=>m.value=$),class:"py-2 px-3 ps-10 pe-16 block w-full bg-gray-200 xl:bg-gray-100 rounded-lg text-sm focus:border-blue-500 h-[40px] focus:border-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:border-transparent dark:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-600",placeholder:"Введіть назву файлу"},null,512),[[e.vModelText,m.value,void 0,{trim:!0}]])])])])):e.createCommentVNode("",!0),p.value?.length?(e.openBlock(),e.createElementBlock("div",ha,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,($,E)=>(e.openBlock(),e.createBlock(aa,{key:E,prefix:b.prefix,item:$,index:E,onUpdate:k[2]||(k[2]=N=>b.$emit("update","file-list")),onOpenModal:k[3]||(k[3]=N=>w(N)),onOpenLightbox:k[4]||(k[4]=N=>u(N))},null,8,["prefix","item","index"]))),128)),f.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ga,k[8]||(k[8]=[e.createElementVNode("p",{class:"text-sm text-gray-600 font-sm"}," Файлів з такою назвою не існує, введіть інше пошукове слово ",-1)])))])):e.createCommentVNode("",!0),e.createVNode(B,{modelValue:a.value,"onUpdate:modelValue":k[5]||(k[5]=$=>a.value=$),startIndex:s.value,"onUpdate:index":k[6]||(k[6]=$=>s.value=$),images:x.value},null,8,["modelValue","startIndex","images"]),e.createVNode(M,e.mergeProps({modelValue:i.value,"onUpdate:modelValue":k[7]||(k[7]=$=>i.value=$),onConfirm:d.value.confirm},d.value),null,16,["modelValue","onConfirm"])])}}}),ya={class:"flex items-center justify-between"},ba={class:"text-[16px] text-gray-900 font-medium"},ka={class:"grid gap-3"},xa=fe(e.defineComponent({__name:"vs-container-switcher",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(r){const t=r,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,o=>{n.value=o}),(o,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",ya,[e.createElementVNode("p",ba,e.toDisplayString(r.title),1),e.createVNode(_n,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),style:e.normalizeStyle(r.style)},null,8,["modelValue","style"])]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",ka,[e.renderSlot(o.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-90320b87"]]),wa={class:"text-[16px] text-gray-900 font-medium"},_a={class:"grid gap-3"},Ca=fe(e.defineComponent({__name:"vs-container-accordion",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(r){const t=r,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,o=>{n.value=o}),(o,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("button",{type:"button",onClick:l[0]||(l[0]=a=>n.value=!n.value),class:"flex items-center gap-2"},[e.createVNode(e.unref(z.ChevronDown),{class:e.normalizeClass(["h-4 w-4 duration-300",[n.value?"-rotate-180":""]])},null,8,["class"]),e.createElementVNode("span",wa,e.toDisplayString(r.title),1)]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",_a,[e.renderSlot(o.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-0c825d65"]]),va={class:"flex items-center justify-between"},Ea={switcher:xa,accordion:Ca,default:e.defineComponent({__name:"vs-container-default",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",va,[e.createElementVNode("p",null,e.toDisplayString(r.title),1)]),e.renderSlot(t.$slots,"default")]))}})},Ge={Equal:"==",Inequal:"!=",Higer:">",HigerOrEqual:">=",Lower:"<",LowerOrEqual:"<=",Between:"between",StartWith:"^",EndWith:"$",Contain:"*",In:"in",NotIn:"not_in"},Ba=(r,t)=>String(r)===String(t),Va=(r,t)=>String(r)!==String(t),Sa=(r,t)=>r>t,$a=(r,t)=>r>=t,Na=(r,t)=>r<t,Aa=(r,t)=>r<=t,Fa=(r,t)=>Array.isArray(t)&&t.length===2?r>=t[0]&&r<=t[1]:!1,Da=(r,t)=>String(r).startsWith(String(t)),Ma=(r,t)=>String(r).endsWith(String(t)),La=(r,t)=>String(r).includes(String(t)),Ta=(r,t)=>Array.isArray(t)?t.includes(r):!1,Ia=(r,t)=>Array.isArray(t)?!t.includes(r):!0,lr=(r,t)=>{if(!t)return!0;switch(t?.[1]){case Ge.Equal:return Ba(r,t?.[2]);case Ge.Inequal:return Va(r,t?.[2]);case Ge.Higer:return Sa(r,t?.[2]);case Ge.HigerOrEqual:return $a(r,t?.[2]);case Ge.Lower:return Na(r,t?.[2]);case Ge.LowerOrEqual:return Aa(r,t?.[2]);case Ge.Between:return Fa(r,t?.[2]);case Ge.StartWith:return Da(r,t?.[2]);case Ge.EndWith:return Ma(r,t?.[2]);case Ge.Contain:return La(r,t?.[2]);case Ge.In:return Ta(r,t?.[2]);case Ge.NotIn:return Ia(r,t?.[2]);default:return!0}},ar=e.defineComponent({__name:"vs-input-container",props:{style:{type:Object,default:()=>({})},title:{type:String,default:""},view:{type:String,default:"default"},name:{type:String,default:""},schema:{type:Array,default:()=>[]}},setup(r){const t=r,n=e.inject("values",e.ref({})),o=e.inject("form"),l=e.computed(()=>t.schema?.filter(c=>{const i=c?.conditions;if(!i)return!0;const d=Array.isArray(i)?i[0]:i,p=t.name?n.value?.[t.name]?.[d]??n.value?.[d]:n.value?.[d];return lr(p,i)})),a=e.computed(()=>Ea[t.view]),s=e.computed(()=>{if(n.value||(n.value={}),!t.name)return n.value;const c=n.value[t.name];if(c)return c;const i={};return n.value={...n.value,[t.name]:i},i});return(c,i)=>r.schema?.length?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:0,title:r.title,style:e.normalizeStyle(r.style)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,d=>(e.openBlock(),e.createBlock(Er,e.mergeProps({key:d.name},{ref_for:!0},d,{item:d,modelValue:s.value[d.name],"onUpdate:modelValue":p=>s.value[d.name]=p,style:r.style,error:e.unref(o)?.errors?.[d.name]}),null,16,["item","modelValue","onUpdate:modelValue","style","error"]))),128))]),_:1},8,["title","style"])):e.createCommentVNode("",!0)}}),Ra=["aria-expanded","data-focus"],Oa={class:"relative flex flex-1 items-center gap-1 py-0.5 pl-1 pr-0 overflow-hidden h-full min-w-0"},za={key:0,class:"flex flex-nowrap items-center gap-1 overflow-x-auto overflow-y-hidden min-w-0 flex-1 py-0.5"},Pa={class:"flex items-center gap-1 min-w-0"},ja=["title"],Ua=["innerHTML"],Ha=["onClick"],qa={class:"flex-1 min-w-[2px]"},Ka=["placeholder"],Ga=["title"],Wa=["innerHTML"],Ya={key:3,class:"truncate flex-1 min-w-0"},Za={key:2,class:"flex-1 min-w-[2px]"},Xa=["placeholder"],Ja={class:"flex items-center shrink-0"},Qa=["disabled"],es={key:1,class:"self-stretch w-px bg-[#ccc] my-[1px]"},ts=["disabled","title"],ns=["aria-disabled","onClick"],rs=["innerHTML"],os={key:1,class:"px-3 py-2 text-center text-gray-500"},ls=["disabled"],Nn="w-[16px] h-[16px] flex items-center justify-center flex-shrink-0 text-current",An=fe(e.defineComponent({__name:"vs-input-select",props:{multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean,default:!0},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{default:400},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{default:0},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(r,{emit:t}){const n=r,o=t,l=e.computed(()=>n.multiple),a=e.computed(()=>n.disabled);Fe(n.style);const s=e.computed({get:()=>n.modelValue,set:R=>o("update:modelValue",R)});!s.value&&n.defaultValue&&(s.value=n.defaultValue);const c=e.ref(null),i=e.ref(null),d=e.ref(null),p=e.ref(null),m=e.ref(!1),x=e.ref(!1),f=e.ref(null),u=e.ref([]),h=e.ref(-1),g=e.ref([]),C=e.ref(""),w=e.ref(null),b=e.ref("bottom"),k=e.ref({}),B=e.ref([]),M=e.computed(()=>{if(!B.value.length)return[];const R=u.value,K=new Map(R.map(q=>[q.id?.toString(),q]));return B.value.map(q=>K.get(q?.toString())).filter(q=>!!q)}),$=e.computed(()=>n.placeholder||"Select..."),E=e.computed(()=>H(f.value));e.computed(()=>l.value?!B.value.length&&C.value==="":!E.value&&C.value==="");const N=e.computed(()=>a.value?!1:l.value?B.value.length>0:!!s.value),v=R=>l.value?B.value.some(K=>K?.toString()===R?.toString()):s.value?.toString()===R?.toString(),S=e.computed(()=>{let R=u.value??[];if(!n.data&&C.value.trim()!==""){const K=C.value.toLowerCase();R=R.filter(q=>{const le=H(q).toLowerCase(),be=q.text?.toLowerCase?.()||"";return le.includes(K)||be.includes(K)})}if(l.value&&B.value.length){const K=new Set(B.value.map(q=>q?.toString()));R=R.filter(q=>!K.has(q.id?.toString()))}return R}),D=e.inject("values"),I=e.inject("field-props"),A=/\{\{\s*([^}]+?)\s*\}\}/g,T=R=>(R?String(R):"").replace(/<[^>]*>/g,"").trim(),L=e.computed(()=>n.slot??n?.optionTemplate??""),U=R=>{if(!R)return"";const K=L.value;return K?K.replace(A,(q,le)=>{const be=le.trim(),_e=R[be];return _e!=null?String(_e):""}):R.text??""},H=R=>{if(!R)return"";if(!L.value)return R.text??"";const q=U(R);return T(q)||R.text||""},W=R=>R?R.icon??null:null,Q=R=>!!(R?.color&&!W(R)),ve=R=>R?.color?{color:R.color}:void 0,ie=R=>!!W(R),G=(R,K,q)=>{if(!I)return!1;const le=I.value?.[R]??{},be=(Ce,Ve,Ie)=>{if(!Ve.length)return Ce;const[Oe,...Qe]=Ve,ze={...Ce};if(!Qe.length)return ze[Oe]=Ie,ze;const Vt=typeof Ce[Oe]=="object"&&Ce[Oe]!==null?Ce[Oe]:{};return ze[Oe]=be(Vt,Qe,Ie),ze},_e=be(le,K,q);return I.value={...I.value||{},[R]:_e},!0},ne=R=>{if(!n.set)return;const K=D?.value;!K&&!I||Object.entries(n.set).forEach(([q,le])=>{if(!q)return;const be=R?R[le]:null,_e=q.split(".").map(Ie=>Ie.trim()).filter(Boolean);if(!_e.length)return;const[Ce,...Ve]=_e;Ve.length&&G(Ce,Ve,be??null)||K&&(K[Ce]=be??null)})},ce=e.computed(()=>n.parent?D?.value?.[n.parent]?.toString()??null:null),ye=async R=>{if(!n.data){let K=n.options??[];if(R?.trim()){const q=R.toLowerCase();K=K.filter(le=>{const be=H(le).toLowerCase(),_e=le.text?.toLowerCase?.()||"";return be.includes(q)||_e.includes(q)})}return K}try{const K=n.host??"",q=n.prefix??"api",le=n.api??`/${q}/suggest/${n.data}`,be=`${K}${le}`,_e=new URLSearchParams;return _e.set("json","1"),R&&_e.set("key",R),ce.value!==void 0&&ce.value!==null&&ce.value!==""&&_e.set("parent",ce.value),n.start===1&&_e.set("start","1"),(await fetch(`${be}?${_e.toString()}`).then(Ve=>Ve.json()))?.data??[]}catch{return[]}},ke=async()=>{n.data?u.value=await ye(C.value):u.value=n.options?[...n.options]:[]},De=async R=>{if(R==null||R==="")return null;const K=u.value?.find(q=>q?.id?.toString()===String(R));if(K)return K;if(n.data)try{const q=n.host??"",le=n.prefix??"api",be=n.api??`/${le}/suggest/${n.data}`,_e=`${q}${be}`,Ce=new URLSearchParams;return Ce.set("json","1"),Ce.set("val",String(R)),ce.value!==void 0&&ce.value!==null&&ce.value!==""&&Ce.set("parent",ce.value),n.start===1&&Ce.set("start","1"),((await fetch(`${_e}?${Ce.toString()}`).then(Oe=>Oe.json()))?.data??[])?.[0]??null}catch{return null}return null},Me=async R=>{const K=new Set(u.value.map(le=>le.id?.toString())),q=R.filter(le=>!K.has(le?.toString()));q.length&&await q.reduce(async(le,be)=>{await le;const _e=await De(be);_e&&u.value.push(_e)},Promise.resolve())},we=()=>{if(!S.value.length){h.value=-1;return}let R=0;if(!l.value&&f.value){const K=f.value.id?.toString(),q=S.value.findIndex(le=>le.id?.toString()===K);q>=0&&(R=q)}h.value=R,e.nextTick(()=>{P(g.value[R],d.value)})},Xe=async()=>{a.value||(m.value=!0,await ke(),await e.nextTick(()=>{Z(),w.value?.focus()}),we())},Le=()=>{m.value=!1,h.value=-1,e.nextTick(()=>{w.value?.blur()})},Je=async R=>{if(a.value)return;!m.value?await Xe():Le()},j=async()=>{if(!a.value){if(m.value){Le();return}await Xe()}},Y=()=>{l.value?(B.value=[],s.value=[],o("change",[]),oe(null,[])):(f.value=null,s.value=null,o("change",null),oe(null,null)),ne(null),C.value="",e.nextTick(()=>w.value?.focus())},J=R=>{l.value&&(B.value=B.value.filter(K=>K?.toString()!==R?.toString()),s.value=[...B.value],o("change",s.value),oe(null),e.nextTick(()=>w.value?.focus()))},oe=(R,K)=>{const q=K??(l.value?[...B.value]:R?.id??null);o("value-selected",{name:n.name,value:q,option:R})},ae=R=>{l.value?(v(R.id)||(B.value=[...B.value,R.id],s.value=[...B.value],o("change",s.value),oe(R)),C.value="",e.nextTick(()=>{w.value?.focus(),h.value=Math.min(h.value,S.value.length-1)}),ne(null)):(f.value=R,s.value=R.id,o("change",s.value),oe(R),C.value="",Le(),ne(R))},xe=R=>{if(v(R.id)){l.value||Le();return}ae(R)},P=(R,K)=>{if(!R||!K)return;const q=R.offsetTop,le=q+R.offsetHeight,be=K.scrollTop,_e=be+K.clientHeight;let Ce=K.scrollTop;q<be?Ce=q-80:le>_e&&(Ce=le-K.clientHeight+4);const Ve=K;Ve.scrollTop=Ce},V=R=>{let K=R.parentElement;for(;K;){if(K.classList.contains("ui-dialog__content"))return K;const q=window.getComputedStyle(K),le=q.overflow+q.overflowY+q.overflowX;if(le.includes("auto")||le.includes("scroll")||K===document.body||K===document.documentElement)return K;K=K.parentElement}return document.body},Z=()=>{if(!i.value)return;const R=i.value.getBoundingClientRect(),K=window.innerHeight||document.documentElement.clientHeight,q=window.innerWidth||document.documentElement.clientWidth,le=8,be=8,_e=n.maxHeight||300,Ce=K-R.bottom-be-le,Ve=R.top-be-le,Ie=Ce>=Ve,Oe=Math.max(q-le*2,0);let{width:Qe}=R;Oe>0&&Qe>Oe&&(Qe=Oe);let{left:ze}=R;ze+Qe+le>q&&(ze=q-Qe-le),ze=Math.max(ze,le);const Vt=Math.min(_e,Math.max(Ie?Ce:Ve,50));b.value=Ie?"bottom":"top",k.value={position:"fixed",left:`${ze}px`,width:`${Qe}px`,maxHeight:`${Vt}px`,transform:Ie?"none":"translateY(-100%)",top:Ie?`${R.bottom+be}px`:`${R.top-be}px`}},ee=async R=>{a.value||!m.value&&(R.key==="ArrowDown"||R.key==="ArrowUp")&&(R.preventDefault(),await Xe())},pe=R=>{if(!m.value)return;const{key:K}=R;if(K==="ArrowDown")R.preventDefault(),h.value+1<S.value.length&&(h.value+=1,P(g.value[h.value],d.value));else if(K==="ArrowUp")R.preventDefault(),h.value>0&&(h.value-=1,P(g.value[h.value],d.value));else if(K==="Enter"){R.preventDefault();const q=S.value[h.value];q&&ae(q),w.value?.blur()}else K==="Escape"?(R.preventDefault(),Le()):K==="Backspace"?l.value&&C.value===""&&B.value.length&&(B.value=B.value.slice(0,-1),s.value=[...B.value],o("change",s.value)):K==="Home"?(h.value=0,P(g.value[0],d.value)):K==="End"?(h.value=S.value.length-1,P(g.value[h.value],d.value)):K==="Tab"&&Le()},Ee=()=>{a.value||(x.value=!0)},vt=()=>{x.value=!1,C.value=""},ot=R=>{R.key==="Escape"&&m.value&&Le()},gt=R=>{const K=R.target;c.value?.contains(K)||p.value?.contains(K)||Le()},yt=R=>{m.value&&d.value&&!d.value.contains(R.target)&&Z()},bt=()=>{m.value&&Z()},Te=()=>{m.value&&Z()};e.watch(()=>n.options,R=>{R?.length&&(u.value=[...R],We())},{immediate:!0});async function We(){if(l.value)Array.isArray(s.value)?B.value=[...s.value]:(B.value=s.value==null?[]:[s.value],s.value=[...B.value]),n.data&&B.value.length&&(await Me(B.value),await e.nextTick());else{if(Array.isArray(s.value)){const R=s.value[0]??null;s.value=R??null}s.value!=null&&(f.value=await De(s.value)),ne(f.value??null)}}e.watch(s,()=>{We()}),e.onMounted(async()=>{addEventListener("keydown",ot),addEventListener("scroll",yt,!0),addEventListener("resize",bt),document.addEventListener("click",gt,!0),i.value&&V(i.value).addEventListener("scroll",Te,!0),n.options?.length&&!n.data?u.value=[...n.options]:n.data&&(u.value=await ye("")),await We(),gn.value=!1}),e.onUnmounted(()=>{removeEventListener("keydown",ot),removeEventListener("scroll",yt,!0),removeEventListener("resize",bt),document.removeEventListener("click",gt,!0),i.value&&V(i.value).removeEventListener("scroll",Te,!0)});const ct=e.ref(!1),Ut=e.ref({}),Et=e.ref([]),hn=e.ref(null);async function kt(){if(!(!n.add?.token||hn?.value.validate()))try{const K=n.add.api??`/api/table/${n.add.token}`,q=await fetch(K,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ut.value)}),le=await q.json().catch(()=>({})),be=le?.error||le?.message,_e=Number(le?.code)>=400;if(!q.ok||_e){me.notify({title:"Помилка",type:"error",message:be||`Код помилки: ${le?.code||q.status}`});return}const Ce=le?.id;if(!Ce){me.notify({title:"Помилка",type:"error",message:"Обʼєкт створено, але в відповіді відсутній ID."});return}if(!n.options?.length&&n.data){const Ve=await fetch(`${n.api??`/api/suggest/${n.data}`}?val=${Ce}`).then(Ie=>Ie.json());f.value=Ve[0],u.value.push(Ve[0]),s.value=Ce}ct.value=!1,me.notify({title:"Успіх",message:"Обʼєкт успішно створено."})}catch(K){me.notify({title:"Помилка",type:"error",message:K?.message||"Не вдалося створити обʼєкт."})}}async function Bt(){if(!n.add)return null;const R=await fetch(`/api/template/form/${n.add.form}`).then(K=>K.json());return Et.value=R.schema,ct.value=!0,null}function Xn(R,K=200){let q;return(...le)=>{q&&clearTimeout(q),q=window.setTimeout(()=>R(...le),K)}}const dt=Xn(async R=>{u.value=await ye(R)},200);e.watch(C,R=>{n.data&&dt(R.trim())}),e.watch(()=>n.options,R=>{!n.data&&R?.length&&(u.value=[...R],We())},{immediate:!0}),e.watch(()=>n.parent??n.parentValue,()=>{n.data&&ke()});const gn=e.ref(!0);return e.watch(ce,async()=>{if(n.data&&(gn.value||(l.value?(B.value=[],s.value=[],o("change",[])):(f.value=null,s.value=null,o("change",null))),await ke(),n.auto===1&&ce.value&&u.value.length>0)){const R=u.value[0];R&&ae(R)}}),(R,K)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(me.VsModal),{visible:ct.value,"onUpdate:visible":K[1]||(K[1]=q=>ct.value=q),class:"z-[1000]",title:"Додати",buttonText:"Додати",onDone:kt,teleport:R.teleport},{default:e.withCtx(()=>[e.createVNode(Ye,{schema:Et.value,modelValue:Ut.value,"onUpdate:modelValue":K[0]||(K[0]=q=>Ut.value=q),ref_key:"addForm",ref:hn},null,8,["schema","modelValue"])]),_:1},8,["visible","teleport"]),e.createElementVNode("div",{class:"flex gap-1 w-full",ref_key:"selectRoot",ref:c,onClick:K[5]||(K[5]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass])},[K[6]||(K[6]=e.createElementVNode("span",{id:"react-select-live-region",class:"sr-only"},null,-1)),K[7]||(K[7]=e.createElementVNode("span",{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text",role:"log",class:"sr-only"},null,-1)),e.createElementVNode("div",{class:e.normalizeClass(["vs-input-select__control flex min-h-[38px] items-center justify-between rounded transition-colors bg-white",a.value?"bg-gray-100 text-gray-400 cursor-not-allowed":""]),role:"combobox","aria-expanded":m.value,"aria-haspopup":"listbox",onKeydown:ee,onClick:j,"data-focus":m.value||x.value?"true":"false",ref_key:"triggerRef",ref:i},[e.createElementVNode("div",Oa,[l.value?(e.openBlock(),e.createElementBlock("div",za,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,q=>(e.openBlock(),e.createElementBlock("div",{class:"flex min-w-0 bg-[rgb(230,230,230)] rounded-[2px] m-[2px] box-border max-w-full",key:q.id},[e.createElementVNode("div",Pa,[Q(q)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[16px] h-[16px] rounded-md block ml-1.5 flex-shrink-0",style:e.normalizeStyle({backgroundColor:q?.color})},null,4)):e.createCommentVNode("",!0),!L.value&&ie(q)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(Nn),style:e.normalizeStyle(ve(q)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(W(q)),{class:"w-full h-full",focusable:"false"}))],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"truncate text-[#172b4d] overflow-hidden max-w-[200px] px-0.5 pl-1.5",title:H(q)},[L.value?(e.openBlock(),e.createElementBlock("span",{key:0,innerHTML:U(q)},null,8,Ua)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(q.text),1)],64))],8,ja)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border text-[#172b4d] hover:bg-[rgb(255,189,173)] hover:text-[rgb(222,53,11)] flex-shrink-0",onClick:e.withModifiers(le=>J(q.id),["stop"])},[e.createVNode(e.unref(z.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Ha)]))),128)),e.createElementVNode("div",qa,[!a.value&&R.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:w,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:B.value.length?" ":$.value,"onUpdate:modelValue":K[2]||(K[2]=q=>C.value=q),onFocus:Ee,onBlur:vt,onKeydown:pe},null,40,Ka)),[[e.vModelText,C.value]]):e.createCommentVNode("",!0)])])):!l.value&&E.value&&C.value===""?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["truncate text-gray-900 absolute inset-x-0 pl-2 flex items-center gap-1 min-w-0"]),title:E.value},[Q(f.value)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[14px] h-[14px] rounded-md block flex-shrink-0",style:e.normalizeStyle({backgroundColor:f.value?.color})},null,4)):e.createCommentVNode("",!0),!L.value&&ie(f.value)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(Nn),style:e.normalizeStyle(ve(f.value)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(W(f.value)),{class:"w-full h-full",focusable:"false"}))],4)):e.createCommentVNode("",!0),L.value?(e.openBlock(),e.createElementBlock("span",{key:2,class:"truncate flex-1 min-w-0",innerHTML:U(f.value)},null,8,Wa)):(e.openBlock(),e.createElementBlock("span",Ya,e.toDisplayString(f.value?.text),1))],8,Ga)):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Za,[!a.value&&R.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:w,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:E.value?" ":$.value,"onUpdate:modelValue":K[3]||(K[3]=q=>C.value=q),onFocus:Ee,onBlur:vt,onKeydown:pe},null,40,Xa)),[[e.vModelText,C.value]]):e.createCommentVNode("",!0)]))]),e.createElementVNode("div",Ja,[N.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.value,onClick:e.withModifiers(Y,["stop"])},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,Qa)):e.createCommentVNode("",!0),N.value?(e.openBlock(),e.createElementBlock("div",es)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.value,onClick:K[4]||(K[4]=e.withModifiers(q=>Je(),["stop"])),title:m.value?"Закрити список":"Відкрити список"},[e.createVNode(e.unref(z.ChevronDown),{class:"h-4 w-4"})],8,ts)])],42,Ra),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[m.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:e.normalizeClass(["fixed z-[3000] rounded bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.1),0_4px_11px_rgba(0,0,0,0.1)]"]),style:e.normalizeStyle(k.value),role:"listbox"},[e.createElementVNode("div",{class:"overflow-y-auto py-1",style:e.normalizeStyle({maxHeight:k.value.maxHeight||"300px"}),ref_key:"listRef",ref:d},[S.value.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(S.value,(q,le)=>(e.openBlock(),e.createElementBlock("div",{key:q.id,ref_for:!0,ref:be=>g.value[le]=be,class:e.normalizeClass(["flex px-3 py-2 gap-2 cursor-pointer select-none text-gray-900",v(q.id)?"bg-[#2684ff] text-white":"bg-white hover:bg-[#deebff] hover:text-[#172b4d]",h.value===le&&!v(q.id)?"bg-[#deebff] text-[#172b4d]":""]),"aria-disabled":v(q.id)?"true":"false",role:"option",tabindex:"-1",onClick:be=>xe(q)},[Q(q)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[11px] h-[11px] rounded-full block flex-shrink-0",style:e.normalizeStyle({backgroundColor:q?.color})},null,4)):e.createCommentVNode("",!0),!L.value&&ie(q)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(Nn),style:e.normalizeStyle(ve(q)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(W(q)),{class:"w-full h-full",focusable:"false"}))],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["leading-[19px]",h.value===q.id?"text-white":"",(h.value===le,"")])},[L.value?(e.openBlock(),e.createElementBlock("span",{key:0,innerHTML:U(q)},null,8,rs)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(q.text),1)],64))],2)],10,ns))),128)):(e.openBlock(),e.createElementBlock("div",os," No options "))],4)],4)):e.createCommentVNode("",!0)]))],2),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:Bt,class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:a.value,type:"button"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),K[8]||(K[8]=e.createElementVNode("span",null,"Додати",-1))],8,ls)):e.createCommentVNode("",!0)],512)],64))}}),[["__scopeId","data-v-4f31eacf"]]),as=["placeholder","disabled"],sr=e.defineComponent({__name:"vs-input-textarea",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,{inputClass:n}=Fe(t.style),o=e.useModel(r,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");function s(){typeof o.value=="string"&&(o.value=o.value.trim())}return(c,i)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{"onUpdate:modelValue":i[0]||(i[0]=d=>o.value=d),placeholder:a.value,disabled:l.value,row:"2",onBlur:s,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] h-auto bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,42,as)),[[e.vModelText,o.value]])}}),ir=e.defineComponent({__name:"vs-input-richtext",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},format:{default:"html"},richtextProps:{default:()=>({})}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.defineAsyncComponent(()=>Promise.resolve().then(()=>Mh)),n=r,{inputClass:o}=Fe(n.style),l=e.useModel(r,"modelValue"),a=e.computed(()=>!!n.disabled),s=e.computed(()=>n.placeholder??""),c=e.computed(()=>({height:"300px",format:n.format,...n.richtextProps}));return(i,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["!h-full",[i.customClass,e.unref(o)]]),style:e.normalizeStyle(a.value?{pointerEvents:"none",opacity:.6}:{})},[e.createVNode(e.unref(t),e.mergeProps({modelValue:l.value,"onUpdate:modelValue":d[0]||(d[0]=p=>l.value=p),placeholder:s.value},c.value),null,16,["modelValue","placeholder"])],6))}}),ss={},is={viewBox:"0 0 178 90",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function cs(r,t){return e.openBlock(),e.createElementBlock("svg",is,t[0]||(t[0]=[e.createStaticVNode('<rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs>',12)]))}const ds=fe(ss,[["render",cs]]),us={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden flex flex-col"},ps={key:0,class:"flex flex-col gap-2 !p-4 border-b border-gray-200 sm:flex-row sm:items-center sm:justify-between bg-gray-50"},fs={key:0,class:"relative w-full"},ms={class:"flex flex-nowrap items-center justify-end gap-2 w-full overflow-x-auto"},hs={class:"w-full overflow-x-auto"},gs={class:"w-full min-w-[640px] table-auto divide-y divide-gray-200"},ys={class:"bg-gray-50"},bs={class:"border-b border-gray-200"},ks={class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 w-12 text-center"},xs=["onClick"],ws={key:0,class:"text-gray-400"},_s={key:0,colspan:"100%",class:"text-center"},Cs={class:"w-full"},vs={class:"p-5 min-h-[200px] flex flex-col justify-center items-center text-center"},Es=["onDragstart","onDragover","onDrop"],Bs={class:"px-4 py-3 text-center align-middle"},Vs={class:"flex items-center justify-center"},Ss=["innerHTML"],$s={key:0,class:"flex items-center gap-3 text-sm text-gray-700"},Ns={key:0},As=["src"],Fs={key:1,class:"rounded-md max-w-[45px] w-[45px] max-h-[45px] h-[45px] bg-gray-200 flex items-center justify-center"},Ds={key:1,class:"flex items-center justify-center"},Ms={key:2,class:"text-sm font-medium text-gray-900"},Ls={class:"px-4 py-3 text-right whitespace-nowrap"},Ts={class:"flex items-center justify-end gap-2"},Is=["onClick"],Rs=["onClick"],Os={class:"vs-form__head mr-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},cr=e.defineComponent({__name:"vs-input-datatable",props:e.mergeModels({actions:{},colModel:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useSlots(),o=j=>t.actions===void 0?!0:t.actions.includes(j),l=["search","import","export","add"],a=e.computed(()=>l.some(j=>o(j))),s=e.useModel(r,"modelValue"),c=e.ref({}),i=e.ref(""),d=e.ref(null),p=e.ref("asc"),m=e.computed(()=>{const j=s.value??[],Y=i.value?j.filter(ae=>x.value?.some(xe=>{const P=xe.key||xe.name;if(!P)return!1;const V=ae[P];return V?Array.isArray(V)?V.join(", ").toLowerCase().includes(i.value.toLowerCase()):String(V).toLowerCase().includes(i.value.toLowerCase()):!1})):j;if(!d.value)return Y;const J=d.value,oe=[...Y].sort((ae,xe)=>{const P=ne(ae?.[J]),V=ne(xe?.[J]);return typeof P=="number"&&typeof V=="number"?P-V:String(P).localeCompare(String(V))});return p.value==="asc"?oe:oe.reverse()}),x=e.computed(()=>(t.colModel??[]).filter(j=>!j.tableHidden)),f=e.ref(null),u=e.ref(null),h=e.ref(null),g=j=>{f.value=j},C=j=>{u.value=j},w=j=>{if(f.value===null||f.value===j){f.value=null,u.value=null;return}const Y=[...s.value],[J]=Y.splice(f.value,1);Y.splice(j,0,J),s.value=Y,f.value=null,u.value=null},b=()=>{h.value&&h.value.click()},k=j=>{const Y=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tif"],J=j.toLowerCase();return Y.some(oe=>J.endsWith(oe))},B=j=>{const J=j.target.files?.[0];if(!J)return;const oe=new FileReader;oe.onload=ae=>{try{const xe=ae.target?.result;if(typeof xe=="string"){const P=JSON.parse(xe);Array.isArray(P)&&s.value.push(...P)}}catch(xe){console.error("Error parsing file:",xe)}},oe.readAsText(J)},M=()=>{const j=JSON.stringify(s.value,null,2),Y=new Blob([j],{type:"application/json"}),J=URL.createObjectURL(Y),oe=document.createElement("a");oe.href=J,oe.download="data.json",oe.click(),URL.revokeObjectURL(J)},$=new Set(["autocomplete","select","radio","checkbox","combobox"]),E=new Map,N=(j,Y)=>{const J=`/api/suggest/${j}`,oe=J.includes("?")?"&":"?",ae=Y?`&val=${Y}`:"";return`${J}${oe}json=1${ae}`},v=j=>j==null||j===""?null:typeof j=="object"?j?.id!==void 0&&j.id!==null&&j.id!==""?j.id:null:j,S=j=>{const Y=new Set;return Array.isArray(s.value)&&s.value.forEach(J=>{const oe=J?.[j];if(oe==null||oe==="")return;if(Array.isArray(oe)){oe.forEach(xe=>{const P=v(xe);P!==null&&Y.add(P)});return}const ae=v(oe);ae!==null&&Y.add(ae)}),Y},D=async()=>{if(!t.colModel?.length)return;const j=t.colModel.filter(Y=>Y.data&&$.has(Y.type?.toLowerCase()||""));j.length&&await Promise.all(j.map(async Y=>{const J=Y.key||Y.name;if(!J)return;const oe=S(J),ae=Array.from(oe).map(V=>String(V)).sort(),xe=ae.join(",");if(!ae.length||E.get(J)===xe)return;E.set(J,xe);const P=ae.map(encodeURIComponent).join(",");try{const Z=await(await fetch(N(Y.data,P))).json();c.value[J]=Z?.data??Z}catch(V){console.error("Failed to fetch column values",V)}}))};e.watch([()=>t.colModel,()=>s.value],()=>{D()},{immediate:!0,deep:!0});const I=e.ref(""),A=e.ref(!1);let T="edit",L=0;const U=j=>(j?.format||j?.type||"").toString().toLowerCase(),H=e.computed(()=>t.colModel?.filter(j=>U(j)!=="slot").map(j=>{const{slot:Y,...J}=j;return J})??[]),W=e.ref({}),Q=e.ref({}),ve=j=>typeof j!="string"?!1:!!n[j],ie=(j,Y)=>Y?Y.split(".").reduce((J,oe)=>J==null?J:J[oe.trim()],j):j,G=(j,Y)=>typeof j!="string"?"":j.replace(/{{\s*([^}]+)\s*}}/g,(J,oe)=>{const ae=ie(Y,oe.trim());return ae??""}),ne=j=>{if(j==null||j==="")return"";if(typeof j=="number")return j;if(typeof j=="boolean")return j?1:0;if(typeof j=="string")return j.toLowerCase();if(Array.isArray(j))return j.map(Y=>ne(Y)).join(", ");if(typeof j=="object"){if(j.text!==void 0)return String(j.text).toLowerCase();if(j.label!==void 0)return String(j.label).toLowerCase();if(j.id!==void 0)return String(j.id).toLowerCase()}return String(j).toLowerCase()},ce=j=>{const Y=j.key||j.name;if(Y){if(d.value===Y){p.value=p.value==="asc"?"desc":"asc";return}d.value=Y,p.value="asc"}};async function ye(){I.value="Додати",A.value=!0,T="add",W.value={}}function ke(j,Y){if(!j?.length)return null;const J=typeof Y=="object"?Y?.id:Y;return J==null||J===""?null:j.find(oe=>oe?.id?.toString()===J.toString())?.text??null}function De(j){return j==null||j===""?"-":Array.isArray(j)?j.map(Y=>typeof Y=="object"?Y?.text??Y?.id??"-":Y).join(", "):typeof j=="object"?j?.text??j?.id??"-":j}function Me(j,Y){const J=Y.key||Y.name,oe=j?.[J],ae=c.value[J];if(!oe)return"-";if(Array.isArray(oe)){const P=oe.map(V=>ke(ae,V)).filter(Boolean);return P.length?P.join(", "):De(oe)}const xe=ke(ae,oe);return xe||De(oe)}async function we(j,Y){I.value="Редагувати",A.value=!0,T="edit",L=Y,W.value={...j}}function Xe(){const j=Q.value.validate();if(j){me.notify({type:"warning",title:"Помилка валідації",message:Object.entries(j).map(([Y,J])=>`${Y}: ${J}`).join(`
|
|
2
|
-
`)});return}T==="add"?Array.isArray(s.value)?s.value=[...s.value,W.value]:s.value=[W.value]:s.value=s.value.map((Y,J)=>J===L?W.value:Y),A.value=!1}function Le(j){s.value=s.value.filter((Y,J)=>J!==j)}function Je(){A.value=!1}return(j,Y)=>(e.openBlock(),e.createElementBlock("div",us,[a.value?(e.openBlock(),e.createElementBlock("div",ps,[o("search")?(e.openBlock(),e.createElementBlock("div",fs,[e.createVNode(e.unref(z.Search),{class:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":Y[0]||(Y[0]=J=>i.value=J),placeholder:"Пошук",class:"w-full rounded-md border border-gray-200 bg-white pl-10 pr-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100"},null,512),[[e.vModelText,i.value]])])):e.createCommentVNode("",!0),e.createElementVNode("div",ms,[o("import")?(e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"fileInput",ref:h,onChange:B,class:"hidden",accept:".json",type:"file"},null,544)):e.createCommentVNode("",!0),o("import")?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",onClick:b,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(z.Upload),{class:"h-4 w-4 text-gray-700"}),Y[4]||(Y[4]=e.createTextVNode(" Імпорт ",-1))])):e.createCommentVNode("",!0),o("export")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:M,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(z.Download),{class:"h-4 w-4 text-gray-700"}),Y[5]||(Y[5]=e.createTextVNode(" Експорт ",-1))])):e.createCommentVNode("",!0),o("add")?(e.openBlock(),e.createElementBlock("button",{key:3,onClick:ye,type:"button",class:"inline-flex items-center gap-2 rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-600 transition-colors"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4 text-white"}),Y[6]||(Y[6]=e.createTextVNode(" Додати ",-1))])):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",hs,[e.createElementVNode("table",gs,[e.createElementVNode("thead",ys,[e.createElementVNode("tr",bs,[e.createElementVNode("th",ks,[e.createVNode(e.unref(z.GripVertical),{class:"mx-auto h-4 w-4 text-gray-400"})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,J=>(e.openBlock(),e.createElementBlock("th",{key:J.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[e.createElementVNode("button",{type:"button",onClick:oe=>ce(J),class:"flex items-center gap-1 text-xs font-semibold text-gray-700 hover:text-gray-900 transition-colors"},[e.createElementVNode("span",null,e.toDisplayString(J.ua||J.label),1),d.value===(J.key||J.name)?(e.openBlock(),e.createElementBlock("span",ws,e.toDisplayString(p.value==="asc"?"▲":"▼"),1)):e.createCommentVNode("",!0)],8,xs)]))),128)),Y[7]||(Y[7]=e.createElementVNode("th",{class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 text-center w-[1%] whitespace-nowrap"}," Дії ",-1))])]),e.createElementVNode("tbody",{class:e.normalizeClass(["divide-y divide-gray-200",{"[&_tr:last-child]:border-0":!u.value}])},[m.value.length===0?(e.openBlock(),e.createElementBlock("td",_s,[e.createElementVNode("div",Cs,[e.createElementVNode("div",vs,[e.createVNode(ds,{class:"w-48 mx-auto"}),Y[8]||(Y[8]=e.createElementVNode("div",{class:"max-w-sm mx-auto mt-6"},[e.createElementVNode("p",{class:"font-medium text-gray-800 dark:text-neutral-200"},"Нічого не знайдено"),e.createElementVNode("p",{class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"})],-1))])])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(J,oe)=>(e.openBlock(),e.createElementBlock("tr",{key:J.id,class:e.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":f.value===oe,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":u.value===oe}]),draggable:"true",onDragstart:ae=>g(oe),onDragover:e.withModifiers(ae=>C(oe),["prevent"]),onDrop:ae=>w(oe)},[e.createElementVNode("td",Bs,[e.createElementVNode("div",Vs,[e.createVNode(e.unref(z.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,ae=>(e.openBlock(),e.createElementBlock("td",{key:ae.key,class:"px-4 py-3 align-middle"},[U(ae)==="slot"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[ve(ae.slot)?e.renderSlot(j.$slots,ae.slot,{key:0,row:J,value:J[ae.key],column:ae}):(e.openBlock(),e.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:G(ae.slot,J)},null,8,Ss))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[U(ae)==="file"?(e.openBlock(),e.createElementBlock("div",$s,[k(Me(J,ae))?(e.openBlock(),e.createElementBlock("div",Ns,[e.createElementVNode("img",{src:Me(J,ae),alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,As)])):(e.openBlock(),e.createElementBlock("div",Fs,[e.createVNode(e.unref(z.FileText),{class:"h-4 w-4 min-w-4"})]))])):U(ae)==="color"?(e.openBlock(),e.createElementBlock("div",Ds,[e.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:e.normalizeStyle({backgroundColor:Me(J,ae)||"#ffffff"})},null,4)])):(e.openBlock(),e.createElementBlock("div",Ms,e.toDisplayString(Me(J,ae)),1))],64))]))),128)),e.createElementVNode("td",Ls,[e.createElementVNode("div",Ts,[e.createElementVNode("button",{onClick:ae=>we(J,oe),class:"p-1.5 text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors"},[e.createVNode(e.unref(z.Pencil),{class:"h-4 w-4"})],8,Is),e.createElementVNode("button",{onClick:ae=>Le(oe),class:"p-1.5 text-gray-600 hover:text-red-600 hover:bg-red-50 rounded transition-colors"},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,Rs)])])],42,Es))),128))],2)])]),e.createVNode(e.unref(me.VsModal),{visible:A.value,title:I.value,size:"lg",onClose:Je,teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(Ye,{schema:H.value,values:W.value,"onUpdate:values":Y[1]||(Y[1]=J=>W.value=J),form:Q.value,"onUpdate:form":Y[2]||(Y[2]=J=>Q.value=J)},null,8,["schema","values","form"]),e.createElementVNode("div",Os,[e.createElementVNode("button",{type:"button",onClick:Y[3]||(Y[3]=J=>A.value=!1),class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:Xe,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])]),_:1},8,["visible","title"])]))}}),zs={},Ps={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","stroke-width":"2",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-line"};function js(r,t){return e.openBlock(),e.createElementBlock("svg",Ps,t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M6 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M18 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M7.5 16.5l9 -9"},null,-1)]))}const Us=fe(zs,[["render",js]]),Hs={},qs={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-polygon"};function Ks(r,t){return e.openBlock(),e.createElementBlock("svg",qs,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M6.5 9.5l3.5 -3"></path><path d="M14 5.5l3 1.5"></path><path d="M18.5 10l-2.5 7"></path><path d="M13.5 17.5l-7 -5"></path>',9)]))}const Gs=fe(Hs,[["render",Ks]]),Ws={},Ys={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-topology-ring-3"};function Zs(r,t){return e.openBlock(),e.createElementBlock("svg",Ys,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M8 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M8 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M6 8v8"></path><path d="M18 16v-8"></path><path d="M8 6h8"></path><path d="M16 18h-8"></path>',9)]))}const Xs=fe(Ws,[["render",Zs]]),Js={class:"bg-white/30 p-1 rounded-md shadow w-fit"},Qs={class:"flex gap-2"},ei=["onClick","title"],ti=["src"],ni=e.defineComponent({__name:"map-layers",props:{basemaps:{}},emits:["onLayerChange"],setup(r,{emit:t}){const n=r,o=e.ref(Object.keys(n.basemaps)[0]),l=t;function a(i){l("onLayerChange",i),o.value=i}const s={z:13,x:4790,y:2762};function c(i){if(i?.preview)return i.preview;if(!i?.url)return;const d={"{z}":s.z,"{x}":s.x,"{y}":s.y};let p=i.url;return Object.entries(d).forEach(([m,x])=>{p=p.replace(new RegExp(m,"gi"),String(x))}),p}return(i,d)=>(e.openBlock(),e.createElementBlock("div",Js,[e.createElementVNode("div",Qs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.basemaps,(p,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:e.normalizeClass(["cursor-pointer border rounded-lg overflow-hidden hover:shadow-sm",{"ring-2 ring-blue-500 border-blue-300":o.value===m}]),onClick:x=>a(m),title:p.name||m,role:"button",tabindex:"0"},[e.createElementVNode("img",{src:c(p),alt:"",class:"w-10 h-10 object-cover"},null,8,ti)],10,ei))),128))])]))}}),ri={class:"map-search-widget flex flex-col gap-2 rounded-xl widget min-w-[200px]"},oi={key:0,class:"vs-select__options absolute z-50 mt-1 w-full bg-white border border-gray-300 shadow-lg rounded-lg text-sm"},li=["onClick"],ai={class:"relative flex-1 min-w-[140px]"},si=["placeholder"],ii={type:"submit",class:"absolute inset-y-0 right-2 flex items-center text-gray-400 hover:text-gray-600","aria-label":"Пошук"},ci="https://data.softpro.ua/api-user/gis-url-proxy",di="https://geo.rv.ua/api-user/dzk.api",ui=fe(e.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(r,{emit:t}){const n=r,o=t,l=["here","xy","parcel"],a=e.computed(()=>{const k=n.config?.tools?.filter(B=>l.includes(B));return k&&k.length?k:l}),s=e.computed(()=>n.config?.placeholder?.trim()||"Пошук…"),c=e.ref(a.value[0]??l[0]);e.watch(a,k=>{k.includes(c.value)||(c.value=k[0])});const i=e.ref(""),d=e.ref(!1),p=e.ref(null);e.watch(c,()=>{i.value="",d.value=!1});function m(k){c.value=k}function x(k){if(!d.value)return;const B=p.value;B&&!B.contains(k.target)&&(d.value=!1)}e.onMounted(()=>{window.addEventListener("click",x,!0)}),e.onBeforeUnmount(()=>{window.removeEventListener("click",x,!0)});function f(k){return k==="xy"?"Координати":k==="parcel"?"Кадастр":"Адреси"}function u(k){const B=k.replace(/[,]+/g," ").trim();if(!B)return null;const M=B.split(/\s+/).filter(Boolean);if(M.length<2)return null;const $=M.slice(0,2).map(Number);if(!$.every(A=>Number.isFinite(A)))return null;const[E,N]=$;let v=E,S=N;const D=A=>Math.abs(A)<=90,I=A=>Math.abs(A)<=180;if(!D(v)||!I(S))if(D(S)&&I(v))v=N,S=E;else return null;return{lat:v,lng:S}}function h(k){return(k?.items||[]).map((M,$)=>({id:String(M?.id??$),title:M?.title||M?.address?.label||"Знайдений обʼєкт",lat:Number(M?.position?.lat),lng:Number(M?.position?.lng)})).filter(M=>Number.isFinite(M.lat)&&Number.isFinite(M.lng))}function g(k){const B=k?.result||k?.data||k;if(!B)return[];const M=B.geom_centroid;if(!M||!Array.isArray(M.coordinates))return[];const[$,E]=M.coordinates;return!Number.isFinite(E)||!Number.isFinite($)?[]:[{id:"parcel",title:B.cadnum||B.cad_num||"Земельна ділянка",lat:E,lng:$}]}function C(k){const M=k.replace(/\s+/g,"").split(":");if(M.length!==4)return!1;const $=[10,2,3,4];return M.every((E,N)=>E.length===$[N]&&/^\d+$/.test(E))}function w(k){o("goToCoordinates",[k.lat,k.lng])}async function b(){const k=i.value.trim();if(k){if(c.value==="xy"){const B=u(k);if(!B){me.notify({type:"warning",title:"Пошук координат",message:"Не знайдено або невірний формат координат"});return}w(B),i.value="";return}try{const B=new URL(c.value==="here"?ci:di);if(c.value==="here")B.searchParams.set("searchtext",k);else{if(!C(k)){me.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}B.searchParams.set("cad_num",k)}const M=await fetch(B.toString());if(!M.ok)throw new Error(`HTTP ${M.status}`);const $=await M.json(),E=c.value==="here"?h($):g($);if(!E.length)me.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const N=E[0];w(N),i.value=""}}catch(B){const M=B?.message||"Помилка пошуку";me.notify({type:"error",title:"Пошук",message:M})}}}return(k,B)=>(e.openBlock(),e.createElementBlock("div",ri,[e.createElementVNode("form",{class:"flex gap-2",onSubmit:e.withModifiers(b,["prevent"])},[a.value.length>1?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"relative search-type w-[140px]"},[e.createElementVNode("button",{type:"button",class:"vstSelect-input transition-all text-left bg-white border border-gray-200 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-100 block w-full py-1.5 px-3 text-sm cursor-pointer flex items-center justify-between gap-2",onClick:B[0]||(B[0]=M=>d.value=!d.value)},[e.createElementVNode("span",null,e.toDisplayString(f(c.value)),1),e.createVNode(e.unref(z.ChevronDown),{class:e.normalizeClass(["h-4 w-4 text-gray-500 transition-transform",{"rotate-180":d.value}])},null,8,["class"])]),d.value?(e.openBlock(),e.createElementBlock("div",oi,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,M=>(e.openBlock(),e.createElementBlock("li",{key:M,class:"px-3 py-2 cursor-pointer hover:bg-gray-100",onClick:$=>m(M)},e.toDisplayString(f(M)),9,li))),128))])])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",ai,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[1]||(B[1]=M=>i.value=M),placeholder:s.value,type:"text",class:"vs-input transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid !pr-8 py-1.5 pl-3 text-sm"},null,8,si),[[e.vModelText,i.value,void 0,{trim:!0}]]),e.createElementVNode("button",ii,[e.createVNode(e.unref(z.Search),{class:"h-4 w-4"})])])],32)]))}}),[["__scopeId","data-v-2b66205f"]]),pi={class:"pt-1 border-t border-gray-100"},fi={class:"space-y-1"},mi=e.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(r,{emit:t}){const n=t,o=e.ref(null),l=e.ref(null),a=(i,d,p)=>Math.min(Math.max(i,d),p),s=()=>{if(o.value===null||l.value===null||!Number.isFinite(o.value)||!Number.isFinite(l.value))return;const i=a(o.value,-90,90),d=a(l.value,-180,180);n("submit",{lat:i,lng:d}),o.value=null,l.value=null},c=()=>{o.value=null,l.value=null,n("cancel")};return(i,d)=>(e.openBlock(),e.createElementBlock("div",pi,[d[2]||(d[2]=e.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),e.createElementVNode("div",fi,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[0]||(d[0]=p=>o.value=p),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта (50.4501)"},null,512),[[e.vModelText,o.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=p=>l.value=p),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота (30.5234)"},null,512),[[e.vModelText,l.value,void 0,{number:!0}]]),e.createElementVNode("div",{class:"flex gap-1.5"},[e.createElementVNode("button",{class:"flex-1 px-2 py-1 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors",type:"button",onClick:s}," Додати "),e.createElementVNode("button",{class:"px-2 py-1 bg-gray-200 hover:bg-gray-300 text-gray-700 text-xs font-medium rounded transition-colors",type:"button",onClick:c}," Скасувати ")])])]))}}),hi=e.defineComponent({__name:"BtnAdd",emits:["click"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=o=>t.$emit("click"))},[e.createVNode(e.unref(z.Plus),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Додати ",-1))]))}}),gi=e.defineComponent({__name:"BtnClear",emits:["click"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"w-full px-2 py-1.5 bg-rose-500 hover:bg-rose-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=o=>t.$emit("click"))},[e.createVNode(e.unref(z.Trash2),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Очистити ",-1))]))}}),yi=e.defineComponent({__name:"BtnComplete",emits:["click"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=o=>t.$emit("click"))},[e.createVNode(e.unref(z.Circle),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode("Замкнути ",-1))]))}}),bi=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function xt(r){return bi.format(r)}function dr(r){return r>=1e3?`${xt(r/1e3)} км`:`${xt(r)} м`}const ki={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},xi={key:0,class:"flex-1 flex gap-1"},wi={key:1,class:"flex-1 font-mono text-gray-700"},_i=e.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(r,{emit:t}){const n=r,o=t,l=e.computed(()=>`${n.coords.lat.toFixed(4)}°, ${n.coords.lng.toFixed(4)}°`),a=e.ref(!1),s=e.ref(n.coords.lat),c=e.ref(n.coords.lng);e.watch(()=>n.coords,x=>{s.value=x.lat,c.value=x.lng},{deep:!0,immediate:!0});const i=(x,f,u)=>Math.min(Math.max(x,f),u),d=()=>{a.value=!0},p=()=>{if(!Number.isFinite(s.value)||!Number.isFinite(c.value))return;const x=i(s.value,-90,90),f=i(c.value,-180,180);o("update",{id:n.id,coords:{lat:x,lng:f}}),a.value=!1},m=()=>{o("delete",n.id)};return(x,f)=>(e.openBlock(),e.createElementBlock("div",ki,[e.createVNode(e.unref(z.MapPin),{size:12,"stroke-width":2,class:"text-gray-400 flex-shrink-0"}),a.value?(e.openBlock(),e.createElementBlock("div",xi,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[0]||(f[0]=u=>s.value=u),type:"number",step:"0.0001",min:"-90",max:"90",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=u=>c.value=u),type:"number",step:"0.0001",min:"-180",max:"180",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота"},null,512),[[e.vModelText,c.value,void 0,{number:!0}]]),e.createElementVNode("button",{class:"px-1.5 py-0.5 bg-emerald-500 text-white rounded hover:bg-emerald-600 text-xs",type:"button",onClick:p}," ✓ ")])):(e.openBlock(),e.createElementBlock("span",wi,e.toDisplayString(l.value),1)),a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"text-blue-500 hover:text-blue-600 px-0.5",type:"button",onClick:d}," ✎ ")),e.createElementVNode("button",{class:"text-rose-500 hover:text-rose-600 px-0.5",type:"button",onClick:m}," ✕ ")]))}}),Ci={class:"ruler-control px-3 py-2.5 space-y-2"},vi={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},Ei={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Сумарна довжина всіх відрізків","aria-hidden":"true"},Bi={class:"text-sm font-semibold text-slate-700"},Vi={class:"ruler-row"},Si={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},$i={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Площа замкнутого контуру","aria-hidden":"true"},Ni={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},Ai=["onClick"],Fi={class:"flex items-center gap-2 mt-0.5 pl-7"},Di={key:0,class:"text-base font-semibold text-green-600"},Mi={key:1,class:"text-xs text-gray-400"},Li={class:"ruler-row flex items-center gap-2 cursor-pointer"},Ti={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Список точок","aria-hidden":"true"},Ii={class:"text-xs font-medium text-gray-600 flex-1"},Ri={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},Oi=e.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(r){const t=r,n=e.ref(!1),o=e.ref("km2"),l=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],a=()=>{n.value=!n.value},s=(u,h)=>{const g=N=>N*Math.PI/180,C=g(h.lat-u.lat),w=g(h.lng-u.lng),b=g(u.lat),k=g(h.lat),B=Math.sin(C/2),M=Math.sin(w/2);return 6371e3*(2*Math.asin(Math.sqrt(B*B+Math.cos(b)*Math.cos(k)*M*M)))},c=e.computed(()=>{if(t.points.length<2)return 0;let u=0;for(let h=1;h<t.points.length;h+=1)u+=s(t.points[h-1].coords,t.points[h].coords);return t.isShapeClosed&&t.points.length>=2&&(u+=s(t.points[t.points.length-1].coords,t.points[0].coords)),u}),i=e.computed(()=>c.value>=1e3?`${xt(c.value/1e3)} км`:`${xt(c.value)} м`);function d(u){if(u.length<3)return 0;const h=u[0].lat,g=u[0].lng,C=(b,k)=>{const B=(b-h)*110574;return{x:(k-g)*111320*Math.cos(h*Math.PI/180),y:B}};let w=0;for(let b=0;b<u.length;b++){const k=(b+1)%u.length,B=C(u[b].lat,u[b].lng),M=C(u[k].lat,u[k].lng);w+=B.x*M.y-B.y*M.x}return Math.abs(w)*.5}const p=e.computed(()=>{if(!t.isShapeClosed||t.points.length<3)return 0;const u=t.points.map(h=>h.coords);return d(u)}),m=e.computed(()=>p.value>0),x=e.computed(()=>{const u=p.value;if(u===0)return"—";if(o.value==="km2"){const g=u/1e6;return`${xt(g)} км²`}if(o.value==="ha"){const g=u/1e4;return`${xt(g)} га`}const h=u>=1?Math.round(u):u;return`${xt(h)} м²`}),f=e.computed(()=>{const u=t.points.length;return u===1?"1 точка":u>=2&&u<=4?`${u} точки`:`${u} точок`});return e.watch(()=>t.points.length,()=>{t.points.length===0&&(n.value=!1)}),(u,h)=>(e.openBlock(),e.createElementBlock("div",Ci,[e.createElementVNode("button",vi,[e.createElementVNode("span",Ei,[e.createVNode(e.unref(z.Info),{size:12,"stroke-width":2.5})]),h[1]||(h[1]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),e.createElementVNode("span",Bi,e.toDisplayString(i.value),1)]),e.createElementVNode("div",Vi,[e.createElementVNode("button",Si,[e.createElementVNode("span",$i,[e.createVNode(e.unref(z.Info),{size:12,"stroke-width":2.5})]),h[2]||(h[2]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),e.createElementVNode("div",Ni,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,(g,C)=>e.createElementVNode("button",{key:g.id,type:"button",class:e.normalizeClass(["px-2.5 py-1 text-xs font-medium transition-colors border-r border-gray-200 last:border-r-0",C===0&&"rounded-l-md",C===l.length-1&&"rounded-r-md",o.value===g.id?"bg-white text-green-600 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-50"]),onClick:e.withModifiers(w=>o.value=g.id,["stop"])},e.toDisplayString(g.label),11,Ai)),64))])]),e.createElementVNode("div",Fi,[m.value?(e.openBlock(),e.createElementBlock("span",Di,e.toDisplayString(x.value),1)):(e.openBlock(),e.createElementBlock("span",Mi,"—"))])]),e.createElementVNode("div",Li,[e.createElementVNode("span",Ti,[e.createVNode(e.unref(z.Info),{size:12,"stroke-width":2.5})]),e.createElementVNode("span",Ii,e.toDisplayString(f.value),1),e.createElementVNode("button",{type:"button",class:"text-xs text-blue-500 hover:text-blue-600 font-medium transition-colors",onClick:e.withModifiers(a,["stop"])}," Координати ")]),n.value?(e.openBlock(),e.createElementBlock("div",Ri,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.points,(g,C)=>(e.openBlock(),e.createBlock(_i,{key:g.id,id:g.id,index:C+1,coords:g.coords,onUpdate:h[0]||(h[0]=w=>u.$emit("update-point",w)),onDelete:w=>u.$emit("delete-point",g.id)},null,8,["id","index","coords","onDelete"]))),128))])):e.createCommentVNode("",!0)]))}}),zi={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},Pi={class:"flex items-start gap-2"},ji=e.defineComponent({__name:"InfoHint",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("div",zi,[e.createElementVNode("div",Pi,[e.createVNode(e.unref(z.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),n[0]||(n[0]=e.createElementVNode("div",{class:"space-y-1"},[e.createElementVNode("p",{class:"text-xs font-medium text-blue-900"}," Натискайте на карту, щоб додати точки вимірювання "),e.createElementVNode("p",{class:"text-[10px] text-blue-700"},' Або скористайтесь кнопкою "Додати" внизу для введення координат вручну ')],-1))])]))}}),Ui={class:"space-y-1.5"},Hi={class:"space-y-1 max-h-40 overflow-y-auto"},qi={class:"text-gray-700"},Ki={class:"font-semibold text-slate-800"},Gi=e.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(r){const t=r;function n(a,s){const c=f=>f*Math.PI/180,i=c(s.lat-a.lat),d=c(s.lng-a.lng),p=c(a.lat),m=c(s.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(i/2)**2+Math.cos(p)*Math.cos(m)*Math.sin(d/2)**2)))}function o(a){return dr(a)}const l=e.computed(()=>{const a=[],s=t.points;if(s.length<2)return a;for(let c=0;c<s.length;c++){const i=c===s.length-1&&t.isShapeClosed?0:c+1;if(i>=s.length)break;const d=n(s[c].coords,s[i].coords);a.push({from:c+1,to:i+1,label:o(d)})}return a});return(a,s)=>(e.openBlock(),e.createElementBlock("div",Ui,[s[0]||(s[0]=e.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),e.createElementVNode("div",Hi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(c,i)=>(e.openBlock(),e.createElementBlock("div",{key:i,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[e.createElementVNode("span",qi,"Точка "+e.toDisplayString(c.from)+" → Точка "+e.toDisplayString(c.to),1),e.createElementVNode("span",Ki,e.toDisplayString(c.label),1)]))),128))])]))}}),Wi={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},Yi={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},Zi={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},Xi={class:"flex items-center gap-2"},Ji={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},Qi={class:"flex border-b border-gray-200"},ec={key:1,class:"px-3 py-2.5"},tc={key:1,class:"text-xs text-gray-500"},nc={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},rc={class:"flex gap-1.5"},oc=e.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(r,{expose:t,emit:n}){const o=n,l=e.ref([]),a=e.computed(()=>l.value.length>0),s=e.ref(!1),c=e.ref(!1),i=e.ref("general");function d(v){i.value=v,o("tab-change",v)}e.onMounted(()=>{o("tab-change",i.value)});const p=e.computed(()=>l.value.length>=3&&!c.value);let m=1;const x=()=>l.value.map(v=>({id:v.id,coords:{...v.coords}})),f=()=>{l.value.length<3&&c.value&&(c.value=!1,o("shape-closed-change",!1)),o("points-change",x())},u=()=>{const v=m;return m+=1,v},h=v=>{l.value=[...l.value,{id:u(),coords:{lat:v.lat,lng:v.lng}}],f()},g=({id:v,coords:S})=>{const D=l.value.findIndex(A=>A.id===v);if(D===-1)return;const I=[...l.value];I[D]={id:v,coords:{...S}},l.value=I,f()},C=v=>{l.value=l.value.filter(S=>S.id!==v),f()},w=()=>{l.value=[],c.value&&(c.value=!1,o("shape-closed-change",!1)),f()},b=v=>{g(v)},k=v=>{C(v)},B=()=>{s.value=!0,o("add-request")},M=v=>{h(v),s.value=!1},$=()=>{s.value=!1},E=()=>{p.value&&(c.value=!0,o("complete"),o("shape-closed-change",!0))},N=()=>{w(),s.value=!1,o("close")};return t({addPoint:h,clearPoints:w}),(v,S)=>(e.openBlock(),e.createElementBlock("div",Wi,[e.createElementVNode("div",Yi,[e.createElementVNode("div",Zi,[e.createElementVNode("div",Xi,[e.createElementVNode("div",Ji,[e.createVNode(e.unref(z.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),S[2]||(S[2]=e.createElementVNode("h3",{class:"text-white font-semibold text-xs"},"Вимірювання",-1))]),e.createElementVNode("button",{class:"w-5 h-5 flex items-center justify-center rounded hover:bg-white/20 transition-colors","aria-label":"Закрити",onClick:N},[e.createVNode(e.unref(z.X),{size:14,"stroke-width":2,class:"text-white"})])]),e.createElementVNode("div",Qi,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:S[0]||(S[0]=D=>d("general"))}," Загальна ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:S[1]||(S[1]=D=>d("topoint"))}," До точки ",2)]),i.value==="general"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.value?(e.openBlock(),e.createBlock(Oi,{key:1,points:l.value,"is-shape-closed":c.value,onUpdatePoint:b,onDeletePoint:k},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createBlock(ji,{key:0}))],64)):(e.openBlock(),e.createElementBlock("div",ec,[a.value?(e.openBlock(),e.createBlock(Gi,{key:0,points:l.value,"is-shape-closed":c.value},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createElementBlock("p",tc,"Додайте точки на карті, щоб бачити відстані між ними."))])),e.createElementVNode("div",nc,[e.createElementVNode("div",rc,[s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(hi,{key:0,onClick:B})),p.value?(e.openBlock(),e.createBlock(yi,{key:1,onClick:E})):e.createCommentVNode("",!0)]),s.value?(e.openBlock(),e.createBlock(mi,{key:0,onSubmit:M,onCancel:$})):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(gi,{key:1,onClick:w})):e.createCommentVNode("",!0)])])]))}}),Pe="ruler-points",at="ruler-line",st="ruler-polygon",it="ruler-segments",lc=e.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(r){function t(u,h){const g=M=>M*Math.PI/180,C=g(h.lat-u.lat),w=g(h.lng-u.lng),b=g(u.lat),k=g(h.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(C/2)**2+Math.cos(b)*Math.cos(k)*Math.sin(w/2)**2)))}function n(u){return dr(u)}const o=r;function l(){return{type:"FeatureCollection",features:[]}}function a(u,h,g){const C=g??"general",w=[];let b=0;w.push(0);for(let k=1;k<u.length;k++)b+=t(u[k-1].coords,u[k].coords),w.push(b);return h&&u.length>=2&&(b+=t(u[u.length-1].coords,u[0].coords)),{type:"FeatureCollection",features:u.map((k,B)=>{const M=C==="general"?B===0?"0":n(w[B]):B===0?"0":n(t(u[B-1].coords,u[B].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[k.coords.lng,k.coords.lat]},properties:{id:k.id,index:B+1,label:M}}})}}function s(u,h){if(u.length<2)return l();const g=[];for(let C=0;C<u.length;C++){const w=C===u.length-1&&h?0:C+1;if(w>=u.length)break;const b=u[C].coords,k=u[w].coords,B=t(b,k);g.push({type:"Feature",geometry:{type:"LineString",coordinates:[[b.lng,b.lat],[k.lng,k.lat]]},properties:{distance:n(B)}})}return{type:"FeatureCollection",features:g}}function c(u,h){if(u.length<2)return l();const g=u.map(C=>[C.coords.lng,C.coords.lat]);return h&&g.push(g[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:g},properties:{}}]}}function i(u){if(u.length<3)return l();const h=u.map(g=>[g.coords.lng,g.coords.lat]);return h.push(h[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[h]},properties:{}}]}}let d=!1;function p(u){u.getSource(Pe)||(u.addSource(Pe,{type:"geojson",data:l()}),u.addLayer({id:`${Pe}-circle`,type:"circle",source:Pe,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),u.addLayer({id:`${Pe}-labels`,type:"symbol",source:Pe,layout:{"text-field":["get","label"],"text-size":14,"text-offset":[0,1.3]},paint:{"text-color":"#0f172a","text-halo-color":"#ffffff","text-halo-width":1}})),u.getSource(it)||(u.addSource(it,{type:"geojson",data:l()}),u.addLayer({id:`${it}-labels`,type:"symbol",source:it,layout:{"text-field":["get","distance"],"text-size":13,"symbol-placement":"line-center","text-rotation-alignment":"map","text-pitch-alignment":"map"},paint:{"text-color":"#1e293b","text-halo-color":"#ffffff","text-halo-width":1.5}})),u.getSource(at)||(u.addSource(at,{type:"geojson",data:l()}),u.addLayer({id:`${at}-layer`,type:"line",source:at,paint:{"line-color":"#3b82f6","line-width":2}})),u.getSource(st)||(u.addSource(st,{type:"geojson",data:l()}),u.addLayer({id:`${st}-layer`,type:"fill",source:st,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function m(u){if(u){try{u.getLayer(`${st}-layer`)&&u.removeLayer(`${st}-layer`),u.getSource(st)&&u.removeSource(st),u.getLayer(`${at}-layer`)&&u.removeLayer(`${at}-layer`),u.getSource(at)&&u.removeSource(at),u.getLayer(`${it}-labels`)&&u.removeLayer(`${it}-labels`),u.getSource(it)&&u.removeSource(it),u.getLayer(`${Pe}-labels`)&&u.removeLayer(`${Pe}-labels`),u.getLayer(`${Pe}-circle`)&&u.removeLayer(`${Pe}-circle`),u.getSource(Pe)&&u.removeSource(Pe)}catch{}d=!1}}function x(u){if(!u)return;const h=u.getSource(Pe),g=u.getSource(at),C=u.getSource(st),w=u.getSource(it),b=o.points,k=o.labelMode??"general";h&&h.setData(a(b,o.isShapeClosed,k)),g&&g.setData(c(b,o.isShapeClosed)),C&&C.setData(i(b)),w&&w.setData(k==="topoint"?s(b,o.isShapeClosed):l())}function f(){const u=o.map;u&&(d||p(u),x(u))}return e.watch(()=>[o.points,o.isShapeClosed,o.labelMode],()=>f(),{deep:!0,immediate:!0}),e.watch(()=>o.map,()=>f(),{immediate:!0}),e.onBeforeUnmount(()=>{m(o.map)}),(u,h)=>null}});function ac(r={}){const t=e.ref(!1),n=e.ref([]),o=e.ref(!1),l=e.ref("general"),a=e.ref(null);function s(){t.value?c():(t.value=!0,r.onActivate?.())}function c(){t.value=!1,n.value=[],o.value=!1,a.value?.clearPoints(),r.onDeactivate?.()}function i(f){n.value=f}function d(f){l.value=f}function p(f){o.value=f}function m(f){t.value&&a.value?.addPoint({lat:f.lat,lng:f.lng})}const x=e.computed(()=>n.value.length>0);return{isRulerActive:t,rulerPoints:n,rulerShapeClosed:o,rulerActiveTab:l,rulerPanelRef:a,hasRulerPoints:x,toggleRuler:s,closeRuler:c,onRulerPointsChange:i,onRulerTabChange:d,onRulerShapeClosedChange:p,handleRulerMapClick:m}}const wt=1e-10,Gt=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,sc=/^[+-]?\d+(?:\.\d+)?$/;function ic(r,t,n){const o=r.split(/\r?\n/).map(d=>d.trim()).filter(Boolean);if(o.length<3)return{ok:!1,errors:[{line:0,message:"Має бути щонайменше 3 рядки координат."}]};if(o.length>100)return{ok:!1,errors:[{line:0,message:"Допускається не більше 100 рядків координат."}]};const l=[],a=[];if(o.forEach((d,p)=>{const m=p+1,x=t==="decimal"?cc(d,m,n):dc(d,m,n);if(!x.ok){l.push(...x.errors);return}const f=a[a.length-1];if(f&&pr(f,x.point)){l.push({line:m,message:"Послідовні точки не повинні дублюватися."});return}a.push(x.point)}),l.length)return{ok:!1,errors:l};if(new Set(a.map(uc)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const c=[...a];let i=!1;return pr(c[0],c[c.length-1])||(c.push(c[0]),i=!0),pc(c)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:c,wasClosedAutomatically:i}}function cc(r,t,n){const o=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(r))return{ok:!1,errors:[{line:t,message:"У десятковому форматі не допускаються літери."}]};const l=r.split(/[\s,;]+/).filter(Boolean);if(l.length<2)return{ok:!1,errors:[{line:t,message:"Кожен рядок має містити дві координати."}]};if(l.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(!l.every(d=>sc.test(d)))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const a=Number(l[0]),s=Number(l[1]);if(!Number.isFinite(a)||!Number.isFinite(s))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const c=n==="lat-lon"?a:s,i=n==="lat-lon"?s:a;return(c<-90||c>90)&&o.push({line:t,message:"Широта поза діапазоном (-90..90)."}),(i<-180||i>180)&&o.push({line:t,message:"Довгота поза діапазоном (-180..180)."}),o.length?{ok:!1,errors:o}:{ok:!0,point:[i,c]}}function dc(r,t,n){Gt.lastIndex=0;const o=[...r.matchAll(Gt)];if(o.length<2)return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати DMS-координати."}]};if(o.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(Gt.lastIndex=0,r.replace(Gt," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:t,message:"У рядку виявлено зайві символи або значення."}]};const a=ur(o[0],t,n==="lat-lon"?"lat":"lon"),s=ur(o[1],t,n==="lat-lon"?"lon":"lat"),c=[];if(a.ok||c.push(a.error),s.ok||c.push(s.error),c.length)return{ok:!1,errors:c};const i=n==="lat-lon"?a.value:s.value;return{ok:!0,point:[n==="lat-lon"?s.value:a.value,i]}}function ur(r,t,n){const o=Number(r[1]),l=Number(r[2]),a=Number(r[3]),s=String(r[4]).toUpperCase();if(!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(a))return{ok:!1,error:{line:t,message:"Невірні значення DMS-координат."}};if(n==="lat"&&!(s==="N"||s==="S")||n==="lon"&&!(s==="E"||s==="W"))return{ok:!1,error:{line:t,message:n==="lat"?"Для широти напрям повинен бути N або S.":"Для довготи напрям повинен бути E або W."}};if(l<0||l>59)return{ok:!1,error:{line:t,message:"Хвилини повинні бути в діапазоні 0..59."}};if(a<0||a>59)return{ok:!1,error:{line:t,message:"Секунди повинні бути в діапазоні 0..59."}};const d=Math.abs(o),p=n==="lat"?90:180;if(d>p)return{ok:!1,error:{line:t,message:n==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===p&&(l!==0||a!==0))return{ok:!1,error:{line:t,message:n==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const m=d+l/60+a/3600;return{ok:!0,value:s==="S"||s==="W"?-m:m}}function uc(r){return`${r[0].toFixed(12)}:${r[1].toFixed(12)}`}function pr(r,t){return Math.abs(r[0]-t[0])<wt&&Math.abs(r[1]-t[1])<wt}function pc(r){if(r.length<4)return!1;for(let t=0;t<r.length-1;t+=1){const n=r[t],o=r[t+1];for(let l=t+1;l<r.length-1;l+=1){if(Math.abs(t-l)<=1||t===0&&l===r.length-2)continue;const a=r[l],s=r[l+1];if(fc(n,o,a,s))return!0}}return!1}function fc(r,t,n,o){const l=Wt(r,t,n),a=Wt(r,t,o),s=Wt(n,o,r),c=Wt(n,o,t);return!!(l!==a&&s!==c||l===0&&Yt(r,n,t)||a===0&&Yt(r,o,t)||s===0&&Yt(n,r,o)||c===0&&Yt(n,t,o))}function Wt(r,t,n){const o=(t[1]-r[1])*(n[0]-t[0])-(t[0]-r[0])*(n[1]-t[1]);return Math.abs(o)<wt?0:o>0?1:2}function Yt(r,t,n){return t[0]<=Math.max(r[0],n[0])+wt&&t[0]+wt>=Math.min(r[0],n[0])&&t[1]<=Math.max(r[1],n[1])+wt&&t[1]+wt>=Math.min(r[1],n[1])}const mc={key:0,class:"absolute top-4 left-4 z-[1000] w-[calc(100%-20px)] sm:w-[350px]"},hc={key:1,class:"form-geom__panel flex gap-1 items-start mt-2"},gc={class:"flex items-center gap-1"},yc=["disabled"],bc={key:0,class:"absolute z-[1600] mt-1 min-w-[120px] bg-white border border-gray-300 shadow-lg rounded-lg text-sm overflow-hidden"},kc=["disabled"],xc=["disabled"],wc={class:"mt-4 flex justify-end gap-2"},_c=["disabled"],Cc={class:"absolute top-4 right-4 z-[1000]"},vc={class:"flex flex-col gap-[2px]"},Ec=["disabled"],Bc=["disabled"],Vc=["disabled"],Sc=["disabled"],$c={class:"bg-white/95 border border-gray-200 rounded-md shadow-xl px-3 py-2 max-w-[240px] text-[11px] sm:text-xs text-gray-900"},Nc={class:"space-y-0.5"},Ac={class:"text-gray-500"},Fc={class:"text-gray-900 text-right break-all"},Dc={class:"absolute left-4 bottom-[36px] z-[1000]"},Mc={class:"flex flex-col gap-2"},Lc={key:0,class:"bg-white/95 border border-gray-200 rounded-md shadow-sm px-3 py-2 text-xs text-gray-700 min-w-[200px]"},Tc={class:"flex flex-col gap-1"},Ic=["checked","disabled","onChange"],Rc={class:"text-gray-700 text-xs font-medium"},Oc={class:"absolute bottom-0 left-0 right-0 z-[1000] min-h-[28px] bg-white/95 border-t border-gray-200 text-xs text-gray-700 flex items-center gap-4 pt-1"},zc={key:0,class:"form-geom__feature flex items-center text-xs transition-all gap-2 w-full px-2 pb-1"},Pc={class:"mr-auto flex items-center gap-2 min-w-0 relative"},jc={class:"shrink-0"},Uc={class:"font-bold"},Hc={class:"flex items-center"},qc={class:"text-xs mr-2"},Kc={key:0,class:"text-xs mr-2"},Gc={key:1,class:"text-xs mr-2"},Wc=["disabled"],Yc=["disabled"],Zt="__vs_form_maplibre_loader__",Xt="vs-global-bounds-src",Jt="vs-global-bounds-line",fr=fe(e.defineComponent({__name:"vs-input-map",props:{tools:{},handleZoom:{type:Boolean,default:!0},ctrlZoom:{type:Boolean,default:!0},geomType:{default:()=>[]},prefix:{default:""},katottg:{default:""},layers:{default:()=>[]},bounds:{},api:{},center:{default:void 0},zoom:{default:void 0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue","valueSelected"],setup(r,{emit:t}){const n=r,o=t,l=e.useAttrs(),a=e.computed(()=>!!n.disabled),s=e.ref(!1),c=e.ref(null),i=e.ref(0),d=e.ref(""),p=e.ref(null),m=e.ref(null),x=e.ref(null),f=ac({onActivate(){if(V)try{V.changeMode("simple_select",{featureIds:[]})}catch{}d.value=""},onDeactivate(){}});function u(){f.toggleRuler()}const h=e.getCurrentInstance(),g=h?.appContext?.config?.globalProperties?.$settings??{},C=g?.map??{},w=h?.vnode?.props??{};function b(y){return Object.prototype.hasOwnProperty.call(w,y)||Object.prototype.hasOwnProperty.call(w,y.replace(/[A-Z]/g,_=>`-${_.toLowerCase()}`))}const k=Array.isArray(C.center)&&C.center.length===2?C.center:Array.isArray(g.center)&&g.center.length===2?g.center:[30,50],B=typeof C.zoom=="number"?C.zoom:typeof g.zoom=="number"?g.zoom:typeof g.defaultZoom=="number"?g.defaultZoom:10,M=e.computed(()=>b("center")?n.center:C.center??n.center),$=e.computed(()=>b("zoom")?n.zoom:C.zoom??n.zoom),E=e.computed(()=>b("katottg")?String(n.katottg??""):String(C.katottg??n.katottg??"")),N=e.computed(()=>b("layers")?n.layers??[]:C.layers??n.layers??[]),v=e.computed(()=>b("bounds")?n.bounds:C.bounds??n.bounds),S=e.ref(Array.isArray(M.value)&&M.value.length===2?[...M.value]:k),D=e.ref(typeof $.value=="number"?$.value:B),I=e.ref(n.modelValue),A=e.ref(null),T=e.ref(null),L=e.ref([]),U=e.ref(!1),H=e.ref(!1),W=e.ref([]),Q=e.reactive({coordinates:"",format:"decimal",order:"lat-lon"}),ve={coordinates:{type:"Textarea",label:"Координати вершин полігону (3-100 точок)",placeholder:`50.4501, 30.5234
|
|
2
|
+
`)});return}T==="add"?Array.isArray(s.value)?s.value=[...s.value,W.value]:s.value=[W.value]:s.value=s.value.map((Y,J)=>J===L?W.value:Y),A.value=!1}function Le(j){s.value=s.value.filter((Y,J)=>J!==j)}function Je(){A.value=!1}return(j,Y)=>(e.openBlock(),e.createElementBlock("div",us,[a.value?(e.openBlock(),e.createElementBlock("div",ps,[o("search")?(e.openBlock(),e.createElementBlock("div",fs,[e.createVNode(e.unref(z.Search),{class:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":Y[0]||(Y[0]=J=>i.value=J),placeholder:"Пошук",class:"w-full rounded-md border border-gray-200 bg-white pl-10 pr-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100"},null,512),[[e.vModelText,i.value]])])):e.createCommentVNode("",!0),e.createElementVNode("div",ms,[o("import")?(e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"fileInput",ref:h,onChange:B,class:"hidden",accept:".json",type:"file"},null,544)):e.createCommentVNode("",!0),o("import")?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",onClick:b,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(z.Upload),{class:"h-4 w-4 text-gray-700"}),Y[4]||(Y[4]=e.createTextVNode(" Імпорт ",-1))])):e.createCommentVNode("",!0),o("export")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:M,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(z.Download),{class:"h-4 w-4 text-gray-700"}),Y[5]||(Y[5]=e.createTextVNode(" Експорт ",-1))])):e.createCommentVNode("",!0),o("add")?(e.openBlock(),e.createElementBlock("button",{key:3,onClick:ye,type:"button",class:"inline-flex items-center gap-2 rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-600 transition-colors"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4 text-white"}),Y[6]||(Y[6]=e.createTextVNode(" Додати ",-1))])):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",hs,[e.createElementVNode("table",gs,[e.createElementVNode("thead",ys,[e.createElementVNode("tr",bs,[e.createElementVNode("th",ks,[e.createVNode(e.unref(z.GripVertical),{class:"mx-auto h-4 w-4 text-gray-400"})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,J=>(e.openBlock(),e.createElementBlock("th",{key:J.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[e.createElementVNode("button",{type:"button",onClick:oe=>ce(J),class:"flex items-center gap-1 text-xs font-semibold text-gray-700 hover:text-gray-900 transition-colors"},[e.createElementVNode("span",null,e.toDisplayString(J.ua||J.label),1),d.value===(J.key||J.name)?(e.openBlock(),e.createElementBlock("span",ws,e.toDisplayString(p.value==="asc"?"▲":"▼"),1)):e.createCommentVNode("",!0)],8,xs)]))),128)),Y[7]||(Y[7]=e.createElementVNode("th",{class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 text-center w-[1%] whitespace-nowrap"}," Дії ",-1))])]),e.createElementVNode("tbody",{class:e.normalizeClass(["divide-y divide-gray-200",{"[&_tr:last-child]:border-0":!u.value}])},[m.value.length===0?(e.openBlock(),e.createElementBlock("td",_s,[e.createElementVNode("div",Cs,[e.createElementVNode("div",vs,[e.createVNode(ds,{class:"w-48 mx-auto"}),Y[8]||(Y[8]=e.createElementVNode("div",{class:"max-w-sm mx-auto mt-6"},[e.createElementVNode("p",{class:"font-medium text-gray-800 dark:text-neutral-200"},"Нічого не знайдено"),e.createElementVNode("p",{class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"})],-1))])])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(J,oe)=>(e.openBlock(),e.createElementBlock("tr",{key:J.id,class:e.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":f.value===oe,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":u.value===oe}]),draggable:"true",onDragstart:ae=>g(oe),onDragover:e.withModifiers(ae=>C(oe),["prevent"]),onDrop:ae=>w(oe)},[e.createElementVNode("td",Bs,[e.createElementVNode("div",Vs,[e.createVNode(e.unref(z.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,ae=>(e.openBlock(),e.createElementBlock("td",{key:ae.key,class:"px-4 py-3 align-middle"},[U(ae)==="slot"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[ve(ae.slot)?e.renderSlot(j.$slots,ae.slot,{key:0,row:J,value:J[ae.key],column:ae}):(e.openBlock(),e.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:G(ae.slot,J)},null,8,Ss))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[U(ae)==="file"?(e.openBlock(),e.createElementBlock("div",$s,[k(Me(J,ae))?(e.openBlock(),e.createElementBlock("div",Ns,[e.createElementVNode("img",{src:Me(J,ae),alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,As)])):(e.openBlock(),e.createElementBlock("div",Fs,[e.createVNode(e.unref(z.FileText),{class:"h-4 w-4 min-w-4"})]))])):U(ae)==="color"?(e.openBlock(),e.createElementBlock("div",Ds,[e.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:e.normalizeStyle({backgroundColor:Me(J,ae)||"#ffffff"})},null,4)])):(e.openBlock(),e.createElementBlock("div",Ms,e.toDisplayString(Me(J,ae)),1))],64))]))),128)),e.createElementVNode("td",Ls,[e.createElementVNode("div",Ts,[e.createElementVNode("button",{onClick:ae=>we(J,oe),class:"p-1.5 text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors"},[e.createVNode(e.unref(z.Pencil),{class:"h-4 w-4"})],8,Is),e.createElementVNode("button",{onClick:ae=>Le(oe),class:"p-1.5 text-gray-600 hover:text-red-600 hover:bg-red-50 rounded transition-colors"},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,Rs)])])],42,Es))),128))],2)])]),e.createVNode(e.unref(me.VsModal),{visible:A.value,title:I.value,size:"lg",onClose:Je,teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(Ye,{schema:H.value,values:W.value,"onUpdate:values":Y[1]||(Y[1]=J=>W.value=J),form:Q.value,"onUpdate:form":Y[2]||(Y[2]=J=>Q.value=J)},null,8,["schema","values","form"]),e.createElementVNode("div",Os,[e.createElementVNode("button",{type:"button",onClick:Y[3]||(Y[3]=J=>A.value=!1),class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:Xe,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])]),_:1},8,["visible","title"])]))}}),zs={},Ps={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","stroke-width":"2",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-line"};function js(r,t){return e.openBlock(),e.createElementBlock("svg",Ps,t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M6 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M18 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M7.5 16.5l9 -9"},null,-1)]))}const Us=fe(zs,[["render",js]]),Hs={},qs={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-polygon"};function Ks(r,t){return e.openBlock(),e.createElementBlock("svg",qs,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M6.5 9.5l3.5 -3"></path><path d="M14 5.5l3 1.5"></path><path d="M18.5 10l-2.5 7"></path><path d="M13.5 17.5l-7 -5"></path>',9)]))}const Gs=fe(Hs,[["render",Ks]]),Ws={},Ys={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-topology-ring-3"};function Zs(r,t){return e.openBlock(),e.createElementBlock("svg",Ys,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M8 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M8 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M6 8v8"></path><path d="M18 16v-8"></path><path d="M8 6h8"></path><path d="M16 18h-8"></path>',9)]))}const Xs=fe(Ws,[["render",Zs]]),Js={class:"bg-white/30 p-1 rounded-md shadow w-fit"},Qs={class:"flex gap-2"},ei=["onClick","title"],ti=["src"],ni=e.defineComponent({__name:"map-layers",props:{basemaps:{}},emits:["onLayerChange"],setup(r,{emit:t}){const n=r,o=e.ref(Object.keys(n.basemaps)[0]),l=t;function a(i){l("onLayerChange",i),o.value=i}const s={z:13,x:4790,y:2762};function c(i){if(i?.preview)return i.preview;if(!i?.url)return;const d={"{z}":s.z,"{x}":s.x,"{y}":s.y};let p=i.url;return Object.entries(d).forEach(([m,x])=>{p=p.replace(new RegExp(m,"gi"),String(x))}),p}return(i,d)=>(e.openBlock(),e.createElementBlock("div",Js,[e.createElementVNode("div",Qs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.basemaps,(p,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:e.normalizeClass(["cursor-pointer border rounded-lg overflow-hidden hover:shadow-sm",{"ring-2 ring-blue-500 border-blue-300":o.value===m}]),onClick:x=>a(m),title:p.name||m,role:"button",tabindex:"0"},[e.createElementVNode("img",{src:c(p),alt:"",class:"w-10 h-10 object-cover"},null,8,ti)],10,ei))),128))])]))}}),ri={class:"map-search-widget flex flex-col gap-2 rounded-xl widget min-w-[200px]"},oi={key:0,class:"vs-select__options absolute z-50 mt-1 w-full bg-white border border-gray-300 shadow-lg rounded-lg text-sm"},li=["onClick"],ai={class:"relative flex-1 min-w-[140px]"},si=["placeholder"],ii={type:"submit",class:"absolute inset-y-0 right-2 flex items-center text-gray-400 hover:text-gray-600","aria-label":"Пошук"},ci="https://data.softpro.ua/api-user/gis-url-proxy",di="https://geo.rv.ua/api-user/dzk.api",ui=fe(e.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(r,{emit:t}){const n=r,o=t,l=["here","xy","parcel"],a=e.computed(()=>{const k=n.config?.tools?.filter(B=>l.includes(B));return k&&k.length?k:l}),s=e.computed(()=>n.config?.placeholder?.trim()||"Пошук…"),c=e.ref(a.value[0]??l[0]);e.watch(a,k=>{k.includes(c.value)||(c.value=k[0])});const i=e.ref(""),d=e.ref(!1),p=e.ref(null);e.watch(c,()=>{i.value="",d.value=!1});function m(k){c.value=k}function x(k){if(!d.value)return;const B=p.value;B&&!B.contains(k.target)&&(d.value=!1)}e.onMounted(()=>{window.addEventListener("click",x,!0)}),e.onBeforeUnmount(()=>{window.removeEventListener("click",x,!0)});function f(k){return k==="xy"?"Координати":k==="parcel"?"Кадастр":"Адреси"}function u(k){const B=k.replace(/[,]+/g," ").trim();if(!B)return null;const M=B.split(/\s+/).filter(Boolean);if(M.length<2)return null;const $=M.slice(0,2).map(Number);if(!$.every(A=>Number.isFinite(A)))return null;const[E,N]=$;let v=E,S=N;const D=A=>Math.abs(A)<=90,I=A=>Math.abs(A)<=180;if(!D(v)||!I(S))if(D(S)&&I(v))v=N,S=E;else return null;return{lat:v,lng:S}}function h(k){return(k?.items||[]).map((M,$)=>({id:String(M?.id??$),title:M?.title||M?.address?.label||"Знайдений обʼєкт",lat:Number(M?.position?.lat),lng:Number(M?.position?.lng)})).filter(M=>Number.isFinite(M.lat)&&Number.isFinite(M.lng))}function g(k){const B=k?.result||k?.data||k;if(!B)return[];const M=B.geom_centroid;if(!M||!Array.isArray(M.coordinates))return[];const[$,E]=M.coordinates;return!Number.isFinite(E)||!Number.isFinite($)?[]:[{id:"parcel",title:B.cadnum||B.cad_num||"Земельна ділянка",lat:E,lng:$}]}function C(k){const M=k.replace(/\s+/g,"").split(":");if(M.length!==4)return!1;const $=[10,2,3,4];return M.every((E,N)=>E.length===$[N]&&/^\d+$/.test(E))}function w(k){o("goToCoordinates",[k.lat,k.lng])}async function b(){const k=i.value.trim();if(k){if(c.value==="xy"){const B=u(k);if(!B){me.notify({type:"warning",title:"Пошук координат",message:"Не знайдено або невірний формат координат"});return}w(B),i.value="";return}try{const B=new URL(c.value==="here"?ci:di);if(c.value==="here")B.searchParams.set("searchtext",k);else{if(!C(k)){me.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}B.searchParams.set("cad_num",k)}const M=await fetch(B.toString());if(!M.ok)throw new Error(`HTTP ${M.status}`);const $=await M.json(),E=c.value==="here"?h($):g($);if(!E.length)me.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const N=E[0];w(N),i.value=""}}catch(B){const M=B?.message||"Помилка пошуку";me.notify({type:"error",title:"Пошук",message:M})}}}return(k,B)=>(e.openBlock(),e.createElementBlock("div",ri,[e.createElementVNode("form",{class:"flex gap-2",onSubmit:e.withModifiers(b,["prevent"])},[a.value.length>1?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"relative search-type w-[140px]"},[e.createElementVNode("button",{type:"button",class:"vstSelect-input transition-all text-left bg-white border border-gray-200 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-100 block w-full py-1.5 px-3 text-sm cursor-pointer flex items-center justify-between gap-2",onClick:B[0]||(B[0]=M=>d.value=!d.value)},[e.createElementVNode("span",null,e.toDisplayString(f(c.value)),1),e.createVNode(e.unref(z.ChevronDown),{class:e.normalizeClass(["h-4 w-4 text-gray-500 transition-transform",{"rotate-180":d.value}])},null,8,["class"])]),d.value?(e.openBlock(),e.createElementBlock("div",oi,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,M=>(e.openBlock(),e.createElementBlock("li",{key:M,class:"px-3 py-2 cursor-pointer hover:bg-gray-100",onClick:$=>m(M)},e.toDisplayString(f(M)),9,li))),128))])])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",ai,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[1]||(B[1]=M=>i.value=M),placeholder:s.value,type:"text",class:"vs-input transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid !pr-8 py-1.5 pl-3 text-sm"},null,8,si),[[e.vModelText,i.value,void 0,{trim:!0}]]),e.createElementVNode("button",ii,[e.createVNode(e.unref(z.Search),{class:"h-4 w-4"})])])],32)]))}}),[["__scopeId","data-v-2b66205f"]]),pi={class:"pt-1 border-t border-gray-100"},fi={class:"space-y-1"},mi=e.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(r,{emit:t}){const n=t,o=e.ref(null),l=e.ref(null),a=(i,d,p)=>Math.min(Math.max(i,d),p),s=()=>{if(o.value===null||l.value===null||!Number.isFinite(o.value)||!Number.isFinite(l.value))return;const i=a(o.value,-90,90),d=a(l.value,-180,180);n("submit",{lat:i,lng:d}),o.value=null,l.value=null},c=()=>{o.value=null,l.value=null,n("cancel")};return(i,d)=>(e.openBlock(),e.createElementBlock("div",pi,[d[2]||(d[2]=e.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),e.createElementVNode("div",fi,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[0]||(d[0]=p=>o.value=p),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта (50.4501)"},null,512),[[e.vModelText,o.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=p=>l.value=p),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота (30.5234)"},null,512),[[e.vModelText,l.value,void 0,{number:!0}]]),e.createElementVNode("div",{class:"flex gap-1.5"},[e.createElementVNode("button",{class:"flex-1 px-2 py-1 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors",type:"button",onClick:s}," Додати "),e.createElementVNode("button",{class:"px-2 py-1 bg-gray-200 hover:bg-gray-300 text-gray-700 text-xs font-medium rounded transition-colors",type:"button",onClick:c}," Скасувати ")])])]))}}),hi=e.defineComponent({__name:"BtnAdd",emits:["click"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=o=>t.$emit("click"))},[e.createVNode(e.unref(z.Plus),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Додати ",-1))]))}}),gi=e.defineComponent({__name:"BtnClear",emits:["click"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"w-full px-2 py-1.5 bg-rose-500 hover:bg-rose-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=o=>t.$emit("click"))},[e.createVNode(e.unref(z.Trash2),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Очистити ",-1))]))}}),yi=e.defineComponent({__name:"BtnComplete",emits:["click"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=o=>t.$emit("click"))},[e.createVNode(e.unref(z.Circle),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode("Замкнути ",-1))]))}}),bi=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function xt(r){return bi.format(r)}function dr(r){return r>=1e3?`${xt(r/1e3)} км`:`${xt(r)} м`}const ki={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},xi={key:0,class:"flex-1 flex gap-1"},wi={key:1,class:"flex-1 font-mono text-gray-700"},_i=e.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(r,{emit:t}){const n=r,o=t,l=e.computed(()=>`${n.coords.lat.toFixed(4)}°, ${n.coords.lng.toFixed(4)}°`),a=e.ref(!1),s=e.ref(n.coords.lat),c=e.ref(n.coords.lng);e.watch(()=>n.coords,x=>{s.value=x.lat,c.value=x.lng},{deep:!0,immediate:!0});const i=(x,f,u)=>Math.min(Math.max(x,f),u),d=()=>{a.value=!0},p=()=>{if(!Number.isFinite(s.value)||!Number.isFinite(c.value))return;const x=i(s.value,-90,90),f=i(c.value,-180,180);o("update",{id:n.id,coords:{lat:x,lng:f}}),a.value=!1},m=()=>{o("delete",n.id)};return(x,f)=>(e.openBlock(),e.createElementBlock("div",ki,[e.createVNode(e.unref(z.MapPin),{size:12,"stroke-width":2,class:"text-gray-400 flex-shrink-0"}),a.value?(e.openBlock(),e.createElementBlock("div",xi,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[0]||(f[0]=u=>s.value=u),type:"number",step:"0.0001",min:"-90",max:"90",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=u=>c.value=u),type:"number",step:"0.0001",min:"-180",max:"180",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота"},null,512),[[e.vModelText,c.value,void 0,{number:!0}]]),e.createElementVNode("button",{class:"px-1.5 py-0.5 bg-emerald-500 text-white rounded hover:bg-emerald-600 text-xs",type:"button",onClick:p}," ✓ ")])):(e.openBlock(),e.createElementBlock("span",wi,e.toDisplayString(l.value),1)),a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"text-blue-500 hover:text-blue-600 px-0.5",type:"button",onClick:d}," ✎ ")),e.createElementVNode("button",{class:"text-rose-500 hover:text-rose-600 px-0.5",type:"button",onClick:m}," ✕ ")]))}}),Ci={class:"ruler-control px-3 py-2.5 space-y-2"},vi={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},Ei={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Сумарна довжина всіх відрізків","aria-hidden":"true"},Bi={class:"text-sm font-semibold text-slate-700"},Vi={class:"ruler-row"},Si={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},$i={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Площа замкнутого контуру","aria-hidden":"true"},Ni={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},Ai=["onClick"],Fi={class:"flex items-center gap-2 mt-0.5 pl-7"},Di={key:0,class:"text-base font-semibold text-green-600"},Mi={key:1,class:"text-xs text-gray-400"},Li={class:"ruler-row flex items-center gap-2 cursor-pointer"},Ti={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Список точок","aria-hidden":"true"},Ii={class:"text-xs font-medium text-gray-600 flex-1"},Ri={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},Oi=e.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(r){const t=r,n=e.ref(!1),o=e.ref("km2"),l=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],a=()=>{n.value=!n.value},s=(u,h)=>{const g=N=>N*Math.PI/180,C=g(h.lat-u.lat),w=g(h.lng-u.lng),b=g(u.lat),k=g(h.lat),B=Math.sin(C/2),M=Math.sin(w/2);return 6371e3*(2*Math.asin(Math.sqrt(B*B+Math.cos(b)*Math.cos(k)*M*M)))},c=e.computed(()=>{if(t.points.length<2)return 0;let u=0;for(let h=1;h<t.points.length;h+=1)u+=s(t.points[h-1].coords,t.points[h].coords);return t.isShapeClosed&&t.points.length>=2&&(u+=s(t.points[t.points.length-1].coords,t.points[0].coords)),u}),i=e.computed(()=>c.value>=1e3?`${xt(c.value/1e3)} км`:`${xt(c.value)} м`);function d(u){if(u.length<3)return 0;const h=u[0].lat,g=u[0].lng,C=(b,k)=>{const B=(b-h)*110574;return{x:(k-g)*111320*Math.cos(h*Math.PI/180),y:B}};let w=0;for(let b=0;b<u.length;b++){const k=(b+1)%u.length,B=C(u[b].lat,u[b].lng),M=C(u[k].lat,u[k].lng);w+=B.x*M.y-B.y*M.x}return Math.abs(w)*.5}const p=e.computed(()=>{if(!t.isShapeClosed||t.points.length<3)return 0;const u=t.points.map(h=>h.coords);return d(u)}),m=e.computed(()=>p.value>0),x=e.computed(()=>{const u=p.value;if(u===0)return"—";if(o.value==="km2"){const g=u/1e6;return`${xt(g)} км²`}if(o.value==="ha"){const g=u/1e4;return`${xt(g)} га`}const h=u>=1?Math.round(u):u;return`${xt(h)} м²`}),f=e.computed(()=>{const u=t.points.length;return u===1?"1 точка":u>=2&&u<=4?`${u} точки`:`${u} точок`});return e.watch(()=>t.points.length,()=>{t.points.length===0&&(n.value=!1)}),(u,h)=>(e.openBlock(),e.createElementBlock("div",Ci,[e.createElementVNode("button",vi,[e.createElementVNode("span",Ei,[e.createVNode(e.unref(z.Info),{size:12,"stroke-width":2.5})]),h[1]||(h[1]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),e.createElementVNode("span",Bi,e.toDisplayString(i.value),1)]),e.createElementVNode("div",Vi,[e.createElementVNode("button",Si,[e.createElementVNode("span",$i,[e.createVNode(e.unref(z.Info),{size:12,"stroke-width":2.5})]),h[2]||(h[2]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),e.createElementVNode("div",Ni,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,(g,C)=>e.createElementVNode("button",{key:g.id,type:"button",class:e.normalizeClass(["px-2.5 py-1 text-xs font-medium transition-colors border-r border-gray-200 last:border-r-0",C===0&&"rounded-l-md",C===l.length-1&&"rounded-r-md",o.value===g.id?"bg-white text-green-600 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-50"]),onClick:e.withModifiers(w=>o.value=g.id,["stop"])},e.toDisplayString(g.label),11,Ai)),64))])]),e.createElementVNode("div",Fi,[m.value?(e.openBlock(),e.createElementBlock("span",Di,e.toDisplayString(x.value),1)):(e.openBlock(),e.createElementBlock("span",Mi,"—"))])]),e.createElementVNode("div",Li,[e.createElementVNode("span",Ti,[e.createVNode(e.unref(z.Info),{size:12,"stroke-width":2.5})]),e.createElementVNode("span",Ii,e.toDisplayString(f.value),1),e.createElementVNode("button",{type:"button",class:"text-xs text-blue-500 hover:text-blue-600 font-medium transition-colors",onClick:e.withModifiers(a,["stop"])}," Координати ")]),n.value?(e.openBlock(),e.createElementBlock("div",Ri,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.points,(g,C)=>(e.openBlock(),e.createBlock(_i,{key:g.id,id:g.id,index:C+1,coords:g.coords,onUpdate:h[0]||(h[0]=w=>u.$emit("update-point",w)),onDelete:w=>u.$emit("delete-point",g.id)},null,8,["id","index","coords","onDelete"]))),128))])):e.createCommentVNode("",!0)]))}}),zi={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},Pi={class:"flex items-start gap-2"},ji=e.defineComponent({__name:"InfoHint",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("div",zi,[e.createElementVNode("div",Pi,[e.createVNode(e.unref(z.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),n[0]||(n[0]=e.createElementVNode("div",{class:"space-y-1"},[e.createElementVNode("p",{class:"text-xs font-medium text-blue-900"}," Натискайте на карту, щоб додати точки вимірювання "),e.createElementVNode("p",{class:"text-[10px] text-blue-700"},' Або скористайтесь кнопкою "Додати" внизу для введення координат вручну ')],-1))])]))}}),Ui={class:"space-y-1.5"},Hi={class:"space-y-1 max-h-40 overflow-y-auto"},qi={class:"text-gray-700"},Ki={class:"font-semibold text-slate-800"},Gi=e.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(r){const t=r;function n(a,s){const c=f=>f*Math.PI/180,i=c(s.lat-a.lat),d=c(s.lng-a.lng),p=c(a.lat),m=c(s.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(i/2)**2+Math.cos(p)*Math.cos(m)*Math.sin(d/2)**2)))}function o(a){return dr(a)}const l=e.computed(()=>{const a=[],s=t.points;if(s.length<2)return a;for(let c=0;c<s.length;c++){const i=c===s.length-1&&t.isShapeClosed?0:c+1;if(i>=s.length)break;const d=n(s[c].coords,s[i].coords);a.push({from:c+1,to:i+1,label:o(d)})}return a});return(a,s)=>(e.openBlock(),e.createElementBlock("div",Ui,[s[0]||(s[0]=e.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),e.createElementVNode("div",Hi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(c,i)=>(e.openBlock(),e.createElementBlock("div",{key:i,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[e.createElementVNode("span",qi,"Точка "+e.toDisplayString(c.from)+" → Точка "+e.toDisplayString(c.to),1),e.createElementVNode("span",Ki,e.toDisplayString(c.label),1)]))),128))])]))}}),Wi={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},Yi={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},Zi={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},Xi={class:"flex items-center gap-2"},Ji={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},Qi={class:"flex border-b border-gray-200"},ec={key:1,class:"px-3 py-2.5"},tc={key:1,class:"text-xs text-gray-500"},nc={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},rc={class:"flex gap-1.5"},oc=e.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(r,{expose:t,emit:n}){const o=n,l=e.ref([]),a=e.computed(()=>l.value.length>0),s=e.ref(!1),c=e.ref(!1),i=e.ref("general");function d(v){i.value=v,o("tab-change",v)}e.onMounted(()=>{o("tab-change",i.value)});const p=e.computed(()=>l.value.length>=3&&!c.value);let m=1;const x=()=>l.value.map(v=>({id:v.id,coords:{...v.coords}})),f=()=>{l.value.length<3&&c.value&&(c.value=!1,o("shape-closed-change",!1)),o("points-change",x())},u=()=>{const v=m;return m+=1,v},h=v=>{l.value=[...l.value,{id:u(),coords:{lat:v.lat,lng:v.lng}}],f()},g=({id:v,coords:S})=>{const D=l.value.findIndex(A=>A.id===v);if(D===-1)return;const I=[...l.value];I[D]={id:v,coords:{...S}},l.value=I,f()},C=v=>{l.value=l.value.filter(S=>S.id!==v),f()},w=()=>{l.value=[],c.value&&(c.value=!1,o("shape-closed-change",!1)),f()},b=v=>{g(v)},k=v=>{C(v)},B=()=>{s.value=!0,o("add-request")},M=v=>{h(v),s.value=!1},$=()=>{s.value=!1},E=()=>{p.value&&(c.value=!0,o("complete"),o("shape-closed-change",!0))},N=()=>{w(),s.value=!1,o("close")};return t({addPoint:h,clearPoints:w}),(v,S)=>(e.openBlock(),e.createElementBlock("div",Wi,[e.createElementVNode("div",Yi,[e.createElementVNode("div",Zi,[e.createElementVNode("div",Xi,[e.createElementVNode("div",Ji,[e.createVNode(e.unref(z.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),S[2]||(S[2]=e.createElementVNode("h3",{class:"text-white font-semibold text-xs"},"Вимірювання",-1))]),e.createElementVNode("button",{class:"w-5 h-5 flex items-center justify-center rounded hover:bg-white/20 transition-colors","aria-label":"Закрити",onClick:N},[e.createVNode(e.unref(z.X),{size:14,"stroke-width":2,class:"text-white"})])]),e.createElementVNode("div",Qi,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:S[0]||(S[0]=D=>d("general"))}," Загальна ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:S[1]||(S[1]=D=>d("topoint"))}," До точки ",2)]),i.value==="general"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.value?(e.openBlock(),e.createBlock(Oi,{key:1,points:l.value,"is-shape-closed":c.value,onUpdatePoint:b,onDeletePoint:k},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createBlock(ji,{key:0}))],64)):(e.openBlock(),e.createElementBlock("div",ec,[a.value?(e.openBlock(),e.createBlock(Gi,{key:0,points:l.value,"is-shape-closed":c.value},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createElementBlock("p",tc,"Додайте точки на карті, щоб бачити відстані між ними."))])),e.createElementVNode("div",nc,[e.createElementVNode("div",rc,[s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(hi,{key:0,onClick:B})),p.value?(e.openBlock(),e.createBlock(yi,{key:1,onClick:E})):e.createCommentVNode("",!0)]),s.value?(e.openBlock(),e.createBlock(mi,{key:0,onSubmit:M,onCancel:$})):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(gi,{key:1,onClick:w})):e.createCommentVNode("",!0)])])]))}}),Pe="ruler-points",at="ruler-line",st="ruler-polygon",it="ruler-segments",lc=e.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(r){function t(u,h){const g=M=>M*Math.PI/180,C=g(h.lat-u.lat),w=g(h.lng-u.lng),b=g(u.lat),k=g(h.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(C/2)**2+Math.cos(b)*Math.cos(k)*Math.sin(w/2)**2)))}function n(u){return dr(u)}const o=r;function l(){return{type:"FeatureCollection",features:[]}}function a(u,h,g){const C=g??"general",w=[];let b=0;w.push(0);for(let k=1;k<u.length;k++)b+=t(u[k-1].coords,u[k].coords),w.push(b);return h&&u.length>=2&&(b+=t(u[u.length-1].coords,u[0].coords)),{type:"FeatureCollection",features:u.map((k,B)=>{const M=C==="general"?B===0?"0":n(w[B]):B===0?"0":n(t(u[B-1].coords,u[B].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[k.coords.lng,k.coords.lat]},properties:{id:k.id,index:B+1,label:M}}})}}function s(u,h){if(u.length<2)return l();const g=[];for(let C=0;C<u.length;C++){const w=C===u.length-1&&h?0:C+1;if(w>=u.length)break;const b=u[C].coords,k=u[w].coords,B=t(b,k);g.push({type:"Feature",geometry:{type:"LineString",coordinates:[[b.lng,b.lat],[k.lng,k.lat]]},properties:{distance:n(B)}})}return{type:"FeatureCollection",features:g}}function c(u,h){if(u.length<2)return l();const g=u.map(C=>[C.coords.lng,C.coords.lat]);return h&&g.push(g[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:g},properties:{}}]}}function i(u){if(u.length<3)return l();const h=u.map(g=>[g.coords.lng,g.coords.lat]);return h.push(h[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[h]},properties:{}}]}}let d=!1;function p(u){u.getSource(Pe)||(u.addSource(Pe,{type:"geojson",data:l()}),u.addLayer({id:`${Pe}-circle`,type:"circle",source:Pe,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),u.addLayer({id:`${Pe}-labels`,type:"symbol",source:Pe,layout:{"text-field":["get","label"],"text-size":14,"text-offset":[0,1.3]},paint:{"text-color":"#0f172a","text-halo-color":"#ffffff","text-halo-width":1}})),u.getSource(it)||(u.addSource(it,{type:"geojson",data:l()}),u.addLayer({id:`${it}-labels`,type:"symbol",source:it,layout:{"text-field":["get","distance"],"text-size":13,"symbol-placement":"line-center","text-rotation-alignment":"map","text-pitch-alignment":"map"},paint:{"text-color":"#1e293b","text-halo-color":"#ffffff","text-halo-width":1.5}})),u.getSource(at)||(u.addSource(at,{type:"geojson",data:l()}),u.addLayer({id:`${at}-layer`,type:"line",source:at,paint:{"line-color":"#3b82f6","line-width":2}})),u.getSource(st)||(u.addSource(st,{type:"geojson",data:l()}),u.addLayer({id:`${st}-layer`,type:"fill",source:st,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function m(u){if(u){try{u.getLayer(`${st}-layer`)&&u.removeLayer(`${st}-layer`),u.getSource(st)&&u.removeSource(st),u.getLayer(`${at}-layer`)&&u.removeLayer(`${at}-layer`),u.getSource(at)&&u.removeSource(at),u.getLayer(`${it}-labels`)&&u.removeLayer(`${it}-labels`),u.getSource(it)&&u.removeSource(it),u.getLayer(`${Pe}-labels`)&&u.removeLayer(`${Pe}-labels`),u.getLayer(`${Pe}-circle`)&&u.removeLayer(`${Pe}-circle`),u.getSource(Pe)&&u.removeSource(Pe)}catch{}d=!1}}function x(u){if(!u)return;const h=u.getSource(Pe),g=u.getSource(at),C=u.getSource(st),w=u.getSource(it),b=o.points,k=o.labelMode??"general";h&&h.setData(a(b,o.isShapeClosed,k)),g&&g.setData(c(b,o.isShapeClosed)),C&&C.setData(i(b)),w&&w.setData(k==="topoint"?s(b,o.isShapeClosed):l())}function f(){const u=o.map;u&&(d||p(u),x(u))}return e.watch(()=>[o.points,o.isShapeClosed,o.labelMode],()=>f(),{deep:!0,immediate:!0}),e.watch(()=>o.map,()=>f(),{immediate:!0}),e.onBeforeUnmount(()=>{m(o.map)}),(u,h)=>null}});function ac(r={}){const t=e.ref(!1),n=e.ref([]),o=e.ref(!1),l=e.ref("general"),a=e.ref(null);function s(){t.value?c():(t.value=!0,r.onActivate?.())}function c(){t.value=!1,n.value=[],o.value=!1,a.value?.clearPoints(),r.onDeactivate?.()}function i(f){n.value=f}function d(f){l.value=f}function p(f){o.value=f}function m(f){t.value&&a.value?.addPoint({lat:f.lat,lng:f.lng})}const x=e.computed(()=>n.value.length>0);return{isRulerActive:t,rulerPoints:n,rulerShapeClosed:o,rulerActiveTab:l,rulerPanelRef:a,hasRulerPoints:x,toggleRuler:s,closeRuler:c,onRulerPointsChange:i,onRulerTabChange:d,onRulerShapeClosedChange:p,handleRulerMapClick:m}}const wt=1e-10,Gt=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,sc=/^[+-]?\d+(?:\.\d+)?$/;function ic(r,t,n){const o=r.split(/\r?\n/).map(d=>d.trim()).filter(Boolean);if(o.length<3)return{ok:!1,errors:[{line:0,message:"Має бути щонайменше 3 рядки координат."}]};if(o.length>100)return{ok:!1,errors:[{line:0,message:"Допускається не більше 100 рядків координат."}]};const l=[],a=[];if(o.forEach((d,p)=>{const m=p+1,x=t==="decimal"?cc(d,m,n):dc(d,m,n);if(!x.ok){l.push(...x.errors);return}const f=a[a.length-1];if(f&&pr(f,x.point)){l.push({line:m,message:"Послідовні точки не повинні дублюватися."});return}a.push(x.point)}),l.length)return{ok:!1,errors:l};if(new Set(a.map(uc)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const c=[...a];let i=!1;return pr(c[0],c[c.length-1])||(c.push(c[0]),i=!0),pc(c)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:c,wasClosedAutomatically:i}}function cc(r,t,n){const o=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(r))return{ok:!1,errors:[{line:t,message:"У десятковому форматі не допускаються літери."}]};const l=r.split(/[\s,;]+/).filter(Boolean);if(l.length<2)return{ok:!1,errors:[{line:t,message:"Кожен рядок має містити дві координати."}]};if(l.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(!l.every(d=>sc.test(d)))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const a=Number(l[0]),s=Number(l[1]);if(!Number.isFinite(a)||!Number.isFinite(s))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const c=n==="lat-lon"?a:s,i=n==="lat-lon"?s:a;return(c<-90||c>90)&&o.push({line:t,message:"Широта поза діапазоном (-90..90)."}),(i<-180||i>180)&&o.push({line:t,message:"Довгота поза діапазоном (-180..180)."}),o.length?{ok:!1,errors:o}:{ok:!0,point:[i,c]}}function dc(r,t,n){Gt.lastIndex=0;const o=[...r.matchAll(Gt)];if(o.length<2)return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати DMS-координати."}]};if(o.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(Gt.lastIndex=0,r.replace(Gt," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:t,message:"У рядку виявлено зайві символи або значення."}]};const a=ur(o[0],t,n==="lat-lon"?"lat":"lon"),s=ur(o[1],t,n==="lat-lon"?"lon":"lat"),c=[];if(a.ok||c.push(a.error),s.ok||c.push(s.error),c.length)return{ok:!1,errors:c};const i=n==="lat-lon"?a.value:s.value;return{ok:!0,point:[n==="lat-lon"?s.value:a.value,i]}}function ur(r,t,n){const o=Number(r[1]),l=Number(r[2]),a=Number(r[3]),s=String(r[4]).toUpperCase();if(!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(a))return{ok:!1,error:{line:t,message:"Невірні значення DMS-координат."}};if(n==="lat"&&!(s==="N"||s==="S")||n==="lon"&&!(s==="E"||s==="W"))return{ok:!1,error:{line:t,message:n==="lat"?"Для широти напрям повинен бути N або S.":"Для довготи напрям повинен бути E або W."}};if(l<0||l>59)return{ok:!1,error:{line:t,message:"Хвилини повинні бути в діапазоні 0..59."}};if(a<0||a>59)return{ok:!1,error:{line:t,message:"Секунди повинні бути в діапазоні 0..59."}};const d=Math.abs(o),p=n==="lat"?90:180;if(d>p)return{ok:!1,error:{line:t,message:n==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===p&&(l!==0||a!==0))return{ok:!1,error:{line:t,message:n==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const m=d+l/60+a/3600;return{ok:!0,value:s==="S"||s==="W"?-m:m}}function uc(r){return`${r[0].toFixed(12)}:${r[1].toFixed(12)}`}function pr(r,t){return Math.abs(r[0]-t[0])<wt&&Math.abs(r[1]-t[1])<wt}function pc(r){if(r.length<4)return!1;for(let t=0;t<r.length-1;t+=1){const n=r[t],o=r[t+1];for(let l=t+1;l<r.length-1;l+=1){if(Math.abs(t-l)<=1||t===0&&l===r.length-2)continue;const a=r[l],s=r[l+1];if(fc(n,o,a,s))return!0}}return!1}function fc(r,t,n,o){const l=Wt(r,t,n),a=Wt(r,t,o),s=Wt(n,o,r),c=Wt(n,o,t);return!!(l!==a&&s!==c||l===0&&Yt(r,n,t)||a===0&&Yt(r,o,t)||s===0&&Yt(n,r,o)||c===0&&Yt(n,t,o))}function Wt(r,t,n){const o=(t[1]-r[1])*(n[0]-t[0])-(t[0]-r[0])*(n[1]-t[1]);return Math.abs(o)<wt?0:o>0?1:2}function Yt(r,t,n){return t[0]<=Math.max(r[0],n[0])+wt&&t[0]+wt>=Math.min(r[0],n[0])&&t[1]<=Math.max(r[1],n[1])+wt&&t[1]+wt>=Math.min(r[1],n[1])}const mc={key:0,class:"absolute top-4 left-4 z-[1000] w-[calc(100%-20px)] sm:w-[350px]"},hc={key:1,class:"form-geom__panel flex gap-1 items-start mt-2"},gc={class:"flex items-center gap-1"},yc=["disabled"],bc={key:0,class:"absolute z-[1600] mt-1 min-w-[120px] bg-white border border-gray-300 shadow-lg rounded-lg text-sm overflow-hidden"},kc=["disabled"],xc=["disabled"],wc={class:"mt-4 flex justify-end gap-2"},_c=["disabled"],Cc={class:"absolute top-4 right-4 z-[1000]"},vc={class:"flex flex-col gap-[2px]"},Ec=["disabled"],Bc=["disabled"],Vc=["disabled"],Sc=["disabled"],$c={class:"bg-white/95 border border-gray-200 rounded-md shadow-xl px-3 py-2 max-w-[240px] text-[11px] sm:text-xs text-gray-900"},Nc={class:"space-y-0.5"},Ac={class:"text-gray-500"},Fc={class:"text-gray-900 text-right break-all"},Dc={class:"absolute left-4 bottom-[36px] z-[1000]"},Mc={class:"flex flex-col gap-2"},Lc={key:0,class:"bg-white/95 border border-gray-200 rounded-md shadow-sm px-3 py-2 text-xs text-gray-700 min-w-[200px]"},Tc={class:"flex flex-col gap-1"},Ic=["checked","disabled","onChange"],Rc={class:"text-gray-700 text-xs font-medium"},Oc={class:"absolute bottom-0 left-0 right-0 z-[1000] min-h-[28px] bg-white/95 border-t border-gray-200 text-xs text-gray-700 flex items-center gap-4 pt-1"},zc={key:0,class:"form-geom__feature flex items-center text-xs transition-all gap-2 w-full px-2 pb-1"},Pc={class:"mr-auto flex items-center gap-2 min-w-0 relative"},jc={class:"shrink-0"},Uc={class:"font-bold"},Hc={class:"flex items-center"},qc={class:"text-xs mr-2"},Kc={key:0,class:"text-xs mr-2"},Gc={key:1,class:"text-xs mr-2"},Wc=["disabled"],Yc=["disabled"],Zt="__vs_form_maplibre_loader__",Xt="vs-global-bounds-src",Jt="vs-global-bounds-line",fr=fe(e.defineComponent({__name:"vs-input-map",props:{tools:{},handleZoom:{type:Boolean,default:!0},ctrlZoom:{type:Boolean,default:!0},geomType:{default:()=>[]},prefix:{default:""},katottg:{default:""},layers:{default:()=>[]},bounds:{},api:{},center:{default:void 0},zoom:{default:void 0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue","valueSelected"],setup(r,{emit:t}){const n=r,o=t,l=e.useAttrs(),a=e.computed(()=>!!n.disabled),s=e.ref(!1),c=e.ref(null),i=e.ref(0),d=e.ref(""),p=e.ref(null),m=e.ref(null),x=e.ref(null),f=ac({onActivate(){if(V)try{V.changeMode("simple_select",{featureIds:[]})}catch{}d.value=""},onDeactivate(){}});function u(){f.toggleRuler()}const h=e.getCurrentInstance(),g=h?.appContext?.config?.globalProperties?.$settings??{},C=g?.map??{},w=h?.vnode?.props??{};function b(y){return Object.prototype.hasOwnProperty.call(w,y)||Object.prototype.hasOwnProperty.call(w,y.replace(/[A-Z]/g,_=>`-${_.toLowerCase()}`))}const k=Array.isArray(C.center)&&C.center.length===2?C.center:Array.isArray(g.center)&&g.center.length===2?g.center:[30,50],B=typeof C.zoom=="number"?C.zoom:typeof g.zoom=="number"?g.zoom:typeof g.defaultZoom=="number"?g.defaultZoom:10,M=e.computed(()=>b("center")?n.center:C.center??n.center),$=e.computed(()=>b("zoom")?n.zoom:C.zoom??n.zoom),E=e.computed(()=>b("katottg")?String(n.katottg??""):String(C.katottg??n.katottg??"")),N=e.computed(()=>b("layers")?n.layers??[]:C.layers??n.layers??[]),v=e.computed(()=>b("bounds")?n.bounds:C.bounds??n.bounds),S=e.ref(Array.isArray(M.value)&&M.value.length===2?[...M.value]:k),D=e.ref(typeof $.value=="number"?$.value:B),I=e.ref(n.modelValue),A=e.ref(null),T=e.ref(null),L=e.ref([]),U=e.ref(!1),H=e.ref(!1),W=e.ref([]),Q=e.ref({coordinates:"",format:"decimal",order:"lat-lon"}),ve={coordinates:{type:"Textarea",label:"Координати вершин полігону (3-100 точок)",placeholder:`50.4501, 30.5234
|
|
3
3
|
50.4510, 30.5242
|
|
4
|
-
50.4494, 30.5260`},format:{type:"Radio",label:"Формат координат",options:[{id:"decimal",text:"Десяткові (Decimal)"},{id:"dms",text:"Градуси-хвилини-секунди (DMS)"}]},order:{type:"Radio",label:"Порядок координат",options:[{id:"lat-lon",text:"lat, lon"},{id:"lon-lat",text:"lon, lat"}]}};let ie=!1;const G=e.reactive({}),ne=e.ref([]),ce=e.computed(()=>ne.value.map(y=>G[y]).filter(Boolean)),ye=e.ref(null),ke=e.computed(()=>ye.value?.entries??[]),De=e.computed(()=>{if(ye.value)return{left:`${ye.value.point.x+12}px`,top:`${ye.value.point.y+12}px`}}),Me=e.computed(()=>{if(Array.isArray(n.tools)&&n.tools.length)return n.tools;const y=l?.tools;return Array.isArray(y)?y.map(_=>String(_)):typeof y=="string"?y.split(",").map(_=>_.trim()).filter(Boolean):[]}),we=e.computed(()=>{const y={search:!1,import:!1,importCoordinates:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Me.value.length)return{...y,import:!0,importCoordinates:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const _=new Set(Me.value.map(F=>F.toLowerCase()));return{search:_.has("search"),import:_.has("import"),importCoordinates:_.has("import-coordinates")||_.has("import_coordinates")||_.has("importcoordinates"),export:_.has("export"),point:_.has("point"),line:_.has("line"),polygon:_.has("polygon"),rectangle:_.has("rectangle"),ruler:_.has("ruler")}});function Xe(y){if(typeof y!="string"||!y.trim())return"";if(/^https?:\/\//i.test(y))return y;const _=window?.location?.origin??"",F=y.replace(/^\/+/,"");return F?_?`${_}/${F}`:`/${F}`:_}function Le(){const y=Array.isArray(C.basemaps)&&C.basemaps.length?C.basemaps:g.basemaps;if(Array.isArray(y)&&y.length){const F=y.map((O,X)=>{const te=String(O?.key??O?.id??O?.name??`b${X}`),se=Xe(String(O?.url??""));if(!se)return null;const he=typeof O?.preview=="string"&&O.preview?Xe(O.preview):"";return[te,{...O,url:se,preview:he}]}).filter(O=>Array.isArray(O)&&O.length===2).reduce((O,[X,te])=>(O[X]=te,O),{});if(Object.keys(F).length)return F}return{voyager:{name:"Оглядова карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/voyager/ua/13/4790/2762.png"},orto10:{name:"Ортофото 1:10K",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4790/2762.png"},osmb:{name:"Open Street Maps",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",preview:"https://tile.openstreetmap.org.ua/styles/osm-bright/13/4790/2762.png"}}}const Je=Le(),j=Object.keys(Je),Y=e.ref(j.length?j[0]:"");async function J(){if(typeof window>"u")return null;const y=window;if(y[Zt])return y[Zt];const _=te=>{if(Array.from(document.styleSheets).some(Be=>Be?.href?.includes(te)))return;const he=document.createElement("link");he.rel="stylesheet",he.href=te,document.head.appendChild(he)},F=async()=>{const te=new Function("u","return import(u)"),se=await te("https://esm.sh/maplibre-gl@3.6.2"),he=se?.default??se;if(!he)throw new Error("maplibre esm fallback failed");window.maplibregl=he,window.mapboxgl=he;const Be=await te("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),Ke=Be?.default??Be;if(!Ke)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=Ke},X=(async()=>{_("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),_("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await F();const te=window.maplibregl,se=window.MapboxDraw;if(!te)throw new Error("maplibregl not available after load");if(!se)throw new Error("MapboxDraw not available after load");return{maplibregl:te,MapboxDraw:se}})().catch(te=>{throw delete y[Zt],te});return y[Zt]=X,X}function oe(y){return{version:8,sources:{rasterSource:{type:"raster",tiles:[y],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let ae=null,xe=null,P=null,V=null,Z=null,ee=null,pe=!1,Ee=!1;function vt(){return{onSetup(){const y=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(y),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:y,startPoint:null,hasCoordinates:!1}},onMouseMove(y,_){if(!y.startPoint)return;const[F,O]=y.startPoint,X=_.lngLat.lng,te=_.lngLat.lat;y.rectangle.setCoordinates([[[F,O],[X,O],[X,te],[F,te],[F,O]]])},onClick(y,_){if(!y.startPoint){y.startPoint=[_.lngLat.lng,_.lngLat.lat],y.hasCoordinates=!0,y.rectangle.setCoordinates([[[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat]]]);return}const[F,O]=y.startPoint,X=_.lngLat.lng,te=_.lngLat.lat;return Math.abs(F-X)>0&&Math.abs(O-te)>0?(y.rectangle.setCoordinates([[[F,O],[X,O],[X,te],[F,te],[F,O]]]),this.map.fire("draw.create",{features:[y.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[y.rectangle.id]})):(this.deleteFeature([y.rectangle.id],{silent:!0}),y.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(y){this.deleteFeature([y.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(y,_,F){if(!y.hasCoordinates)return;const O=_.properties.id===y.rectangle.id;_.properties.active=O?"true":"false",F(_)}}}const ot=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["!=","active","true"]],paint:{"fill-color":"#3b82f6","fill-outline-color":"#3b82f6","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":"#2563eb","fill-outline-color":"#2563eb","fill-opacity":.2}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","$type","Polygon"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-lines-inactive",type:"line",filter:["all",["==","$type","LineString"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-lines-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","active","true"]],paint:{"circle-radius":5,"circle-color":"#3b82f6"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","meta","midpoint"],["==","$type","Point"]],paint:{"circle-radius":4,"circle-color":"#1d4ed8"}}];function gt(){const y=Y.value;return!y||!Je[y]?.url?"":Je[y].url}function yt(y,_){return y?.id?String(y.id):y?.url?`${y.url}-${_}`:`layer-${_}`}function bt(y){const _=String(y?.url??"").trim();if(!_)return"";if(/^https?:\/\//i.test(_))return _;const F=window.location?.origin??"",O=_.replace(/^\/+/,"");return`${F}/${O}`}function Te(y){y&&ye.value?.layerId!==y||(ye.value=null)}function We(y,_={}){return y.popup===!1?[]:Array.isArray(y.popup)?y.popup.length?y.popup.map(F=>{const O=F?.field||F?.name;if(!O)return null;const X=_[O];return X==null||X===""?null:{key:F.label||O,value:String(X)}}).filter(Boolean):[]:Object.entries(_).slice(0,5).map(([F,O])=>({key:F,value:O==null?"—":String(O)}))}function ct(y){if(!Array.isArray(y))return[];const _=O=>Array.isArray(O)&&O.length>=2&&Number.isFinite(Number(O[0]))&&Number.isFinite(Number(O[1])),F=O=>{if(!O.length)return O;const X=O[0],te=O[O.length-1];return!te||X[0]!==te[0]||X[1]!==te[1]?[...O,X]:O};if(y.length&&_(y[0])){const O=y.map(X=>[Number(X[0]),Number(X[1])]).filter(_);return O.length?[F(O)]:[]}return y.length&&Array.isArray(y[0])&&_(y[0][0])?y.map(X=>Array.isArray(X)?X.map(te=>[Number(te[0]),Number(te[1])]):[]).filter(X=>X.length).map(F):y.length&&Array.isArray(y[0])&&Array.isArray(y[0][0])&&_(y[0][0][0])?y.flatMap(X=>Array.isArray(X)?X:[]).map(X=>Array.isArray(X)?X.map(te=>[Number(te[0]),Number(te[1])]):[]).filter(X=>X.length).map(F):[]}function Ut(y){const _=y.style??{},F=_.color??"#3b82f6";if(!_.colorAttr||!_.colorSet)return F;const O=Object.keys(_.colorSet);if(!O.length)return F;const X=["match",["to-string",["get",_.colorAttr]]];return O.forEach(te=>{X.push(String(te),_.colorSet?.[te]??F)}),X.push(F),X}function Et(y){if(!P)return;y.handlers.forEach(F=>{try{P.off(F.type,F.layerId,F.handler)}catch{}}),y.handlers=[],[...y.layerIds,...y.boundsIds].forEach(F=>{P.getLayer(F)&&P.removeLayer(F)}),P.getSource(y.sourceId)&&P.removeSource(y.sourceId);const _=`vs-ov-bounds-src-${y.id}`;P.getSource(_)&&P.removeSource(_),Te(y.id)}function hn(y,_){if(!P)return[];const F=`vs-ov-bounds-src-${_}`,O=`vs-ov-bounds-line-${_}`,X=y.bounds??v.value??L.value,te=ct(X);if(!te.length)return[];const se={type:"FeatureCollection",features:te.map(he=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:he}}))};return P.getSource(F)&&P.removeSource(F),P.addSource(F,{type:"geojson",data:se}),P.addLayer({id:O,type:"line",source:F,paint:{"line-color":y.style?.stroke??y.style?.color??"#2563eb","line-width":y.style?.width??2,"line-opacity":y.style?.opacity??.8,"line-dasharray":[2,2]}}),[O]}function kt(y){if(!P)return;Et(y);const _=y.config,F=bt(_);if(!F)return;const O=[],X=[];if(/\.v(?:m)?t(?:\?|$)/i.test(F)||/\.pbf(?:\?|$)/i.test(F)){const he=_.sourceLayer||_.layer||_.service_layer||_.dataset?.layer||_.id;P.addSource(y.sourceId,{type:"vector",tiles:[F]});const Be=String(_.style?.type??"polygon").toLowerCase(),Ke=Ut(_),et=_.style?.opacity??.5;if(Be==="point"){const lt=`vs-ov-point-${y.id}`;P.addLayer({id:lt,type:"circle",source:y.sourceId,"source-layer":he,paint:{"circle-color":Ke,"circle-radius":5,"circle-opacity":et}}),O.push(lt)}else if(Be==="polyline"||Be==="line"){const lt=`vs-ov-line-${y.id}`;P.addLayer({id:lt,type:"line",source:y.sourceId,"source-layer":he,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Ke,"line-width":_.style?.width??2,"line-opacity":et}}),O.push(lt)}else{const lt=`vs-ov-fill-${y.id}`,qt=`vs-ov-border-${y.id}`;P.addLayer({id:lt,type:"fill",source:y.sourceId,"source-layer":he,paint:{"fill-color":Ke,"fill-opacity":et}}),P.addLayer({id:qt,type:"line",source:y.sourceId,"source-layer":he,paint:{"line-color":_.style?.stroke??_.style?.color??"#2563eb","line-width":_.style?.width??1,"line-opacity":et}}),O.push(lt,qt)}}else{P.addSource(y.sourceId,{type:"raster",tiles:[F],tileSize:256});const he=`vs-ov-raster-${y.id}`;P.addLayer({id:he,type:"raster",source:y.sourceId,paint:{"raster-opacity":_.style?.opacity??1}}),O.push(he)}O.forEach(he=>{const Be=et=>{if(!et?.features?.length){Te(y.id);return}const lt=et.features[0]?.properties??{},qt=We(y.config,lt);if(!qt.length){Te(y.id);return}ye.value={layerId:y.id,entries:qt,point:{x:et.point.x,y:et.point.y}}},Ke=()=>Te(y.id);P.on("mousemove",he,Be),P.on("mouseleave",he,Ke),X.push({layerId:he,type:"mousemove",handler:Be},{layerId:he,type:"mouseleave",handler:Ke})}),y.layerIds=O,y.boundsIds=hn(y.config,y.id),y.handlers=X;const se=y.visible?"visible":"none";[...y.layerIds,...y.boundsIds].forEach(he=>{P.getLayer(he)&&P.setLayoutProperty(he,"visibility",se)})}function Bt(){if(!P)return;const _={type:"FeatureCollection",features:ct(v.value??L.value).map(F=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:F}}))};P.getSource(Xt)?P.getSource(Xt).setData(_):P.addSource(Xt,{type:"geojson",data:_}),P.getLayer(Jt)||P.addLayer({id:Jt,type:"line",source:Xt,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function Xn(y){if(!P||a.value)return;const _=G[y];if(!_)return;_.visible=!_.visible;const F=_.visible?"visible":"none";[..._.layerIds,..._.boundsIds].forEach(O=>{P.getLayer(O)&&P.setLayoutProperty(O,"visibility",F)}),dt(),_.visible||Te(y)}function dt(){if(!P)return;const y=[],_=[],F=[],O=[];ne.value.forEach(se=>{const he=G[se];if(!he)return;const Be=String(he.config?.url??""),Ke=/\.v(?:m)?t(?:\?|$)/i.test(Be),et=/\.png(?:\?|$)/i.test(Be);Ke?F.push(...he.layerIds):et?y.push(...he.layerIds):_.push(...he.layerIds),O.push(...he.boundsIds)}),[...y,..._,...F,...O].forEach(se=>{P.getLayer(se)&&P.moveLayer(se)}),P.getLayer(Jt)&&P.moveLayer(Jt),(P.getStyle?.()?.layers??[]).map(se=>String(se?.id??"")).filter(se=>se.startsWith("gl-draw-")).forEach(se=>{P.getLayer(se)&&P.moveLayer(se)})}function gn(y){if(!Je[y]||(Y.value=y,!P))return;const _=gt();if(!_)return;const F=P.getCenter?.(),O=P.getZoom?.(),X=V?.getAll?.();P.setStyle(oe(_)),P.once("style.load",()=>{if(P&&(F&&Number.isFinite(O)&&P.jumpTo({center:[F.lng,F.lat],zoom:O}),Bt(),ne.value.forEach(te=>{const se=G[te];se&&kt(se)}),dt(),X?.features?.length&&V))try{X.features.forEach(te=>V.add(te)),i.value=X.features.length}catch{i.value=0}})}function R(y){return y?y.type==="FeatureCollection"?y.features?.[0]?.geometry??null:y.type==="Feature"?y.geometry??null:y.geom?.type&&Array.isArray(y.geom.coordinates)?{type:y.geom.type,coordinates:y.geom.coordinates}:typeof y.type=="string"&&Array.isArray(y.coordinates)?y:null:null}function K(y){return{type:"Feature",properties:{},geometry:y}}function q(y){if(!y)return null;try{return JSON.parse(JSON.stringify(y))}catch{return null}}function le(y){if(!y)return"__null__";try{return JSON.stringify(y)}catch{return"__invalid__"}}function be(y){const _=Oe(y);if(!_)return null;const[[F,O],[X,te]]=_;return{lat:(O+te)/2,lng:(F+X)/2}}function _e(y){if(!Array.isArray(y)||y.length<3)return 0;const _=(O,X)=>{const te=O*2003750834e-2/180,se=Math.log(Math.tan((90+X)*Math.PI/360))/(Math.PI/180);return[te,se*2003750834e-2/180]};let F=0;for(let O=0;O<y.length-1;O+=1){const[X,te]=_(Number(y[O][0]),Number(y[O][1])),[se,he]=_(Number(y[O+1][0]),Number(y[O+1][1]));F+=X*he-se*te}return Math.abs(F/2)/1e6}function Ce(y){if(!y?.type||!y?.coordinates)return null;if(y.type==="Polygon"){const _=y.coordinates?.[0];return Array.isArray(_)?_e(_):null}return y.type==="MultiPolygon"?y.coordinates.reduce((_,F)=>{const O=F?.[0];return Array.isArray(O)?_+_e(O):_},0):null}function Ve(y){if(!y){p.value=null;return}const _=be(y);if(!_){p.value=null;return}p.value={type:String(y.type??"Feature"),center:_,areaKm2:Ce(y)}}function Ie(y,_){if(!Array.isArray(y)||!Array.isArray(_)||y.length!==2||_.length!==2)return!1;const F=1e-9;return Math.abs(Number(y[0])-Number(_[0]))<F&&Math.abs(Number(y[1])-Number(_[1]))<F}function Oe(y){if(!y)return null;let _=1/0,F=1/0,O=-1/0,X=-1/0;const te=se=>{if(Array.isArray(se)){if(se.length>=2&&Number.isFinite(se[0])&&Number.isFinite(se[1])){const he=Number(se[0]),Be=Number(se[1]);_=Math.min(_,he),F=Math.min(F,Be),O=Math.max(O,he),X=Math.max(X,Be);return}se.forEach(te)}};return te(y.coordinates),!Number.isFinite(_)||!Number.isFinite(F)?null:[[_,F],[O,X]]}function Qe(y){if(!P||!y)return;const _=Oe(y);if(!_)return;const[[F,O],[X,te]]=_;if(F===X&&O===te){P.easeTo({center:[F,O],zoom:Math.max(D.value,14)});return}P.fitBounds(_,{padding:30,duration:250,maxZoom:18})}function ze(){if(!V){i.value=0;return}const y=V.getAll();i.value=y?.features?.length??0}function Vt(){if(!V)return;const y=V.getAll();if(i.value=y?.features?.length??0,!y?.features?.length){Z=null,p.value=null,ie||(ee="__null__",o("update:modelValue",null));return}const _=q(y.features[y.features.length-1]?.geometry??null);Z=_,Ve(_),ie||(ee=le(_),o("update:modelValue",_))}function yn(){if(!V)return;(V.getAll()?.features||[]).forEach(_=>V.delete(_.id)),ze()}function bn(y){if(!V)return;const _=R(y);if(ie=!0,yn(),_)try{V.add(K(_))}catch{}ie=!1,Z=q(_),ze(),Ve(_),_&&(Qe(_),a.value||xn())}function Lh(){if(V){if(ie=!0,yn(),Z)try{V.add(K(Z))}catch{}ie=!1,ze(),Ve(Z)}}function Ht(){if(V){try{V.changeMode("simple_select",{featureIds:[]})}catch{}d.value=""}}function kn(y){if(a.value||!V)return;f.isRulerActive.value&&f.closeRuler(),Ee=!0,Ht(),d.value=y;const _=y==="marker"?"draw_point":y==="polyline"?"draw_line_string":y==="rectangle"?"draw_rectangle":"draw_polygon";ie=!0,yn(),ie=!1;try{V.changeMode(_)}catch{d.value=""}finally{requestAnimationFrame(()=>{Ee=!1})}}function xn(){if(a.value||!V)return;const y=V.getAll();if(y?.features?.length)try{V.changeMode("direct_select",{featureId:y.features[0].id}),d.value="edit"}catch{d.value=""}}function Th(){a.value||!V||(Ht(),yn(),ee="__null__",p.value=null,o("update:modelValue",null))}function Ih(){a.value||!Z||Qe(Z)}function Rh(y){P&&P.easeTo({center:[y[1],y[0]],zoom:13,duration:250})}function Oh(){a.value||A.value?.click()}function zh(){a.value||(U.value=!U.value)}function fo(y){if(!U.value)return;const _=T.value;_&&!_.contains(y.target)&&(U.value=!1)}function Ph(){U.value=!1,Oh()}function jh(){a.value||(W.value=[],U.value=!1,H.value=!0)}function Uh(){H.value=!1,W.value=[]}function Hh(){if(a.value||!V)return;const y=ic(Q.coordinates??"",Q.format||"decimal",Q.order||"lat-lon");if(!y.ok){W.value=y.errors,qh(y.errors);return}W.value=[],bn({type:"Polygon",coordinates:[y.ring]}),H.value=!1,y.wasClosedAutomatically&&me.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function qh(y){if(!y.length)return;const _=5;y.slice(0,_).forEach(F=>{const O=F.line>0?`Рядок ${F.line}`:"Загальна помилка";me.notify({type:"warning",title:"Імпорт координат",message:`${O} — ${F.message}`})}),y.length>_&&me.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${y.length-_}`})}function Kh(y){if(a.value||!V)return;U.value=!1;const _=y.target,F=_.files?.[0];if(!F)return;const O=new FileReader;O.onload=()=>{try{const X=JSON.parse(String(O.result)),te=R(X);if(!te)return;bn(te)}finally{_.value=""}},O.readAsText(F)}function Gh(){if(a.value||!V)return;const y=V.getAll(),_=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),F=URL.createObjectURL(_),O=document.createElement("a");O.href=F,O.download="data.geojson",O.click(),URL.revokeObjectURL(F)}return e.onMounted(async()=>{if(window.addEventListener("click",fo,!0),!c.value)return;const y=await J();ae=y.maplibregl,xe=y.MapboxDraw;const _=gt();_&&(P=new ae.Map({container:c.value,style:oe(_),center:[S.value[0],S.value[1]],zoom:D.value,attributionControl:!1}),m.value=P,P.addControl(new ae.NavigationControl({showCompass:!0}),"bottom-right"),P.on("load",()=>{if(!(!xe||!P)){if(V=new xe({displayControlsDefault:!1,modes:{...xe.modes,draw_rectangle:vt()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:ot}),P.addControl(V),P.on("click",F=>{if(!f.isRulerActive.value)return;const O=F?.lngLat;O&&x.value?.addPoint?.({lat:O.lat,lng:O.lng})}),P.on("draw.create",()=>{if(!V||f.isRulerActive.value)return;const F=V.getAll();if(F.features.length>1){const O=F.features[F.features.length-1];ie=!0,F.features.slice(0,-1).forEach(X=>V.delete(X.id)),ie=!1,O&&(ie=!0,V.add(O),ie=!1)}Vt(),xn()}),P.on("draw.update",F=>{if(!pe&&!f.isRulerActive.value){if(F?.action==="move"){if(pe=!0,Lh(),pe=!1,d.value==="edit"){const O=V?.getAll?.()?.features?.[0];if(O?.id)try{V.changeMode("direct_select",{featureId:O.id})}catch{d.value=""}}return}Vt()}}),P.on("draw.delete",()=>{f.isRulerActive.value||d.value==="marker"||d.value==="polyline"||d.value==="polygon"||d.value==="rectangle"||(Vt(),d.value="",Ht())}),P.on("draw.selectionchange",()=>{if(!(!V||pe)&&!f.isRulerActive.value&&d.value!=="edit"&&!(d.value==="marker"||d.value==="polyline"||d.value==="polygon"||d.value==="rectangle")){if(!a.value&&i.value>0){xn();return}try{V.changeMode("simple_select",{featureIds:[]})}catch{}}}),I.value!==void 0){const F=I.value;I.value=void 0,requestAnimationFrame(()=>{V&&bn(F)})}Bt(),ne.value.forEach(F=>{const O=G[F];O&&kt(O)}),dt()}}),P.on("zoomend",()=>{P&&(D.value=P.getZoom())}))}),e.onUnmounted(()=>{f.isRulerActive.value&&f.closeRuler(),window.removeEventListener("click",fo,!0),Object.values(G).forEach(y=>{P&&Et(y)}),Te(),P?.remove&&P.remove(),P=null,V=null,m.value=null}),e.watch(()=>n.modelValue,y=>{if(!V){I.value=y;return}const _=R(y),F=le(_);if(ee&&F===ee){ee=null;return}ee=null,bn(y)},{deep:!0}),e.watch(()=>N.value,y=>{const _=Array.isArray(y)?y:[],F=[],O=new Set;_.forEach((X,te)=>{if(!X)return;const se=yt(X,te);F.push(se),O.add(se);const he={...X,id:se},Be=G[se],Ke=Be?.visible??!!he.visible;Be&&P&&Et(Be),G[se]={id:se,config:he,visible:Ke,sourceId:`vs-ov-src-${se}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(G).forEach(X=>{if(O.has(X))return;const te=G[X];te&&P&&Et(te),delete G[X]}),ne.value=F,P&&(ne.value.forEach(X=>{const te=G[X];te&&kt(te)}),dt())},{immediate:!0,deep:!0}),e.watch(()=>v.value,()=>{P&&(Bt(),ne.value.forEach(y=>{const _=G[y];_&&kt(_)}),dt())},{deep:!0}),e.watch(()=>E.value,async y=>{if(L.value=[],!y){P&&(Bt(),ne.value.forEach(_=>{const F=G[_];F&&kt(F)}),dt());return}try{const _=await fetch(`https://data.gki.com.ua/api-user/atu/${y}`);if(!_?.ok)return;const O=(await _.json())?.geometry?.coordinates;Array.isArray(O)&&O.length&&(L.value=O)}catch(_){console.error("Failed to fetch KATOTTG bounds",_)}finally{if(!P)return;Bt(),ne.value.forEach(_=>{const F=G[_];F&&kt(F)}),dt()}},{immediate:!0}),e.watch(()=>M.value,y=>{if(!Array.isArray(y)||y.length!==2)return;const _=[Number(y[0]),Number(y[1])];if(Ie(S.value,_)||(S.value=[..._],!P))return;const F=P.getCenter?.();F&&Ie([F.lng,F.lat],S.value)||P.easeTo({center:[S.value[0],S.value[1]]})},{deep:!0}),e.watch(()=>$.value,y=>{typeof y=="number"&&(D.value=y,P&&P.setZoom(y))}),e.watch(a,y=>{y&&Ht()}),e.watch(i,y=>{if(y>0){a.value||xn();return}Ee||Ht()}),e.watch(s,()=>{setTimeout(()=>{P?.resize&&P.resize()},50)}),(y,_)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!s.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:s.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:c,class:"w-full h-[calc(100%-28px)]"},null,512),we.value.search||we.value.import||we.value.importCoordinates||we.value.export?(e.openBlock(),e.createElementBlock("div",mc,[we.value.search?(e.openBlock(),e.createBlock(ui,{key:0,onGoToCoordinates:Rh})):e.createCommentVNode("",!0),we.value.import||we.value.importCoordinates||we.value.export?(e.openBlock(),e.createElementBlock("div",hc,[e.createElementVNode("div",gc,[we.value.import||we.value.importCoordinates?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:T,class:"relative"},[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:zh,disabled:a.value},[_[8]||(_[8]=e.createTextVNode(" Import ",-1)),e.createVNode(e.unref(z.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":U.value}])},null,8,["class"])],8,yc),U.value?(e.openBlock(),e.createElementBlock("div",bc,[we.value.import?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100",onClick:Ph}," З файлу ")):e.createCommentVNode("",!0),we.value.importCoordinates?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100",onClick:jh}," З координат ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),we.value.export?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:Gh,disabled:a.value||i.value===0}," Export ",8,kc)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:A,type:"file",onChange:Kh,accept:".json,.geojson",class:"hidden",disabled:a.value},null,40,xc)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(me.VsModal),{visible:H.value,"onUpdate:visible":_[1]||(_[1]=F=>H.value=F),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(Ye,{schema:ve,values:Q,"onUpdate:values":_[0]||(_[0]=F=>Q=F)},null,8,["values"]),e.createElementVNode("div",wc,[e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:Uh}," Скасувати "),e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:Hh,disabled:a.value}," Побудувати ",8,_c)])]),_:1},8,["visible"]),e.createElementVNode("div",Cc,[e.createElementVNode("div",vc,[we.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="marker"}]),title:"Point",onClick:_[2]||(_[2]=F=>kn("marker")),disabled:a.value},[e.createVNode(e.unref(z.MapPin),{class:"h-4 w-4"})],10,Ec)):e.createCommentVNode("",!0),we.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="polyline"}]),title:"Line",onClick:_[3]||(_[3]=F=>kn("polyline")),disabled:a.value},[e.createVNode(Us)],10,Bc)):e.createCommentVNode("",!0),we.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="polygon"}]),title:"Polygon",onClick:_[4]||(_[4]=F=>kn("polygon")),disabled:a.value},[e.createVNode(Gs)],10,Vc)):e.createCommentVNode("",!0),we.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="rectangle"}]),title:"Rectangle",onClick:_[5]||(_[5]=F=>kn("rectangle")),disabled:a.value},[e.createVNode(Xs)],10,Sc)):e.createCommentVNode("",!0),we.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(f).isRulerActive.value}]),title:"Ruler",onClick:u},[e.createVNode(e.unref(z.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:_[6]||(_[6]=F=>s.value=!s.value),title:"Full Screen"},[e.createVNode(e.unref(z.Maximize),{class:"h-4 w-4"})])])]),we.value.ruler&&e.unref(f).isRulerActive.value?(e.openBlock(),e.createBlock(oc,{key:1,ref_key:"rulerPanelRefEl",ref:x,onClose:_[7]||(_[7]=F=>e.unref(f).closeRuler()),onTabChange:e.unref(f).onRulerTabChange,onPointsChange:e.unref(f).onRulerPointsChange,onShapeClosedChange:e.unref(f).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),we.value.ruler&&e.unref(f).isRulerActive.value&&e.unref(f).hasRulerPoints.value?(e.openBlock(),e.createBlock(lc,{key:2,map:m.value,points:e.unref(f).rulerPoints.value,"is-shape-closed":e.unref(f).rulerShapeClosed.value,"label-mode":e.unref(f).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),ke.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(De.value)},[e.createElementVNode("div",$c,[e.createElementVNode("dl",Nc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ke.value,F=>(e.openBlock(),e.createElementBlock("div",{key:`${F.key}-${F.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",Ac,e.toDisplayString(F.key),1),e.createElementVNode("dd",Fc,e.toDisplayString(F.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Dc,[e.createElementVNode("div",Mc,[e.createVNode(ni,{basemaps:e.unref(Je),onOnLayerChange:gn},null,8,["basemaps"]),ce.value.length?(e.openBlock(),e.createElementBlock("div",Lc,[_[9]||(_[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",Tc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ce.value,F=>(e.openBlock(),e.createElementBlock("label",{key:F.id,class:"flex items-center gap-2 cursor-pointer select-none"},[e.createElementVNode("input",{type:"checkbox",class:"rounded border-gray-300 text-blue-600 focus:ring-blue-500",checked:F.visible,disabled:a.value,onChange:O=>Xn(F.id)},null,40,Ic),e.createElementVNode("span",Rc,e.toDisplayString(F.config.title||F.config.name||F.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Oc,[p.value?(e.openBlock(),e.createElementBlock("div",zc,[e.createElementVNode("div",Pc,[e.createElementVNode("div",jc,[_[10]||(_[10]=e.createTextVNode(" Type: ",-1)),e.createElementVNode("span",Uc,e.toDisplayString(p.value.type),1)])]),e.createElementVNode("div",Hc,[e.createElementVNode("div",qc,[_[11]||(_[11]=e.createTextVNode(" Center: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.center.lat.toFixed(5))+", "+e.toDisplayString(p.value.center.lng.toFixed(5)),1)]),p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",Kc,[_[12]||(_[12]=e.createTextVNode(" Area: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",Gc,_[13]||(_[13]=[e.createTextVNode("Area: ",-1),e.createElementVNode("b",null,"—",-1)]))),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md mr-1 cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Zoom to feature",onClick:Ih,disabled:a.value},[e.createVNode(e.unref(z.ZoomIn),{class:"h-3 w-3"})],8,Wc),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Delete feature",onClick:Th,disabled:a.value},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,Yc)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-bd691051"]]),Zc=["data-focus"],Xc={class:"flex items-center"},Jc={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},Qc=["onClick","aria-label"],ed={key:0,class:"absolute text-gray-500 truncate pl-2"},td={class:"flex-1 min-w-[2px]"},nd=["placeholder"],rd={class:"flex items-center shrink-0"},od=["disabled"],mr=e.defineComponent({__name:"vs-input-tag",props:e.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(r,{emit:t}){const n=r,o=t;Fe(n.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),c=e.ref(!1),i=e.ref(""),d=e.useModel(r,"modelValue"),p=e.computed(()=>n.placeholder||"Add tag…"),m=e.computed(()=>d.value?.length===0&&i.value===""),x=e.computed(()=>!n.disabled&&d.value?.length>0),f=e.computed(()=>n.disabled),u=async()=>{f.value||await e.nextTick(()=>s.value?.focus())},h=M=>{const $=M.trim();$!==""&&(!d.value||!Array.isArray(d.value)?d.value=[$]:n.unique?d.value.includes($)||(d.value=[...d.value,$]):d.value=[...d.value,$],i.value="")},g=()=>{const M=i.value;M.trim()!==""&&h(M),i.value=""},C=M=>{const $=d.value.slice();$.splice(M,1),o("update:modelValue",$)},w=()=>{o("update:modelValue",[])},b=()=>{f.value||(c.value=!0)},k=()=>{c.value=!1,!f.value&&g()},B=M=>{const{key:$}=M;$==="Enter"?(M.preventDefault(),g()):$==="Backspace"&&i.value===""&&d.value.length>0&&C(d.value.length-1)};return(M,$)=>(e.openBlock(),e.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:l,onClick:$[1]||($[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass]),role:"group","aria-label":"Tag input"},[e.createElementVNode("div",{class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",c.value?"border-blue-500 ring-1 ring-blue-500":"",f.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":c.value?"true":"false",onClick:u},[e.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:a},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(E,N)=>(e.openBlock(),e.createElementBlock("div",{key:N,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",Xc,[e.createElementVNode("div",Jc,e.toDisplayString(E),1)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border hover:bg-[#ffbdad] hover:text-[#de350b]",onClick:e.withModifiers(v=>C(N),["stop"]),"aria-label":`Remove ${E}`},[e.createVNode(e.unref(z.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Qc)]))),128)),m.value?(e.openBlock(),e.createElementBlock("div",ed,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",td,[f.value?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:s,class:"pl-2 w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-label":"Add tag","onUpdate:modelValue":$[0]||($[0]=E=>i.value=E),onFocus:b,onBlur:k,onKeydown:B,placeholder:d.value&&d.value.length?"":void 0},null,40,nd)),[[e.vModelText,i.value]])])],512),e.createElementVNode("div",rd,[x.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-label":"Clear all tags",disabled:f.value,onClick:e.withModifiers(w,["stop"])},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,od)):e.createCommentVNode("",!0)])],10,Zc)],2)],512))}}),ld={class:"relative flex gap-1 bg-white w-full"},ad=["disabled","placeholder"],hr=fe(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.inject("values"),n=r,o=e.useModel(r,"modelValue");function l(s){const c={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return s.toLowerCase().split("").map(i=>c[i]||i).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[n.parent||""]?.toString(),c=l(s);o.value=c.toString()};return(s,c)=>(e.openBlock(),e.createElementBlock("div",ld,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:s.disabled,placeholder:s.placeholder,"onUpdate:modelValue":c[0]||(c[0]=i=>o.value=i),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,ad),[[e.vModelText,o.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:a}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),sd={class:"relative flex gap-1 bg-white w-full"},id=["disabled","placeholder"],cd=["disabled"],dd={key:0},ud={key:1},gr=fe(e.defineComponent({__name:"vs-input-codegen",props:e.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.ref(!1),l=e.computed(()=>t.init!==!1),a=e.computed(()=>!!t.table&&!!t.code),s=()=>{if(!a.value)return"";const d=encodeURIComponent(String(t.table)),p=encodeURIComponent(String(t.code));return`/api/code-gen/${d}/${p}`},c=async()=>{if(!a.value||o.value)return;const d=s();if(d){o.value=!0;try{const m=await(await fetch(d)).text();n.value=m}finally{o.value=!1}}},i=()=>{l.value&&(n.value||c())};return e.onMounted(()=>{i()}),e.watch(()=>[t.table,t.code,t.init],()=>{i()}),(d,p)=>(e.openBlock(),e.createElementBlock("div",sd,[e.withDirectives(e.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":p[0]||(p[0]=m=>n.value=m),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,id),[[e.vModelText,n.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:o.value||d.disabled||!a.value,onClick:c},[o.value?(e.openBlock(),e.createElementBlock("span",ud,"...")):(e.openBlock(),e.createElementBlock("span",dd,"Gen"))],8,cd)]))}}),[["__scopeId","data-v-6ee5237d"]]),pd={class:"w-full"},fd={ref:"sortableContainer",class:"flex flex-col gap-1"},md=["onDragstart","onDrop"],hd={class:"cursor-move",type:"button"},gd={class:"w-1/3"},yd={class:"w-2/3"},bd=["onClick"],kd={key:0,class:"text-[14px] text-gray-700"},xd={class:"mt-2 w-full flex items-center"},wd=["disabled"],yr=fe(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,o=e.inject("values"),l=r,a=t,s=l.addButtonText??"Додати",c=l.ignore??[],i=e.ref([]),d=e.ref(null);(()=>{const g=l.parent&&o?.value?.[l.parent]||l.modelValue||{};i.value=Object.entries(g).filter(([C])=>!c.includes(C)).map(([C,w])=>({id:n("key-value-"),key:C,value:w}))})();function m(g){d.value=g}function x(g){if(d.value===null||d.value===g)return;const C=i.value.splice(d.value,1)[0];i.value.splice(g,0,C),d.value=null}const f=e.computed(()=>i.value.some(g=>g.key&&!g.value||!g.key&&g.value)),u=()=>{i.value.push({id:n("key-value-"),key:"",value:""})},h=g=>{i.value=i.value.filter(C=>C.id!==g)};return e.watch(i,g=>{const C={};g.forEach(b=>{b.key&&b.value!==void 0&&(C[b.key]=b.value)});const w={};c.length&&c.forEach(b=>{w[b]=l.parent?o?.value?.[l.parent]?.[b]:void 0}),o?.value&&l.parent&&(o.value[l.parent]={...w,...C}),a("update:modelValue",C)},{deep:!0}),(g,C)=>(e.openBlock(),e.createElementBlock("div",pd,[e.createElementVNode("div",fd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(w,b)=>(e.openBlock(),e.createElementBlock("div",{key:w.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===b}]),draggable:"true",onDragstart:k=>m(b),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:k=>x(b)},[e.createElementVNode("button",hd,[e.createVNode(e.unref(z.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",gd,[e.createVNode(St,{modelValue:w.key,"onUpdate:modelValue":k=>w.key=k,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",yd,[e.createVNode(St,{modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:k=>h(w.id),class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,bd)],42,md))),128))],512),i.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",kd," Дані для відображення відсутні ")),e.createElementVNode("div",xd,[e.createElementVNode("button",{type:"button",onClick:u,disabled:f.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(s)),1)],8,wd)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),_d={class:"w-full"},Cd={ref:"sortableContainer",class:"flex flex-col gap-1"},vd=["onDragstart","onDrop"],Ed=["disabled"],Bd={class:"flex-1"},Vd=["onClick","disabled"],Sd={key:0,class:"text-[14px] text-gray-700"},$d={class:"mt-2 w-full flex items-center"},Nd=["disabled"],br=fe(e.defineComponent({__name:"vs-input-text-array",props:e.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),c=e.computed(()=>t.addButtonText??"Додати");let i=!1;const d=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,p=g=>{const C=g??n.value??[];o.value=C.map((w,b)=>({id:o.value[b]?.id??d("text-array"),value:w??""}))};p(),e.watch(()=>n.value,g=>{if(i){i=!1;return}p(g||[])},{deep:!0}),e.watch(o,g=>{i=!0,n.value=g.map(C=>C.value).filter(C=>C!=null&&C!=="")},{deep:!0});const m=e.computed(()=>a.value||o.value.some(g=>!g.value));function x(){m.value||(o.value=[...o.value,{id:d("text-array"),value:""}])}function f(g){a.value||(o.value=o.value.filter(C=>C.id!==g))}function u(g){a.value||(l.value=g)}function h(g){if(a.value||l.value===null||l.value===g)return;const C=[...o.value],[w]=C.splice(l.value,1);C.splice(g,0,w),o.value=C,l.value=null}return(g,C)=>(e.openBlock(),e.createElementBlock("div",_d,[e.createElementVNode("div",Cd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(w,b)=>(e.openBlock(),e.createElementBlock("div",{key:w.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":l.value===b}]),draggable:"true",onDragstart:k=>u(b),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:k=>h(b)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(z.GripVertical),{class:"h-4 w-4"})],8,Ed),e.createElementVNode("div",Bd,[g.inputType==="text"?(e.openBlock(),e.createBlock(St,{key:0,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="tel"?(e.openBlock(),e.createBlock(Bn,{key:1,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="email"?(e.openBlock(),e.createBlock(En,{key:2,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="mask"?(e.openBlock(),e.createBlock(vn,{key:3,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,mask:g.mask,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:k=>f(w.id),disabled:a.value,class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200 disabled:opacity-50"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,Vd)],42,vd))),128))],512),o.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Sd," Дані для відображення відсутні ")),e.createElementVNode("div",$d,[e.createElementVNode("button",{type:"button",onClick:x,disabled:m.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(c.value),1)],8,Nd)])]))}}),[["__scopeId","data-v-2c229b1f"]]),Ad={class:"flex items-center gap-2 w-full"},Fd=["disabled"],Dd=["disabled"],kr=e.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,{inputClass:o}=Fe(n.style),l=t,a=e.computed({get:()=>n.modelValue||"#000000",set:c=>l("update:modelValue",c)}),s=e.computed(()=>!!n.disabled);return(c,i)=>(e.openBlock(),e.createElementBlock("div",Ad,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":i[0]||(i[0]=d=>a.value=d),disabled:s.value,ref:"color",class:e.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[c.modelValue?"":"text-opacity-50",e.unref(o)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,Fd),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":i[1]||(i[1]=d=>a.value=d),disabled:s.value},null,8,Dd),[[e.vModelText,a.value]])]))}}),Md={class:"flex items-center gap-2 w-full"},Ld=["min","max","step","disabled"],Td=["disabled"],xr=e.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,{inputClass:o}=Fe(n.style),l=t,a=e.computed({get:()=>Number(n.modelValue??n.min),set:c=>l("update:modelValue",Number(c))}),s=e.computed(()=>!!n.disabled);return(c,i)=>(e.openBlock(),e.createElementBlock("div",Md,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":i[0]||(i[0]=d=>a.value=d),min:c.min,max:c.max,step:c.step,disabled:s.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[c.modelValue?"":"text-opacity-50",e.unref(o)].join(" ")])},null,10,Ld),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number","onUpdate:modelValue":i[1]||(i[1]=d=>a.value=d),disabled:s.value},null,8,Td),[[e.vModelText,a.value]])]))}}),Id=["placeholder","disabled","name"],Rd=["type","value","onInput","placeholder","disabled"],Od=["onClick"],wr=e.defineComponent({__name:"vs-input-array",props:e.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.ref(t.count),o=e.computed(()=>t.limit),{inputClass:l}=Fe(t.style),a=e.useModel(r,"modelValue"),s=e.computed(()=>!!t.disabled),c=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const h=a.value?.length??0;h<n.value&&(a.value=[...a.value??[],...Array(n.value-h)])});const i=e.ref({}),d=e.ref({});function p(h,g){h&&(i.value[g]=h)}async function m(h,g){if(!h||t.inputType!=="mask")return;const{default:C}=await Promise.resolve().then(()=>Hn);d.value[g]&&d.value[g].destroy(),d.value[g]=C(h,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[g].on("accept",()=>{const w=[...a.value||[]];w[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=w}),d.value[g].on("complete",()=>{const w=[...a.value||[]];w[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=w}),a.value?.[g]&&(d.value[g].value=a.value[g])}function x(h,g){if(s.value)return;const C=h.target.value??null,w=[...a.value];w[g]=t.inputType==="text"?C:Number(C),a.value=w}function f(){n.value+=1;const h=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,h],t.inputType==="mask"&&setTimeout(()=>{const g=n.value-1;i.value[g]&&m(i.value[g],g)},0)}function u(h){if(n.value>1){d.value[h]&&(d.value[h].destroy(),delete d.value[h]),n.value-=1,a.value=a.value.filter((C,w)=>w!==h);const g={};Object.keys(d.value).forEach(C=>{const w=parseInt(C,10);w>h?g[w-1]=d.value[w]:w<h&&(g[w]=d.value[w])}),d.value=g}}return e.onMounted(()=>{if(t.inputType==="mask")for(let h=0;h<n.value;h+=1)i.value[h]&&m(i.value[h],h)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(h=>{h&&h.destroy()})}),e.watch(()=>t.mask,h=>{t.inputType==="mask"&&Object.values(d.value).forEach(g=>{g&&g.updateOptions({mask:h,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,h=>{t.inputType==="mask"&&h&&h.forEach((g,C)=>{d.value[C]&&d.value[C].value!==g&&(d.value[C].value=g||"")})},{deep:!0}),(h,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["grid gap-2",`grid-cols-${o.value}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,C=>(e.openBlock(),e.createElementBlock("div",{key:C,class:"flex items-center gap-2 w-full"},[h.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:w=>p(w,C-1),placeholder:h.placeholder,disabled:h.disabled,name:`${h.name}[${C-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Id)):(e.openBlock(),e.createElementBlock("input",{key:1,type:h.inputType,value:a.value?.[C-1],onInput:w=>x(w,C-1),placeholder:c.value,disabled:s.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,Rd)),!h.disabled&&C===n.value&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(f,["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-green-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"})])):e.createCommentVNode("",!0),!h.disabled&&n.value>1&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(w=>u(C-1),["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-red-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,Od)):e.createCommentVNode("",!0)]))),128))],2))}}),zd=["aria-expanded","data-focus"],Pd=["placeholder","disabled","readonly"],jd={class:"max-h-full"},Ud=["onClick","disabled"],Hd={key:0,class:"px-3 py-2 text-sm text-stone-500"},qd={class:"flex flex-col gap-1"},Kd=["onDragstart","onDrop"],Gd=["disabled"],Wd=["title"],Yd=["disabled","onClick","aria-label"],Zd={key:0,class:"text-xs text-stone-500"},Qt=fe(e.defineComponent({__name:"vs-input-array-select",props:e.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(r,{emit:t}){const n=r,o=t,l=e.useModel(r,"modelValue"),a=e.ref([]),s=e.ref(n.options??[]),c=e.ref({}),i=e.ref({}),d=e.ref({keyword:"",parent:null}),p=e.ref(""),m=e.ref(!1),x=e.ref(null),f=e.ref(null),u=e.ref(null),h=e.ref(null),g=e.ref(null),C=e.ref({});let w=!1,b=!1;const k=e.inject("values"),B=e.computed(()=>!!n.disabled),M=e.computed(()=>n.placeholder??"Оберіть значення"),$=e.computed(()=>n.search!==!1),E=e.computed(()=>{const V=n.parent??n.parentValue;return V?String(V):""}),N=e.computed(()=>E.value?k?.value?.[E.value]??null:null),v=V=>V==null?"__null__":String(V),S=V=>{if(!V)return"";const Z=V.label??V.text??V.name??V.ua??V.en;return Z?String(Z):V.id!==void 0&&V.id!==null?String(V.id):""},D=V=>{const Z=v(V);return i.value[Z]||(i.value[Z]=`array-select-${Z}-${Math.random().toString(36).slice(2,8)}`),i.value[Z]},I=e.computed(()=>new Set(a.value.map(V=>v(V.id)))),A=e.computed(()=>{const V=I.value;let Z=[...s.value];if(!n.data&&p.value.trim()){const ee=p.value.toLowerCase();Z=Z.filter(pe=>S(pe).toLowerCase().includes(ee))}return Z.filter(ee=>!V.has(v(ee.id)))}),T=()=>{if(!n.data)return"";const V=n.prefix??"api",Z=n.api??`/${V}/suggest/${n.data}`;return`${n.host??""}${Z}`},L=()=>{a.value.length&&(w=!0,a.value=a.value.map(V=>({...V,text:c.value[v(V.id)]??V.text})))},U=V=>{const Z=v(V.id),ee=S(V);ee&&(c.value[Z]=ee)},H=V=>{s.value=V?[...V]:[],V?.forEach(U),L()},W=V=>{if(!V.length)return;const Z=new Map(s.value.map(ee=>[v(ee.id),ee]));V.forEach(ee=>{const pe=v(ee.id);Z.set(pe,ee),U(ee)}),s.value=Array.from(Z.values()),L()},Q=async(V="")=>{if(!n.data)return[];const Z=T();if(!Z)return[];const ee=new URLSearchParams;ee.set("json","1"),V&&ee.set("key",V),n.start===1&&ee.set("start","1"),N.value!==null&&N.value!==void 0&&N.value!==""&&ee.set("parent",String(N.value));try{return(await(await fetch(`${Z}?${ee.toString()}`)).json())?.data??[]}catch{return[]}},ve=async V=>{if(!n.data||!V.length)return[];const Z=T();if(!Z)return[];const ee=Array.from(new Set(V.map(Ee=>v(Ee)))),pe=new URLSearchParams;pe.set("json","1"),pe.set("val",ee.join(",")),n.start===1&&pe.set("start","1"),N.value!==null&&N.value!==void 0&&N.value!==""&&pe.set("parent",String(N.value));try{const ot=(await(await fetch(`${Z}?${pe.toString()}`)).json())?.data??[];return W(ot),ot}catch{return[]}},ie=async(V="",{force:Z=!1}={})=>{if(!n.data)return;const ee=N.value??null;if(!Z&&d.value.keyword===V&&d.value.parent===ee&&s.value.length>0)return;d.value={keyword:V,parent:ee};const Ee=await Q(V);H(Ee)},ne=((V,Z=200)=>{let ee;return(...pe)=>{ee&&clearTimeout(ee),ee=setTimeout(()=>V(...pe),Z)}})(async V=>{n.data&&await ie(V,{force:!0})},250),ce=e.ref(null),ye=()=>{if(!u.value)return;const V=u.value.getBoundingClientRect(),Z=window.innerHeight??document.documentElement.clientHeight,ee=window.innerWidth??document.documentElement.clientWidth,pe=8,Ee=8,vt=n.maxHeight??280,ot=Z-V.bottom-Ee-pe,gt=V.top-Ee-pe,yt=ot>=gt,bt=Math.max(ee-pe*2,0);let{width:Te}=V;bt>0&&Te>bt&&(Te=bt);let{left:We}=V;We+Te+pe>ee&&(We=ee-Te-pe),We=Math.max(We,pe);const ct=Math.min(vt,Math.max(yt?ot:gt,50));C.value={position:"fixed",left:`${We}px`,width:`${Te}px`,maxHeight:`${ct}px`,transform:yt?"none":"translateY(-100%)",top:yt?`${V.bottom+Ee}px`:`${V.top-Ee}px`}},ke=async(V="click")=>{B.value||m.value||(ce.value=V,await ie(p.value.trim()),m.value=!0,await e.nextTick(),ye(),g.value?.focus())},De=()=>{m.value=!1,ce.value=null,e.nextTick(()=>{g.value?.blur()})},Me=async V=>{if(V.stopPropagation(),!B.value){if(m.value){if(ce.value==="focus"){ce.value=null;return}De();return}await ke("click")}},we=V=>{V.key==="Escape"&&De()},Xe=V=>{if(!m.value)return;const Z=V.target;h.value?.contains(Z)||De()},Le=V=>{const Z=V.target;f.value?.contains(Z)||h.value?.contains(Z)||De()},Je=V=>{if(V.key==="Escape"){V.preventDefault(),De();return}if(V.key==="Enter"){V.preventDefault();const Z=A.value[0];Z&&j(Z)}},j=V=>{if(!V)return;const Z=v(V.id);if(I.value.has(Z))return;U(V);const ee={id:V.id,text:S(V)||String(V.id??""),key:D(V.id)};a.value=[...a.value,ee],Y(V),p.value="",e.nextTick(()=>{g.value?.focus()})},Y=V=>{const Z=a.value.map(ee=>ee.id);o("value-selected",{name:n.name,value:Z,option:V})},J=V=>{if(B.value)return;const Z=a.value.filter(ee=>v(ee.id)!==v(V));a.value=Z},oe=V=>{B.value||(x.value=V)},ae=V=>{if(B.value||x.value===null||x.value===V)return;const Z=[...a.value],[ee]=Z.splice(x.value,1);Z.splice(V,0,ee),x.value=null,a.value=Z},xe=async()=>{const Z=(Array.isArray(l.value)?[...l.value]:[]).filter(pe=>pe!=null);if(n.data&&Z.length){const pe=Z.filter(Ee=>!c.value[v(Ee)]);pe.length&&await ve(pe)}const ee=Z.map(pe=>({id:pe,text:c.value[v(pe)]??String(pe),key:D(pe)}));w=!0,a.value=ee};e.watch(a,V=>{if(w){w=!1;return}const Z=V.map(ee=>ee.id);b=!0,l.value=Z,o("change",Z)},{deep:!0}),e.watch(l,()=>{if(b){b=!1;return}xe()},{deep:!0}),e.watch(p,V=>{!n.data||!m.value||ne(V.trim())}),e.watch(B,V=>{V&&De()}),e.watch(()=>n.options,async V=>{n.data||(H(V??[]),await xe())},{immediate:!0,deep:!0}),e.watch(()=>n.data,async V=>{V&&(await ie(p.value.trim()),await xe())},{immediate:!0});const P=e.ref(!1);return e.watch(N,async()=>{if(n.data){if(!P.value){P.value=!0;return}a.value=[],await ie(p.value.trim()),await xe()}}),e.onMounted(async()=>{document.addEventListener("click",Le,!0),window.addEventListener("keydown",we),window.addEventListener("scroll",Xe,!0),await xe()}),e.onUnmounted(()=>{document.removeEventListener("click",Le,!0),window.removeEventListener("keydown",we),window.removeEventListener("scroll",Xe,!0)}),(V,Z)=>(e.openBlock(),e.createElementBlock("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:f},[e.createElementVNode("div",{class:"relative",onClick:Z[2]||(Z[2]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:u,class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",m.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",B.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),role:"combobox","aria-expanded":m.value,"aria-haspopup":"listbox","data-focus":m.value?"true":"false",onClick:Me},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":Z[0]||(Z[0]=ee=>p.value=ee),placeholder:M.value,disabled:B.value,readonly:!$.value,onFocus:Z[1]||(Z[1]=()=>ke("focus")),onKeydown:Je,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,Pd),[[e.vModelText,p.value]]),e.createElementVNode("span",{class:e.normalizeClass(["text-stone-400 transition-transform duration-150",m.value?"rotate-180":""]),"aria-hidden":"true"},[e.createVNode(e.unref(z.ChevronDown),{class:"h-4 w-4"})],2)],10,zd),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:h,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(C.value)},[e.createElementVNode("div",jd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value,ee=>(e.openBlock(),e.createElementBlock("button",{key:v(ee.id),type:"button",class:"w-full px-3 py-2 text-left text-sm text-stone-900 hover:bg-stone-100 disabled:opacity-50",onClick:e.withModifiers(pe=>j(ee),["stop"]),disabled:B.value},e.toDisplayString(S(ee)),9,Ud))),128)),A.value.length===0?(e.openBlock(),e.createElementBlock("p",Hd," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),e.createElementVNode("div",qd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(ee,pe)=>(e.openBlock(),e.createElementBlock("div",{key:ee.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":x.value===pe}]),draggable:"true",onDragstart:Ee=>oe(pe),onDragover:Z[3]||(Z[3]=e.withModifiers(()=>{},["prevent"])),onDrop:Ee=>ae(pe),onDragend:Z[4]||(Z[4]=Ee=>x.value=null)},[e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-500 hover:text-stone-900",disabled:B.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(z.GripVertical),{class:"h-4 w-4"})],8,Gd),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:ee.text},e.toDisplayString(ee.text),9,Wd),e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-400 hover:text-stone-900",disabled:B.value,onClick:e.withModifiers(Ee=>J(ee.id),["stop"]),"aria-label":`Видалити ${ee.text}`},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,Yd)],42,Kd))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",Zd,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512))}}),[["__scopeId","data-v-56e6cd88"]]),Xd={class:"flex items-center gap-2 w-full"},Jd={class:"relative flex-1"},Qd=["placeholder","disabled","onKeydown"],eu=["disabled"],tu={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},nu={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},ru={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},ou=["onClick"],lu={key:0,class:"p-4 text-sm text-gray-500"},_r=e.defineComponent({__name:"vs-input-address",props:e.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(r,{emit:t}){const n=/{{\s*([^}]+?)\s*}}/g,o=r,l=t,{inputClass:a}=Fe(o.style),s=e.useModel(r,"modelValue"),c=e.computed({get:()=>s.value,set:$=>{s.value=$}}),i=e.ref(!1),d=e.ref([]),p=e.ref(!1),m=e.ref(null);e.watch(p,$=>{typeof document>"u"||($?(m.value=document.body.style.overflow,document.body.style.overflow="hidden"):m.value!=null?(document.body.style.overflow=m.value,m.value=null):document.body.style.removeProperty("overflow"))}),e.onBeforeUnmount(()=>{typeof document>"u"||(m.value!=null?document.body.style.overflow=m.value:document.body.style.removeProperty("overflow"))});const x=e.computed(()=>o.placeholder??""),f=e.computed(()=>!!o.disabled),u=$=>{if(!$)return null;if(Array.isArray($))return $;if(typeof $=="string"){const E=$.split(",").map(N=>N.trim()).filter(Boolean);return E.length!==4?null:E.map(Number)}return null},h=e.computed(()=>{const $=u(o.bbox);if(!$||$.length!==4)return null;const E=$.map(Number);return E.some(N=>Number.isNaN(N))?null:E}),g=e.computed(()=>{const $=h.value;if(!$)return"";const[E,N,v,S]=$;return`${E},${Math.max(N,S)},${v},${Math.min(N,S)}`});e.computed(()=>g.value?"1":"0");const C=e.inject("values");function w(){!f.value&&c.value.trim()&&b()}async function b(){const $=(c.value||"").trim();if(!$)return;let E=$;if(o.includes?.length&&C?.value){const v=o.includes.map(S=>C.value?.[S]).filter(Boolean);v.length&&(E=`${v.join(", ")}, ${$}`)}const N=M(E);if(N){i.value=!0;try{const S=await(await fetch(N)).json();d.value=Array.isArray(S)?S:[],p.value=!0}catch(v){console.error("Address search error:",v)}finally{i.value=!1}}}function k(){p.value=!p.value}function B($){if(!$)return;p.value=!1;const E=parseFloat($.lat),v={type:"Point",coordinates:[parseFloat($.lon),E]};o.geom&&C?.value&&(C.value[o.geom]=v),l("update:geom",v)}function M($){if(!o.api)return"";const E={value:encodeURIComponent($),bbox:h.value?h.value.join(","):""};return o.api.replace(n,(N,v)=>E[v.trim()]??"")}return($,E)=>(e.openBlock(),e.createElementBlock("div",Xd,[e.createElementVNode("div",Jd,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":E[0]||(E[0]=N=>c.value=N),placeholder:x.value,disabled:f.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white border rounded-md placeholder:text-gray-400 focus:ring-2 focus:ring-blue-500",[e.unref(a),{"!border-red-600":o.error}]]),style:{border:"1px solid #CFD9E0"},onKeydown:e.withKeys(e.withModifiers(w,["prevent"]),["enter"])},null,42,Qd),[[e.vModelText,c.value]]),d.value.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick:k,title:"Show search results"},[e.createVNode(e.unref(z.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:b,class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px]",disabled:i.value||!c.value?.trim()},[i.value?(e.openBlock(),e.createBlock(e.unref(z.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(z.Search),{key:0,class:"h-4 w-4"}))],8,eu),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[p.value?(e.openBlock(),e.createElementBlock("div",tu,[e.createElementVNode("div",nu,[e.createElementVNode("div",ru,[E[2]||(E[2]=e.createElementVNode("span",null,"Search results",-1)),e.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:E[1]||(E[1]=N=>p.value=!1),title:"Close"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(N,v)=>(e.openBlock(),e.createElementBlock("li",{key:v,onClick:S=>B(N),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(N.display_name),9,ou))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",lu," No results found "))])])):e.createCommentVNode("",!0)]))]))}}),Cr=(r="")=>`${r}${Math.floor(Math.random()*1e4)}`,au={class:"vs-datalist space-y-3"},su={class:"space-y-3"},iu=["onClick","disabled"],cu={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},du=["disabled"],uu=fe(e.defineComponent({__name:"vs-input-datalist",props:e.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.computed(()=>Array.isArray(n.value)?n.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(h=>({...h,disabled:t.disabled||h.disabled}))??[]),s=e.computed(()=>a.value.map(h=>u(h))),c=e.computed(()=>t.disabled?!1:t.maxItems?o.value.length<t.maxItems:!0),i=e.computed(()=>t.disabled||o.value.length<=(t.minItems||0));e.watch(()=>o.value.length,()=>{d(),p()},{immediate:!0}),e.watch(()=>t.schema,p,{immediate:!0,deep:!0});function d(){const h=o.value.length;l.value.length<h?l.value=[...l.value,...Array.from({length:h-l.value.length},()=>Cr())]:l.value.length>h&&l.value.splice(h)}function p(){if(!t.minItems||o.value.length>=t.minItems)return;const h=t.minItems-o.value.length,g=Array.from({length:h},m);n.value=[...o.value,...g]}function m(){const h={};return a.value.forEach(g=>{h[g.name]=g?.default??null}),h}function x(){c.value&&(n.value=[...o.value,m()],d())}function f(h){i.value||(n.value=o.value.filter((g,C)=>C!==h),d(),p())}function u(h){return{...h}}return(h,g)=>(e.openBlock(),e.createElementBlock("div",au,[e.createElementVNode("div",su,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(C,w)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[w],class:"flex items-center gap-3"},[e.createVNode(Ye,{schema:s.value,layout:"inline",navigation:!1,values:o.value[w],"onUpdate:values":b=>o.value[w]=b,"form-id":l.value[w]},null,8,["schema","values","onUpdate:values","form-id"]),e.createElementVNode("button",{type:"button",class:"h-[38px] w-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",onClick:b=>f(w),disabled:i.value},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,iu)]))),128)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",cu,e.toDisplayString(t.emptyLabel),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:x,disabled:!c.value},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,du)]))}}),[["__scopeId","data-v-260e3e66"]]),pu={class:"vs-dataform space-y-4"},fu=["draggable","onDragstart","onDragover","onDragenter","onDrop"],mu={class:"flex items-center gap-2"},hu=["onClick"],gu={class:"text-sm font-medium text-gray-700"},yu={class:"flex items-center gap-2"},bu=["title","onClick","disabled"],ku=["title","onClick","disabled"],xu={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},wu=["disabled"],_u=fe(e.defineComponent({__name:"vs-input-dataform",props:e.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),c=e.ref(null),i=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),p=e.computed(()=>t.emptyLabel??"Ще немає груп"),m=e.computed(()=>t.schema?.map(G=>({...G,disabled:t.disabled||G.disabled}))??[]),x=e.computed(()=>m.value.map(G=>N(G))),f=e.computed(()=>t.view==="accordion"),u=e.computed(()=>!!(t.collapsible||f.value)),h=e.computed(()=>t.draggable!==!1),g=e.computed(()=>t.disabled?!1:t.maxGroups?n.value.length<t.maxGroups:!0),C=e.computed(()=>t.disabled||n.value.length<=(t.minGroups||0));e.watch(()=>n.value.length,()=>{w(),b(),k()},{immediate:!0}),e.watch(()=>t.schema,k,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{b()},{immediate:!0});function w(){const G=n.value.length;o.value.length<G?o.value=[...o.value,...Array.from({length:G-o.value.length},()=>Cr())]:o.value.length>G&&o.value.splice(G)}function b(){const G=n.value.length;f.value?G===0?a.value=-1:a.value>=G?a.value=G-1:a.value<0&&(a.value=0):l.value.length<G?l.value=[...l.value,...Array.from({length:G-l.value.length},()=>!1)]:l.value.length>G&&l.value.splice(G)}function k(){if(!t.minGroups||n.value.length>=t.minGroups)return;const G=t.minGroups-n.value.length,ne=Array.from({length:G},B);n.value=[...n.value,...ne],b()}function B(){const G={};return m.value.forEach(ne=>{G[ne.name]=ne?.default??null}),G}function M(){g.value&&(n.value=[...n.value,B()],w(),b())}function $(G){C.value||(n.value=n.value.filter((ne,ce)=>ce!==G),w(),f.value?a.value>=n.value.length&&(a.value=n.value.length-1):l.value.splice(G,1),k())}function E(G){if(t.disabled)return;const ne=JSON.parse(JSON.stringify(n.value[G]??{}));n.value=[...n.value.slice(0,G+1),ne,...n.value.slice(G+1)],w(),f.value?a.value>G&&(a.value+=1):l.value.splice(G+1,0,l.value[G]??!1)}function N(G){return{...G}}function v(G){return f.value?a.value===-1&&G===0?!1:a.value!==G:!!l.value[G]}function S(G){if(u.value){if(f.value){a.value=G;return}l.value[G]=!l.value[G]}}function D(G,ne){if(!h.value||t.disabled){ne.preventDefault();return}s.value=G,c.value=G,i.value={groups:JSON.parse(JSON.stringify(n.value)),keys:[...o.value],states:[...l.value]},ne.dataTransfer?.setData("text/plain",String(G)),ne.dataTransfer?.setDragImage?.(ne.currentTarget,0,0)}function I(G,ne){!h.value||t.disabled||s.value!==null&&W(G,ne)}function A(G,ne){W(G,ne)}function T(G){!h.value||t.disabled||ie()}function L(){i.value&&H(),s.value=null,c.value=null,i.value=null}function U(G,ne){const ce=[...n.value],[ye]=ce.splice(G,1);ce.splice(ne,0,ye),n.value=ce;const ke=[...o.value],[De]=ke.splice(G,1);if(ke.splice(ne,0,De),o.value=ke,f.value)a.value===G&&(a.value=ne);else{const Me=[...l.value],[we]=Me.splice(G,1);Me.splice(ne,0,we),l.value=Me}}function H(){i.value&&(n.value=i.value.groups,o.value=i.value.keys,l.value=i.value.states,i.value=null,c.value=null)}function W(G,ne){if(s.value===null)return;const ce=Q(G,ne);c.value=ce,ve(ce)}function Q(G,ne){if(!ne?.currentTarget)return G;const ce=ne.currentTarget.getBoundingClientRect(),ke=ne.clientY-ce.top>ce.height/2?G+1:G;return Math.max(0,Math.min(ke,n.value.length))}function ve(G){const ne=s.value;if(ne===null)return;let ce=G;if(ce>n.value.length&&(ce=n.value.length),ce===ne||ce===ne+1)return;const ye=ce>ne?ce-1:ce;U(ne,ye),s.value=ye,c.value=ce>ne?ye+1:ye}function ie(){i.value=null,s.value=null,c.value=null}return(G,ne)=>(e.openBlock(),e.createElementBlock("div",pu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(ce,ye)=>(e.openBlock(),e.createElementBlock("div",{key:o.value[ye],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":v(ye)?"pt-6 px-6":"p-6"]]),draggable:h.value&&!t.disabled,onDragstart:ke=>D(ye,ke),onDragend:L,onDragover:e.withModifiers(ke=>I(ye,ke),["prevent"]),onDragenter:e.withModifiers(ke=>A(ye,ke),["prevent"]),onDrop:e.withModifiers(ke=>T(),["prevent"])},[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3",[t.view!=="accordion"?"-mx-6 -mt-6 px-6":"",t.view!=="accordion"&&!v(ye)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",mu,[h.value?(e.openBlock(),e.createBlock(e.unref(z.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:ke=>S(ye)},[e.createVNode(e.unref(z.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",v(ye)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,hu)):e.createCommentVNode("",!0),e.createElementVNode("div",gu,e.toDisplayString(`${d.value} (${ye+1})`),1)]),e.createElementVNode("div",yu,[e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.duplicateTitle,onClick:ke=>E(ye),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(z.Copy),{class:"h-4 w-4"})],8,bu),e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.removeTitle,onClick:ke=>$(ye),disabled:C.value,draggable:"false"},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,ku)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(Ye,{class:"vs-dataform__form",schema:x.value,layout:"inline",navigation:!1,values:n.value[ye],"onUpdate:values":ke=>n.value[ye]=ke,"form-id":o.value[ye],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!v(ye)]])],42,fu))),128)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",xu,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:M,disabled:!g.value},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,wu)]))}}),[["__scopeId","data-v-cfbcfed8"]]),en="__vs_form_monaco_loader__",_t="__vs_form_monaco_script_loader__",tn="__vs_form_monaco_editor_loader__",Fn=e.defineComponent({__name:"vs-input-monaco",props:e.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r,{expose:t}){const n=r,o=e.useModel(r,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof n.height=="number"?`${n.height}px`:n.height||"280px");let s=null,c=null,i=!1;const d=()=>{if(c)return Promise.resolve(c);if(typeof window>"u")return Promise.resolve(null);const u=window;if(u.monaco?.editor?.create)return c=u.monaco,Promise.resolve(c);if(u[en])return u[en];const g=(async()=>{const C=k=>{if(Array.from(document.styleSheets||[]).some($=>$?.href?.includes(k)))return;const M=document.createElement("link");M.rel="stylesheet",M.href=k,document.head.appendChild(M)},w=k=>{if(u[_t]?.[k])return u[_t][k];u[_t]||={};const B=Array.from(document.scripts).find(M=>M.src===k);return B?(u[_t][k]=new Promise((M,$)=>{const E=B.readyState;if(B.dataset.loaded==="true"||E==="loaded"||E==="complete"){M();return}B.addEventListener("load",()=>{B.dataset.loaded="true",M()},{once:!0}),B.addEventListener("error",N=>$(N),{once:!0})}),u[_t][k]):(u[_t][k]=new Promise((M,$)=>{const E=document.createElement("script");E.src=k,E.async=!0,E.onload=()=>{E.dataset.loaded="true",M()},E.onerror=N=>$(N),document.body.appendChild(E)}),u[_t][k])},b="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return C(`${b}/editor/editor.main.min.css`),await w(`${b}/loader.min.js`),u[tn]||(u[tn]=new Promise((k,B)=>{window.require.config({paths:{vs:b}}),window.require(["vs/editor/editor.main"],()=>{c=window.monaco,u.monaco=c,k(c)},M=>B(M))}).catch(k=>{throw delete u[tn],k})),u[tn]})().catch(C=>{throw delete u[en],C});return u[en]=g,g},p=()=>{!l.value||!c||(s&&(s.dispose(),s=null),s=c.editor.create(l.value,{value:o.value||"",language:n.syntax,theme:n.theme,automaticLayout:!0,minimap:{enabled:!!n.minimap},readOnly:!!n.disabled}),s.onDidChangeModelContent(()=>{i||(o.value=s.getValue())}))},m=()=>{s?.focus()},x=()=>s,f=()=>c;return e.watch(()=>o.value,u=>{if(!s)return;const h=s.getValue();u!==h&&(i=!0,s.setValue(u||""),i=!1)}),e.watch(()=>n.syntax,u=>{!s||!c||c.editor.setModelLanguage(s.getModel(),u||"xml")}),e.watch(()=>n.theme,u=>{c&&c.editor.setTheme(u||"vs-light")}),e.watch(()=>n.disabled,u=>{s&&s.updateOptions({readOnly:!!u})}),e.watch(()=>n.minimap,u=>{s&&s.updateOptions({minimap:{enabled:!!u}})}),e.onMounted(async()=>{try{const u=await d();if(!u||!u.editor)return;c=u,p()}catch(u){console.error("Failed to load Monaco editor",u)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:m,getEditor:x,getMonaco:f}),(u,h)=>(e.openBlock(),e.createElementBlock("div",{class:"w-full",style:e.normalizeStyle({height:a.value})},[e.createElementVNode("div",{ref_key:"editorContainer",ref:l,class:"w-full h-full overflow-hidden border border-[#CFD9E0] rounded"},null,512)],4))}}),vr={VsInputText:St,VsInputRadio:Vn,"vs-input-text":St,"vs-input-password":Lo,"vs-input-textarea":sr,"vs-input-richtext":ir,"vs-input-mask":vn,"vs-input-number":Qn,"vs-input-radio":Vn,"vs-input-select":An,"vs-input-switcher":_n,"vs-input-static":Cn,"vs-input-container":ar,"vs-input-date":bl,"vs-input-checkbox":er,"vs-input-file":rr,"vs-input-file2":$n,file2:$n,File2:$n,"vs-input-html":Cn,"vs-input-email":En,"vs-input-tel":Bn,"vs-input-datatable":cr,"vs-input-map":fr,"vs-input-file-list":or,"vs-input-tags":mr,"vs-input-slug":hr,"vs-input-codegen":gr,"vs-input-key-value":yr,"vs-input-text[]":br,"vs-input-range":xr,"vs-input-color":kr,"vs-input-native-select":An,VsInputArraySelect:Qt,"vs-input-array":wr,"vs-input-array-select":Qt,"array-select":Qt,"vs-input-address":_r,"vs-input-datalist":uu,"vs-input-dataform":_u,"vs-input-monaco":Fn},Cu=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(r){const t=r,n=e.inject("values");async function o(){try{if(!t.api)return;const l=t.api.replace("{{value}}",t.value),a=await fetch(l);if(!a.ok){me.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!n)return;for(const[c,i]of Object.entries(t.set))n.value[c]=s.result[i]}catch(l){console.error(t.error,l)}}return(l,a)=>(e.openBlock(),e.createElementBlock("button",{onClick:o,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},e.toDisplayString(l.button),1))}}),vu={class:"flex flex-col gap-1 w-full"},Eu=["innerHTML"],Er=e.defineComponent({__name:"vs-compact-form-layout",props:e.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:e.mergeModels(["value-selected"],["update:modelValue"]),setup(r,{emit:t}){const n=r,o=e.useModel(r,"modelValue"),l=t,a=e.computed(()=>Do[`${n.layout}`]),s=["label","placeholder","info","description","text","html"],c=e.ref(C()),i=e.computed(()=>u(n.item,c.value)),d=e.computed(()=>vr?.[`vs-input-${n.item.type}`]),p=e.inject("field-props"),m=e.computed(()=>{const b=e.unref(d);if(!b)return new Set;const k=b.props??b.__vccOpts?.props;if(!k)return new Set;const B=Array.isArray(k)?k:Object.keys(k);return new Set(B)}),x=e.computed(()=>{const b={...i.value??{}},k=n.item?.name;k&&p?.value?.[k]&&Object.assign(b,p.value[k]);const B=m.value;return B.size?Object.fromEntries(Object.entries(b).filter(([M])=>B.has(M))):{}}),f=b=>{const k=typeof b=="object"&&b!==null?b:{value:b};l("value-selected",{...k,name:k.name??n.item?.name})};e.onMounted(()=>{c.value=C(),window.addEventListener("storage",w)}),e.onUnmounted(()=>{window.removeEventListener("storage",w)});function u(b,k){if(!b)return{};const B={...b};return s.forEach(M=>{const $=g(b,M,k);$!=null&&(B[M]=$)}),Array.isArray(b.options)&&(B.options=b.options.map(M=>h(M,k))),B}function h(b,k){if(!b)return b;const B={...b},M=g(b,"label",k),$=g(b,"text",k);return M!=null&&(B.label=M),$!=null?B.text=$:M!=null&&(B.text=M),B}function g(b,k,B){const M=`${k}:${B}`;if(b?.[M]!=null)return b[M];if(k==="label"&&b?.[B]!=null)return b[B];if(b?.[k]!=null)return b[k];if(k==="label"){if(b?.ua!=null)return b.ua;if(b?.en!=null)return b.en}if(k==="text"||k==="html"){if(b?.ua!=null)return b.ua;if(b?.en!=null)return b.en}return null}function C(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function w(){c.value=C()}return(b,k)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:i.value.ua,error:n.error||"",item:i.value,columns:n.columns,label:i.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${n.item.type}-component`])},[e.createElementVNode("div",vu,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),e.mergeProps(x.value,{modelValue:o.value,"onUpdate:modelValue":k[0]||(k[0]=B=>o.value=B),onValueSelected:f}),null,16,["modelValue"])),i.value.description&&n.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:i.value.description},null,8,Eu)):e.createCommentVNode("",!0)]),i.value.behavior?.api&&i.value.behavior?.button?(e.openBlock(),e.createBlock(Cu,e.mergeProps({key:0},i.value.behavior,{value:o.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),Bu={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},Vu={class:"vs-compact-form-navigation__rail mt-[6px]"},Su=["onClick"],$u=fe(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(r,{expose:t}){const n=r,o=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!n.enabled),c=e.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),i=e.computed(()=>{const S=n.width;if(S==null)return{};const D=typeof S=="number"?`${S}px`:`${S}`;return{width:D,minWidth:D}});let d=null,p=0,m=0,x=null,f=null,u=null;const h=()=>N(),g=()=>w();e.watch(()=>n.target,async S=>{if(M(),!S){x=null,o.value=[],l.value="";return}x=S,s.value&&(await e.nextTick(),B(S),w())},{immediate:!0}),e.watch(()=>n.scrollContainer,S=>{if(!s.value){f=S??null;return}C(S??null),e.nextTick(()=>w())},{immediate:!0}),e.onMounted(()=>{n.scrollContainer||C(null),w()}),e.onBeforeUnmount(()=>{M(),C(null,!0),x=null,typeof window<"u"&&(p&&window.cancelAnimationFrame(p),m&&window.cancelAnimationFrame(m))});function C(S,D=!1){if(u&&(u(),u=null),D){f=null;return}if(f=S??null,typeof window>"u")return;const I=S??window,A=window;I.addEventListener("scroll",h,{passive:!0}),A.addEventListener("resize",g),u=()=>{I.removeEventListener("scroll",h),A.removeEventListener("resize",g)}}function w(){if(!s.value||!x)return;p&&typeof window<"u"&&window.cancelAnimationFrame(p);const S=()=>{b(),p=0};typeof window>"u"?S():p=window.requestAnimationFrame(S)}function b(){if(!s.value||!x)return;const S=Array.from(x.querySelectorAll("h1, h2")),D=new Set,I=[];S.forEach((A,T)=>{const L=A.textContent?.trim()??"";if(!L)return;let U=(A.getAttribute("id")??"").trim();U||(U=k(L)||`heading-${T+1}`);let H=U,W=1;for(;D.has(H);)H=`${U}-${W+=1}`;A.id!==H&&Object.assign(A,{id:H}),D.add(H),I.push({id:H,text:L,level:A.tagName.toLowerCase()==="h1"?1:2})}),o.value=I,I.length||(l.value=""),E()}function k(S){return S.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function B(S){!S||!s.value||typeof MutationObserver>"u"||(M(),d=new MutationObserver(()=>w()),d.observe(S,{childList:!0,subtree:!0}))}function M(){d&&(d.disconnect(),d=null)}function $(S){const D=f;if(!D)return typeof window>"u"?S.offsetTop:S.getBoundingClientRect().top+window.scrollY;const I=S.getBoundingClientRect(),A=D.getBoundingClientRect();return I.top-A.top+D.scrollTop}function E(){if(!s.value||!o.value.length)return;const S=f,D=(S?S.scrollTop:null)||(typeof window<"u"?window.scrollY:0),I=(S?S.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),A=D+I;let T=null;for(let U=0;U<o.value.length;U+=1){const H=o.value[U],W=document.getElementById(H.id);if(W){const Q=$(W);Q+W.offsetHeight>D&&Q<A&&(T=H.id)}}!T&&a.value&&(T=a.value),T&&(a.value=T);const L=S?S.scrollHeight-S.clientHeight:document.documentElement.scrollHeight-window.innerHeight;D+5>=L&&(T=o.value[o.value.length-1].id),T&&(l.value=T)}function N(){s.value&&(m&&window.cancelAnimationFrame(m),m=window.requestAnimationFrame(()=>{E(),m=0}))}function v(S){if(!s.value)return;const D=document.getElementById(S);if(!D)return;const I=f,A=Math.max(0,$(D));I?I.scrollTo({top:A,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:A,behavior:"smooth"})}return t({refresh:w}),(S,D)=>s.value&&o.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(c.value),style:e.normalizeStyle(i.value)},[e.createElementVNode("h2",Bu,e.toDisplayString(S.title),1),e.createElementVNode("div",Vu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,I=>(e.openBlock(),e.createElementBlock("div",{key:I.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",I.level===2?"vs-compact-form-navigation__item--nested":"",I.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:A=>v(I.id),class:e.normalizeClass(["vs-compact-form-navigation__button flex gap-x-3 py-[6px] pr-3 text-sm duration-200 hover:text-gray-800",I.level===2?"pl-[15px]":"pl-[18px]",I.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(I.text),1)],10,Su)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),ut={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:r=>`Мінімальна довжина — ${r} символів`,maxlength:r=>`Максимальна довжина — ${r} символів`},Nu=r=>typeof r=="string"?r.trim()?!1:ut.required:Array.isArray(r)?r.map(n=>typeof n=="string"?n.trim():n).filter(n=>n!=null&&n!=="").length?!1:ut.required:typeof r=="number"?Number?.isNaN(r)?ut?.required:!1:r?!1:ut.required,Au=r=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return r?t.test(r)?!1:ut.email:!1},Fu=r=>{const t=/^\+[1-9]\d{1,14}$/;return r?t.test(r)?!1:ut.tel:!1},Br=r=>r==null?0:typeof r=="string"?r.trim().length:Array.isArray(r)?r.length:typeof r=="number"?r.toString().length:String(r).length,Du=(r,t)=>{if(r==null)return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&Br(r)<n?t?.message||ut.minlength(n):!1},Mu=(r,t)=>{if(r==null||r==="")return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&Br(r)>n?t?.message||ut.maxlength(n):!1},Lu=(r,t)=>{const n=t.pattern??t.regexp,o=typeof n=="string"?new RegExp(n):n;if(Array.isArray(r)){const l=r.filter(Boolean);return l.length===0||l.every(a=>o.test(a))?!1:t.message}return!o.test(r)&&r?t.message:!1},Tu=(r,t)=>!1,Iu=(r,t)=>{switch(typeof t=="string"?t:t.type){case"required":return Nu(r);case"email":return Au(r);case"tel":return Fu(r);case"regexp":return Lu(r,t);case"minlength":return Du(r,t);case"maxlength":return Mu(r,t);case"custom":return Tu();default:return!1}},Ru={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file"};function Vr(r){const t=r?.toLowerCase();return Ru[t]||t}function Dn(r,t=!1){if(Array.isArray(r)){const o=[];return r.forEach(l=>{const a={...l};a.name=(l.name||l.id||l.key||"").toString(),a.type=Vr(l.type),a.label=l.label||l.ua,a.rules=l.rules||l.validators,a.type==="email"&&!a.rules&&(a.rules=["email"]),l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=Dn(a.schema,a.disabled)),o.push(a)}),o}const n=[];return Object.entries(r).forEach(o=>{const l={name:o[0],...o[1],type:Vr(o[1].type),label:o[1].label||o[1].ua,rules:o[1].rules||o[1].validators,disabled:o[1].disabled??t};l.type==="email"&&!l.rules&&(l.rules=["email"]),o[1].type?.includes("list")&&(l.multiple=!0),!l.api&&o[1].data&&(l.api=`/api/suggest/${o[1].data}`),Array.isArray(l.schema)&&(l.schema=Dn(l.schema,l.disabled)),n.push(l)}),n}function Ou(r,t,n=!1){const o=e.computed(()=>Dn((Array.isArray(t),t),typeof n=="boolean"?n:n.value)),l=e.ref({});function a(d){const p=d?.conditions;if(!p)return!0;const m=Array.isArray(p)?p[0]:p,x=r?.value?.[m];return lr(x,p)}const s=(d=o.value,p=!0)=>(d.forEach(m=>{const x=[],f=Number(m?.minlength),u=Number(m?.maxlength);!Number.isNaN(f)&&Number.isFinite(f)&&x.push({type:"minlength",value:f}),!Number.isNaN(u)&&Number.isFinite(u)&&x.push({type:"maxlength",value:u});const h=[...x,...m.rules||[]];if(h.length){if(!a(m)){delete l.value[m.name];return}let g=!1,C=null;h.forEach(w=>{const b=Iu(r.value[m.name],w);b&&(g=!0,!C&&typeof b=="string"&&(C=b))}),g&&C?l.value[m.name]=C:delete l.value[m.name]}m.schema&&s(m.schema,!1)}),p&&Object.values(l.value).some(Boolean)?l.value:null),c=e.computed(()=>o.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{r.value={},l.value={}},visibleSchema:c}}const zu={class:"flex w-full h-full min-h-0 gap-6"},Pu={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},Ye=e.defineComponent({__name:"vs-compact-form",props:e.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:e.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(r,{expose:t,emit:n}){const o=n,l=r,a=e.useModel(r,"form"),s=e.useModel(r,"modelValue"),c=e.useModel(r,"values"),i=e.computed({get:()=>c.value??s.value,set:I=>{s.value=I,c.value=I}}),{errors:d,validate:p,reset:m,visibleSchema:x}=Ou(i,l.schema,e.toRef(l,"disabled")),f=e.ref(null),u=e.ref(null),h=e.ref({}),g=e.computed(()=>l.navigation),C=e.computed(()=>l.navWidth),w=e.computed(()=>l.style?.columns),b=Object.freeze({container:12,label:3}),k=e.computed(()=>l.columns??w.value??b),B=e.computed(()=>l.columns!=null||w.value!=null),M=e.computed(()=>B.value?"horizontal":l.layout),$=I=>I?.columns?"horizontal":M.value,E=I=>I?.columns??k.value,N=()=>{o("update:modelValue",i.value),p(),o("handle-submit",i.value)},v=I=>{o("value-selected",I)},S=()=>{l.formId&&(i.value?.id!==void 0&&i.value?.id!==null&&i.value?.id!==""||(i.value={...i.value??{},id:l.formId}))};t({validate:p,reset:m,errors:d}),e.onMounted(()=>{S(),a.value={value:i.value,errors:d.value,reset:m,validate:p,formId:l.formId}}),e.watch(()=>l.formId,()=>{S()},{immediate:!0});function D(I,A){if(I===A)return!0;if(typeof I!="object"||typeof A!="object"||!I||!A)return!1;const T=Object.keys(I),L=Object.keys(A);return T.length!==L.length?!1:T.every(U=>I[U]===A[U])}return e.provide("form",a),e.provide("values",i),e.provide("field-props",h),(I,A)=>(e.openBlock(),e.createElementBlock("div",zu,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:u},[e.createElementVNode("form",{ref_key:"formRef",ref:f,onSubmit:e.withModifiers(N,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",M.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(x),(T,L)=>(e.openBlock(),e.createElementBlock("div",{key:T.name,class:e.normalizeClass($(T)==="horizontal"?"col-span-12":`col-span-${T.col||12}`)},[e.createVNode(Er,{style:e.normalizeStyle(I.style),item:T,layout:$(T),columns:E(T),"model-value":i.value[T.name],"onUpdate:modelValue":U=>{const H=i.value[T.name];D(H,U)||(i.value[T.name]=U)},error:e.unref(d)[T.name],onValueSelected:v},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),$(T)==="settings"&&L+1!==e.unref(x).length?(e.openBlock(),e.createElementBlock("div",Pu)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode($u,{target:f.value,"scroll-container":u.value,enabled:g.value,width:C.value},null,8,["target","scroll-container","enabled","width"])]))}}),ju={class:"relative"},Uu={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},Hu={class:"m-[10px] fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 min-h-0 h-fit max-h-[80vh] overflow-hidden opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl lg:w-7/12 w-11/12"},qu={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Ku={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Gu={class:"p-4 mim-h-0 h-full overflow-auto"},Sr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(r,{emit:t}){const n=r,o=t,l=e.ref(n.schema),a=e.ref(n.defaultValue?JSON.parse(JSON.stringify(n.defaultValue)):{}),s=e.ref({}),c=e.ref(n.token||""),i=e.ref(n.mode),d=()=>{const u=n.method?.trim().toUpperCase();return u==="GET"||u==="POST"||u==="PUT"?u:i.value==="add"?"POST":"PUT"},p=()=>{me.notify({type:"success",title:"Успішно",message:`Дані успішно ${i.value==="add"?"збережено":"оновлено"}`})},m=async u=>{if(console.log(u),u.ok){await u.json().catch(()=>({})),p(),o("save",a.value);return}if(u.status===400){const h=await u.json().catch(()=>({}));me.notify({type:"warning",title:"Помилка валідації",message:h.message||"Некоректні дані (400)"});return}if(u.status===500){me.notify({type:"error",title:"Серверна помилка",message:"Виникла помилка на сервері (500)"});return}me.notify({type:"error",title:"Помилка",message:`Статус: ${u.status}`})};async function x(){const u=s.value.validate();if(u){me.notify({type:"warning",title:"Помилка валідації",message:Object.entries(u).map(([g,C])=>`${g}: ${C}`).join(`
|
|
4
|
+
50.4494, 30.5260`},format:{type:"Radio",label:"Формат координат",options:[{id:"decimal",text:"Десяткові (Decimal)"},{id:"dms",text:"Градуси-хвилини-секунди (DMS)"}]},order:{type:"Radio",label:"Порядок координат",options:[{id:"lat-lon",text:"lat, lon"},{id:"lon-lat",text:"lon, lat"}]}};let ie=!1;const G=e.reactive({}),ne=e.ref([]),ce=e.computed(()=>ne.value.map(y=>G[y]).filter(Boolean)),ye=e.ref(null),ke=e.computed(()=>ye.value?.entries??[]),De=e.computed(()=>{if(ye.value)return{left:`${ye.value.point.x+12}px`,top:`${ye.value.point.y+12}px`}}),Me=e.computed(()=>{if(Array.isArray(n.tools)&&n.tools.length)return n.tools;const y=l?.tools;return Array.isArray(y)?y.map(_=>String(_)):typeof y=="string"?y.split(",").map(_=>_.trim()).filter(Boolean):[]}),we=e.computed(()=>{const y={search:!1,import:!1,importCoordinates:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Me.value.length)return{...y,import:!0,importCoordinates:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const _=new Set(Me.value.map(F=>F.toLowerCase()));return{search:_.has("search"),import:_.has("import"),importCoordinates:_.has("import-coordinates")||_.has("import_coordinates")||_.has("importcoordinates"),export:_.has("export"),point:_.has("point"),line:_.has("line"),polygon:_.has("polygon"),rectangle:_.has("rectangle"),ruler:_.has("ruler")}});function Xe(y){if(typeof y!="string"||!y.trim())return"";if(/^https?:\/\//i.test(y))return y;const _=window?.location?.origin??"",F=y.replace(/^\/+/,"");return F?_?`${_}/${F}`:`/${F}`:_}function Le(){const y=Array.isArray(C.basemaps)&&C.basemaps.length?C.basemaps:g.basemaps;if(Array.isArray(y)&&y.length){const F=y.map((O,X)=>{const te=String(O?.key??O?.id??O?.name??`b${X}`),se=Xe(String(O?.url??""));if(!se)return null;const he=typeof O?.preview=="string"&&O.preview?Xe(O.preview):"";return[te,{...O,url:se,preview:he}]}).filter(O=>Array.isArray(O)&&O.length===2).reduce((O,[X,te])=>(O[X]=te,O),{});if(Object.keys(F).length)return F}return{voyager:{name:"Оглядова карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/voyager/ua/13/4790/2762.png"},orto10:{name:"Ортофото 1:10K",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4790/2762.png"},osmb:{name:"Open Street Maps",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",preview:"https://tile.openstreetmap.org.ua/styles/osm-bright/13/4790/2762.png"}}}const Je=Le(),j=Object.keys(Je),Y=e.ref(j.length?j[0]:"");async function J(){if(typeof window>"u")return null;const y=window;if(y[Zt])return y[Zt];const _=te=>{if(Array.from(document.styleSheets).some(Be=>Be?.href?.includes(te)))return;const he=document.createElement("link");he.rel="stylesheet",he.href=te,document.head.appendChild(he)},F=async()=>{const te=new Function("u","return import(u)"),se=await te("https://esm.sh/maplibre-gl@3.6.2"),he=se?.default??se;if(!he)throw new Error("maplibre esm fallback failed");window.maplibregl=he,window.mapboxgl=he;const Be=await te("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),Ke=Be?.default??Be;if(!Ke)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=Ke},X=(async()=>{_("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),_("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await F();const te=window.maplibregl,se=window.MapboxDraw;if(!te)throw new Error("maplibregl not available after load");if(!se)throw new Error("MapboxDraw not available after load");return{maplibregl:te,MapboxDraw:se}})().catch(te=>{throw delete y[Zt],te});return y[Zt]=X,X}function oe(y){return{version:8,sources:{rasterSource:{type:"raster",tiles:[y],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let ae=null,xe=null,P=null,V=null,Z=null,ee=null,pe=!1,Ee=!1;function vt(){return{onSetup(){const y=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(y),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:y,startPoint:null,hasCoordinates:!1}},onMouseMove(y,_){if(!y.startPoint)return;const[F,O]=y.startPoint,X=_.lngLat.lng,te=_.lngLat.lat;y.rectangle.setCoordinates([[[F,O],[X,O],[X,te],[F,te],[F,O]]])},onClick(y,_){if(!y.startPoint){y.startPoint=[_.lngLat.lng,_.lngLat.lat],y.hasCoordinates=!0,y.rectangle.setCoordinates([[[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat],[_.lngLat.lng,_.lngLat.lat]]]);return}const[F,O]=y.startPoint,X=_.lngLat.lng,te=_.lngLat.lat;return Math.abs(F-X)>0&&Math.abs(O-te)>0?(y.rectangle.setCoordinates([[[F,O],[X,O],[X,te],[F,te],[F,O]]]),this.map.fire("draw.create",{features:[y.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[y.rectangle.id]})):(this.deleteFeature([y.rectangle.id],{silent:!0}),y.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(y){this.deleteFeature([y.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(y,_,F){if(!y.hasCoordinates)return;const O=_.properties.id===y.rectangle.id;_.properties.active=O?"true":"false",F(_)}}}const ot=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["!=","active","true"]],paint:{"fill-color":"#3b82f6","fill-outline-color":"#3b82f6","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":"#2563eb","fill-outline-color":"#2563eb","fill-opacity":.2}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","$type","Polygon"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-lines-inactive",type:"line",filter:["all",["==","$type","LineString"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-lines-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","active","true"]],paint:{"circle-radius":5,"circle-color":"#3b82f6"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","meta","midpoint"],["==","$type","Point"]],paint:{"circle-radius":4,"circle-color":"#1d4ed8"}}];function gt(){const y=Y.value;return!y||!Je[y]?.url?"":Je[y].url}function yt(y,_){return y?.id?String(y.id):y?.url?`${y.url}-${_}`:`layer-${_}`}function bt(y){const _=String(y?.url??"").trim();if(!_)return"";if(/^https?:\/\//i.test(_))return _;const F=window.location?.origin??"",O=_.replace(/^\/+/,"");return`${F}/${O}`}function Te(y){y&&ye.value?.layerId!==y||(ye.value=null)}function We(y,_={}){return y.popup===!1?[]:Array.isArray(y.popup)?y.popup.length?y.popup.map(F=>{const O=F?.field||F?.name;if(!O)return null;const X=_[O];return X==null||X===""?null:{key:F.label||O,value:String(X)}}).filter(Boolean):[]:Object.entries(_).slice(0,5).map(([F,O])=>({key:F,value:O==null?"—":String(O)}))}function ct(y){if(!Array.isArray(y))return[];const _=O=>Array.isArray(O)&&O.length>=2&&Number.isFinite(Number(O[0]))&&Number.isFinite(Number(O[1])),F=O=>{if(!O.length)return O;const X=O[0],te=O[O.length-1];return!te||X[0]!==te[0]||X[1]!==te[1]?[...O,X]:O};if(y.length&&_(y[0])){const O=y.map(X=>[Number(X[0]),Number(X[1])]).filter(_);return O.length?[F(O)]:[]}return y.length&&Array.isArray(y[0])&&_(y[0][0])?y.map(X=>Array.isArray(X)?X.map(te=>[Number(te[0]),Number(te[1])]):[]).filter(X=>X.length).map(F):y.length&&Array.isArray(y[0])&&Array.isArray(y[0][0])&&_(y[0][0][0])?y.flatMap(X=>Array.isArray(X)?X:[]).map(X=>Array.isArray(X)?X.map(te=>[Number(te[0]),Number(te[1])]):[]).filter(X=>X.length).map(F):[]}function Ut(y){const _=y.style??{},F=_.color??"#3b82f6";if(!_.colorAttr||!_.colorSet)return F;const O=Object.keys(_.colorSet);if(!O.length)return F;const X=["match",["to-string",["get",_.colorAttr]]];return O.forEach(te=>{X.push(String(te),_.colorSet?.[te]??F)}),X.push(F),X}function Et(y){if(!P)return;y.handlers.forEach(F=>{try{P.off(F.type,F.layerId,F.handler)}catch{}}),y.handlers=[],[...y.layerIds,...y.boundsIds].forEach(F=>{P.getLayer(F)&&P.removeLayer(F)}),P.getSource(y.sourceId)&&P.removeSource(y.sourceId);const _=`vs-ov-bounds-src-${y.id}`;P.getSource(_)&&P.removeSource(_),Te(y.id)}function hn(y,_){if(!P)return[];const F=`vs-ov-bounds-src-${_}`,O=`vs-ov-bounds-line-${_}`,X=y.bounds??v.value??L.value,te=ct(X);if(!te.length)return[];const se={type:"FeatureCollection",features:te.map(he=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:he}}))};return P.getSource(F)&&P.removeSource(F),P.addSource(F,{type:"geojson",data:se}),P.addLayer({id:O,type:"line",source:F,paint:{"line-color":y.style?.stroke??y.style?.color??"#2563eb","line-width":y.style?.width??2,"line-opacity":y.style?.opacity??.8,"line-dasharray":[2,2]}}),[O]}function kt(y){if(!P)return;Et(y);const _=y.config,F=bt(_);if(!F)return;const O=[],X=[];if(/\.v(?:m)?t(?:\?|$)/i.test(F)||/\.pbf(?:\?|$)/i.test(F)){const he=_.sourceLayer||_.layer||_.service_layer||_.dataset?.layer||_.id;P.addSource(y.sourceId,{type:"vector",tiles:[F]});const Be=String(_.style?.type??"polygon").toLowerCase(),Ke=Ut(_),et=_.style?.opacity??.5;if(Be==="point"){const lt=`vs-ov-point-${y.id}`;P.addLayer({id:lt,type:"circle",source:y.sourceId,"source-layer":he,paint:{"circle-color":Ke,"circle-radius":5,"circle-opacity":et}}),O.push(lt)}else if(Be==="polyline"||Be==="line"){const lt=`vs-ov-line-${y.id}`;P.addLayer({id:lt,type:"line",source:y.sourceId,"source-layer":he,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Ke,"line-width":_.style?.width??2,"line-opacity":et}}),O.push(lt)}else{const lt=`vs-ov-fill-${y.id}`,qt=`vs-ov-border-${y.id}`;P.addLayer({id:lt,type:"fill",source:y.sourceId,"source-layer":he,paint:{"fill-color":Ke,"fill-opacity":et}}),P.addLayer({id:qt,type:"line",source:y.sourceId,"source-layer":he,paint:{"line-color":_.style?.stroke??_.style?.color??"#2563eb","line-width":_.style?.width??1,"line-opacity":et}}),O.push(lt,qt)}}else{P.addSource(y.sourceId,{type:"raster",tiles:[F],tileSize:256});const he=`vs-ov-raster-${y.id}`;P.addLayer({id:he,type:"raster",source:y.sourceId,paint:{"raster-opacity":_.style?.opacity??1}}),O.push(he)}O.forEach(he=>{const Be=et=>{if(!et?.features?.length){Te(y.id);return}const lt=et.features[0]?.properties??{},qt=We(y.config,lt);if(!qt.length){Te(y.id);return}ye.value={layerId:y.id,entries:qt,point:{x:et.point.x,y:et.point.y}}},Ke=()=>Te(y.id);P.on("mousemove",he,Be),P.on("mouseleave",he,Ke),X.push({layerId:he,type:"mousemove",handler:Be},{layerId:he,type:"mouseleave",handler:Ke})}),y.layerIds=O,y.boundsIds=hn(y.config,y.id),y.handlers=X;const se=y.visible?"visible":"none";[...y.layerIds,...y.boundsIds].forEach(he=>{P.getLayer(he)&&P.setLayoutProperty(he,"visibility",se)})}function Bt(){if(!P)return;const _={type:"FeatureCollection",features:ct(v.value??L.value).map(F=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:F}}))};P.getSource(Xt)?P.getSource(Xt).setData(_):P.addSource(Xt,{type:"geojson",data:_}),P.getLayer(Jt)||P.addLayer({id:Jt,type:"line",source:Xt,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function Xn(y){if(!P||a.value)return;const _=G[y];if(!_)return;_.visible=!_.visible;const F=_.visible?"visible":"none";[..._.layerIds,..._.boundsIds].forEach(O=>{P.getLayer(O)&&P.setLayoutProperty(O,"visibility",F)}),dt(),_.visible||Te(y)}function dt(){if(!P)return;const y=[],_=[],F=[],O=[];ne.value.forEach(se=>{const he=G[se];if(!he)return;const Be=String(he.config?.url??""),Ke=/\.v(?:m)?t(?:\?|$)/i.test(Be),et=/\.png(?:\?|$)/i.test(Be);Ke?F.push(...he.layerIds):et?y.push(...he.layerIds):_.push(...he.layerIds),O.push(...he.boundsIds)}),[...y,..._,...F,...O].forEach(se=>{P.getLayer(se)&&P.moveLayer(se)}),P.getLayer(Jt)&&P.moveLayer(Jt),(P.getStyle?.()?.layers??[]).map(se=>String(se?.id??"")).filter(se=>se.startsWith("gl-draw-")).forEach(se=>{P.getLayer(se)&&P.moveLayer(se)})}function gn(y){if(!Je[y]||(Y.value=y,!P))return;const _=gt();if(!_)return;const F=P.getCenter?.(),O=P.getZoom?.(),X=V?.getAll?.();P.setStyle(oe(_)),P.once("style.load",()=>{if(P&&(F&&Number.isFinite(O)&&P.jumpTo({center:[F.lng,F.lat],zoom:O}),Bt(),ne.value.forEach(te=>{const se=G[te];se&&kt(se)}),dt(),X?.features?.length&&V))try{X.features.forEach(te=>V.add(te)),i.value=X.features.length}catch{i.value=0}})}function R(y){return y?y.type==="FeatureCollection"?y.features?.[0]?.geometry??null:y.type==="Feature"?y.geometry??null:y.geom?.type&&Array.isArray(y.geom.coordinates)?{type:y.geom.type,coordinates:y.geom.coordinates}:typeof y.type=="string"&&Array.isArray(y.coordinates)?y:null:null}function K(y){return{type:"Feature",properties:{},geometry:y}}function q(y){if(!y)return null;try{return JSON.parse(JSON.stringify(y))}catch{return null}}function le(y){if(!y)return"__null__";try{return JSON.stringify(y)}catch{return"__invalid__"}}function be(y){const _=Oe(y);if(!_)return null;const[[F,O],[X,te]]=_;return{lat:(O+te)/2,lng:(F+X)/2}}function _e(y){if(!Array.isArray(y)||y.length<3)return 0;const _=(O,X)=>{const te=O*2003750834e-2/180,se=Math.log(Math.tan((90+X)*Math.PI/360))/(Math.PI/180);return[te,se*2003750834e-2/180]};let F=0;for(let O=0;O<y.length-1;O+=1){const[X,te]=_(Number(y[O][0]),Number(y[O][1])),[se,he]=_(Number(y[O+1][0]),Number(y[O+1][1]));F+=X*he-se*te}return Math.abs(F/2)/1e6}function Ce(y){if(!y?.type||!y?.coordinates)return null;if(y.type==="Polygon"){const _=y.coordinates?.[0];return Array.isArray(_)?_e(_):null}return y.type==="MultiPolygon"?y.coordinates.reduce((_,F)=>{const O=F?.[0];return Array.isArray(O)?_+_e(O):_},0):null}function Ve(y){if(!y){p.value=null;return}const _=be(y);if(!_){p.value=null;return}p.value={type:String(y.type??"Feature"),center:_,areaKm2:Ce(y)}}function Ie(y,_){if(!Array.isArray(y)||!Array.isArray(_)||y.length!==2||_.length!==2)return!1;const F=1e-9;return Math.abs(Number(y[0])-Number(_[0]))<F&&Math.abs(Number(y[1])-Number(_[1]))<F}function Oe(y){if(!y)return null;let _=1/0,F=1/0,O=-1/0,X=-1/0;const te=se=>{if(Array.isArray(se)){if(se.length>=2&&Number.isFinite(se[0])&&Number.isFinite(se[1])){const he=Number(se[0]),Be=Number(se[1]);_=Math.min(_,he),F=Math.min(F,Be),O=Math.max(O,he),X=Math.max(X,Be);return}se.forEach(te)}};return te(y.coordinates),!Number.isFinite(_)||!Number.isFinite(F)?null:[[_,F],[O,X]]}function Qe(y){if(!P||!y)return;const _=Oe(y);if(!_)return;const[[F,O],[X,te]]=_;if(F===X&&O===te){P.easeTo({center:[F,O],zoom:Math.max(D.value,14)});return}P.fitBounds(_,{padding:30,duration:250,maxZoom:18})}function ze(){if(!V){i.value=0;return}const y=V.getAll();i.value=y?.features?.length??0}function Vt(){if(!V)return;const y=V.getAll();if(i.value=y?.features?.length??0,!y?.features?.length){Z=null,p.value=null,ie||(ee="__null__",o("update:modelValue",null));return}const _=q(y.features[y.features.length-1]?.geometry??null);Z=_,Ve(_),ie||(ee=le(_),o("update:modelValue",_))}function yn(){if(!V)return;(V.getAll()?.features||[]).forEach(_=>V.delete(_.id)),ze()}function bn(y){if(!V)return;const _=R(y);if(ie=!0,yn(),_)try{V.add(K(_))}catch{}ie=!1,Z=q(_),ze(),Ve(_),_&&(Qe(_),a.value||xn())}function Lh(){if(V){if(ie=!0,yn(),Z)try{V.add(K(Z))}catch{}ie=!1,ze(),Ve(Z)}}function Ht(){if(V){try{V.changeMode("simple_select",{featureIds:[]})}catch{}d.value=""}}function kn(y){if(a.value||!V)return;f.isRulerActive.value&&f.closeRuler(),Ee=!0,Ht(),d.value=y;const _=y==="marker"?"draw_point":y==="polyline"?"draw_line_string":y==="rectangle"?"draw_rectangle":"draw_polygon";ie=!0,yn(),ie=!1;try{V.changeMode(_)}catch{d.value=""}finally{requestAnimationFrame(()=>{Ee=!1})}}function xn(){if(a.value||!V)return;const y=V.getAll();if(y?.features?.length)try{V.changeMode("direct_select",{featureId:y.features[0].id}),d.value="edit"}catch{d.value=""}}function Th(){a.value||!V||(Ht(),yn(),ee="__null__",p.value=null,o("update:modelValue",null))}function Ih(){a.value||!Z||Qe(Z)}function Rh(y){P&&P.easeTo({center:[y[1],y[0]],zoom:13,duration:250})}function Oh(){a.value||A.value?.click()}function zh(){a.value||(U.value=!U.value)}function fo(y){if(!U.value)return;const _=T.value;_&&!_.contains(y.target)&&(U.value=!1)}function Ph(){U.value=!1,Oh()}function jh(){a.value||(W.value=[],U.value=!1,H.value=!0)}function Uh(){H.value=!1,W.value=[]}function Hh(){if(a.value||!V)return;const y=ic(Q.value.coordinates??"",Q.value.format||"decimal",Q.value.order||"lat-lon");if(!y.ok){W.value=y.errors,qh(y.errors);return}W.value=[],bn({type:"Polygon",coordinates:[y.ring]}),H.value=!1,y.wasClosedAutomatically&&me.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function qh(y){if(!y.length)return;const _=5;y.slice(0,_).forEach(F=>{const O=F.line>0?`Рядок ${F.line}`:"Загальна помилка";me.notify({type:"warning",title:"Імпорт координат",message:`${O} — ${F.message}`})}),y.length>_&&me.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${y.length-_}`})}function Kh(y){if(a.value||!V)return;U.value=!1;const _=y.target,F=_.files?.[0];if(!F)return;const O=new FileReader;O.onload=()=>{try{const X=JSON.parse(String(O.result)),te=R(X);if(!te)return;bn(te)}finally{_.value=""}},O.readAsText(F)}function Gh(){if(a.value||!V)return;const y=V.getAll(),_=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),F=URL.createObjectURL(_),O=document.createElement("a");O.href=F,O.download="data.geojson",O.click(),URL.revokeObjectURL(F)}return e.onMounted(async()=>{if(window.addEventListener("click",fo,!0),!c.value)return;const y=await J();ae=y.maplibregl,xe=y.MapboxDraw;const _=gt();_&&(P=new ae.Map({container:c.value,style:oe(_),center:[S.value[0],S.value[1]],zoom:D.value,attributionControl:!1}),m.value=P,P.addControl(new ae.NavigationControl({showCompass:!0}),"bottom-right"),P.on("load",()=>{if(!(!xe||!P)){if(V=new xe({displayControlsDefault:!1,modes:{...xe.modes,draw_rectangle:vt()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:ot}),P.addControl(V),P.on("click",F=>{if(!f.isRulerActive.value)return;const O=F?.lngLat;O&&x.value?.addPoint?.({lat:O.lat,lng:O.lng})}),P.on("draw.create",()=>{if(!V||f.isRulerActive.value)return;const F=V.getAll();if(F.features.length>1){const O=F.features[F.features.length-1];ie=!0,F.features.slice(0,-1).forEach(X=>V.delete(X.id)),ie=!1,O&&(ie=!0,V.add(O),ie=!1)}Vt(),xn()}),P.on("draw.update",F=>{if(!pe&&!f.isRulerActive.value){if(F?.action==="move"){if(pe=!0,Lh(),pe=!1,d.value==="edit"){const O=V?.getAll?.()?.features?.[0];if(O?.id)try{V.changeMode("direct_select",{featureId:O.id})}catch{d.value=""}}return}Vt()}}),P.on("draw.delete",()=>{f.isRulerActive.value||d.value==="marker"||d.value==="polyline"||d.value==="polygon"||d.value==="rectangle"||(Vt(),d.value="",Ht())}),P.on("draw.selectionchange",()=>{if(!(!V||pe)&&!f.isRulerActive.value&&d.value!=="edit"&&!(d.value==="marker"||d.value==="polyline"||d.value==="polygon"||d.value==="rectangle")){if(!a.value&&i.value>0){xn();return}try{V.changeMode("simple_select",{featureIds:[]})}catch{}}}),I.value!==void 0){const F=I.value;I.value=void 0,requestAnimationFrame(()=>{V&&bn(F)})}Bt(),ne.value.forEach(F=>{const O=G[F];O&&kt(O)}),dt()}}),P.on("zoomend",()=>{P&&(D.value=P.getZoom())}))}),e.onUnmounted(()=>{f.isRulerActive.value&&f.closeRuler(),window.removeEventListener("click",fo,!0),Object.values(G).forEach(y=>{P&&Et(y)}),Te(),P?.remove&&P.remove(),P=null,V=null,m.value=null}),e.watch(()=>n.modelValue,y=>{if(!V){I.value=y;return}const _=R(y),F=le(_);if(ee&&F===ee){ee=null;return}ee=null,bn(y)},{deep:!0}),e.watch(()=>N.value,y=>{const _=Array.isArray(y)?y:[],F=[],O=new Set;_.forEach((X,te)=>{if(!X)return;const se=yt(X,te);F.push(se),O.add(se);const he={...X,id:se},Be=G[se],Ke=Be?.visible??!!he.visible;Be&&P&&Et(Be),G[se]={id:se,config:he,visible:Ke,sourceId:`vs-ov-src-${se}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(G).forEach(X=>{if(O.has(X))return;const te=G[X];te&&P&&Et(te),delete G[X]}),ne.value=F,P&&(ne.value.forEach(X=>{const te=G[X];te&&kt(te)}),dt())},{immediate:!0,deep:!0}),e.watch(()=>v.value,()=>{P&&(Bt(),ne.value.forEach(y=>{const _=G[y];_&&kt(_)}),dt())},{deep:!0}),e.watch(()=>E.value,async y=>{if(L.value=[],!y){P&&(Bt(),ne.value.forEach(_=>{const F=G[_];F&&kt(F)}),dt());return}try{const _=await fetch(`https://data.gki.com.ua/api-user/atu/${y}`);if(!_?.ok)return;const O=(await _.json())?.geometry?.coordinates;Array.isArray(O)&&O.length&&(L.value=O)}catch(_){console.error("Failed to fetch KATOTTG bounds",_)}finally{if(!P)return;Bt(),ne.value.forEach(_=>{const F=G[_];F&&kt(F)}),dt()}},{immediate:!0}),e.watch(()=>M.value,y=>{if(!Array.isArray(y)||y.length!==2)return;const _=[Number(y[0]),Number(y[1])];if(Ie(S.value,_)||(S.value=[..._],!P))return;const F=P.getCenter?.();F&&Ie([F.lng,F.lat],S.value)||P.easeTo({center:[S.value[0],S.value[1]]})},{deep:!0}),e.watch(()=>$.value,y=>{typeof y=="number"&&(D.value=y,P&&P.setZoom(y))}),e.watch(a,y=>{y&&Ht()}),e.watch(i,y=>{if(y>0){a.value||xn();return}Ee||Ht()}),e.watch(s,()=>{setTimeout(()=>{P?.resize&&P.resize()},50)}),(y,_)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!s.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:s.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:c,class:"w-full h-[calc(100%-28px)]"},null,512),we.value.search||we.value.import||we.value.importCoordinates||we.value.export?(e.openBlock(),e.createElementBlock("div",mc,[we.value.search?(e.openBlock(),e.createBlock(ui,{key:0,onGoToCoordinates:Rh})):e.createCommentVNode("",!0),we.value.import||we.value.importCoordinates||we.value.export?(e.openBlock(),e.createElementBlock("div",hc,[e.createElementVNode("div",gc,[we.value.import||we.value.importCoordinates?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:T,class:"relative"},[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:zh,disabled:a.value},[_[8]||(_[8]=e.createTextVNode(" Import ",-1)),e.createVNode(e.unref(z.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":U.value}])},null,8,["class"])],8,yc),U.value?(e.openBlock(),e.createElementBlock("div",bc,[we.value.import?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100",onClick:Ph}," З файлу ")):e.createCommentVNode("",!0),we.value.importCoordinates?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100",onClick:jh}," З координат ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),we.value.export?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:Gh,disabled:a.value||i.value===0}," Export ",8,kc)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:A,type:"file",onChange:Kh,accept:".json,.geojson",class:"hidden",disabled:a.value},null,40,xc)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(me.VsModal),{visible:H.value,"onUpdate:visible":_[1]||(_[1]=F=>H.value=F),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(Ye,{schema:ve,values:Q.value,"onUpdate:values":_[0]||(_[0]=F=>Q.value=F)},null,8,["values"]),e.createElementVNode("div",wc,[e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:Uh}," Скасувати "),e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:Hh,disabled:a.value}," Побудувати ",8,_c)])]),_:1},8,["visible"]),e.createElementVNode("div",Cc,[e.createElementVNode("div",vc,[we.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="marker"}]),title:"Point",onClick:_[2]||(_[2]=F=>kn("marker")),disabled:a.value},[e.createVNode(e.unref(z.MapPin),{class:"h-4 w-4"})],10,Ec)):e.createCommentVNode("",!0),we.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="polyline"}]),title:"Line",onClick:_[3]||(_[3]=F=>kn("polyline")),disabled:a.value},[e.createVNode(Us)],10,Bc)):e.createCommentVNode("",!0),we.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="polygon"}]),title:"Polygon",onClick:_[4]||(_[4]=F=>kn("polygon")),disabled:a.value},[e.createVNode(Gs)],10,Vc)):e.createCommentVNode("",!0),we.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":d.value==="rectangle"}]),title:"Rectangle",onClick:_[5]||(_[5]=F=>kn("rectangle")),disabled:a.value},[e.createVNode(Xs)],10,Sc)):e.createCommentVNode("",!0),we.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(f).isRulerActive.value}]),title:"Ruler",onClick:u},[e.createVNode(e.unref(z.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:_[6]||(_[6]=F=>s.value=!s.value),title:"Full Screen"},[e.createVNode(e.unref(z.Maximize),{class:"h-4 w-4"})])])]),we.value.ruler&&e.unref(f).isRulerActive.value?(e.openBlock(),e.createBlock(oc,{key:1,ref_key:"rulerPanelRefEl",ref:x,onClose:_[7]||(_[7]=F=>e.unref(f).closeRuler()),onTabChange:e.unref(f).onRulerTabChange,onPointsChange:e.unref(f).onRulerPointsChange,onShapeClosedChange:e.unref(f).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),we.value.ruler&&e.unref(f).isRulerActive.value&&e.unref(f).hasRulerPoints.value?(e.openBlock(),e.createBlock(lc,{key:2,map:m.value,points:e.unref(f).rulerPoints.value,"is-shape-closed":e.unref(f).rulerShapeClosed.value,"label-mode":e.unref(f).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),ke.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(De.value)},[e.createElementVNode("div",$c,[e.createElementVNode("dl",Nc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ke.value,F=>(e.openBlock(),e.createElementBlock("div",{key:`${F.key}-${F.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",Ac,e.toDisplayString(F.key),1),e.createElementVNode("dd",Fc,e.toDisplayString(F.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Dc,[e.createElementVNode("div",Mc,[e.createVNode(ni,{basemaps:e.unref(Je),onOnLayerChange:gn},null,8,["basemaps"]),ce.value.length?(e.openBlock(),e.createElementBlock("div",Lc,[_[9]||(_[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",Tc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ce.value,F=>(e.openBlock(),e.createElementBlock("label",{key:F.id,class:"flex items-center gap-2 cursor-pointer select-none"},[e.createElementVNode("input",{type:"checkbox",class:"rounded border-gray-300 text-blue-600 focus:ring-blue-500",checked:F.visible,disabled:a.value,onChange:O=>Xn(F.id)},null,40,Ic),e.createElementVNode("span",Rc,e.toDisplayString(F.config.title||F.config.name||F.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Oc,[p.value?(e.openBlock(),e.createElementBlock("div",zc,[e.createElementVNode("div",Pc,[e.createElementVNode("div",jc,[_[10]||(_[10]=e.createTextVNode(" Type: ",-1)),e.createElementVNode("span",Uc,e.toDisplayString(p.value.type),1)])]),e.createElementVNode("div",Hc,[e.createElementVNode("div",qc,[_[11]||(_[11]=e.createTextVNode(" Center: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.center.lat.toFixed(5))+", "+e.toDisplayString(p.value.center.lng.toFixed(5)),1)]),p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",Kc,[_[12]||(_[12]=e.createTextVNode(" Area: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",Gc,_[13]||(_[13]=[e.createTextVNode("Area: ",-1),e.createElementVNode("b",null,"—",-1)]))),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md mr-1 cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Zoom to feature",onClick:Ih,disabled:a.value},[e.createVNode(e.unref(z.ZoomIn),{class:"h-3 w-3"})],8,Wc),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Delete feature",onClick:Th,disabled:a.value},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,Yc)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-ab3ec4b5"]]),Zc=["data-focus"],Xc={class:"flex items-center"},Jc={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},Qc=["onClick","aria-label"],ed={key:0,class:"absolute text-gray-500 truncate pl-2"},td={class:"flex-1 min-w-[2px]"},nd=["placeholder"],rd={class:"flex items-center shrink-0"},od=["disabled"],mr=e.defineComponent({__name:"vs-input-tag",props:e.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(r,{emit:t}){const n=r,o=t;Fe(n.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),c=e.ref(!1),i=e.ref(""),d=e.useModel(r,"modelValue"),p=e.computed(()=>n.placeholder||"Add tag…"),m=e.computed(()=>d.value?.length===0&&i.value===""),x=e.computed(()=>!n.disabled&&d.value?.length>0),f=e.computed(()=>n.disabled),u=async()=>{f.value||await e.nextTick(()=>s.value?.focus())},h=M=>{const $=M.trim();$!==""&&(!d.value||!Array.isArray(d.value)?d.value=[$]:n.unique?d.value.includes($)||(d.value=[...d.value,$]):d.value=[...d.value,$],i.value="")},g=()=>{const M=i.value;M.trim()!==""&&h(M),i.value=""},C=M=>{const $=d.value.slice();$.splice(M,1),o("update:modelValue",$)},w=()=>{o("update:modelValue",[])},b=()=>{f.value||(c.value=!0)},k=()=>{c.value=!1,!f.value&&g()},B=M=>{const{key:$}=M;$==="Enter"?(M.preventDefault(),g()):$==="Backspace"&&i.value===""&&d.value.length>0&&C(d.value.length-1)};return(M,$)=>(e.openBlock(),e.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:l,onClick:$[1]||($[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass]),role:"group","aria-label":"Tag input"},[e.createElementVNode("div",{class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",c.value?"border-blue-500 ring-1 ring-blue-500":"",f.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":c.value?"true":"false",onClick:u},[e.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:a},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(E,N)=>(e.openBlock(),e.createElementBlock("div",{key:N,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",Xc,[e.createElementVNode("div",Jc,e.toDisplayString(E),1)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border hover:bg-[#ffbdad] hover:text-[#de350b]",onClick:e.withModifiers(v=>C(N),["stop"]),"aria-label":`Remove ${E}`},[e.createVNode(e.unref(z.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Qc)]))),128)),m.value?(e.openBlock(),e.createElementBlock("div",ed,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",td,[f.value?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:s,class:"pl-2 w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-label":"Add tag","onUpdate:modelValue":$[0]||($[0]=E=>i.value=E),onFocus:b,onBlur:k,onKeydown:B,placeholder:d.value&&d.value.length?"":void 0},null,40,nd)),[[e.vModelText,i.value]])])],512),e.createElementVNode("div",rd,[x.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-label":"Clear all tags",disabled:f.value,onClick:e.withModifiers(w,["stop"])},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,od)):e.createCommentVNode("",!0)])],10,Zc)],2)],512))}}),ld={class:"relative flex gap-1 bg-white w-full"},ad=["disabled","placeholder"],hr=fe(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.inject("values"),n=r,o=e.useModel(r,"modelValue");function l(s){const c={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return s.toLowerCase().split("").map(i=>c[i]||i).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[n.parent||""]?.toString(),c=l(s);o.value=c.toString()};return(s,c)=>(e.openBlock(),e.createElementBlock("div",ld,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:s.disabled,placeholder:s.placeholder,"onUpdate:modelValue":c[0]||(c[0]=i=>o.value=i),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,ad),[[e.vModelText,o.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:a}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),sd={class:"relative flex gap-1 bg-white w-full"},id=["disabled","placeholder"],cd=["disabled"],dd={key:0},ud={key:1},gr=fe(e.defineComponent({__name:"vs-input-codegen",props:e.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.ref(!1),l=e.computed(()=>t.init!==!1),a=e.computed(()=>!!t.table&&!!t.code),s=()=>{if(!a.value)return"";const d=encodeURIComponent(String(t.table)),p=encodeURIComponent(String(t.code));return`/api/code-gen/${d}/${p}`},c=async()=>{if(!a.value||o.value)return;const d=s();if(d){o.value=!0;try{const m=await(await fetch(d)).text();n.value=m}finally{o.value=!1}}},i=()=>{l.value&&(n.value||c())};return e.onMounted(()=>{i()}),e.watch(()=>[t.table,t.code,t.init],()=>{i()}),(d,p)=>(e.openBlock(),e.createElementBlock("div",sd,[e.withDirectives(e.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":p[0]||(p[0]=m=>n.value=m),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,id),[[e.vModelText,n.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:o.value||d.disabled||!a.value,onClick:c},[o.value?(e.openBlock(),e.createElementBlock("span",ud,"...")):(e.openBlock(),e.createElementBlock("span",dd,"Gen"))],8,cd)]))}}),[["__scopeId","data-v-6ee5237d"]]),pd={class:"w-full"},fd={ref:"sortableContainer",class:"flex flex-col gap-1"},md=["onDragstart","onDrop"],hd={class:"cursor-move",type:"button"},gd={class:"w-1/3"},yd={class:"w-2/3"},bd=["onClick"],kd={key:0,class:"text-[14px] text-gray-700"},xd={class:"mt-2 w-full flex items-center"},wd=["disabled"],yr=fe(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,o=e.inject("values"),l=r,a=t,s=l.addButtonText??"Додати",c=l.ignore??[],i=e.ref([]),d=e.ref(null);(()=>{const g=l.parent&&o?.value?.[l.parent]||l.modelValue||{};i.value=Object.entries(g).filter(([C])=>!c.includes(C)).map(([C,w])=>({id:n("key-value-"),key:C,value:w}))})();function m(g){d.value=g}function x(g){if(d.value===null||d.value===g)return;const C=i.value.splice(d.value,1)[0];i.value.splice(g,0,C),d.value=null}const f=e.computed(()=>i.value.some(g=>g.key&&!g.value||!g.key&&g.value)),u=()=>{i.value.push({id:n("key-value-"),key:"",value:""})},h=g=>{i.value=i.value.filter(C=>C.id!==g)};return e.watch(i,g=>{const C={};g.forEach(b=>{b.key&&b.value!==void 0&&(C[b.key]=b.value)});const w={};c.length&&c.forEach(b=>{w[b]=l.parent?o?.value?.[l.parent]?.[b]:void 0}),o?.value&&l.parent&&(o.value[l.parent]={...w,...C}),a("update:modelValue",C)},{deep:!0}),(g,C)=>(e.openBlock(),e.createElementBlock("div",pd,[e.createElementVNode("div",fd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(w,b)=>(e.openBlock(),e.createElementBlock("div",{key:w.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===b}]),draggable:"true",onDragstart:k=>m(b),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:k=>x(b)},[e.createElementVNode("button",hd,[e.createVNode(e.unref(z.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",gd,[e.createVNode(St,{modelValue:w.key,"onUpdate:modelValue":k=>w.key=k,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",yd,[e.createVNode(St,{modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:k=>h(w.id),class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,bd)],42,md))),128))],512),i.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",kd," Дані для відображення відсутні ")),e.createElementVNode("div",xd,[e.createElementVNode("button",{type:"button",onClick:u,disabled:f.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(s)),1)],8,wd)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),_d={class:"w-full"},Cd={ref:"sortableContainer",class:"flex flex-col gap-1"},vd=["onDragstart","onDrop"],Ed=["disabled"],Bd={class:"flex-1"},Vd=["onClick","disabled"],Sd={key:0,class:"text-[14px] text-gray-700"},$d={class:"mt-2 w-full flex items-center"},Nd=["disabled"],br=fe(e.defineComponent({__name:"vs-input-text-array",props:e.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),c=e.computed(()=>t.addButtonText??"Додати");let i=!1;const d=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,p=g=>{const C=g??n.value??[];o.value=C.map((w,b)=>({id:o.value[b]?.id??d("text-array"),value:w??""}))};p(),e.watch(()=>n.value,g=>{if(i){i=!1;return}p(g||[])},{deep:!0}),e.watch(o,g=>{i=!0,n.value=g.map(C=>C.value).filter(C=>C!=null&&C!=="")},{deep:!0});const m=e.computed(()=>a.value||o.value.some(g=>!g.value));function x(){m.value||(o.value=[...o.value,{id:d("text-array"),value:""}])}function f(g){a.value||(o.value=o.value.filter(C=>C.id!==g))}function u(g){a.value||(l.value=g)}function h(g){if(a.value||l.value===null||l.value===g)return;const C=[...o.value],[w]=C.splice(l.value,1);C.splice(g,0,w),o.value=C,l.value=null}return(g,C)=>(e.openBlock(),e.createElementBlock("div",_d,[e.createElementVNode("div",Cd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(w,b)=>(e.openBlock(),e.createElementBlock("div",{key:w.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":l.value===b}]),draggable:"true",onDragstart:k=>u(b),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:k=>h(b)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(z.GripVertical),{class:"h-4 w-4"})],8,Ed),e.createElementVNode("div",Bd,[g.inputType==="text"?(e.openBlock(),e.createBlock(St,{key:0,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="tel"?(e.openBlock(),e.createBlock(Bn,{key:1,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="email"?(e.openBlock(),e.createBlock(En,{key:2,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="mask"?(e.openBlock(),e.createBlock(vn,{key:3,modelValue:w.value,"onUpdate:modelValue":k=>w.value=k,mask:g.mask,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:k=>f(w.id),disabled:a.value,class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200 disabled:opacity-50"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,Vd)],42,vd))),128))],512),o.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Sd," Дані для відображення відсутні ")),e.createElementVNode("div",$d,[e.createElementVNode("button",{type:"button",onClick:x,disabled:m.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(c.value),1)],8,Nd)])]))}}),[["__scopeId","data-v-2c229b1f"]]),Ad={class:"flex items-center gap-2 w-full"},Fd=["disabled"],Dd=["disabled"],kr=e.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,{inputClass:o}=Fe(n.style),l=t,a=e.computed({get:()=>n.modelValue||"#000000",set:c=>l("update:modelValue",c)}),s=e.computed(()=>!!n.disabled);return(c,i)=>(e.openBlock(),e.createElementBlock("div",Ad,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":i[0]||(i[0]=d=>a.value=d),disabled:s.value,ref:"color",class:e.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[c.modelValue?"":"text-opacity-50",e.unref(o)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,Fd),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":i[1]||(i[1]=d=>a.value=d),disabled:s.value},null,8,Dd),[[e.vModelText,a.value]])]))}}),Md={class:"flex items-center gap-2 w-full"},Ld=["min","max","step","disabled"],Td=["disabled"],xr=e.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,{inputClass:o}=Fe(n.style),l=t,a=e.computed({get:()=>Number(n.modelValue??n.min),set:c=>l("update:modelValue",Number(c))}),s=e.computed(()=>!!n.disabled);return(c,i)=>(e.openBlock(),e.createElementBlock("div",Md,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":i[0]||(i[0]=d=>a.value=d),min:c.min,max:c.max,step:c.step,disabled:s.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[c.modelValue?"":"text-opacity-50",e.unref(o)].join(" ")])},null,10,Ld),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number","onUpdate:modelValue":i[1]||(i[1]=d=>a.value=d),disabled:s.value},null,8,Td),[[e.vModelText,a.value]])]))}}),Id=["placeholder","disabled","name"],Rd=["type","value","onInput","placeholder","disabled"],Od=["onClick"],wr=e.defineComponent({__name:"vs-input-array",props:e.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.ref(t.count),o=e.computed(()=>t.limit),{inputClass:l}=Fe(t.style),a=e.useModel(r,"modelValue"),s=e.computed(()=>!!t.disabled),c=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const h=a.value?.length??0;h<n.value&&(a.value=[...a.value??[],...Array(n.value-h)])});const i=e.ref({}),d=e.ref({});function p(h,g){h&&(i.value[g]=h)}async function m(h,g){if(!h||t.inputType!=="mask")return;const{default:C}=await Promise.resolve().then(()=>Hn);d.value[g]&&d.value[g].destroy(),d.value[g]=C(h,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[g].on("accept",()=>{const w=[...a.value||[]];w[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=w}),d.value[g].on("complete",()=>{const w=[...a.value||[]];w[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=w}),a.value?.[g]&&(d.value[g].value=a.value[g])}function x(h,g){if(s.value)return;const C=h.target.value??null,w=[...a.value];w[g]=t.inputType==="text"?C:Number(C),a.value=w}function f(){n.value+=1;const h=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,h],t.inputType==="mask"&&setTimeout(()=>{const g=n.value-1;i.value[g]&&m(i.value[g],g)},0)}function u(h){if(n.value>1){d.value[h]&&(d.value[h].destroy(),delete d.value[h]),n.value-=1,a.value=a.value.filter((C,w)=>w!==h);const g={};Object.keys(d.value).forEach(C=>{const w=parseInt(C,10);w>h?g[w-1]=d.value[w]:w<h&&(g[w]=d.value[w])}),d.value=g}}return e.onMounted(()=>{if(t.inputType==="mask")for(let h=0;h<n.value;h+=1)i.value[h]&&m(i.value[h],h)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(h=>{h&&h.destroy()})}),e.watch(()=>t.mask,h=>{t.inputType==="mask"&&Object.values(d.value).forEach(g=>{g&&g.updateOptions({mask:h,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,h=>{t.inputType==="mask"&&h&&h.forEach((g,C)=>{d.value[C]&&d.value[C].value!==g&&(d.value[C].value=g||"")})},{deep:!0}),(h,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["grid gap-2",`grid-cols-${o.value}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,C=>(e.openBlock(),e.createElementBlock("div",{key:C,class:"flex items-center gap-2 w-full"},[h.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:w=>p(w,C-1),placeholder:h.placeholder,disabled:h.disabled,name:`${h.name}[${C-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Id)):(e.openBlock(),e.createElementBlock("input",{key:1,type:h.inputType,value:a.value?.[C-1],onInput:w=>x(w,C-1),placeholder:c.value,disabled:s.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,Rd)),!h.disabled&&C===n.value&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(f,["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-green-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"})])):e.createCommentVNode("",!0),!h.disabled&&n.value>1&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(w=>u(C-1),["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-red-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,Od)):e.createCommentVNode("",!0)]))),128))],2))}}),zd=["aria-expanded","data-focus"],Pd=["placeholder","disabled","readonly"],jd={class:"max-h-full"},Ud=["onClick","disabled"],Hd={key:0,class:"px-3 py-2 text-sm text-stone-500"},qd={class:"flex flex-col gap-1"},Kd=["onDragstart","onDrop"],Gd=["disabled"],Wd=["title"],Yd=["disabled","onClick","aria-label"],Zd={key:0,class:"text-xs text-stone-500"},Qt=fe(e.defineComponent({__name:"vs-input-array-select",props:e.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(r,{emit:t}){const n=r,o=t,l=e.useModel(r,"modelValue"),a=e.ref([]),s=e.ref(n.options??[]),c=e.ref({}),i=e.ref({}),d=e.ref({keyword:"",parent:null}),p=e.ref(""),m=e.ref(!1),x=e.ref(null),f=e.ref(null),u=e.ref(null),h=e.ref(null),g=e.ref(null),C=e.ref({});let w=!1,b=!1;const k=e.inject("values"),B=e.computed(()=>!!n.disabled),M=e.computed(()=>n.placeholder??"Оберіть значення"),$=e.computed(()=>n.search!==!1),E=e.computed(()=>{const V=n.parent??n.parentValue;return V?String(V):""}),N=e.computed(()=>E.value?k?.value?.[E.value]??null:null),v=V=>V==null?"__null__":String(V),S=V=>{if(!V)return"";const Z=V.label??V.text??V.name??V.ua??V.en;return Z?String(Z):V.id!==void 0&&V.id!==null?String(V.id):""},D=V=>{const Z=v(V);return i.value[Z]||(i.value[Z]=`array-select-${Z}-${Math.random().toString(36).slice(2,8)}`),i.value[Z]},I=e.computed(()=>new Set(a.value.map(V=>v(V.id)))),A=e.computed(()=>{const V=I.value;let Z=[...s.value];if(!n.data&&p.value.trim()){const ee=p.value.toLowerCase();Z=Z.filter(pe=>S(pe).toLowerCase().includes(ee))}return Z.filter(ee=>!V.has(v(ee.id)))}),T=()=>{if(!n.data)return"";const V=n.prefix??"api",Z=n.api??`/${V}/suggest/${n.data}`;return`${n.host??""}${Z}`},L=()=>{a.value.length&&(w=!0,a.value=a.value.map(V=>({...V,text:c.value[v(V.id)]??V.text})))},U=V=>{const Z=v(V.id),ee=S(V);ee&&(c.value[Z]=ee)},H=V=>{s.value=V?[...V]:[],V?.forEach(U),L()},W=V=>{if(!V.length)return;const Z=new Map(s.value.map(ee=>[v(ee.id),ee]));V.forEach(ee=>{const pe=v(ee.id);Z.set(pe,ee),U(ee)}),s.value=Array.from(Z.values()),L()},Q=async(V="")=>{if(!n.data)return[];const Z=T();if(!Z)return[];const ee=new URLSearchParams;ee.set("json","1"),V&&ee.set("key",V),n.start===1&&ee.set("start","1"),N.value!==null&&N.value!==void 0&&N.value!==""&&ee.set("parent",String(N.value));try{return(await(await fetch(`${Z}?${ee.toString()}`)).json())?.data??[]}catch{return[]}},ve=async V=>{if(!n.data||!V.length)return[];const Z=T();if(!Z)return[];const ee=Array.from(new Set(V.map(Ee=>v(Ee)))),pe=new URLSearchParams;pe.set("json","1"),pe.set("val",ee.join(",")),n.start===1&&pe.set("start","1"),N.value!==null&&N.value!==void 0&&N.value!==""&&pe.set("parent",String(N.value));try{const ot=(await(await fetch(`${Z}?${pe.toString()}`)).json())?.data??[];return W(ot),ot}catch{return[]}},ie=async(V="",{force:Z=!1}={})=>{if(!n.data)return;const ee=N.value??null;if(!Z&&d.value.keyword===V&&d.value.parent===ee&&s.value.length>0)return;d.value={keyword:V,parent:ee};const Ee=await Q(V);H(Ee)},ne=((V,Z=200)=>{let ee;return(...pe)=>{ee&&clearTimeout(ee),ee=setTimeout(()=>V(...pe),Z)}})(async V=>{n.data&&await ie(V,{force:!0})},250),ce=e.ref(null),ye=()=>{if(!u.value)return;const V=u.value.getBoundingClientRect(),Z=window.innerHeight??document.documentElement.clientHeight,ee=window.innerWidth??document.documentElement.clientWidth,pe=8,Ee=8,vt=n.maxHeight??280,ot=Z-V.bottom-Ee-pe,gt=V.top-Ee-pe,yt=ot>=gt,bt=Math.max(ee-pe*2,0);let{width:Te}=V;bt>0&&Te>bt&&(Te=bt);let{left:We}=V;We+Te+pe>ee&&(We=ee-Te-pe),We=Math.max(We,pe);const ct=Math.min(vt,Math.max(yt?ot:gt,50));C.value={position:"fixed",left:`${We}px`,width:`${Te}px`,maxHeight:`${ct}px`,transform:yt?"none":"translateY(-100%)",top:yt?`${V.bottom+Ee}px`:`${V.top-Ee}px`}},ke=async(V="click")=>{B.value||m.value||(ce.value=V,await ie(p.value.trim()),m.value=!0,await e.nextTick(),ye(),g.value?.focus())},De=()=>{m.value=!1,ce.value=null,e.nextTick(()=>{g.value?.blur()})},Me=async V=>{if(V.stopPropagation(),!B.value){if(m.value){if(ce.value==="focus"){ce.value=null;return}De();return}await ke("click")}},we=V=>{V.key==="Escape"&&De()},Xe=V=>{if(!m.value)return;const Z=V.target;h.value?.contains(Z)||De()},Le=V=>{const Z=V.target;f.value?.contains(Z)||h.value?.contains(Z)||De()},Je=V=>{if(V.key==="Escape"){V.preventDefault(),De();return}if(V.key==="Enter"){V.preventDefault();const Z=A.value[0];Z&&j(Z)}},j=V=>{if(!V)return;const Z=v(V.id);if(I.value.has(Z))return;U(V);const ee={id:V.id,text:S(V)||String(V.id??""),key:D(V.id)};a.value=[...a.value,ee],Y(V),p.value="",e.nextTick(()=>{g.value?.focus()})},Y=V=>{const Z=a.value.map(ee=>ee.id);o("value-selected",{name:n.name,value:Z,option:V})},J=V=>{if(B.value)return;const Z=a.value.filter(ee=>v(ee.id)!==v(V));a.value=Z},oe=V=>{B.value||(x.value=V)},ae=V=>{if(B.value||x.value===null||x.value===V)return;const Z=[...a.value],[ee]=Z.splice(x.value,1);Z.splice(V,0,ee),x.value=null,a.value=Z},xe=async()=>{const Z=(Array.isArray(l.value)?[...l.value]:[]).filter(pe=>pe!=null);if(n.data&&Z.length){const pe=Z.filter(Ee=>!c.value[v(Ee)]);pe.length&&await ve(pe)}const ee=Z.map(pe=>({id:pe,text:c.value[v(pe)]??String(pe),key:D(pe)}));w=!0,a.value=ee};e.watch(a,V=>{if(w){w=!1;return}const Z=V.map(ee=>ee.id);b=!0,l.value=Z,o("change",Z)},{deep:!0}),e.watch(l,()=>{if(b){b=!1;return}xe()},{deep:!0}),e.watch(p,V=>{!n.data||!m.value||ne(V.trim())}),e.watch(B,V=>{V&&De()}),e.watch(()=>n.options,async V=>{n.data||(H(V??[]),await xe())},{immediate:!0,deep:!0}),e.watch(()=>n.data,async V=>{V&&(await ie(p.value.trim()),await xe())},{immediate:!0});const P=e.ref(!1);return e.watch(N,async()=>{if(n.data){if(!P.value){P.value=!0;return}a.value=[],await ie(p.value.trim()),await xe()}}),e.onMounted(async()=>{document.addEventListener("click",Le,!0),window.addEventListener("keydown",we),window.addEventListener("scroll",Xe,!0),await xe()}),e.onUnmounted(()=>{document.removeEventListener("click",Le,!0),window.removeEventListener("keydown",we),window.removeEventListener("scroll",Xe,!0)}),(V,Z)=>(e.openBlock(),e.createElementBlock("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:f},[e.createElementVNode("div",{class:"relative",onClick:Z[2]||(Z[2]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:u,class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",m.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",B.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),role:"combobox","aria-expanded":m.value,"aria-haspopup":"listbox","data-focus":m.value?"true":"false",onClick:Me},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":Z[0]||(Z[0]=ee=>p.value=ee),placeholder:M.value,disabled:B.value,readonly:!$.value,onFocus:Z[1]||(Z[1]=()=>ke("focus")),onKeydown:Je,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,Pd),[[e.vModelText,p.value]]),e.createElementVNode("span",{class:e.normalizeClass(["text-stone-400 transition-transform duration-150",m.value?"rotate-180":""]),"aria-hidden":"true"},[e.createVNode(e.unref(z.ChevronDown),{class:"h-4 w-4"})],2)],10,zd),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:h,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(C.value)},[e.createElementVNode("div",jd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value,ee=>(e.openBlock(),e.createElementBlock("button",{key:v(ee.id),type:"button",class:"w-full px-3 py-2 text-left text-sm text-stone-900 hover:bg-stone-100 disabled:opacity-50",onClick:e.withModifiers(pe=>j(ee),["stop"]),disabled:B.value},e.toDisplayString(S(ee)),9,Ud))),128)),A.value.length===0?(e.openBlock(),e.createElementBlock("p",Hd," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),e.createElementVNode("div",qd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(ee,pe)=>(e.openBlock(),e.createElementBlock("div",{key:ee.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":x.value===pe}]),draggable:"true",onDragstart:Ee=>oe(pe),onDragover:Z[3]||(Z[3]=e.withModifiers(()=>{},["prevent"])),onDrop:Ee=>ae(pe),onDragend:Z[4]||(Z[4]=Ee=>x.value=null)},[e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-500 hover:text-stone-900",disabled:B.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(z.GripVertical),{class:"h-4 w-4"})],8,Gd),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:ee.text},e.toDisplayString(ee.text),9,Wd),e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-400 hover:text-stone-900",disabled:B.value,onClick:e.withModifiers(Ee=>J(ee.id),["stop"]),"aria-label":`Видалити ${ee.text}`},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})],8,Yd)],42,Kd))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",Zd,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512))}}),[["__scopeId","data-v-56e6cd88"]]),Xd={class:"flex items-center gap-2 w-full"},Jd={class:"relative flex-1"},Qd=["placeholder","disabled","onKeydown"],eu=["disabled"],tu={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},nu={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},ru={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},ou=["onClick"],lu={key:0,class:"p-4 text-sm text-gray-500"},_r=e.defineComponent({__name:"vs-input-address",props:e.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(r,{emit:t}){const n=/{{\s*([^}]+?)\s*}}/g,o=r,l=t,{inputClass:a}=Fe(o.style),s=e.useModel(r,"modelValue"),c=e.computed({get:()=>s.value,set:$=>{s.value=$}}),i=e.ref(!1),d=e.ref([]),p=e.ref(!1),m=e.ref(null);e.watch(p,$=>{typeof document>"u"||($?(m.value=document.body.style.overflow,document.body.style.overflow="hidden"):m.value!=null?(document.body.style.overflow=m.value,m.value=null):document.body.style.removeProperty("overflow"))}),e.onBeforeUnmount(()=>{typeof document>"u"||(m.value!=null?document.body.style.overflow=m.value:document.body.style.removeProperty("overflow"))});const x=e.computed(()=>o.placeholder??""),f=e.computed(()=>!!o.disabled),u=$=>{if(!$)return null;if(Array.isArray($))return $;if(typeof $=="string"){const E=$.split(",").map(N=>N.trim()).filter(Boolean);return E.length!==4?null:E.map(Number)}return null},h=e.computed(()=>{const $=u(o.bbox);if(!$||$.length!==4)return null;const E=$.map(Number);return E.some(N=>Number.isNaN(N))?null:E}),g=e.computed(()=>{const $=h.value;if(!$)return"";const[E,N,v,S]=$;return`${E},${Math.max(N,S)},${v},${Math.min(N,S)}`});e.computed(()=>g.value?"1":"0");const C=e.inject("values");function w(){!f.value&&c.value.trim()&&b()}async function b(){const $=(c.value||"").trim();if(!$)return;let E=$;if(o.includes?.length&&C?.value){const v=o.includes.map(S=>C.value?.[S]).filter(Boolean);v.length&&(E=`${v.join(", ")}, ${$}`)}const N=M(E);if(N){i.value=!0;try{const S=await(await fetch(N)).json();d.value=Array.isArray(S)?S:[],p.value=!0}catch(v){console.error("Address search error:",v)}finally{i.value=!1}}}function k(){p.value=!p.value}function B($){if(!$)return;p.value=!1;const E=parseFloat($.lat),v={type:"Point",coordinates:[parseFloat($.lon),E]};o.geom&&C?.value&&(C.value[o.geom]=v),l("update:geom",v)}function M($){if(!o.api)return"";const E={value:encodeURIComponent($),bbox:h.value?h.value.join(","):""};return o.api.replace(n,(N,v)=>E[v.trim()]??"")}return($,E)=>(e.openBlock(),e.createElementBlock("div",Xd,[e.createElementVNode("div",Jd,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":E[0]||(E[0]=N=>c.value=N),placeholder:x.value,disabled:f.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white border rounded-md placeholder:text-gray-400 focus:ring-2 focus:ring-blue-500",[e.unref(a),{"!border-red-600":o.error}]]),style:{border:"1px solid #CFD9E0"},onKeydown:e.withKeys(e.withModifiers(w,["prevent"]),["enter"])},null,42,Qd),[[e.vModelText,c.value]]),d.value.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick:k,title:"Show search results"},[e.createVNode(e.unref(z.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:b,class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px]",disabled:i.value||!c.value?.trim()},[i.value?(e.openBlock(),e.createBlock(e.unref(z.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(z.Search),{key:0,class:"h-4 w-4"}))],8,eu),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[p.value?(e.openBlock(),e.createElementBlock("div",tu,[e.createElementVNode("div",nu,[e.createElementVNode("div",ru,[E[2]||(E[2]=e.createElementVNode("span",null,"Search results",-1)),e.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:E[1]||(E[1]=N=>p.value=!1),title:"Close"},[e.createVNode(e.unref(z.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(N,v)=>(e.openBlock(),e.createElementBlock("li",{key:v,onClick:S=>B(N),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(N.display_name),9,ou))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",lu," No results found "))])])):e.createCommentVNode("",!0)]))]))}}),Cr=(r="")=>`${r}${Math.floor(Math.random()*1e4)}`,au={class:"vs-datalist space-y-3"},su={class:"space-y-3"},iu=["onClick","disabled"],cu={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},du=["disabled"],uu=fe(e.defineComponent({__name:"vs-input-datalist",props:e.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.computed(()=>Array.isArray(n.value)?n.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(h=>({...h,disabled:t.disabled||h.disabled}))??[]),s=e.computed(()=>a.value.map(h=>u(h))),c=e.computed(()=>t.disabled?!1:t.maxItems?o.value.length<t.maxItems:!0),i=e.computed(()=>t.disabled||o.value.length<=(t.minItems||0));e.watch(()=>o.value.length,()=>{d(),p()},{immediate:!0}),e.watch(()=>t.schema,p,{immediate:!0,deep:!0});function d(){const h=o.value.length;l.value.length<h?l.value=[...l.value,...Array.from({length:h-l.value.length},()=>Cr())]:l.value.length>h&&l.value.splice(h)}function p(){if(!t.minItems||o.value.length>=t.minItems)return;const h=t.minItems-o.value.length,g=Array.from({length:h},m);n.value=[...o.value,...g]}function m(){const h={};return a.value.forEach(g=>{h[g.name]=g?.default??null}),h}function x(){c.value&&(n.value=[...o.value,m()],d())}function f(h){i.value||(n.value=o.value.filter((g,C)=>C!==h),d(),p())}function u(h){return{...h}}return(h,g)=>(e.openBlock(),e.createElementBlock("div",au,[e.createElementVNode("div",su,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(C,w)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[w],class:"flex items-center gap-3"},[e.createVNode(Ye,{schema:s.value,layout:"inline",navigation:!1,values:o.value[w],"onUpdate:values":b=>o.value[w]=b,"form-id":l.value[w]},null,8,["schema","values","onUpdate:values","form-id"]),e.createElementVNode("button",{type:"button",class:"h-[38px] w-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",onClick:b=>f(w),disabled:i.value},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,iu)]))),128)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",cu,e.toDisplayString(t.emptyLabel),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:x,disabled:!c.value},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,du)]))}}),[["__scopeId","data-v-260e3e66"]]),pu={class:"vs-dataform space-y-4"},fu=["draggable","onDragstart","onDragover","onDragenter","onDrop"],mu={class:"flex items-center gap-2"},hu=["onClick"],gu={class:"text-sm font-medium text-gray-700"},yu={class:"flex items-center gap-2"},bu=["title","onClick","disabled"],ku=["title","onClick","disabled"],xu={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},wu=["disabled"],_u=fe(e.defineComponent({__name:"vs-input-dataform",props:e.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,n=e.useModel(r,"modelValue"),o=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),c=e.ref(null),i=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),p=e.computed(()=>t.emptyLabel??"Ще немає груп"),m=e.computed(()=>t.schema?.map(G=>({...G,disabled:t.disabled||G.disabled}))??[]),x=e.computed(()=>m.value.map(G=>N(G))),f=e.computed(()=>t.view==="accordion"),u=e.computed(()=>!!(t.collapsible||f.value)),h=e.computed(()=>t.draggable!==!1),g=e.computed(()=>t.disabled?!1:t.maxGroups?n.value.length<t.maxGroups:!0),C=e.computed(()=>t.disabled||n.value.length<=(t.minGroups||0));e.watch(()=>n.value.length,()=>{w(),b(),k()},{immediate:!0}),e.watch(()=>t.schema,k,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{b()},{immediate:!0});function w(){const G=n.value.length;o.value.length<G?o.value=[...o.value,...Array.from({length:G-o.value.length},()=>Cr())]:o.value.length>G&&o.value.splice(G)}function b(){const G=n.value.length;f.value?G===0?a.value=-1:a.value>=G?a.value=G-1:a.value<0&&(a.value=0):l.value.length<G?l.value=[...l.value,...Array.from({length:G-l.value.length},()=>!1)]:l.value.length>G&&l.value.splice(G)}function k(){if(!t.minGroups||n.value.length>=t.minGroups)return;const G=t.minGroups-n.value.length,ne=Array.from({length:G},B);n.value=[...n.value,...ne],b()}function B(){const G={};return m.value.forEach(ne=>{G[ne.name]=ne?.default??null}),G}function M(){g.value&&(n.value=[...n.value,B()],w(),b())}function $(G){C.value||(n.value=n.value.filter((ne,ce)=>ce!==G),w(),f.value?a.value>=n.value.length&&(a.value=n.value.length-1):l.value.splice(G,1),k())}function E(G){if(t.disabled)return;const ne=JSON.parse(JSON.stringify(n.value[G]??{}));n.value=[...n.value.slice(0,G+1),ne,...n.value.slice(G+1)],w(),f.value?a.value>G&&(a.value+=1):l.value.splice(G+1,0,l.value[G]??!1)}function N(G){return{...G}}function v(G){return f.value?a.value===-1&&G===0?!1:a.value!==G:!!l.value[G]}function S(G){if(u.value){if(f.value){a.value=G;return}l.value[G]=!l.value[G]}}function D(G,ne){if(!h.value||t.disabled){ne.preventDefault();return}s.value=G,c.value=G,i.value={groups:JSON.parse(JSON.stringify(n.value)),keys:[...o.value],states:[...l.value]},ne.dataTransfer?.setData("text/plain",String(G)),ne.dataTransfer?.setDragImage?.(ne.currentTarget,0,0)}function I(G,ne){!h.value||t.disabled||s.value!==null&&W(G,ne)}function A(G,ne){W(G,ne)}function T(G){!h.value||t.disabled||ie()}function L(){i.value&&H(),s.value=null,c.value=null,i.value=null}function U(G,ne){const ce=[...n.value],[ye]=ce.splice(G,1);ce.splice(ne,0,ye),n.value=ce;const ke=[...o.value],[De]=ke.splice(G,1);if(ke.splice(ne,0,De),o.value=ke,f.value)a.value===G&&(a.value=ne);else{const Me=[...l.value],[we]=Me.splice(G,1);Me.splice(ne,0,we),l.value=Me}}function H(){i.value&&(n.value=i.value.groups,o.value=i.value.keys,l.value=i.value.states,i.value=null,c.value=null)}function W(G,ne){if(s.value===null)return;const ce=Q(G,ne);c.value=ce,ve(ce)}function Q(G,ne){if(!ne?.currentTarget)return G;const ce=ne.currentTarget.getBoundingClientRect(),ke=ne.clientY-ce.top>ce.height/2?G+1:G;return Math.max(0,Math.min(ke,n.value.length))}function ve(G){const ne=s.value;if(ne===null)return;let ce=G;if(ce>n.value.length&&(ce=n.value.length),ce===ne||ce===ne+1)return;const ye=ce>ne?ce-1:ce;U(ne,ye),s.value=ye,c.value=ce>ne?ye+1:ye}function ie(){i.value=null,s.value=null,c.value=null}return(G,ne)=>(e.openBlock(),e.createElementBlock("div",pu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(ce,ye)=>(e.openBlock(),e.createElementBlock("div",{key:o.value[ye],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":v(ye)?"pt-6 px-6":"p-6"]]),draggable:h.value&&!t.disabled,onDragstart:ke=>D(ye,ke),onDragend:L,onDragover:e.withModifiers(ke=>I(ye,ke),["prevent"]),onDragenter:e.withModifiers(ke=>A(ye,ke),["prevent"]),onDrop:e.withModifiers(ke=>T(),["prevent"])},[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3",[t.view!=="accordion"?"-mx-6 -mt-6 px-6":"",t.view!=="accordion"&&!v(ye)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",mu,[h.value?(e.openBlock(),e.createBlock(e.unref(z.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:ke=>S(ye)},[e.createVNode(e.unref(z.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",v(ye)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,hu)):e.createCommentVNode("",!0),e.createElementVNode("div",gu,e.toDisplayString(`${d.value} (${ye+1})`),1)]),e.createElementVNode("div",yu,[e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.duplicateTitle,onClick:ke=>E(ye),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(z.Copy),{class:"h-4 w-4"})],8,bu),e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.removeTitle,onClick:ke=>$(ye),disabled:C.value,draggable:"false"},[e.createVNode(e.unref(z.Trash2),{class:"h-4 w-4"})],8,ku)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(Ye,{class:"vs-dataform__form",schema:x.value,layout:"inline",navigation:!1,values:n.value[ye],"onUpdate:values":ke=>n.value[ye]=ke,"form-id":o.value[ye],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!v(ye)]])],42,fu))),128)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",xu,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:M,disabled:!g.value},[e.createVNode(e.unref(z.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,wu)]))}}),[["__scopeId","data-v-cfbcfed8"]]),en="__vs_form_monaco_loader__",_t="__vs_form_monaco_script_loader__",tn="__vs_form_monaco_editor_loader__",Fn=e.defineComponent({__name:"vs-input-monaco",props:e.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r,{expose:t}){const n=r,o=e.useModel(r,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof n.height=="number"?`${n.height}px`:n.height||"280px");let s=null,c=null,i=!1;const d=()=>{if(c)return Promise.resolve(c);if(typeof window>"u")return Promise.resolve(null);const u=window;if(u.monaco?.editor?.create)return c=u.monaco,Promise.resolve(c);if(u[en])return u[en];const g=(async()=>{const C=k=>{if(Array.from(document.styleSheets||[]).some($=>$?.href?.includes(k)))return;const M=document.createElement("link");M.rel="stylesheet",M.href=k,document.head.appendChild(M)},w=k=>{if(u[_t]?.[k])return u[_t][k];u[_t]||={};const B=Array.from(document.scripts).find(M=>M.src===k);return B?(u[_t][k]=new Promise((M,$)=>{const E=B.readyState;if(B.dataset.loaded==="true"||E==="loaded"||E==="complete"){M();return}B.addEventListener("load",()=>{B.dataset.loaded="true",M()},{once:!0}),B.addEventListener("error",N=>$(N),{once:!0})}),u[_t][k]):(u[_t][k]=new Promise((M,$)=>{const E=document.createElement("script");E.src=k,E.async=!0,E.onload=()=>{E.dataset.loaded="true",M()},E.onerror=N=>$(N),document.body.appendChild(E)}),u[_t][k])},b="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return C(`${b}/editor/editor.main.min.css`),await w(`${b}/loader.min.js`),u[tn]||(u[tn]=new Promise((k,B)=>{window.require.config({paths:{vs:b}}),window.require(["vs/editor/editor.main"],()=>{c=window.monaco,u.monaco=c,k(c)},M=>B(M))}).catch(k=>{throw delete u[tn],k})),u[tn]})().catch(C=>{throw delete u[en],C});return u[en]=g,g},p=()=>{!l.value||!c||(s&&(s.dispose(),s=null),s=c.editor.create(l.value,{value:o.value||"",language:n.syntax,theme:n.theme,automaticLayout:!0,minimap:{enabled:!!n.minimap},readOnly:!!n.disabled}),s.onDidChangeModelContent(()=>{i||(o.value=s.getValue())}))},m=()=>{s?.focus()},x=()=>s,f=()=>c;return e.watch(()=>o.value,u=>{if(!s)return;const h=s.getValue();u!==h&&(i=!0,s.setValue(u||""),i=!1)}),e.watch(()=>n.syntax,u=>{!s||!c||c.editor.setModelLanguage(s.getModel(),u||"xml")}),e.watch(()=>n.theme,u=>{c&&c.editor.setTheme(u||"vs-light")}),e.watch(()=>n.disabled,u=>{s&&s.updateOptions({readOnly:!!u})}),e.watch(()=>n.minimap,u=>{s&&s.updateOptions({minimap:{enabled:!!u}})}),e.onMounted(async()=>{try{const u=await d();if(!u||!u.editor)return;c=u,p()}catch(u){console.error("Failed to load Monaco editor",u)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:m,getEditor:x,getMonaco:f}),(u,h)=>(e.openBlock(),e.createElementBlock("div",{class:"w-full",style:e.normalizeStyle({height:a.value})},[e.createElementVNode("div",{ref_key:"editorContainer",ref:l,class:"w-full h-full overflow-hidden border border-[#CFD9E0] rounded"},null,512)],4))}}),vr={VsInputText:St,VsInputRadio:Vn,"vs-input-text":St,"vs-input-password":Lo,"vs-input-textarea":sr,"vs-input-richtext":ir,"vs-input-mask":vn,"vs-input-number":Qn,"vs-input-radio":Vn,"vs-input-select":An,"vs-input-switcher":_n,"vs-input-static":Cn,"vs-input-container":ar,"vs-input-date":bl,"vs-input-checkbox":er,"vs-input-file":rr,"vs-input-file2":$n,file2:$n,File2:$n,"vs-input-html":Cn,"vs-input-email":En,"vs-input-tel":Bn,"vs-input-datatable":cr,"vs-input-map":fr,"vs-input-file-list":or,"vs-input-tags":mr,"vs-input-slug":hr,"vs-input-codegen":gr,"vs-input-key-value":yr,"vs-input-text[]":br,"vs-input-range":xr,"vs-input-color":kr,"vs-input-native-select":An,VsInputArraySelect:Qt,"vs-input-array":wr,"vs-input-array-select":Qt,"array-select":Qt,"vs-input-address":_r,"vs-input-datalist":uu,"vs-input-dataform":_u,"vs-input-monaco":Fn},Cu=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(r){const t=r,n=e.inject("values");async function o(){try{if(!t.api)return;const l=t.api.replace("{{value}}",t.value),a=await fetch(l);if(!a.ok){me.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!n)return;for(const[c,i]of Object.entries(t.set))n.value[c]=s.result[i]}catch(l){console.error(t.error,l)}}return(l,a)=>(e.openBlock(),e.createElementBlock("button",{onClick:o,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},e.toDisplayString(l.button),1))}}),vu={class:"flex flex-col gap-1 w-full"},Eu=["innerHTML"],Er=e.defineComponent({__name:"vs-compact-form-layout",props:e.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:e.mergeModels(["value-selected"],["update:modelValue"]),setup(r,{emit:t}){const n=r,o=e.useModel(r,"modelValue"),l=t,a=e.computed(()=>Do[`${n.layout}`]),s=["label","placeholder","info","description","text","html"],c=e.ref(C()),i=e.computed(()=>u(n.item,c.value)),d=e.computed(()=>vr?.[`vs-input-${n.item.type}`]),p=e.inject("field-props"),m=e.computed(()=>{const b=e.unref(d);if(!b)return new Set;const k=b.props??b.__vccOpts?.props;if(!k)return new Set;const B=Array.isArray(k)?k:Object.keys(k);return new Set(B)}),x=e.computed(()=>{const b={...i.value??{}},k=n.item?.name;k&&p?.value?.[k]&&Object.assign(b,p.value[k]);const B=m.value;return B.size?Object.fromEntries(Object.entries(b).filter(([M])=>B.has(M))):{}}),f=b=>{const k=typeof b=="object"&&b!==null?b:{value:b};l("value-selected",{...k,name:k.name??n.item?.name})};e.onMounted(()=>{c.value=C(),window.addEventListener("storage",w)}),e.onUnmounted(()=>{window.removeEventListener("storage",w)});function u(b,k){if(!b)return{};const B={...b};return s.forEach(M=>{const $=g(b,M,k);$!=null&&(B[M]=$)}),Array.isArray(b.options)&&(B.options=b.options.map(M=>h(M,k))),B}function h(b,k){if(!b)return b;const B={...b},M=g(b,"label",k),$=g(b,"text",k);return M!=null&&(B.label=M),$!=null?B.text=$:M!=null&&(B.text=M),B}function g(b,k,B){const M=`${k}:${B}`;if(b?.[M]!=null)return b[M];if(k==="label"&&b?.[B]!=null)return b[B];if(b?.[k]!=null)return b[k];if(k==="label"){if(b?.ua!=null)return b.ua;if(b?.en!=null)return b.en}if(k==="text"||k==="html"){if(b?.ua!=null)return b.ua;if(b?.en!=null)return b.en}return null}function C(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function w(){c.value=C()}return(b,k)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:i.value.ua,error:n.error||"",item:i.value,columns:n.columns,label:i.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${n.item.type}-component`])},[e.createElementVNode("div",vu,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),e.mergeProps(x.value,{modelValue:o.value,"onUpdate:modelValue":k[0]||(k[0]=B=>o.value=B),onValueSelected:f}),null,16,["modelValue"])),i.value.description&&n.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:i.value.description},null,8,Eu)):e.createCommentVNode("",!0)]),i.value.behavior?.api&&i.value.behavior?.button?(e.openBlock(),e.createBlock(Cu,e.mergeProps({key:0},i.value.behavior,{value:o.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),Bu={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},Vu={class:"vs-compact-form-navigation__rail mt-[6px]"},Su=["onClick"],$u=fe(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(r,{expose:t}){const n=r,o=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!n.enabled),c=e.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),i=e.computed(()=>{const S=n.width;if(S==null)return{};const D=typeof S=="number"?`${S}px`:`${S}`;return{width:D,minWidth:D}});let d=null,p=0,m=0,x=null,f=null,u=null;const h=()=>N(),g=()=>w();e.watch(()=>n.target,async S=>{if(M(),!S){x=null,o.value=[],l.value="";return}x=S,s.value&&(await e.nextTick(),B(S),w())},{immediate:!0}),e.watch(()=>n.scrollContainer,S=>{if(!s.value){f=S??null;return}C(S??null),e.nextTick(()=>w())},{immediate:!0}),e.onMounted(()=>{n.scrollContainer||C(null),w()}),e.onBeforeUnmount(()=>{M(),C(null,!0),x=null,typeof window<"u"&&(p&&window.cancelAnimationFrame(p),m&&window.cancelAnimationFrame(m))});function C(S,D=!1){if(u&&(u(),u=null),D){f=null;return}if(f=S??null,typeof window>"u")return;const I=S??window,A=window;I.addEventListener("scroll",h,{passive:!0}),A.addEventListener("resize",g),u=()=>{I.removeEventListener("scroll",h),A.removeEventListener("resize",g)}}function w(){if(!s.value||!x)return;p&&typeof window<"u"&&window.cancelAnimationFrame(p);const S=()=>{b(),p=0};typeof window>"u"?S():p=window.requestAnimationFrame(S)}function b(){if(!s.value||!x)return;const S=Array.from(x.querySelectorAll("h1, h2")),D=new Set,I=[];S.forEach((A,T)=>{const L=A.textContent?.trim()??"";if(!L)return;let U=(A.getAttribute("id")??"").trim();U||(U=k(L)||`heading-${T+1}`);let H=U,W=1;for(;D.has(H);)H=`${U}-${W+=1}`;A.id!==H&&Object.assign(A,{id:H}),D.add(H),I.push({id:H,text:L,level:A.tagName.toLowerCase()==="h1"?1:2})}),o.value=I,I.length||(l.value=""),E()}function k(S){return S.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function B(S){!S||!s.value||typeof MutationObserver>"u"||(M(),d=new MutationObserver(()=>w()),d.observe(S,{childList:!0,subtree:!0}))}function M(){d&&(d.disconnect(),d=null)}function $(S){const D=f;if(!D)return typeof window>"u"?S.offsetTop:S.getBoundingClientRect().top+window.scrollY;const I=S.getBoundingClientRect(),A=D.getBoundingClientRect();return I.top-A.top+D.scrollTop}function E(){if(!s.value||!o.value.length)return;const S=f,D=(S?S.scrollTop:null)||(typeof window<"u"?window.scrollY:0),I=(S?S.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),A=D+I;let T=null;for(let U=0;U<o.value.length;U+=1){const H=o.value[U],W=document.getElementById(H.id);if(W){const Q=$(W);Q+W.offsetHeight>D&&Q<A&&(T=H.id)}}!T&&a.value&&(T=a.value),T&&(a.value=T);const L=S?S.scrollHeight-S.clientHeight:document.documentElement.scrollHeight-window.innerHeight;D+5>=L&&(T=o.value[o.value.length-1].id),T&&(l.value=T)}function N(){s.value&&(m&&window.cancelAnimationFrame(m),m=window.requestAnimationFrame(()=>{E(),m=0}))}function v(S){if(!s.value)return;const D=document.getElementById(S);if(!D)return;const I=f,A=Math.max(0,$(D));I?I.scrollTo({top:A,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:A,behavior:"smooth"})}return t({refresh:w}),(S,D)=>s.value&&o.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(c.value),style:e.normalizeStyle(i.value)},[e.createElementVNode("h2",Bu,e.toDisplayString(S.title),1),e.createElementVNode("div",Vu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,I=>(e.openBlock(),e.createElementBlock("div",{key:I.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",I.level===2?"vs-compact-form-navigation__item--nested":"",I.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:A=>v(I.id),class:e.normalizeClass(["vs-compact-form-navigation__button flex gap-x-3 py-[6px] pr-3 text-sm duration-200 hover:text-gray-800",I.level===2?"pl-[15px]":"pl-[18px]",I.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(I.text),1)],10,Su)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),ut={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:r=>`Мінімальна довжина — ${r} символів`,maxlength:r=>`Максимальна довжина — ${r} символів`},Nu=r=>typeof r=="string"?r.trim()?!1:ut.required:Array.isArray(r)?r.map(n=>typeof n=="string"?n.trim():n).filter(n=>n!=null&&n!=="").length?!1:ut.required:typeof r=="number"?Number?.isNaN(r)?ut?.required:!1:r?!1:ut.required,Au=r=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return r?t.test(r)?!1:ut.email:!1},Fu=r=>{const t=/^\+[1-9]\d{1,14}$/;return r?t.test(r)?!1:ut.tel:!1},Br=r=>r==null?0:typeof r=="string"?r.trim().length:Array.isArray(r)?r.length:typeof r=="number"?r.toString().length:String(r).length,Du=(r,t)=>{if(r==null)return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&Br(r)<n?t?.message||ut.minlength(n):!1},Mu=(r,t)=>{if(r==null||r==="")return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&Br(r)>n?t?.message||ut.maxlength(n):!1},Lu=(r,t)=>{const n=t.pattern??t.regexp,o=typeof n=="string"?new RegExp(n):n;if(Array.isArray(r)){const l=r.filter(Boolean);return l.length===0||l.every(a=>o.test(a))?!1:t.message}return!o.test(r)&&r?t.message:!1},Tu=(r,t)=>!1,Iu=(r,t)=>{switch(typeof t=="string"?t:t.type){case"required":return Nu(r);case"email":return Au(r);case"tel":return Fu(r);case"regexp":return Lu(r,t);case"minlength":return Du(r,t);case"maxlength":return Mu(r,t);case"custom":return Tu();default:return!1}},Ru={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file"};function Vr(r){const t=r?.toLowerCase();return Ru[t]||t}function Dn(r,t=!1){if(Array.isArray(r)){const o=[];return r.forEach(l=>{const a={...l};a.name=(l.name||l.id||l.key||"").toString(),a.type=Vr(l.type),a.label=l.label||l.ua,a.rules=l.rules||l.validators,a.type==="email"&&!a.rules&&(a.rules=["email"]),l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=Dn(a.schema,a.disabled)),o.push(a)}),o}const n=[];return Object.entries(r).forEach(o=>{const l={name:o[0],...o[1],type:Vr(o[1].type),label:o[1].label||o[1].ua,rules:o[1].rules||o[1].validators,disabled:o[1].disabled??t};l.type==="email"&&!l.rules&&(l.rules=["email"]),o[1].type?.includes("list")&&(l.multiple=!0),!l.api&&o[1].data&&(l.api=`/api/suggest/${o[1].data}`),Array.isArray(l.schema)&&(l.schema=Dn(l.schema,l.disabled)),n.push(l)}),n}function Ou(r,t,n=!1){const o=e.computed(()=>Dn((Array.isArray(t),t),typeof n=="boolean"?n:n.value)),l=e.ref({});function a(d){const p=d?.conditions;if(!p)return!0;const m=Array.isArray(p)?p[0]:p,x=r?.value?.[m];return lr(x,p)}const s=(d=o.value,p=!0)=>(d.forEach(m=>{const x=[],f=Number(m?.minlength),u=Number(m?.maxlength);!Number.isNaN(f)&&Number.isFinite(f)&&x.push({type:"minlength",value:f}),!Number.isNaN(u)&&Number.isFinite(u)&&x.push({type:"maxlength",value:u});const h=[...x,...m.rules||[]];if(h.length){if(!a(m)){delete l.value[m.name];return}let g=!1,C=null;h.forEach(w=>{const b=Iu(r.value[m.name],w);b&&(g=!0,!C&&typeof b=="string"&&(C=b))}),g&&C?l.value[m.name]=C:delete l.value[m.name]}m.schema&&s(m.schema,!1)}),p&&Object.values(l.value).some(Boolean)?l.value:null),c=e.computed(()=>o.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{r.value={},l.value={}},visibleSchema:c}}const zu={class:"flex w-full h-full min-h-0 gap-6"},Pu={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},Ye=e.defineComponent({__name:"vs-compact-form",props:e.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:e.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(r,{expose:t,emit:n}){const o=n,l=r,a=e.useModel(r,"form"),s=e.useModel(r,"modelValue"),c=e.useModel(r,"values"),i=e.computed({get:()=>c.value??s.value,set:I=>{s.value=I,c.value=I}}),{errors:d,validate:p,reset:m,visibleSchema:x}=Ou(i,l.schema,e.toRef(l,"disabled")),f=e.ref(null),u=e.ref(null),h=e.ref({}),g=e.computed(()=>l.navigation),C=e.computed(()=>l.navWidth),w=e.computed(()=>l.style?.columns),b=Object.freeze({container:12,label:3}),k=e.computed(()=>l.columns??w.value??b),B=e.computed(()=>l.columns!=null||w.value!=null),M=e.computed(()=>B.value?"horizontal":l.layout),$=I=>I?.columns?"horizontal":M.value,E=I=>I?.columns??k.value,N=()=>{o("update:modelValue",i.value),p(),o("handle-submit",i.value)},v=I=>{o("value-selected",I)},S=()=>{l.formId&&(i.value?.id!==void 0&&i.value?.id!==null&&i.value?.id!==""||(i.value={...i.value??{},id:l.formId}))};t({validate:p,reset:m,errors:d}),e.onMounted(()=>{S(),a.value={value:i.value,errors:d.value,reset:m,validate:p,formId:l.formId}}),e.watch(()=>l.formId,()=>{S()},{immediate:!0});function D(I,A){if(I===A)return!0;if(typeof I!="object"||typeof A!="object"||!I||!A)return!1;const T=Object.keys(I),L=Object.keys(A);return T.length!==L.length?!1:T.every(U=>I[U]===A[U])}return e.provide("form",a),e.provide("values",i),e.provide("field-props",h),(I,A)=>(e.openBlock(),e.createElementBlock("div",zu,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:u},[e.createElementVNode("form",{ref_key:"formRef",ref:f,onSubmit:e.withModifiers(N,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",M.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(x),(T,L)=>(e.openBlock(),e.createElementBlock("div",{key:T.name,class:e.normalizeClass($(T)==="horizontal"?"col-span-12":`col-span-${T.col||12}`)},[e.createVNode(Er,{style:e.normalizeStyle(I.style),item:T,layout:$(T),columns:E(T),"model-value":i.value[T.name],"onUpdate:modelValue":U=>{const H=i.value[T.name];D(H,U)||(i.value[T.name]=U)},error:e.unref(d)[T.name],onValueSelected:v},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),$(T)==="settings"&&L+1!==e.unref(x).length?(e.openBlock(),e.createElementBlock("div",Pu)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode($u,{target:f.value,"scroll-container":u.value,enabled:g.value,width:C.value},null,8,["target","scroll-container","enabled","width"])]))}}),ju={class:"relative"},Uu={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},Hu={class:"m-[10px] fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 min-h-0 h-fit max-h-[80vh] overflow-hidden opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl lg:w-7/12 w-11/12"},qu={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Ku={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Gu={class:"p-4 mim-h-0 h-full overflow-auto"},Sr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(r,{emit:t}){const n=r,o=t,l=e.ref(n.schema),a=e.ref(n.defaultValue?JSON.parse(JSON.stringify(n.defaultValue)):{}),s=e.ref({}),c=e.ref(n.token||""),i=e.ref(n.mode),d=()=>{const u=n.method?.trim().toUpperCase();return u==="GET"||u==="POST"||u==="PUT"?u:i.value==="add"?"POST":"PUT"},p=()=>{me.notify({type:"success",title:"Успішно",message:`Дані успішно ${i.value==="add"?"збережено":"оновлено"}`})},m=async u=>{if(console.log(u),u.ok){await u.json().catch(()=>({})),p(),o("save",a.value);return}if(u.status===400){const h=await u.json().catch(()=>({}));me.notify({type:"warning",title:"Помилка валідації",message:h.message||"Некоректні дані (400)"});return}if(u.status===500){me.notify({type:"error",title:"Серверна помилка",message:"Виникла помилка на сервері (500)"});return}me.notify({type:"error",title:"Помилка",message:`Статус: ${u.status}`})};async function x(){const u=s.value.validate();if(u){me.notify({type:"warning",title:"Помилка валідації",message:Object.entries(u).map(([g,C])=>`${g}: ${C}`).join(`
|
|
5
5
|
`)});return}const h=n.api?.trim();if(h){const g=d();try{const C=await fetch(h,{method:g,headers:g==="GET"?void 0:{"Content-Type":"application/json"},body:g==="GET"?void 0:JSON.stringify(a.value)});await m(C)}catch(C){me.notify({type:"error",title:"Помилка з’єднання",message:C.message||"Не вдалося виконати запит"})}return}if(c.value)try{const g=await fetch(`/api/table/${c.value}`,{method:i.value==="add"?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.value)});await m(g)}catch(g){me.notify({type:"error",title:"Помилка з’єднання",message:g.message||"Не вдалося виконати запит"})}else o("edit",a.value),f()}function f(){o("close")}return e.onMounted(async()=>{try{if(n.form&&!n.schema){const u=await fetch(`/api/template/form/${n.form}`);if(!u.ok){me.notify({type:u.status>=400&&u.status<500?"warning":"error",title:"Error",message:`Error code: ${u.status}`});return}const h=await u.json();l.value=h.schema,h.token&&(c.value=h.token)}else if(n.token&&!n.defaultValue){c.value=n.token;const u=await fetch(`/api/form/${c.value}`);if(!u.ok){me.notify({type:u.status>=400&&u.status<500?"warning":"error",title:"Error",message:`Error code: ${u.status}`});return}const h=await u.json();l.value=h.schema,h.data?a.value=h.data:i.value="add",h.obj&&(a.value={...a.value,...h.obj})}}catch(u){me.notify({type:"error",title:"Error",message:u.message||"Unexpected error"}),console.error(u)}}),(u,h)=>(e.openBlock(),e.createElementBlock("div",ju,[e.createElementVNode("div",Uu,[e.createElementVNode("div",Hu,[e.createElementVNode("div",qu,[e.createElementVNode("h3",Ku,e.toDisplayString(i.value==="add"?"Додати":"Змінити"),1),e.createElementVNode("button",{onClick:f,type:"button",class:"size-8 inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent bg-gray-100 text-gray-800 hover:bg-gray-200 focus:outline-none focus:bg-gray-200 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-400 dark:focus:bg-neutral-600"},[h[2]||(h[2]=e.createElementVNode("span",{class:"sr-only"},"Close",-1)),e.createVNode(e.unref(z.X),{class:"h-4 w-4 flex-shrink-0"})])]),e.createElementVNode("div",Gu,[l.value?(e.openBlock(),e.createBlock(Ye,{key:0,schema:l.value,values:a.value,"onUpdate:values":h[0]||(h[0]=g=>a.value=g),form:s.value,"onUpdate:form":h[1]||(h[1]=g=>s.value=g),formId:c.value},null,8,["schema","values","form","formId"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"vs-form__head mr-5 mb-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},[e.createElementVNode("button",{type:"button",onClick:f,class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:x,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])])])]))}}),Wu=1440*60*1e3,Yu=["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"],Zu=["січ","лют","бер","квіт","трав","черв","лип","серп","вер","жовт","лист","груд"],Xu=["нд","пн","вт","ср","чт","пт","сб"];function $e(r){return r instanceof Date&&!Number.isNaN(r.getTime())}const $t=r=>new Date(r.getTime());function Ct(r){const t=$t(r);return t.setHours(0,0,0,0),t}function At(r){const t=$t(r);return t.setHours(23,59,59,999),t}function Mn(r){return Ct(new Date(r.getFullYear(),r.getMonth(),1))}function Ln(r){return At(new Date(r.getFullYear(),r.getMonth()+1,0))}function Tn(r,t){const n=new Date(r),o=n.getDate();n.setDate(1),n.setMonth(n.getMonth()+t);const l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return n.setDate(Math.min(o,l)),n}function Ju(r,t){return Tn(r,-1)}function nn(r,t){const n=new Date(r);return n.setFullYear(n.getFullYear()+t),n}function $r(r,t){return nn(r,-t)}function Nr(r){return Ct(new Date(r.getFullYear(),0,1))}function Ar(r){return At(new Date(r.getFullYear(),11,31))}function Qu(r){const t=Math.floor(r.getFullYear()/10)*10;return Ct(new Date(t,0,1))}function ep(r){const t=Math.floor(r.getFullYear()/10)*10+9;return At(new Date(t,11,31))}const Ze=r=>r.getFullYear(),rn=r=>Math.floor(r.getFullYear()/10)*10;function tp(r){const t=[];let n=Ct(r.start);const o=Ct(r.end);for(;n<=o;)t.push($t(n)),n=new Date(n.getTime()+Wu);return t}function np(r){const t=[];let n=Mn(r.start);const o=Ln(r.end);for(;n<=o;)t.push($t(n)),n=Tn(n,1);return t}function rp(r){const t=[];let n=Nr(r.start);const o=Ar(r.end);for(;n<=o;)t.push($t(n)),n=nn(n,1);return t}function In(r,t=1){const n=Ct(r),o=(n.getDay()-t+7)%7;return n.setDate(n.getDate()-o),n}function op(r,t=1){const n=In(r,t);return n.setDate(n.getDate()+6),At(n)}function lp(r,t,n=0){const o=In(r,n),l=(t-n+7)%7;return o.setDate(o.getDate()+l),o}const on=(r,t)=>!!r&&!!t&&r.getFullYear()===t.getFullYear()&&r.getMonth()===t.getMonth()&&r.getDate()===t.getDate(),Rn=(r,t)=>!!r&&!!t&&r.getFullYear()===t.getFullYear()&&r.getMonth()===t.getMonth(),Fr=(r,t)=>!!r&&!!t&&r.getFullYear()===t.getFullYear(),Dr=(r,t)=>!!r&&!!t&&on(r,t)&&r.getHours()===t.getHours(),ap=(r,t)=>!!r&&!!t&&Dr(r,t)&&r.getMinutes()===t.getMinutes();function sp(r,t){const n=r.getTime();return n>=t.start.getTime()&&n<=t.end.getTime()}const Ft=(r,t)=>!!r&&!!t&&r.getTime()<t.getTime(),Dt=(r,t)=>!!r&&!!t&&r.getTime()>t.getTime();function ip(r){const t=r.filter(n=>$e(n));if(t.length)return t.reduce((n,o)=>n.getTime()>=o.getTime()?n:o)}function cp(r){const t=r.filter(n=>$e(n));if(t.length)return t.reduce((n,o)=>n.getTime()<=o.getTime()?n:o)}function Mr(r,t){const n=$t(r);return typeof t.year=="number"&&n.setFullYear(t.year),typeof t.month=="number"&&n.setMonth(t.month),typeof t.date=="number"&&n.setDate(t.date),typeof t.hours=="number"&&n.setHours(t.hours),typeof t.minutes=="number"&&n.setMinutes(t.minutes),typeof t.seconds=="number"&&n.setSeconds(t.seconds),typeof t.milliseconds=="number"&&n.setMilliseconds(t.milliseconds),n}const ln=(r,t=2)=>String(r).padStart(t,"0");function Lr(r,t){return t==="wide"?Yu[r]:Zu[r]}function dp(r){return Xu[r]}const up=[{token:"LLLL",format:r=>Lr(r.getMonth(),"wide")},{token:"LLL",format:r=>Lr(r.getMonth(),"abbreviated")},{token:"EE",format:r=>dp(r.getDay())},{token:"yyyy",format:r=>String(r.getFullYear())},{token:"MM",format:r=>ln(r.getMonth()+1)},{token:"dd",format:r=>ln(r.getDate())},{token:"HH",format:r=>ln(r.getHours())},{token:"mm",format:r=>ln(r.getMinutes())}];function an(r,t){if(!$e(r))return"";let n="",o=0;for(;o<t.length;){const l=up.find(a=>t.startsWith(a.token,o));l?(n+=l.format(r),o+=l.token.length):(n+=t[o],o+=1)}return n}const pp={"yyyy-MM-dd":/^(\d{4})-(\d{2})-(\d{2})$/,"dd.MM.yyyy":/^(\d{2})\.(\d{2})\.(\d{4})$/,"dd.MM.yyyy HH:mm":/^(\d{2})\.(\d{2})\.(\d{4}) (\d{2}):(\d{2})$/,"HH:mm":/^(\d{2}):(\d{2})$/,"MM.yyyy":/^(\d{2})\.(\d{4})$/,yyyy:/^(\d{4})$/};function Tr(r,t){const n=pp[t];if(!n){const l=new Date(r);return $e(l)?l:null}const o=r.match(n);if(!o)return null;switch(t){case"yyyy-MM-dd":{const[,l,a,s]=o,c=new Date(Number(l),Number(a)-1,Number(s));return $e(c)?c:null}case"dd.MM.yyyy":{const[,l,a,s]=o,c=new Date(Number(s),Number(a)-1,Number(l));return $e(c)?c:null}case"dd.MM.yyyy HH:mm":{const[,l,a,s,c,i]=o,d=new Date(Number(s),Number(a)-1,Number(l),Number(c),Number(i));return $e(d)?d:null}case"HH:mm":{const[,l,a]=o,s=new Date;return s.setHours(Number(l),Number(a),0,0),s}case"MM.yyyy":{const[,l,a]=o;return new Date(Number(a),Number(l)-1,1)}case"yyyy":{const[,l]=o;return new Date(Number(l),0,1)}default:return null}}const fp=["year","month","day","time","custom"],mp=e.defineComponent({components:{ChevronLeft:z.ChevronLeft,ChevronRight:z.ChevronRight},emits:{elementClick:r=>$e(r),left:()=>!0,right:()=>!0,heading:()=>!0},props:{headingClickable:{type:Boolean,default:!1},leftDisabled:{type:Boolean,default:!1},rightDisabled:{type:Boolean,default:!1},columnCount:{type:Number,default:7},items:{type:Array,default:()=>[]},viewMode:{type:String,required:!0,validate:r=>typeof r=="string"&&fp.includes(r)}}}),hp={class:"v3dp__heading"},gp=["disabled"],yp=["disabled"],bp={class:"v3dp__body"},kp={class:"v3dp__subheading"},xp={class:"v3dp__elements"},wp=["disabled","onClick"];function _p(r,t,n,o,l,a){const s=e.resolveComponent("ChevronLeft"),c=e.resolveComponent("ChevronRight");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["v3dp__popout",`v3dp__popout-${r.viewMode}`]),style:e.normalizeStyle({"--popout-column-definition":`repeat(${r.columnCount}, 1fr)`}),onMousedown:t[3]||(t[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",hp,[e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__left",disabled:r.leftDisabled,onClick:t[0]||(t[0]=e.withModifiers(i=>r.$emit("left"),["stop","prevent"]))},[e.renderSlot(r.$slots,"arrow-left",{},()=>[e.createVNode(s,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,gp),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.headingClickable?"button":"span"),{class:"v3dp__heading__center",onClick:t[1]||(t[1]=e.withModifiers(i=>r.$emit("heading"),["stop","prevent"]))},{default:e.withCtx(()=>[e.renderSlot(r.$slots,"heading",{},void 0,!0)]),_:3})),e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__right",disabled:r.rightDisabled,onClick:t[2]||(t[2]=e.withModifiers(i=>r.$emit("right"),["stop","prevent"]))},[e.renderSlot(r.$slots,"arrow-right",{},()=>[e.createVNode(c,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,yp)]),e.createElementVNode("div",bp,["subheading"in r.$slots?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",kp,[e.renderSlot(r.$slots,"subheading",{},void 0,!0)]),t[4]||(t[4]=e.createElementVNode("hr",{class:"v3dp__divider"},null,-1))],64)):e.createCommentVNode("",!0),e.createElementVNode("div",xp,[e.renderSlot(r.$slots,"body",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,i=>(e.openBlock(),e.createElementBlock("button",{key:i.key,disabled:i.disabled,class:e.normalizeClass([{selected:i.selected,current:i.current},`v3dp__element__button__${r.viewMode}`]),onClick:e.withModifiers(d=>r.$emit("elementClick",i.value),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(i.display),1)],10,wp))),128))],!0)])])],38)}const sn=fe(mp,[["render",_p],["__scopeId","data-v-9e083852"]]),Cp=e.defineComponent({components:{PickerPopup:sn},emits:{"update:pageDate":r=>$e(r),select:r=>$e(r)},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(r,{emit:t}){const n=e.computed(()=>Qu(r.pageDate)),o=e.computed(()=>ep(r.pageDate)),l=(m,x,f)=>!x&&!f?!0:!(x&&Ze(m)<Ze(x)||f&&Ze(m)>Ze(f)),a=e.computed(()=>rp({start:n.value,end:o.value}).map(m=>({value:m,key:String(Ze(m)),display:Ze(m),selected:!!r.selected&&Ze(m)===Ze(r.selected),disabled:!l(m,r.lowerLimit,r.upperLimit)}))),s=e.computed(()=>{const m=Ze(n.value),x=Ze(o.value);return`${m} - ${x}`}),c=e.computed(()=>r.lowerLimit&&(rn(r.lowerLimit)===rn(r.pageDate)||Ft(r.pageDate,r.lowerLimit))),i=e.computed(()=>r.upperLimit&&(rn(r.upperLimit)===rn(r.pageDate)||Dt(r.pageDate,r.upperLimit)));return{years:a,heading:s,leftDisabled:c,rightDisabled:i,previousPage:()=>t("update:pageDate",$r(r.pageDate,10)),nextPage:()=>t("update:pageDate",nn(r.pageDate,10))}}});function vp(r,t,n,o,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{columnCount:3,leftDisabled:r.leftDisabled,rightDisabled:r.rightDisabled,items:r.years,viewMode:"year",onLeft:r.previousPage,onRight:r.nextPage,onElementClick:t[0]||(t[0]=c=>r.$emit("select",c))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.heading),1)]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const Ep=fe(Cp,[["render",vp]]),Bp=e.defineComponent({components:{PickerPopup:sn},emits:{"update:pageDate":r=>$e(r),select:r=>$e(r),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"LLL"},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(r,{emit:t}){const n=e.computed(()=>Nr(r.pageDate)),o=e.computed(()=>Ar(r.pageDate)),l=e.computed(()=>x=>an(x,r.format)),a=(x,f,u)=>!f&&!u?!0:!(f&&Ft(x,Mn(f))||u&&Dt(x,Ln(u))),s=e.computed(()=>np({start:n.value,end:o.value}).map(x=>({value:x,display:l.value(x),key:l.value(x),selected:!!r.selected&&Rn(r.selected,x),disabled:!a(x,r.lowerLimit,r.upperLimit)}))),c=e.computed(()=>Ze(n.value)),i=e.computed(()=>r.lowerLimit&&(Fr(r.lowerLimit,r.pageDate)||Ft(r.pageDate,r.lowerLimit))),d=e.computed(()=>r.upperLimit&&(Fr(r.upperLimit,r.pageDate)||Dt(r.pageDate,r.upperLimit)));return{months:s,heading:c,leftDisabled:i,rightDisabled:d,previousPage:()=>t("update:pageDate",$r(r.pageDate,1)),nextPage:()=>t("update:pageDate",nn(r.pageDate,1))}}});function Vp(r,t,n,o,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:3,items:r.months,leftDisabled:r.leftDisabled,rightDisabled:r.rightDisabled,viewMode:"month",onLeft:r.previousPage,onRight:r.nextPage,onHeading:t[0]||(t[0]=c=>r.$emit("back")),onElementClick:t[1]||(t[1]=c=>r.$emit("select",c))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.heading),1)]),_:1},8,["items","leftDisabled","rightDisabled","onLeft","onRight"])}const Sp=fe(Bp,[["render",Vp]]),$p=e.defineComponent({components:{PickerPopup:sn},emits:{"update:pageDate":r=>$e(r),select:r=>$e(r),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"dd"},headingFormat:{type:String,required:!1,default:"LLLL yyyy"},weekdayFormat:{type:String,required:!1,default:"EE"},weekStartsOn:{type:Number,required:!1,default:1,validator:r=>typeof r=="number"&&Number.isInteger(r)&&r>=0&&r<=6},customWeekdays:{type:Array,required:!1},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1}},setup(r,{emit:t}){const n=e.computed(()=>g=>C=>an(C,g)),o=e.computed(()=>Mn(r.pageDate)),l=e.computed(()=>Ln(r.pageDate)),a=e.computed(()=>({start:o.value,end:l.value})),s=e.computed(()=>({start:In(o.value,r.weekStartsOn),end:op(l.value,r.weekStartsOn)})),c=e.computed(()=>r.customWeekdays?.length===7?r.customWeekdays:null),i=e.computed(()=>{const g=r.weekStartsOn,C=c.value;if(C)return Array.from({length:7}).map((b,k)=>C[(g+k)%7]);const w=n.value(r.weekdayFormat);return Array.from(Array(7)).map((b,k)=>(g+k)%7).map(b=>lp(new Date,b,r.weekStartsOn)).map(w)}),d=(g,C,w,b)=>b?.dates?.some(k=>on(g,k))||b?.predicate?.(g)?!1:!C&&!w?!0:!(C&&Ft(g,Ct(C))||w&&Dt(g,At(w))),p=e.computed(()=>{const g=new Date,C=n.value(r.format);return tp(s.value).map(w=>({value:w,display:C(w),selected:!!r.selected&&on(r.selected,w),current:on(g,w),disabled:!r.allowOutsideInterval&&!sp(w,a.value)||!d(w,r.lowerLimit,r.upperLimit,r.disabledDates),key:n.value("yyyy-MM-dd")(w)}))}),m=e.computed(()=>n.value(r.headingFormat)(r.pageDate)),x=e.computed(()=>r.lowerLimit&&(Rn(r.lowerLimit,r.pageDate)||Ft(r.pageDate,r.lowerLimit))),f=e.computed(()=>r.upperLimit&&(Rn(r.upperLimit,r.pageDate)||Dt(r.pageDate,r.upperLimit)));return{weekDays:i,days:p,heading:m,leftDisabled:x,rightDisabled:f,previousPage:()=>t("update:pageDate",Ju(r.pageDate)),nextPage:()=>t("update:pageDate",Tn(r.pageDate,1))}}});function Np(r,t,n,o,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",leftDisabled:r.leftDisabled,rightDisabled:r.rightDisabled,items:r.days,viewMode:"day",onLeft:r.previousPage,onRight:r.nextPage,onHeading:t[0]||(t[0]=c=>r.$emit("back")),onElementClick:t[1]||(t[1]=c=>r.$emit("select",c))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.heading),1)]),subheading:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.weekDays,(c,i)=>(e.openBlock(),e.createElementBlock("span",{key:c,class:e.normalizeClass(`v3dp__subheading__weekday__${i}`)},e.toDisplayString(c),3))),128))]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const Ap=fe($p,[["render",Np]]);function Ir(r,t){const n=r.getBoundingClientRect(),o={height:r.clientHeight,width:r.clientWidth},l=t.getBoundingClientRect();if(!(l.top>=n.top&&l.bottom<=n.top+o.height)){const s=l.top-n.top,c=l.bottom-n.bottom;Math.abs(s)<Math.abs(c)?r.scrollTop+=s:r.scrollTop+=c}}const Fp=e.defineComponent({components:{PickerPopup:sn},emits:{select:r=>$e(r),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},visible:{type:Boolean,required:!0},disabledTime:{type:Object,required:!1}},setup(r,{emit:t}){const n=e.ref(null),o=e.ref(null),l=e.computed(()=>r.pageDate??r.selected),a=e.ref(l.value.getHours()),s=e.ref(l.value.getMinutes());e.watch(()=>r.selected,f=>{let u=0,h=0;f&&(u=f.getHours(),h=f.getMinutes()),a.value=u,s.value=h});const c=e.computed(()=>[...Array(24).keys()].map(f=>({value:f,date:Mr(new Date(l.value.getTime()),{hours:f,minutes:s.value,seconds:0}),selected:a.value===f,ref:e.ref(null)}))),i=e.computed(()=>[...Array(60).keys()].map(f=>({value:f,date:Mr(new Date(l.value.getTime()),{hours:a.value,minutes:f,seconds:0}),selected:s.value===f,ref:e.ref(null)}))),d=f=>{s.value=f.value,t("select",f.date)},p=()=>{const f=c.value.find(h=>h.ref.value?.classList?.contains("selected")??!1),u=i.value.find(h=>h.ref.value?.classList?.contains("selected")??!1);f&&u&&(Ir(n.value,f.ref.value),Ir(o.value,u.ref.value))};return e.watch(()=>r.visible,f=>{f&&e.nextTick(p)}),{hoursListRef:n,minutesListRef:o,hours:a,minutes:s,hoursList:c,minutesList:i,padStartZero:f=>`0${f}`.substr(-2),selectMinutes:d,isEnabled:f=>!(r.disabledTime?.dates?.some(u=>Dr(f,u)&&ap(f,u))||r.disabledTime?.predicate?.(f)),scroll:p}}}),Dp={ref:"hoursListRef",class:"v3dp__column"},Mp=["disabled","onClick"],Lp={ref:"minutesListRef",class:"v3dp__column"},Tp=["disabled","onClick"];function Ip(r,t,n,o,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:2,leftDisabled:!0,rightDisabled:!0,viewMode:"time",onHeading:t[0]||(t[0]=c=>r.$emit("back"))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.padStartZero(r.hours))+":"+e.toDisplayString(r.padStartZero(r.minutes)),1)]),body:e.withCtx(()=>[e.createElementVNode("div",Dp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.hoursList,c=>(e.openBlock(),e.createElementBlock("button",{key:c.value,ref_for:!0,ref:c.ref,class:e.normalizeClass([{selected:c.selected},"v3dp__element_button__hour"]),disabled:!r.isEnabled(c.date),onClick:e.withModifiers(i=>r.hours=c.value,["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(r.padStartZero(c.value)),1)],10,Mp))),128))],512),e.createElementVNode("div",Lp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.minutesList,c=>(e.openBlock(),e.createElementBlock("button",{key:c.value,ref_for:!0,ref:c.ref,class:e.normalizeClass([{selected:c.selected},"v3dp__element_button__minute"]),disabled:!r.isEnabled(c.date),onClick:e.withModifiers(i=>r.selectMinutes(c),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(r.padStartZero(c.value)),1)],10,Tp))),128))],512)]),_:1})}const Rp=fe(Fp,[["render",Ip],["__scopeId","data-v-610b89e1"]]),cn=["time","day","month","year"],Op=(r,t,n=void 0)=>{let o=n||new Date;const l=ip([r,o]);l&&(o=l);const a=cp([t,o]);return a&&(o=a),o},zp=e.defineComponent({components:{YearPicker:Ep,MonthPicker:Sp,DayPicker:Ap,TimePicker:Rp},inheritAttrs:!1,props:{placeholder:{type:String,default:""},modelValue:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1},disabledTime:{type:Object,required:!1},upperLimit:{type:Date,required:!1},lowerLimit:{type:Date,required:!1},startingView:{type:String,required:!1,default:"day",validate:r=>typeof r=="string"&&cn.includes(r)},startingViewDate:{type:Date,required:!1,default:()=>new Date},dayPickerHeadingFormat:{type:String,required:!1,default:"LLLL yyyy"},monthListFormat:{type:String,required:!1,default:"LLL"},weekdayFormat:{type:String,required:!1,default:"EE"},dayFormat:{type:String,required:!1,default:"dd"},inputFormat:{type:String,required:!1,default:"yyyy-MM-dd"},weekDayNames:{type:Array,required:!1},weekStartsOn:{type:Number,required:!1,default:1,validator:r=>[0,1,2,3,4,5,6].includes(r)},disabled:{type:Boolean,required:!1,default:!1},clearable:{type:Boolean,required:!1,default:!1},typeable:{type:Boolean,required:!1,default:!1},minimumView:{type:String,required:!1,default:"day",validate:r=>typeof r=="string"&&cn.includes(r)}},emits:{"update:modelValue":r=>r==null||$e(r),decadePageChanged:r=>!0,yearPageChanged:r=>!0,monthPageChanged:r=>!0,opened:()=>!0,closed:()=>!0},setup(r,{emit:t,attrs:n}){const o=e.ref("none"),l=e.ref(r.startingViewDate),a=e.ref(null),s=e.ref(!1),c=e.ref(""),i=T=>{const L=T.replace(/[a-zA-Z]/g,"0");return/0/.test(L)?L:""},d=e.computed(()=>i(r.inputFormat));let p=null,m=null;const x=()=>{p?.destroy(),p=null},f=async()=>{if(!m){const{default:T}=await Promise.resolve().then(()=>Hn);m=T}return m},u=()=>{p&&p.value!==c.value&&(p.value=c.value??"")},h=async()=>{if(x(),!a.value||!d.value)return;p=(await f())(a.value,{mask:d.value,lazy:!0,overwrite:!0}),u()};e.watchEffect(()=>{if(!c.value)return;const T=Tr(c.value,r.inputFormat);T&&(l.value=T)}),e.watchEffect(()=>{c.value=r.modelValue&&$e(r.modelValue)?an(r.modelValue,r.inputFormat):""}),e.onMounted(()=>{d.value&&e.nextTick(()=>{h()})}),e.onBeforeUnmount(()=>{x()}),e.watch(d,T=>{T?e.nextTick(()=>{h()}):x()}),e.watch(c,()=>{u()});const g=(T="none")=>{r.disabled||(T!=="none"&&o.value==="none"&&(l.value=r.modelValue||Op(r.lowerLimit,r.upperLimit,l.value)),o.value=T,t(T!=="none"?"opened":"closed"))};e.watchEffect(()=>{r.disabled&&(o.value="none")});const C=(T,L)=>{l.value=L,T==="year"?t("decadePageChanged",L):T==="month"?t("yearPageChanged",L):T==="day"&&t("monthPageChanged",L)},w=T=>{l.value=T,r.minimumView==="year"?(g("none"),t("update:modelValue",T)):o.value="month"},b=T=>{l.value=T,r.minimumView==="month"?(g("none"),t("update:modelValue",T)):o.value="day"},k=T=>{l.value=T,r.minimumView==="day"?(g("none"),t("update:modelValue",T)):o.value="time"},B=T=>{g("none"),t("update:modelValue",T)},M=()=>{r.clearable&&(g("none"),t("update:modelValue",null),l.value=r.startingViewDate)},$=()=>s.value=!0,E=()=>g(S.value),N=()=>{s.value=!1,g()},v=T=>{const L=T.keyCode?T.keyCode:T.which;if([27,13].includes(L)&&a.value.blur(),r.typeable){const H=Tr(a.value.value,r.inputFormat);H&&c.value===an(H,r.inputFormat)&&(c.value=a.value.value,t("update:modelValue",H))}},S=e.computed(()=>{const T=cn.indexOf(r.startingView),L=cn.indexOf(r.minimumView);return T<L?r.minimumView:r.startingView}),D=T=>Object.fromEntries(Object.entries(T??{}).filter(([L,U])=>L.startsWith("--"))),I=e.computed(()=>r.weekDayNames?.length===7?r.weekDayNames:void 0);return{blur:N,focus:E,click:$,input:c,inputRef:a,pageDate:l,renderView:g,updatePageDate:C,selectYear:w,selectMonth:b,selectDay:k,selectTime:B,keyUp:v,normalizedWeekdayNames:I,viewShown:o,goBackFromTimepicker:()=>r.startingView==="time"&&r.minimumView==="time"?null:o.value="day",clearModelValue:M,initialView:S,log:T=>console.log(T),variables:D}}}),Pp={class:"v3dp__input_wrapper"},jp=["readonly","placeholder","disabled","tabindex"],Up={class:"v3dp__clearable"};function Hp(r,t,n,o,l,a){const s=e.resolveComponent("year-picker"),c=e.resolveComponent("month-picker"),i=e.resolveComponent("day-picker"),d=e.resolveComponent("time-picker");return e.openBlock(),e.createElementBlock("div",{class:"v3dp__datepicker",style:e.normalizeStyle(r.variables(r.$attrs.style))},[e.createElementVNode("div",Pp,[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"text",ref:"inputRef",readonly:!r.typeable,"onUpdate:modelValue":t[0]||(t[0]=p=>r.input=p)},r.$attrs,{placeholder:r.placeholder,disabled:r.disabled,tabindex:r.disabled?-1:0,onKeyup:t[1]||(t[1]=(...p)=>r.keyUp&&r.keyUp(...p)),onBlur:t[2]||(t[2]=(...p)=>r.blur&&r.blur(...p)),onFocus:t[3]||(t[3]=(...p)=>r.focus&&r.focus(...p)),onClick:t[4]||(t[4]=(...p)=>r.click&&r.click(...p))}),null,16,jp),[[e.vModelText,r.input]]),e.withDirectives(e.createElementVNode("div",Up,[e.renderSlot(r.$slots,"clear",{onClear:r.clearModelValue},()=>[e.createElementVNode("i",{onClick:t[5]||(t[5]=p=>r.clearModelValue())},"x")])],512),[[e.vShow,r.clearable&&r.modelValue]])]),e.withDirectives(e.createVNode(s,{pageDate:r.pageDate,"onUpdate:pageDate":t[6]||(t[6]=p=>r.updatePageDate("year",p)),selected:r.modelValue,lowerLimit:r.lowerLimit,upperLimit:r.upperLimit,onSelect:r.selectYear},null,8,["pageDate","selected","lowerLimit","upperLimit","onSelect"]),[[e.vShow,r.viewShown==="year"]]),e.withDirectives(e.createVNode(c,{pageDate:r.pageDate,"onUpdate:pageDate":t[7]||(t[7]=p=>r.updatePageDate("month",p)),selected:r.modelValue,onSelect:r.selectMonth,lowerLimit:r.lowerLimit,upperLimit:r.upperLimit,format:r.monthListFormat,onBack:t[8]||(t[8]=p=>r.viewShown="year")},null,8,["pageDate","selected","onSelect","lowerLimit","upperLimit","format"]),[[e.vShow,r.viewShown==="month"]]),e.withDirectives(e.createVNode(i,{pageDate:r.pageDate,"onUpdate:pageDate":t[9]||(t[9]=p=>r.updatePageDate("day",p)),selected:r.modelValue,weekStartsOn:r.weekStartsOn,lowerLimit:r.lowerLimit,upperLimit:r.upperLimit,headingFormat:r.dayPickerHeadingFormat,disabledDates:r.disabledDates,weekdayFormat:r.weekdayFormat,"allow-outside-interval":r.allowOutsideInterval,format:r.dayFormat,"custom-weekdays":r.normalizedWeekdayNames,onSelect:r.selectDay,onBack:t[10]||(t[10]=p=>r.viewShown="month")},null,8,["pageDate","selected","weekStartsOn","lowerLimit","upperLimit","headingFormat","disabledDates","weekdayFormat","allow-outside-interval","format","custom-weekdays","onSelect"]),[[e.vShow,r.viewShown==="day"]]),e.withDirectives(e.createVNode(d,{pageDate:r.pageDate,visible:r.viewShown==="time",selected:r.modelValue,disabledTime:r.disabledTime,onSelect:r.selectTime,onBack:r.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"]),[[e.vShow,r.viewShown==="time"]])],4)}const qp=fe(zp,[["render",Hp]]),Kp=fe(e.defineComponent({__name:"vs-input-date2",props:{clearable:{type:Boolean,default:!0},now:{type:Boolean},editable:{type:Boolean,default:!0},time:{type:Boolean},isInfinity:{type:Boolean},mode:{default:"date"},weekStart:{},dayNames:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(r,{emit:t}){const n=r,o=t,{inputClass:l}=Fe(n.style),a=e.computed(()=>n.mode?n.mode:n.time?"datetime":"date"),s={date:"дд.мм.рррр",datetime:"дд.мм.рррр гг:хх",month:"мм.рррр",week:"рррр-тиждень",time:"гг:хх",year:"рррр"},c=e.computed(()=>n.placeholder||s[a.value]||""),i=e.computed(()=>["py-1.5 px-3 block w-full placeholder:text-[#767f8f] bg-white",l.value,n.customClass,{"!border-red-600":n.error}]),d=e.computed(()=>!n.modelValue&&n.now?new Date:null),p=e.computed({get:()=>b(n.modelValue??d.value,a.value)||void 0,set:L=>o("update:modelValue",k(L,a.value))}),m=["Пн","Вт","Ср","Чт","Пт","Сб","Нд"],x=e.computed(()=>{if(n.dayNames?.length)return n.dayNames.length===7?n.dayNames:m}),f=e.computed(()=>{const L=n.weekStart,U=typeof L=="string"?Number(L):L;return U===void 0||Number.isNaN(U)?1:Math.min(6,Math.max(0,U))}),u=e.computed(()=>{switch(a.value){case"time":return{startingView:"time",minimumView:"time"};case"month":return{startingView:"month",minimumView:"month"};case"year":return{startingView:"year",minimumView:"year"};case"datetime":return{startingView:"day",minimumView:"time"};default:return{startingView:"day",minimumView:"day"}}}),h={date:"dd.MM.yyyy",datetime:"dd.MM.yyyy HH:mm",month:"MM.yyyy",time:"HH:mm",week:"dd.MM.yyyy",year:"yyyy"},g=e.computed(()=>h[a.value]||"dd.MM.yyyy"),C=e.computed(()=>({"--vdp-selected-bg-color":n.style?.primaryColor||"#2563eb","--vdp-hover-bg-color":n.style?.primaryColor||"#2563eb","--vdp-selected-color":"#ffffff","--vdp-hover-color":"#ffffff","--vdp-border-radius":n.style?.size==="sm"?"6px":"8px","--vdp-elem-font-size":n.style?.size==="sm"?"0.75em":"0.85em"})),w=e.ref(!1);e.watch(()=>n.modelValue,L=>{L?w.value=!0:n.now||(w.value=!1)},{immediate:!0}),e.watchEffect(()=>{n.now&&!n.modelValue&&!w.value&&(o("update:modelValue",k(new Date,a.value)),w.value=!0)});function b(L,U){if(!L)return null;if(L instanceof Date&&!Number.isNaN(L.getTime()))return L;if(typeof L!="string")return null;switch(U){case"datetime":return E(L);case"time":return S(L);case"month":return N(L);case"year":return v(L);case"week":return D(L);case"date":default:return $(L)}}function k(L,U){if(!L)return null;const H=L instanceof Date?L:b(L,U);if(!H)return null;switch(U){case"datetime":return`${B(H)}T${M(H)}`;case"time":return M(H);case"month":return`${H.getFullYear()}-${T(H.getMonth()+1)}`;case"year":return`${H.getFullYear()}`;case"week":{const{year:W,week:Q}=I(H);return`${W}-W${T(Q)}`}case"date":default:return B(H)}}function B(L){return`${L.getFullYear()}-${T(L.getMonth()+1)}-${T(L.getDate())}`}function M(L){return`${T(L.getHours())}:${T(L.getMinutes())}`}function $(L){const U=L.split("-");if(U.length<3)return null;const[H,W,Q]=U.map(Number);return!H||!W||!Q?null:new Date(H,W-1,Q)}function E(L){const U=L.includes("T")?L:L.replace(" ","T"),H=new Date(U);return Number.isNaN(H.getTime())?null:H}function N(L){const[U,H]=L.split("-").map(Number);return!U||Number.isNaN(H)?null:new Date(U,(H||1)-1,1)}function v(L){const U=Number(L);return U?new Date(U,0,1):null}function S(L){const U=L.match(/^(\d{1,2}):(\d{2})$/);if(!U)return null;const[,H,W]=U,Q=new Date;return Q.setHours(Number(H),Number(W),0,0),Q}function D(L){const U=L.match(/^(\d{4})-W(\d{2})$/);if(!U)return null;const[,H,W]=U,Q=Number(W);return A(Number(H),Q)}function I(L){const U=new Date(Date.UTC(L.getFullYear(),L.getMonth(),L.getDate())),H=U.getUTCDay()||7;U.setUTCDate(U.getUTCDate()+4-H);const W=new Date(Date.UTC(U.getUTCFullYear(),0,1)),Q=Math.ceil(((U.getTime()-W.getTime())/864e5+1)/7);return{year:U.getUTCFullYear(),week:Q}}function A(L,U){if(!L||!U)return null;const H=new Date(L,0,1+(U-1)*7),W=H.getDay(),Q=H;return W<=4?Q.setDate(H.getDate()-H.getDay()+1):Q.setDate(H.getDate()+8-H.getDay()),Q}function T(L){return String(L).padStart(2,"0")}return(L,U)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-date-picker",n.customClass]),style:e.normalizeStyle(C.value)},[e.createVNode(qp,{modelValue:p.value,"onUpdate:modelValue":U[0]||(U[0]=H=>p.value=H),placeholder:c.value,disabled:n.disabled,clearable:n.clearable,typeable:n.editable,"week-day-names":x.value,"week-starts-on":f.value,"starting-view":u.value.startingView,"minimum-view":u.value.minimumView,"input-format":g.value,name:n.name,class:e.normalizeClass(i.value)},null,8,["modelValue","placeholder","disabled","clearable","typeable","week-day-names","week-starts-on","starting-view","minimum-view","input-format","name","class"])],6))}}),[["__scopeId","data-v-a65a2ac3"]]),Gp={form:{richtext:{paragraph:"Paragraph",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",createTable:"Create Table",addColumn:"Add Column",addRow:"Add Row",deleteColumn:"Delete Column",deleteRow:"Delete Row",deleteTable:"Delete Table",mergeCells:"Merge Cells",splitCells:"Split Cells",linkTitle:"Enter Link",link:"Link",linkUrl:"Enter URL",editLink:"Edit Link",openLink:"Open Link",removeLink:"Remove Link",openInNewTab:"Open in New Tab",editor:"Editor",html:"HTML",markdown:"Markdown",create:"Create",update:"Update",cancel:"Cancel"}}},Wp={form:{richtext:{paragraph:"Звичайний текст",heading1:"Заголовок 1",heading2:"Заголовок 2",heading3:"Заголовок 3",heading4:"Заголовок 4",heading5:"Заголовок 5",heading6:"Заголовок 6",createTable:"Створити таблицю",addColumn:"Додати колонку",addRow:"Додати рядок",deleteColumn:"Видалити колонку",deleteRow:"Видалити рядок",deleteTable:"Видалити таблицю",mergeCells:"Об'єднати комірки",splitCells:"Розділити комірки",linkTitle:"Додати посилання",link:"Посилання",linkUrl:"Введіть URL",editLink:"Редагувати посилання",openLink:"Відкрити посилання",removeLink:"Видалити посилання",openInNewTab:"Відкривати в новій вкладці",editor:"Редактор",html:"HTML",markdown:"Markdown",create:"Створити",update:"Оновити",cancel:"Скасувати"}}},Rr=Gp.form.richtext,Or=Wp.form.richtext,On={en:{form:{richtext:Rr}},uk:{form:{richtext:Or}}},zr=(r={mode:"edit",schema:null})=>new Promise(t=>{const{close:n}=me.modal({title:r.mode==="add"?"Додати":"Редагувати",template:"",visible:!0,size:"medium",closeClickBack:!0,content:Sr,contentProps:{...r,onClose:()=>{t(null),n()},onSave:o=>{t(o),n()}}})});Ye.install=function(t){t.component("VForm",Ye),Object.assign(t.config.globalProperties,{$form:zr}),t.provide("form",zr),window.v3plugin||(window.v3plugin={})};function pt(r){return typeof r=="string"||r instanceof String}function Pr(r){var t;return typeof r=="object"&&r!=null&&(r==null||(t=r.constructor)==null?void 0:t.name)==="Object"}function jr(r,t){return Array.isArray(t)?jr(r,(n,o)=>t.includes(o)):Object.entries(r).reduce((n,o)=>{let[l,a]=o;return t(a,l)&&(n[l]=a),n},{})}const re={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function Ur(r){switch(r){case re.LEFT:return re.FORCE_LEFT;case re.RIGHT:return re.FORCE_RIGHT;default:return r}}function zn(r){return r.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function dn(r,t){if(t===r)return!0;const n=Array.isArray(t),o=Array.isArray(r);let l;if(n&&o){if(t.length!=r.length)return!1;for(l=0;l<t.length;l++)if(!dn(t[l],r[l]))return!1;return!0}if(n!=o)return!1;if(t&&r&&typeof t=="object"&&typeof r=="object"){const a=t instanceof Date,s=r instanceof Date;if(a&&s)return t.getTime()==r.getTime();if(a!=s)return!1;const c=t instanceof RegExp,i=r instanceof RegExp;if(c&&i)return t.toString()==r.toString();if(c!=i)return!1;const d=Object.keys(t);for(l=0;l<d.length;l++)if(!Object.prototype.hasOwnProperty.call(r,d[l]))return!1;for(l=0;l<d.length;l++)if(!dn(r[d[l]],t[d[l]]))return!1;return!0}else if(t&&r&&typeof t=="function"&&typeof r=="function")return t.toString()===r.toString();return!1}class Yp{constructor(t){for(Object.assign(this,t);this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start;if(this.insertedCount)for(;this.value.slice(this.cursorPos)!==this.oldValue.slice(this.oldSelection.end);)this.value.length-this.cursorPos<this.oldValue.length-this.oldSelection.end?++this.oldSelection.end:++this.cursorPos}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){return this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return!this.removedCount||this.insertedCount?re.NONE:(this.oldSelection.end===this.cursorPos||this.oldSelection.start===this.cursorPos)&&this.oldSelection.end===this.oldSelection.start?re.RIGHT:re.LEFT}}function ue(r,t){return new ue.InputMask(r,t)}function Hr(r){if(r==null)throw new Error("mask property should be defined");return r instanceof RegExp?ue.MaskedRegExp:pt(r)?ue.MaskedPattern:r===Date?ue.MaskedDate:r===Number?ue.MaskedNumber:Array.isArray(r)||r===Array?ue.MaskedDynamic:ue.Masked&&r.prototype instanceof ue.Masked?r:ue.Masked&&r instanceof ue.Masked?r.constructor:r instanceof Function?ue.MaskedFunction:(console.warn("Mask not found for mask",r),ue.Masked)}function Nt(r){if(!r)throw new Error("Options in not defined");if(ue.Masked){if(r.prototype instanceof ue.Masked)return{mask:r};const{mask:t=void 0,...n}=r instanceof ue.Masked?{mask:r}:Pr(r)&&r.mask instanceof ue.Masked?r:{};if(t){const o=t.mask;return{...jr(t,(l,a)=>!a.startsWith("_")),mask:t.constructor,_mask:o,...n}}}return Pr(r)?{...r}:{mask:r}}function tt(r){if(ue.Masked&&r instanceof ue.Masked)return r;const t=Nt(r),n=Hr(t.mask);if(!n)throw new Error("Masked class is not found for provided mask "+t.mask+", appropriate module needs to be imported manually before creating mask.");return t.mask===n&&delete t.mask,t._mask&&(t.mask=t._mask,delete t._mask),new n(t)}ue.createMask=tt;class un{get selectionStart(){let t;try{t=this._unsafeSelectionStart}catch{}return t??this.value.length}get selectionEnd(){let t;try{t=this._unsafeSelectionEnd}catch{}return t??this.value.length}select(t,n){if(!(t==null||n==null||t===this.selectionStart&&n===this.selectionEnd))try{this._unsafeSelect(t,n)}catch{}}get isActive(){return!1}}ue.MaskElement=un;const qr=90,Zp=89;class Mt extends un{constructor(t){super(),this.input=t,this._onKeydown=this._onKeydown.bind(this),this._onInput=this._onInput.bind(this),this._onBeforeinput=this._onBeforeinput.bind(this),this._onCompositionEnd=this._onCompositionEnd.bind(this)}get rootElement(){var t,n,o;return(t=(n=(o=this.input).getRootNode)==null?void 0:n.call(o))!=null?t:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(t){this.input.addEventListener("keydown",this._onKeydown),this.input.addEventListener("input",this._onInput),this.input.addEventListener("beforeinput",this._onBeforeinput),this.input.addEventListener("compositionend",this._onCompositionEnd),this.input.addEventListener("drop",t.drop),this.input.addEventListener("click",t.click),this.input.addEventListener("focus",t.focus),this.input.addEventListener("blur",t.commit),this._handlers=t}_onKeydown(t){if(this._handlers.redo&&(t.keyCode===qr&&t.shiftKey&&(t.metaKey||t.ctrlKey)||t.keyCode===Zp&&t.ctrlKey))return t.preventDefault(),this._handlers.redo(t);if(this._handlers.undo&&t.keyCode===qr&&(t.metaKey||t.ctrlKey))return t.preventDefault(),this._handlers.undo(t);t.isComposing||this._handlers.selectionChange(t)}_onBeforeinput(t){if(t.inputType==="historyUndo"&&this._handlers.undo)return t.preventDefault(),this._handlers.undo(t);if(t.inputType==="historyRedo"&&this._handlers.redo)return t.preventDefault(),this._handlers.redo(t)}_onCompositionEnd(t){this._handlers.input(t)}_onInput(t){t.isComposing||this._handlers.input(t)}unbindEvents(){this.input.removeEventListener("keydown",this._onKeydown),this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("beforeinput",this._onBeforeinput),this.input.removeEventListener("compositionend",this._onCompositionEnd),this.input.removeEventListener("drop",this._handlers.drop),this.input.removeEventListener("click",this._handlers.click),this.input.removeEventListener("focus",this._handlers.focus),this.input.removeEventListener("blur",this._handlers.commit),this._handlers={}}}ue.HTMLMaskElement=Mt;class Kr extends Mt{constructor(t){super(t),this.input=t}get _unsafeSelectionStart(){return this.input.selectionStart!=null?this.input.selectionStart:this.value.length}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,n){this.input.setSelectionRange(t,n)}get value(){return this.input.value}set value(t){this.input.value=t}}ue.HTMLMaskElement=Mt;class Pn extends Mt{get _unsafeSelectionStart(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),o=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||o==null||o<l?o:l}get _unsafeSelectionEnd(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),o=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||o==null||o>l?o:l}_unsafeSelect(t,n){if(!this.rootElement.createRange)return;const o=this.rootElement.createRange();o.setStart(this.input.firstChild||this.input,t),o.setEnd(this.input.lastChild||this.input,n);const l=this.rootElement,a=l.getSelection&&l.getSelection();a&&(a.removeAllRanges(),a.addRange(o))}get value(){return this.input.textContent||""}set value(t){this.input.textContent=t}}ue.HTMLContenteditableMaskElement=Pn;class pn{constructor(){this.states=[],this.currentIndex=0}get currentState(){return this.states[this.currentIndex]}get isEmpty(){return this.states.length===0}push(t){this.currentIndex<this.states.length-1&&(this.states.length=this.currentIndex+1),this.states.push(t),this.states.length>pn.MAX_LENGTH&&this.states.shift(),this.currentIndex=this.states.length-1}go(t){return this.currentIndex=Math.min(Math.max(this.currentIndex+t,0),this.states.length-1),this.currentState}undo(){return this.go(-1)}redo(){return this.go(1)}clear(){this.states.length=0,this.currentIndex=0}}pn.MAX_LENGTH=100;class Gr{constructor(t,n){this.el=t instanceof un?t:t.isContentEditable&&t.tagName!=="INPUT"&&t.tagName!=="TEXTAREA"?new Pn(t):new Kr(t),this.masked=tt(n),this._listeners={},this._value="",this._unmaskedValue="",this._rawInputValue="",this.history=new pn,this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this._onUndo=this._onUndo.bind(this),this._onRedo=this._onRedo.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}maskEquals(t){var n;return t==null||((n=this.masked)==null?void 0:n.maskEquals(t))}get mask(){return this.masked.mask}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof ue.Masked)&&this.masked.constructor===Hr(t)){this.masked.updateOptions({mask:t});return}const n=t instanceof ue.Masked?t:tt({mask:t});n.unmaskedValue=this.masked.unmaskedValue,this.masked=n}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl("auto"))}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl("auto"))}get rawInputValue(){return this._rawInputValue}set rawInputValue(t){this.rawInputValue!==t&&(this.masked.rawInputValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl("auto"))}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange,undo:this._onUndo,redo:this._onRedo})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t,n){const o=this._listeners[t];o&&o.forEach(l=>l(n))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){!this.el||!this.el.isActive||(this.el.select(t,t),this._saveSelection())}_saveSelection(){this.displayValue!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value,this._unmaskedValue=this.masked.unmaskedValue,this._rawInputValue=this.masked.rawInputValue}updateControl(t){const n=this.masked.unmaskedValue,o=this.masked.value,l=this.masked.rawInputValue,a=this.displayValue,s=this.unmaskedValue!==n||this.value!==o||this._rawInputValue!==l;this._unmaskedValue=n,this._value=o,this._rawInputValue=l,this.el.value!==a&&(this.el.value=a),t==="auto"?this.alignCursor():t!=null&&(this.cursorPos=t),s&&this._fireChangeEvents(),!this._historyChanging&&(s||this.history.isEmpty)&&this.history.push({unmaskedValue:n,selection:{start:this.selectionStart,end:this.cursorPos}})}updateOptions(t){const{mask:n,...o}=t,l=!this.maskEquals(n),a=this.masked.optionsIsChanged(o);l&&(this.mask=n),a&&this.masked.updateOptions(o),(l||a)&&this.updateControl()}updateCursor(t){t!=null&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())},10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,re.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,n){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(n),this}off(t,n){if(!this._listeners[t])return this;if(!n)return delete this._listeners[t],this;const o=this._listeners[t].indexOf(n);return o>=0&&this._listeners[t].splice(o,1),this}_onInput(t){this._inputEvent=t,this._abortUpdateCursor();const n=new Yp({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),o=this.masked.rawInputValue,l=this.masked.splice(n.startChangePos,n.removed.length,n.inserted,n.removeDirection,{input:!0,raw:!0}).offset,a=o===this.masked.rawInputValue?n.removeDirection:re.NONE;let s=this.masked.nearestInputPos(n.startChangePos+l,a);a!==re.NONE&&(s=this.masked.nearestInputPos(s,re.NONE)),this.updateControl(s),delete this._inputEvent}_onChange(){this.displayValue!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}_onDrop(t){t.preventDefault(),t.stopPropagation()}_onFocus(t){this.alignCursorFriendly()}_onClick(t){this.alignCursorFriendly()}_onUndo(){this._applyHistoryState(this.history.undo())}_onRedo(){this._applyHistoryState(this.history.redo())}_applyHistoryState(t){t&&(this._historyChanging=!0,this.unmaskedValue=t.unmaskedValue,this.el.select(t.selection.start,t.selection.end),this._saveSelection(),this._historyChanging=!1)}destroy(){this._unbindEvents(),this._listeners.length=0,delete this.el}}ue.InputMask=Gr;class ge{static normalize(t){return Array.isArray(t)?t:[t,new ge]}constructor(t){Object.assign(this,{inserted:"",rawInserted:"",tailShift:0,skip:!1},t)}aggregate(t){return this.inserted+=t.inserted,this.rawInserted+=t.rawInserted,this.tailShift+=t.tailShift,this.skip=this.skip||t.skip,this}get offset(){return this.tailShift+this.inserted.length}get consumed(){return!!this.rawInserted||this.skip}equals(t){return this.inserted===t.inserted&&this.tailShift===t.tailShift&&this.rawInserted===t.rawInserted&&this.skip===t.skip}}ue.ChangeDetails=ge;class nt{constructor(t,n,o){t===void 0&&(t=""),n===void 0&&(n=0),this.value=t,this.from=n,this.stop=o}toString(){return this.value}extend(t){this.value+=String(t)}appendTo(t){return t.append(this.toString(),{tail:!0}).aggregate(t._appendPlaceholder())}get state(){return{value:this.value,from:this.from,stop:this.stop}}set state(t){Object.assign(this,t)}unshift(t){if(!this.value.length||t!=null&&this.from>=t)return"";const n=this.value[0];return this.value=this.value.slice(1),n}shift(){if(!this.value.length)return"";const t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}class Ne{constructor(t){this._value="",this._update({...Ne.DEFAULTS,...t}),this._initialized=!0}updateOptions(t){this.optionsIsChanged(t)&&this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value}reset(){this._value=""}get value(){return this._value}set value(t){this.resolve(t,{input:!0})}resolve(t,n){n===void 0&&(n={input:!0}),this.reset(),this.append(t,n,""),this.doCommit()}get unmaskedValue(){return this.value}set unmaskedValue(t){this.resolve(t,{})}get typedValue(){return this.parse?this.parse(this.value,this):this.unmaskedValue}set typedValue(t){this.format?this.value=this.format(t,this):this.unmaskedValue=String(t)}get rawInputValue(){return this.extractInput(0,this.displayValue.length,{raw:!0})}set rawInputValue(t){this.resolve(t,{raw:!0})}get displayValue(){return this.value}get isComplete(){return!0}get isFilled(){return this.isComplete}nearestInputPos(t,n){return t}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),Math.min(this.displayValue.length,n-t)}extractInput(t,n,o){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this.displayValue.slice(t,n)}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new nt(this.extractInput(t,n),t)}appendTail(t){return pt(t)&&(t=new nt(String(t))),t.appendTo(this)}_appendCharRaw(t,n){return t?(this._value+=t,new ge({inserted:t,rawInserted:t})):new ge}_appendChar(t,n,o){n===void 0&&(n={});const l=this.state;let a;if([t,a]=this.doPrepareChar(t,n),t&&(a=a.aggregate(this._appendCharRaw(t,n)),!a.rawInserted&&this.autofix==="pad")){const s=this.state;this.state=l;let c=this.pad(n);const i=this._appendCharRaw(t,n);c=c.aggregate(i),i.rawInserted||c.equals(a)?a=c:this.state=s}if(a.inserted){let s,c=this.doValidate(n)!==!1;if(c&&o!=null){const i=this.state;if(this.overwrite===!0){s=o.state;for(let p=0;p<a.rawInserted.length;++p)o.unshift(this.displayValue.length-a.tailShift)}let d=this.appendTail(o);if(c=d.rawInserted.length===o.toString().length,!(c&&d.inserted)&&this.overwrite==="shift"){this.state=i,s=o.state;for(let p=0;p<a.rawInserted.length;++p)o.shift();d=this.appendTail(o),c=d.rawInserted.length===o.toString().length}c&&d.inserted&&(this.state=i)}c||(a=new ge,this.state=l,o&&s&&(o.state=s))}return a}_appendPlaceholder(){return new ge}_appendEager(){return new ge}append(t,n,o){if(!pt(t))throw new Error("value should be string");const l=pt(o)?new nt(String(o)):o;n!=null&&n.tail&&(n._beforeTailState=this.state);let a;[t,a]=this.doPrepare(t,n);for(let s=0;s<t.length;++s){const c=this._appendChar(t[s],n,l);if(!c.rawInserted&&!this.doSkipInvalid(t[s],n,l))break;a.aggregate(c)}return(this.eager===!0||this.eager==="append")&&n!=null&&n.input&&t&&a.aggregate(this._appendEager()),l!=null&&(a.tailShift+=this.appendTail(l).tailShift),a}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this._value=this.displayValue.slice(0,t)+this.displayValue.slice(n),new ge}withValueRefresh(t){if(this._refreshing||!this._initialized)return t();this._refreshing=!0;const n=this.rawInputValue,o=this.value,l=t();return this.rawInputValue=n,this.value&&this.value!==o&&o.indexOf(this.value)===0&&(this.append(o.slice(this.displayValue.length),{},""),this.doCommit()),delete this._refreshing,l}runIsolated(t){if(this._isolated||!this._initialized)return t(this);this._isolated=!0;const n=this.state,o=t(this);return this.state=n,delete this._isolated,o}doSkipInvalid(t,n,o){return!!this.skipInvalid}doPrepare(t,n){return n===void 0&&(n={}),ge.normalize(this.prepare?this.prepare(t,this,n):t)}doPrepareChar(t,n){return n===void 0&&(n={}),ge.normalize(this.prepareChar?this.prepareChar(t,this,n):t)}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}splice(t,n,o,l,a){o===void 0&&(o=""),l===void 0&&(l=re.NONE),a===void 0&&(a={input:!0});const s=t+n,c=this.extractTail(s),i=this.eager===!0||this.eager==="remove";let d;i&&(l=Ur(l),d=this.extractInput(0,s,{raw:!0}));let p=t;const m=new ge;if(l!==re.NONE&&(p=this.nearestInputPos(t,n>1&&t!==0&&!i?re.NONE:l),m.tailShift=p-t),m.aggregate(this.remove(p)),i&&l!==re.NONE&&d===this.rawInputValue)if(l===re.FORCE_LEFT){let x;for(;d===this.rawInputValue&&(x=this.displayValue.length);)m.aggregate(new ge({tailShift:-1})).aggregate(this.remove(x-1))}else l===re.FORCE_RIGHT&&c.unshift();return m.aggregate(this.append(o,a,c))}maskEquals(t){return this.mask===t}optionsIsChanged(t){return!dn(this,t)}typedValueEquals(t){const n=this.typedValue;return t===n||Ne.EMPTY_VALUES.includes(t)&&Ne.EMPTY_VALUES.includes(n)||(this.format?this.format(t,this)===this.format(this.typedValue,this):!1)}pad(t){return new ge}}Ne.DEFAULTS={skipInvalid:!0},Ne.EMPTY_VALUES=[void 0,null,""],ue.Masked=Ne;class ft{constructor(t,n){t===void 0&&(t=[]),n===void 0&&(n=0),this.chunks=t,this.from=n}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=pt(t)?new nt(String(t)):t;const n=this.chunks[this.chunks.length-1],o=n&&(n.stop===t.stop||t.stop==null)&&t.from===n.from+n.toString().length;if(t instanceof nt)o?n.extend(t.toString()):this.chunks.push(t);else if(t instanceof ft){if(t.stop==null){let l;for(;t.chunks.length&&t.chunks[0].stop==null;)l=t.chunks.shift(),l.from+=t.from,this.extend(l)}t.toString()&&(t.stop=t.blockIndex,this.chunks.push(t))}}appendTo(t){if(!(t instanceof ue.MaskedPattern))return new nt(this.toString()).appendTo(t);const n=new ge;for(let o=0;o<this.chunks.length;++o){const l=this.chunks[o],a=t._mapPosToBlock(t.displayValue.length),s=l.stop;let c;if(s!=null&&(!a||a.index<=s)&&((l instanceof ft||t._stops.indexOf(s)>=0)&&n.aggregate(t._appendPlaceholder(s)),c=l instanceof ft&&t._blocks[s]),c){const i=c.appendTail(l);n.aggregate(i);const d=l.toString().slice(i.rawInserted.length);d&&n.aggregate(t.append(d,{tail:!0}))}else n.aggregate(t.append(l.toString(),{tail:!0}))}return n}get state(){return{chunks:this.chunks.map(t=>t.state),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(t){const{chunks:n,...o}=t;Object.assign(this,o),this.chunks=n.map(l=>{const a="chunks"in l?new ft:new nt;return a.state=l,a})}unshift(t){if(!this.chunks.length||t!=null&&this.from>=t)return"";const n=t!=null?t-this.from:t;let o=0;for(;o<this.chunks.length;){const l=this.chunks[o],a=l.unshift(n);if(l.toString()){if(!a)break;++o}else this.chunks.splice(o,1);if(a)return a}return""}shift(){if(!this.chunks.length)return"";let t=this.chunks.length-1;for(;0<=t;){const n=this.chunks[t],o=n.shift();if(n.toString()){if(!o)break;--t}else this.chunks.splice(t,1);if(o)return o}return""}}class Xp{constructor(t,n){this.masked=t,this._log=[];const{offset:o,index:l}=t._mapPosToBlock(n)||(n<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0});this.offset=o,this.index=l,this.ok=!1}get block(){return this.masked._blocks[this.index]}get pos(){return this.masked._blockStartPos(this.index)+this.offset}get state(){return{index:this.index,offset:this.offset,ok:this.ok}}set state(t){Object.assign(this,t)}pushState(){this._log.push(this.state)}popState(){const t=this._log.pop();return t&&(this.state=t),t}bindBlock(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.displayValue.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=((n=this.block)==null?void 0:n.displayValue.length)||0){var n;if(t())return this.ok=!0}return this.ok=!1}_pushRight(t){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(t())return this.ok=!0;return this.ok=!1}pushLeftBeforeFilled(){return this._pushLeft(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,re.FORCE_LEFT),this.offset!==0))return!0})}pushLeftBeforeInput(){return this._pushLeft(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,re.LEFT),!0})}pushLeftBeforeRequired(){return this._pushLeft(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,re.LEFT),!0})}pushRightBeforeFilled(){return this._pushRight(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,re.FORCE_RIGHT),this.offset!==this.block.value.length))return!0})}pushRightBeforeInput(){return this._pushRight(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,re.NONE),!0})}pushRightBeforeRequired(){return this._pushRight(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,re.NONE),!0})}}class jn{constructor(t){Object.assign(this,t),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}get rawInputValue(){return this._isRawInput?this.value:""}get displayValue(){return this.value}reset(){this._isRawInput=!1,this._value=""}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(n),this._value||(this._isRawInput=!1),new ge}nearestInputPos(t,n){n===void 0&&(n=re.NONE);const o=0,l=this._value.length;switch(n){case re.LEFT:case re.FORCE_LEFT:return o;case re.NONE:case re.RIGHT:case re.FORCE_RIGHT:default:return l}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._isRawInput?n-t:0}extractInput(t,n,o){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),o===void 0&&(o={}),o.raw&&this._isRawInput&&this._value.slice(t,n)||""}get isComplete(){return!0}get isFilled(){return!!this._value}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new ge;const o=this.eager===!0||this.eager==="append",a=this.char===t&&(this.isUnmasking||n.input||n.raw)&&(!n.raw||!o)&&!n.tail,s=new ge({inserted:this.char,rawInserted:a?this.char:""});return this._value=this.char,this._isRawInput=a&&(n.raw||n.input),s}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new ge;return this.isFilled||(this._value=t.inserted=this.char),t}extractTail(){return new nt("")}appendTail(t){return pt(t)&&(t=new nt(String(t))),t.appendTo(this)}append(t,n,o){const l=this._appendChar(t[0],n);return o!=null&&(l.tailShift+=this.appendTail(o).tailShift),l}doCommit(){}get state(){return{_value:this._value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value,this._isRawInput=!!t._rawInputValue}pad(t){return this._appendPlaceholder()}}class Lt{constructor(t){const{parent:n,isOptional:o,placeholderChar:l,displayChar:a,lazy:s,eager:c,...i}=t;this.masked=tt(i),Object.assign(this,{parent:n,isOptional:o,placeholderChar:l,displayChar:a,lazy:s,eager:c})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),t===0&&n>=1?(this.isFilled=!1,this.masked.remove(t,n)):new ge}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get rawInputValue(){return this.masked.rawInputValue}get displayValue(){return this.masked.value&&this.displayChar||this.value}get isComplete(){return!!this.masked.value||this.isOptional}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new ge;const o=this.masked.state;let l=this.masked._appendChar(t,this.currentMaskFlags(n));return l.inserted&&this.doValidate(n)===!1&&(l=new ge,this.masked.state=o),!l.inserted&&!this.isOptional&&!this.lazy&&!n.input&&(l.inserted=this.placeholderChar),l.skip=!l.inserted&&!this.isOptional,this.isFilled=!!l.inserted,l}append(t,n,o){return this.masked.append(t,this.currentMaskFlags(n),o)}_appendPlaceholder(){return this.isFilled||this.isOptional?new ge:(this.isFilled=!0,new ge({inserted:this.placeholderChar}))}_appendEager(){return new ge}extractTail(t,n){return this.masked.extractTail(t,n)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,n,o){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.masked.extractInput(t,n,o)}nearestInputPos(t,n){n===void 0&&(n=re.NONE);const o=0,l=this.value.length,a=Math.min(Math.max(t,o),l);switch(n){case re.LEFT:case re.FORCE_LEFT:return this.isComplete?a:o;case re.RIGHT:case re.FORCE_RIGHT:return this.isComplete?a:l;case re.NONE:default:return a}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.value.slice(t,n).length}doValidate(t){return this.masked.doValidate(this.currentMaskFlags(t))&&(!this.parent||this.parent.doValidate(this.currentMaskFlags(t)))}doCommit(){this.masked.doCommit()}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue,masked:this.masked.state,isFilled:this.isFilled}}set state(t){this.masked.state=t.masked,this.isFilled=t.isFilled}currentMaskFlags(t){var n;return{...t,_beforeTailState:(t==null||(n=t._beforeTailState)==null?void 0:n.masked)||t?._beforeTailState}}pad(t){return new ge}}Lt.DEFAULT_DEFINITIONS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./};class Wr extends Ne{updateOptions(t){super.updateOptions(t)}_update(t){const n=t.mask;n&&(t.validate=o=>o.search(n)>=0),super._update(t)}}ue.MaskedRegExp=Wr;class Ae extends Ne{constructor(t){super({...Ae.DEFAULTS,...t,definitions:Object.assign({},Lt.DEFAULT_DEFINITIONS,t?.definitions)})}updateOptions(t){super.updateOptions(t)}_update(t){t.definitions=Object.assign({},this.definitions,t.definitions),super._update(t),this._rebuildMask()}_rebuildMask(){const t=this.definitions;this._blocks=[],this.exposeBlock=void 0,this._stops=[],this._maskedBlocks={};const n=this.mask;if(!n||!t)return;let o=!1,l=!1;for(let a=0;a<n.length;++a){if(this.blocks){const d=n.slice(a),p=Object.keys(this.blocks).filter(x=>d.indexOf(x)===0);p.sort((x,f)=>f.length-x.length);const m=p[0];if(m){const{expose:x,repeat:f,...u}=Nt(this.blocks[m]),h={lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,autofix:this.autofix,...u,repeat:f,parent:this},g=f!=null?new ue.RepeatBlock(h):tt(h);g&&(this._blocks.push(g),x&&(this.exposeBlock=g),this._maskedBlocks[m]||(this._maskedBlocks[m]=[]),this._maskedBlocks[m].push(this._blocks.length-1)),a+=m.length-1;continue}}let s=n[a],c=s in t;if(s===Ae.STOP_CHAR){this._stops.push(this._blocks.length);continue}if(s==="{"||s==="}"){o=!o;continue}if(s==="["||s==="]"){l=!l;continue}if(s===Ae.ESCAPE_CHAR){if(++a,s=n[a],!s)break;c=!1}const i=c?new Lt({isOptional:l,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...Nt(t[s]),parent:this}):new jn({char:s,eager:this.eager,isUnmasking:o});this._blocks.push(i)}}get state(){return{...super.state,_blocks:this._blocks.map(t=>t.state)}}set state(t){if(!t){this.reset();return}const{_blocks:n,...o}=t;this._blocks.forEach((l,a)=>l.state=n[a]),super.state=o}reset(){super.reset(),this._blocks.forEach(t=>t.reset())}get isComplete(){return this.exposeBlock?this.exposeBlock.isComplete:this._blocks.every(t=>t.isComplete)}get isFilled(){return this._blocks.every(t=>t.isFilled)}get isFixed(){return this._blocks.every(t=>t.isFixed)}get isOptional(){return this._blocks.every(t=>t.isOptional)}doCommit(){this._blocks.forEach(t=>t.doCommit()),super.doCommit()}get unmaskedValue(){return this.exposeBlock?this.exposeBlock.unmaskedValue:this._blocks.reduce((t,n)=>t+=n.unmaskedValue,"")}set unmaskedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.unmaskedValue=t,this.appendTail(n),this.doCommit()}else super.unmaskedValue=t}get value(){return this.exposeBlock?this.exposeBlock.value:this._blocks.reduce((t,n)=>t+=n.value,"")}set value(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.value=t,this.appendTail(n),this.doCommit()}else super.value=t}get typedValue(){return this.exposeBlock?this.exposeBlock.typedValue:super.typedValue}set typedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.typedValue=t,this.appendTail(n),this.doCommit()}else super.typedValue=t}get displayValue(){return this._blocks.reduce((t,n)=>t+=n.displayValue,"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const n=new ge;let o=(t=this._mapPosToBlock(this.displayValue.length))==null?void 0:t.index;if(o==null)return n;this._blocks[o].isFilled&&++o;for(let l=o;l<this._blocks.length;++l){const a=this._blocks[l]._appendEager();if(!a.inserted)break;n.aggregate(a)}return n}_appendCharRaw(t,n){n===void 0&&(n={});const o=this._mapPosToBlock(this.displayValue.length),l=new ge;if(!o)return l;for(let s=o.index,c;c=this._blocks[s];++s){var a;const i=c._appendChar(t,{...n,_beforeTailState:(a=n._beforeTailState)==null||(a=a._blocks)==null?void 0:a[s]});if(l.aggregate(i),i.consumed)break}return l}extractTail(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const o=new ft;return t===n||this._forEachBlocksInRange(t,n,(l,a,s,c)=>{const i=l.extractTail(s,c);i.stop=this._findStopBefore(a),i.from=this._blockStartPos(a),i instanceof ft&&(i.blockIndex=a),o.extend(i)}),o}extractInput(t,n,o){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),o===void 0&&(o={}),t===n)return"";let l="";return this._forEachBlocksInRange(t,n,(a,s,c,i)=>{l+=a.extractInput(c,i,o)}),l}_findStopBefore(t){let n;for(let o=0;o<this._stops.length;++o){const l=this._stops[o];if(l<=t)n=l;else break}return n}_appendPlaceholder(t){const n=new ge;if(this.lazy&&t==null)return n;const o=this._mapPosToBlock(this.displayValue.length);if(!o)return n;const l=o.index,a=t??this._blocks.length;return this._blocks.slice(l,a).forEach(s=>{if(!s.lazy||t!=null){var c;n.aggregate(s._appendPlaceholder((c=s._blocks)==null?void 0:c.length))}}),n}_mapPosToBlock(t){let n="";for(let o=0;o<this._blocks.length;++o){const l=this._blocks[o],a=n.length;if(n+=l.displayValue,t<=n.length)return{index:o,offset:t-a}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce((n,o)=>n+=o.displayValue.length,0)}_forEachBlocksInRange(t,n,o){n===void 0&&(n=this.displayValue.length);const l=this._mapPosToBlock(t);if(l){const a=this._mapPosToBlock(n),s=a&&l.index===a.index,c=l.offset,i=a&&s?a.offset:this._blocks[l.index].displayValue.length;if(o(this._blocks[l.index],l.index,c,i),a&&!s){for(let d=l.index+1;d<a.index;++d)o(this._blocks[d],d,0,this._blocks[d].displayValue.length);o(this._blocks[a.index],a.index,0,a.offset)}}}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const o=super.remove(t,n);return this._forEachBlocksInRange(t,n,(l,a,s,c)=>{o.aggregate(l.remove(s,c))}),o}nearestInputPos(t,n){if(n===void 0&&(n=re.NONE),!this._blocks.length)return 0;const o=new Xp(this,t);if(n===re.NONE)return o.pushRightBeforeInput()||(o.popState(),o.pushLeftBeforeInput())?o.pos:this.displayValue.length;if(n===re.LEFT||n===re.FORCE_LEFT){if(n===re.LEFT){if(o.pushRightBeforeFilled(),o.ok&&o.pos===t)return t;o.popState()}if(o.pushLeftBeforeInput(),o.pushLeftBeforeRequired(),o.pushLeftBeforeFilled(),n===re.LEFT){if(o.pushRightBeforeInput(),o.pushRightBeforeRequired(),o.ok&&o.pos<=t||(o.popState(),o.ok&&o.pos<=t))return o.pos;o.popState()}return o.ok?o.pos:n===re.FORCE_LEFT?0:(o.popState(),o.ok||(o.popState(),o.ok)?o.pos:0)}return n===re.RIGHT||n===re.FORCE_RIGHT?(o.pushRightBeforeInput(),o.pushRightBeforeRequired(),o.pushRightBeforeFilled()?o.pos:n===re.FORCE_RIGHT?this.displayValue.length:(o.popState(),o.ok||(o.popState(),o.ok)?o.pos:this.nearestInputPos(t,re.LEFT))):t}totalInputPositions(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);let o=0;return this._forEachBlocksInRange(t,n,(l,a,s,c)=>{o+=l.totalInputPositions(s,c)}),o}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const n=this._maskedBlocks[t];return n?n.map(o=>this._blocks[o]):[]}pad(t){const n=new ge;return this._forEachBlocksInRange(0,this.displayValue.length,o=>n.aggregate(o.pad(t))),n}}Ae.DEFAULTS={...Ne.DEFAULTS,lazy:!0,placeholderChar:"_"},Ae.STOP_CHAR="`",Ae.ESCAPE_CHAR="\\",Ae.InputDefinition=Lt,Ae.FixedDefinition=jn,ue.MaskedPattern=Ae;class Tt extends Ae{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:n=this.to||0,from:o=this.from||0,maxLength:l=this.maxLength||0,autofix:a=this.autofix,...s}=t;this.to=n,this.from=o,this.maxLength=Math.max(String(n).length,l),this.autofix=a;const c=String(this.from).padStart(this.maxLength,"0"),i=String(this.to).padStart(this.maxLength,"0");let d=0;for(;d<i.length&&i[d]===c[d];)++d;s.mask=i.slice(0,d).replace(/0/g,"\\0")+"0".repeat(this.maxLength-d),super._update(s)}get isComplete(){return super.isComplete&&!!this.value}boundaries(t){let n="",o="";const[,l,a]=t.match(/^(\D*)(\d*)(\D*)/)||[];return a&&(n="0".repeat(l.length)+a,o="9".repeat(l.length)+a),n=n.padEnd(this.maxLength,"0"),o=o.padEnd(this.maxLength,"9"),[n,o]}doPrepareChar(t,n){n===void 0&&(n={});let o;return[t,o]=super.doPrepareChar(t.replace(/\D/g,""),n),t||(o.skip=!this.isComplete),[t,o]}_appendCharRaw(t,n){if(n===void 0&&(n={}),!this.autofix||this.value.length+1>this.maxLength)return super._appendCharRaw(t,n);const o=String(this.from).padStart(this.maxLength,"0"),l=String(this.to).padStart(this.maxLength,"0"),[a,s]=this.boundaries(this.value+t);return Number(s)<this.from?super._appendCharRaw(o[this.value.length],n):Number(a)>this.to?!n.tail&&this.autofix==="pad"&&this.value.length+1<this.maxLength?super._appendCharRaw(o[this.value.length],n).aggregate(this._appendCharRaw(t,n)):super._appendCharRaw(l[this.value.length],n):super._appendCharRaw(t,n)}doValidate(t){const n=this.value;if(n.search(/[^0]/)===-1&&n.length<=this._matchFrom)return!0;const[l,a]=this.boundaries(n);return this.from<=Number(a)&&Number(l)<=this.to&&super.doValidate(t)}pad(t){const n=new ge;if(this.value.length===this.maxLength)return n;const o=this.value,l=this.maxLength-this.value.length;if(l){this.reset();for(let a=0;a<l;++a)n.aggregate(super._appendCharRaw("0",t));o.split("").forEach(a=>this._appendCharRaw(a))}return n}}ue.MaskedRange=Tt;const Jp="d{.}`m{.}`Y";class rt extends Ae{static extractPatternOptions(t){const{mask:n,pattern:o,...l}=t;return{...l,mask:pt(n)?n:o}}constructor(t){super(rt.extractPatternOptions({...rt.DEFAULTS,...t}))}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:n,pattern:o,blocks:l,...a}={...rt.DEFAULTS,...t},s=Object.assign({},rt.GET_DEFAULT_BLOCKS());t.min&&(s.Y.from=t.min.getFullYear()),t.max&&(s.Y.to=t.max.getFullYear()),t.min&&t.max&&s.Y.from===s.Y.to&&(s.m.from=t.min.getMonth()+1,s.m.to=t.max.getMonth()+1,s.m.from===s.m.to&&(s.d.from=t.min.getDate(),s.d.to=t.max.getDate())),Object.assign(s,this.blocks,l),super._update({...a,mask:pt(n)?n:o,blocks:s})}doValidate(t){const n=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&n!=null&&(this.min==null||this.min<=n)&&(this.max==null||n<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}optionsIsChanged(t){return super.optionsIsChanged(rt.extractPatternOptions(t))}}rt.GET_DEFAULT_BLOCKS=()=>({d:{mask:Tt,from:1,to:31,maxLength:2},m:{mask:Tt,from:1,to:12,maxLength:2},Y:{mask:Tt,from:1900,to:9999}}),rt.DEFAULTS={...Ae.DEFAULTS,mask:Date,pattern:Jp,format:(r,t)=>{if(!r)return"";const n=String(r.getDate()).padStart(2,"0"),o=String(r.getMonth()+1).padStart(2,"0"),l=r.getFullYear();return[n,o,l].join(".")},parse:(r,t)=>{const[n,o,l]=r.split(".").map(Number);return new Date(l,o-1,n)}},ue.MaskedDate=rt;class It extends Ne{constructor(t){super({...It.DEFAULTS,...t}),this.currentMask=void 0}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),"mask"in t&&(this.exposeMask=void 0,this.compiledMasks=Array.isArray(t.mask)?t.mask.map(n=>{const{expose:o,...l}=Nt(n),a=tt({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...l});return o&&(this.exposeMask=a),a}):[])}_appendCharRaw(t,n){n===void 0&&(n={});const o=this._applyDispatch(t,n);return this.currentMask&&o.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(n))),o}_applyDispatch(t,n,o){t===void 0&&(t=""),n===void 0&&(n={}),o===void 0&&(o="");const l=n.tail&&n._beforeTailState!=null?n._beforeTailState._value:this.value,a=this.rawInputValue,s=n.tail&&n._beforeTailState!=null?n._beforeTailState._rawInputValue:a,c=a.slice(s.length),i=this.currentMask,d=new ge,p=i?.state;return this.currentMask=this.doDispatch(t,{...n},o),this.currentMask&&(this.currentMask!==i?(this.currentMask.reset(),s&&(this.currentMask.append(s,{raw:!0}),d.tailShift=this.currentMask.value.length-l.length),c&&(d.tailShift+=this.currentMask.append(c,{raw:!0,tail:!0}).tailShift)):p&&(this.currentMask.state=p)),d}_appendPlaceholder(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}appendTail(t){const n=new ge;return t&&n.aggregate(this._applyDispatch("",{},t)),n.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var n,o;return{...t,_beforeTailState:((n=t._beforeTailState)==null?void 0:n.currentMaskRef)===this.currentMask&&((o=t._beforeTailState)==null?void 0:o.currentMask)||t._beforeTailState}}doDispatch(t,n,o){return n===void 0&&(n={}),o===void 0&&(o=""),this.dispatch(t,this,n,o)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,n){n===void 0&&(n={});let[o,l]=super.doPrepare(t,n);if(this.currentMask){let a;[o,a]=super.doPrepare(o,this.currentMaskFlags(n)),l=l.aggregate(a)}return[o,l]}doPrepareChar(t,n){n===void 0&&(n={});let[o,l]=super.doPrepareChar(t,n);if(this.currentMask){let a;[o,a]=super.doPrepareChar(o,this.currentMaskFlags(n)),l=l.aggregate(a)}return[o,l]}reset(){var t;(t=this.currentMask)==null||t.reset(),this.compiledMasks.forEach(n=>n.reset())}get value(){return this.exposeMask?this.exposeMask.value:this.currentMask?this.currentMask.value:""}set value(t){this.exposeMask?(this.exposeMask.value=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.value=t}get unmaskedValue(){return this.exposeMask?this.exposeMask.unmaskedValue:this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){this.exposeMask?(this.exposeMask.unmaskedValue=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.unmaskedValue=t}get typedValue(){return this.exposeMask?this.exposeMask.typedValue:this.currentMask?this.currentMask.typedValue:""}set typedValue(t){if(this.exposeMask){this.exposeMask.typedValue=t,this.currentMask=this.exposeMask,this._applyDispatch();return}let n=String(t);this.currentMask&&(this.currentMask.typedValue=t,n=this.currentMask.unmaskedValue),this.unmaskedValue=n}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var t;return!!((t=this.currentMask)!=null&&t.isComplete)}get isFilled(){var t;return!!((t=this.currentMask)!=null&&t.isFilled)}remove(t,n){const o=new ge;return this.currentMask&&o.aggregate(this.currentMask.remove(t,n)).aggregate(this._applyDispatch()),o}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map(n=>n.state),currentMaskRef:this.currentMask,currentMask:(t=this.currentMask)==null?void 0:t.state}}set state(t){const{compiledMasks:n,currentMaskRef:o,currentMask:l,...a}=t;n&&this.compiledMasks.forEach((s,c)=>s.state=n[c]),o!=null&&(this.currentMask=o,this.currentMask.state=l),super.state=a}extractInput(t,n,o){return this.currentMask?this.currentMask.extractInput(t,n,o):""}extractTail(t,n){return this.currentMask?this.currentMask.extractTail(t,n):super.extractTail(t,n)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,n){return this.currentMask?this.currentMask.nearestInputPos(t,n):super.nearestInputPos(t,n)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(t){this._overwrite=t}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(t){this._eager=t}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(t){this._skipInvalid=t}get autofix(){return this.currentMask?this.currentMask.autofix:this._autofix}set autofix(t){this._autofix=t}maskEquals(t){return Array.isArray(t)?this.compiledMasks.every((n,o)=>{if(!t[o])return;const{mask:l,...a}=t[o];return dn(n,a)&&n.maskEquals(l)}):super.maskEquals(t)}typedValueEquals(t){var n;return!!((n=this.currentMask)!=null&&n.typedValueEquals(t))}}It.DEFAULTS={...Ne.DEFAULTS,dispatch:(r,t,n,o)=>{if(!t.compiledMasks.length)return;const l=t.rawInputValue,a=t.compiledMasks.map((s,c)=>{const i=t.currentMask===s,d=i?s.displayValue.length:s.nearestInputPos(s.displayValue.length,re.FORCE_LEFT);return s.rawInputValue!==l?(s.reset(),s.append(l,{raw:!0})):i||s.remove(d),s.append(r,t.currentMaskFlags(n)),s.appendTail(o),{index:c,weight:s.rawInputValue.length,totalInputPositions:s.totalInputPositions(0,Math.max(d,s.nearestInputPos(s.displayValue.length,re.FORCE_LEFT)))}});return a.sort((s,c)=>c.weight-s.weight||c.totalInputPositions-s.totalInputPositions),t.compiledMasks[a[0].index]}},ue.MaskedDynamic=It;class Rt extends Ae{constructor(t){super({...Rt.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){const{enum:n,...o}=t;if(n){const l=n.map(c=>c.length),a=Math.min(...l),s=Math.max(...l)-a;o.mask="*".repeat(a),s&&(o.mask+="["+"*".repeat(s)+"]"),this.enum=n}super._update(o)}_appendCharRaw(t,n){n===void 0&&(n={});const o=Math.min(this.nearestInputPos(0,re.FORCE_RIGHT),this.value.length),l=this.enum.filter(a=>this.matchValue(a,this.unmaskedValue+t,o));if(l.length){l.length===1&&this._forEachBlocksInRange(0,this.value.length,(s,c)=>{const i=l[0][c];c>=this.value.length||i===s.value||(s.reset(),s._appendChar(i,n))});const a=super._appendCharRaw(l[0][this.value.length],n);return l.length===1&&l[0].slice(this.unmaskedValue.length).split("").forEach(s=>a.aggregate(super._appendCharRaw(s))),a}return new ge({skip:!this.isComplete})}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new nt("",t)}remove(t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),t===n)return new ge;const o=Math.min(super.nearestInputPos(0,re.FORCE_RIGHT),this.value.length);let l;for(l=t;l>=0&&!(this.enum.filter(c=>this.matchValue(c,this.value.slice(o,l),o)).length>1);--l);const a=super.remove(l,n);return a.tailShift+=l-t,a}get isComplete(){return this.enum.indexOf(this.value)>=0}}Rt.DEFAULTS={...Ae.DEFAULTS,matchValue:(r,t,n)=>r.indexOf(t,n)===n},ue.MaskedEnum=Rt;class Yr extends Ne{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}ue.MaskedFunction=Yr;var Zr;class Re extends Ne{constructor(t){super({...Re.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){const t="^"+(this.allowNegative?"[+|\\-]?":""),n="\\d*",o=(this.scale?"("+zn(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+n+o),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(zn).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(zn(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const n=t.split(this.radix);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),n.join(this.radix)}doPrepareChar(t,n){n===void 0&&(n={});const[o,l]=super.doPrepareChar(this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(n.input&&n.raw||!n.input&&!n.raw)?t.replace(this._mapToRadixRegExp,this.radix):t),n);return t&&!o&&(l.skip=!0),o&&!this.allowPositive&&!this.value&&o!=="-"&&l.aggregate(this._appendChar("-")),[o,l]}_separatorsCount(t,n){n===void 0&&(n=!1);let o=0;for(let l=0;l<t;++l)this._value.indexOf(this.thousandsSeparator,l)===l&&(++o,n&&(t+=this.thousandsSeparator.length));return o}_separatorsCountFromSlice(t){return t===void 0&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,n,o){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n),this._removeThousandsSeparators(super.extractInput(t,n,o))}_appendCharRaw(t,n){n===void 0&&(n={});const o=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,l=this._separatorsCountFromSlice(o);this._value=this._removeThousandsSeparators(this.value);const a=this._value;this._value+=t;const s=this.number;let c=!isNaN(s),i=!1;if(c){let x;this.min!=null&&this.min<0&&this.number<this.min&&(x=this.min),this.max!=null&&this.max>0&&this.number>this.max&&(x=this.max),x!=null&&(this.autofix?(this._value=this.format(x,this).replace(Re.UNMASKED_RADIX,this.radix),i||(i=a===this._value&&!n.tail)):c=!1),c&&(c=!!this._value.match(this._numberRegExp))}let d;c?d=new ge({inserted:this._value.slice(a.length),rawInserted:i?"":t,skip:i}):(this._value=a,d=new ge),this._value=this._insertThousandsSeparators(this._value);const p=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,m=this._separatorsCountFromSlice(p);return d.tailShift+=(m-l)*this.thousandsSeparator.length,d}_findSeparatorAround(t){if(this.thousandsSeparator){const n=t-this.thousandsSeparator.length+1,o=this.value.indexOf(this.thousandsSeparator,n);if(o<=t)return o}return-1}_adjustRangeWithSeparators(t,n){const o=this._findSeparatorAround(t);o>=0&&(t=o);const l=this._findSeparatorAround(n);return l>=0&&(n=l+this.thousandsSeparator.length),[t,n]}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n);const o=this.value.slice(0,t),l=this.value.slice(n),a=this._separatorsCount(o.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(o+l));const s=this._separatorsCountFromSlice(o);return new ge({tailShift:(s-a)*this.thousandsSeparator.length})}nearestInputPos(t,n){if(!this.thousandsSeparator)return t;switch(n){case re.NONE:case re.LEFT:case re.FORCE_LEFT:{const o=this._findSeparatorAround(t-1);if(o>=0){const l=o+this.thousandsSeparator.length;if(t<l||this.value.length<=l||n===re.FORCE_LEFT)return o}break}case re.RIGHT:case re.FORCE_RIGHT:{const o=this._findSeparatorAround(t);if(o>=0)return o+this.thousandsSeparator.length}}return t}doCommit(){if(this.value){const t=this.number;let n=t;this.min!=null&&(n=Math.max(n,this.min)),this.max!=null&&(n=Math.min(n,this.max)),n!==t&&(this.unmaskedValue=this.format(n,this));let o=this.value;this.normalizeZeros&&(o=this._normalizeZeros(o)),this.padFractionalZeros&&this.scale>0&&(o=this._padFractionalZeros(o)),this._value=o}super.doCommit()}_normalizeZeros(t){const n=this._removeThousandsSeparators(t).split(this.radix);return n[0]=n[0].replace(/^(\D*)(0*)(\d*)/,(o,l,a,s)=>l+s),t.length&&!/\d$/.test(n[0])&&(n[0]=n[0]+"0"),n.length>1&&(n[1]=n[1].replace(/0*$/,""),n[1].length||(n.length=1)),this._insertThousandsSeparators(n.join(this.radix))}_padFractionalZeros(t){if(!t)return t;const n=t.split(this.radix);return n.length<2&&n.push(""),n[1]=n[1].padEnd(this.scale,"0"),n.join(this.radix)}doSkipInvalid(t,n,o){n===void 0&&(n={});const l=this.scale===0&&t!==this.thousandsSeparator&&(t===this.radix||t===Re.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,n,o)&&!l}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,Re.UNMASKED_RADIX)}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.parse(this.unmaskedValue,this)}set typedValue(t){this.rawInputValue=this.format(t,this).replace(Re.UNMASKED_RADIX,this.radix)}get number(){return this.typedValue}set number(t){this.typedValue=t}get allowNegative(){return this.min!=null&&this.min<0||this.max!=null&&this.max<0}get allowPositive(){return this.min!=null&&this.min>0||this.max!=null&&this.max>0}typedValueEquals(t){return(super.typedValueEquals(t)||Re.EMPTY_VALUES.includes(t)&&Re.EMPTY_VALUES.includes(this.typedValue))&&!(t===0&&this.value==="")}}Zr=Re,Re.UNMASKED_RADIX=".",Re.EMPTY_VALUES=[...Ne.EMPTY_VALUES,0],Re.DEFAULTS={...Ne.DEFAULTS,mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[Zr.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:r=>r.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},ue.MaskedNumber=Re;const fn={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function Un(r,t,n){t===void 0&&(t=fn.MASKED),n===void 0&&(n=fn.MASKED);const o=tt(r);return l=>o.runIsolated(a=>(a[t]=l,a[n]))}function Xr(r,t,n,o){return Un(t,n,o)(r)}ue.PIPE_TYPE=fn,ue.createPipe=Un,ue.pipe=Xr;class Jr extends Ae{get repeatFrom(){var t;return(t=Array.isArray(this.repeat)?this.repeat[0]:this.repeat===1/0?0:this.repeat)!=null?t:0}get repeatTo(){var t;return(t=Array.isArray(this.repeat)?this.repeat[1]:this.repeat)!=null?t:1/0}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){var n,o,l;const{repeat:a,...s}=Nt(t);this._blockOpts=Object.assign({},this._blockOpts,s);const c=tt(this._blockOpts);this.repeat=(n=(o=a??c.repeat)!=null?o:this.repeat)!=null?n:1/0,super._update({mask:"m".repeat(Math.max(this.repeatTo===1/0&&((l=this._blocks)==null?void 0:l.length)||0,this.repeatFrom)),blocks:{m:c},eager:c.eager,overwrite:c.overwrite,skipInvalid:c.skipInvalid,lazy:c.lazy,placeholderChar:c.placeholderChar,displayChar:c.displayChar})}_allocateBlock(t){if(t<this._blocks.length)return this._blocks[t];if(this.repeatTo===1/0||this._blocks.length<this.repeatTo)return this._blocks.push(tt(this._blockOpts)),this.mask+="m",this._blocks[this._blocks.length-1]}_appendCharRaw(t,n){n===void 0&&(n={});const o=new ge;for(let i=(l=(a=this._mapPosToBlock(this.displayValue.length))==null?void 0:a.index)!=null?l:Math.max(this._blocks.length-1,0),d,p;d=(s=this._blocks[i])!=null?s:p=!p&&this._allocateBlock(i);++i){var l,a,s,c;const m=d._appendChar(t,{...n,_beforeTailState:(c=n._beforeTailState)==null||(c=c._blocks)==null?void 0:c[i]});if(m.skip&&p){this._blocks.pop(),this.mask=this.mask.slice(1);break}if(o.aggregate(m),m.consumed)break}return o}_trimEmptyTail(t,n){var o,l;t===void 0&&(t=0);const a=Math.max(((o=this._mapPosToBlock(t))==null?void 0:o.index)||0,this.repeatFrom,0);let s;n!=null&&(s=(l=this._mapPosToBlock(n))==null?void 0:l.index),s==null&&(s=this._blocks.length-1);let c=0;for(let i=s;a<=i&&!this._blocks[i].unmaskedValue;--i,++c);c&&(this._blocks.splice(s-c+1,c),this.mask=this.mask.slice(c))}reset(){super.reset(),this._trimEmptyTail()}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const o=super.remove(t,n);return this._trimEmptyTail(t,n),o}totalInputPositions(t,n){return t===void 0&&(t=0),n==null&&this.repeatTo===1/0?1/0:super.totalInputPositions(t,n)}get state(){return super.state}set state(t){this._blocks.length=t._blocks.length,this.mask=this.mask.slice(0,this._blocks.length),super.state=t}}ue.RepeatBlock=Jr;try{globalThis.IMask=ue}catch{}const Hn=Object.freeze(Object.defineProperty({__proto__:null,ChangeDetails:ge,ChunksTailDetails:ft,DIRECTION:re,HTMLContenteditableMaskElement:Pn,HTMLInputMaskElement:Kr,HTMLMaskElement:Mt,InputMask:Gr,MaskElement:un,Masked:Ne,MaskedDate:rt,MaskedDynamic:It,MaskedEnum:Rt,MaskedFunction:Yr,MaskedNumber:Re,MaskedPattern:Ae,MaskedRange:Tt,MaskedRegExp:Wr,PIPE_TYPE:fn,PatternFixedDefinition:jn,PatternInputDefinition:Lt,RepeatBlock:Jr,createMask:tt,createPipe:Un,default:ue,forceDirection:Ur,normalizeOpts:Nt,pipe:Xr},Symbol.toStringTag,{value:"Module"})),Qp=async r=>{try{const t=new FormData;return t.append("unique","true"),t.append("file",r),(await(await fetch("/file/upload/uploads?id=&form=&table=",{method:"POST",body:t})).json())?.result}catch(t){console.error(t)}},ef=async(r,t,n)=>{const o=t.clipboardData?.items;if(o){const l=t.clipboardData?.getData("text/html"),a=t.clipboardData?.getData("text/plain");if(l){const{state:s,dispatch:c}=r,{tr:i}=s,d=n.fromSchema(r.state.schema),p=new DOMParser().parseFromString(l,"text/html").body,m=d.parse(p),x=i.replaceSelectionWith(m);return c(x),t.preventDefault(),!0}if(a){const{state:s,dispatch:c}=r,{tr:i}=s,d=i.insertText(a,s.selection.from,s.selection.to);return c(d),t.preventDefault(),!0}for(let s=0;s<o.length;s++){const c=o[s];if(c.type.startsWith("image/")){const i=c.getAsFile();if(i){const d=await Qp(i),{schema:p}=r.state,m=p.nodes.image.create({src:d?.file_path}),x=r.state.tr.replaceSelectionWith(m);return r.dispatch(x),t.preventDefault(),!0}}}}return!1},tf="https://esm.sh",je="3.7.2",Qr="3.7.2",nf=`?deps=@tiptap/core@${je},@tiptap/pm@${Qr}`,Ue=r=>`${tf}/${r}${nf}`,He={core:Ue(`@tiptap/core@${je}`),starterKit:Ue(`@tiptap/starter-kit@${je}`),textStyle:Ue(`@tiptap/extension-text-style@${je}`),table:Ue(`@tiptap/extension-table@${je}`),highlight:Ue(`@tiptap/extension-highlight@${je}`),subscript:Ue(`@tiptap/extension-subscript@${je}`),superscript:Ue(`@tiptap/extension-superscript@${je}`),link:Ue(`@tiptap/extension-link@${je}`),image:Ue(`@tiptap/extension-image@${je}`),textAlign:Ue(`@tiptap/extension-text-align@${je}`),heading:Ue(`@tiptap/extension-heading@${je}`),paragraph:Ue(`@tiptap/extension-paragraph@${je}`),pmModel:Ue(`@tiptap/pm@${Qr}/model`)},Ot="__vs_form_tiptap_loader__",qe=r=>import(r),Se=(r,t)=>r?.[t]||r?.default?.[t]||r?.default?.default?.[t]||r?.default||r,eo={1:"font-weight:700; font-size:30px;",2:"font-weight:700; font-size:26px;",3:"font-weight:700; font-size:22px;",4:"font-weight:700; font-size:18px;",5:"font-weight:500; font-size:16px;",6:"font-weight:400; font-size:14px;"},rf=r=>r.extend({addOptions(){return{...this.parent?.(),levels:[1,2,3,4,5,6]}}}).extend({addAttributes(){return{...this.parent?.(),level:{default:1,renderHTML:t=>{const n=t.level||1;return{class:`heading-level-${n}`,style:eo[n]||eo[1]}}}}}}),of=r=>r.configure({HTMLAttributes:{style:"min-height: 1rem;"}}),lf=(r,t,n,o,l)=>{const a=t.extend({renderHTML({HTMLAttributes:s}){return["div",{style:"overflow-x: auto;"},["table",s,0]]},parseHTML(){return[{tag:"div.table-wrapper table",priority:100},{tag:"table"}]}});return r.extend({addExtensions(){return[a.configure({HTMLAttributes:{class:"editor-content"},resizable:!0}),n,o,l]}})},af=r=>r.extend({addAttributes(){return{...this.parent?.(),fontFamily:{default:null,parseHTML:t=>t.style.fontFamily?.replace(/['"]/g,""),renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}},fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}},color:{default:null,parseHTML:t=>t.style.color?.replace(/['"]/g,""),renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}},backgroundColor:{default:null,parseHTML:t=>t.style.backgroundColor?.replace(/['"]/g,""),renderHTML:t=>!t.backgroundColor||t.backgroundColor==="transparent"?{}:{style:`background-color: ${t.backgroundColor}`}}}},addCommands(){return{setFontFamily:t=>({chain:n})=>n().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run(),setFontSize:t=>({chain:n})=>n().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run(),setColor:t=>({chain:n})=>n().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run(),setBackgroundColor:t=>({chain:n})=>n().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),sf=r=>r.create({name:"iframe",group:"block",inline:!1,atom:!0,selectable:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"280"},frameborder:{default:"0"},allow:{default:null},allowfullscreen:{default:null},referrerpolicy:{default:null},loading:{default:null},class:{default:null},title:{default:null},style:{default:null}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",t]}});async function cf(){if(typeof window>"u")return null;const r=window;return r[Ot]||(r[Ot]=Promise.all([qe(He.core),qe(He.starterKit),qe(He.textStyle),qe(He.table),qe(He.highlight),qe(He.subscript),qe(He.superscript),qe(He.link),qe(He.image),qe(He.textAlign),qe(He.heading),qe(He.paragraph),qe(He.pmModel)]).then(([t,n,o,l,a,s,c,i,d,p,m,x,f])=>{const u=Se(t,"Editor"),h=Se(t,"Node"),g=Se(t,"Extension"),C=Se(n,"StarterKit"),w=Se(o,"TextStyle"),b=Se(l,"TableKit"),k=Se(l,"Table"),B=Se(l,"TableRow"),M=Se(l,"TableCell"),$=Se(l,"TableHeader"),E=Se(a,"Highlight"),N=Se(s,"Subscript"),v=Se(c,"Superscript"),S=Se(i,"Link"),D=Se(d,"Image"),I=Se(p,"TextAlign"),A=Se(m,"Heading"),T=Se(x,"Paragraph"),L=Se(f,"DOMParser");if(!u||!h||!C||!w||!b||!k||!B||!M||!$||!E||!N||!v||!S||!D||!I||!A||!T||!L)throw new Error("Failed to resolve one or more Tiptap modules");return{Editor:u,Extension:g,ProseMirrorDOMParser:L,StarterKit:C,ExtendedTextStyle:af(w),Highlight:E,Subscript:N,Superscript:v,Link:S,Image:D,TextAlign:I,CustomHeading:rf(A),CustomParagraph:of(T),CustomTableKit:lf(b,k,B,M,$),Iframe:sf(h)}}).catch(t=>{throw delete r[Ot],t})),r[Ot]}function df(r){let t=!1;const n=e.shallowRef(null),o=e.ref(!1),l=e.ref(""),a=async(d,p="")=>{if(!d)return null;o.value=!0,l.value="";try{const m=await cf();if(!m)return null;const x=new m.Editor({element:d,content:p,extensions:[m.StarterKit.configure({history:{depth:100,newGroupDelay:500},code:{HTMLAttributes:{class:"editor-code"}},codeBlock:{HTMLAttributes:{class:"editor-codeblock"}},paragraph:!1,heading:!1,link:!1}),m.Superscript,m.Subscript,m.ExtendedTextStyle,m.CustomParagraph,m.CustomHeading,m.Highlight,m.Image.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"editor-image"}}),m.TextAlign.configure({types:["heading","paragraph"]}),m.Link.configure({HTMLAttributes:{class:"editor-link"},openOnClick:!1,autolink:!0}),m.CustomTableKit,m.Iframe],editorProps:{handlePaste:(f,u)=>ef(f,u,m.ProseMirrorDOMParser),handleKeyDown:(f,u)=>{if(u.key==="Tab"){const h=f.state,{$anchor:g}=h.selection;let C=!1;for(let w=g.depth;w>0;w--){const b=g.node(w);if(b&&(b.type.name==="bulletList"||b.type.name==="orderedList")){C=!0;break}}return C?!1:(u.preventDefault(),!0)}return!1}}});return n.value=e.markRaw(x),x}catch(m){return l.value="Failed to load rich text editor dependencies.",console.error("Failed to initialize rich text editor",m),null}finally{o.value=!1}},s=e.computed(()=>n.value||null);return e.watch(n,d=>{d&&n.value.on("update",p=>{if(!t){t=!0;const m=p.editor.getHTML();r.modelValue,setTimeout(()=>{t=!1},10)}})}),{editor:n,editorInstance:s,focusEditor:()=>{n.value&&!n.value.isFocused&&n.value.commands.focus()},createEditor:a,destroyEditor:()=>{n.value&&(n.value.destroy(),n.value=null)},isLoading:o,loadError:l}}function uf(r,t,n,{toEditorContent:o,toSourceContent:l}={}){const a=e.ref(!1),s=e.ref(""),c=e.ref(null);return{isHtmlMode:a,htmlContent:s,htmlTextarea:c,toggleHtmlMode:async p=>{if(a.value=p,p)r.value&&(s.value=l?await l(r.value.getHTML(),t):r.value.getHTML()),e.nextTick(()=>{c.value&&c.value.focus?.()});else if(r.value){const m=o?await o(s.value,t):s.value;r.value.commands.setContent(m,!0),e.nextTick(()=>{r.value?.commands?.focus?.()})}},onHtmlInput:p=>{s.value=p,n&&n("update:modelValue",p)}}}function pf(){const r=e.ref(!1);return{isFullscreen:r,toggleFullscreen:()=>{r.value=!r.value}}}const mt=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),zt=r=>{let t=mt(r||"");return t=t.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,o,l,a)=>{const s=a?` title="${mt(a)}"`:"";return`<img src="${mt(l)}" alt="${mt(o)}"${s}>`}),t=t.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,o,l,a)=>{const s=a?` title="${mt(a)}"`:"";return`<a href="${mt(l)}"${s} target="_blank" rel="noopener noreferrer">${o}</a>`}),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^_]+)__/g,"<strong>$1</strong>"),t=t.replace(/~~([^~]+)~~/g,"<del>$1</del>"),t=t.replace(/\*([^*\n]+)\*/g,"<em>$1</em>"),t=t.replace(/_([^_\n]+)_/g,"<em>$1</em>"),t},Pt=r=>/^\s*\d+\.\s+/.test(r),qn=r=>/^\s*[-*+]\s+/.test(r),to=r=>/^\s*[-*+]\s+\[[ xX]\]\s+/.test(r),Kn=r=>/^\s*>\s?/.test(r),Gn=r=>/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(r),no=r=>r.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>zt(t.trim())),ff=(r,t)=>{const n=r[t],o=r[t+1];if(!n||!o||!n.includes("|")||!Gn(o))return null;const l=no(n),a=[];let s=t+2;for(;s<r.length&&r[s].includes("|")&&r[s].trim()!=="";){const d=no(r[s]);a.push(`<tr>${d.map(p=>`<td>${p}</td>`).join("")}</tr>`),s+=1}const c=`<thead><tr>${l.map(d=>`<th>${d}</th>`).join("")}</tr></thead>`,i=a.length?`<tbody>${a.join("")}</tbody>`:"";return{html:`<table>${c}${i}</table>`,nextIndex:s}},mf=(r,t)=>{const n=Pt(r[t]),o=n?"ol":"ul",l=[];let a=t;for(;a<r.length;){const s=r[a];if(s.trim()===""||!(n?Pt(s):(qn(s)||to(s))&&!Pt(s)))break;const i=s.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);if(i){const d=i[1].toLowerCase()==="x";l.push(`<li><input type="checkbox" disabled${d?" checked":""}> ${zt(i[2])}</li>`)}else{const d=s.replace(/^\s*(?:[-*+]|\d+\.)\s+/,"");l.push(`<li>${zt(d)}</li>`)}a+=1}return{html:`<${o}>${l.join("")}</${o}>`,nextIndex:a}},hf=(r,t)=>{const o=r[t].replace(/^```/,"").trim(),l=[];let a=t+1;for(;a<r.length&&!r[a].startsWith("```");)l.push(r[a]),a+=1;return{html:`<pre><code${o?` class="language-${mt(o)}"`:""}>${mt(l.join(`
|
|
6
6
|
`))}</code></pre>`,nextIndex:a<r.length?a+1:a}},gf=(r,t)=>{const n=[];let o=t;for(;o<r.length;){const l=r[o];if(l.trim()===""||l.startsWith("```")||/^#{1,6}\s+/.test(l)||/^---+$/.test(l.trim())||/^\*\*\*+$/.test(l.trim())||Kn(l)||Pt(l)||qn(l)||o+1<r.length&&l.includes("|")&&Gn(r[o+1]))break;n.push(l.trim()),o+=1}return{html:`<p>${zt(n.join(" "))}</p>`,nextIndex:o}},ro=r=>{const n=(r||"").replace(/\r\n/g,`
|
|
7
7
|
`).split(`
|