Files
OpenGFW/web/dist/assets/RulesView-hVmwxU6M.js
T
2026-07-27 10:45:47 +08:00

47 lines
80 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{c as he,B as pe,m as A,g as F,u as t,C as It,d as U,x as Ke,o as m,h as B,D as ae,a as S,j as G,F as ee,r as de,E as we,G as xe,w as h,H as J,P as te,I as Me,J as jt,K as Gt,p as v,L as me,M as Ae,N as Xt,O as ge,Q as rt,R as re,S as St,U as Et,i as Jt,k as H,V as Bt,t as $,W as Yt,X as Qt,n as Zt,Y as ea,e as fe,f as ve,Z as At,$ as ye,b as O,l as _,a0 as ta,s as oe,y as tt,a1 as Ee,a2 as aa,a3 as mt,_ as la,a4 as Be,z as Je}from"./index-DIqASLVQ.js";import{_ as na}from"./PageHeader.vue_vue_type_script_setup_true_lang-CD1KTXEu.js";import{u as Fe,a as De,b as st,c as be,d as Ge,g as oa}from"./Collection-CwtwoTtI.js";import{i as He,V as ra,u as sa,a as it,h as ia,P as ua,b as da,c as ca,d as pa,e as fa,f as va,F as ma,D as ha,g as ga,j as ya,k as Ft,T as ba,l as _a,C as xa,_ as je}from"./Select.vue_vue_type_script_setup_true_lang-CzaVl8rJ.js";import{g as Ca,i as ka,m as wa,c as qa,_ as Ye,a as ht,b as Ue}from"./TabsTrigger.vue_vue_type_script_setup_true_lang-RkMkvDd1.js";import{S as Va,T as Ot,_ as gt}from"./Modal.vue_vue_type_script_setup_true_lang-DNsJ6686.js";import{_ as Te}from"./Badge.vue_vue_type_script_setup_true_lang-DSNeqlXx.js";/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $a=he("ArrowDownIcon",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ia=he("ArrowUpIcon",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Sa=he("ChevronsUpDownIcon",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yt=he("FileCode2Icon",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ea=he("PencilIcon",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Tt=he("PlusIcon",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ba=he("RotateCcwIcon",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Aa=he("SaveIcon",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
* @license lucide-vue-next v0.469.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Fa=he("WandSparklesIcon",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);function Oa(n,a,e){const o=n.findIndex(s=>He(s,a)),l=n.findIndex(s=>He(s,e));if(o===-1||l===-1)return[];const[r,i]=[o,l].sort((s,u)=>s-u);return n.slice(r,i+1)}const Ta=["INPUT","TEXTAREA"];function Ra(n,a,e,o={}){if(!a||o.enableIgnoredElement&&Ta.includes(a.nodeName))return null;const{arrowKeyOptions:l="both",attributeName:r="[data-reka-collection-item]",itemsArray:i=[],loop:s=!0,dir:u="ltr",preventScroll:x=!0,focus:d=!1}=o,[C,I,k,y,f,g]=[n.key==="ArrowRight",n.key==="ArrowLeft",n.key==="ArrowUp",n.key==="ArrowDown",n.key==="Home",n.key==="End"],p=k||y,q=C||I;if(!f&&!g&&(!p&&!q||l==="vertical"&&q||l==="horizontal"&&p))return null;const E=i;if(!E.length)return null;x&&n.preventDefault();let V=null;return q||p?V=Rt(E,a,{goForward:p?y:u==="ltr"?C:I,loop:s}):f?V=E.at(0)||null:g&&(V=E.at(-1)||null),d&&(V==null||V.focus()),V}function Rt(n,a,e,o=n.includes(a)?n.length:n.length+1){if(--o===0)return null;const l=n.indexOf(a);let r;if(l===-1?r=e.goForward?0:n.length-1:r=e.goForward?l+1:l-1,!e.loop&&(r<0||r>=n.length))return null;const i=(r+n.length)%n.length,s=n[i];return s?s.hasAttribute("disabled")&&s.getAttribute("disabled")!=="false"?Rt(n,s,e,o):s:null}function ut(n){const a=A(!1);function e(){a.value=!0}function o(l){pe(()=>{a.value=!1,n==null||n(l)})}return{isComposing:a,handleCompositionStart:e,handleCompositionEnd:o}}function za(n){const a=F(()=>t(n)),e=F(()=>new Intl.Collator("en",{usage:"search",...a.value}));return{startsWith:(i,s)=>s.length===0?!0:(i=i.normalize("NFC"),s=s.normalize("NFC"),e.value.compare(i.slice(0,s.length),s)===0),endsWith:(i,s)=>s.length===0?!0:(i=i.normalize("NFC"),s=s.normalize("NFC"),e.value.compare(i.slice(-s.length),s)===0),contains:(i,s)=>{if(s.length===0)return!0;i=i.normalize("NFC"),s=s.normalize("NFC");let u=0;const x=s.length;for(;u+x<=i.length;u++){const d=i.slice(u,u+x);if(e.value.compare(s,d)===0)return!0}return!1}}}function Pa(){var a,e;const n=(e=(a=It())==null?void 0:a.vnode)==null?void 0:e.scopeId;return n?{[n]:""}:{}}function Da(){return{ALT:"Alt",ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",BACKSPACE:"Backspace",CAPS_LOCK:"CapsLock",CONTROL:"Control",DELETE:"Delete",END:"End",ENTER:"Enter",ESCAPE:"Escape",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",HOME:"Home",META:"Meta",PAGE_DOWN:"PageDown",PAGE_UP:"PageUp",SHIFT:"Shift",SPACE:" ",TAB:"Tab",CTRL:"Control",ASTERISK:"*",SPACE_CODE:"Space"}}var La=U({inheritAttrs:!1,__name:"VisuallyHiddenInputBubble",props:{name:{type:String,required:!0},value:{type:null,required:!0},checked:{type:Boolean,required:!1,default:void 0},required:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},feature:{type:String,required:!1,default:"fully-hidden"}},setup(n){const a=n,{primitiveElement:e,currentElement:o}=Fe(),l=F(()=>a.checked??a.value);return Ke(l,(r,i)=>{if(!o.value)return;const s=o.value,u=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(u,"value").set;if(d&&r!==i){const C=new Event("input",{bubbles:!0}),I=new Event("change",{bubbles:!0});d.call(s,r),s.dispatchEvent(C),s.dispatchEvent(I)}}),(r,i)=>(m(),B(ra,ae({ref_key:"primitiveElement",ref:e},{...a,...r.$attrs},{as:"input"}),null,16))}}),bt=La,Na=U({inheritAttrs:!1,__name:"VisuallyHiddenInput",props:{name:{type:String,required:!0},value:{type:null,required:!0},checked:{type:Boolean,required:!1,default:void 0},required:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},feature:{type:String,required:!1,default:"fully-hidden"}},setup(n){const a=n,e=F(()=>typeof a.value=="object"&&Array.isArray(a.value)&&a.value.length===0&&a.required),o=F(()=>typeof a.value=="string"||typeof a.value=="number"||typeof a.value=="boolean"||a.value===null||a.value===void 0?[{name:a.name,value:a.value}]:typeof a.value=="object"&&Array.isArray(a.value)?a.value.flatMap((l,r)=>typeof l=="object"?Object.entries(l).map(([i,s])=>({name:`${a.name}[${r}][${i}]`,value:s})):{name:`${a.name}[${r}]`,value:l}):a.value!==null&&typeof a.value=="object"&&!Array.isArray(a.value)?Object.entries(a.value).map(([l,r])=>({name:`${a.name}[${l}]`,value:r})):[]);return(l,r)=>(m(),S(ee,null,[G(" We render single input if it's required "),e.value?(m(),B(bt,ae({key:l.name},{...a,...l.$attrs},{name:l.name,value:l.value}),null,16,["name","value"])):(m(!0),S(ee,{key:1},de(o.value,i=>(m(),B(bt,ae({key:i.name},{ref_for:!0},{...a,...l.$attrs},{name:i.name,value:i.value}),null,16,["name","value"]))),128))],2112))}}),dt=Na;function Ua(n,a,e){return n===void 0?!1:Array.isArray(n)?n.some(o=>ze(o,a,e)):ze(n,a,e)}function ze(n,a,e){return n===void 0||a===void 0?!1:typeof n=="string"?n===a:typeof e=="function"?e(n,a):typeof e=="string"?(n==null?void 0:n[e])===(a==null?void 0:a[e]):He(n,a)}const[Xe,Ma]=be("ListboxRoot");var Wa=U({__name:"ListboxRoot",props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},orientation:{type:String,required:!1,default:"vertical"},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},selectionBehavior:{type:String,required:!1,default:"toggle"},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","entryFocus","leave"],setup(n,{expose:a,emit:e}){const o=n,l=e,{multiple:r,highlightOnHover:i,orientation:s,disabled:u,selectionBehavior:x,dir:d}=we(o),{getItems:C}=De({isProvider:!0}),{handleTypeaheadSearch:I}=sa(),{primitiveElement:k,currentElement:y}=Fe(),f=Da(),g=st(d),p=it(y),q=A(),E=A(!1),V=A(!0),P=xe(o,"modelValue",l,{defaultValue:o.defaultValue??(r.value?[]:void 0),passive:o.modelValue===void 0,deep:!0});function ue(w){if(E.value=!0,o.multiple){const z=Array.isArray(P.value)?[...P.value]:[],D=z.findIndex(Z=>ze(Z,w,o.by));o.selectionBehavior==="toggle"?(D===-1?z.push(w):z.splice(D,1),P.value=z):(P.value=[w],q.value=w)}else o.selectionBehavior==="toggle"&&ze(P.value,w,o.by)?P.value=void 0:P.value=w;setTimeout(()=>{E.value=!1},1)}const j=A(null),T=A(null),M=A(!1),X=A(!1),Y=Me(),W=Me(),ne=Me();function le(){return C().map(w=>w.ref).filter(w=>w.dataset.disabled!=="")}function K(w,z=!0,D){if(!w)return;j.value=w,(D??V.value)&&j.value.focus(),z&&j.value.scrollIntoView({block:"nearest"});const Z=C().find(ie=>ie.ref===w);l("highlight",Z)}function Ve(w){if(M.value)ne.trigger(w);else{const z=C().find(D=>ze(D.value,w,o.by));z&&(j.value=z.ref,K(z.ref))}}function $e(w){if(j.value&&j.value.isConnected){if(w.ctrlKey||w.metaKey||w.altKey)return;w.preventDefault(),w.stopPropagation(),X.value||j.value.click()}}function Ie(w){if(V.value){if(E.value=!0,M.value)W.trigger(w);else{const z=w.altKey||w.ctrlKey||w.metaKey;if(z&&w.key==="a"&&r.value){const D=C(),Z=D.map(Se=>Se.value);P.value=[...Z],w.preventDefault();const ie=D.at(-1);ie&&K(ie.ref)}else if(!z){const D=I(w.key,C());D&&K(D)}}setTimeout(()=>{E.value=!1},1)}}function c(){X.value=!0}function b(){pe(()=>{X.value=!1})}function L(){pe(()=>{const w=new KeyboardEvent("keydown",{key:"PageUp"});Q(w)})}function R(w){const z=j.value;z!=null&&z.isConnected&&(T.value=z),j.value=null,l("leave",w)}function N(w){var D,Z;const z=new CustomEvent("listbox.entryFocus",{bubbles:!1,cancelable:!0});if((D=w.currentTarget)==null||D.dispatchEvent(z),l("entryFocus",z),!z.defaultPrevented)if(T.value)K(T.value);else{const ie=(Z=le())==null?void 0:Z[0];K(ie)}}function Q(w){const z=Ca(w,s.value,g.value);if(!z)return;let D=le();if(j.value){if(z==="last")D.reverse();else if(z==="prev"||z==="next"){z==="prev"&&D.reverse();const Z=D.indexOf(j.value);D=D.slice(Z+1)}ce(w,D[0])}if(D.length){const Z=!j.value&&z==="prev"?D.length-1:0;K(D[Z])}if(M.value)return W.trigger(w)}function ce(w,z){var Z,ie,Se;if(!(M.value||o.selectionBehavior!=="replace"||!r.value||!Array.isArray(P.value)||(w.altKey||w.ctrlKey||w.metaKey)&&!w.shiftKey)&&w.shiftKey){const Le=C().filter(Oe=>Oe.ref.dataset.disabled!=="");let Ne=(Z=Le.find(Oe=>Oe.ref===z))==null?void 0:Z.value;if(w.key===f.END?Ne=(ie=Le.at(-1))==null?void 0:ie.value:w.key===f.HOME&&(Ne=(Se=Le[0])==null?void 0:Se.value),!Ne||!q.value)return;const Ht=Oa(Le.map(Oe=>Oe.value),q.value,Ne);P.value=Ht}}async function ft(w,z=!0){if(jt)if(await pe(),M.value)Y.trigger({event:w,scroll:z});else{const D=le(),Z=D.find(Se=>Se.dataset.state==="checked"),ie=z?void 0:!1;Z?K(Z,z,ie):D.length&&K(D[0],z,ie)}}let vt=!1;return Ke(P,()=>{if(!E.value){const w=vt;vt=!0,pe(()=>{ft(void 0,w)})}},{immediate:!0,deep:!0}),a({highlightedElement:j,highlightItem:Ve,highlightFirstItem:L,highlightSelected:ft,getItems:C}),Ma({modelValue:P,onValueChange:ue,multiple:r,orientation:s,dir:g,disabled:u,highlightOnHover:i,highlightedElement:j,isVirtual:M,virtualFocusHook:Y,virtualKeydownHook:W,virtualHighlightHook:ne,by:o.by,firstValue:q,selectionBehavior:x,focusable:V,onLeave:R,onEnter:N,changeHighlight:K,onKeydownEnter:$e,onKeydownNavigation:Q,onKeydownTypeAhead:Ie,onCompositionStart:c,onCompositionEnd:b,highlightFirstItem:L}),(w,z)=>(m(),B(t(te),{ref_key:"primitiveElement",ref:k,as:w.as,"as-child":w.asChild,dir:t(g),"data-disabled":t(u)?"":void 0,onPointerleave:R,onFocusout:z[0]||(z[0]=async D=>{const Z=D.relatedTarget||D.target;await pe(),j.value&&t(y)&&!t(y).contains(Z)&&R(D)})},{default:h(()=>[J(w.$slots,"default",{modelValue:t(P)}),t(p)&&w.name?(m(),B(t(dt),{key:0,name:w.name,value:t(P),disabled:t(u),required:w.required},null,8,["name","value","disabled","required"])):G("v-if",!0)]),_:3},8,["as","as-child","dir","data-disabled"]))}}),Ka=Wa,Ha=U({__name:"ListboxContent",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(n){const{CollectionSlot:a}=De(),e=Xe(),o=Gt(!1,10);return(l,r)=>(m(),B(t(a),null,{default:h(()=>[v(t(te),{role:"listbox",as:l.as,"as-child":l.asChild,tabindex:t(e).focusable.value?t(e).highlightedElement.value?"-1":"0":"-1","aria-orientation":t(e).orientation.value,"aria-multiselectable":!!t(e).multiple.value,"data-orientation":t(e).orientation.value,onMousedown:r[0]||(r[0]=Ae(i=>o.value=!0,["left"])),onFocus:r[1]||(r[1]=i=>{t(o)||t(e).onEnter(i)}),onKeydown:[r[2]||(r[2]=me(i=>{t(e).orientation.value==="vertical"&&(i.key==="ArrowLeft"||i.key==="ArrowRight")||t(e).orientation.value==="horizontal"&&(i.key==="ArrowUp"||i.key==="ArrowDown")||(i.preventDefault(),t(e).focusable.value&&t(e).onKeydownNavigation(i))},["down","up","left","right","home","end"])),me(t(e).onKeydownEnter,["enter"]),t(e).onKeydownTypeAhead]},{default:h(()=>[J(l.$slots,"default")]),_:3},8,["as","as-child","tabindex","aria-orientation","aria-multiselectable","data-orientation","onKeydown"])]),_:3}))}}),ja=Ha,Ga=U({__name:"ListboxFilter",props:{modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,l=xe(e,"modelValue",a,{defaultValue:"",passive:e.modelValue===void 0}),r=Xe(),{primitiveElement:i,currentElement:s}=Fe(),u=F(()=>e.disabled||r.disabled.value||!1),x=A();Xt(()=>{var p;return x.value=(p=r.highlightedElement.value)==null?void 0:p.id}),ge(()=>{r.focusable.value=!1,setTimeout(()=>{var p;e.autoFocus&&((p=s.value)==null||p.focus())},1)}),rt(()=>{r.focusable.value=!0});const{isComposing:d,handleCompositionStart:C,handleCompositionEnd:I}=ut(p=>{l.value=p.target.value,r.onCompositionEnd(),r.highlightFirstItem()});function k(){r.onCompositionStart(),C()}function y(p){d.value||(l.value=p.target.value,r.highlightFirstItem())}function f(p){d.value||(p.preventDefault(),r.onKeydownNavigation(p))}function g(p){d.value||r.onKeydownEnter(p)}return(p,q)=>(m(),B(t(te),{ref_key:"primitiveElement",ref:i,as:p.as,"as-child":p.asChild,value:t(l),disabled:u.value?"":void 0,"data-disabled":u.value?"":void 0,"aria-disabled":u.value??void 0,"aria-activedescendant":x.value,type:"text",onKeydown:[me(f,["down","up","home","end"]),me(g,["enter"])],onInput:y,onCompositionstart:k,onCompositionend:t(I)},{default:h(()=>[J(p.$slots,"default",{modelValue:t(l)})]),_:3},8,["as","as-child","value","disabled","data-disabled","aria-disabled","aria-activedescendant","onCompositionend"]))}}),Xa=Ga;const Ja="listbox.select",[Io,Ya]=be("ListboxItem");var Qa=U({__name:"ListboxItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},emits:["select"],setup(n,{emit:a}){const e=n,o=a,l=Ge(void 0,"reka-listbox-item"),{CollectionItem:r}=De(),{forwardRef:i,currentElement:s}=re(),u=Xe(),x=F(()=>s.value!=null&&s.value===u.highlightedElement.value),d=F(()=>Ua(u.modelValue.value,e.value,u.by)),C=F(()=>u.disabled.value||e.disabled);async function I(y){o("select",y),!(y!=null&&y.defaultPrevented)&&!C.value&&y&&(u.onValueChange(e.value),u.changeHighlight(s.value))}function k(y){const f={originalEvent:y,value:e.value};ia(Ja,I,f)}return Ya({isSelected:d}),(y,f)=>(m(),B(t(r),{value:y.value},{default:h(()=>[St([x.value,d.value,C.value,t(u).focusable.value],()=>v(t(te),ae({id:t(l)},y.$attrs,{ref:t(i),role:"option",tabindex:t(u).focusable.value?x.value?"0":"-1":-1,"aria-selected":d.value,as:y.as,"as-child":y.asChild,disabled:C.value?"":void 0,"data-disabled":C.value?"":void 0,"data-highlighted":x.value?"":void 0,"data-state":d.value?"checked":"unchecked",onClick:k,onKeydown:me(Ae(k,["prevent"]),["space"]),onPointermove:f[0]||(f[0]=()=>{t(u).highlightedElement.value!==t(s)&&t(u).highlightOnHover.value&&t(u).changeHighlight(t(s),!1,!1)})}),{default:h(()=>[J(y.$slots,"default")]),_:3},16,["id","tabindex","aria-selected","as","as-child","disabled","data-disabled","data-highlighted","data-state","onKeydown"]),f,1)]),_:3},8,["value"]))}}),Za=Qa;const[qe,el]=be("ComboboxRoot");var tl=U({__name:"ComboboxRoot",props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},openOnFocus:{type:Boolean,required:!1,default:!1},openOnClick:{type:Boolean,required:!1,default:!1},ignoreFilter:{type:Boolean,required:!1},resetModelValueOnClear:{type:Boolean,required:!1,default:!1},modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},highlightOnHover:{type:Boolean,required:!1,default:!0},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","update:open"],setup(n,{expose:a,emit:e}){var Ve,$e,Ie;const o=n,l=e,{primitiveElement:r,currentElement:i}=Fe(),{multiple:s,disabled:u,ignoreFilter:x,resetSearchTermOnSelect:d,openOnFocus:C,openOnClick:I,dir:k,resetModelValueOnClear:y,highlightOnHover:f}=we(o),g=st(k),p=xe(o,"modelValue",l,{defaultValue:o.defaultValue??(s.value?[]:void 0),passive:o.modelValue===void 0,deep:!0}),q=xe(o,"open",l,{defaultValue:o.defaultOpen,passive:o.open===void 0});async function E(c){var b,L;q.value=c,ne.value="",c?(await pe(),(b=r.value)==null||b.highlightSelected(),P.value=!0,(L=j.value)==null||L.focus()):(P.value=!1,setTimeout(()=>{!c&&o.resetSearchTermOnBlur&&V.trigger()},1))}const V=Me(),P=A(!1),ue=A(!1),j=A(),T=A(),M=F(()=>{var c;return((c=r.value)==null?void 0:c.highlightedElement)??void 0}),X=A(new Map),Y=A(new Map),{contains:W}=za({sensitivity:"base"}),ne=A(""),le=F(c=>{if(!ne.value||o.ignoreFilter||ue.value)return{count:X.value.size,items:(c==null?void 0:c.items)??new Map,groups:(c==null?void 0:c.groups)??new Set(Y.value.keys())};let b=0;const L=new Map,R=new Set;for(const[N,Q]of X.value){const ce=W(Q,ne.value);L.set(N,ce?1:0),ce&&b++}for(const[N,Q]of Y.value)for(const ce of Q)if(L.get(ce)>0){R.add(N);break}return{count:b,items:L,groups:R}}),K=It();return ge(()=>{var c,b,L;K!=null&&K.exposed&&(K.exposed.highlightItem=(c=r.value)==null?void 0:c.highlightItem,K.exposed.highlightFirstItem=(b=r.value)==null?void 0:b.highlightFirstItem,K.exposed.highlightSelected=(L=r.value)==null?void 0:L.highlightSelected)}),a({filtered:le,highlightedElement:M,highlightItem:(Ve=r.value)==null?void 0:Ve.highlightItem,highlightFirstItem:($e=r.value)==null?void 0:$e.highlightFirstItem,highlightSelected:(Ie=r.value)==null?void 0:Ie.highlightSelected}),el({modelValue:p,multiple:s,disabled:u,open:q,onOpenChange:E,contentId:"",isUserInputted:P,isVirtual:ue,inputElement:j,highlightedElement:M,onInputElementChange:c=>j.value=c,triggerElement:T,onTriggerElementChange:c=>T.value=c,parentElement:i,resetSearchTermOnSelect:d,onResetSearchTerm:V.on,allItems:X,allGroups:Y,filterSearch:ne,filterState:le,ignoreFilter:x,openOnFocus:C,openOnClick:I,resetModelValueOnClear:y}),(c,b)=>(m(),B(t(ua),null,{default:h(()=>[v(t(Ka),ae({ref_key:"primitiveElement",ref:r},c.$attrs,{modelValue:t(p),"onUpdate:modelValue":b[0]||(b[0]=L=>Et(p)?p.value=L:null),style:{pointerEvents:t(q)?"auto":void 0},as:c.as,"as-child":c.asChild,dir:t(g),multiple:t(s),name:c.name,required:c.required,disabled:t(u),"highlight-on-hover":t(f),by:o.by,onHighlight:b[1]||(b[1]=L=>l("highlight",L))}),{default:h(()=>[J(c.$slots,"default",{open:t(q),modelValue:t(p)})]),_:3},16,["modelValue","style","as","as-child","dir","multiple","name","required","disabled","highlight-on-hover","by"])]),_:3}))}}),al=tl,ll=U({__name:"ComboboxAnchor",props:{reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(n){const{forwardRef:a}=re();return(e,o)=>(m(),B(t(da),{"as-child":"",reference:e.reference},{default:h(()=>[v(t(te),ae({ref:t(a),"as-child":e.asChild,as:e.as},e.$attrs),{default:h(()=>[J(e.$slots,"default")]),_:3},16,["as-child","as"])]),_:3},8,["reference"]))}}),nl=ll;const[So,ol]=be("ComboboxContent");var rl=U({__name:"ComboboxContentImpl",props:{position:{type:String,required:!1,default:"inline"},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},memoDependencies:{type:Array,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},dir:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(n,{emit:a}){const e=n,o=a,{position:l}=we(e),r=qe(),i=F(()=>r.ignoreFilter.value?r.allItems.value.size===0:r.filterState.value.count===0),{forwardRef:s,currentElement:u}=re();ca(e.bodyLock),pa(),fa(r.parentElement);const x=F(()=>e.position==="popper"?e:{}),d=va(x.value),C={boxSizing:"border-box","--reka-combobox-content-transform-origin":"var(--reka-popper-transform-origin)","--reka-combobox-content-available-width":"var(--reka-popper-available-width)","--reka-combobox-content-available-height":"var(--reka-popper-available-height)","--reka-combobox-trigger-width":"var(--reka-popper-anchor-width)","--reka-combobox-trigger-height":"var(--reka-popper-anchor-height)"};ol({position:l});const I=A(!1);ge(()=>{r.inputElement.value&&(I.value=u.value.contains(r.inputElement.value),I.value&&r.inputElement.value.focus())}),rt(()=>{var f;const y=oa();I.value&&(!y||y===document.body)&&((f=r.triggerElement.value)==null||f.focus())});function k(y){var p,q;if((p=r.parentElement.value)!=null&&p.contains(y))return!0;const f=y instanceof Element?y.closest("label"):null,g=f==null?void 0:f.control;return!!g&&!!((q=r.parentElement.value)!=null&&q.contains(g))}return(y,f)=>(m(),B(t(ja),{"as-child":""},{default:h(()=>[v(t(ma),{"as-child":"",onMountAutoFocus:f[5]||(f[5]=Ae(()=>{},["prevent"])),onUnmountAutoFocus:f[6]||(f[6]=Ae(()=>{},["prevent"]))},{default:h(()=>[v(t(ha),{"as-child":"","disable-outside-pointer-events":y.disableOutsidePointerEvents,onDismiss:f[0]||(f[0]=g=>t(r).onOpenChange(!1)),onFocusOutside:f[1]||(f[1]=g=>{k(g.target)&&g.preventDefault(),o("focusOutside",g)}),onInteractOutside:f[2]||(f[2]=g=>o("interactOutside",g)),onEscapeKeyDown:f[3]||(f[3]=g=>o("escapeKeyDown",g)),onPointerDownOutside:f[4]||(f[4]=g=>{k(g.target)&&g.preventDefault(),o("pointerDownOutside",g)})},{default:h(()=>[(m(),B(Jt(t(l)==="popper"?t(ga):t(te)),ae({...y.$attrs,...t(d)},{id:t(r).contentId,ref:t(s),"memo-dependencies":t(l)==="popper"?[t(r).filterSearch.value,t(r).filterState.value]:void 0,"data-state":t(r).open.value?"open":"closed","data-empty":i.value?"":void 0,style:{display:e.hideWhenEmpty&&i.value?"none":"flex",flexDirection:"column",outline:"none",...t(l)==="popper"?C:{}}}),{default:h(()=>[J(y.$slots,"default")]),_:3},16,["id","memo-dependencies","data-state","data-empty","style"]))]),_:3},8,["disable-outside-pointer-events"])]),_:3})]),_:3}))}}),sl=rl,il=U({__name:"ComboboxContent",props:{forceMount:{type:Boolean,required:!1},position:{type:String,required:!1},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},memoDependencies:{type:Array,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},dir:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(n,{emit:a}){const l=ya(n,a),{forwardRef:r}=re(),i=qe();return i.contentId||(i.contentId=Ge(void 0,"reka-combobox-content")),(s,u)=>(m(),B(t(Ft),{present:s.forceMount||t(i).open.value},{default:h(()=>[v(sl,ae({...t(l),...s.$attrs},{ref:t(r)}),{default:h(()=>[J(s.$slots,"default")]),_:3},16)]),_:3},8,["present"]))}}),ul=il,dl=U({__name:"ComboboxEmpty",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(n){const a=n,e=qe(),o=F(()=>e.ignoreFilter.value?e.allItems.value.size===0:e.filterState.value.count===0);return(l,r)=>o.value?(m(),B(t(te),Bt(ae({key:0},a)),{default:h(()=>[J(l.$slots,"default",{},()=>[r[0]||(r[0]=H("No options"))])]),_:3},16)):G("v-if",!0)}}),cl=dl;const[pl]=be("ComboboxGroup");var fl=U({__name:"ComboboxInput",props:{displayValue:{type:Function,required:!1},modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,o=a,l=qe(),r=Xe(),{primitiveElement:i,currentElement:s}=Fe(),u=xe(e,"modelValue",o,{passive:e.modelValue===void 0});ge(()=>{s.value&&l.onInputElementChange(s.value)});const{isComposing:x,handleCompositionStart:d,handleCompositionEnd:C}=ut(E=>{const V=E.target;V&&k(V.value)});function I(E){x.value||(E.preventDefault(),l.open.value||l.onOpenChange(!0))}function k(E){l.open.value?l.filterSearch.value=E:(l.onOpenChange(!0),pe(()=>{E&&(l.filterSearch.value=E,r.highlightFirstItem())}))}function y(E){x.value||k(E.target.value)}function f(){l.openOnFocus.value&&!l.open.value&&l.onOpenChange(!0)}function g(E){var j,T;if(!l.open.value)return;const V=E.relatedTarget;if(!V)return;const P=(j=l.parentElement.value)==null?void 0:j.contains(V),ue=(T=document.getElementById(l.contentId))==null?void 0:T.contains(V);!P&&!ue&&requestAnimationFrame(()=>{var Y,W;if(!l.open.value)return;const M=document.activeElement;!((Y=l.parentElement.value)!=null&&Y.contains(M))&&!((W=document.getElementById(l.contentId))!=null&&W.contains(M))&&l.onOpenChange(!1)})}function p(){l.openOnClick.value&&!l.open.value&&l.onOpenChange(!0)}function q(){const E=l.modelValue.value;e.displayValue?u.value=e.displayValue(E):!l.multiple.value&&E&&!Array.isArray(E)&&typeof E!="object"?u.value=E.toString():u.value="",pe(()=>{u.value=u.value})}return l.onResetSearchTerm(()=>{q()}),Ke(l.modelValue,async()=>{!l.isUserInputted.value&&l.resetSearchTermOnSelect.value&&q()},{immediate:!0,deep:!0}),Ke(l.filterState,(E,V)=>{!l.isVirtual.value&&V.count===0&&r.highlightFirstItem()}),(E,V)=>(m(),B(t(Xa),{ref_key:"primitiveElement",ref:i,modelValue:t(u),"onUpdate:modelValue":V[0]||(V[0]=P=>Et(u)?u.value=P:null),as:E.as,"as-child":E.asChild,"auto-focus":E.autoFocus,disabled:E.disabled,"aria-expanded":t(l).open.value,"aria-controls":t(l).contentId,"aria-autocomplete":"list",role:"combobox",autocomplete:"off",onClick:p,onInput:y,onKeydown:me(I,["down","up"]),onFocus:f,onBlur:g,onCompositionstart:t(d),onCompositionend:t(C)},{default:h(()=>[J(E.$slots,"default")]),_:3},8,["modelValue","as","as-child","auto-focus","disabled","aria-expanded","aria-controls","onCompositionstart","onCompositionend"]))}}),vl=fl,ml=U({__name:"ComboboxItem",props:{textValue:{type:String,required:!1},value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select"],setup(n,{emit:a}){const e=n,o=a,l=Ge(void 0,"reka-combobox-item"),r=qe(),i=pl(null),{primitiveElement:s,currentElement:u}=Fe();if(e.value==="")throw new Error("A <ComboboxItem /> must have a value prop that is not an empty string. This is because the Combobox value can be set to an empty string to clear the selection and show the placeholder.");const x=F(()=>{if(r.isVirtual.value||r.ignoreFilter.value||!r.filterSearch.value)return!0;{const d=r.filterState.value.items.get(l);return d===void 0?!0:d>0}});return ge(()=>{var C;r.allItems.value.set(l,e.textValue||u.value.textContent||u.value.innerText);const d=i==null?void 0:i.id;d&&(r.allGroups.value.has(d)?(C=r.allGroups.value.get(d))==null||C.add(l):r.allGroups.value.set(d,new Set([l])))}),rt(()=>{r.allItems.value.delete(l)}),(d,C)=>x.value?St([x.value,t(r).filterSearch.value,t(r).disabled.value,d.disabled,e.value,e.as,e.asChild,...Object.values(d.$attrs)],()=>(m(),B(t(Za),ae({key:0},e,{id:t(l),ref_key:"primitiveElement",ref:s,disabled:t(r).disabled.value||d.disabled,onSelect:C[0]||(C[0]=I=>{var k;o("select",I),!I.defaultPrevented&&(!t(r).multiple.value&&!d.disabled&&!t(r).disabled.value?(I.preventDefault(),t(r).onOpenChange(!1),t(r).modelValue.value=e.value):t(r).multiple.value&&((k=t(r).inputElement.value)==null||k.focus()))})}),{default:h(()=>[J(d.$slots,"default",{},()=>[H($(d.value),1)])]),_:3},16,["id","disabled"])),C,1):G("v-if",!0)}}),hl=ml,gl=U({__name:"ComboboxPortal",props:{to:{type:null,required:!1},disabled:{type:Boolean,required:!1},defer:{type:Boolean,required:!1},forceMount:{type:Boolean,required:!1}},setup(n){const a=n;return(e,o)=>(m(),B(t(ba),Bt(Yt(a)),{default:h(()=>[J(e.$slots,"default")]),_:3},16))}}),yl=gl,bl=U({__name:"ComboboxTrigger",props:{disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(n){const a=n,{forwardRef:e,currentElement:o}=re(),l=qe(),r=F(()=>a.disabled||l.disabled.value||!1);return ge(()=>{o.value&&l.onTriggerElementChange(o.value)}),(i,s)=>(m(),B(t(te),ae(a,{ref:t(e),type:i.as==="button"?"button":void 0,tabindex:"-1","aria-label":"Show popup","aria-haspopup":"listbox","aria-expanded":t(l).open.value,"aria-controls":t(l).contentId,"data-state":t(l).open.value?"open":"closed",disabled:r.value,"data-disabled":r.value?"":void 0,"aria-disabled":r.value??void 0,onClick:s[0]||(s[0]=u=>t(l).onOpenChange(!t(l).open.value))}),{default:h(()=>[J(i.$slots,"default")]),_:3},16,["type","aria-expanded","aria-controls","data-state","disabled","data-disabled","aria-disabled"]))}}),_l=bl,xl=U({__name:"ComboboxViewport",props:{nonce:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(n){const a=n,{forwardRef:e}=re(),{nonce:o}=we(a),l=_a(o),r=qe();return(i,s)=>(m(),S(ee,null,[v(t(te),ae({...i.$attrs,...a},{ref:t(e),"data-reka-combobox-viewport":"",role:"presentation",style:{position:"relative",flex:t(r).isVirtual.value?void 0:1,overflow:"auto"}}),{default:h(()=>[J(i.$slots,"default")]),_:3},16,["style"]),v(t(te),{as:"style",nonce:t(l)},{default:h(()=>s[0]||(s[0]=[H(" /* Hide scrollbars cross-browser and enable momentum scroll for touch devices */ [data-reka-combobox-viewport] { scrollbar-width:none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } [data-reka-combobox-viewport]::-webkit-scrollbar { display: none; } ")])),_:1,__:[0]},8,["nonce"])],64))}}),Cl=xl;const[kl,wl]=be("SwitchRoot");var ql=U({inheritAttrs:!1,__name:"SwitchRoot",props:{defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},disabled:{type:Boolean,required:!1},id:{type:String,required:!1},value:{type:String,required:!1,default:"on"},trueValue:{type:null,required:!1,default:()=>!0},falseValue:{type:null,required:!1,default:()=>!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,o=a,{disabled:l}=we(e),r=xe(e,"modelValue",o,{defaultValue:e.defaultValue??e.falseValue,passive:e.modelValue===void 0}),i=F(()=>r.value===e.trueValue);function s(){l.value||(r.value=i.value?e.falseValue:e.trueValue)}const{forwardRef:u,currentElement:x}=re(),d=it(x),C=Pa(),I=F(()=>{var k;return e.id&&x.value?(k=document.querySelector(`[for="${e.id}"]`))==null?void 0:k.innerText:void 0});return wl({checked:i,toggleCheck:s,disabled:l}),(k,y)=>(m(),S(ee,null,[v(t(te),ae({id:k.id,ref:t(u),role:"switch",type:k.as==="button"?"button":void 0,value:k.value,"aria-label":k.$attrs["aria-label"]||I.value,"aria-checked":i.value,"aria-required":k.required,"data-state":i.value?"checked":"unchecked","data-disabled":t(l)?"":void 0,"as-child":k.asChild,as:k.as,disabled:t(l)},{...t(C),...k.$attrs},{onClick:s,onKeydown:me(Ae(s,["prevent"]),["enter"])}),{default:h(()=>[J(k.$slots,"default",{modelValue:t(r),checked:i.value})]),_:3},16,["id","type","value","aria-label","aria-checked","aria-required","data-state","data-disabled","as-child","as","disabled","onKeydown"]),t(d)&&k.name?(m(),B(t(dt),ae({key:0,type:"checkbox",name:k.name,disabled:t(l),required:k.required,value:k.value,checked:i.value},t(C)),null,16,["name","disabled","required","value","checked"])):G("v-if",!0)],64))}}),Vl=ql,$l=U({__name:"SwitchThumb",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(n){const a=kl();return re(),(e,o)=>(m(),B(t(te),{"data-state":t(a).checked.value?"checked":"unchecked","data-disabled":t(a).disabled.value?"":void 0,"as-child":e.asChild,as:e.as},{default:h(()=>[J(e.$slots,"default")]),_:3},8,["data-state","data-disabled","as-child","as"]))}}),Il=$l,Sl=U({__name:"TabsContent",props:{value:{type:[String,Number],required:!0},forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(n){const a=n,{forwardRef:e}=re(),o=ka(),l=F(()=>wa(o.baseId,a.value)),r=F(()=>qa(o.baseId,a.value)),i=F(()=>a.value===o.modelValue.value),s=A(i.value);return ge(()=>{o.registerContent(a.value),requestAnimationFrame(()=>{s.value=!1})}),Qt(()=>{o.unregisterContent(a.value)}),(u,x)=>(m(),B(t(Ft),{present:u.forceMount||i.value,"force-mount":""},{default:h(({present:d})=>[v(t(te),{id:r.value,ref:t(e),"as-child":u.asChild,as:u.as,role:"tabpanel","data-state":i.value?"active":"inactive","data-orientation":t(o).orientation.value,"aria-labelledby":l.value,hidden:!d,tabindex:"0",style:Zt({animationDuration:s.value?"0s":void 0})},{default:h(()=>[!t(o).unmountOnHide.value||d?J(u.$slots,"default",{key:0}):G("v-if",!0)]),_:2},1032,["id","as-child","as","data-state","data-orientation","aria-labelledby","hidden","style"])]),_:3},8,["present"]))}}),El=Sl;const[ct,Bl]=be("TagsInputRoot");var Al=U({__name:"TagsInputRoot",props:{modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1,default:()=>[]},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1,default:","},dir:{type:String,required:!1},max:{type:Number,required:!1,default:0},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1,default:n=>n.toString()},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","invalid","addTag","removeTag"],setup(n,{emit:a}){const e=n,o=a,{addOnPaste:l,disabled:r,delimiter:i,max:s,id:u,dir:x,addOnBlur:d,addOnTab:C}=we(e),I=st(x),k=xe(e,"modelValue",o,{defaultValue:e.defaultValue,passive:!0,deep:!0}),{forwardRef:y,currentElement:f}=re(),{focused:g}=ea(f),p=it(f),{getItems:q,CollectionSlot:E}=De({isProvider:!0}),V=A(),P=A(!1),ue=F(()=>Array.isArray(k.value)?[...k.value]:[]);function j(T){if(T!==-1){const M=q().filter(X=>X.ref.dataset.disabled!=="");k.value=k.value.filter((X,Y)=>Y!==T),o("removeTag",M[T].value)}}return Bl({modelValue:k,onAddValue:T=>{const M=[...ue.value],X=M.length>0&&typeof M[0]=="object",Y=M.length>0&&typeof e.defaultValue[0]=="object";if((X||Y)&&typeof e.convertValue!="function")throw new Error("You must provide a `convertValue` function when using objects as values.");const W=e.convertValue?e.convertValue(T):T;if(M.length>=s.value&&s.value)return o("invalid",W),!1;if(e.duplicate)return k.value=[...M,W],o("addTag",W),!0;if(M.includes(W))P.value=!0;else return k.value=[...M,W],o("addTag",W),!0;return o("invalid",W),!1},onRemoveValue:j,onInputKeydown:T=>{if(T.isComposing)return;const M=T.target,X=q().map(W=>W.ref).filter(W=>W.dataset.disabled!=="");if(!X.length)return;const Y=X.at(-1);switch(T.key){case"Delete":case"Backspace":{if(M.selectionStart!==0||M.selectionEnd!==0)break;if(V.value){const W=X.findIndex(ne=>ne===V.value);j(W),V.value=V.value===Y?X.at(W-1):X.at(W+1),T.preventDefault()}else T.key==="Backspace"&&(V.value=Y,T.preventDefault());break}case"Home":case"End":case"ArrowRight":case"ArrowLeft":{const W=T.key==="ArrowRight"&&I.value==="ltr"||T.key==="ArrowLeft"&&I.value==="rtl",ne=!W;if(M.selectionStart!==0||M.selectionEnd!==0)break;if(ne&&!V.value)V.value=Y,T.preventDefault();else if(W&&Y&&V.value===Y)V.value=void 0,T.preventDefault();else if(V.value){const le=Ra(T,V.value,void 0,{itemsArray:X,loop:!1,dir:I.value});le&&(V.value=le),T.preventDefault()}break}case"ArrowUp":case"ArrowDown":{V.value&&T.preventDefault();break}default:V.value=void 0}},selectedElement:V,isInvalidInput:P,addOnPaste:l,addOnBlur:d,addOnTab:C,dir:I,disabled:r,delimiter:i,max:s,id:u,displayValue:e.displayValue}),(T,M)=>(m(),B(t(E),null,{default:h(()=>[v(t(te),{ref:t(y),dir:t(I),as:T.as,"as-child":T.asChild,"data-invalid":P.value?"":void 0,"data-disabled":t(r)?"":void 0,"data-focused":t(g)?"":void 0},{default:h(()=>[J(T.$slots,"default",{modelValue:t(k)}),t(p)&&T.name?(m(),B(t(dt),{key:0,name:T.name,value:t(k),required:T.required,disabled:t(r)},null,8,["name","value","required","disabled"])):G("v-if",!0)]),_:3},8,["dir","as","as-child","data-invalid","data-disabled","data-focused"])]),_:3}))}}),Fl=Al,Ol=U({__name:"TagsInputInput",props:{placeholder:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},maxLength:{type:Number,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},setup(n){const a=n,e=ct(),{forwardRef:o,currentElement:l}=re();function r(y){if(e.selectedElement.value=void 0,!e.addOnBlur.value)return;const f=y.target,g=y.relatedTarget,p=f.getAttribute("aria-controls");if(p&&(g!=null&&g.closest(`#${CSS.escape(p)}`))||!f.value)return;e.onAddValue(f.value)&&(f.value="")}function i(y){e.addOnTab.value&&d(y)}const{isComposing:s,handleCompositionStart:u,handleCompositionEnd:x}=ut();async function d(y){if(s.value||(await pe(),y.defaultPrevented))return;const f=y.target;if(!f.value)return;e.onAddValue(f.value)&&(f.value=""),y.preventDefault()}function C(y){if(s.value||(e.isInvalidInput.value=!1,y.data===null))return;const f=e.delimiter.value;if(f===y.data||f instanceof RegExp&&f.test(y.data)){const p=y.target;if(p.value=p.value.replace(f,""),p.value.trim()===""){p.value="";return}e.onAddValue(p.value)&&(p.value="")}}function I(y){s.value||e.onInputKeydown(y)}function k(y){if(e.addOnPaste.value){y.preventDefault();const f=y.clipboardData;if(!f)return;const g=f.getData("text");e.delimiter.value?g.split(e.delimiter.value).forEach(q=>{e.onAddValue(q)}):e.onAddValue(g)}}return ge(()=>{const y=l.value.nodeName==="INPUT"?l.value:l.value.querySelector("input");y&&setTimeout(()=>{a.autoFocus&&(y==null||y.focus())},1)}),(y,f)=>{var g;return m(),B(t(te),{id:(g=t(e).id)==null?void 0:g.value,ref:t(o),type:"text",autocomplete:"off",autocorrect:"off",autocapitalize:"off",as:y.as,"as-child":y.asChild,maxlength:y.maxLength,placeholder:y.placeholder,disabled:t(e).disabled.value,"data-invalid":t(e).isInvalidInput.value?"":void 0,onInput:C,onKeydown:[me(d,["enter"]),me(i,["tab"]),I],onBlur:r,onCompositionstart:t(u),onCompositionend:t(x),onPaste:k},{default:h(()=>[J(y.$slots,"default")]),_:3},8,["id","as","as-child","maxlength","placeholder","disabled","data-invalid","onCompositionstart","onCompositionend"])}}}),Tl=Ol;const[zt,Rl]=be("TagsInputItem");var zl=U({__name:"TagsInputItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(n){const a=n,{value:e}=we(a),o=ct(),{forwardRef:l,currentElement:r}=re(),{CollectionItem:i}=De(),s=F(()=>o.selectedElement.value===r.value),u=F(()=>a.disabled||o.disabled.value),x=Rl({value:e,isSelected:s,disabled:u,textId:"",displayValue:F(()=>o.displayValue(e.value))});return(d,C)=>(m(),B(t(i),{value:t(e)},{default:h(()=>[v(t(te),{ref:t(l),as:d.as,"as-child":d.asChild,"aria-labelledby":t(x).textId,"aria-current":s.value,"data-disabled":u.value?"":void 0,"data-state":s.value?"active":"inactive"},{default:h(()=>[J(d.$slots,"default")]),_:3},8,["as","as-child","aria-labelledby","aria-current","data-disabled","data-state"])]),_:3},8,["value"]))}}),Pl=zl,Dl=U({__name:"TagsInputItemDelete",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(n){const a=n;re();const e=ct(),o=zt(),l=F(()=>{var i;return((i=o.disabled)==null?void 0:i.value)||e.disabled.value});function r(){if(l.value)return;const i=e.modelValue.value.findIndex(s=>He(s,o.value.value));e.onRemoveValue(i)}return(i,s)=>(m(),B(t(te),ae({tabindex:"-1"},a,{"aria-labelledby":t(o).textId,"aria-current":t(o).isSelected.value,"data-state":t(o).isSelected.value?"active":"inactive","data-disabled":l.value?"":void 0,type:i.as==="button"?"button":void 0,onClick:r}),{default:h(()=>[J(i.$slots,"default")]),_:3},16,["aria-labelledby","aria-current","data-state","data-disabled","type"]))}}),Ll=Dl,Nl=U({__name:"TagsInputItemText",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(n){const a=n,e=zt();return re(),e.textId||(e.textId=Ge(void 0,"reka-tags-input-item-text")),(o,l)=>(m(),B(t(te),ae(a,{id:t(e).textId}),{default:h(()=>[J(o.$slots,"default",{},()=>[H($(t(e).displayValue.value),1)])]),_:3},16,["id"]))}}),Ul=Nl;const Ml=U({__name:"Switch",props:{class:{},modelValue:{type:Boolean},id:{}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,o=a;return(l,r)=>(m(),B(t(Vl),{id:e.id,"model-value":e.modelValue,class:fe(t(ve)("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50",e.class)),"onUpdate:modelValue":r[0]||(r[0]=i=>o("update:modelValue",i))},{default:h(()=>[v(t(Il),{class:"bg-background pointer-events-none block size-4 rounded-full shadow-sm ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0.5"})]),_:1},8,["id","model-value","class"]))}}),Wl={class:"flex flex-col gap-1.5"},Pt=U({__name:"TagsInput",props:{modelValue:{},placeholder:{},validate:{type:Function},class:{}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,o=a,l=F(()=>e.validate?new Set(e.modelValue.filter(i=>{var s;return(s=e.validate)==null?void 0:s.call(e,i)})):new Set),r=F(()=>{if(!e.validate)return[];const i=new Set;for(const s of e.modelValue){const u=e.validate(s);u&&i.add(u)}return[...i]});return(i,s)=>(m(),S("div",Wl,[v(t(Fl),{"model-value":e.modelValue,delimiter:",","add-on-paste":!0,class:fe(t(ve)("border-input bg-background focus-within:border-ring focus-within:ring-ring/40 flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-md border px-2 py-1.5 shadow-xs transition-[color,box-shadow] focus-within:ring-[3px]",e.class)),"onUpdate:modelValue":s[0]||(s[0]=u=>o("update:modelValue",u))},{default:h(()=>[(m(!0),S(ee,null,de(e.modelValue,u=>(m(),B(t(Pl),{key:u,value:u,class:fe(t(ve)("flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-xs",l.value.has(u)?"border-destructive/50 bg-destructive/10 text-destructive":"bg-secondary text-secondary-foreground border-transparent"))},{default:h(()=>[v(t(Ul)),v(t(Ll),{class:"hover:text-foreground opacity-60 transition-opacity hover:opacity-100"},{default:h(()=>[v(t(At),{class:"size-3"})]),_:1})]),_:1},8,["value","class"]))),128)),v(t(Tl),{placeholder:e.modelValue.length?"":e.placeholder,class:"placeholder:text-muted-foreground min-w-24 flex-1 bg-transparent px-1 text-sm outline-none"},null,8,["placeholder"])]),_:1},8,["model-value","class"]),(m(!0),S(ee,null,de(r.value,u=>(m(),S("p",{key:u,class:"text-destructive text-xs"},$(u),1))),128))]))}}),_t=U({__name:"TabsContent",props:{class:{},value:{}},setup(n){const a=n;return(e,o)=>(m(),B(t(El),{value:a.value,class:fe(t(ve)("outline-none",a.class))},{default:h(()=>[J(e.$slots,"default")]),_:3},8,["value","class"]))}}),Kl=["value"],Qe=U({__name:"Textarea",props:{class:{},modelValue:{}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,o=a;return(l,r)=>(m(),S("textarea",{value:e.modelValue,class:fe(t(ve)("border-input bg-background flex min-h-20 w-full rounded-md border px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none sm:text-sm","placeholder:text-muted-foreground field-sizing-content","focus-visible:border-ring focus-visible:ring-ring/40 focus-visible:ring-[3px]","disabled:cursor-not-allowed disabled:opacity-50",e.class)),onInput:r[0]||(r[0]=i=>o("update:modelValue",i.target.value))},null,42,Kl))}}),We=A(null),at=A({ip:"",site:""}),lt=A(!1);let Re=null;async function Hl(n=!1){if(!(We.value&&!n))return Re||(lt.value=!0,Re=(async()=>{try{const a=await ye.geo(n);We.value=a,at.value={ip:a.ipError??"",site:a.siteError??""}}catch(a){const e=a instanceof Error?a.message:String(a);at.value={ip:e,site:e},We.value={ip:[],site:[]}}finally{lt.value=!1,Re=null}})(),Re)}function jl(){return{geo:We,error:at,loading:lt,load:Hl}}const Ze=new Map;function Gl(n){const a=n==="zh"?"zh-CN":"en";if(!Ze.has(a))try{Ze.set(a,new Intl.DisplayNames([a],{type:"region"}))}catch{return null}return Ze.get(a)??null}function Xl(n,a){var o;if(!/^[a-z]{2}$/i.test(n))return null;const e=n.toUpperCase();try{const l=(o=Gl(a))==null?void 0:o.of(e);return l&&l!==e?l:null}catch{return null}}function Jl(n){if(!/^[a-z]{2}$/i.test(n))return"";const a=127462,e=n.toUpperCase();return String.fromCodePoint(a+e.charCodeAt(0)-65,a+e.charCodeAt(1)-65)}const Yl={class:"flex flex-col gap-1.5"},Ql={class:"text-muted-foreground text-xs"},Zl={key:0,class:"font-mono"},en={key:0,class:"flex flex-wrap gap-1.5"},tn=["aria-label","onClick"],an={key:1,class:"text-muted-foreground text-xs"},ln={key:0,class:"shrink-0"},nn={class:"truncate"},on={class:"text-muted-foreground ml-auto shrink-0 text-[11px] tabular-nums"},rn=U({__name:"GeoPicker",props:{modelValue:{},kind:{}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,o=a,{lang:l}=ta(),{geo:r,error:i,loading:s,load:u}=jl(),x=A(""),d=F(()=>{var q,E;const g=(e.kind==="geoip"?(q=r.value)==null?void 0:q.ip:(E=r.value)==null?void 0:E.site)??[],p=[];for(const V of g)if(e.kind==="geoip"){const P=Xl(V.code,l.value);p.push({value:V.code,label:P??V.code,hint:`${V.code.toUpperCase()} · ${V.count}`,flag:Jl(V.code)})}else{p.push({value:V.code,label:V.code,hint:String(V.count),flag:""});for(const P of V.attributes??[])p.push({value:`${V.code}@${P}`,label:`${V.code}@${P}`,hint:_("rules.geo.attribute"),flag:""})}return p}),C=F(()=>{const g=x.value.trim().toLowerCase();return(g?d.value.filter(q=>q.value.includes(g)||q.label.toLowerCase().includes(g)):d.value).slice(0,300)}),I=F(()=>!s.value&&d.value.length===0),k=F(()=>e.kind==="geoip"?i.value.ip:i.value.site);function y(g){o("update:modelValue",e.modelValue.filter(p=>p!==g))}function f(g){const p=d.value.find(q=>q.value===g);return p?`${p.flag} ${p.label}`.trim():g}return u(),(g,p)=>(m(),S("div",Yl,[I.value?(m(),S(ee,{key:0},[v(t(Pt),{"model-value":e.modelValue,placeholder:e.kind==="geoip"?"cn, us, private":"category-ads-all","onUpdate:modelValue":p[0]||(p[0]=q=>o("update:modelValue",q))},null,8,["model-value","placeholder"]),O("p",Ql,[H($(t(_)("rules.geo.unavailable"))+" ",1),k.value?(m(),S("span",Zl,"("+$(k.value)+")",1)):G("",!0)])],64)):(m(),S(ee,{key:1},[e.modelValue.length?(m(),S("div",en,[(m(!0),S(ee,null,de(e.modelValue,q=>(m(),S("span",{key:q,class:"bg-secondary text-secondary-foreground inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-xs"},[H($(f(q))+" ",1),O("button",{type:"button",class:"opacity-60 transition-opacity hover:opacity-100","aria-label":t(_)("common.delete"),onClick:E=>y(q)},[v(t(At),{class:"size-3"})],8,tn)]))),128))])):G("",!0),t(s)?(m(),S("p",an,$(t(_)("rules.geo.loading")),1)):G("",!0),v(t(al),{"model-value":e.modelValue,multiple:"","ignore-filter":"","reset-search-term-on-blur":!1,"onUpdate:modelValue":p[2]||(p[2]=q=>o("update:modelValue",q??[]))},{default:h(()=>[v(t(nl),{class:"border-input bg-background focus-within:border-ring focus-within:ring-ring/40 flex h-9 w-full items-center gap-2 rounded-md border px-3 shadow-xs transition-[color,box-shadow] focus-within:ring-[3px]"},{default:h(()=>[v(t(Va),{class:"text-muted-foreground size-4 shrink-0"}),v(t(vl),{modelValue:x.value,"onUpdate:modelValue":p[1]||(p[1]=q=>x.value=q),placeholder:e.kind==="geoip"?t(_)("rules.geo.searchCountry"):t(_)("rules.geo.searchSite"),class:"placeholder:text-muted-foreground w-full bg-transparent text-sm outline-none"},null,8,["modelValue","placeholder"]),v(t(_l),{class:"text-muted-foreground shrink-0"},{default:h(()=>[v(t(Sa),{class:"size-4"})]),_:1})]),_:1}),v(t(yl),null,{default:h(()=>[v(t(ul),{position:"popper","side-offset":4,class:"bg-popover text-popover-foreground animate-fade-in z-50 max-h-72 w-[var(--reka-combobox-trigger-width)] overflow-hidden rounded-md border shadow-md"},{default:h(()=>[v(t(Cl),{class:"max-h-72 overflow-y-auto p-1"},{default:h(()=>[v(t(cl),{class:"text-muted-foreground px-2 py-4 text-center text-xs"},{default:h(()=>[H($(t(_)("common.empty")),1)]),_:1}),(m(!0),S(ee,null,de(C.value,q=>(m(),B(t(hl),{key:q.value,value:q.value,class:fe(t(ve)("data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none"))},{default:h(()=>[q.flag?(m(),S("span",ln,$(q.flag),1)):G("",!0),O("span",nn,$(q.label),1),O("span",on,$(q.hint),1),e.modelValue.includes(q.value)?(m(),B(t(xa),{key:1,class:"absolute right-2 size-4"})):G("",!0)]),_:2},1032,["value","class"]))),128))]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value"])],64))]))}}),Ce=[{key:"proto",group:"basic",type:"proto",expr:"proto"},{key:"ip.dst",group:"basic",type:"ip",expr:"ip.dst"},{key:"ip.src",group:"basic",type:"ip",expr:"ip.src"},{key:"port.dst",group:"basic",type:"port",expr:"port.dst"},{key:"port.src",group:"basic",type:"port",expr:"port.src"},{key:"tls.sni",group:"domain",type:"domain",expr:"string(tls?.req?.sni)",analyzer:"tls"},{key:"quic.sni",group:"domain",type:"domain",expr:"string(quic?.req?.sni)",analyzer:"quic"},{key:"dns.name",group:"domain",type:"domain",analyzer:"dns",iter:"dns?.questions ?? []",item:"string(.name)"},{key:"http.host",group:"http",type:"domain",expr:"string(http?.req?.headers?.host)",analyzer:"http"},{key:"http.path",group:"http",type:"text",expr:"string(http?.req?.path)",analyzer:"http"},{key:"http.method",group:"http",type:"text",expr:"string(http?.req?.method)",analyzer:"http"},{key:"http.ua",group:"http",type:"text",expr:'string(get(http?.req?.headers, "user-agent"))',analyzer:"http"},{key:"analyzer",group:"protocol",type:"analyzer"}],nt=Object.fromEntries(Ce.map(n=>[n.key,n])),Dt={proto:["is"],ip:["cidr","geoip","is"],port:["is","range"],domain:["subdomain","wildcard","is","contains","endsWith","startsWith","regex","geosite"],text:["contains","is","startsWith","endsWith","regex"],analyzer:["detected"]},sn=["tcp","udp"];function un(n){return Dt[n][0]}function xt(n){return Dt[n.type]}function se(n){return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}const dn=/[.+?^${}()|[\]\\]/g;function Ct(n){return`^${n.replace(dn,"\\$&").replace(/\*/g,".*")}$`}function Lt(n){const a=n.trim();if(a==="*")return{kind:"any",value:""};if(!a.includes("*"))return{kind:"exact",value:a};const e=a.startsWith("*"),o=a.endsWith("*"),l=a.replace(/^\*/,"").replace(/\*$/,"");return l.includes("*")?{kind:"regex",value:Ct(a)}:e&&o?{kind:"contains",value:l}:e?{kind:"suffix",value:l}:o?{kind:"prefix",value:l}:{kind:"regex",value:Ct(a)}}function cn(n,a){const e=Lt(a);switch(e.kind){case"any":return`${n} != ""`;case"exact":return`${n} == ${se(e.value)}`;case"suffix":return`${n} endsWith ${se(e.value)}`;case"prefix":return`${n} startsWith ${se(e.value)}`;case"contains":return`${n} contains ${se(e.value)}`;case"regex":return`${n} matches ${se(e.value)}`}}function pn(n,a,e,o){const l=o.trim();switch(a){case"is":return n.type==="port"?`${e} == ${l}`:`${e} == ${se(l)}`;case"subdomain":return`(${e} == ${se(l)} || ${e} endsWith ${se("."+l)})`;case"wildcard":return cn(e,l);case"contains":case"startsWith":case"endsWith":return`${e} ${a} ${se(l)}`;case"regex":return`${e} matches ${se(l)}`;case"geosite":return`geosite(${e}, ${se(l.toLowerCase())})`;case"cidr":return`cidr(${e}, ${se(l)})`;case"geoip":return`geoip(${e}, ${se(l.toLowerCase())})`;case"detected":return`${l} != nil`;case"range":return""}}function fn(n){const a=nt[n.field];if(!a)return"";const e=n.values.map(l=>l.trim()).filter(Boolean);let o;if(n.op==="range"){const[l,r]=n.values;if(!(l!=null&&l.trim())||!(r!=null&&r.trim()))return"";o=`(${a.expr} >= ${l.trim()} && ${a.expr} <= ${r.trim()})`}else{if(e.length===0)return"";const l=a.iter?a.item:a.expr,r=e.map(s=>pn(a,n.op,l,s)),i=r.length>1?`(${r.join(" || ")})`:r[0];o=a.iter?`any(${a.iter}, {${i}})`:i}return n.negate?o.startsWith("(")&&o.endsWith(")")?`!${o}`:`!(${o})`:o}function ot(n){const a=n.conditions.map(fn).filter(Boolean);return a.length===0?"":a.length===1?a[0]:a.join(n.mode==="and"?" && ":" || ")}const vn=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Nt(n){const a=vn.exec(n);return a?a.slice(1).every(e=>Number(e)<=255&&String(Number(e))===e):!1}function Ut(n){return!n.includes(":")||!/^[0-9a-fA-F:.]+$/.test(n)?!1:(n.match(/::/g)??[]).length<=1&&n.split(":").length<=9}function mn(n){return Nt(n)||Ut(n)}function hn(n){const a=n.lastIndexOf("/");if(a<0)return!1;const e=n.slice(0,a),o=n.slice(a+1);if(!/^\d{1,3}$/.test(o))return!1;const l=Number(o);return Nt(e)?l<=32:Ut(e)?l<=128:!1}function gn(n){return/^\d{1,5}$/.test(n)&&Number(n)<=65535}function yn(n,a,e){const o=e.trim();if(!o)return"";switch(a){case"cidr":return hn(o)?"":_("rules.invalidCidr");case"regex":try{return new RegExp(o),""}catch{return _("rules.invalidRegex")}case"geoip":case"geosite":return/^[a-z0-9-]+(@[a-z0-9-]+)*$/i.test(o)?"":_("rules.invalidGeo");case"wildcard":return/^[a-z0-9.*_-]+$/i.test(o)?"":_("rules.invalidDomain")}if((n==="domain"||n==="text")&&o.includes("*"))return _("rules.starHint");switch(n){case"ip":return mn(o)?"":_("rules.invalidIp");case"port":return gn(o)?"":_("rules.invalidPort");case"domain":return/^[a-z0-9.*_-]+$/i.test(o)?"":_("rules.invalidDomain");default:return""}}const bn={class:"bg-muted/40 flex flex-col gap-2 rounded-lg border p-2.5"},_n={class:"flex flex-wrap items-center gap-2"},xn=["aria-pressed"],Cn={key:0,class:"flex flex-wrap gap-1.5"},kn=["onClick"],wn={key:1,class:"flex flex-wrap gap-1.5"},qn=["onClick"],Vn={key:2,class:"flex items-center gap-2"},$n=U({__name:"ConditionRow",props:{condition:{},analyzers:{},removable:{type:Boolean}},emits:["update","remove"],setup(n,{emit:a}){const e=n,o=a,l=F(()=>nt[e.condition.field]??Ce[0]),r=f=>`rules.field.${f.replace(/\./g,"_")}`,i=F(()=>Ce.map(f=>({value:f.key,label:`${_(`rules.group.${f.group}`)} · ${_(r(f.key))}`}))),s=F(()=>xt(l.value).map(f=>({value:f,label:_(`rules.op.${f}`)})));function u(f){o("update",{...e.condition,...f})}function x(f){const g=nt[f];if(!g)return;const p=xt(g).includes(e.condition.op);u({field:f,op:p?e.condition.op:un(g.type),values:p&&g.type===l.value.type?e.condition.values:[]})}function d(f){u({op:f,values:[]})}function C(f){const g=e.condition.values.includes(f)?e.condition.values.filter(p=>p!==f):[...e.condition.values,f];u({values:g})}const I=f=>yn(l.value.type,e.condition.op,f),k=F(()=>{switch(e.condition.op){case"cidr":return"10.0.0.0/8, 2001:db8::/32";case"wildcard":return"*.example.com";case"regex":return"^/api/v\\d+/"}switch(l.value.type){case"ip":return"1.2.3.4";case"port":return"443";case"domain":return"example.com";default:return _("rules.valuePlaceholder")}}),y=F(()=>e.condition.op!=="wildcard"?[]:e.condition.values.filter(Boolean).slice(0,4).map(f=>{const g=Lt(f);return`${f} → ${_(`rules.wildcard.${g.kind}`,{value:g.value})}`}));return(f,g)=>(m(),S("div",bn,[O("div",_n,[v(t(je),{"model-value":e.condition.field,options:i.value,"aria-label":t(_)("rules.builder.field"),class:"h-8 min-w-0 flex-1 basis-45 text-xs sm:basis-56","onUpdate:modelValue":x},null,8,["model-value","options","aria-label"]),v(t(je),{"model-value":e.condition.op,options:s.value,"aria-label":t(_)("rules.builder.operator"),class:"h-8 min-w-0 flex-1 basis-32 text-xs sm:basis-40 sm:flex-none","onUpdate:modelValue":d},null,8,["model-value","options","aria-label"]),O("button",{type:"button",class:fe(t(ve)("h-8 shrink-0 rounded-md border px-2 text-xs font-medium transition-colors",n.condition.negate?"border-block/40 bg-block/10 text-block":"text-muted-foreground hover:bg-accent")),"aria-pressed":e.condition.negate,onClick:g[0]||(g[0]=p=>u({negate:!e.condition.negate}))},$(t(_)("rules.builder.not")),11,xn),e.removable?(m(),B(t(oe),{key:0,variant:"ghost",size:"icon-sm",class:"text-muted-foreground hover:text-destructive shrink-0","aria-label":t(_)("common.delete"),onClick:g[1]||(g[1]=p=>o("remove"))},{default:h(()=>[v(t(Ot),{class:"size-3.5"})]),_:1},8,["aria-label"])):G("",!0)]),l.value.type==="proto"?(m(),S("div",Cn,[(m(!0),S(ee,null,de(t(sn),p=>(m(),S("button",{key:p,type:"button",class:fe(t(ve)("rounded-md border px-2.5 py-1 font-mono text-xs uppercase transition-colors",e.condition.values.includes(p)?"border-primary/40 bg-primary/10 text-foreground":"text-muted-foreground hover:bg-accent")),onClick:q=>C(p)},$(p),11,kn))),128))])):l.value.type==="analyzer"?(m(),S("div",wn,[(m(!0),S(ee,null,de(e.analyzers,p=>(m(),S("button",{key:p,type:"button",class:fe(t(ve)("rounded-md border px-2.5 py-1 font-mono text-xs transition-colors",e.condition.values.includes(p)?"border-primary/40 bg-primary/10 text-foreground":"text-muted-foreground hover:bg-accent")),onClick:q=>C(p)},$(p),11,qn))),128))])):n.condition.op==="range"?(m(),S("div",Vn,[v(t(tt),{"model-value":e.condition.values[0]??"",inputmode:"numeric",placeholder:"1024",class:"h-8 w-28 text-xs","onUpdate:modelValue":g[2]||(g[2]=p=>u({values:[p,e.condition.values[1]??""]}))},null,8,["model-value"]),g[6]||(g[6]=O("span",{class:"text-muted-foreground text-xs"},"–",-1)),v(t(tt),{"model-value":e.condition.values[1]??"",inputmode:"numeric",placeholder:"65535",class:"h-8 w-28 text-xs","onUpdate:modelValue":g[3]||(g[3]=p=>u({values:[e.condition.values[0]??"",p]}))},null,8,["model-value"])])):e.condition.op==="geoip"||e.condition.op==="geosite"?(m(),B(rn,{key:3,"model-value":e.condition.values,kind:e.condition.op,"onUpdate:modelValue":g[4]||(g[4]=p=>u({values:p}))},null,8,["model-value","kind"])):(m(),S(ee,{key:4},[v(t(Pt),{"model-value":e.condition.values,placeholder:k.value,validate:I,"onUpdate:modelValue":g[5]||(g[5]=p=>u({values:p}))},null,8,["model-value","placeholder"]),(m(!0),S(ee,null,de(y.value,p=>(m(),S("p",{key:p,class:"text-muted-foreground font-mono text-[11px]"},$(p),1))),128))],64))]))}});let kt=0;function _e(n={}){return kt+=1,{id:`c${kt}`,field:"tls.sni",op:"subdomain",negate:!1,values:[],...n}}function et(){return{mode:"and",conditions:[_e()]}}const In={class:"flex flex-col gap-3"},Sn={class:"flex flex-wrap items-center gap-2 text-sm"},En={class:"text-muted-foreground"},Bn={class:"bg-muted inline-flex rounded-md p-0.5"},An=["onClick"],Fn={class:"text-muted-foreground"},On={class:"flex flex-col gap-2"},Tn={key:0,class:"flex items-center gap-2"},Rn={class:"text-muted-foreground text-[11px] font-medium uppercase"},zn={class:"flex flex-col gap-1"},Pn={class:"text-muted-foreground text-xs font-medium"},Dn={class:"bg-muted/60 text-muted-foreground block rounded-md px-2.5 py-2 font-mono text-[11px] leading-relaxed break-all"},Ln=U({__name:"RuleBuilder",props:{modelValue:{},analyzers:{}},emits:["update:modelValue"],setup(n,{emit:a}){const e=n,o=a,l=F(()=>ot(e.modelValue));function r(x){o("update:modelValue",{...e.modelValue,...x})}function i(x,d){const C=[...e.modelValue.conditions];C[x]=d,r({conditions:C})}function s(x){r({conditions:e.modelValue.conditions.filter((d,C)=>C!==x)})}function u(){r({conditions:[...e.modelValue.conditions,_e()]})}return(x,d)=>(m(),S("div",In,[O("div",Sn,[O("span",En,$(t(_)("rules.builder.match")),1),O("div",Bn,[(m(),S(ee,null,de(["and","or"],C=>O("button",{key:C,type:"button",class:fe(t(ve)("rounded-[5px] px-2.5 py-1 text-xs font-medium transition-colors",e.modelValue.mode===C?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground")),onClick:I=>r({mode:C})},$(t(_)(`rules.builder.${C}`)),11,An)),64))]),O("span",Fn,$(t(_)("rules.builder.matchSuffix")),1)]),O("div",On,[(m(!0),S(ee,null,de(e.modelValue.conditions,(C,I)=>(m(),S(ee,{key:C.id},[I>0?(m(),S("div",Tn,[d[0]||(d[0]=O("span",{class:"bg-border h-px flex-1"},null,-1)),O("span",Rn,$(t(_)(`rules.builder.${e.modelValue.mode}`)),1),d[1]||(d[1]=O("span",{class:"bg-border h-px flex-1"},null,-1))])):G("",!0),v($n,{condition:C,analyzers:e.analyzers,removable:e.modelValue.conditions.length>1,onUpdate:k=>i(I,k),onRemove:k=>s(I)},null,8,["condition","analyzers","removable","onUpdate","onRemove"])],64))),128))]),v(t(oe),{variant:"outline",size:"sm",class:"w-full",onClick:u},{default:h(()=>[v(t(Tt),{class:"size-3.5"}),H(" "+$(t(_)("rules.builder.addCondition")),1)]),_:1}),O("div",zn,[O("span",Pn,$(t(_)("rules.builder.preview")),1),O("code",Dn,$(l.value||t(_)("rules.builder.empty")),1)])]))}});function wt(n){const a=n.trim();if(!a)return null;let e="and",o=ke(a,"&&");if(o.length===1){const r=ke(a,"||");r.length>1&&(e="or",o=r)}const l=[];for(const r of o){const i=Nn(r);if(!i)return null;l.push(i)}return{mode:e,conditions:l}}function Nn(n){let a=n.trim(),e=!1;a.startsWith("!")&&(e=!0,a=a.slice(1).trim());const o=Pe(a);if(o)return _e({field:o.field.key,op:o.op,negate:e,values:[o.value]});const l=pt(a),r=Mt(l,"any");if(r!==null){const[s,u]=ke(r,",").map(d=>d.trim());if(!(u!=null&&u.startsWith("{"))||!u.endsWith("}"))return null;const x=Ce.find(d=>d.iter===s);return x?qt(x,u.slice(1,-1).trim(),e,x.item):null}const i=ke(l,"&&");if(i.length===2){const s=/^(\S+)\s*>=\s*(\d+)$/.exec(i[0].trim()),u=/^(\S+)\s*<=\s*(\d+)$/.exec(i[1].trim());if(s&&u&&s[1]===u[1]){const x=Ce.find(d=>d.expr===s[1]&&d.type==="port");return x?_e({field:x.key,op:"range",negate:e,values:[s[2],u[2]]}):null}return null}return i.length>1?null:qt(null,l,e)}function qt(n,a,e,o){const l=Pe(a.trim(),o);if(l&&(!n||l.field.key===n.key))return _e({field:l.field.key,op:l.op,negate:e,values:[l.value]});const r=ke(pt(a),"||");if(r.length<2)return null;const i=[];let s=n;for(const d of r){const C=Pe(d.trim(),o);if(!C||(s||(s=C.field),C.field.key!==s.key))return null;i.push(C)}if(!s)return null;if(new Set(i.map(d=>d.op)).size===1)return _e({field:s.key,op:i[0].op,negate:e,values:i.map(d=>d.value)});const x=i.map(d=>Un(d.op,d.value));return x.some(d=>d===null)?null:_e({field:s.key,op:"wildcard",negate:e,values:x})}function Un(n,a){switch(n){case"wildcard":return a;case"is":return a.includes("*")?null:a;case"endsWith":return`*${a}`;case"startsWith":return`${a}*`;case"contains":return`*${a}*`;default:return null}}const Mn={geoip:"geoip",geosite:"geosite",cidr:"cidr"},Wn={"==":"is",contains:"contains",startsWith:"startsWith",endsWith:"endsWith",matches:"regex"};function Vt(n){const a=[];for(const e of Ce)e.item&&a.push({subject:e.item,field:e}),e.expr&&a.push({subject:e.expr,field:e});return a.sort((e,o)=>+(o.subject===n)-+(e.subject===n)||o.subject.length-e.subject.length)}function Pe(n,a){const e=n.trim(),o=/^([a-z][\w]*)\s*!=\s*nil$/.exec(e);if(o){const l=Ce.find(r=>r.type==="analyzer");if(l)return{field:l,subject:"",op:"detected",value:o[1]}}if(e.startsWith("(")&&Kt(e)){const l=ke(pt(e),"||");if(l.length===2){const r=Pe(l[0].trim(),a),i=Pe(l[1].trim(),a);if(r&&i&&r.op==="is"&&i.op==="endsWith"&&r.field.key===i.field.key&&i.value===`.${r.value}`)return{...r,op:"subdomain"}}return null}for(const[l,r]of Object.entries(Mn)){const i=Mt(e,l);if(i===null)continue;const s=ke(i,",").map(d=>d.trim());if(s.length!==2)return null;const u=Vt(a).find(d=>d.subject===s[0]),x=$t(s[1]);return!u||x===null?null:{field:u.field,subject:u.subject,op:r,value:x}}for(const{subject:l,field:r}of Vt(a)){if(!e.startsWith(l))continue;const i=e.slice(l.length).trim();if(i==='!= ""')return{field:r,subject:l,op:"wildcard",value:"*"};for(const[s,u]of Object.entries(Wn)){if(!i.startsWith(s))continue;const x=i.slice(s.length).trim();if(r.type==="port"&&/^\d+$/.test(x)&&u==="is")return{field:r,subject:l,op:u,value:x};const d=$t(x);if(d!==null)return{field:r,subject:l,op:u,value:d}}return null}return null}function Mt(n,a){const e=`${a}(`;if(!n.startsWith(e)||!n.endsWith(")"))return null;const o=n.slice(e.length,-1);return Wt(o)?o:null}function $t(n){if(n.length<2||n[0]!=='"'||n[n.length-1]!=='"')return null;const a=n.slice(1,-1);let e="";for(let o=0;o<a.length;o++)if(a[o]==="\\"&&o+1<a.length)o++,e+=a[o];else{if(a[o]==='"')return null;e+=a[o]}return e}function ke(n,a){const e=[];let o=0,l=!1,r=0;for(let i=0;i<n.length;i++){const s=n[i];if(l){s==="\\"?i++:s==='"'&&(l=!1);continue}s==='"'?l=!0:s==="("||s==="["||s==="{"?o++:s===")"||s==="]"||s==="}"?o--:o===0&&n.startsWith(a,i)&&(e.push(n.slice(r,i)),i+=a.length-1,r=i+1)}return e.push(n.slice(r)),e.map(i=>i.trim()).filter(i=>i.length>0)}function Wt(n){let a=0,e=!1;for(let o=0;o<n.length;o++){const l=n[o];if(e){l==="\\"?o++:l==='"'&&(e=!1);continue}if(l==='"')e=!0;else if(l==="("||l==="["||l==="{")a++;else if((l===")"||l==="]"||l==="}")&&(a--,a<0))return!1}return a===0&&!e}function Kt(n){return!n.startsWith("(")||!n.endsWith(")")?!1:Wt(n.slice(1,-1))}function pt(n){let a=n.trim();for(;Kt(a);)a=a.slice(1,-1).trim();return a}const Kn={class:"hidden sm:inline"},Hn={class:"hidden sm:inline"},jn={class:"mb-3 flex flex-wrap items-center gap-2"},Gn={key:1,class:"text-muted-foreground ml-auto hidden truncate font-mono text-[11px] sm:inline"},Xn={key:0,class:"border-destructive/40 bg-destructive/10 text-destructive mb-3 rounded-lg border px-3 py-2 font-mono text-xs break-words whitespace-pre-wrap"},Jn={key:0,class:"text-muted-foreground py-12 text-center text-sm"},Yn={key:1,class:"flex flex-col gap-2"},Qn={class:"flex items-start justify-between gap-3"},Zn={class:"flex min-w-0 flex-col gap-1.5"},eo={class:"flex flex-wrap items-center gap-1.5"},to={class:"text-muted-foreground font-mono text-[11px] tabular-nums"},ao={class:"truncate text-sm font-medium"},lo={class:"text-muted-foreground bg-muted/60 rounded-md px-2 py-1.5 font-mono text-[11px] leading-relaxed break-all sm:text-xs"},no={class:"flex shrink-0 flex-col gap-1 sm:flex-row"},oo={key:0,class:"text-muted-foreground py-10 text-center text-sm"},ro={class:"text-muted-foreground mt-2 text-xs"},so={class:"flex flex-col gap-2"},io={class:"grid gap-4 sm:grid-cols-2"},uo={class:"flex flex-col gap-2"},co={class:"flex flex-col justify-end gap-2"},po={class:"flex h-9 items-center"},fo={key:0,class:"flex flex-col gap-4"},vo={class:"flex flex-col gap-2"},mo={class:"flex flex-col gap-2"},ho={class:"flex flex-col gap-2"},go={class:"flex flex-wrap items-center justify-between gap-2"},yo={key:0,class:"border-drop/40 bg-drop/10 text-drop rounded-md border px-2.5 py-2 text-xs"},bo={class:"text-muted-foreground text-xs"},_o={key:1,class:"text-destructive font-mono text-xs break-words"},Eo=U({__name:"RulesView",setup(n){const a=A("visual"),e=A([]),o=A(""),l=A(""),r=A(null),i=A(!0),s=A(!1),u=A(!1),x=A(""),d=A(null),C=A(-1),I=A(-1),k=A("builder"),y=A(et()),f=A(!1),g=A(!1),p=F(()=>{var c;return(((c=r.value)==null?void 0:c.analyzers)??[]).map(b=>b.name)}),q=F(()=>{var c;return[{value:"",label:_("rules.actionNone")},...(((c=r.value)==null?void 0:c.actions)??[]).map(b=>({value:b,label:_(`action.${b}`)}))]}),E=F(()=>{var c;return(((c=r.value)==null?void 0:c.modifiers)??[]).map(b=>({value:b,label:b}))}),V=c=>{switch(c){case"allow":return"allow";case"block":return"block";case"drop":return"drop";case"modify":return"modify";default:return"muted"}};ge(async()=>{try{const[c,b]=await Promise.all([ye.rules(),ye.meta()]);e.value=c.rules??[],o.value=c.raw,l.value=c.path,r.value=b}catch(c){x.value=c instanceof Ee?c.message:String(c)}finally{i.value=!1}});async function P(c){if(!(c===a.value||s.value)){s.value=!0,x.value="";try{const b=await ye.validateRules(c==="yaml"?{rules:e.value}:{raw:o.value});if(c==="yaml")o.value=b.raw;else{if(!b.valid){x.value=b.error??_("rules.invalid");return}e.value=b.rules??[]}a.value=c}catch(b){x.value=b instanceof Ee?b.message:String(b)}finally{s.value=!1}}}function ue(){return a.value==="yaml"?{raw:o.value}:{rules:e.value}}async function j(){s.value=!0,x.value="";try{const c=await ye.validateRules(ue());c.valid?Je.success(_("rules.valid")):x.value=c.error??_("rules.invalid")}catch(c){x.value=c instanceof Ee?c.message:String(c)}finally{s.value=!1}}async function T(){s.value=!0,x.value="";try{const c=await ye.saveRules(ue());e.value=c.rules??[],o.value=c.raw,u.value=!1,Je.success(_("rules.saved"),_("rules.count",{n:e.value.length}))}catch(c){x.value=c instanceof Ee?c.message:String(c),Je.error(_("rules.invalid"),x.value)}finally{s.value=!1}}async function M(){s.value=!0,x.value="";try{const c=await ye.rules();e.value=c.rules??[],o.value=c.raw,u.value=!1}catch(c){x.value=c instanceof Ee?c.message:String(c)}finally{s.value=!1}}function X(c,b){const L=c+b;if(L<0||L>=e.value.length)return;const R=[...e.value],[N]=R.splice(c,1);R.splice(L,0,N),e.value=R,u.value=!0}function Y(){C.value=-1,d.value={name:"",action:"block",log:!1,expr:""},le.value="{}",y.value=et(),f.value=!1,k.value="builder",K.value=""}function W(c){var R;const b=e.value[c];C.value=c,d.value={...b},le.value=JSON.stringify(((R=b.modifier)==null?void 0:R.args)??{},null,2);const L=wt(b.expr);f.value=L===null,y.value=L??et(),k.value=L?"builder":"expr",K.value=""}function ne(c){if(!(c===k.value||!d.value)){if(c==="expr"){const b=ot(y.value);b&&(d.value.expr=b)}else{const b=wt(d.value.expr);f.value=b===null,b&&(y.value=b)}k.value=c}}const le=A("{}"),K=A(""),Ve=F(()=>{var c;return k.value==="builder"?ot(y.value):((c=d.value)==null?void 0:c.expr)??""});async function $e(){var R,N;const c=d.value;if(!c||g.value)return;if(K.value="",!c.name.trim()){K.value=_("rules.nameRequired");return}const b=Ve.value.trim();if(!b){K.value=_("rules.exprRequired");return}if(c.expr=b,c.action==="modify")try{const Q=JSON.parse(le.value||"{}");c.modifier={name:((R=c.modifier)==null?void 0:R.name)??((N=E.value[0])==null?void 0:N.value)??"",args:Q}}catch{K.value=_("rules.invalidJson");return}else c.modifier=null;g.value=!0;try{const Q=await ye.validateRules({rules:[{...c,name:c.name.trim()}]});if(!Q.valid){K.value=Q.error??_("rules.invalid");return}}catch(Q){K.value=Q instanceof Ee?Q.message:String(Q);return}finally{g.value=!1}const L=[...e.value];C.value>=0?L[C.value]=c:L.push(c),e.value=L,u.value=!0,d.value=null}function Ie(c){e.value=e.value.filter((b,L)=>L!==c),u.value=!0,I.value=-1}return(c,b)=>{var L;return m(),S("div",null,[v(na,{title:t(_)("rules.title"),description:t(_)("rules.subtitle")},{actions:h(()=>[v(t(oe),{variant:"ghost",size:"sm",disabled:s.value,onClick:M},{default:h(()=>[v(t(Ba),{class:"size-3.5"}),O("span",Kn,$(t(_)("common.refresh")),1)]),_:1},8,["disabled"]),v(t(oe),{variant:"outline",size:"sm",disabled:s.value,onClick:j},{default:h(()=>[v(t(aa),{class:"size-3.5"}),O("span",Hn,$(t(_)("rules.validate")),1)]),_:1},8,["disabled"]),v(t(oe),{size:"sm",disabled:s.value,onClick:T},{default:h(()=>[s.value?(m(),B(t(mt),{key:0,class:"size-3.5 animate-spin"})):(m(),B(t(Aa),{key:1,class:"size-3.5"})),H(" "+$(t(_)("rules.save")),1)]),_:1},8,["disabled"])]),_:1},8,["title","description"]),O("div",jn,[v(t(Ye),{"model-value":a.value,"onUpdate:modelValue":P},{default:h(()=>[v(t(ht),null,{default:h(()=>[v(t(Ue),{value:"visual"},{default:h(()=>[H($(t(_)("rules.visual")),1)]),_:1}),v(t(Ue),{value:"yaml"},{default:h(()=>[v(t(yt)),H(" "+$(t(_)("rules.yaml")),1)]),_:1})]),_:1})]),_:1},8,["model-value"]),v(t(Te),{variant:"secondary"},{default:h(()=>[H($(t(_)("rules.count",{n:e.value.length})),1)]),_:1}),u.value?(m(),B(t(Te),{key:0,variant:"drop"},{default:h(()=>[H($(t(_)("rules.unsaved")),1)]),_:1})):G("",!0),l.value?(m(),S("span",Gn,$(l.value),1)):G("",!0)]),x.value?(m(),S("p",Xn,$(x.value),1)):G("",!0),v(t(Ye),{"model-value":a.value,"onUpdate:modelValue":P},{default:h(()=>[v(t(_t),{value:"visual"},{default:h(()=>[i.value?(m(),S("div",Jn,$(t(_)("common.loading")),1)):(m(),S("div",Yn,[(m(!0),S(ee,null,de(e.value,(R,N)=>(m(),B(t(la),{key:`${R.name}-${N}`,class:"p-3 sm:p-4"},{default:h(()=>{var Q;return[O("div",Qn,[O("div",Zn,[O("div",eo,[O("span",to,"#"+$(N+1),1),O("span",ao,$(R.name),1),R.action?(m(),B(t(Te),{key:0,variant:V(R.action),class:"uppercase"},{default:h(()=>[H($(t(_)(`action.${R.action}`)),1)]),_:2},1032,["variant"])):G("",!0),R.log?(m(),B(t(Te),{key:1,variant:"log"},{default:h(()=>[H($(t(_)("action.log")),1)]),_:1})):G("",!0),(Q=R.modifier)!=null&&Q.name?(m(),B(t(Te),{key:2,variant:"outline"},{default:h(()=>[H($(R.modifier.name),1)]),_:2},1024)):G("",!0)]),O("code",lo,$(R.expr),1)]),O("div",no,[v(t(oe),{variant:"ghost",size:"icon-sm","aria-label":t(_)("rules.moveUp"),disabled:N===0,onClick:ce=>X(N,-1)},{default:h(()=>[v(t(Ia),{class:"size-3.5"})]),_:1},8,["aria-label","disabled","onClick"]),v(t(oe),{variant:"ghost",size:"icon-sm","aria-label":t(_)("rules.moveDown"),disabled:N===e.value.length-1,onClick:ce=>X(N,1)},{default:h(()=>[v(t($a),{class:"size-3.5"})]),_:1},8,["aria-label","disabled","onClick"]),v(t(oe),{variant:"ghost",size:"icon-sm","aria-label":t(_)("common.edit"),onClick:ce=>W(N)},{default:h(()=>[v(t(Ea),{class:"size-3.5"})]),_:1},8,["aria-label","onClick"]),v(t(oe),{variant:"ghost",size:"icon-sm",class:"text-destructive","aria-label":t(_)("common.delete"),onClick:ce=>I.value=N},{default:h(()=>[v(t(Ot),{class:"size-3.5"})]),_:1},8,["aria-label","onClick"])])])]}),_:2},1024))),128)),e.value.length?G("",!0):(m(),S("p",oo,$(t(_)("rules.empty")),1)),v(t(oe),{variant:"outline",class:"mt-1 w-full",onClick:Y},{default:h(()=>[v(t(Tt),{class:"size-4"}),H(" "+$(t(_)("rules.add")),1)]),_:1})]))]),_:1}),v(t(_t),{value:"yaml"},{default:h(()=>[v(t(Qe),{modelValue:o.value,"onUpdate:modelValue":[b[0]||(b[0]=R=>o.value=R),b[1]||(b[1]=R=>u.value=!0)],spellcheck:"false",class:"h-[60vh] resize-y font-mono text-xs leading-relaxed"},null,8,["modelValue"]),O("p",ro,$(t(_)("rules.hint")),1)]),_:1})]),_:1},8,["model-value"]),v(t(gt),{open:d.value!==null,title:C.value>=0?t(_)("rules.editTitle"):t(_)("rules.addTitle"),class:"sm:max-w-2xl","onUpdate:open":b[11]||(b[11]=R=>!R&&(d.value=null,K.value=""))},{footer:h(()=>[v(t(oe),{variant:"outline",onClick:b[10]||(b[10]=R=>(d.value=null,K.value=""))},{default:h(()=>[H($(t(_)("common.cancel")),1)]),_:1}),v(t(oe),{disabled:g.value,onClick:$e},{default:h(()=>[g.value?(m(),B(t(mt),{key:0,class:"size-4 animate-spin"})):G("",!0),H(" "+$(t(_)("common.save")),1)]),_:1},8,["disabled"])]),default:h(()=>{var R;return[d.value?(m(),S("form",{key:0,class:"flex flex-col gap-4",onSubmit:b[9]||(b[9]=Ae(()=>{},["prevent"]))},[O("div",so,[v(t(Be),{for:"rule-name"},{default:h(()=>[H($(t(_)("rules.name")),1)]),_:1}),v(t(tt),{id:"rule-name",modelValue:d.value.name,"onUpdate:modelValue":b[2]||(b[2]=N=>d.value.name=N),placeholder:t(_)("rules.namePlaceholder")},null,8,["modelValue","placeholder"])]),O("div",io,[O("div",uo,[v(t(Be),null,{default:h(()=>[H($(t(_)("rules.action")),1)]),_:1}),v(t(je),{"model-value":d.value.action??"",options:q.value,"onUpdate:modelValue":b[3]||(b[3]=N=>d.value.action=N)},null,8,["model-value","options"])]),O("div",co,[v(t(Be),{for:"rule-log"},{default:h(()=>[H($(t(_)("rules.log")),1)]),_:1}),O("div",po,[v(t(Ml),{id:"rule-log",modelValue:d.value.log,"onUpdate:modelValue":b[4]||(b[4]=N=>d.value.log=N)},null,8,["modelValue"])])])]),d.value.action==="modify"?(m(),S("div",fo,[O("div",vo,[v(t(Be),null,{default:h(()=>[H($(t(_)("rules.modifier")),1)]),_:1}),v(t(je),{"model-value":((R=d.value.modifier)==null?void 0:R.name)??"",options:E.value,"onUpdate:modelValue":b[5]||(b[5]=N=>{var Q;return d.value.modifier={name:N,args:(Q=d.value.modifier)==null?void 0:Q.args}})},null,8,["model-value","options"])]),O("div",mo,[v(t(Be),{for:"rule-args"},{default:h(()=>[H($(t(_)("rules.modifierArgs")),1)]),_:1}),v(t(Qe),{id:"rule-args",modelValue:le.value,"onUpdate:modelValue":b[6]||(b[6]=N=>le.value=N),class:"font-mono text-xs",rows:"4"},null,8,["modelValue"])])])):G("",!0),O("div",ho,[O("div",go,[v(t(Be),null,{default:h(()=>[H($(t(_)("rules.conditions")),1)]),_:1}),v(t(Ye),{"model-value":k.value,"onUpdate:modelValue":ne},{default:h(()=>[v(t(ht),{class:"h-8"},{default:h(()=>[v(t(Ue),{value:"builder",class:"text-xs"},{default:h(()=>[v(t(Fa)),H(" "+$(t(_)("rules.builder.tab")),1)]),_:1}),v(t(Ue),{value:"expr",class:"text-xs"},{default:h(()=>[v(t(yt)),H(" "+$(t(_)("rules.expr")),1)]),_:1})]),_:1})]),_:1},8,["model-value"])]),f.value&&k.value==="expr"?(m(),S("p",yo,$(t(_)("rules.builder.notParsed")),1)):G("",!0),k.value==="builder"?(m(),B(Ln,{key:1,modelValue:y.value,"onUpdate:modelValue":b[7]||(b[7]=N=>y.value=N),analyzers:p.value},null,8,["modelValue","analyzers"])):(m(),S(ee,{key:2},[v(t(Qe),{modelValue:d.value.expr,"onUpdate:modelValue":b[8]||(b[8]=N=>d.value.expr=N),spellcheck:"false",placeholder:t(_)("rules.exprPlaceholder"),class:"min-h-28 font-mono text-xs leading-relaxed"},null,8,["modelValue","placeholder"]),O("p",bo,$(t(_)("rules.exprHint")),1)],64))]),K.value?(m(),S("p",_o,$(K.value),1)):G("",!0)],32)):G("",!0)]}),_:1},8,["open","title"]),v(t(gt),{open:I.value>=0,title:t(_)("common.delete"),description:I.value>=0?t(_)("rules.deleteConfirm",{name:((L=e.value[I.value])==null?void 0:L.name)??""}):"","onUpdate:open":b[14]||(b[14]=R=>!R&&(I.value=-1))},{footer:h(()=>[v(t(oe),{variant:"outline",onClick:b[12]||(b[12]=R=>I.value=-1)},{default:h(()=>[H($(t(_)("common.cancel")),1)]),_:1}),v(t(oe),{variant:"destructive",onClick:b[13]||(b[13]=R=>Ie(I.value))},{default:h(()=>[H($(t(_)("common.delete")),1)]),_:1})]),_:1},8,["open","title","description"])])}}});export{Eo as default};