Skip to content

The only tool you need to know what is happening and how to fix it.

7.7 KB
Raw Blame
import"./DsnmJJEf.js";import{_ as $,aW as ee,aX as te,u as d,g as a,l as g,p as E,c as D,f as R,d as b,a as M,ar as re,e as G,m as ne,s as B,h as X,x as F,r as K}from"./BKFspo1J.js";import{i as I}from"./COK9M2N0.js";import{c as se}from"./CWm9VMfX.js";import{s as J,p as l,r as W}from"./CARHnQ8P.js";import{c as ie}from"./BXr1Q65P.js";import{d as oe}from"./DwMHXN8q.js";import{C as Q,w as H,E as ae,S as ue,i as ce}from"./R7BU62x2.js";import{a as de,e as U,h as V,i as he,d as le,c as fe,b as m,m as pe}from"./BoImjCaE.js";import"./69_IOA4Y.js";import{i as me}from"./CbajjPbm.js";import{H as ge}from"./BJiluzmF.js";import{I as ke}from"./CM27iA0o.js";import{C as be}from"./Bpxj4ei_.js";const ye=[];function Ce(t,e=!1,n=!1){return N(t,new Map,"",ye,null,n)}function N(t,e,n,r,s=null,f=!1){if(typeof t=="object"&&t!==null){var h=e.get(t);if(h!==void 0)return h;if(t instanceof Map)return new Map(t);if(t instanceof Set)return new Set(t);if($(t)){var o=Array(t.length);e.set(t,o),s!==null&&e.set(s,o);for(var u=0;u<t.length;u+=1){var w=t[u];u in t&&(o[u]=N(w,e,n,r,null,f))}return o}if(ee(t)===te){o={},e.set(t,o),s!==null&&e.set(s,o);for(var k in t)o[k]=N(t[k],e,n,r,null,f);return o}if(t instanceof Date)return structuredClone(t);if(typeof t.toJSON=="function"&&!f)return N(t.toJSON(),e,n,r,t)}if(t instanceof EventTarget)return t;try{return structuredClone(t)}catch{return t}}const ve=le({component:"checkbox",parts:["root","group","group-label","input"]}),xe=new Q("Checkbox.Group"),Y=new Q("Checkbox.Root");class j{static create(e,n=null){return Y.set(new j(e,n))}opts;group;#e=d(()=>this.group&&this.group.opts.name.current?this.group.opts.name.current:this.opts.name.current);get trueName(){return a(this.#e)}set trueName(e){g(this.#e,e)}#t=d(()=>this.group&&this.group.opts.required.current?!0:this.opts.required.current);get trueRequired(){return a(this.#t)}set trueRequired(e){g(this.#t,e)}#r=d(()=>this.group&&this.group.opts.disabled.current?!0:this.opts.disabled.current);get trueDisabled(){return a(this.#r)}set trueDisabled(e){g(this.#r,e)}#s=d(()=>this.group&&this.group.opts.readonly.current?!0:this.opts.readonly.current);get trueReadonly(){return a(this.#s)}set trueReadonly(e){g(this.#s,e)}attachment;constructor(e,n){this.opts=e,this.group=n,this.attachment=de(this.opts.ref),this.onkeydown=this.onkeydown.bind(this),this.onclick=this.onclick.bind(this),H.pre([()=>Ce(this.group?.opts.value.current),()=>this.opts.value.current],([r,s])=>{!r||!s||(this.opts.checked.current=r.includes(s))}),H.pre(()=>this.opts.checked.current,r=>{this.group&&(r?this.group?.addValue(this.opts.value.current):this.group?.removeValue(this.opts.value.current))})}onkeydown(e){this.trueDisabled||this.trueReadonly||(e.key===ae&&e.preventDefault(),e.key===ue&&(e.preventDefault(),this.#n()))}#n(){this.opts.indeterminate.current?(this.opts.indeterminate.current=!1,this.opts.checked.current=!0):this.opts.checked.current=!this.opts.checked.current}onclick(e){if(!(this.trueDisabled||this.trueReadonly)){if(this.opts.type.current==="submit"){this.#n();return}e.preventDefault(),this.#n()}}#i=d(()=>({checked:this.opts.checked.current,indeterminate:this.opts.indeterminate.current}));get snippetProps(){return a(this.#i)}set snippetProps(e){g(this.#i,e)}#o=d(()=>({id:this.opts.id.current,role:"checkbox",type:this.opts.type.current,disabled:this.trueDisabled,"aria-checked":he(this.opts.checked.current,this.opts.indeterminate.current),"aria-required":V(this.trueRequired),"aria-readonly":V(this.trueReadonly),"data-disabled":U(this.trueDisabled),"data-readonly":U(this.trueReadonly),"data-state":_e(this.opts.checked.current,this.opts.indeterminate.current),[ve.root]:"",onclick:this.onclick,onkeydown:this.onkeydown,...this.attachment}));get props(){return a(this.#o)}set props(e){g(this.#o,e)}}class L{static create(){return new L(Y.get())}root;#e=d(()=>this.root.group?!!(this.root.opts.value.current!==void 0&&this.root.group.opts.value.current.includes(this.root.opts.value.current)):this.root.opts.checked.current);get trueChecked(){return a(this.#e)}set trueChecked(e){g(this.#e,e)}#t=d(()=>!!this.root.trueName);get shouldRender(){return a(this.#t)}set shouldRender(e){g(this.#t,e)}constructor(e){this.root=e,this.onfocus=this.onfocus.bind(this)}onfocus(e){ce(this.root.opts.ref.current)&&this.root.opts.ref.current.focus()}#r=d(()=>({type:"checkbox",checked:this.root.opts.checked.current===!0,disabled:this.root.trueDisabled,required:this.root.trueRequired,name:this.root.trueName,value:this.root.opts.value.current,readonly:this.root.trueReadonly,onfocus:this.onfocus}));get props(){return a(this.#r)}set props(e){g(this.#r,e)}}function _e(t,e){return e?"indeterminate":t?"checked":"unchecked"}function Re(t,e){E(e,!1);const n=L.create();me();var r=D(),s=R(r);{var f=h=>{ge(h,J(()=>n.props))};I(s,h=>{n.shouldRender&&h(f)})}b(t,r),M()}var we=G("<button><!></button>"),qe=G("<!> <!>",1);function De(t,e){const n=re();E(e,!0);let r=l(e,"checked",15,!1),s=l(e,"ref",15,null),f=l(e,"disabled",3,!1),h=l(e,"required",3,!1),o=l(e,"name",3,void 0),u=l(e,"value",3,"on"),w=l(e,"id",19,()=>fe(n)),k=l(e,"indeterminate",15,!1),S=l(e,"type",3,"button"),y=W(e,["$$slots","$$events","$$legacy","checked","ref","onCheckedChange","children","disabled","required","name","value","id","indeterminate","onIndeterminateChange","child","type","readonly"]);const p=xe.getOr(null);p&&u()&&(p.opts.value.current.includes(u())?r(!0):r(!1)),H.pre(()=>u(),()=>{p&&u()&&(p.opts.value.current.includes(u())?r(!0):r(!1))});const C=j.create({checked:m(()=>r(),i=>{r(i),e.onCheckedChange?.(i)}),disabled:m(()=>f()??!1),required:m(()=>h()),name:m(()=>o()),value:m(()=>u()),id:m(()=>w()),ref:m(()=>s(),i=>s(i)),indeterminate:m(()=>k(),i=>{k(i),e.onIndeterminateChange?.(i)}),type:m(()=>S()),readonly:m(()=>!!e.readonly)},p),v=d(()=>pe({...y},C.props));var x=qe(),P=R(x);{var q=i=>{var c=D(),_=R(c);{let T=d(()=>({props:a(v),...C.snippetProps}));B(_,()=>e.child,()=>a(T))}b(i,c)},A=i=>{var c=we();oe(c,()=>({...a(v)}));var _=X(c);B(_,()=>e.children??F,()=>C.snippetProps),K(c),b(i,c)};I(P,i=>{e.child?i(q):i(A,!1)})}var O=ne(P,2);Re(O,{}),b(t,x),M()}function Se(t,e){E(e,!0);let n=W(e,["$$slots","$$events","$$legacy"]);const r=[["path",{d:"M5 12h14"}]];ke(t,J({name:"minus"},()=>n,{get iconNode(){return r},children:(s,f)=>{var h=D(),o=R(h);B(o,()=>e.children??F),b(s,h)},$$slots:{default:!0}})),M()}var Pe=G('<span class="flex items-center justify-center text-current"><!></span>');function Le(t,e){E(e,!0);let n=l(e,"ref",15,null),r=l(e,"checked",15,!1),s=l(e,"disabled",3,!1),f=W(e,["$$slots","$$events","$$legacy","ref","checked","onCheckedChange","class","disabled"]);const h=d(()=>r()===!0),o=d(()=>r()==="indeterminate");function u(y){const p=y;r(p),e.onCheckedChange?.(p)}function w(y){y&&(r("indeterminate"),e.onCheckedChange?.("indeterminate"))}var k=D(),S=R(k);{const y=(C,v)=>{let x=()=>v?.().checked,P=()=>v?.().indeterminate;var q=Pe(),A=X(q);{var O=c=>{Se(c,{class:"size-3"})},i=c=>{var _=D(),T=R(_);{var Z=z=>{be(z,{class:"size-3"})};I(T,z=>{x()&&z(Z)},!0)}b(c,_)};I(A,c=>{P()?c(O):c(i,!1)})}K(q),b(C,q)};let p=d(()=>ie("peer size-4 shrink-0 rounded-[4px] border border-input bg-background transition-colors dark:border-white","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50","data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground","data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground",e.class));se(S,()=>De,(C,v)=>{v(C,J({get checked(){return a(h)},get indeterminate(){return a(o)},onCheckedChange:u,onIndeterminateChange:w,get disabled(){return s()},get class(){return a(p)}},()=>f,{get ref(){return n()},set ref(x){n(x)},children:y,$$slots:{default:!0}}))})}b(t,k),M()}export{Le as C,Ce as s};