@json-to-office/jto 0.1.0 → 0.1.1
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/README.md +20 -5
- package/dist/cli.js +1 -1
- package/dist/client/assets/{HomePage-CGK1cPFp.js → HomePage-D9PVR0H8.js} +3 -3
- package/dist/client/assets/{HomePage-CGK1cPFp.js.map → HomePage-D9PVR0H8.js.map} +1 -1
- package/dist/client/assets/{JsonEditorPage-DKaFqYpM.js → JsonEditorPage-bCBt1A49.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-DKaFqYpM.js.map → JsonEditorPage-bCBt1A49.js.map} +1 -1
- package/dist/client/assets/{button-B5W5GwSc.js → button-CMkwEplC.js} +2 -2
- package/dist/client/assets/{button-B5W5GwSc.js.map → button-CMkwEplC.js.map} +1 -1
- package/dist/client/assets/{editor-CH_tiHyn.js → editor-CtwF-qwA.js} +2 -2
- package/dist/client/assets/{editor-CH_tiHyn.js.map → editor-CtwF-qwA.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-8I2epq6g.js → editor-monaco-json-DHRbpQ-v.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-8I2epq6g.js.map → editor-monaco-json-DHRbpQ-v.js.map} +1 -1
- package/dist/client/assets/{index-DactvF4v.js → index-CGQAncgl.js} +3 -3
- package/dist/client/assets/index-CGQAncgl.js.map +1 -0
- package/dist/client/assets/{preview-CJlTPgks.js → preview-38guLS86.js} +2 -2
- package/dist/client/assets/{preview-CJlTPgks.js.map → preview-38guLS86.js.map} +1 -1
- package/dist/client/assets/{settings-store-provider-DuCKtwqs.js → settings-store-provider-BEzje7_o.js} +2 -2
- package/dist/client/assets/{settings-store-provider-DuCKtwqs.js.map → settings-store-provider-BEzje7_o.js.map} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +6 -6
- package/dist/client/assets/index-DactvF4v.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-
|
|
2
|
-
var Bp=Object.defineProperty;var Up=(e,t,n)=>t in e?Bp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ga=(e,t,n)=>Up(e,typeof t!="symbol"?t+"":t,n);import{j as c,b as Jp}from"./query-vendor-UL64zsGL.js";import{a as _e,f as xu,h as ia,i as yu,r as b,j as bu,k as vi,l as wi,D as ki,m as _i,n as vu,o as qp,V as Hp,p as wu,I as Wp,q as Gp,s as ku,t as Kp,v as _u,w as Yp,x as Xp,G as Qp,S as Su,y as ju,L as Nu,z as Cu,A as eh,E as th,F as nh,H as Eu,J as Iu,K as Tu,M as Au,N as zu,Q as Ou,U as Pu,W as Du,X as Ru,Y as Mu,Z as Fu,_ as rh,$ as ih,a0 as $u,a1 as sh,a2 as ah,a3 as Lu,a4 as Zu,a5 as Vu,a6 as oh,a7 as lh,a8 as uh,a9 as ch,aa as dh,ab as fh,ac as Bu,ad as Uu,ae as Ju,af as qu,ag as Hu,ah as Wu,ai as Gu,aj as Ku,ak as Yu,al as ph,am as hh,an as mh,ao as gh,ap as xh,g as sa}from"./react-vendor-DhdcN9D5.js";import{B as xe}from"./button-B5W5GwSc.js";import{c as B,T as Tr,C as yh,E as bh,F as bt,S as qt,a as vh,b as Ge,d as Ke,e as Ye,u as Si,f as $t,g as Xu,s as Zi,_ as Qu,h as Ar,A as wh,i as zr}from"./index-DactvF4v.js";import{X as hn,a as _r,C as pn,b as Kt,d as kh,e as fr,f as ec,P as _h,g as Ka,h as Qn,F as ks,S as tc,i as Ya,j as Xa,k as Qa,I as nc,l as rc,E as Yr,m as aa,n as Sh,M as jh,o as Nh,p as Ch,q as ic,r as Eh,s as Vi,t as Xr,u as eo,G as Ih,v as Th,R as Ah,w as zh,T as sc,x as Oh,y as Ph,z as ac,A as oa,B as Dh,D as oc,H as Rh,J as Mh,K as to,L as Fh,N as _s,O as $h}from"./ui-vendor-C6DsfOoA.js";import{S as Ln}from"./radix-ui-CXavUarI.js";import{i as Lh,u as qe,a as lc,b as on,g as Ss,c as Or,S as Zh,O as Vh,T as Bh,D as Uh}from"./settings-store-provider-DuCKtwqs.js";import{a as Jh,d as qh,p as Hh,b as Wh,u as Gh,e as Kh}from"./state-vendor-CAMVKh-F.js";var Sr=e=>e.type==="checkbox",dn=e=>e instanceof Date,it=e=>e==null;const uc=e=>typeof e=="object";var Ve=e=>!it(e)&&!Array.isArray(e)&&uc(e)&&!dn(e),cc=e=>Ve(e)&&e.target?Sr(e.target)?e.target.checked:e.target.value:e,Yh=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,dc=(e,t)=>e.has(Yh(t)),Xh=e=>{const t=e.constructor&&e.constructor.prototype;return Ve(t)&&t.hasOwnProperty("isPrototypeOf")},la=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function lt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(la&&(e instanceof Blob||r))&&(n||Ve(e)))if(t=n?[]:{},!n&&!Xh(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=lt(e[i]));else return e;return t}var ji=e=>Array.isArray(e)?e.filter(Boolean):[],Ze=e=>e===void 0,X=(e,t,n)=>{if(!t||!Ve(e))return n;const r=ji(t.split(/[,[\].]+?/)).reduce((i,s)=>it(i)?i:i[s],e);return Ze(r)||r===e?Ze(e[t])?n:e[t]:r},xt=e=>typeof e=="boolean",ua=e=>/^\w*$/.test(e),fc=e=>ji(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Ce=(e,t,n)=>{let r=-1;const i=ua(t)?[t]:fc(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let u=n;if(r!==a){const l=e[o];u=Ve(l)||Array.isArray(l)?l:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=u,e=e[o]}return e};const Qr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},jt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},pc=_e.createContext(null),Ni=()=>_e.useContext(pc),Qh=e=>{const{children:t,...n}=e;return _e.createElement(pc.Provider,{value:n},t)};var hc=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==jt.all&&(t._proxyFormState[a]=!r||jt.all),n&&(n[a]=!0),e[a]}});return i},ut=e=>Ve(e)&&!Object.keys(e).length,mc=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return ut(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||jt.all))},ar=e=>Array.isArray(e)?e:[e],gc=(e,t,n)=>!e||!t||e===t||ar(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function ca(e){const t=_e.useRef(e);t.current=e,_e.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function em(e){const t=Ni(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=_e.useState(n._formState),u=_e.useRef(!0),l=_e.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=_e.useRef(i);return f.current=i,ca({disabled:r,next:d=>u.current&&gc(f.current,d.name,s)&&mc(d,l.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),_e.useEffect(()=>(u.current=!0,l.current.isValid&&n._updateValid(!0),()=>{u.current=!1}),[n]),_e.useMemo(()=>hc(a,n,l.current,!1),[a,n])}var At=e=>typeof e=="string",xc=(e,t,n,r,i)=>At(e)?(r&&t.watch.add(e),X(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),X(n,s))):(r&&(t.watchAll=!0),n);function tm(e){const t=Ni(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=_e.useRef(r);o.current=r,ca({disabled:s,subject:n._subjects.values,next:f=>{gc(o.current,f.name,a)&&l(lt(xc(o.current,n._names,f.values||n._formValues,!1,i)))}});const[u,l]=_e.useState(n._getWatch(r,i));return _e.useEffect(()=>n._removeUnmounted()),u}function nm(e){const t=Ni(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=dc(i._names.array,n),o=tm({control:i,name:n,defaultValue:X(i._formValues,n,X(i._defaultValues,n,e.defaultValue)),exact:!0}),u=em({control:i,name:n,exact:!0}),l=_e.useRef(i.register(n,{...e.rules,value:o,...xt(e.disabled)?{disabled:e.disabled}:{}})),f=_e.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!X(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!X(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!X(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!X(u.validatingFields,n)},error:{enumerable:!0,get:()=>X(u.errors,n)}}),[u,n]),d=_e.useMemo(()=>({name:n,value:o,...xt(r)||u.disabled?{disabled:u.disabled||r}:{},onChange:h=>l.current.onChange({target:{value:cc(h),name:n},type:Qr.CHANGE}),onBlur:()=>l.current.onBlur({target:{value:X(i._formValues,n),name:n},type:Qr.BLUR}),ref:h=>{const p=X(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:g=>h.setCustomValidity(g),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,u.disabled,o,i._fields]);return _e.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(g,w)=>{const S=X(i._fields,g);S&&S._f&&(S._f.mount=w)};if(p(n,!0),h){const g=lt(X(i._options.defaultValues,n));Ce(i._defaultValues,n,g),Ze(X(i._formValues,n))&&Ce(i._formValues,n,g)}return!a&&i.register(n),()=>{(a?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,a,s]),_e.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),_e.useMemo(()=>({field:d,formState:u,fieldState:f}),[d,u,f])}const rm=e=>e.render(nm(e));var im=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},no=e=>({isOnSubmit:!e||e===jt.onSubmit,isOnBlur:e===jt.onBlur,isOnChange:e===jt.onChange,isOnAll:e===jt.all,isOnTouch:e===jt.onTouched}),ro=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const or=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=X(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(or(o,t))break}else if(Ve(o)&&or(o,t))break}}};var sm=(e,t,n)=>{const r=ar(X(e,n));return Ce(r,"root",t[n]),Ce(e,n,r),e},da=e=>e.type==="file",Tt=e=>typeof e=="function",ei=e=>{if(!la)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Br=e=>At(e),fa=e=>e.type==="radio",ti=e=>e instanceof RegExp;const io={value:!1,isValid:!1},so={value:!0,isValid:!0};var yc=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ze(e[0].attributes.value)?Ze(e[0].value)||e[0].value===""?so:{value:e[0].value,isValid:!0}:so:io}return io};const ao={isValid:!1,value:null};var bc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,ao):ao;function oo(e,t,n="validate"){if(Br(e)||Array.isArray(e)&&e.every(Br)||xt(e)&&!e)return{type:n,message:Br(e)?e:"",ref:t}}var wn=e=>Ve(e)&&!ti(e)?e:{value:e,message:""},lo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:u,maxLength:l,minLength:f,min:d,max:h,pattern:p,validate:g,name:w,valueAsNumber:S,mount:y}=e._f,_=X(n,w);if(!y||t.has(w))return{};const x=o?o[0]:a,D=Z=>{i&&x.reportValidity&&(x.setCustomValidity(xt(Z)?"":Z||""),x.reportValidity())},I={},k=fa(a),E=Sr(a),L=k||E,G=(S||da(a))&&Ze(a.value)&&Ze(_)||ei(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,C=im.bind(null,w,r,I),J=(Z,V,z,A=Ft.maxLength,q=Ft.minLength)=>{const F=Z?V:z;I[w]={type:Z?A:q,message:F,ref:a,...C(Z?A:q,F)}};if(s?!Array.isArray(_)||!_.length:u&&(!L&&(G||it(_))||xt(_)&&!_||E&&!yc(o).isValid||k&&!bc(o).isValid)){const{value:Z,message:V}=Br(u)?{value:!!u,message:u}:wn(u);if(Z&&(I[w]={type:Ft.required,message:V,ref:x,...C(Ft.required,V)},!r))return D(V),I}if(!G&&(!it(d)||!it(h))){let Z,V;const z=wn(h),A=wn(d);if(!it(_)&&!isNaN(_)){const q=a.valueAsNumber||_&&+_;it(z.value)||(Z=q>z.value),it(A.value)||(V=q<A.value)}else{const q=a.valueAsDate||new Date(_),F=m=>new Date(new Date().toDateString()+" "+m),N=a.type=="time",R=a.type=="week";At(z.value)&&_&&(Z=N?F(_)>F(z.value):R?_>z.value:q>new Date(z.value)),At(A.value)&&_&&(V=N?F(_)<F(A.value):R?_<A.value:q<new Date(A.value))}if((Z||V)&&(J(!!Z,z.message,A.message,Ft.max,Ft.min),!r))return D(I[w].message),I}if((l||f)&&!G&&(At(_)||s&&Array.isArray(_))){const Z=wn(l),V=wn(f),z=!it(Z.value)&&_.length>+Z.value,A=!it(V.value)&&_.length<+V.value;if((z||A)&&(J(z,Z.message,V.message),!r))return D(I[w].message),I}if(p&&!G&&At(_)){const{value:Z,message:V}=wn(p);if(ti(Z)&&!_.match(Z)&&(I[w]={type:Ft.pattern,message:V,ref:a,...C(Ft.pattern,V)},!r))return D(V),I}if(g){if(Tt(g)){const Z=await g(_,n),V=oo(Z,x);if(V&&(I[w]={...V,...C(Ft.validate,V.message)},!r))return D(V.message),I}else if(Ve(g)){let Z={};for(const V in g){if(!ut(Z)&&!r)break;const z=oo(await g[V](_,n),x,V);z&&(Z={...z,...C(V,z.message)},D(z.message),r&&(I[w]=Z))}if(!ut(Z)&&(I[w]={ref:x,...Z},!r))return I}}return D(!0),I};function am(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Ze(e)?r++:e[t[r++]];return e}function om(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ze(e[t]))return!1;return!0}function We(e,t){const n=Array.isArray(t)?t:ua(t)?[t]:fc(t),r=n.length===1?e:am(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Ve(r)&&ut(r)||Array.isArray(r)&&om(r))&&We(e,n.slice(0,-1)),e}var Bi=()=>{let e=[];return{get observers(){return e},next:i=>{for(const s of e)s.next&&s.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(s=>s!==i)}}),unsubscribe:()=>{e=[]}}},js=e=>it(e)||!uc(e);function Ht(e,t){if(js(e)||js(t))return e===t;if(dn(e)&&dn(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const a=t[i];if(dn(s)&&dn(a)||Ve(s)&&Ve(a)||Array.isArray(s)&&Array.isArray(a)?!Ht(s,a):s!==a)return!1}}return!0}var vc=e=>e.type==="select-multiple",lm=e=>fa(e)||Sr(e),Ui=e=>ei(e)&&e.isConnected,wc=e=>{for(const t in e)if(Tt(e[t]))return!0;return!1};function ni(e,t={}){const n=Array.isArray(e);if(Ve(e)||n)for(const r in e)Array.isArray(e[r])||Ve(e[r])&&!wc(e[r])?(t[r]=Array.isArray(e[r])?[]:{},ni(e[r],t[r])):it(e[r])||(t[r]=!0);return t}function kc(e,t,n){const r=Array.isArray(e);if(Ve(e)||r)for(const i in e)Array.isArray(e[i])||Ve(e[i])&&!wc(e[i])?Ze(t)||js(n[i])?n[i]=Array.isArray(e[i])?ni(e[i],[]):{...ni(e[i])}:kc(e[i],it(t)?{}:t[i],n[i]):n[i]=!Ht(e[i],t[i]);return n}var Jn=(e,t)=>kc(e,t,ni(t)),_c=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ze(e)?e:t?e===""?NaN:e&&+e:n&&At(e)?new Date(e):r?r(e):e;function Ji(e){const t=e.ref;return da(t)?t.files:fa(t)?bc(e.refs).value:vc(t)?[...t.selectedOptions].map(({value:n})=>n):Sr(t)?yc(e.refs).value:_c(Ze(t.value)?e.ref.value:t.value,e)}var um=(e,t,n,r)=>{const i={};for(const s of e){const a=X(t,s);a&&Ce(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},qn=e=>Ze(e)?e:ti(e)?e.source:Ve(e)?ti(e.value)?e.value.source:e.value:e;const uo="AsyncFunction";var cm=e=>!!e&&!!e.validate&&!!(Tt(e.validate)&&e.validate.constructor.name===uo||Ve(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===uo)),dm=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function co(e,t,n){const r=X(e,n);if(r||ua(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=X(t,s),o=X(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var fm=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,pm=(e,t)=>!ji(X(e,t)).length&&We(e,t);const hm={mode:jt.onSubmit,reValidateMode:jt.onChange,shouldFocusError:!0};function mm(e={}){let t={...hm,...e},n={submitCount:0,isDirty:!1,isLoading:Tt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=Ve(t.defaultValues)||Ve(t.values)?lt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:lt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u,l=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:Bi(),array:Bi(),state:Bi()},h=no(t.mode),p=no(t.reValidateMode),g=t.criteriaMode===jt.all,w=j=>T=>{clearTimeout(l),l=setTimeout(j,T)},S=async j=>{if(!t.disabled&&(f.isValid||j)){const T=t.resolver?ut((await L()).errors):await C(r,!0);T!==n.isValid&&d.state.next({isValid:T})}},y=(j,T)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((j||Array.from(o.mount)).forEach(M=>{M&&(T?Ce(n.validatingFields,M,T):We(n.validatingFields,M))}),d.state.next({validatingFields:n.validatingFields,isValidating:!ut(n.validatingFields)}))},_=(j,T=[],M,Q,K=!0,W=!0)=>{if(Q&&M&&!t.disabled){if(a.action=!0,W&&Array.isArray(X(r,j))){const ie=M(X(r,j),Q.argA,Q.argB);K&&Ce(r,j,ie)}if(W&&Array.isArray(X(n.errors,j))){const ie=M(X(n.errors,j),Q.argA,Q.argB);K&&Ce(n.errors,j,ie),pm(n.errors,j)}if(f.touchedFields&&W&&Array.isArray(X(n.touchedFields,j))){const ie=M(X(n.touchedFields,j),Q.argA,Q.argB);K&&Ce(n.touchedFields,j,ie)}f.dirtyFields&&(n.dirtyFields=Jn(i,s)),d.state.next({name:j,isDirty:Z(j,T),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Ce(s,j,T)},x=(j,T)=>{Ce(n.errors,j,T),d.state.next({errors:n.errors})},D=j=>{n.errors=j,d.state.next({errors:n.errors,isValid:!1})},I=(j,T,M,Q)=>{const K=X(r,j);if(K){const W=X(s,j,Ze(M)?X(i,j):M);Ze(W)||Q&&Q.defaultChecked||T?Ce(s,j,T?W:Ji(K._f)):A(j,W),a.mount&&S()}},k=(j,T,M,Q,K)=>{let W=!1,ie=!1;const he={name:j};if(!t.disabled){const P=!!(X(r,j)&&X(r,j)._f&&X(r,j)._f.disabled);if(!M||Q){f.isDirty&&(ie=n.isDirty,n.isDirty=he.isDirty=Z(),W=ie!==he.isDirty);const U=P||Ht(X(i,j),T);ie=!!(!P&&X(n.dirtyFields,j)),U||P?We(n.dirtyFields,j):Ce(n.dirtyFields,j,!0),he.dirtyFields=n.dirtyFields,W=W||f.dirtyFields&&ie!==!U}if(M){const U=X(n.touchedFields,j);U||(Ce(n.touchedFields,j,M),he.touchedFields=n.touchedFields,W=W||f.touchedFields&&U!==M)}W&&K&&d.state.next(he)}return W?he:{}},E=(j,T,M,Q)=>{const K=X(n.errors,j),W=f.isValid&&xt(T)&&n.isValid!==T;if(t.delayError&&M?(u=w(()=>x(j,M)),u(t.delayError)):(clearTimeout(l),u=null,M?Ce(n.errors,j,M):We(n.errors,j)),(M?!Ht(K,M):K)||!ut(Q)||W){const ie={...Q,...W&&xt(T)?{isValid:T}:{},errors:n.errors,name:j};n={...n,...ie},d.state.next(ie)}},L=async j=>{y(j,!0);const T=await t.resolver(s,t.context,um(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(j),T},G=async j=>{const{errors:T}=await L(j);if(j)for(const M of j){const Q=X(T,M);Q?Ce(n.errors,M,Q):We(n.errors,M)}else n.errors=T;return T},C=async(j,T,M={valid:!0})=>{for(const Q in j){const K=j[Q];if(K){const{_f:W,...ie}=K;if(W){const he=o.array.has(W.name),P=K._f&&cm(K._f);P&&f.validatingFields&&y([Q],!0);const U=await lo(K,o.disabled,s,g,t.shouldUseNativeValidation&&!T,he);if(P&&f.validatingFields&&y([Q]),U[W.name]&&(M.valid=!1,T))break;!T&&(X(U,W.name)?he?sm(n.errors,U,W.name):Ce(n.errors,W.name,U[W.name]):We(n.errors,W.name))}!ut(ie)&&await C(ie,T,M)}}return M.valid},J=()=>{for(const j of o.unMount){const T=X(r,j);T&&(T._f.refs?T._f.refs.every(M=>!Ui(M)):!Ui(T._f.ref))&&de(j)}o.unMount=new Set},Z=(j,T)=>!t.disabled&&(j&&T&&Ce(s,j,T),!Ht(ee(),i)),V=(j,T,M)=>xc(j,o,{...a.mount?s:Ze(T)?i:At(j)?{[j]:T}:T},M,T),z=j=>ji(X(a.mount?s:i,j,t.shouldUnregister?X(i,j,[]):[])),A=(j,T,M={})=>{const Q=X(r,j);let K=T;if(Q){const W=Q._f;W&&(!W.disabled&&Ce(s,j,_c(T,W)),K=ei(W.ref)&&it(T)?"":T,vc(W.ref)?[...W.ref.options].forEach(ie=>ie.selected=K.includes(ie.value)):W.refs?Sr(W.ref)?W.refs.length>1?W.refs.forEach(ie=>(!ie.defaultChecked||!ie.disabled)&&(ie.checked=Array.isArray(K)?!!K.find(he=>he===ie.value):K===ie.value)):W.refs[0]&&(W.refs[0].checked=!!K):W.refs.forEach(ie=>ie.checked=ie.value===K):da(W.ref)?W.ref.value="":(W.ref.value=K,W.ref.type||d.values.next({name:j,values:{...s}})))}(M.shouldDirty||M.shouldTouch)&&k(j,K,M.shouldTouch,M.shouldDirty,!0),M.shouldValidate&&m(j)},q=(j,T,M)=>{for(const Q in T){const K=T[Q],W=`${j}.${Q}`,ie=X(r,W);(o.array.has(j)||Ve(K)||ie&&!ie._f)&&!dn(K)?q(W,K,M):A(W,K,M)}},F=(j,T,M={})=>{const Q=X(r,j),K=o.array.has(j),W=lt(T);Ce(s,j,W),K?(d.array.next({name:j,values:{...s}}),(f.isDirty||f.dirtyFields)&&M.shouldDirty&&d.state.next({name:j,dirtyFields:Jn(i,s),isDirty:Z(j,W)})):Q&&!Q._f&&!it(W)?q(j,W,M):A(j,W,M),ro(j,o)&&d.state.next({...n}),d.values.next({name:a.mount?j:void 0,values:{...s}})},N=async j=>{a.mount=!0;const T=j.target;let M=T.name,Q=!0;const K=X(r,M),W=()=>T.type?Ji(K._f):cc(j),ie=he=>{Q=Number.isNaN(he)||dn(he)&&isNaN(he.getTime())||Ht(he,X(s,M,he))};if(K){let he,P;const U=W(),se=j.type===Qr.BLUR||j.type===Qr.FOCUS_OUT,ge=!dm(K._f)&&!t.resolver&&!X(n.errors,M)&&!K._f.deps||fm(se,X(n.touchedFields,M),n.isSubmitted,p,h),O=ro(M,o,se);Ce(s,M,U),se?(K._f.onBlur&&K._f.onBlur(j),u&&u(0)):K._f.onChange&&K._f.onChange(j);const oe=k(M,U,se,!1),be=!ut(oe)||O;if(!se&&d.values.next({name:M,type:j.type,values:{...s}}),ge)return f.isValid&&(t.mode==="onBlur"&&se?S():se||S()),be&&d.state.next({name:M,...O?{}:oe});if(!se&&O&&d.state.next({...n}),t.resolver){const{errors:Te}=await L([M]);if(ie(U),Q){const He=co(n.errors,r,M),Ue=co(Te,r,He.name||M);he=Ue.error,M=Ue.name,P=ut(Te)}}else y([M],!0),he=(await lo(K,o.disabled,s,g,t.shouldUseNativeValidation))[M],y([M]),ie(U),Q&&(he?P=!1:f.isValid&&(P=await C(r,!0)));Q&&(K._f.deps&&m(K._f.deps),E(M,P,he,oe))}},R=(j,T)=>{if(X(n.errors,T)&&j.focus)return j.focus(),1},m=async(j,T={})=>{let M,Q;const K=ar(j);if(t.resolver){const W=await G(Ze(j)?j:K);M=ut(W),Q=j?!K.some(ie=>X(W,ie)):M}else j?(Q=(await Promise.all(K.map(async W=>{const ie=X(r,W);return await C(ie&&ie._f?{[W]:ie}:ie)}))).every(Boolean),!(!Q&&!n.isValid)&&S()):Q=M=await C(r);return d.state.next({...!At(j)||f.isValid&&M!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:M}:{},errors:n.errors}),T.shouldFocus&&!Q&&or(r,R,j?K:o.mount),Q},ee=j=>{const T={...a.mount?s:i};return Ze(j)?T:At(j)?X(T,j):j.map(M=>X(T,M))},ne=(j,T)=>({invalid:!!X((T||n).errors,j),isDirty:!!X((T||n).dirtyFields,j),error:X((T||n).errors,j),isValidating:!!X(n.validatingFields,j),isTouched:!!X((T||n).touchedFields,j)}),v=j=>{j&&ar(j).forEach(T=>We(n.errors,T)),d.state.next({errors:j?n.errors:{}})},re=(j,T,M)=>{const Q=(X(r,j,{_f:{}})._f||{}).ref,K=X(n.errors,j)||{},{ref:W,message:ie,type:he,...P}=K;Ce(n.errors,j,{...P,...T,ref:Q}),d.state.next({name:j,errors:n.errors,isValid:!1}),M&&M.shouldFocus&&Q&&Q.focus&&Q.focus()},fe=(j,T)=>Tt(j)?d.values.subscribe({next:M=>j(V(void 0,T),M)}):V(j,T,!0),de=(j,T={})=>{for(const M of j?ar(j):o.mount)o.mount.delete(M),o.array.delete(M),T.keepValue||(We(r,M),We(s,M)),!T.keepError&&We(n.errors,M),!T.keepDirty&&We(n.dirtyFields,M),!T.keepTouched&&We(n.touchedFields,M),!T.keepIsValidating&&We(n.validatingFields,M),!t.shouldUnregister&&!T.keepDefaultValue&&We(i,M);d.values.next({values:{...s}}),d.state.next({...n,...T.keepDirty?{isDirty:Z()}:{}}),!T.keepIsValid&&S()},ae=({disabled:j,name:T,field:M,fields:Q})=>{(xt(j)&&a.mount||j||o.disabled.has(T))&&(j?o.disabled.add(T):o.disabled.delete(T),k(T,Ji(M?M._f:X(Q,T)._f),!1,!1,!0))},le=(j,T={})=>{let M=X(r,j);const Q=xt(T.disabled)||xt(t.disabled);return Ce(r,j,{...M||{},_f:{...M&&M._f?M._f:{ref:{name:j}},name:j,mount:!0,...T}}),o.mount.add(j),M?ae({field:M,disabled:xt(T.disabled)?T.disabled:t.disabled,name:j}):I(j,!0,T.value),{...Q?{disabled:T.disabled||t.disabled}:{},...t.progressive?{required:!!T.required,min:qn(T.min),max:qn(T.max),minLength:qn(T.minLength),maxLength:qn(T.maxLength),pattern:qn(T.pattern)}:{},name:j,onChange:N,onBlur:N,ref:K=>{if(K){le(j,T),M=X(r,j);const W=Ze(K.value)&&K.querySelectorAll&&K.querySelectorAll("input,select,textarea")[0]||K,ie=lm(W),he=M._f.refs||[];if(ie?he.find(P=>P===W):W===M._f.ref)return;Ce(r,j,{_f:{...M._f,...ie?{refs:[...he.filter(Ui),W,...Array.isArray(X(i,j))?[{}]:[]],ref:{type:W.type,name:j}}:{ref:W}}}),I(j,!1,void 0,W)}else M=X(r,j,{}),M._f&&(M._f.mount=!1),(t.shouldUnregister||T.shouldUnregister)&&!(dc(o.array,j)&&a.action)&&o.unMount.add(j)}}},je=()=>t.shouldFocusError&&or(r,R,o.mount),Le=j=>{xt(j)&&(d.state.next({disabled:j}),or(r,(T,M)=>{const Q=X(r,M);Q&&(T.disabled=Q._f.disabled||j,Array.isArray(Q._f.refs)&&Q._f.refs.forEach(K=>{K.disabled=Q._f.disabled||j}))},0,!1))},Be=(j,T)=>async M=>{let Q;M&&(M.preventDefault&&M.preventDefault(),M.persist&&M.persist());let K=lt(s);if(o.disabled.size)for(const W of o.disabled)Ce(K,W,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:W,values:ie}=await L();n.errors=W,K=ie}else await C(r);if(We(n.errors,"root"),ut(n.errors)){d.state.next({errors:{}});try{await j(K,M)}catch(W){Q=W}}else T&&await T({...n.errors},M),je(),setTimeout(je);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ut(n.errors)&&!Q,submitCount:n.submitCount+1,errors:n.errors}),Q)throw Q},mt=(j,T={})=>{X(r,j)&&(Ze(T.defaultValue)?F(j,lt(X(i,j))):(F(j,T.defaultValue),Ce(i,j,lt(T.defaultValue))),T.keepTouched||We(n.touchedFields,j),T.keepDirty||(We(n.dirtyFields,j),n.isDirty=T.defaultValue?Z(j,lt(X(i,j))):Z()),T.keepError||(We(n.errors,j),f.isValid&&S()),d.state.next({...n}))},wt=(j,T={})=>{const M=j?lt(j):i,Q=lt(M),K=ut(j),W=K?i:Q;if(T.keepDefaultValues||(i=M),!T.keepValues){if(T.keepDirtyValues){const ie=new Set([...o.mount,...Object.keys(Jn(i,s))]);for(const he of Array.from(ie))X(n.dirtyFields,he)?Ce(W,he,X(s,he)):F(he,X(W,he))}else{if(la&&Ze(j))for(const ie of o.mount){const he=X(r,ie);if(he&&he._f){const P=Array.isArray(he._f.refs)?he._f.refs[0]:he._f.ref;if(ei(P)){const U=P.closest("form");if(U){U.reset();break}}}}r={}}s=t.shouldUnregister?T.keepDefaultValues?lt(i):{}:lt(W),d.array.next({values:{...W}}),d.values.next({values:{...W}})}o={mount:T.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!T.keepIsValid||!!T.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:T.keepSubmitCount?n.submitCount:0,isDirty:K?!1:T.keepDirty?n.isDirty:!!(T.keepDefaultValues&&!Ht(j,i)),isSubmitted:T.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:K?{}:T.keepDirtyValues?T.keepDefaultValues&&s?Jn(i,s):n.dirtyFields:T.keepDefaultValues&&j?Jn(i,j):T.keepDirty?n.dirtyFields:{},touchedFields:T.keepTouched?n.touchedFields:{},errors:T.keepErrors?n.errors:{},isSubmitSuccessful:T.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Me=(j,T)=>wt(Tt(j)?j(s):j,T);return{control:{register:le,unregister:de,getFieldState:ne,handleSubmit:Be,setError:re,_executeSchema:L,_getWatch:V,_getDirty:Z,_updateValid:S,_removeUnmounted:J,_updateFieldArray:_,_updateDisabledField:ae,_getFieldArray:z,_reset:wt,_resetDefaultValues:()=>Tt(t.defaultValues)&&t.defaultValues().then(j=>{Me(j,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:Le,_subjects:d,_proxyFormState:f,_setErrors:D,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:m,register:le,handleSubmit:Be,watch:fe,setValue:F,getValues:ee,reset:Me,resetField:mt,clearErrors:v,unregister:de,setError:re,setFocus:(j,T={})=>{const M=X(r,j),Q=M&&M._f;if(Q){const K=Q.refs?Q.refs[0]:Q.ref;K.focus&&(K.focus(),T.shouldSelect&&Tt(K.select)&&K.select())}},getFieldState:ne}}function gm(e={}){const t=_e.useRef(void 0),n=_e.useRef(void 0),[r,i]=_e.useState({isDirty:!1,isValidating:!1,isLoading:Tt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Tt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...mm(e),formState:r});const s=t.current.control;return s._options=e,ca({subject:s._subjects.state,next:a=>{mc(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),_e.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),_e.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),_e.useEffect(()=>{e.values&&!Ht(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),_e.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),_e.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),_e.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=hc(r,s),t.current}function xm(e){return async t=>{const n=e(t);if(n.success&&n.data)return{values:n.data,errors:{}};const r={};if(n.errors)for(const i of n.errors){const s=i.path||"root";r[s]||(r[s]={type:"validation",message:i.message})}return{values:{},errors:r}}}const Lt=xu,fo=yu,ym=bu,po=ia,Sc=b.forwardRef(({className:e,...t},n)=>c.jsx(_i,{ref:n,className:B("fixed inset-0 z-50 bg-black/80",e),...t}));Sc.displayName=_i.displayName;const zt=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ym,{children:[c.jsx(Sc,{}),c.jsxs(vi,{ref:r,className:B("bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg",e),...n,children:[t,c.jsxs(ia,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[c.jsx(hn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zt.displayName=vi.displayName;const mn=({className:e,...t})=>c.jsx("div",{className:B("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});mn.displayName="DialogHeader";const pr=({className:e,...t})=>c.jsx("div",{className:B("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});pr.displayName="DialogFooter";const gn=b.forwardRef(({className:e,...t},n)=>c.jsx(wi,{ref:n,className:B("text-lg leading-none font-semibold tracking-tight",e),...t}));gn.displayName=wi.displayName;const Dn=b.forwardRef(({className:e,...t},n)=>c.jsx(ki,{ref:n,className:B("text-muted-foreground text-sm",e),...t}));Dn.displayName=ki.displayName;const bm=_r("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),pa=b.forwardRef(({className:e,...t},n)=>c.jsx(vu,{ref:n,className:B(bm(),e),...t}));pa.displayName=vu.displayName;const vm=Qh,jc=b.createContext({}),ho=({...e})=>c.jsx(jc.Provider,{value:{name:e.name},children:c.jsx(rm,{...e})}),Ci=()=>{const e=b.useContext(jc),t=b.useContext(Nc),{getFieldState:n,formState:r}=Ni(),i=n(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:s}=t;return{id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...i}},Nc=b.createContext({}),Ns=b.forwardRef(({className:e,...t},n)=>{const r=b.useId();return c.jsx(Nc.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:B("space-y-2",e),...t})})});Ns.displayName="FormItem";const Cs=b.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=Ci();return c.jsx(pa,{ref:n,className:B(r&&"text-destructive",e),htmlFor:i,...t})});Cs.displayName="FormLabel";const Es=b.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=Ci();return c.jsx(Ln,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Es.displayName="FormControl";const Cc=b.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=Ci();return c.jsx("p",{ref:n,id:r,className:B("text-muted-foreground text-[0.8rem]",e),...t})});Cc.displayName="FormDescription";const Is=b.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=Ci(),a=i?String(i==null?void 0:i.message):t;return a?c.jsx("p",{ref:r,id:s,className:B("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});Is.displayName="FormMessage";const ha=b.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:B("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ha.displayName="Input";const ma=qp,wm=Qp,ga=Hp,Ei=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(wu,{ref:r,className:B("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:truncate cursor-pointer",e),...n,children:[t,c.jsx(Wp,{asChild:!0,children:c.jsx(pn,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));Ei.displayName=wu.displayName;const Ec=b.forwardRef(({className:e,...t},n)=>c.jsx(Su,{ref:n,className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(kh,{className:"h-4 w-4"})}));Ec.displayName=Su.displayName;const Ic=b.forwardRef(({className:e,...t},n)=>c.jsx(ju,{ref:n,className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(pn,{className:"h-4 w-4"})}));Ic.displayName=ju.displayName;const Ii=b.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(Gp,{children:c.jsxs(ku,{ref:i,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(Ec,{}),c.jsx(Kp,{className:B("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Ic,{})]})}));Ii.displayName=ku.displayName;const Tc=b.forwardRef(({className:e,...t},n)=>c.jsx(Nu,{ref:n,className:B("px-2 py-1.5 text-sm font-semibold",e),...t}));Tc.displayName=Nu.displayName;const hr=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(_u,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Yp,{children:c.jsx(Kt,{className:"h-4 w-4"})})}),c.jsx(Xp,{children:t})]}));hr.displayName=_u.displayName;const km=b.forwardRef(({className:e,...t},n)=>c.jsx(Cu,{ref:n,className:B("bg-muted -mx-1 my-1 h-px",e),...t}));km.displayName=Cu.displayName;function xa(){const e=new Date,t=n=>String(n).padStart(2,"0");return`Chat ${t(e.getMonth()+1)}/${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`}const Ac=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),_m=(e=Ac())=>Jh()(qh(Hh((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,a)=>a!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),a={id:i,documentName:r,title:xa(),messages:[],createdAt:s,updatedAt:s};return t(o=>({threads:{...o.threads,[i]:a},activeThreadId:{...o.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const a=Object.fromEntries(Object.entries(i.threads).filter(([l])=>l!==r)),o=s.documentName,u={...i.activeThreadId};if(u[o]===r){const l=Object.values(a).filter(f=>f.documentName===o);l.length>0?(l.sort((f,d)=>d.updatedAt-f.updatedAt),u[o]=l[0].id):delete u[o]}t({threads:a,activeThreadId:u})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,u]of Object.entries(s))u.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[u,l]of Object.entries(a))l.documentName===r&&(a[u]={...l,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:Wh(()=>Lh),partialize:t=>({threads:t.threads,activeThreadId:t.activeThreadId,scope:t.scope,model:t.model}),migrate:(t,n)=>{if(n===0&&t){const r=t.chatMessages;if(Array.isArray(r)&&r.length>0){const i=crypto.randomUUID(),s=Date.now();return{threads:{[i]:{id:i,documentName:"__migrated__",title:"Migrated Chat",messages:r,createdAt:s,updatedAt:s}},activeThreadId:{__migrated__:i}}}return{threads:{},activeThreadId:{}}}return t}}))),zc=b.createContext(void 0),Sm=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=_m(Ac())),c.jsx(zc.Provider,{value:t.current,children:e})},Se=e=>{const t=b.useContext(zc);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return Gh(t,e)};function jm(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Nm(e,t,n){const r={},i=[];e!=="delete"&&(r.name=Tr.String({minLength:1,maxLength:120,pattern:"^[a-zA-Z0-9-_. ]+$",description:"Document name (e.g., my-report.docx.json or my-theme.theme.json)"}),i.push("name")),e==="create"&&(r.template=Tr.Optional(Tr.String({description:"Template selection"})));const s=Tr.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!yh(s,a))for(const l of bh(s,a))o.push({path:l.path.replace(/^\//,""),message:l.message});const u=a;if(e!=="delete"&&u.name){const l=u.name.trim();l?(u.name=l,t(l)||o.push({path:"name",message:"Document with this name already exists"})):o.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&u.template&&(n.some(l=>l.name===u.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?u:void 0,errors:o}}}}function Cm(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Em=e=>({create:{title:e?"New Theme":"New Document",description:e?"Create a new theme from scratch or based on discovered themes.":"Create a new document from scratch or based on discovered documents.",button:"Create",buttonVariant:"default"},update:{title:"Rename Document",description:"Give your document a new name.",button:"Save",buttonVariant:"default"},delete:{title:"Are you absolutely sure?",description:"This action cannot be undone. Are you sure you want to permanently delete this document?",button:"Confirm",buttonVariant:"destructive"}}),Hn="__empty__";function Im({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,u]=b.useState(!1),[l,f]=b.useState(null),d=Em(a),{documents:h,openTabs:p,createDocument:g,renameDocument:w,deleteDocument:S,openDocument:y,closeDocument:_}=qe(F=>F),{updateTheme:x}=lc(F=>F),D=Se(F=>F.renameThreadsForDocument),I=Se(F=>F.deleteThreadsForDocument),k=b.useMemo(()=>a?s||[]:i||[],[a,i,s]),E=b.useMemo(()=>{const F={current:[],downstream:[]};return k.forEach(N=>{F[N.location]&&F[N.location].push(N)}),F},[k]),L=b.useMemo(()=>k.map(F=>({name:F.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[k]),G=b.useMemo(()=>Nm(e,F=>jm(F,h,r),L),[e,h,r,L]),C=G.schema,J=b.useMemo(()=>{const F=new Map;return k.forEach(N=>F.set(N.path,N)),F},[k]),Z=Hn,V=gm({resolver:xm(G.validate),defaultValues:Cm(e,void 0,r)}),[z,A]=b.useState(Z);b.useEffect(()=>{if(z&&z!==Hn&&e==="create"){const F=J.get(z);F&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(F.name)}/content`).then(N=>{if(!N.ok)throw new Error(`Failed to fetch content: ${N.statusText}`);return N.text()}).then(N=>{try{const R=JSON.parse(N);f(JSON.stringify(R,null,2))}catch(R){console.error("Invalid JSON content received:",R),f(null)}}).catch(N=>{console.error("Failed to fetch content:",N),f(null)})}},[z,e,J,a]),b.useEffect(()=>{t&&(V.reset(),f(null),A(Z))},[V,t]);const q=V.handleSubmit(async({name:F,template:N})=>{u(!0);try{if(await new Promise(R=>setTimeout(R,200)),e==="create"){const R=z?J.get(z):k.find(ae=>ae.name===N);let m,ee=F;if(a){const ae=ee.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");m=l||JSON.stringify(bt==="docx"?{name:ae,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:{family:"Calibri",size:28},body:{family:"Calibri",size:11}},page:{size:"A4"}}:{name:ae,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const je=`.${bt}.theme.json`;ee.endsWith(je)||(ee=ee.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),ee+=je)}else{const ae=R;m=l||JSON.stringify(bt==="docx"?{name:"docx",props:{theme:(ae==null?void 0:ae.theme)||"default",metadata:{title:(ae==null?void 0:ae.title)||ee.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(ae==null?void 0:ae.title)||ee.replace(/\.(json|js)$/i,""),theme:(ae==null?void 0:ae.theme)||"default"},children:[{name:"slide",props:{},children:[{name:"text",props:{text:"Start writing your presentation content here...",fontSize:24,y:2,x:1,w:8}}]}]},null,2);const le=bt==="docx"?".docx.json":".pptx.json";!ee.endsWith(le)&&!ee.endsWith(".json")&&(ee+=le)}const ne=ee.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),v=ne?ne[0]:"",re=ee.slice(0,ee.length-v.length);let fe=ee,de=1;for(;h.some(ae=>ae.name===fe);)de++,fe=`${re} (${de})${v}`;ee=fe,g(ee,m),y(ee),a&&x(ee,m)}else if(e==="update"){const R=r,m=F,ee=p.includes(R);ee&&_(R),w(R,m),D(R,m),ee&&y(m)}else if(e==="delete"){const R=r;_(R),S(R),I(R)}n()}finally{u(!1)}});return c.jsx(vm,{...V,children:c.jsxs("form",{onSubmit:q,children:[c.jsxs(mn,{children:[c.jsx(gn,{children:d[e].title}),c.jsx(Dn,{children:d[e].description})]}),c.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[C.properties&&"name"in C.properties&&c.jsx(ho,{control:V.control,name:"name",render:({field:F})=>c.jsxs(Ns,{children:[c.jsx(Cs,{children:"Name"}),c.jsx(Es,{children:c.jsx(ha,{placeholder:"Enter a name or select a template below",autoComplete:"off",...F})}),c.jsx(Is,{})]})}),e==="create"&&c.jsx(ho,{control:V.control,name:"template",render:({field:F})=>c.jsxs(Ns,{children:[c.jsx(Cs,{children:a?"Base Theme":"Base Document"}),c.jsxs(ma,{onValueChange:N=>{if(N===Hn)F.onChange(void 0),V.setValue("name",""),A(Hn),f(null);else{const R=J.get(N);R&&(F.onChange(R.name),V.setValue("name",R.name),A(N))}},defaultValue:Z,children:[c.jsx(Es,{children:c.jsx(Ei,{children:c.jsx(ga,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),c.jsxs(Ii,{className:"max-h-[300px]",children:[c.jsxs(hr,{value:Hn,children:["Empty ",a?"theme":"document"]}),Object.entries(E).map(([N,R])=>R.length===0?null:c.jsxs(wm,{children:[c.jsx(Tc,{children:N==="current"?"📁 Current Directory":"📦 Project"}),R.map(m=>{let ee=m.name;if(m.title)ee=`${m.name} - ${m.title}`;else if(m.description){const ne=m.description.length>40?m.description.substring(0,40)+"...":m.description;ee=`${m.name} - ${ne}`}return c.jsx(hr,{value:m.path,className:"pl-6",children:ee},m.path)})]},N))]})]}),c.jsxs(Cc,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),c.jsx(Is,{})]})})]}),c.jsx(pr,{children:c.jsx(xe,{type:"submit",variant:d[e].buttonVariant,disabled:o,children:o?c.jsxs(c.Fragment,{children:[c.jsx(qt,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):d[e].button})})]})})}const ri=_e.memo(Im),Tm=eh,Am=th,zm=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Au,{ref:i,className:B("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none",t&&"pl-8",e),...r,children:[n,c.jsx(fr,{className:"ml-auto h-4 w-4"})]}));zm.displayName=Au.displayName;const Om=b.forwardRef(({className:e,...t},n)=>c.jsx(zu,{ref:n,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));Om.displayName=zu.displayName;const Oc=b.forwardRef(({className:e,...t},n)=>c.jsx(nh,{children:c.jsx(Eu,{ref:n,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",e),...t})}));Oc.displayName=Eu.displayName;const er=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Iu,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));er.displayName=Iu.displayName;const Pm=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Ou,{ref:i,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Pu,{children:c.jsx(Kt,{className:"h-4 w-4"})})}),t]}));Pm.displayName=Ou.displayName;const Dm=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Du,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Pu,{children:c.jsx(ec,{className:"h-4 w-4 fill-current"})})}),t]}));Dm.displayName=Du.displayName;const Rm=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ru,{ref:r,className:B("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Rm.displayName=Ru.displayName;const Ts=b.forwardRef(({className:e,...t},n)=>c.jsx(Tu,{ref:n,className:B("bg-border -mx-1 my-1 h-px",e),...t}));Ts.displayName=Tu.displayName;const Ur=({className:e,...t})=>c.jsx("span",{className:B("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});Ur.displayName="ContextMenuShortcut";const Pc=b.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>c.jsx(Mu,{ref:i,decorative:n,orientation:t,className:B("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Pc.displayName=Mu.displayName;const Dc=xu,Mm=yu,Fm=bu,Rc=b.forwardRef(({className:e,...t},n)=>c.jsx(_i,{className:B("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",e),...t,ref:n}));Rc.displayName=_i.displayName;const $m=_r("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ya=b.forwardRef(({side:e="right",className:t,children:n,...r},i)=>c.jsxs(Fm,{children:[c.jsx(Rc,{}),c.jsxs(vi,{ref:i,className:B($m({side:e}),t),...r,children:[c.jsxs(ia,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[c.jsx(hn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));ya.displayName=vi.displayName;const Lm=b.forwardRef(({className:e,...t},n)=>c.jsx(wi,{ref:n,className:B("text-foreground text-lg font-semibold",e),...t}));Lm.displayName=wi.displayName;const Zm=b.forwardRef(({className:e,...t},n)=>c.jsx(ki,{ref:n,className:B("text-muted-foreground text-sm",e),...t}));Zm.displayName=ki.displayName;function lr({className:e,...t}){return c.jsx("div",{className:B("bg-primary/10 animate-pulse rounded-md",e),...t})}const qi=768,Hi=1200;function Mc(){const[e,t]=b.useState(void 0);return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${qi-1}px)`),r=()=>{t(window.innerWidth<qi)};return n.addEventListener("change",r),t(window.innerWidth<qi),()=>n.removeEventListener("change",r)},[]),!!e}function Vm(){const[e,t]=b.useState(void 0);return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Hi-1}px)`),r=()=>{t(window.innerWidth<Hi)};return n.addEventListener("change",r),t(window.innerWidth<Hi),()=>n.removeEventListener("change",r)},[]),!!e}const Bm="sidebar_state",Um=60*60*24*7,Jm="16rem",qm="18rem",Hm="3rem",Wm="b",Fc=b.createContext(null);function Ti(){const e=b.useContext(Fc);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const $c=b.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const u=Mc(),[l,f]=b.useState(!1),[d,h]=b.useState(e),p=t??d,g=b.useCallback(_=>{const x=typeof _=="function"?_(p):_;n?n(x):h(x),document.cookie=`${Bm}=${x}; path=/; max-age=${Um}`},[n,p]),w=b.useCallback(()=>u?f(_=>!_):g(_=>!_),[u,g,f]);b.useEffect(()=>{const _=D=>{var E;const I=D;if(!I)return!1;const k=(E=I.tagName)==null?void 0:E.toLowerCase();return k==="input"||k==="textarea"||k==="select"||I.isContentEditable?!0:!!(I.closest&&I.closest(".monaco-editor"))},x=D=>{const I=D.metaKey||D.ctrlKey,k=D.key.toLowerCase();if(I&&k===Wm){D.preventDefault(),w();return}I&&k==="s"&&!_(D.target)&&(D.preventDefault(),w())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[w]);const S=p?"expanded":"collapsed",y=b.useMemo(()=>({state:S,open:p,setOpen:g,isMobile:u,openMobile:l,setOpenMobile:f,toggleSidebar:w}),[S,p,g,u,l,f,w]);return c.jsx(Fc.Provider,{value:y,children:c.jsx(vh,{delayDuration:0,children:c.jsx("div",{style:{"--sidebar-width":Jm,"--sidebar-width-icon":Hm,...i},className:B("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});$c.displayName="SidebarProvider";const Lc=b.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:u,openMobile:l,setOpenMobile:f}=Ti();return n==="none"?c.jsx("div",{className:B("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?c.jsx(Dc,{open:l,onOpenChange:f,...s,children:c.jsx(ya,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":qm},side:e,children:c.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):c.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":u,"data-collapsible":u==="collapsed"?n:"","data-variant":t,"data-side":e,children:[c.jsx("div",{className:B("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),c.jsx("div",{className:B("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:c.jsx("div",{"data-sidebar":"sidebar",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow",children:i})})]})});Lc.displayName="Sidebar";const Gm=b.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Ti();return c.jsxs(xe,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:B("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[c.jsx(_h,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Gm.displayName="SidebarTrigger";const Km=b.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Ti();return c.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:B("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});Km.displayName="SidebarRail";const Ym=b.forwardRef(({className:e,...t},n)=>c.jsx("main",{ref:n,className:B("bg-background relative flex min-h-svh flex-1 flex-col","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2",e),...t}));Ym.displayName="SidebarInset";const Xm=b.forwardRef(({className:e,...t},n)=>c.jsx(ha,{ref:n,"data-sidebar":"input",className:B("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));Xm.displayName="SidebarInput";const Zc=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"header",className:B("flex flex-col gap-2 p-2",e),...t}));Zc.displayName="SidebarHeader";const Vc=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"footer",className:B("flex flex-col gap-2 p-2",e),...t}));Vc.displayName="SidebarFooter";const Bc=b.forwardRef(({className:e,...t},n)=>c.jsx(Pc,{ref:n,"data-sidebar":"separator",className:B("bg-sidebar-border mx-2 w-auto",e),...t}));Bc.displayName="SidebarSeparator";const Uc=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"content",className:B("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Uc.displayName="SidebarContent";const Jr=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group",className:B("relative flex w-full min-w-0 flex-col p-2",e),...t}));Jr.displayName="SidebarGroup";const qr=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Ln:"div";return c.jsx(i,{ref:r,"data-sidebar":"group-label",className:B("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opa] duration-200 ease-linear outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});qr.displayName="SidebarGroupLabel";const Qm=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Ln:"button";return c.jsx(i,{ref:r,"data-sidebar":"group-action",className:B("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});Qm.displayName="SidebarGroupAction";const tr=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group-content",className:B("w-full text-sm",e),...t}));tr.displayName="SidebarGroupContent";const As=b.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu",className:B("flex w-full min-w-0 flex-col gap-1",e),...t}));As.displayName="SidebarMenu";const Jc=b.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,"data-sidebar":"menu-item",className:B("group/menu-item relative",e),...t}));Jc.displayName="SidebarMenuItem";const eg=_r("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),qc=b.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const u=e?Ln:"button",{isMobile:l,state:f}=Ti(),d=c.jsx(u,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:B(eg({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:d}),c.jsx(Ye,{side:"right",align:"center",hidden:f!=="collapsed"||l,...i})]})):d});qc.displayName="SidebarMenuButton";const tg=b.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?Ln:"button";return c.jsx(s,{ref:i,"data-sidebar":"menu-action",className:B("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...r})});tg.displayName="SidebarMenuAction";const ng=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:B("text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));ng.displayName="SidebarMenuBadge";const rg=b.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=b.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:B("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&c.jsx(lr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(lr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});rg.displayName="SidebarMenuSkeleton";const ig=b.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:B("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));ig.displayName="SidebarMenuSub";const sg=b.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));sg.displayName="SidebarMenuSubItem";const ag=b.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?Ln:"a";return c.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:B("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...i})});ag.displayName="SidebarMenuSubButton";function zs(e,t){const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.style.display="none",r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}const og=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function lg({document:e,indicator:t,compact:n=!1}){const r=b.useRef(null),[i,s]=b.useState(!1),[a,o]=b.useState(!1),[u,l]=b.useState(!1),{openDocument:f,documentTypes:d,activeTab:h}=qe(A=>A),{name:p,text:g,isGenerating:w}=on(A=>A),y=(d[e.name]||"application/json+report")==="application/json+theme",_=h===e.name,[x,D]=b.useState(p),[I,k]=b.useState(g),E=100,L=0;b.useEffect(()=>{const A=setTimeout(()=>{p&&g?(D(p),k(g)):w||(D(""),k(""))},w?E:L);return()=>clearTimeout(A)},[p,g,w]);const G=x===e.name,C=A=>{var F;const q=new Set;try{const N=JSON.parse(A);(F=N.props)!=null&&F.theme&&q.add(N.props.theme),N.children&&Array.isArray(N.children)&&N.children.forEach(R=>{var m;R.name==="docx"&&((m=R.props)!=null&&m.theme)&&q.add(R.props.theme)})}catch{}return q},J=b.useMemo(()=>{if(!y||!I)return!1;try{const A=JSON.parse(e.text),q=Ss(A);if(q)return C(I).has(q)}catch{}return!1},[y,I,e.text,e.name,x]),Z=b.useCallback(()=>{o(!1)},[]),V=b.useCallback(()=>{l(!1)},[]),z=c.jsxs(qc,{variant:"default",size:"default",ref:r,className:B("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),G&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),J&&!_&&!G&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:A=>{var q;(A.ctrlKey||A.metaKey)&&A.key==="Enter"?(f(e.name),A.preventDefault()):A.key==="Enter"?(o(!0),A.preventDefault()):A.key==="Backspace"||A.key==="Delete"?(l(!0),A.preventDefault()):A.key==="Escape"&&((q=r.current)==null||q.blur(),A.preventDefault())},children:[_?c.jsx(Ka,{className:B("size-4","text-green-600 dark:text-green-400")}):G?c.jsx(Ka,{className:B("size-4","text-blue-600 dark:text-blue-400")}):y?c.jsx(Qn,{className:"size-4 text-purple-600 dark:text-purple-400"}):c.jsx(ks,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&c.jsx("span",{className:B("truncate flex-1",y&&!_&&!G&&!J&&"text-purple-700 dark:text-purple-300",(_||G||J)&&"font-medium"),children:e.name})]});return c.jsxs(Jc,{children:[c.jsxs(Tm,{onOpenChange:s,children:[c.jsx(Am,{children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:z}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[e.name,y?c.jsx("div",{className:"opacity-70",children:"Theme"}):c.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):z}),c.jsxs(Oc,{children:[c.jsxs(er,{onClick:()=>f(e.name),children:["Open",c.jsx(Ur,{children:og?"⌘⏎":"⌃⏎"})]}),c.jsx(Ts,{}),c.jsx(er,{disabled:!e,onClick:()=>{e&&zs(`${e.name}.js`,new Blob([e.text],{type:e.type}))},children:"Download..."}),c.jsx(Ts,{}),c.jsxs(er,{onClick:()=>o(!0),children:["Rename...",c.jsx(Ur,{children:"⏎"})]}),c.jsxs(er,{onClick:()=>l(!0),children:["Delete",c.jsx(Ur,{children:"⌫"})]})]})]}),c.jsx(Lt,{open:a,onOpenChange:o,children:c.jsx(zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:A=>{var q;A.preventDefault(),(q=r.current)==null||q.focus()},children:c.jsx(ri,{mode:"update",shouldReset:!a,postSubmit:Z,selectedName:e.name})})}),c.jsx(Lt,{open:u,onOpenChange:l,children:c.jsx(zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:A=>{var q;A.preventDefault(),(q=r.current)==null||q.focus()},children:c.jsx(ri,{mode:"delete",shouldReset:!u,postSubmit:V,selectedName:e.name})})})]})}const mo=_e.memo(lg);async function ug(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const cg=_r("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function ln({className:e,variant:t,...n}){return c.jsx("div",{className:B(cg({variant:t}),e),...n})}const fn=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Fu,{ref:r,className:B("relative overflow-hidden",e),...n,children:[c.jsx(rh,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Hc,{}),c.jsx(ih,{})]}));fn.displayName=Fu.displayName;const Hc=b.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx($u,{ref:r,orientation:t,className:B("flex touch-none transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(sh,{className:"bg-border relative flex-1 rounded-full"})}));Hc.displayName=$u.displayName;const Wc=ah,ba=b.forwardRef(({className:e,...t},n)=>c.jsx(Lu,{ref:n,className:B("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));ba.displayName=Lu.displayName;const An=b.forwardRef(({className:e,...t},n)=>c.jsx(Zu,{ref:n,className:B("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-md px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow",e),...t}));An.displayName=Zu.displayName;const zn=b.forwardRef(({className:e,...t},n)=>c.jsx(Vu,{ref:n,className:B("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));zn.displayName=Vu.displayName;const dg=_r("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Os=b.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:B(dg({variant:t}),e),...n}));Os.displayName="Alert";const fg=b.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:B("mb-1 font-medium leading-none tracking-tight",e),...t}));fg.displayName="AlertTitle";const Ps=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:B("text-sm [&_p]:leading-relaxed",e),...t}));Ps.displayName="AlertDescription";const ii=b.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=b.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),u=()=>s(!i),l=()=>t===null?c.jsx("span",{className:"text-orange-500",children:"null"}):t===void 0?c.jsx("span",{className:"text-gray-500",children:"undefined"}):typeof t=="boolean"?c.jsx("span",{className:"text-blue-500",children:String(t)}):typeof t=="number"?c.jsx("span",{className:"text-green-500",children:t}):typeof t=="string"?t.startsWith("http")?c.jsxs("span",{className:"text-purple-500",children:['"',t,'"']}):t.startsWith("#/")?c.jsxs("span",{className:"text-cyan-500",children:['"',t,'"']}):c.jsxs("span",{className:"text-amber-600",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return c.jsxs("div",{className:B("text-sm",n>0&&"ml-4"),children:[c.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded px-1 py-0.5",children:[a&&c.jsx("button",{onClick:u,className:"mr-1 hover:bg-muted rounded p-0.5","aria-label":i?"Collapse":"Expand",children:i?c.jsx(pn,{className:"h-3 w-3"}):c.jsx(fr,{className:"h-3 w-3"})}),!a&&c.jsx("span",{className:"w-4"}),e&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:['"',e,'"']}),c.jsx("span",{className:"mx-1",children:":"})]}),a?c.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&c.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):l(),!a&&!r&&c.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&c.jsxs("div",{className:"ml-4",children:[o?t.map((d,h)=>c.jsx(ii,{keyName:String(h),value:d,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([d,h],p,g)=>c.jsx(ii,{keyName:d,value:h,depth:n+1,isLast:p===g.length-1},d)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});ii.displayName="JsonNode";const si=b.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:B("space-y-4",r),children:[c.jsx(lr,{className:"h-8 w-64"}),c.jsx(lr,{className:"h-4 w-full"}),c.jsx(lr,{className:"h-64 w-full"})]}):n?c.jsx(Os,{variant:"destructive",className:r,children:c.jsx(Ps,{children:n})}):e?c.jsx(fn,{className:B("h-full w-full rounded-md border bg-muted/10 p-4",r),children:c.jsx("div",{className:"font-mono text-xs",children:c.jsx(ii,{value:e})})}):c.jsx(Os,{className:r,children:c.jsx(Ps,{children:"No schema available"})}));si.displayName="SchemaViewer";function pg({plugins:e,onClose:t}){var Z,V;const{toast:n}=Si(),r=$t(z=>z.togglePlugin),i=$t(z=>z.isPluginSelected),s=$t(z=>z.clearSelections),a=$t(z=>z.selectedPlugins),o=$t(z=>z.applyPluginsWithValidation),u=$t(z=>z.isApplyingPlugins),[l,f]=b.useState(null),[d,h]=b.useState("list"),[p,g]=b.useState("overview"),[w,S]=b.useState(null),[y,_]=b.useState(0),[x,D]=b.useState("list"),I=Array.from(a),k=z=>{f(z),h("detail")},E=()=>{h("list"),g("overview"),_(0),D("list")},L=b.useMemo(()=>{const z={current:[],downstream:[],upstream:[]};return e.forEach(A=>{z[A.location]&&z[A.location].push(A)}),z},[e]),G=async(z,A)=>{l&&(await ug(l.name,z.props),S(A),setTimeout(()=>S(null),2e3))},C=z=>{switch(z){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return z}},J=z=>{switch(z){case"current":return c.jsx(jh,{className:"size-3"});case"downstream":return c.jsx(Sh,{className:"size-3"});case"upstream":return c.jsx(ks,{className:"size-3"});default:return null}};return c.jsxs(c.Fragment,{children:[c.jsxs(mn,{children:[c.jsxs(gn,{className:"flex items-center gap-2",children:[c.jsx(tc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Discovered Plugins"]}),c.jsxs(Dn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project."," ",I.length>0&&c.jsxs("span",{className:"text-primary font-medium",children:[I.length," selected"]})]})]}),d==="list"&&I.length>0&&c.jsxs("div",{className:"flex items-center justify-between mt-4 p-2 bg-muted/50 rounded-lg",children:[c.jsxs("div",{className:"text-sm text-muted-foreground",children:[I.length," plugin",I.length!==1?"s":""," selected"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(xe,{size:"sm",variant:"outline",onClick:s,children:"Clear All"}),c.jsx(xe,{size:"sm",disabled:u,onClick:async()=>{console.log("Apply Selection clicked with plugins:",I),await o(()=>{n({title:"Plugins Applied Successfully!",description:`${I.length} plugin${I.length!==1?"s":""} have been applied. Autocomplete and validation are now updated.`,className:"border-green-500"}),t()},z=>{n({title:"Failed to Apply Plugins",description:z||"Unable to update schema validation. Please try again.",variant:"destructive"})})},children:u?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"size-4 mr-1 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Applying..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Kt,{className:"size-4 mr-1"}),"Apply Selection"]})})]})]}),c.jsxs("div",{className:"mt-4 flex-1 overflow-hidden",children:[d==="list"&&c.jsx(fn,{className:"h-[600px] pr-4",children:Object.entries(L).map(([z,A])=>A.length===0?null:c.jsxs("div",{className:"mb-6",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm font-semibold text-muted-foreground",children:[J(z),C(z),c.jsx(ln,{variant:"secondary",className:"ml-auto",children:A.length})]}),c.jsx("div",{className:"space-y-2",children:A.map(q=>{const F=i(q.name);return c.jsxs("div",{className:B("flex items-center justify-between p-3 rounded-lg border transition-colors group",F&&"bg-primary/10 border-primary","hover:bg-accent/50"),children:[c.jsxs("div",{className:"flex-1 cursor-pointer",onClick:()=>k(q),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ya,{className:"size-4 text-blue-600 dark:text-blue-400"}),c.jsx("span",{className:"font-medium",children:q.name}),q.version&&c.jsxs(ln,{variant:"outline",className:"text-xs",children:["v",q.version]})]}),q.description&&c.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:q.description}),c.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:q.relativePath})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[F&&c.jsx(Xa,{className:"size-4 text-primary"}),c.jsx(xe,{size:"sm",variant:F?"secondary":"outline",onClick:N=>{N.stopPropagation(),r(q)},children:F?"Selected":"Select"}),c.jsx(fr,{className:"size-4 text-muted-foreground group-hover:translate-x-1 transition-transform"})]})]},q.name)})})]},z))}),d==="detail"&&l&&c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b",children:[c.jsxs(xe,{variant:"ghost",size:"sm",onClick:E,className:"gap-1 -ml-2",children:[c.jsx(Qa,{className:"size-4"}),"Back to Plugins"]}),c.jsx("div",{className:"flex-1"}),c.jsxs(ln,{variant:"outline",children:[l.name,l.version&&` v${l.version}`]})]}),c.jsxs(Wc,{value:p,onValueChange:g,className:"flex-1 flex flex-col overflow-hidden5",children:[c.jsxs(ba,{className:"grid w-full grid-cols-3 mb-4",children:[c.jsxs(An,{value:"overview",className:"gap-2",children:[c.jsx(nc,{className:"size-4"}),"Overview"]}),c.jsxs(An,{value:"schema",className:"gap-2",disabled:!l.schema||Object.keys(l.schema).length===0,children:[c.jsx(rc,{className:"size-4"}),"Schema"]}),c.jsxs(An,{value:"examples",className:"gap-2",disabled:!l.examples||l.examples.length===0,children:[c.jsx(Yr,{className:"size-4"}),"Examples"," ",l.examples&&`(${l.examples.length})`]})]}),c.jsx(zn,{value:"overview",className:"flex-1 overflow-hidden",children:c.jsx(fn,{className:"h-[500px] pr-4",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[c.jsx(Ya,{className:"size-5 text-blue-600 dark:text-blue-400"}),l.name]}),l.version&&c.jsxs(ln,{variant:"outline",className:"mt-2 mb-1",children:["Version ",l.version]})]}),l.description&&c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium mb-1",children:"Description"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})]}),c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium mb-1",children:"Location"}),c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[J(l.location),c.jsx("span",{children:C(l.location)}),c.jsxs("span",{className:"text-xs",children:["(",l.relativePath,")"]})]})]}),((Z=l.schema)==null?void 0:Z.properties)&&c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium mb-2",children:"Configuration Properties (Quick Preview)"}),c.jsxs("div",{className:"space-y-1",children:[Object.entries(l.schema.properties).slice(0,5).map(([z,A])=>c.jsxs("div",{className:"text-xs",children:[c.jsx("span",{className:"font-mono font-medium",children:z}),A.type&&c.jsxs("span",{className:"text-muted-foreground ml-2",children:["(",A.type,")",A.optional?" - optional":""]})]},z)),Object.keys(l.schema.properties).length>5&&c.jsxs("div",{className:"text-xs text-muted-foreground",children:["...and"," ",Object.keys(l.schema.properties).length-5," ","more properties. View the Schema tab for complete details."]})]})]})]})})}),c.jsx(zn,{value:"schema",className:"flex-1 overflow-hidden",children:c.jsx(si,{schema:((V=l.schema)==null?void 0:V.jsonSchema)||null,loading:!1,className:"h-[500px]"})}),c.jsx(zn,{value:"examples",className:"flex-1 overflow-hidden",children:l.examples&&l.examples.length>0?c.jsxs(c.Fragment,{children:[x==="list"&&l.examples.length>1&&c.jsx(fn,{className:"h-[500px]",children:c.jsx("div",{className:"space-y-3",children:l.examples.map((z,A)=>c.jsx("div",{className:"p-4 border rounded-lg hover:bg-muted cursor-pointer transition-colors group",onClick:()=>{_(A),D("detail")},children:c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsxs(ln,{variant:"secondary",className:"text-xs",children:["Example ",A+1]}),c.jsx("h3",{className:"font-semibold text-sm",children:z.title||`Example ${A+1}`})]}),z.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-2 line-clamp-2",children:z.description})]}),c.jsx(fr,{className:"size-5 text-muted-foreground mt-1 group-hover:translate-x-1 transition-transform"})]})},A))})}),(x==="detail"||l.examples.length===1)&&l.examples[y]&&c.jsxs(c.Fragment,{children:[l.examples.length>1&&c.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b",children:[c.jsxs(xe,{variant:"ghost",size:"sm",onClick:()=>D("list"),className:"gap-1 -ml-2",children:[c.jsx(Qa,{className:"size-4"}),"Back to Examples"]}),c.jsx("div",{className:"flex-1"}),c.jsxs(ln,{variant:"secondary",className:"text-xs",children:["Example ",y+1," of"," ",l.examples.length]})]}),c.jsx(fn,{className:"max-h-[50vh]",children:c.jsxs("div",{className:"space-y-4",children:[l.examples[y].title&&c.jsx("h3",{className:"text-lg font-semibold",children:l.examples[y].title}),l.examples[y].description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:l.examples[y].description}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h4",{className:"text-sm font-medium",children:"Full Component Configuration"}),c.jsx(xe,{size:"sm",variant:"outline",onClick:()=>G(l.examples[y],y),children:w===y?c.jsxs(c.Fragment,{children:[c.jsx(Xa,{className:"size-4 mr-2 text-green-600"}),"Copied!"]}):c.jsxs(c.Fragment,{children:[c.jsx(aa,{className:"size-4 mr-2"}),"Copy"]})})]}),c.jsx("pre",{className:"p-4 bg-muted rounded-lg overflow-x-auto",children:c.jsx("code",{className:"text-sm",children:JSON.stringify(l.examples[y].props,null,2)})})]})]})})]}),c.jsx("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(ks,{className:"size-4 text-muted-foreground mt-0.5"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.jsx("p",{className:"font-medium mb-1",children:"How to use:"}),c.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[c.jsx("li",{children:"Copy the example configuration"}),c.jsx("li",{children:"Paste it into your document's children array"}),c.jsx("li",{children:"Adjust the configuration values as needed"})]})]})]})})]}):c.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[c.jsx(Yr,{className:"size-12 mx-auto mb-3 opacity-20"}),c.jsx("p",{children:"No examples available for this plugin"})]})})]})]})]})]})}const Wi=oh,Gi=lh,Ki=uh,Gc=ch,Kc=dh,hg=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(qu,{ref:i,className:B("focus:bg-accent data-[state=open]:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,c.jsx(fr,{className:"ml-auto"})]}));hg.displayName=qu.displayName;const mg=b.forwardRef(({className:e,...t},n)=>c.jsx(Hu,{ref:n,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));mg.displayName=Hu.displayName;const va=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(fh,{children:c.jsx(Bu,{ref:r,sideOffset:t,className:B("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));va.displayName=Bu.displayName;const Wt=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Uu,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));Wt.displayName=Uu.displayName;const gg=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Wu,{ref:i,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Gu,{children:c.jsx(Kt,{className:"h-4 w-4"})})}),t]}));gg.displayName=Wu.displayName;const xg=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ku,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Gu,{children:c.jsx(ec,{className:"h-2 w-2 fill-current"})})}),t]}));xg.displayName=Ku.displayName;const yg=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Yu,{ref:r,className:B("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));yg.displayName=Yu.displayName;const ai=b.forwardRef(({className:e,...t},n)=>c.jsx(Ju,{ref:n,className:B("bg-muted -mx-1 my-1 h-px",e),...t}));ai.displayName=Ju.displayName;function bg(){const{theme:e,setTheme:t}=Xu(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=b.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(xe,{variant:"ghost",size:"icon",onClick:r,children:[c.jsx(Nh,{className:"hidden dark:block"}),c.jsx(Ch,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:"Toggle theme"})})]})}async function vg(e){if(navigator.clipboard&&navigator.clipboard.writeText)try{return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard API failed, falling back to legacy method:",t)}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="2em",t.style.height="2em",t.style.padding="0",t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("Failed to copy text to clipboard:",t),!1}}function wg(e){try{const t=typeof e=="string"?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch(t){return console.error("Failed to format schema:",t),typeof e=="string"?e:JSON.stringify(e)}}async function kg(e){const t=wg(e);return vg(t)}const Yc=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=b.useState(n),[s,a]=b.useState(null),[o,u]=b.useState(null),[l,f]=b.useState(!1),[d,h]=b.useState(!1),[p,g]=b.useState(null),[w,S]=b.useState(null),[y,_]=b.useState(!1),{toast:x}=Si(),D=$t(V=>V.selectedPlugins),I=Array.from(D);b.useEffect(()=>{n&&i(n)},[n]);const k=b.useCallback(async()=>{f(!0),g(null);try{const V=await Zi.fetchDocumentSchema(I);a(V)}catch(V){const z=V instanceof Error?V.message:"Failed to load document schema";g(z),x({variant:"destructive",title:"Error loading schema",description:z})}finally{f(!1)}},[I,x]),E=b.useCallback(async()=>{if(!o){h(!0),S(null);try{const V=await Zi.fetchThemeSchema();u(V)}catch(V){const z=V instanceof Error?V.message:"Failed to load theme schema";S(z),x({variant:"destructive",title:"Error loading schema",description:z})}finally{h(!1)}}},[o,x]),[L,G]=b.useState([]);b.useEffect(()=>{e||(a(null),g(null))},[e]),b.useEffect(()=>{if(!e)return;const V=I.length!==L.length||I.some((z,A)=>z!==L[A]);r==="document"?(!s||V)&&(V&&(Zi.clearPluginSchemaCache(),G([...I])),l||k()):r==="theme"&&!o&&!d&&E()},[r,e,s,o,l,d,I,L,k,E]);const C=I.length,J=r==="document"?s:o,Z=async()=>{if(J)try{await kg(J)&&(_(!0),x({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(V){console.error("Copy failed:",V)}};return c.jsx(Lt,{open:e,onOpenChange:t,children:c.jsxs(zt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(mn,{children:c.jsx(gn,{children:"Schema Viewer"})}),c.jsxs(Wc,{value:r,onValueChange:V=>i(V),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(ba,{children:[c.jsxs(An,{value:"document",className:"flex items-center gap-1",children:["Document",C>0&&c.jsxs(ln,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",C]})]}),c.jsx(An,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(xe,{variant:"ghost",size:"icon",onClick:Z,disabled:y||!J,"aria-label":"Copy schema",children:y?c.jsx(Kt,{className:"h-4 w-4"}):c.jsx(aa,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(zn,{value:"document",className:"h-full",children:c.jsx(si,{schema:s,loading:l,error:p||void 0})}),c.jsx(zn,{value:"theme",className:"h-full",children:c.jsx(si,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function _g({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=qe(Kh(N=>({documents:N.documents,documentTypes:N.documentTypes,createDocument:N.createDocument,openDocument:N.openDocument}))),u=lc(N=>N.updateTheme),[l,f]=b.useState(!1),[d,h]=b.useState(!1),[p,g]=b.useState(!1),[w,S]=b.useState(!1),[y,_]=b.useState(new Set(["current-docs","current-themes"])),{toast:x}=Si(),D=i.filter(N=>s[N.name]!=="application/json+theme"),I=i.filter(N=>s[N.name]==="application/json+theme"),k=b.useMemo(()=>{if(!e)return{current:[],downstream:[]};const N={current:[],downstream:[]};return e.documents.forEach(R=>{N[R.location]&&N[R.location].push(R)}),N},[e]),E=b.useMemo(()=>{if(!e)return{current:[],downstream:[]};const N={current:[],downstream:[]};return e.themes.forEach(R=>{N[R.location]&&N[R.location].push(R)}),N},[e]),L=b.useMemo(()=>{const N=new Set;return D.forEach(R=>{try{const m=JSON.parse(R.text);m.children&&Array.isArray(m.children)&&m.children.forEach(ee=>{var ne;ee.name==="docx"&&((ne=ee.props)!=null&&ne.theme)&&N.add(ee.props.theme)})}catch{}}),N},[D]),G=b.useCallback(()=>{f(!1)},[]),C=b.useCallback(()=>{h(!1)},[]),J=b.useRef(new Map);b.useEffect(()=>{const N=J.current,R=new Map;I.forEach(m=>{R.set(m.name,m.text),N.get(m.name)!==m.text&&u(m.name,m.text)}),J.current=R},[I,u]);const Z=N=>{_(R=>{const m=new Set(R);return m.has(N)?m.delete(N):m.add(N),m})},V=qe(N=>N.activeTab),z=V&&s[V]==="application/json+theme"?"theme":"document",{resolvedTheme:A}=Xu(),q=A==="dark"?"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo-white.svg?updatedAt=1751359555877":"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo.svg?updatedAt=1749817149276",F=b.useCallback(async(N,R)=>{if(i.some(m=>m.name===N)){o(N);return}try{const m=await fetch(`/api/discovery/${R?"themes":"documents"}/${encodeURIComponent(N)}/content`);if(!m.ok)throw new Error(m.statusText);const ee=await m.text(),ne=JSON.parse(ee);a(N,JSON.stringify(ne,null,2)),o(N),x({title:`Added ${R?"theme":"document"}: ${N}`})}catch{x({title:"Failed to load",description:`Could not load ${N}`,variant:"destructive"})}},[i,a,o,x]);return c.jsxs(c.Fragment,{children:[c.jsxs(Lc,{collapsible:"none",style:{"--sidebar-width":n?"2.5rem":"16rem"},children:[c.jsx(Zc,{children:c.jsx("div",{className:B("flex items-center transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?c.jsx(xe,{variant:"ghost",size:"icon",title:"Expand sidebar",onClick:t,children:c.jsx(ic,{className:"h-4 w-4"})}):c.jsxs(c.Fragment,{children:[c.jsx("a",{href:"/",className:"flex items-center pl-2",children:c.jsx("img",{src:q,alt:"WiseAir logo",className:"h-5 w-auto max-w-[120px] shrink-0"})}),c.jsx("div",{className:"flex items-center gap-1",children:c.jsx(xe,{variant:"ghost",size:"icon",title:"Collapse sidebar",onClick:t,children:c.jsx(Eh,{className:"h-4 w-4"})})})]})})}),c.jsxs(Uc,{className:B("h-full transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100"),children:[c.jsxs(Jr,{children:[c.jsxs(qr,{className:B("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Vi,{className:"size-3"}),!n&&c.jsx("span",{children:"Active Documents"})]}),c.jsxs(Lt,{open:l,onOpenChange:f,children:[c.jsx(fo,{asChild:!0,children:c.jsx("div",{className:B("flex",n?"w-full justify-center":""),children:c.jsx(xe,{className:B("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Document",disabled:!e||e.documents.length===0,children:n?c.jsx(Vi,{className:"size-4"}):c.jsx(Xr,{className:"size-4"})})})}),c.jsx(zt,{className:"sm:max-w-[525px]",children:c.jsx(ri,{mode:"create",shouldReset:!l,postSubmit:G,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]}),n?c.jsx(tr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:D.map(N=>{const R=V===N.name;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(N.name),className:B("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",R?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),N.name.charAt(0).toUpperCase()]})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:N.name})})]},N.name)})})}):c.jsx(tr,{children:c.jsx(As,{children:D.length>0?D.map((N,R)=>c.jsx(mo,{document:N,compact:n},`doc-${R}`)):c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),c.jsx(Bc,{}),c.jsxs(Jr,{children:[c.jsxs(qr,{className:B("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Qn,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&c.jsx("span",{children:"Active Themes"})]}),e&&e.themes.length>0&&c.jsxs(Lt,{open:d,onOpenChange:h,children:[c.jsx(fo,{asChild:!0,children:c.jsx("div",{className:B("flex",n?"w-full justify-center":""),children:c.jsx(xe,{className:B("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Theme",children:n?c.jsx(Qn,{className:"size-4"}):c.jsx(Xr,{className:"size-4"})})})}),c.jsx(zt,{className:"sm:max-w-[525px]",children:c.jsx(ri,{mode:"create",shouldReset:!d,postSubmit:C,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?c.jsx(tr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:I.map(N=>{const R=V===N.name;let m=null;try{const ne=JSON.parse(N.text);m=Ss(ne)}catch{}const ee=m?L.has(m):!1;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(N.name),className:B("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",R?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":ee?"bg-purple-50 text-purple-600 dark:bg-purple-900/20 dark:text-purple-400":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),c.jsx(Qn,{className:"size-3"})]})}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[N.name,ee&&c.jsx("div",{className:"opacity-70",children:"In use"})]})})]},N.name)})})}):c.jsx(tr,{children:c.jsx(As,{children:I.length>0?I.map((N,R)=>{let m=null;try{const ne=JSON.parse(N.text);m=Ss(ne)}catch{}const ee=m?L.has(m):!1;return c.jsx(mo,{document:N,compact:n,indicator:ee?"in-use":void 0},`theme-${R}`)}):c.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No active themes."," ",e&&e.themes.length>0?"Click + to add one.":"No themes discovered in project."]})})})]}),e&&(e.documents.length>0||e.themes.length>0)&&c.jsxs(Jr,{className:"mt-2 border-t pt-4",children:[c.jsx(qr,{className:B("flex items-center mb-2",n?"justify-center":"gap-2"),children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(eo,{className:"size-3"})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:"Expand sidebar to show discovered resources"})})]}):c.jsxs(c.Fragment,{children:[c.jsx(eo,{className:"size-3"}),c.jsx("span",{children:"Discovered Resources"})]})}),!n&&c.jsxs(c.Fragment,{children:[Object.entries(k).map(([N,R])=>{if(R.length===0)return null;const m=`${N}-docs`,ee=y.has(m);return c.jsxs(Wi,{open:ee,children:[c.jsxs(Gi,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>Z(m),children:[c.jsx(pn,{className:B("size-3 transition-transform",!ee&&"-rotate-90")}),c.jsx(Vi,{className:"size-3"}),N==="current"?"Current Directory":"Project"," ","Documents (",R.length,")"]}),c.jsx(Ki,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((ne,v)=>{const re=i.some(fe=>fe.name===ne.name);return c.jsxs("button",{onClick:()=>F(ne.name,!1),className:B("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-blue-400/60 dark:border-blue-500/40","hover:bg-accent hover:text-accent-foreground",re&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:ne.name}),ne.title&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:ne.title})]},v)})})})]},m)}),Object.entries(E).map(([N,R])=>{if(R.length===0)return null;const m=`${N}-themes`,ee=y.has(m);return c.jsxs(Wi,{open:ee,children:[c.jsxs(Gi,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>Z(m),children:[c.jsx(pn,{className:B("size-3 transition-transform",!ee&&"-rotate-90")}),c.jsx(Qn,{className:"size-3"}),N==="current"?"Current Directory":"Project"," ","Themes (",R.length,")"]}),c.jsx(Ki,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((ne,v)=>{const re=i.some(fe=>fe.name===ne.name);return c.jsxs("button",{onClick:()=>F(ne.name,!0),className:B("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-purple-400/60 dark:border-purple-500/40","hover:bg-accent hover:text-accent-foreground",re&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:ne.name}),ne.description&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:ne.description})]},v)})})})]},m)}),e&&e.plugins.length>0&&c.jsxs(Wi,{open:y.has("plugins"),children:[c.jsxs(Gi,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>Z("plugins"),children:[c.jsx(pn,{className:B("size-3 transition-transform",!y.has("plugins")&&"-rotate-90")}),c.jsx(tc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",e.plugins.length,")"]}),c.jsx(Ki,{children:c.jsxs("div",{className:"pl-4 space-y-0.5",children:[e.plugins.map((N,R)=>c.jsxs("div",{className:"py-1 px-2 text-sm text-muted-foreground border-l-2 border-amber-400/60 dark:border-amber-500/40",children:[c.jsx("div",{className:"font-medium",children:N.name}),N.description&&c.jsx("div",{className:"text-xs opacity-70 truncate",children:N.description})]},R)),c.jsx("div",{className:"flex items-center justify-end pr-3 pt-1",children:c.jsx(xe,{className:"h-6 px-2 text-xs",variant:"ghost",title:"Open plugin manager",onClick:()=>g(!0),children:"Manage plugins"})})]})})]})]})]})]}),c.jsx(Vc,{children:c.jsx("div",{className:B("flex w-full items-center transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:c.jsx(bg,{})})}),c.jsx(Lt,{open:p,onOpenChange:g,children:c.jsx(zt,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:c.jsx(pg,{plugins:(e==null?void 0:e.plugins)||[],onClose:()=>g(!1)})})})]}),c.jsx(Yc,{open:w,onOpenChange:S,defaultTab:z==="theme"?"theme":"document"})]})}const go=b.memo(_g),Sg=b.lazy(()=>Qu(()=>import("./editor-CH_tiHyn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function xo(){return c.jsx(b.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(Sg,{})})}const jg=b.lazy(()=>Qu(()=>import("./preview-CJlTPgks.js"),__vite__mapDeps([12,1,2,3,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function yo(){return c.jsx(b.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(jg,{})})}const Ng=({className:e,...t})=>c.jsx(hh,{className:B("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Yi=ph,bo=({withHandle:e,className:t,...n})=>c.jsx(mh,{className:B("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&c.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:c.jsx(Ih,{className:"h-2.5 w-2.5"})})});function Cg({className:e,...t}){return c.jsx(gh,{"data-slot":"switch",className:B("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:c.jsx(xh,{"data-slot":"switch-thumb",className:B("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Eg({children:e,className:t}){return c.jsx("kbd",{className:B("inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1 rounded border border-border bg-background text-[11px] font-mono font-medium text-muted-foreground shadow-[0_1px_0_0] shadow-border/50 leading-none select-none",t),children:e})}function Ig({children:e,className:t}){return c.jsx("span",{className:B("inline-flex items-center gap-0.5",t),children:e})}const Pr=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function Ds({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Pr?"⌘":"Ctrl";case"shift":return Pr?"⇧":"Shift";case"alt":return Pr?"⌥":"Alt";case"ctrl":return Pr?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(Ig,{className:t,children:r.map((i,s)=>c.jsx(Eg,{children:i},s))})}class Tg{constructor(t){Ga(this,"client");this.client=Jp.create({baseURL:t||void 0||"/api",headers:{"Content-Type":"application/json"}})}get(t,n){return this.client.get(t,n)}post(t,n,r){return this.client.post(t,n,r)}put(t,n,r){return this.client.put(t,n,r)}delete(t,n){return this.client.delete(t,n)}patch(t,n,r){return this.client.patch(t,n,r)}}const Ag=new Tg;function zg(){const e=b.useRef(null),t=b.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const u=new AbortController;e.current=u;try{a==null||a("parsing","Validating JSON structure...");let l;try{l=JSON.parse(i)}catch(k){throw new Error(`Invalid JSON: ${k instanceof Error?k.message:"Unknown parse error"}`)}a==null||a("building",`Building ${Ar.toLowerCase()} structure...`);const f={jsonDefinition:l,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${bt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const h=await fetch(wh.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:u.signal}),p=await h.json();if(!h.ok||!p.success){const k=p.error||p.message||`API request failed with status: ${h.status}`;throw new Error(k)}const{data:g,cache:w,warnings:S}=p,y=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=y==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${Ar.toLowerCase()}`;a==null||a("finalizing",_);const x=globalThis.atob(g.document),D=new Uint8Array(x.length);for(let k=0;k<x.length;k++)D[k]=x.charCodeAt(k);const I=new Blob([D],{type:g.contentType});if(I.size===0)throw new Error(`Received empty ${Ar.toLowerCase()} from API`);return{name:r,text:i,blob:I,filename:g.filename,fileId:g.fileId,cacheStatus:y,cacheHitRate:w.hitRate,warnings:S}}catch(l){throw l instanceof Error&&l.name==="AbortError"?new Error(`${Ar} generation was cancelled`):l}finally{e.current===u&&(e.current=null)}},[]),n=b.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,cancelGeneration:n}}function Og(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const u=Object.entries(a.context).map(([l,f])=>`${l}: ${JSON.stringify(f)}`).join(", ");o+=` (${u})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}const vo=bt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Xi={docxjs:["⚡","(Recommended) works in the browser"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Pg({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:u,onShowCacheMetrics:l,onShowSchemas:f,documentText:d,warnings:h,renderingLibrary:p,setRenderingLibrary:g,onToggleChat:w,chatOpen:S,onTogglePreview:y,previewOpen:_}){const x=p!=="docxjs",[D,I]=b.useState(!1),[k,E]=b.useState(!1),[L,G]=b.useState(!1),[C,J]=b.useState(!1),[Z,V]=b.useState(!1),[z,A]=b.useState(!1),{toast:q}=Si(),{generatePresentation:F}=zg(),N=b.useCallback(async()=>{if(t){I(!0);try{await new Promise(v=>setTimeout(v,100)),zs(`${e}${zr}`,t)}finally{setTimeout(()=>I(!1),500)}}},[t,e]),R=b.useCallback(async()=>{if(!(!h||h.length===0)){E(!0);try{const v=Og(h);if(!v){q({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const re=await F("warnings",JSON.stringify(v,null,2),{});re&&typeof re=="object"&&"blob"in re&&re.blob&&(zs(`${e}-warnings${zr}`,re.blob),q({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(v){console.error("Failed to generate warnings document:",v),q({title:"Download failed",description:v instanceof Error?v.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>E(!1),500)}}},[h,e,F,q]),m=b.useCallback(async()=>{const v=r==null?void 0:r.current;if(v!=null&&v.src){G(!0);try{await new Promise(fe=>{let de=null,ae=!1;const le=()=>{de&&(clearTimeout(de),de=null),v.removeEventListener("load",Le),v.removeEventListener("error",Be)},je=()=>{ae||(ae=!0,le(),fe())},Le=()=>je(),Be=()=>je();v.addEventListener("load",Le),v.addEventListener("error",Be),de=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),je()},5e3);const mt=v.src,wt=mt.includes("?")?"&":"?",Me=Date.now();v.src=`${mt}${wt}_reload=${Me}`})}catch(re){console.error("Iframe reload failed:",re)}finally{G(!1)}}},[r]),ee=b.useCallback(async()=>{J(!0);try{await Ag.delete(`/${bt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),q({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(v){console.error("Failed to clear cache:",v),q({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{J(!1)}},[q]),ne=b.useCallback(async()=>{if(!d){q({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}A(!0);try{const v=await fetch(`/api/${bt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:d})});if(!v.ok){let de=`Request failed with status ${v.status}`;try{const ae=await v.json();ae.message&&(de=ae.message)}catch{}q({title:"Failed to get standard components",description:de,variant:"destructive"});return}const re=await v.json(),fe=JSON.stringify(re.data,null,2);await navigator.clipboard.writeText(fe),q({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(v){console.error("Error copying standard components:",v),q({title:"Error",description:v instanceof Error?v.message:"Failed to copy standard components",variant:"destructive"})}finally{A(!1)}},[d,q]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"bg-sidebar flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[c.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded hover:bg-muted/60 shrink-0",children:c.jsx(nc,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),c.jsx(Ye,{className:"max-w-sm",children:c.jsxs("p",{className:"text-sm",children:["Preview uses ",bt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",zr," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||x)&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(xe,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||u||_===!1,children:[u?c.jsx(qt,{size:"sm"}):c.jsx(Th,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:_===!1?"Open preview to run":u?"Rendering preview...":"Render preview"})})]}),bt==="docx"&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[c.jsx(pa,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),c.jsx(Cg,{checked:i,onCheckedChange:s,disabled:x})]})}),c.jsx(Ye,{children:c.jsx("p",{children:x?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:m,disabled:L||o||u,children:L?c.jsx(qt,{size:"sm"}):c.jsx(Ah,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsx("p",{children:L?"Reloading...":"Reload"})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(xe,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||D||o,onClick:N,children:[D?c.jsx(qt,{size:"sm"}):c.jsx(zh,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download ",zr]})})]}),h&&h.length>0&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:"outline",size:"icon",className:"h-7 w-7 bg-amber-50 dark:bg-amber-950 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800 hover:bg-amber-100 dark:hover:bg-amber-900",disabled:k||o,onClick:R,children:k?c.jsx(qt,{size:"sm"}):c.jsx(sc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),p&&g&&c.jsxs(ma,{value:p,onValueChange:g,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ei,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:c.jsx(ga,{placeholder:"Renderer"})})}),c.jsx(Ye,{children:c.jsx("p",{children:"Select the rendering library"})})]}),c.jsx(Ii,{className:"text-sidebar-foreground",children:vo.map(v=>c.jsxs(hr,{value:v,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{tabIndex:-1,children:Xi[v][0]}),c.jsx(Ye,{children:Xi[v][1]})]})," ",v]},v))})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Gc,{children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Kc,{asChild:!0,children:c.jsx(xe,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(Oh,{className:"h-3.5 w-3.5"})})})}),c.jsx(Ye,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(va,{align:"end",className:"w-52",children:[f&&c.jsxs(Wt,{onClick:f,children:[c.jsx(rc,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),l&&c.jsxs(Wt,{onClick:l,children:[c.jsx(Ph,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),c.jsxs(Wt,{onClick:ne,disabled:!d||z,children:[c.jsx(ac,{className:"h-4 w-4 mr-2"}),z?"Copying...":"Copy standard components"]}),c.jsx(ai,{}),c.jsxs(Wt,{onClick:()=>V(!0),disabled:C,className:"text-destructive focus:text-destructive",children:[c.jsx(oa,{className:"h-4 w-4 mr-2"}),C?"Clearing...":"Clear all caches"]}),p&&g&&c.jsxs(c.Fragment,{children:[c.jsx(ai,{className:"lg:hidden"}),vo.map(v=>c.jsxs(Wt,{className:"lg:hidden",onClick:()=>g(v),children:[c.jsx("span",{className:"mr-2",children:p===v?"●":"○"}),Xi[v][0]," ",v]},v))]})]})]}),y&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:_?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:y,children:_?c.jsx(Yr,{className:"h-3.5 w-3.5"}):c.jsx(Dh,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[_?"Hide":"Show"," Preview ",c.jsx(Ds,{shortcut:"mod+shift+p"})]})})]}),w&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:S?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:w,children:c.jsx(oc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[S?"Close":"Open"," AI Chat ",c.jsx(Ds,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(Lt,{open:Z,onOpenChange:V,children:c.jsxs(zt,{className:"max-w-sm",children:[c.jsxs(mn,{children:[c.jsx(gn,{children:"Clear all caches?"}),c.jsx(Dn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),c.jsxs(pr,{children:[c.jsx(xe,{variant:"outline",size:"sm",onClick:()=>V(!1),children:"Cancel"}),c.jsx(xe,{variant:"destructive",size:"sm",disabled:C,onClick:async()=>{await ee(),V(!1)},children:C?c.jsx(qt,{size:"sm"}):"Clear"})]})]})})]})}const Dg=_e.memo(Pg);function wo({previewOpen:e,onTogglePreview:t}){const n=on(E=>E.name||""),r=on(E=>E.blob),i=on(E=>E.isGenerating),s=on(E=>E.text),a=on(E=>E.warnings),o=on(E=>E.isRendering),u=Or(E=>E.autoReload),l=Or(E=>E.renderingLibrary),f=Or(E=>E.setSettings),d=Or(E=>E.useGlobalPreviewHeader??!0),h=qe(E=>E.activeTab),p=qe(E=>E.documentTypes),g=h&&p[h]==="application/json+theme"?"theme":"document",w=Se(E=>E.chatOpen),S=Se(E=>E.toggleChat),[y,_]=_e.useState(!1);if(!d)return null;const x=b.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!u}),[u,f]),D=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),I=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),k=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(Dg,{name:k,blob:r,displayReloadButton:!1,autoReload:u,onToggleAutoReload:x,onManualRender:D,isGenerating:i,isRendering:!!o,onShowCacheMetrics:I,onShowSchemas:()=>_(!0),documentText:s,warnings:a,renderingLibrary:l,setRenderingLibrary:E=>f({renderingLibrary:E}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),c.jsx(Yc,{open:y,onOpenChange:_,defaultTab:g==="theme"?"theme":"document"})]})}function Rg(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Mg=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Fg=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$g={};function ko(e,t){return($g.jsx?Fg:Mg).test(e)}const Lg=/[ \t\n\f\r]/g;function Zg(e){return typeof e=="object"?e.type==="text"?_o(e.value):!1:_o(e)}function _o(e){return e.replace(Lg,"")===""}class jr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}jr.prototype.normal={};jr.prototype.property={};jr.prototype.space=void 0;function Xc(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new jr(n,r,t)}function Rs(e){return e.toLowerCase()}class ct{constructor(t,n){this.attribute=n,this.property=t}}ct.prototype.attribute="";ct.prototype.booleanish=!1;ct.prototype.boolean=!1;ct.prototype.commaOrSpaceSeparated=!1;ct.prototype.commaSeparated=!1;ct.prototype.defined=!1;ct.prototype.mustUseProperty=!1;ct.prototype.number=!1;ct.prototype.overloadedBoolean=!1;ct.prototype.property="";ct.prototype.spaceSeparated=!1;ct.prototype.space=void 0;let Vg=0;const me=bn(),Je=bn(),Ms=bn(),H=bn(),Ae=bn(),On=bn(),ft=bn();function bn(){return 2**++Vg}const Fs=Object.freeze(Object.defineProperty({__proto__:null,boolean:me,booleanish:Je,commaOrSpaceSeparated:ft,commaSeparated:On,number:H,overloadedBoolean:Ms,spaceSeparated:Ae},Symbol.toStringTag,{value:"Module"})),Qi=Object.keys(Fs);class wa extends ct{constructor(t,n,r,i){let s=-1;if(super(t,n),So(this,"space",i),typeof r=="number")for(;++s<Qi.length;){const a=Qi[s];So(this,Qi[s],(r&Fs[a])===Fs[a])}}}wa.prototype.defined=!0;function So(e,t,n){n&&(e[t]=n)}function Zn(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new wa(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Rs(r)]=r,n[Rs(s.attribute)]=r}return new jr(t,n,e.space)}const Qc=Zn({properties:{ariaActiveDescendant:null,ariaAtomic:Je,ariaAutoComplete:null,ariaBusy:Je,ariaChecked:Je,ariaColCount:H,ariaColIndex:H,ariaColSpan:H,ariaControls:Ae,ariaCurrent:null,ariaDescribedBy:Ae,ariaDetails:null,ariaDisabled:Je,ariaDropEffect:Ae,ariaErrorMessage:null,ariaExpanded:Je,ariaFlowTo:Ae,ariaGrabbed:Je,ariaHasPopup:null,ariaHidden:Je,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ae,ariaLevel:H,ariaLive:null,ariaModal:Je,ariaMultiLine:Je,ariaMultiSelectable:Je,ariaOrientation:null,ariaOwns:Ae,ariaPlaceholder:null,ariaPosInSet:H,ariaPressed:Je,ariaReadOnly:Je,ariaRelevant:null,ariaRequired:Je,ariaRoleDescription:Ae,ariaRowCount:H,ariaRowIndex:H,ariaRowSpan:H,ariaSelected:Je,ariaSetSize:H,ariaSort:null,ariaValueMax:H,ariaValueMin:H,ariaValueNow:H,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function ed(e,t){return t in e?e[t]:t}function td(e,t){return ed(e,t.toLowerCase())}const Bg=Zn({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:On,acceptCharset:Ae,accessKey:Ae,action:null,allow:null,allowFullScreen:me,allowPaymentRequest:me,allowUserMedia:me,alt:null,as:null,async:me,autoCapitalize:null,autoComplete:Ae,autoFocus:me,autoPlay:me,blocking:Ae,capture:null,charSet:null,checked:me,cite:null,className:Ae,cols:H,colSpan:null,content:null,contentEditable:Je,controls:me,controlsList:Ae,coords:H|On,crossOrigin:null,data:null,dateTime:null,decoding:null,default:me,defer:me,dir:null,dirName:null,disabled:me,download:Ms,draggable:Je,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:me,formTarget:null,headers:Ae,height:H,hidden:Ms,high:H,href:null,hrefLang:null,htmlFor:Ae,httpEquiv:Ae,id:null,imageSizes:null,imageSrcSet:null,inert:me,inputMode:null,integrity:null,is:null,isMap:me,itemId:null,itemProp:Ae,itemRef:Ae,itemScope:me,itemType:Ae,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:me,low:H,manifest:null,max:null,maxLength:H,media:null,method:null,min:null,minLength:H,multiple:me,muted:me,name:null,nonce:null,noModule:me,noValidate:me,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:me,optimum:H,pattern:null,ping:Ae,placeholder:null,playsInline:me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:me,referrerPolicy:null,rel:Ae,required:me,reversed:me,rows:H,rowSpan:H,sandbox:Ae,scope:null,scoped:me,seamless:me,selected:me,shadowRootClonable:me,shadowRootDelegatesFocus:me,shadowRootMode:null,shape:null,size:H,sizes:null,slot:null,span:H,spellCheck:Je,src:null,srcDoc:null,srcLang:null,srcSet:null,start:H,step:null,style:null,tabIndex:H,target:null,title:null,translate:null,type:null,typeMustMatch:me,useMap:null,value:Je,width:H,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ae,axis:null,background:null,bgColor:null,border:H,borderColor:null,bottomMargin:H,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:me,declare:me,event:null,face:null,frame:null,frameBorder:null,hSpace:H,leftMargin:H,link:null,longDesc:null,lowSrc:null,marginHeight:H,marginWidth:H,noResize:me,noHref:me,noShade:me,noWrap:me,object:null,profile:null,prompt:null,rev:null,rightMargin:H,rules:null,scheme:null,scrolling:Je,standby:null,summary:null,text:null,topMargin:H,valueType:null,version:null,vAlign:null,vLink:null,vSpace:H,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:me,disableRemotePlayback:me,prefix:null,property:null,results:H,security:null,unselectable:null},space:"html",transform:td}),Ug=Zn({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ft,accentHeight:H,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:H,amplitude:H,arabicForm:null,ascent:H,attributeName:null,attributeType:null,azimuth:H,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:H,by:null,calcMode:null,capHeight:H,className:Ae,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:H,diffuseConstant:H,direction:null,display:null,dur:null,divisor:H,dominantBaseline:null,download:me,dx:null,dy:null,edgeMode:null,editable:null,elevation:H,enableBackground:null,end:null,event:null,exponent:H,externalResourcesRequired:null,fill:null,fillOpacity:H,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:On,g2:On,glyphName:On,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:H,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:H,horizOriginX:H,horizOriginY:H,id:null,ideographic:H,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:H,k:H,k1:H,k2:H,k3:H,k4:H,kernelMatrix:ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:H,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:H,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:H,overlineThickness:H,paintOrder:null,panose1:null,path:null,pathLength:H,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ae,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:H,pointsAtY:H,pointsAtZ:H,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ft,rev:ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ft,requiredFeatures:ft,requiredFonts:ft,requiredFormats:ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:H,specularExponent:H,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:H,strikethroughThickness:H,string:null,stroke:null,strokeDashArray:ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:H,strokeOpacity:H,strokeWidth:null,style:null,surfaceScale:H,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ft,tabIndex:H,tableValues:null,target:null,targetX:H,targetY:H,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:H,underlineThickness:H,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:H,values:null,vAlphabetic:H,vMathematical:H,vectorEffect:null,vHanging:H,vIdeographic:H,version:null,vertAdvY:H,vertOriginX:H,vertOriginY:H,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:H,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ed}),nd=Zn({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),rd=Zn({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:td}),id=Zn({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Jg={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},qg=/[A-Z]/g,jo=/-[a-z]/g,Hg=/^data[-\w.:]+$/i;function Wg(e,t){const n=Rs(t);let r=t,i=ct;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hg.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(jo,Kg);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!jo.test(s)){let a=s.replace(qg,Gg);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=wa}return new i(r,t)}function Gg(e){return"-"+e.toLowerCase()}function Kg(e){return e.charAt(1).toUpperCase()}const Yg=Xc([Qc,Bg,nd,rd,id],"html"),ka=Xc([Qc,Ug,nd,rd,id],"svg");function Xg(e){return e.join(" ").trim()}var kn={},es,No;function Qg(){if(No)return es;No=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,u=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-CtwF-qwA.js","assets/query-vendor-UL64zsGL.js","assets/react-vendor-DhdcN9D5.js","assets/radix-ui-CXavUarI.js","assets/editor-monaco-json-DHRbpQ-v.js","assets/index-CGQAncgl.js","assets/ui-vendor-C6DsfOoA.js","assets/monaco-editor-DzeBDgmk.js","assets/state-vendor-CAMVKh-F.js","assets/index-B9dV-vCI.css","assets/settings-store-provider-BEzje7_o.js","assets/button-CMkwEplC.js","assets/preview-38guLS86.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Bp=Object.defineProperty;var Up=(e,t,n)=>t in e?Bp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ga=(e,t,n)=>Up(e,typeof t!="symbol"?t+"":t,n);import{j as c,b as Jp}from"./query-vendor-UL64zsGL.js";import{a as _e,f as xu,h as ia,i as yu,r as b,j as bu,k as vi,l as wi,D as ki,m as _i,n as vu,o as qp,V as Hp,p as wu,I as Wp,q as Gp,s as ku,t as Kp,v as _u,w as Yp,x as Xp,G as Qp,S as Su,y as ju,L as Nu,z as Cu,A as eh,E as th,F as nh,H as Eu,J as Iu,K as Tu,M as Au,N as zu,Q as Ou,U as Pu,W as Du,X as Ru,Y as Mu,Z as Fu,_ as rh,$ as ih,a0 as $u,a1 as sh,a2 as ah,a3 as Lu,a4 as Zu,a5 as Vu,a6 as oh,a7 as lh,a8 as uh,a9 as ch,aa as dh,ab as fh,ac as Bu,ad as Uu,ae as Ju,af as qu,ag as Hu,ah as Wu,ai as Gu,aj as Ku,ak as Yu,al as ph,am as hh,an as mh,ao as gh,ap as xh,g as sa}from"./react-vendor-DhdcN9D5.js";import{B as xe}from"./button-CMkwEplC.js";import{c as B,T as Tr,C as yh,E as bh,F as bt,S as qt,a as vh,b as Ge,d as Ke,e as Ye,u as Si,f as $t,g as Xu,s as Zi,_ as Qu,h as Ar,A as wh,i as zr}from"./index-CGQAncgl.js";import{X as hn,a as _r,C as pn,b as Kt,d as kh,e as fr,f as ec,P as _h,g as Ka,h as Qn,F as ks,S as tc,i as Ya,j as Xa,k as Qa,I as nc,l as rc,E as Yr,m as aa,n as Sh,M as jh,o as Nh,p as Ch,q as ic,r as Eh,s as Vi,t as Xr,u as eo,G as Ih,v as Th,R as Ah,w as zh,T as sc,x as Oh,y as Ph,z as ac,A as oa,B as Dh,D as oc,H as Rh,J as Mh,K as to,L as Fh,N as _s,O as $h}from"./ui-vendor-C6DsfOoA.js";import{S as Ln}from"./radix-ui-CXavUarI.js";import{i as Lh,u as qe,a as lc,b as on,g as Ss,c as Or,S as Zh,O as Vh,T as Bh,D as Uh}from"./settings-store-provider-BEzje7_o.js";import{a as Jh,d as qh,p as Hh,b as Wh,u as Gh,e as Kh}from"./state-vendor-CAMVKh-F.js";var Sr=e=>e.type==="checkbox",dn=e=>e instanceof Date,it=e=>e==null;const uc=e=>typeof e=="object";var Ve=e=>!it(e)&&!Array.isArray(e)&&uc(e)&&!dn(e),cc=e=>Ve(e)&&e.target?Sr(e.target)?e.target.checked:e.target.value:e,Yh=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,dc=(e,t)=>e.has(Yh(t)),Xh=e=>{const t=e.constructor&&e.constructor.prototype;return Ve(t)&&t.hasOwnProperty("isPrototypeOf")},la=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function lt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(la&&(e instanceof Blob||r))&&(n||Ve(e)))if(t=n?[]:{},!n&&!Xh(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=lt(e[i]));else return e;return t}var ji=e=>Array.isArray(e)?e.filter(Boolean):[],Ze=e=>e===void 0,X=(e,t,n)=>{if(!t||!Ve(e))return n;const r=ji(t.split(/[,[\].]+?/)).reduce((i,s)=>it(i)?i:i[s],e);return Ze(r)||r===e?Ze(e[t])?n:e[t]:r},xt=e=>typeof e=="boolean",ua=e=>/^\w*$/.test(e),fc=e=>ji(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Ce=(e,t,n)=>{let r=-1;const i=ua(t)?[t]:fc(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let u=n;if(r!==a){const l=e[o];u=Ve(l)||Array.isArray(l)?l:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=u,e=e[o]}return e};const Qr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},jt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},pc=_e.createContext(null),Ni=()=>_e.useContext(pc),Qh=e=>{const{children:t,...n}=e;return _e.createElement(pc.Provider,{value:n},t)};var hc=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==jt.all&&(t._proxyFormState[a]=!r||jt.all),n&&(n[a]=!0),e[a]}});return i},ut=e=>Ve(e)&&!Object.keys(e).length,mc=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return ut(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||jt.all))},ar=e=>Array.isArray(e)?e:[e],gc=(e,t,n)=>!e||!t||e===t||ar(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function ca(e){const t=_e.useRef(e);t.current=e,_e.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function em(e){const t=Ni(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=_e.useState(n._formState),u=_e.useRef(!0),l=_e.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=_e.useRef(i);return f.current=i,ca({disabled:r,next:d=>u.current&&gc(f.current,d.name,s)&&mc(d,l.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),_e.useEffect(()=>(u.current=!0,l.current.isValid&&n._updateValid(!0),()=>{u.current=!1}),[n]),_e.useMemo(()=>hc(a,n,l.current,!1),[a,n])}var At=e=>typeof e=="string",xc=(e,t,n,r,i)=>At(e)?(r&&t.watch.add(e),X(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),X(n,s))):(r&&(t.watchAll=!0),n);function tm(e){const t=Ni(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=_e.useRef(r);o.current=r,ca({disabled:s,subject:n._subjects.values,next:f=>{gc(o.current,f.name,a)&&l(lt(xc(o.current,n._names,f.values||n._formValues,!1,i)))}});const[u,l]=_e.useState(n._getWatch(r,i));return _e.useEffect(()=>n._removeUnmounted()),u}function nm(e){const t=Ni(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=dc(i._names.array,n),o=tm({control:i,name:n,defaultValue:X(i._formValues,n,X(i._defaultValues,n,e.defaultValue)),exact:!0}),u=em({control:i,name:n,exact:!0}),l=_e.useRef(i.register(n,{...e.rules,value:o,...xt(e.disabled)?{disabled:e.disabled}:{}})),f=_e.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!X(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!X(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!X(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!X(u.validatingFields,n)},error:{enumerable:!0,get:()=>X(u.errors,n)}}),[u,n]),d=_e.useMemo(()=>({name:n,value:o,...xt(r)||u.disabled?{disabled:u.disabled||r}:{},onChange:h=>l.current.onChange({target:{value:cc(h),name:n},type:Qr.CHANGE}),onBlur:()=>l.current.onBlur({target:{value:X(i._formValues,n),name:n},type:Qr.BLUR}),ref:h=>{const p=X(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:g=>h.setCustomValidity(g),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,u.disabled,o,i._fields]);return _e.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(g,w)=>{const S=X(i._fields,g);S&&S._f&&(S._f.mount=w)};if(p(n,!0),h){const g=lt(X(i._options.defaultValues,n));Ce(i._defaultValues,n,g),Ze(X(i._formValues,n))&&Ce(i._formValues,n,g)}return!a&&i.register(n),()=>{(a?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,a,s]),_e.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),_e.useMemo(()=>({field:d,formState:u,fieldState:f}),[d,u,f])}const rm=e=>e.render(nm(e));var im=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},no=e=>({isOnSubmit:!e||e===jt.onSubmit,isOnBlur:e===jt.onBlur,isOnChange:e===jt.onChange,isOnAll:e===jt.all,isOnTouch:e===jt.onTouched}),ro=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const or=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=X(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(or(o,t))break}else if(Ve(o)&&or(o,t))break}}};var sm=(e,t,n)=>{const r=ar(X(e,n));return Ce(r,"root",t[n]),Ce(e,n,r),e},da=e=>e.type==="file",Tt=e=>typeof e=="function",ei=e=>{if(!la)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Br=e=>At(e),fa=e=>e.type==="radio",ti=e=>e instanceof RegExp;const io={value:!1,isValid:!1},so={value:!0,isValid:!0};var yc=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ze(e[0].attributes.value)?Ze(e[0].value)||e[0].value===""?so:{value:e[0].value,isValid:!0}:so:io}return io};const ao={isValid:!1,value:null};var bc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,ao):ao;function oo(e,t,n="validate"){if(Br(e)||Array.isArray(e)&&e.every(Br)||xt(e)&&!e)return{type:n,message:Br(e)?e:"",ref:t}}var wn=e=>Ve(e)&&!ti(e)?e:{value:e,message:""},lo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:u,maxLength:l,minLength:f,min:d,max:h,pattern:p,validate:g,name:w,valueAsNumber:S,mount:y}=e._f,_=X(n,w);if(!y||t.has(w))return{};const x=o?o[0]:a,D=Z=>{i&&x.reportValidity&&(x.setCustomValidity(xt(Z)?"":Z||""),x.reportValidity())},I={},k=fa(a),E=Sr(a),L=k||E,G=(S||da(a))&&Ze(a.value)&&Ze(_)||ei(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,C=im.bind(null,w,r,I),J=(Z,V,z,A=Ft.maxLength,q=Ft.minLength)=>{const F=Z?V:z;I[w]={type:Z?A:q,message:F,ref:a,...C(Z?A:q,F)}};if(s?!Array.isArray(_)||!_.length:u&&(!L&&(G||it(_))||xt(_)&&!_||E&&!yc(o).isValid||k&&!bc(o).isValid)){const{value:Z,message:V}=Br(u)?{value:!!u,message:u}:wn(u);if(Z&&(I[w]={type:Ft.required,message:V,ref:x,...C(Ft.required,V)},!r))return D(V),I}if(!G&&(!it(d)||!it(h))){let Z,V;const z=wn(h),A=wn(d);if(!it(_)&&!isNaN(_)){const q=a.valueAsNumber||_&&+_;it(z.value)||(Z=q>z.value),it(A.value)||(V=q<A.value)}else{const q=a.valueAsDate||new Date(_),F=m=>new Date(new Date().toDateString()+" "+m),N=a.type=="time",R=a.type=="week";At(z.value)&&_&&(Z=N?F(_)>F(z.value):R?_>z.value:q>new Date(z.value)),At(A.value)&&_&&(V=N?F(_)<F(A.value):R?_<A.value:q<new Date(A.value))}if((Z||V)&&(J(!!Z,z.message,A.message,Ft.max,Ft.min),!r))return D(I[w].message),I}if((l||f)&&!G&&(At(_)||s&&Array.isArray(_))){const Z=wn(l),V=wn(f),z=!it(Z.value)&&_.length>+Z.value,A=!it(V.value)&&_.length<+V.value;if((z||A)&&(J(z,Z.message,V.message),!r))return D(I[w].message),I}if(p&&!G&&At(_)){const{value:Z,message:V}=wn(p);if(ti(Z)&&!_.match(Z)&&(I[w]={type:Ft.pattern,message:V,ref:a,...C(Ft.pattern,V)},!r))return D(V),I}if(g){if(Tt(g)){const Z=await g(_,n),V=oo(Z,x);if(V&&(I[w]={...V,...C(Ft.validate,V.message)},!r))return D(V.message),I}else if(Ve(g)){let Z={};for(const V in g){if(!ut(Z)&&!r)break;const z=oo(await g[V](_,n),x,V);z&&(Z={...z,...C(V,z.message)},D(z.message),r&&(I[w]=Z))}if(!ut(Z)&&(I[w]={ref:x,...Z},!r))return I}}return D(!0),I};function am(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Ze(e)?r++:e[t[r++]];return e}function om(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ze(e[t]))return!1;return!0}function We(e,t){const n=Array.isArray(t)?t:ua(t)?[t]:fc(t),r=n.length===1?e:am(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Ve(r)&&ut(r)||Array.isArray(r)&&om(r))&&We(e,n.slice(0,-1)),e}var Bi=()=>{let e=[];return{get observers(){return e},next:i=>{for(const s of e)s.next&&s.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(s=>s!==i)}}),unsubscribe:()=>{e=[]}}},js=e=>it(e)||!uc(e);function Ht(e,t){if(js(e)||js(t))return e===t;if(dn(e)&&dn(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const a=t[i];if(dn(s)&&dn(a)||Ve(s)&&Ve(a)||Array.isArray(s)&&Array.isArray(a)?!Ht(s,a):s!==a)return!1}}return!0}var vc=e=>e.type==="select-multiple",lm=e=>fa(e)||Sr(e),Ui=e=>ei(e)&&e.isConnected,wc=e=>{for(const t in e)if(Tt(e[t]))return!0;return!1};function ni(e,t={}){const n=Array.isArray(e);if(Ve(e)||n)for(const r in e)Array.isArray(e[r])||Ve(e[r])&&!wc(e[r])?(t[r]=Array.isArray(e[r])?[]:{},ni(e[r],t[r])):it(e[r])||(t[r]=!0);return t}function kc(e,t,n){const r=Array.isArray(e);if(Ve(e)||r)for(const i in e)Array.isArray(e[i])||Ve(e[i])&&!wc(e[i])?Ze(t)||js(n[i])?n[i]=Array.isArray(e[i])?ni(e[i],[]):{...ni(e[i])}:kc(e[i],it(t)?{}:t[i],n[i]):n[i]=!Ht(e[i],t[i]);return n}var Jn=(e,t)=>kc(e,t,ni(t)),_c=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ze(e)?e:t?e===""?NaN:e&&+e:n&&At(e)?new Date(e):r?r(e):e;function Ji(e){const t=e.ref;return da(t)?t.files:fa(t)?bc(e.refs).value:vc(t)?[...t.selectedOptions].map(({value:n})=>n):Sr(t)?yc(e.refs).value:_c(Ze(t.value)?e.ref.value:t.value,e)}var um=(e,t,n,r)=>{const i={};for(const s of e){const a=X(t,s);a&&Ce(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},qn=e=>Ze(e)?e:ti(e)?e.source:Ve(e)?ti(e.value)?e.value.source:e.value:e;const uo="AsyncFunction";var cm=e=>!!e&&!!e.validate&&!!(Tt(e.validate)&&e.validate.constructor.name===uo||Ve(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===uo)),dm=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function co(e,t,n){const r=X(e,n);if(r||ua(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=X(t,s),o=X(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var fm=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,pm=(e,t)=>!ji(X(e,t)).length&&We(e,t);const hm={mode:jt.onSubmit,reValidateMode:jt.onChange,shouldFocusError:!0};function mm(e={}){let t={...hm,...e},n={submitCount:0,isDirty:!1,isLoading:Tt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=Ve(t.defaultValues)||Ve(t.values)?lt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:lt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u,l=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:Bi(),array:Bi(),state:Bi()},h=no(t.mode),p=no(t.reValidateMode),g=t.criteriaMode===jt.all,w=j=>T=>{clearTimeout(l),l=setTimeout(j,T)},S=async j=>{if(!t.disabled&&(f.isValid||j)){const T=t.resolver?ut((await L()).errors):await C(r,!0);T!==n.isValid&&d.state.next({isValid:T})}},y=(j,T)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((j||Array.from(o.mount)).forEach(M=>{M&&(T?Ce(n.validatingFields,M,T):We(n.validatingFields,M))}),d.state.next({validatingFields:n.validatingFields,isValidating:!ut(n.validatingFields)}))},_=(j,T=[],M,Q,K=!0,W=!0)=>{if(Q&&M&&!t.disabled){if(a.action=!0,W&&Array.isArray(X(r,j))){const ie=M(X(r,j),Q.argA,Q.argB);K&&Ce(r,j,ie)}if(W&&Array.isArray(X(n.errors,j))){const ie=M(X(n.errors,j),Q.argA,Q.argB);K&&Ce(n.errors,j,ie),pm(n.errors,j)}if(f.touchedFields&&W&&Array.isArray(X(n.touchedFields,j))){const ie=M(X(n.touchedFields,j),Q.argA,Q.argB);K&&Ce(n.touchedFields,j,ie)}f.dirtyFields&&(n.dirtyFields=Jn(i,s)),d.state.next({name:j,isDirty:Z(j,T),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Ce(s,j,T)},x=(j,T)=>{Ce(n.errors,j,T),d.state.next({errors:n.errors})},D=j=>{n.errors=j,d.state.next({errors:n.errors,isValid:!1})},I=(j,T,M,Q)=>{const K=X(r,j);if(K){const W=X(s,j,Ze(M)?X(i,j):M);Ze(W)||Q&&Q.defaultChecked||T?Ce(s,j,T?W:Ji(K._f)):A(j,W),a.mount&&S()}},k=(j,T,M,Q,K)=>{let W=!1,ie=!1;const he={name:j};if(!t.disabled){const P=!!(X(r,j)&&X(r,j)._f&&X(r,j)._f.disabled);if(!M||Q){f.isDirty&&(ie=n.isDirty,n.isDirty=he.isDirty=Z(),W=ie!==he.isDirty);const U=P||Ht(X(i,j),T);ie=!!(!P&&X(n.dirtyFields,j)),U||P?We(n.dirtyFields,j):Ce(n.dirtyFields,j,!0),he.dirtyFields=n.dirtyFields,W=W||f.dirtyFields&&ie!==!U}if(M){const U=X(n.touchedFields,j);U||(Ce(n.touchedFields,j,M),he.touchedFields=n.touchedFields,W=W||f.touchedFields&&U!==M)}W&&K&&d.state.next(he)}return W?he:{}},E=(j,T,M,Q)=>{const K=X(n.errors,j),W=f.isValid&&xt(T)&&n.isValid!==T;if(t.delayError&&M?(u=w(()=>x(j,M)),u(t.delayError)):(clearTimeout(l),u=null,M?Ce(n.errors,j,M):We(n.errors,j)),(M?!Ht(K,M):K)||!ut(Q)||W){const ie={...Q,...W&&xt(T)?{isValid:T}:{},errors:n.errors,name:j};n={...n,...ie},d.state.next(ie)}},L=async j=>{y(j,!0);const T=await t.resolver(s,t.context,um(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(j),T},G=async j=>{const{errors:T}=await L(j);if(j)for(const M of j){const Q=X(T,M);Q?Ce(n.errors,M,Q):We(n.errors,M)}else n.errors=T;return T},C=async(j,T,M={valid:!0})=>{for(const Q in j){const K=j[Q];if(K){const{_f:W,...ie}=K;if(W){const he=o.array.has(W.name),P=K._f&&cm(K._f);P&&f.validatingFields&&y([Q],!0);const U=await lo(K,o.disabled,s,g,t.shouldUseNativeValidation&&!T,he);if(P&&f.validatingFields&&y([Q]),U[W.name]&&(M.valid=!1,T))break;!T&&(X(U,W.name)?he?sm(n.errors,U,W.name):Ce(n.errors,W.name,U[W.name]):We(n.errors,W.name))}!ut(ie)&&await C(ie,T,M)}}return M.valid},J=()=>{for(const j of o.unMount){const T=X(r,j);T&&(T._f.refs?T._f.refs.every(M=>!Ui(M)):!Ui(T._f.ref))&&de(j)}o.unMount=new Set},Z=(j,T)=>!t.disabled&&(j&&T&&Ce(s,j,T),!Ht(ee(),i)),V=(j,T,M)=>xc(j,o,{...a.mount?s:Ze(T)?i:At(j)?{[j]:T}:T},M,T),z=j=>ji(X(a.mount?s:i,j,t.shouldUnregister?X(i,j,[]):[])),A=(j,T,M={})=>{const Q=X(r,j);let K=T;if(Q){const W=Q._f;W&&(!W.disabled&&Ce(s,j,_c(T,W)),K=ei(W.ref)&&it(T)?"":T,vc(W.ref)?[...W.ref.options].forEach(ie=>ie.selected=K.includes(ie.value)):W.refs?Sr(W.ref)?W.refs.length>1?W.refs.forEach(ie=>(!ie.defaultChecked||!ie.disabled)&&(ie.checked=Array.isArray(K)?!!K.find(he=>he===ie.value):K===ie.value)):W.refs[0]&&(W.refs[0].checked=!!K):W.refs.forEach(ie=>ie.checked=ie.value===K):da(W.ref)?W.ref.value="":(W.ref.value=K,W.ref.type||d.values.next({name:j,values:{...s}})))}(M.shouldDirty||M.shouldTouch)&&k(j,K,M.shouldTouch,M.shouldDirty,!0),M.shouldValidate&&m(j)},q=(j,T,M)=>{for(const Q in T){const K=T[Q],W=`${j}.${Q}`,ie=X(r,W);(o.array.has(j)||Ve(K)||ie&&!ie._f)&&!dn(K)?q(W,K,M):A(W,K,M)}},F=(j,T,M={})=>{const Q=X(r,j),K=o.array.has(j),W=lt(T);Ce(s,j,W),K?(d.array.next({name:j,values:{...s}}),(f.isDirty||f.dirtyFields)&&M.shouldDirty&&d.state.next({name:j,dirtyFields:Jn(i,s),isDirty:Z(j,W)})):Q&&!Q._f&&!it(W)?q(j,W,M):A(j,W,M),ro(j,o)&&d.state.next({...n}),d.values.next({name:a.mount?j:void 0,values:{...s}})},N=async j=>{a.mount=!0;const T=j.target;let M=T.name,Q=!0;const K=X(r,M),W=()=>T.type?Ji(K._f):cc(j),ie=he=>{Q=Number.isNaN(he)||dn(he)&&isNaN(he.getTime())||Ht(he,X(s,M,he))};if(K){let he,P;const U=W(),se=j.type===Qr.BLUR||j.type===Qr.FOCUS_OUT,ge=!dm(K._f)&&!t.resolver&&!X(n.errors,M)&&!K._f.deps||fm(se,X(n.touchedFields,M),n.isSubmitted,p,h),O=ro(M,o,se);Ce(s,M,U),se?(K._f.onBlur&&K._f.onBlur(j),u&&u(0)):K._f.onChange&&K._f.onChange(j);const oe=k(M,U,se,!1),be=!ut(oe)||O;if(!se&&d.values.next({name:M,type:j.type,values:{...s}}),ge)return f.isValid&&(t.mode==="onBlur"&&se?S():se||S()),be&&d.state.next({name:M,...O?{}:oe});if(!se&&O&&d.state.next({...n}),t.resolver){const{errors:Te}=await L([M]);if(ie(U),Q){const He=co(n.errors,r,M),Ue=co(Te,r,He.name||M);he=Ue.error,M=Ue.name,P=ut(Te)}}else y([M],!0),he=(await lo(K,o.disabled,s,g,t.shouldUseNativeValidation))[M],y([M]),ie(U),Q&&(he?P=!1:f.isValid&&(P=await C(r,!0)));Q&&(K._f.deps&&m(K._f.deps),E(M,P,he,oe))}},R=(j,T)=>{if(X(n.errors,T)&&j.focus)return j.focus(),1},m=async(j,T={})=>{let M,Q;const K=ar(j);if(t.resolver){const W=await G(Ze(j)?j:K);M=ut(W),Q=j?!K.some(ie=>X(W,ie)):M}else j?(Q=(await Promise.all(K.map(async W=>{const ie=X(r,W);return await C(ie&&ie._f?{[W]:ie}:ie)}))).every(Boolean),!(!Q&&!n.isValid)&&S()):Q=M=await C(r);return d.state.next({...!At(j)||f.isValid&&M!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:M}:{},errors:n.errors}),T.shouldFocus&&!Q&&or(r,R,j?K:o.mount),Q},ee=j=>{const T={...a.mount?s:i};return Ze(j)?T:At(j)?X(T,j):j.map(M=>X(T,M))},ne=(j,T)=>({invalid:!!X((T||n).errors,j),isDirty:!!X((T||n).dirtyFields,j),error:X((T||n).errors,j),isValidating:!!X(n.validatingFields,j),isTouched:!!X((T||n).touchedFields,j)}),v=j=>{j&&ar(j).forEach(T=>We(n.errors,T)),d.state.next({errors:j?n.errors:{}})},re=(j,T,M)=>{const Q=(X(r,j,{_f:{}})._f||{}).ref,K=X(n.errors,j)||{},{ref:W,message:ie,type:he,...P}=K;Ce(n.errors,j,{...P,...T,ref:Q}),d.state.next({name:j,errors:n.errors,isValid:!1}),M&&M.shouldFocus&&Q&&Q.focus&&Q.focus()},fe=(j,T)=>Tt(j)?d.values.subscribe({next:M=>j(V(void 0,T),M)}):V(j,T,!0),de=(j,T={})=>{for(const M of j?ar(j):o.mount)o.mount.delete(M),o.array.delete(M),T.keepValue||(We(r,M),We(s,M)),!T.keepError&&We(n.errors,M),!T.keepDirty&&We(n.dirtyFields,M),!T.keepTouched&&We(n.touchedFields,M),!T.keepIsValidating&&We(n.validatingFields,M),!t.shouldUnregister&&!T.keepDefaultValue&&We(i,M);d.values.next({values:{...s}}),d.state.next({...n,...T.keepDirty?{isDirty:Z()}:{}}),!T.keepIsValid&&S()},ae=({disabled:j,name:T,field:M,fields:Q})=>{(xt(j)&&a.mount||j||o.disabled.has(T))&&(j?o.disabled.add(T):o.disabled.delete(T),k(T,Ji(M?M._f:X(Q,T)._f),!1,!1,!0))},le=(j,T={})=>{let M=X(r,j);const Q=xt(T.disabled)||xt(t.disabled);return Ce(r,j,{...M||{},_f:{...M&&M._f?M._f:{ref:{name:j}},name:j,mount:!0,...T}}),o.mount.add(j),M?ae({field:M,disabled:xt(T.disabled)?T.disabled:t.disabled,name:j}):I(j,!0,T.value),{...Q?{disabled:T.disabled||t.disabled}:{},...t.progressive?{required:!!T.required,min:qn(T.min),max:qn(T.max),minLength:qn(T.minLength),maxLength:qn(T.maxLength),pattern:qn(T.pattern)}:{},name:j,onChange:N,onBlur:N,ref:K=>{if(K){le(j,T),M=X(r,j);const W=Ze(K.value)&&K.querySelectorAll&&K.querySelectorAll("input,select,textarea")[0]||K,ie=lm(W),he=M._f.refs||[];if(ie?he.find(P=>P===W):W===M._f.ref)return;Ce(r,j,{_f:{...M._f,...ie?{refs:[...he.filter(Ui),W,...Array.isArray(X(i,j))?[{}]:[]],ref:{type:W.type,name:j}}:{ref:W}}}),I(j,!1,void 0,W)}else M=X(r,j,{}),M._f&&(M._f.mount=!1),(t.shouldUnregister||T.shouldUnregister)&&!(dc(o.array,j)&&a.action)&&o.unMount.add(j)}}},je=()=>t.shouldFocusError&&or(r,R,o.mount),Le=j=>{xt(j)&&(d.state.next({disabled:j}),or(r,(T,M)=>{const Q=X(r,M);Q&&(T.disabled=Q._f.disabled||j,Array.isArray(Q._f.refs)&&Q._f.refs.forEach(K=>{K.disabled=Q._f.disabled||j}))},0,!1))},Be=(j,T)=>async M=>{let Q;M&&(M.preventDefault&&M.preventDefault(),M.persist&&M.persist());let K=lt(s);if(o.disabled.size)for(const W of o.disabled)Ce(K,W,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:W,values:ie}=await L();n.errors=W,K=ie}else await C(r);if(We(n.errors,"root"),ut(n.errors)){d.state.next({errors:{}});try{await j(K,M)}catch(W){Q=W}}else T&&await T({...n.errors},M),je(),setTimeout(je);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ut(n.errors)&&!Q,submitCount:n.submitCount+1,errors:n.errors}),Q)throw Q},mt=(j,T={})=>{X(r,j)&&(Ze(T.defaultValue)?F(j,lt(X(i,j))):(F(j,T.defaultValue),Ce(i,j,lt(T.defaultValue))),T.keepTouched||We(n.touchedFields,j),T.keepDirty||(We(n.dirtyFields,j),n.isDirty=T.defaultValue?Z(j,lt(X(i,j))):Z()),T.keepError||(We(n.errors,j),f.isValid&&S()),d.state.next({...n}))},wt=(j,T={})=>{const M=j?lt(j):i,Q=lt(M),K=ut(j),W=K?i:Q;if(T.keepDefaultValues||(i=M),!T.keepValues){if(T.keepDirtyValues){const ie=new Set([...o.mount,...Object.keys(Jn(i,s))]);for(const he of Array.from(ie))X(n.dirtyFields,he)?Ce(W,he,X(s,he)):F(he,X(W,he))}else{if(la&&Ze(j))for(const ie of o.mount){const he=X(r,ie);if(he&&he._f){const P=Array.isArray(he._f.refs)?he._f.refs[0]:he._f.ref;if(ei(P)){const U=P.closest("form");if(U){U.reset();break}}}}r={}}s=t.shouldUnregister?T.keepDefaultValues?lt(i):{}:lt(W),d.array.next({values:{...W}}),d.values.next({values:{...W}})}o={mount:T.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!T.keepIsValid||!!T.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:T.keepSubmitCount?n.submitCount:0,isDirty:K?!1:T.keepDirty?n.isDirty:!!(T.keepDefaultValues&&!Ht(j,i)),isSubmitted:T.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:K?{}:T.keepDirtyValues?T.keepDefaultValues&&s?Jn(i,s):n.dirtyFields:T.keepDefaultValues&&j?Jn(i,j):T.keepDirty?n.dirtyFields:{},touchedFields:T.keepTouched?n.touchedFields:{},errors:T.keepErrors?n.errors:{},isSubmitSuccessful:T.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Me=(j,T)=>wt(Tt(j)?j(s):j,T);return{control:{register:le,unregister:de,getFieldState:ne,handleSubmit:Be,setError:re,_executeSchema:L,_getWatch:V,_getDirty:Z,_updateValid:S,_removeUnmounted:J,_updateFieldArray:_,_updateDisabledField:ae,_getFieldArray:z,_reset:wt,_resetDefaultValues:()=>Tt(t.defaultValues)&&t.defaultValues().then(j=>{Me(j,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:Le,_subjects:d,_proxyFormState:f,_setErrors:D,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:m,register:le,handleSubmit:Be,watch:fe,setValue:F,getValues:ee,reset:Me,resetField:mt,clearErrors:v,unregister:de,setError:re,setFocus:(j,T={})=>{const M=X(r,j),Q=M&&M._f;if(Q){const K=Q.refs?Q.refs[0]:Q.ref;K.focus&&(K.focus(),T.shouldSelect&&Tt(K.select)&&K.select())}},getFieldState:ne}}function gm(e={}){const t=_e.useRef(void 0),n=_e.useRef(void 0),[r,i]=_e.useState({isDirty:!1,isValidating:!1,isLoading:Tt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Tt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...mm(e),formState:r});const s=t.current.control;return s._options=e,ca({subject:s._subjects.state,next:a=>{mc(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),_e.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),_e.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),_e.useEffect(()=>{e.values&&!Ht(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),_e.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),_e.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),_e.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=hc(r,s),t.current}function xm(e){return async t=>{const n=e(t);if(n.success&&n.data)return{values:n.data,errors:{}};const r={};if(n.errors)for(const i of n.errors){const s=i.path||"root";r[s]||(r[s]={type:"validation",message:i.message})}return{values:{},errors:r}}}const Lt=xu,fo=yu,ym=bu,po=ia,Sc=b.forwardRef(({className:e,...t},n)=>c.jsx(_i,{ref:n,className:B("fixed inset-0 z-50 bg-black/80",e),...t}));Sc.displayName=_i.displayName;const zt=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ym,{children:[c.jsx(Sc,{}),c.jsxs(vi,{ref:r,className:B("bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg",e),...n,children:[t,c.jsxs(ia,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[c.jsx(hn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zt.displayName=vi.displayName;const mn=({className:e,...t})=>c.jsx("div",{className:B("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});mn.displayName="DialogHeader";const pr=({className:e,...t})=>c.jsx("div",{className:B("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});pr.displayName="DialogFooter";const gn=b.forwardRef(({className:e,...t},n)=>c.jsx(wi,{ref:n,className:B("text-lg leading-none font-semibold tracking-tight",e),...t}));gn.displayName=wi.displayName;const Dn=b.forwardRef(({className:e,...t},n)=>c.jsx(ki,{ref:n,className:B("text-muted-foreground text-sm",e),...t}));Dn.displayName=ki.displayName;const bm=_r("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),pa=b.forwardRef(({className:e,...t},n)=>c.jsx(vu,{ref:n,className:B(bm(),e),...t}));pa.displayName=vu.displayName;const vm=Qh,jc=b.createContext({}),ho=({...e})=>c.jsx(jc.Provider,{value:{name:e.name},children:c.jsx(rm,{...e})}),Ci=()=>{const e=b.useContext(jc),t=b.useContext(Nc),{getFieldState:n,formState:r}=Ni(),i=n(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:s}=t;return{id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...i}},Nc=b.createContext({}),Ns=b.forwardRef(({className:e,...t},n)=>{const r=b.useId();return c.jsx(Nc.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:B("space-y-2",e),...t})})});Ns.displayName="FormItem";const Cs=b.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=Ci();return c.jsx(pa,{ref:n,className:B(r&&"text-destructive",e),htmlFor:i,...t})});Cs.displayName="FormLabel";const Es=b.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=Ci();return c.jsx(Ln,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Es.displayName="FormControl";const Cc=b.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=Ci();return c.jsx("p",{ref:n,id:r,className:B("text-muted-foreground text-[0.8rem]",e),...t})});Cc.displayName="FormDescription";const Is=b.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=Ci(),a=i?String(i==null?void 0:i.message):t;return a?c.jsx("p",{ref:r,id:s,className:B("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});Is.displayName="FormMessage";const ha=b.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:B("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ha.displayName="Input";const ma=qp,wm=Qp,ga=Hp,Ei=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(wu,{ref:r,className:B("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:truncate cursor-pointer",e),...n,children:[t,c.jsx(Wp,{asChild:!0,children:c.jsx(pn,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));Ei.displayName=wu.displayName;const Ec=b.forwardRef(({className:e,...t},n)=>c.jsx(Su,{ref:n,className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(kh,{className:"h-4 w-4"})}));Ec.displayName=Su.displayName;const Ic=b.forwardRef(({className:e,...t},n)=>c.jsx(ju,{ref:n,className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(pn,{className:"h-4 w-4"})}));Ic.displayName=ju.displayName;const Ii=b.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(Gp,{children:c.jsxs(ku,{ref:i,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(Ec,{}),c.jsx(Kp,{className:B("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Ic,{})]})}));Ii.displayName=ku.displayName;const Tc=b.forwardRef(({className:e,...t},n)=>c.jsx(Nu,{ref:n,className:B("px-2 py-1.5 text-sm font-semibold",e),...t}));Tc.displayName=Nu.displayName;const hr=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(_u,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Yp,{children:c.jsx(Kt,{className:"h-4 w-4"})})}),c.jsx(Xp,{children:t})]}));hr.displayName=_u.displayName;const km=b.forwardRef(({className:e,...t},n)=>c.jsx(Cu,{ref:n,className:B("bg-muted -mx-1 my-1 h-px",e),...t}));km.displayName=Cu.displayName;function xa(){const e=new Date,t=n=>String(n).padStart(2,"0");return`Chat ${t(e.getMonth()+1)}/${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`}const Ac=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),_m=(e=Ac())=>Jh()(qh(Hh((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,a)=>a!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),a={id:i,documentName:r,title:xa(),messages:[],createdAt:s,updatedAt:s};return t(o=>({threads:{...o.threads,[i]:a},activeThreadId:{...o.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const a=Object.fromEntries(Object.entries(i.threads).filter(([l])=>l!==r)),o=s.documentName,u={...i.activeThreadId};if(u[o]===r){const l=Object.values(a).filter(f=>f.documentName===o);l.length>0?(l.sort((f,d)=>d.updatedAt-f.updatedAt),u[o]=l[0].id):delete u[o]}t({threads:a,activeThreadId:u})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,u]of Object.entries(s))u.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[u,l]of Object.entries(a))l.documentName===r&&(a[u]={...l,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:Wh(()=>Lh),partialize:t=>({threads:t.threads,activeThreadId:t.activeThreadId,scope:t.scope,model:t.model}),migrate:(t,n)=>{if(n===0&&t){const r=t.chatMessages;if(Array.isArray(r)&&r.length>0){const i=crypto.randomUUID(),s=Date.now();return{threads:{[i]:{id:i,documentName:"__migrated__",title:"Migrated Chat",messages:r,createdAt:s,updatedAt:s}},activeThreadId:{__migrated__:i}}}return{threads:{},activeThreadId:{}}}return t}}))),zc=b.createContext(void 0),Sm=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=_m(Ac())),c.jsx(zc.Provider,{value:t.current,children:e})},Se=e=>{const t=b.useContext(zc);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return Gh(t,e)};function jm(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Nm(e,t,n){const r={},i=[];e!=="delete"&&(r.name=Tr.String({minLength:1,maxLength:120,pattern:"^[a-zA-Z0-9-_. ]+$",description:"Document name (e.g., my-report.docx.json or my-theme.theme.json)"}),i.push("name")),e==="create"&&(r.template=Tr.Optional(Tr.String({description:"Template selection"})));const s=Tr.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!yh(s,a))for(const l of bh(s,a))o.push({path:l.path.replace(/^\//,""),message:l.message});const u=a;if(e!=="delete"&&u.name){const l=u.name.trim();l?(u.name=l,t(l)||o.push({path:"name",message:"Document with this name already exists"})):o.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&u.template&&(n.some(l=>l.name===u.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?u:void 0,errors:o}}}}function Cm(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Em=e=>({create:{title:e?"New Theme":"New Document",description:e?"Create a new theme from scratch or based on discovered themes.":"Create a new document from scratch or based on discovered documents.",button:"Create",buttonVariant:"default"},update:{title:"Rename Document",description:"Give your document a new name.",button:"Save",buttonVariant:"default"},delete:{title:"Are you absolutely sure?",description:"This action cannot be undone. Are you sure you want to permanently delete this document?",button:"Confirm",buttonVariant:"destructive"}}),Hn="__empty__";function Im({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,u]=b.useState(!1),[l,f]=b.useState(null),d=Em(a),{documents:h,openTabs:p,createDocument:g,renameDocument:w,deleteDocument:S,openDocument:y,closeDocument:_}=qe(F=>F),{updateTheme:x}=lc(F=>F),D=Se(F=>F.renameThreadsForDocument),I=Se(F=>F.deleteThreadsForDocument),k=b.useMemo(()=>a?s||[]:i||[],[a,i,s]),E=b.useMemo(()=>{const F={current:[],downstream:[]};return k.forEach(N=>{F[N.location]&&F[N.location].push(N)}),F},[k]),L=b.useMemo(()=>k.map(F=>({name:F.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[k]),G=b.useMemo(()=>Nm(e,F=>jm(F,h,r),L),[e,h,r,L]),C=G.schema,J=b.useMemo(()=>{const F=new Map;return k.forEach(N=>F.set(N.path,N)),F},[k]),Z=Hn,V=gm({resolver:xm(G.validate),defaultValues:Cm(e,void 0,r)}),[z,A]=b.useState(Z);b.useEffect(()=>{if(z&&z!==Hn&&e==="create"){const F=J.get(z);F&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(F.name)}/content`).then(N=>{if(!N.ok)throw new Error(`Failed to fetch content: ${N.statusText}`);return N.text()}).then(N=>{try{const R=JSON.parse(N);f(JSON.stringify(R,null,2))}catch(R){console.error("Invalid JSON content received:",R),f(null)}}).catch(N=>{console.error("Failed to fetch content:",N),f(null)})}},[z,e,J,a]),b.useEffect(()=>{t&&(V.reset(),f(null),A(Z))},[V,t]);const q=V.handleSubmit(async({name:F,template:N})=>{u(!0);try{if(await new Promise(R=>setTimeout(R,200)),e==="create"){const R=z?J.get(z):k.find(ae=>ae.name===N);let m,ee=F;if(a){const ae=ee.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");m=l||JSON.stringify(bt==="docx"?{name:ae,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:{family:"Calibri",size:28},body:{family:"Calibri",size:11}},page:{size:"A4"}}:{name:ae,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const je=`.${bt}.theme.json`;ee.endsWith(je)||(ee=ee.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),ee+=je)}else{const ae=R;m=l||JSON.stringify(bt==="docx"?{name:"docx",props:{theme:(ae==null?void 0:ae.theme)||"default",metadata:{title:(ae==null?void 0:ae.title)||ee.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(ae==null?void 0:ae.title)||ee.replace(/\.(json|js)$/i,""),theme:(ae==null?void 0:ae.theme)||"default"},children:[{name:"slide",props:{},children:[{name:"text",props:{text:"Start writing your presentation content here...",fontSize:24,y:2,x:1,w:8}}]}]},null,2);const le=bt==="docx"?".docx.json":".pptx.json";!ee.endsWith(le)&&!ee.endsWith(".json")&&(ee+=le)}const ne=ee.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),v=ne?ne[0]:"",re=ee.slice(0,ee.length-v.length);let fe=ee,de=1;for(;h.some(ae=>ae.name===fe);)de++,fe=`${re} (${de})${v}`;ee=fe,g(ee,m),y(ee),a&&x(ee,m)}else if(e==="update"){const R=r,m=F,ee=p.includes(R);ee&&_(R),w(R,m),D(R,m),ee&&y(m)}else if(e==="delete"){const R=r;_(R),S(R),I(R)}n()}finally{u(!1)}});return c.jsx(vm,{...V,children:c.jsxs("form",{onSubmit:q,children:[c.jsxs(mn,{children:[c.jsx(gn,{children:d[e].title}),c.jsx(Dn,{children:d[e].description})]}),c.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[C.properties&&"name"in C.properties&&c.jsx(ho,{control:V.control,name:"name",render:({field:F})=>c.jsxs(Ns,{children:[c.jsx(Cs,{children:"Name"}),c.jsx(Es,{children:c.jsx(ha,{placeholder:"Enter a name or select a template below",autoComplete:"off",...F})}),c.jsx(Is,{})]})}),e==="create"&&c.jsx(ho,{control:V.control,name:"template",render:({field:F})=>c.jsxs(Ns,{children:[c.jsx(Cs,{children:a?"Base Theme":"Base Document"}),c.jsxs(ma,{onValueChange:N=>{if(N===Hn)F.onChange(void 0),V.setValue("name",""),A(Hn),f(null);else{const R=J.get(N);R&&(F.onChange(R.name),V.setValue("name",R.name),A(N))}},defaultValue:Z,children:[c.jsx(Es,{children:c.jsx(Ei,{children:c.jsx(ga,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),c.jsxs(Ii,{className:"max-h-[300px]",children:[c.jsxs(hr,{value:Hn,children:["Empty ",a?"theme":"document"]}),Object.entries(E).map(([N,R])=>R.length===0?null:c.jsxs(wm,{children:[c.jsx(Tc,{children:N==="current"?"📁 Current Directory":"📦 Project"}),R.map(m=>{let ee=m.name;if(m.title)ee=`${m.name} - ${m.title}`;else if(m.description){const ne=m.description.length>40?m.description.substring(0,40)+"...":m.description;ee=`${m.name} - ${ne}`}return c.jsx(hr,{value:m.path,className:"pl-6",children:ee},m.path)})]},N))]})]}),c.jsxs(Cc,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),c.jsx(Is,{})]})})]}),c.jsx(pr,{children:c.jsx(xe,{type:"submit",variant:d[e].buttonVariant,disabled:o,children:o?c.jsxs(c.Fragment,{children:[c.jsx(qt,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):d[e].button})})]})})}const ri=_e.memo(Im),Tm=eh,Am=th,zm=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Au,{ref:i,className:B("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none",t&&"pl-8",e),...r,children:[n,c.jsx(fr,{className:"ml-auto h-4 w-4"})]}));zm.displayName=Au.displayName;const Om=b.forwardRef(({className:e,...t},n)=>c.jsx(zu,{ref:n,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));Om.displayName=zu.displayName;const Oc=b.forwardRef(({className:e,...t},n)=>c.jsx(nh,{children:c.jsx(Eu,{ref:n,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",e),...t})}));Oc.displayName=Eu.displayName;const er=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Iu,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));er.displayName=Iu.displayName;const Pm=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Ou,{ref:i,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Pu,{children:c.jsx(Kt,{className:"h-4 w-4"})})}),t]}));Pm.displayName=Ou.displayName;const Dm=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Du,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Pu,{children:c.jsx(ec,{className:"h-4 w-4 fill-current"})})}),t]}));Dm.displayName=Du.displayName;const Rm=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ru,{ref:r,className:B("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Rm.displayName=Ru.displayName;const Ts=b.forwardRef(({className:e,...t},n)=>c.jsx(Tu,{ref:n,className:B("bg-border -mx-1 my-1 h-px",e),...t}));Ts.displayName=Tu.displayName;const Ur=({className:e,...t})=>c.jsx("span",{className:B("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});Ur.displayName="ContextMenuShortcut";const Pc=b.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>c.jsx(Mu,{ref:i,decorative:n,orientation:t,className:B("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Pc.displayName=Mu.displayName;const Dc=xu,Mm=yu,Fm=bu,Rc=b.forwardRef(({className:e,...t},n)=>c.jsx(_i,{className:B("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",e),...t,ref:n}));Rc.displayName=_i.displayName;const $m=_r("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ya=b.forwardRef(({side:e="right",className:t,children:n,...r},i)=>c.jsxs(Fm,{children:[c.jsx(Rc,{}),c.jsxs(vi,{ref:i,className:B($m({side:e}),t),...r,children:[c.jsxs(ia,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[c.jsx(hn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));ya.displayName=vi.displayName;const Lm=b.forwardRef(({className:e,...t},n)=>c.jsx(wi,{ref:n,className:B("text-foreground text-lg font-semibold",e),...t}));Lm.displayName=wi.displayName;const Zm=b.forwardRef(({className:e,...t},n)=>c.jsx(ki,{ref:n,className:B("text-muted-foreground text-sm",e),...t}));Zm.displayName=ki.displayName;function lr({className:e,...t}){return c.jsx("div",{className:B("bg-primary/10 animate-pulse rounded-md",e),...t})}const qi=768,Hi=1200;function Mc(){const[e,t]=b.useState(void 0);return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${qi-1}px)`),r=()=>{t(window.innerWidth<qi)};return n.addEventListener("change",r),t(window.innerWidth<qi),()=>n.removeEventListener("change",r)},[]),!!e}function Vm(){const[e,t]=b.useState(void 0);return b.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Hi-1}px)`),r=()=>{t(window.innerWidth<Hi)};return n.addEventListener("change",r),t(window.innerWidth<Hi),()=>n.removeEventListener("change",r)},[]),!!e}const Bm="sidebar_state",Um=60*60*24*7,Jm="16rem",qm="18rem",Hm="3rem",Wm="b",Fc=b.createContext(null);function Ti(){const e=b.useContext(Fc);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const $c=b.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const u=Mc(),[l,f]=b.useState(!1),[d,h]=b.useState(e),p=t??d,g=b.useCallback(_=>{const x=typeof _=="function"?_(p):_;n?n(x):h(x),document.cookie=`${Bm}=${x}; path=/; max-age=${Um}`},[n,p]),w=b.useCallback(()=>u?f(_=>!_):g(_=>!_),[u,g,f]);b.useEffect(()=>{const _=D=>{var E;const I=D;if(!I)return!1;const k=(E=I.tagName)==null?void 0:E.toLowerCase();return k==="input"||k==="textarea"||k==="select"||I.isContentEditable?!0:!!(I.closest&&I.closest(".monaco-editor"))},x=D=>{const I=D.metaKey||D.ctrlKey,k=D.key.toLowerCase();if(I&&k===Wm){D.preventDefault(),w();return}I&&k==="s"&&!_(D.target)&&(D.preventDefault(),w())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[w]);const S=p?"expanded":"collapsed",y=b.useMemo(()=>({state:S,open:p,setOpen:g,isMobile:u,openMobile:l,setOpenMobile:f,toggleSidebar:w}),[S,p,g,u,l,f,w]);return c.jsx(Fc.Provider,{value:y,children:c.jsx(vh,{delayDuration:0,children:c.jsx("div",{style:{"--sidebar-width":Jm,"--sidebar-width-icon":Hm,...i},className:B("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});$c.displayName="SidebarProvider";const Lc=b.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:u,openMobile:l,setOpenMobile:f}=Ti();return n==="none"?c.jsx("div",{className:B("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?c.jsx(Dc,{open:l,onOpenChange:f,...s,children:c.jsx(ya,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":qm},side:e,children:c.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):c.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":u,"data-collapsible":u==="collapsed"?n:"","data-variant":t,"data-side":e,children:[c.jsx("div",{className:B("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),c.jsx("div",{className:B("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:c.jsx("div",{"data-sidebar":"sidebar",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow",children:i})})]})});Lc.displayName="Sidebar";const Gm=b.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Ti();return c.jsxs(xe,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:B("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[c.jsx(_h,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Gm.displayName="SidebarTrigger";const Km=b.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Ti();return c.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:B("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});Km.displayName="SidebarRail";const Ym=b.forwardRef(({className:e,...t},n)=>c.jsx("main",{ref:n,className:B("bg-background relative flex min-h-svh flex-1 flex-col","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2",e),...t}));Ym.displayName="SidebarInset";const Xm=b.forwardRef(({className:e,...t},n)=>c.jsx(ha,{ref:n,"data-sidebar":"input",className:B("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));Xm.displayName="SidebarInput";const Zc=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"header",className:B("flex flex-col gap-2 p-2",e),...t}));Zc.displayName="SidebarHeader";const Vc=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"footer",className:B("flex flex-col gap-2 p-2",e),...t}));Vc.displayName="SidebarFooter";const Bc=b.forwardRef(({className:e,...t},n)=>c.jsx(Pc,{ref:n,"data-sidebar":"separator",className:B("bg-sidebar-border mx-2 w-auto",e),...t}));Bc.displayName="SidebarSeparator";const Uc=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"content",className:B("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Uc.displayName="SidebarContent";const Jr=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group",className:B("relative flex w-full min-w-0 flex-col p-2",e),...t}));Jr.displayName="SidebarGroup";const qr=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Ln:"div";return c.jsx(i,{ref:r,"data-sidebar":"group-label",className:B("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opa] duration-200 ease-linear outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});qr.displayName="SidebarGroupLabel";const Qm=b.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Ln:"button";return c.jsx(i,{ref:r,"data-sidebar":"group-action",className:B("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});Qm.displayName="SidebarGroupAction";const tr=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group-content",className:B("w-full text-sm",e),...t}));tr.displayName="SidebarGroupContent";const As=b.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu",className:B("flex w-full min-w-0 flex-col gap-1",e),...t}));As.displayName="SidebarMenu";const Jc=b.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,"data-sidebar":"menu-item",className:B("group/menu-item relative",e),...t}));Jc.displayName="SidebarMenuItem";const eg=_r("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),qc=b.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const u=e?Ln:"button",{isMobile:l,state:f}=Ti(),d=c.jsx(u,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:B(eg({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:d}),c.jsx(Ye,{side:"right",align:"center",hidden:f!=="collapsed"||l,...i})]})):d});qc.displayName="SidebarMenuButton";const tg=b.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?Ln:"button";return c.jsx(s,{ref:i,"data-sidebar":"menu-action",className:B("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...r})});tg.displayName="SidebarMenuAction";const ng=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:B("text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));ng.displayName="SidebarMenuBadge";const rg=b.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=b.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:B("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&c.jsx(lr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(lr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});rg.displayName="SidebarMenuSkeleton";const ig=b.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:B("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));ig.displayName="SidebarMenuSub";const sg=b.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));sg.displayName="SidebarMenuSubItem";const ag=b.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?Ln:"a";return c.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:B("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...i})});ag.displayName="SidebarMenuSubButton";function zs(e,t){const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.style.display="none",r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}const og=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function lg({document:e,indicator:t,compact:n=!1}){const r=b.useRef(null),[i,s]=b.useState(!1),[a,o]=b.useState(!1),[u,l]=b.useState(!1),{openDocument:f,documentTypes:d,activeTab:h}=qe(A=>A),{name:p,text:g,isGenerating:w}=on(A=>A),y=(d[e.name]||"application/json+report")==="application/json+theme",_=h===e.name,[x,D]=b.useState(p),[I,k]=b.useState(g),E=100,L=0;b.useEffect(()=>{const A=setTimeout(()=>{p&&g?(D(p),k(g)):w||(D(""),k(""))},w?E:L);return()=>clearTimeout(A)},[p,g,w]);const G=x===e.name,C=A=>{var F;const q=new Set;try{const N=JSON.parse(A);(F=N.props)!=null&&F.theme&&q.add(N.props.theme),N.children&&Array.isArray(N.children)&&N.children.forEach(R=>{var m;R.name==="docx"&&((m=R.props)!=null&&m.theme)&&q.add(R.props.theme)})}catch{}return q},J=b.useMemo(()=>{if(!y||!I)return!1;try{const A=JSON.parse(e.text),q=Ss(A);if(q)return C(I).has(q)}catch{}return!1},[y,I,e.text,e.name,x]),Z=b.useCallback(()=>{o(!1)},[]),V=b.useCallback(()=>{l(!1)},[]),z=c.jsxs(qc,{variant:"default",size:"default",ref:r,className:B("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),G&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),J&&!_&&!G&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:A=>{var q;(A.ctrlKey||A.metaKey)&&A.key==="Enter"?(f(e.name),A.preventDefault()):A.key==="Enter"?(o(!0),A.preventDefault()):A.key==="Backspace"||A.key==="Delete"?(l(!0),A.preventDefault()):A.key==="Escape"&&((q=r.current)==null||q.blur(),A.preventDefault())},children:[_?c.jsx(Ka,{className:B("size-4","text-green-600 dark:text-green-400")}):G?c.jsx(Ka,{className:B("size-4","text-blue-600 dark:text-blue-400")}):y?c.jsx(Qn,{className:"size-4 text-purple-600 dark:text-purple-400"}):c.jsx(ks,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&c.jsx("span",{className:B("truncate flex-1",y&&!_&&!G&&!J&&"text-purple-700 dark:text-purple-300",(_||G||J)&&"font-medium"),children:e.name})]});return c.jsxs(Jc,{children:[c.jsxs(Tm,{onOpenChange:s,children:[c.jsx(Am,{children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:z}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[e.name,y?c.jsx("div",{className:"opacity-70",children:"Theme"}):c.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):z}),c.jsxs(Oc,{children:[c.jsxs(er,{onClick:()=>f(e.name),children:["Open",c.jsx(Ur,{children:og?"⌘⏎":"⌃⏎"})]}),c.jsx(Ts,{}),c.jsx(er,{disabled:!e,onClick:()=>{e&&zs(`${e.name}.js`,new Blob([e.text],{type:e.type}))},children:"Download..."}),c.jsx(Ts,{}),c.jsxs(er,{onClick:()=>o(!0),children:["Rename...",c.jsx(Ur,{children:"⏎"})]}),c.jsxs(er,{onClick:()=>l(!0),children:["Delete",c.jsx(Ur,{children:"⌫"})]})]})]}),c.jsx(Lt,{open:a,onOpenChange:o,children:c.jsx(zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:A=>{var q;A.preventDefault(),(q=r.current)==null||q.focus()},children:c.jsx(ri,{mode:"update",shouldReset:!a,postSubmit:Z,selectedName:e.name})})}),c.jsx(Lt,{open:u,onOpenChange:l,children:c.jsx(zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:A=>{var q;A.preventDefault(),(q=r.current)==null||q.focus()},children:c.jsx(ri,{mode:"delete",shouldReset:!u,postSubmit:V,selectedName:e.name})})})]})}const mo=_e.memo(lg);async function ug(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const cg=_r("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function ln({className:e,variant:t,...n}){return c.jsx("div",{className:B(cg({variant:t}),e),...n})}const fn=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Fu,{ref:r,className:B("relative overflow-hidden",e),...n,children:[c.jsx(rh,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Hc,{}),c.jsx(ih,{})]}));fn.displayName=Fu.displayName;const Hc=b.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx($u,{ref:r,orientation:t,className:B("flex touch-none transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(sh,{className:"bg-border relative flex-1 rounded-full"})}));Hc.displayName=$u.displayName;const Wc=ah,ba=b.forwardRef(({className:e,...t},n)=>c.jsx(Lu,{ref:n,className:B("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));ba.displayName=Lu.displayName;const An=b.forwardRef(({className:e,...t},n)=>c.jsx(Zu,{ref:n,className:B("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-md px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow",e),...t}));An.displayName=Zu.displayName;const zn=b.forwardRef(({className:e,...t},n)=>c.jsx(Vu,{ref:n,className:B("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));zn.displayName=Vu.displayName;const dg=_r("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Os=b.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:B(dg({variant:t}),e),...n}));Os.displayName="Alert";const fg=b.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:B("mb-1 font-medium leading-none tracking-tight",e),...t}));fg.displayName="AlertTitle";const Ps=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:B("text-sm [&_p]:leading-relaxed",e),...t}));Ps.displayName="AlertDescription";const ii=b.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=b.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),u=()=>s(!i),l=()=>t===null?c.jsx("span",{className:"text-orange-500",children:"null"}):t===void 0?c.jsx("span",{className:"text-gray-500",children:"undefined"}):typeof t=="boolean"?c.jsx("span",{className:"text-blue-500",children:String(t)}):typeof t=="number"?c.jsx("span",{className:"text-green-500",children:t}):typeof t=="string"?t.startsWith("http")?c.jsxs("span",{className:"text-purple-500",children:['"',t,'"']}):t.startsWith("#/")?c.jsxs("span",{className:"text-cyan-500",children:['"',t,'"']}):c.jsxs("span",{className:"text-amber-600",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return c.jsxs("div",{className:B("text-sm",n>0&&"ml-4"),children:[c.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded px-1 py-0.5",children:[a&&c.jsx("button",{onClick:u,className:"mr-1 hover:bg-muted rounded p-0.5","aria-label":i?"Collapse":"Expand",children:i?c.jsx(pn,{className:"h-3 w-3"}):c.jsx(fr,{className:"h-3 w-3"})}),!a&&c.jsx("span",{className:"w-4"}),e&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:['"',e,'"']}),c.jsx("span",{className:"mx-1",children:":"})]}),a?c.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&c.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):l(),!a&&!r&&c.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&c.jsxs("div",{className:"ml-4",children:[o?t.map((d,h)=>c.jsx(ii,{keyName:String(h),value:d,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([d,h],p,g)=>c.jsx(ii,{keyName:d,value:h,depth:n+1,isLast:p===g.length-1},d)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});ii.displayName="JsonNode";const si=b.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:B("space-y-4",r),children:[c.jsx(lr,{className:"h-8 w-64"}),c.jsx(lr,{className:"h-4 w-full"}),c.jsx(lr,{className:"h-64 w-full"})]}):n?c.jsx(Os,{variant:"destructive",className:r,children:c.jsx(Ps,{children:n})}):e?c.jsx(fn,{className:B("h-full w-full rounded-md border bg-muted/10 p-4",r),children:c.jsx("div",{className:"font-mono text-xs",children:c.jsx(ii,{value:e})})}):c.jsx(Os,{className:r,children:c.jsx(Ps,{children:"No schema available"})}));si.displayName="SchemaViewer";function pg({plugins:e,onClose:t}){var Z,V;const{toast:n}=Si(),r=$t(z=>z.togglePlugin),i=$t(z=>z.isPluginSelected),s=$t(z=>z.clearSelections),a=$t(z=>z.selectedPlugins),o=$t(z=>z.applyPluginsWithValidation),u=$t(z=>z.isApplyingPlugins),[l,f]=b.useState(null),[d,h]=b.useState("list"),[p,g]=b.useState("overview"),[w,S]=b.useState(null),[y,_]=b.useState(0),[x,D]=b.useState("list"),I=Array.from(a),k=z=>{f(z),h("detail")},E=()=>{h("list"),g("overview"),_(0),D("list")},L=b.useMemo(()=>{const z={current:[],downstream:[],upstream:[]};return e.forEach(A=>{z[A.location]&&z[A.location].push(A)}),z},[e]),G=async(z,A)=>{l&&(await ug(l.name,z.props),S(A),setTimeout(()=>S(null),2e3))},C=z=>{switch(z){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return z}},J=z=>{switch(z){case"current":return c.jsx(jh,{className:"size-3"});case"downstream":return c.jsx(Sh,{className:"size-3"});case"upstream":return c.jsx(ks,{className:"size-3"});default:return null}};return c.jsxs(c.Fragment,{children:[c.jsxs(mn,{children:[c.jsxs(gn,{className:"flex items-center gap-2",children:[c.jsx(tc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Discovered Plugins"]}),c.jsxs(Dn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project."," ",I.length>0&&c.jsxs("span",{className:"text-primary font-medium",children:[I.length," selected"]})]})]}),d==="list"&&I.length>0&&c.jsxs("div",{className:"flex items-center justify-between mt-4 p-2 bg-muted/50 rounded-lg",children:[c.jsxs("div",{className:"text-sm text-muted-foreground",children:[I.length," plugin",I.length!==1?"s":""," selected"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(xe,{size:"sm",variant:"outline",onClick:s,children:"Clear All"}),c.jsx(xe,{size:"sm",disabled:u,onClick:async()=>{console.log("Apply Selection clicked with plugins:",I),await o(()=>{n({title:"Plugins Applied Successfully!",description:`${I.length} plugin${I.length!==1?"s":""} have been applied. Autocomplete and validation are now updated.`,className:"border-green-500"}),t()},z=>{n({title:"Failed to Apply Plugins",description:z||"Unable to update schema validation. Please try again.",variant:"destructive"})})},children:u?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"size-4 mr-1 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Applying..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Kt,{className:"size-4 mr-1"}),"Apply Selection"]})})]})]}),c.jsxs("div",{className:"mt-4 flex-1 overflow-hidden",children:[d==="list"&&c.jsx(fn,{className:"h-[600px] pr-4",children:Object.entries(L).map(([z,A])=>A.length===0?null:c.jsxs("div",{className:"mb-6",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm font-semibold text-muted-foreground",children:[J(z),C(z),c.jsx(ln,{variant:"secondary",className:"ml-auto",children:A.length})]}),c.jsx("div",{className:"space-y-2",children:A.map(q=>{const F=i(q.name);return c.jsxs("div",{className:B("flex items-center justify-between p-3 rounded-lg border transition-colors group",F&&"bg-primary/10 border-primary","hover:bg-accent/50"),children:[c.jsxs("div",{className:"flex-1 cursor-pointer",onClick:()=>k(q),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ya,{className:"size-4 text-blue-600 dark:text-blue-400"}),c.jsx("span",{className:"font-medium",children:q.name}),q.version&&c.jsxs(ln,{variant:"outline",className:"text-xs",children:["v",q.version]})]}),q.description&&c.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:q.description}),c.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:q.relativePath})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[F&&c.jsx(Xa,{className:"size-4 text-primary"}),c.jsx(xe,{size:"sm",variant:F?"secondary":"outline",onClick:N=>{N.stopPropagation(),r(q)},children:F?"Selected":"Select"}),c.jsx(fr,{className:"size-4 text-muted-foreground group-hover:translate-x-1 transition-transform"})]})]},q.name)})})]},z))}),d==="detail"&&l&&c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b",children:[c.jsxs(xe,{variant:"ghost",size:"sm",onClick:E,className:"gap-1 -ml-2",children:[c.jsx(Qa,{className:"size-4"}),"Back to Plugins"]}),c.jsx("div",{className:"flex-1"}),c.jsxs(ln,{variant:"outline",children:[l.name,l.version&&` v${l.version}`]})]}),c.jsxs(Wc,{value:p,onValueChange:g,className:"flex-1 flex flex-col overflow-hidden5",children:[c.jsxs(ba,{className:"grid w-full grid-cols-3 mb-4",children:[c.jsxs(An,{value:"overview",className:"gap-2",children:[c.jsx(nc,{className:"size-4"}),"Overview"]}),c.jsxs(An,{value:"schema",className:"gap-2",disabled:!l.schema||Object.keys(l.schema).length===0,children:[c.jsx(rc,{className:"size-4"}),"Schema"]}),c.jsxs(An,{value:"examples",className:"gap-2",disabled:!l.examples||l.examples.length===0,children:[c.jsx(Yr,{className:"size-4"}),"Examples"," ",l.examples&&`(${l.examples.length})`]})]}),c.jsx(zn,{value:"overview",className:"flex-1 overflow-hidden",children:c.jsx(fn,{className:"h-[500px] pr-4",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[c.jsx(Ya,{className:"size-5 text-blue-600 dark:text-blue-400"}),l.name]}),l.version&&c.jsxs(ln,{variant:"outline",className:"mt-2 mb-1",children:["Version ",l.version]})]}),l.description&&c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium mb-1",children:"Description"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})]}),c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium mb-1",children:"Location"}),c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[J(l.location),c.jsx("span",{children:C(l.location)}),c.jsxs("span",{className:"text-xs",children:["(",l.relativePath,")"]})]})]}),((Z=l.schema)==null?void 0:Z.properties)&&c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium mb-2",children:"Configuration Properties (Quick Preview)"}),c.jsxs("div",{className:"space-y-1",children:[Object.entries(l.schema.properties).slice(0,5).map(([z,A])=>c.jsxs("div",{className:"text-xs",children:[c.jsx("span",{className:"font-mono font-medium",children:z}),A.type&&c.jsxs("span",{className:"text-muted-foreground ml-2",children:["(",A.type,")",A.optional?" - optional":""]})]},z)),Object.keys(l.schema.properties).length>5&&c.jsxs("div",{className:"text-xs text-muted-foreground",children:["...and"," ",Object.keys(l.schema.properties).length-5," ","more properties. View the Schema tab for complete details."]})]})]})]})})}),c.jsx(zn,{value:"schema",className:"flex-1 overflow-hidden",children:c.jsx(si,{schema:((V=l.schema)==null?void 0:V.jsonSchema)||null,loading:!1,className:"h-[500px]"})}),c.jsx(zn,{value:"examples",className:"flex-1 overflow-hidden",children:l.examples&&l.examples.length>0?c.jsxs(c.Fragment,{children:[x==="list"&&l.examples.length>1&&c.jsx(fn,{className:"h-[500px]",children:c.jsx("div",{className:"space-y-3",children:l.examples.map((z,A)=>c.jsx("div",{className:"p-4 border rounded-lg hover:bg-muted cursor-pointer transition-colors group",onClick:()=>{_(A),D("detail")},children:c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsxs(ln,{variant:"secondary",className:"text-xs",children:["Example ",A+1]}),c.jsx("h3",{className:"font-semibold text-sm",children:z.title||`Example ${A+1}`})]}),z.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-2 line-clamp-2",children:z.description})]}),c.jsx(fr,{className:"size-5 text-muted-foreground mt-1 group-hover:translate-x-1 transition-transform"})]})},A))})}),(x==="detail"||l.examples.length===1)&&l.examples[y]&&c.jsxs(c.Fragment,{children:[l.examples.length>1&&c.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b",children:[c.jsxs(xe,{variant:"ghost",size:"sm",onClick:()=>D("list"),className:"gap-1 -ml-2",children:[c.jsx(Qa,{className:"size-4"}),"Back to Examples"]}),c.jsx("div",{className:"flex-1"}),c.jsxs(ln,{variant:"secondary",className:"text-xs",children:["Example ",y+1," of"," ",l.examples.length]})]}),c.jsx(fn,{className:"max-h-[50vh]",children:c.jsxs("div",{className:"space-y-4",children:[l.examples[y].title&&c.jsx("h3",{className:"text-lg font-semibold",children:l.examples[y].title}),l.examples[y].description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:l.examples[y].description}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h4",{className:"text-sm font-medium",children:"Full Component Configuration"}),c.jsx(xe,{size:"sm",variant:"outline",onClick:()=>G(l.examples[y],y),children:w===y?c.jsxs(c.Fragment,{children:[c.jsx(Xa,{className:"size-4 mr-2 text-green-600"}),"Copied!"]}):c.jsxs(c.Fragment,{children:[c.jsx(aa,{className:"size-4 mr-2"}),"Copy"]})})]}),c.jsx("pre",{className:"p-4 bg-muted rounded-lg overflow-x-auto",children:c.jsx("code",{className:"text-sm",children:JSON.stringify(l.examples[y].props,null,2)})})]})]})})]}),c.jsx("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(ks,{className:"size-4 text-muted-foreground mt-0.5"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.jsx("p",{className:"font-medium mb-1",children:"How to use:"}),c.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[c.jsx("li",{children:"Copy the example configuration"}),c.jsx("li",{children:"Paste it into your document's children array"}),c.jsx("li",{children:"Adjust the configuration values as needed"})]})]})]})})]}):c.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[c.jsx(Yr,{className:"size-12 mx-auto mb-3 opacity-20"}),c.jsx("p",{children:"No examples available for this plugin"})]})})]})]})]})]})}const Wi=oh,Gi=lh,Ki=uh,Gc=ch,Kc=dh,hg=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(qu,{ref:i,className:B("focus:bg-accent data-[state=open]:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,c.jsx(fr,{className:"ml-auto"})]}));hg.displayName=qu.displayName;const mg=b.forwardRef(({className:e,...t},n)=>c.jsx(Hu,{ref:n,className:B("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));mg.displayName=Hu.displayName;const va=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(fh,{children:c.jsx(Bu,{ref:r,sideOffset:t,className:B("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));va.displayName=Bu.displayName;const Wt=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Uu,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));Wt.displayName=Uu.displayName;const gg=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Wu,{ref:i,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Gu,{children:c.jsx(Kt,{className:"h-4 w-4"})})}),t]}));gg.displayName=Wu.displayName;const xg=b.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ku,{ref:r,className:B("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Gu,{children:c.jsx(ec,{className:"h-2 w-2 fill-current"})})}),t]}));xg.displayName=Ku.displayName;const yg=b.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Yu,{ref:r,className:B("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));yg.displayName=Yu.displayName;const ai=b.forwardRef(({className:e,...t},n)=>c.jsx(Ju,{ref:n,className:B("bg-muted -mx-1 my-1 h-px",e),...t}));ai.displayName=Ju.displayName;function bg(){const{theme:e,setTheme:t}=Xu(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=b.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(xe,{variant:"ghost",size:"icon",onClick:r,children:[c.jsx(Nh,{className:"hidden dark:block"}),c.jsx(Ch,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:"Toggle theme"})})]})}async function vg(e){if(navigator.clipboard&&navigator.clipboard.writeText)try{return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard API failed, falling back to legacy method:",t)}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="2em",t.style.height="2em",t.style.padding="0",t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("Failed to copy text to clipboard:",t),!1}}function wg(e){try{const t=typeof e=="string"?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch(t){return console.error("Failed to format schema:",t),typeof e=="string"?e:JSON.stringify(e)}}async function kg(e){const t=wg(e);return vg(t)}const Yc=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=b.useState(n),[s,a]=b.useState(null),[o,u]=b.useState(null),[l,f]=b.useState(!1),[d,h]=b.useState(!1),[p,g]=b.useState(null),[w,S]=b.useState(null),[y,_]=b.useState(!1),{toast:x}=Si(),D=$t(V=>V.selectedPlugins),I=Array.from(D);b.useEffect(()=>{n&&i(n)},[n]);const k=b.useCallback(async()=>{f(!0),g(null);try{const V=await Zi.fetchDocumentSchema(I);a(V)}catch(V){const z=V instanceof Error?V.message:"Failed to load document schema";g(z),x({variant:"destructive",title:"Error loading schema",description:z})}finally{f(!1)}},[I,x]),E=b.useCallback(async()=>{if(!o){h(!0),S(null);try{const V=await Zi.fetchThemeSchema();u(V)}catch(V){const z=V instanceof Error?V.message:"Failed to load theme schema";S(z),x({variant:"destructive",title:"Error loading schema",description:z})}finally{h(!1)}}},[o,x]),[L,G]=b.useState([]);b.useEffect(()=>{e||(a(null),g(null))},[e]),b.useEffect(()=>{if(!e)return;const V=I.length!==L.length||I.some((z,A)=>z!==L[A]);r==="document"?(!s||V)&&(V&&(Zi.clearPluginSchemaCache(),G([...I])),l||k()):r==="theme"&&!o&&!d&&E()},[r,e,s,o,l,d,I,L,k,E]);const C=I.length,J=r==="document"?s:o,Z=async()=>{if(J)try{await kg(J)&&(_(!0),x({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(V){console.error("Copy failed:",V)}};return c.jsx(Lt,{open:e,onOpenChange:t,children:c.jsxs(zt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(mn,{children:c.jsx(gn,{children:"Schema Viewer"})}),c.jsxs(Wc,{value:r,onValueChange:V=>i(V),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(ba,{children:[c.jsxs(An,{value:"document",className:"flex items-center gap-1",children:["Document",C>0&&c.jsxs(ln,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",C]})]}),c.jsx(An,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(xe,{variant:"ghost",size:"icon",onClick:Z,disabled:y||!J,"aria-label":"Copy schema",children:y?c.jsx(Kt,{className:"h-4 w-4"}):c.jsx(aa,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(zn,{value:"document",className:"h-full",children:c.jsx(si,{schema:s,loading:l,error:p||void 0})}),c.jsx(zn,{value:"theme",className:"h-full",children:c.jsx(si,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function _g({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=qe(Kh(N=>({documents:N.documents,documentTypes:N.documentTypes,createDocument:N.createDocument,openDocument:N.openDocument}))),u=lc(N=>N.updateTheme),[l,f]=b.useState(!1),[d,h]=b.useState(!1),[p,g]=b.useState(!1),[w,S]=b.useState(!1),[y,_]=b.useState(new Set(["current-docs","current-themes"])),{toast:x}=Si(),D=i.filter(N=>s[N.name]!=="application/json+theme"),I=i.filter(N=>s[N.name]==="application/json+theme"),k=b.useMemo(()=>{if(!e)return{current:[],downstream:[]};const N={current:[],downstream:[]};return e.documents.forEach(R=>{N[R.location]&&N[R.location].push(R)}),N},[e]),E=b.useMemo(()=>{if(!e)return{current:[],downstream:[]};const N={current:[],downstream:[]};return e.themes.forEach(R=>{N[R.location]&&N[R.location].push(R)}),N},[e]),L=b.useMemo(()=>{const N=new Set;return D.forEach(R=>{try{const m=JSON.parse(R.text);m.children&&Array.isArray(m.children)&&m.children.forEach(ee=>{var ne;ee.name==="docx"&&((ne=ee.props)!=null&&ne.theme)&&N.add(ee.props.theme)})}catch{}}),N},[D]),G=b.useCallback(()=>{f(!1)},[]),C=b.useCallback(()=>{h(!1)},[]),J=b.useRef(new Map);b.useEffect(()=>{const N=J.current,R=new Map;I.forEach(m=>{R.set(m.name,m.text),N.get(m.name)!==m.text&&u(m.name,m.text)}),J.current=R},[I,u]);const Z=N=>{_(R=>{const m=new Set(R);return m.has(N)?m.delete(N):m.add(N),m})},V=qe(N=>N.activeTab),z=V&&s[V]==="application/json+theme"?"theme":"document",{resolvedTheme:A}=Xu(),q=A==="dark"?"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo-white.svg?updatedAt=1751359555877":"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo.svg?updatedAt=1749817149276",F=b.useCallback(async(N,R)=>{if(i.some(m=>m.name===N)){o(N);return}try{const m=await fetch(`/api/discovery/${R?"themes":"documents"}/${encodeURIComponent(N)}/content`);if(!m.ok)throw new Error(m.statusText);const ee=await m.text(),ne=JSON.parse(ee);a(N,JSON.stringify(ne,null,2)),o(N),x({title:`Added ${R?"theme":"document"}: ${N}`})}catch{x({title:"Failed to load",description:`Could not load ${N}`,variant:"destructive"})}},[i,a,o,x]);return c.jsxs(c.Fragment,{children:[c.jsxs(Lc,{collapsible:"none",style:{"--sidebar-width":n?"2.5rem":"16rem"},children:[c.jsx(Zc,{children:c.jsx("div",{className:B("flex items-center transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?c.jsx(xe,{variant:"ghost",size:"icon",title:"Expand sidebar",onClick:t,children:c.jsx(ic,{className:"h-4 w-4"})}):c.jsxs(c.Fragment,{children:[c.jsx("a",{href:"/",className:"flex items-center pl-2",children:c.jsx("img",{src:q,alt:"WiseAir logo",className:"h-5 w-auto max-w-[120px] shrink-0"})}),c.jsx("div",{className:"flex items-center gap-1",children:c.jsx(xe,{variant:"ghost",size:"icon",title:"Collapse sidebar",onClick:t,children:c.jsx(Eh,{className:"h-4 w-4"})})})]})})}),c.jsxs(Uc,{className:B("h-full transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100"),children:[c.jsxs(Jr,{children:[c.jsxs(qr,{className:B("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Vi,{className:"size-3"}),!n&&c.jsx("span",{children:"Active Documents"})]}),c.jsxs(Lt,{open:l,onOpenChange:f,children:[c.jsx(fo,{asChild:!0,children:c.jsx("div",{className:B("flex",n?"w-full justify-center":""),children:c.jsx(xe,{className:B("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Document",disabled:!e||e.documents.length===0,children:n?c.jsx(Vi,{className:"size-4"}):c.jsx(Xr,{className:"size-4"})})})}),c.jsx(zt,{className:"sm:max-w-[525px]",children:c.jsx(ri,{mode:"create",shouldReset:!l,postSubmit:G,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]}),n?c.jsx(tr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:D.map(N=>{const R=V===N.name;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(N.name),className:B("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",R?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),N.name.charAt(0).toUpperCase()]})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:N.name})})]},N.name)})})}):c.jsx(tr,{children:c.jsx(As,{children:D.length>0?D.map((N,R)=>c.jsx(mo,{document:N,compact:n},`doc-${R}`)):c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),c.jsx(Bc,{}),c.jsxs(Jr,{children:[c.jsxs(qr,{className:B("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Qn,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&c.jsx("span",{children:"Active Themes"})]}),e&&e.themes.length>0&&c.jsxs(Lt,{open:d,onOpenChange:h,children:[c.jsx(fo,{asChild:!0,children:c.jsx("div",{className:B("flex",n?"w-full justify-center":""),children:c.jsx(xe,{className:B("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Theme",children:n?c.jsx(Qn,{className:"size-4"}):c.jsx(Xr,{className:"size-4"})})})}),c.jsx(zt,{className:"sm:max-w-[525px]",children:c.jsx(ri,{mode:"create",shouldReset:!d,postSubmit:C,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?c.jsx(tr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:I.map(N=>{const R=V===N.name;let m=null;try{const ne=JSON.parse(N.text);m=Ss(ne)}catch{}const ee=m?L.has(m):!1;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(N.name),className:B("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",R?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":ee?"bg-purple-50 text-purple-600 dark:bg-purple-900/20 dark:text-purple-400":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),c.jsx(Qn,{className:"size-3"})]})}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[N.name,ee&&c.jsx("div",{className:"opacity-70",children:"In use"})]})})]},N.name)})})}):c.jsx(tr,{children:c.jsx(As,{children:I.length>0?I.map((N,R)=>{let m=null;try{const ne=JSON.parse(N.text);m=Ss(ne)}catch{}const ee=m?L.has(m):!1;return c.jsx(mo,{document:N,compact:n,indicator:ee?"in-use":void 0},`theme-${R}`)}):c.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No active themes."," ",e&&e.themes.length>0?"Click + to add one.":"No themes discovered in project."]})})})]}),e&&(e.documents.length>0||e.themes.length>0)&&c.jsxs(Jr,{className:"mt-2 border-t pt-4",children:[c.jsx(qr,{className:B("flex items-center mb-2",n?"justify-center":"gap-2"),children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(eo,{className:"size-3"})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:"Expand sidebar to show discovered resources"})})]}):c.jsxs(c.Fragment,{children:[c.jsx(eo,{className:"size-3"}),c.jsx("span",{children:"Discovered Resources"})]})}),!n&&c.jsxs(c.Fragment,{children:[Object.entries(k).map(([N,R])=>{if(R.length===0)return null;const m=`${N}-docs`,ee=y.has(m);return c.jsxs(Wi,{open:ee,children:[c.jsxs(Gi,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>Z(m),children:[c.jsx(pn,{className:B("size-3 transition-transform",!ee&&"-rotate-90")}),c.jsx(Vi,{className:"size-3"}),N==="current"?"Current Directory":"Project"," ","Documents (",R.length,")"]}),c.jsx(Ki,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((ne,v)=>{const re=i.some(fe=>fe.name===ne.name);return c.jsxs("button",{onClick:()=>F(ne.name,!1),className:B("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-blue-400/60 dark:border-blue-500/40","hover:bg-accent hover:text-accent-foreground",re&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:ne.name}),ne.title&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:ne.title})]},v)})})})]},m)}),Object.entries(E).map(([N,R])=>{if(R.length===0)return null;const m=`${N}-themes`,ee=y.has(m);return c.jsxs(Wi,{open:ee,children:[c.jsxs(Gi,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>Z(m),children:[c.jsx(pn,{className:B("size-3 transition-transform",!ee&&"-rotate-90")}),c.jsx(Qn,{className:"size-3"}),N==="current"?"Current Directory":"Project"," ","Themes (",R.length,")"]}),c.jsx(Ki,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((ne,v)=>{const re=i.some(fe=>fe.name===ne.name);return c.jsxs("button",{onClick:()=>F(ne.name,!0),className:B("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-purple-400/60 dark:border-purple-500/40","hover:bg-accent hover:text-accent-foreground",re&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:ne.name}),ne.description&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:ne.description})]},v)})})})]},m)}),e&&e.plugins.length>0&&c.jsxs(Wi,{open:y.has("plugins"),children:[c.jsxs(Gi,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>Z("plugins"),children:[c.jsx(pn,{className:B("size-3 transition-transform",!y.has("plugins")&&"-rotate-90")}),c.jsx(tc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",e.plugins.length,")"]}),c.jsx(Ki,{children:c.jsxs("div",{className:"pl-4 space-y-0.5",children:[e.plugins.map((N,R)=>c.jsxs("div",{className:"py-1 px-2 text-sm text-muted-foreground border-l-2 border-amber-400/60 dark:border-amber-500/40",children:[c.jsx("div",{className:"font-medium",children:N.name}),N.description&&c.jsx("div",{className:"text-xs opacity-70 truncate",children:N.description})]},R)),c.jsx("div",{className:"flex items-center justify-end pr-3 pt-1",children:c.jsx(xe,{className:"h-6 px-2 text-xs",variant:"ghost",title:"Open plugin manager",onClick:()=>g(!0),children:"Manage plugins"})})]})})]})]})]})]}),c.jsx(Vc,{children:c.jsx("div",{className:B("flex w-full items-center transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:c.jsx(bg,{})})}),c.jsx(Lt,{open:p,onOpenChange:g,children:c.jsx(zt,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:c.jsx(pg,{plugins:(e==null?void 0:e.plugins)||[],onClose:()=>g(!1)})})})]}),c.jsx(Yc,{open:w,onOpenChange:S,defaultTab:z==="theme"?"theme":"document"})]})}const go=b.memo(_g),Sg=b.lazy(()=>Qu(()=>import("./editor-CtwF-qwA.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function xo(){return c.jsx(b.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(Sg,{})})}const jg=b.lazy(()=>Qu(()=>import("./preview-38guLS86.js"),__vite__mapDeps([12,1,2,3,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function yo(){return c.jsx(b.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(jg,{})})}const Ng=({className:e,...t})=>c.jsx(hh,{className:B("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Yi=ph,bo=({withHandle:e,className:t,...n})=>c.jsx(mh,{className:B("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&c.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:c.jsx(Ih,{className:"h-2.5 w-2.5"})})});function Cg({className:e,...t}){return c.jsx(gh,{"data-slot":"switch",className:B("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:c.jsx(xh,{"data-slot":"switch-thumb",className:B("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Eg({children:e,className:t}){return c.jsx("kbd",{className:B("inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1 rounded border border-border bg-background text-[11px] font-mono font-medium text-muted-foreground shadow-[0_1px_0_0] shadow-border/50 leading-none select-none",t),children:e})}function Ig({children:e,className:t}){return c.jsx("span",{className:B("inline-flex items-center gap-0.5",t),children:e})}const Pr=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function Ds({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Pr?"⌘":"Ctrl";case"shift":return Pr?"⇧":"Shift";case"alt":return Pr?"⌥":"Alt";case"ctrl":return Pr?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(Ig,{className:t,children:r.map((i,s)=>c.jsx(Eg,{children:i},s))})}class Tg{constructor(t){Ga(this,"client");this.client=Jp.create({baseURL:t||void 0||"/api",headers:{"Content-Type":"application/json"}})}get(t,n){return this.client.get(t,n)}post(t,n,r){return this.client.post(t,n,r)}put(t,n,r){return this.client.put(t,n,r)}delete(t,n){return this.client.delete(t,n)}patch(t,n,r){return this.client.patch(t,n,r)}}const Ag=new Tg;function zg(){const e=b.useRef(null),t=b.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const u=new AbortController;e.current=u;try{a==null||a("parsing","Validating JSON structure...");let l;try{l=JSON.parse(i)}catch(k){throw new Error(`Invalid JSON: ${k instanceof Error?k.message:"Unknown parse error"}`)}a==null||a("building",`Building ${Ar.toLowerCase()} structure...`);const f={jsonDefinition:l,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${bt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const h=await fetch(wh.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:u.signal}),p=await h.json();if(!h.ok||!p.success){const k=p.error||p.message||`API request failed with status: ${h.status}`;throw new Error(k)}const{data:g,cache:w,warnings:S}=p,y=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=y==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${Ar.toLowerCase()}`;a==null||a("finalizing",_);const x=globalThis.atob(g.document),D=new Uint8Array(x.length);for(let k=0;k<x.length;k++)D[k]=x.charCodeAt(k);const I=new Blob([D],{type:g.contentType});if(I.size===0)throw new Error(`Received empty ${Ar.toLowerCase()} from API`);return{name:r,text:i,blob:I,filename:g.filename,fileId:g.fileId,cacheStatus:y,cacheHitRate:w.hitRate,warnings:S}}catch(l){throw l instanceof Error&&l.name==="AbortError"?new Error(`${Ar} generation was cancelled`):l}finally{e.current===u&&(e.current=null)}},[]),n=b.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,cancelGeneration:n}}function Og(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const u=Object.entries(a.context).map(([l,f])=>`${l}: ${JSON.stringify(f)}`).join(", ");o+=` (${u})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}const vo=bt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Xi={docxjs:["⚡","(Recommended) works in the browser"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Pg({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:u,onShowCacheMetrics:l,onShowSchemas:f,documentText:d,warnings:h,renderingLibrary:p,setRenderingLibrary:g,onToggleChat:w,chatOpen:S,onTogglePreview:y,previewOpen:_}){const x=p!=="docxjs",[D,I]=b.useState(!1),[k,E]=b.useState(!1),[L,G]=b.useState(!1),[C,J]=b.useState(!1),[Z,V]=b.useState(!1),[z,A]=b.useState(!1),{toast:q}=Si(),{generatePresentation:F}=zg(),N=b.useCallback(async()=>{if(t){I(!0);try{await new Promise(v=>setTimeout(v,100)),zs(`${e}${zr}`,t)}finally{setTimeout(()=>I(!1),500)}}},[t,e]),R=b.useCallback(async()=>{if(!(!h||h.length===0)){E(!0);try{const v=Og(h);if(!v){q({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const re=await F("warnings",JSON.stringify(v,null,2),{});re&&typeof re=="object"&&"blob"in re&&re.blob&&(zs(`${e}-warnings${zr}`,re.blob),q({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(v){console.error("Failed to generate warnings document:",v),q({title:"Download failed",description:v instanceof Error?v.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>E(!1),500)}}},[h,e,F,q]),m=b.useCallback(async()=>{const v=r==null?void 0:r.current;if(v!=null&&v.src){G(!0);try{await new Promise(fe=>{let de=null,ae=!1;const le=()=>{de&&(clearTimeout(de),de=null),v.removeEventListener("load",Le),v.removeEventListener("error",Be)},je=()=>{ae||(ae=!0,le(),fe())},Le=()=>je(),Be=()=>je();v.addEventListener("load",Le),v.addEventListener("error",Be),de=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),je()},5e3);const mt=v.src,wt=mt.includes("?")?"&":"?",Me=Date.now();v.src=`${mt}${wt}_reload=${Me}`})}catch(re){console.error("Iframe reload failed:",re)}finally{G(!1)}}},[r]),ee=b.useCallback(async()=>{J(!0);try{await Ag.delete(`/${bt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),q({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(v){console.error("Failed to clear cache:",v),q({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{J(!1)}},[q]),ne=b.useCallback(async()=>{if(!d){q({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}A(!0);try{const v=await fetch(`/api/${bt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:d})});if(!v.ok){let de=`Request failed with status ${v.status}`;try{const ae=await v.json();ae.message&&(de=ae.message)}catch{}q({title:"Failed to get standard components",description:de,variant:"destructive"});return}const re=await v.json(),fe=JSON.stringify(re.data,null,2);await navigator.clipboard.writeText(fe),q({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(v){console.error("Error copying standard components:",v),q({title:"Error",description:v instanceof Error?v.message:"Failed to copy standard components",variant:"destructive"})}finally{A(!1)}},[d,q]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"bg-sidebar flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[c.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded hover:bg-muted/60 shrink-0",children:c.jsx(nc,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),c.jsx(Ye,{className:"max-w-sm",children:c.jsxs("p",{className:"text-sm",children:["Preview uses ",bt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",zr," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||x)&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(xe,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||u||_===!1,children:[u?c.jsx(qt,{size:"sm"}):c.jsx(Th,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:_===!1?"Open preview to run":u?"Rendering preview...":"Render preview"})})]}),bt==="docx"&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[c.jsx(pa,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),c.jsx(Cg,{checked:i,onCheckedChange:s,disabled:x})]})}),c.jsx(Ye,{children:c.jsx("p",{children:x?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:m,disabled:L||o||u,children:L?c.jsx(qt,{size:"sm"}):c.jsx(Ah,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsx("p",{children:L?"Reloading...":"Reload"})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(xe,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||D||o,onClick:N,children:[D?c.jsx(qt,{size:"sm"}):c.jsx(zh,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download ",zr]})})]}),h&&h.length>0&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:"outline",size:"icon",className:"h-7 w-7 bg-amber-50 dark:bg-amber-950 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800 hover:bg-amber-100 dark:hover:bg-amber-900",disabled:k||o,onClick:R,children:k?c.jsx(qt,{size:"sm"}):c.jsx(sc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),p&&g&&c.jsxs(ma,{value:p,onValueChange:g,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ei,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:c.jsx(ga,{placeholder:"Renderer"})})}),c.jsx(Ye,{children:c.jsx("p",{children:"Select the rendering library"})})]}),c.jsx(Ii,{className:"text-sidebar-foreground",children:vo.map(v=>c.jsxs(hr,{value:v,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{tabIndex:-1,children:Xi[v][0]}),c.jsx(Ye,{children:Xi[v][1]})]})," ",v]},v))})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Gc,{children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Kc,{asChild:!0,children:c.jsx(xe,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(Oh,{className:"h-3.5 w-3.5"})})})}),c.jsx(Ye,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(va,{align:"end",className:"w-52",children:[f&&c.jsxs(Wt,{onClick:f,children:[c.jsx(rc,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),l&&c.jsxs(Wt,{onClick:l,children:[c.jsx(Ph,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),c.jsxs(Wt,{onClick:ne,disabled:!d||z,children:[c.jsx(ac,{className:"h-4 w-4 mr-2"}),z?"Copying...":"Copy standard components"]}),c.jsx(ai,{}),c.jsxs(Wt,{onClick:()=>V(!0),disabled:C,className:"text-destructive focus:text-destructive",children:[c.jsx(oa,{className:"h-4 w-4 mr-2"}),C?"Clearing...":"Clear all caches"]}),p&&g&&c.jsxs(c.Fragment,{children:[c.jsx(ai,{className:"lg:hidden"}),vo.map(v=>c.jsxs(Wt,{className:"lg:hidden",onClick:()=>g(v),children:[c.jsx("span",{className:"mr-2",children:p===v?"●":"○"}),Xi[v][0]," ",v]},v))]})]})]}),y&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:_?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:y,children:_?c.jsx(Yr,{className:"h-3.5 w-3.5"}):c.jsx(Dh,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[_?"Hide":"Show"," Preview ",c.jsx(Ds,{shortcut:"mod+shift+p"})]})})]}),w&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(xe,{variant:S?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:w,children:c.jsx(oc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[S?"Close":"Open"," AI Chat ",c.jsx(Ds,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(Lt,{open:Z,onOpenChange:V,children:c.jsxs(zt,{className:"max-w-sm",children:[c.jsxs(mn,{children:[c.jsx(gn,{children:"Clear all caches?"}),c.jsx(Dn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),c.jsxs(pr,{children:[c.jsx(xe,{variant:"outline",size:"sm",onClick:()=>V(!1),children:"Cancel"}),c.jsx(xe,{variant:"destructive",size:"sm",disabled:C,onClick:async()=>{await ee(),V(!1)},children:C?c.jsx(qt,{size:"sm"}):"Clear"})]})]})})]})}const Dg=_e.memo(Pg);function wo({previewOpen:e,onTogglePreview:t}){const n=on(E=>E.name||""),r=on(E=>E.blob),i=on(E=>E.isGenerating),s=on(E=>E.text),a=on(E=>E.warnings),o=on(E=>E.isRendering),u=Or(E=>E.autoReload),l=Or(E=>E.renderingLibrary),f=Or(E=>E.setSettings),d=Or(E=>E.useGlobalPreviewHeader??!0),h=qe(E=>E.activeTab),p=qe(E=>E.documentTypes),g=h&&p[h]==="application/json+theme"?"theme":"document",w=Se(E=>E.chatOpen),S=Se(E=>E.toggleChat),[y,_]=_e.useState(!1);if(!d)return null;const x=b.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!u}),[u,f]),D=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),I=b.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),k=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(Dg,{name:k,blob:r,displayReloadButton:!1,autoReload:u,onToggleAutoReload:x,onManualRender:D,isGenerating:i,isRendering:!!o,onShowCacheMetrics:I,onShowSchemas:()=>_(!0),documentText:s,warnings:a,renderingLibrary:l,setRenderingLibrary:E=>f({renderingLibrary:E}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),c.jsx(Yc,{open:y,onOpenChange:_,defaultTab:g==="theme"?"theme":"document"})]})}function Rg(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Mg=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Fg=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$g={};function ko(e,t){return($g.jsx?Fg:Mg).test(e)}const Lg=/[ \t\n\f\r]/g;function Zg(e){return typeof e=="object"?e.type==="text"?_o(e.value):!1:_o(e)}function _o(e){return e.replace(Lg,"")===""}class jr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}jr.prototype.normal={};jr.prototype.property={};jr.prototype.space=void 0;function Xc(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new jr(n,r,t)}function Rs(e){return e.toLowerCase()}class ct{constructor(t,n){this.attribute=n,this.property=t}}ct.prototype.attribute="";ct.prototype.booleanish=!1;ct.prototype.boolean=!1;ct.prototype.commaOrSpaceSeparated=!1;ct.prototype.commaSeparated=!1;ct.prototype.defined=!1;ct.prototype.mustUseProperty=!1;ct.prototype.number=!1;ct.prototype.overloadedBoolean=!1;ct.prototype.property="";ct.prototype.spaceSeparated=!1;ct.prototype.space=void 0;let Vg=0;const me=bn(),Je=bn(),Ms=bn(),H=bn(),Ae=bn(),On=bn(),ft=bn();function bn(){return 2**++Vg}const Fs=Object.freeze(Object.defineProperty({__proto__:null,boolean:me,booleanish:Je,commaOrSpaceSeparated:ft,commaSeparated:On,number:H,overloadedBoolean:Ms,spaceSeparated:Ae},Symbol.toStringTag,{value:"Module"})),Qi=Object.keys(Fs);class wa extends ct{constructor(t,n,r,i){let s=-1;if(super(t,n),So(this,"space",i),typeof r=="number")for(;++s<Qi.length;){const a=Qi[s];So(this,Qi[s],(r&Fs[a])===Fs[a])}}}wa.prototype.defined=!0;function So(e,t,n){n&&(e[t]=n)}function Zn(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new wa(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Rs(r)]=r,n[Rs(s.attribute)]=r}return new jr(t,n,e.space)}const Qc=Zn({properties:{ariaActiveDescendant:null,ariaAtomic:Je,ariaAutoComplete:null,ariaBusy:Je,ariaChecked:Je,ariaColCount:H,ariaColIndex:H,ariaColSpan:H,ariaControls:Ae,ariaCurrent:null,ariaDescribedBy:Ae,ariaDetails:null,ariaDisabled:Je,ariaDropEffect:Ae,ariaErrorMessage:null,ariaExpanded:Je,ariaFlowTo:Ae,ariaGrabbed:Je,ariaHasPopup:null,ariaHidden:Je,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ae,ariaLevel:H,ariaLive:null,ariaModal:Je,ariaMultiLine:Je,ariaMultiSelectable:Je,ariaOrientation:null,ariaOwns:Ae,ariaPlaceholder:null,ariaPosInSet:H,ariaPressed:Je,ariaReadOnly:Je,ariaRelevant:null,ariaRequired:Je,ariaRoleDescription:Ae,ariaRowCount:H,ariaRowIndex:H,ariaRowSpan:H,ariaSelected:Je,ariaSetSize:H,ariaSort:null,ariaValueMax:H,ariaValueMin:H,ariaValueNow:H,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function ed(e,t){return t in e?e[t]:t}function td(e,t){return ed(e,t.toLowerCase())}const Bg=Zn({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:On,acceptCharset:Ae,accessKey:Ae,action:null,allow:null,allowFullScreen:me,allowPaymentRequest:me,allowUserMedia:me,alt:null,as:null,async:me,autoCapitalize:null,autoComplete:Ae,autoFocus:me,autoPlay:me,blocking:Ae,capture:null,charSet:null,checked:me,cite:null,className:Ae,cols:H,colSpan:null,content:null,contentEditable:Je,controls:me,controlsList:Ae,coords:H|On,crossOrigin:null,data:null,dateTime:null,decoding:null,default:me,defer:me,dir:null,dirName:null,disabled:me,download:Ms,draggable:Je,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:me,formTarget:null,headers:Ae,height:H,hidden:Ms,high:H,href:null,hrefLang:null,htmlFor:Ae,httpEquiv:Ae,id:null,imageSizes:null,imageSrcSet:null,inert:me,inputMode:null,integrity:null,is:null,isMap:me,itemId:null,itemProp:Ae,itemRef:Ae,itemScope:me,itemType:Ae,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:me,low:H,manifest:null,max:null,maxLength:H,media:null,method:null,min:null,minLength:H,multiple:me,muted:me,name:null,nonce:null,noModule:me,noValidate:me,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:me,optimum:H,pattern:null,ping:Ae,placeholder:null,playsInline:me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:me,referrerPolicy:null,rel:Ae,required:me,reversed:me,rows:H,rowSpan:H,sandbox:Ae,scope:null,scoped:me,seamless:me,selected:me,shadowRootClonable:me,shadowRootDelegatesFocus:me,shadowRootMode:null,shape:null,size:H,sizes:null,slot:null,span:H,spellCheck:Je,src:null,srcDoc:null,srcLang:null,srcSet:null,start:H,step:null,style:null,tabIndex:H,target:null,title:null,translate:null,type:null,typeMustMatch:me,useMap:null,value:Je,width:H,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ae,axis:null,background:null,bgColor:null,border:H,borderColor:null,bottomMargin:H,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:me,declare:me,event:null,face:null,frame:null,frameBorder:null,hSpace:H,leftMargin:H,link:null,longDesc:null,lowSrc:null,marginHeight:H,marginWidth:H,noResize:me,noHref:me,noShade:me,noWrap:me,object:null,profile:null,prompt:null,rev:null,rightMargin:H,rules:null,scheme:null,scrolling:Je,standby:null,summary:null,text:null,topMargin:H,valueType:null,version:null,vAlign:null,vLink:null,vSpace:H,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:me,disableRemotePlayback:me,prefix:null,property:null,results:H,security:null,unselectable:null},space:"html",transform:td}),Ug=Zn({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ft,accentHeight:H,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:H,amplitude:H,arabicForm:null,ascent:H,attributeName:null,attributeType:null,azimuth:H,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:H,by:null,calcMode:null,capHeight:H,className:Ae,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:H,diffuseConstant:H,direction:null,display:null,dur:null,divisor:H,dominantBaseline:null,download:me,dx:null,dy:null,edgeMode:null,editable:null,elevation:H,enableBackground:null,end:null,event:null,exponent:H,externalResourcesRequired:null,fill:null,fillOpacity:H,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:On,g2:On,glyphName:On,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:H,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:H,horizOriginX:H,horizOriginY:H,id:null,ideographic:H,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:H,k:H,k1:H,k2:H,k3:H,k4:H,kernelMatrix:ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:H,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:H,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:H,overlineThickness:H,paintOrder:null,panose1:null,path:null,pathLength:H,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ae,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:H,pointsAtY:H,pointsAtZ:H,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ft,rev:ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ft,requiredFeatures:ft,requiredFonts:ft,requiredFormats:ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:H,specularExponent:H,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:H,strikethroughThickness:H,string:null,stroke:null,strokeDashArray:ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:H,strokeOpacity:H,strokeWidth:null,style:null,surfaceScale:H,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ft,tabIndex:H,tableValues:null,target:null,targetX:H,targetY:H,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:H,underlineThickness:H,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:H,values:null,vAlphabetic:H,vMathematical:H,vectorEffect:null,vHanging:H,vIdeographic:H,version:null,vertAdvY:H,vertOriginX:H,vertOriginY:H,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:H,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ed}),nd=Zn({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),rd=Zn({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:td}),id=Zn({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Jg={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},qg=/[A-Z]/g,jo=/-[a-z]/g,Hg=/^data[-\w.:]+$/i;function Wg(e,t){const n=Rs(t);let r=t,i=ct;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hg.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(jo,Kg);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!jo.test(s)){let a=s.replace(qg,Gg);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=wa}return new i(r,t)}function Gg(e){return"-"+e.toLowerCase()}function Kg(e){return e.charAt(1).toUpperCase()}const Yg=Xc([Qc,Bg,nd,rd,id],"html"),ka=Xc([Qc,Ug,nd,rd,id],"svg");function Xg(e){return e.join(" ").trim()}var kn={},es,No;function Qg(){if(No)return es;No=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,u=`
|
|
3
3
|
`,l="/",f="*",d="",h="comment",p="declaration";function g(S,y){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];y=y||{};var _=1,x=1;function D(z){var A=z.match(t);A&&(_+=A.length);var q=z.lastIndexOf(u);x=~q?z.length-q:x+z.length}function I(){var z={line:_,column:x};return function(A){return A.position=new k(z),G(),A}}function k(z){this.start=z,this.end={line:_,column:x},this.source=y.source}k.prototype.content=S;function E(z){var A=new Error(y.source+":"+_+":"+x+": "+z);if(A.reason=z,A.filename=y.source,A.line=_,A.column=x,A.source=S,!y.silent)throw A}function L(z){var A=z.exec(S);if(A){var q=A[0];return D(q),S=S.slice(q.length),A}}function G(){L(n)}function C(z){var A;for(z=z||[];A=J();)A!==!1&&z.push(A);return z}function J(){var z=I();if(!(l!=S.charAt(0)||f!=S.charAt(1))){for(var A=2;d!=S.charAt(A)&&(f!=S.charAt(A)||l!=S.charAt(A+1));)++A;if(A+=2,d===S.charAt(A-1))return E("End of comment missing");var q=S.slice(2,A-2);return x+=2,D(q),S=S.slice(A),x+=2,z({type:h,comment:q})}}function Z(){var z=I(),A=L(r);if(A){if(J(),!L(i))return E("property missing ':'");var q=L(s),F=z({type:p,property:w(A[0].replace(e,d)),value:q?w(q[0].replace(e,d)):d});return L(a),F}}function V(){var z=[];C(z);for(var A;A=Z();)A!==!1&&(z.push(A),C(z));return z}return G(),V()}function w(S){return S?S.replace(o,d):d}return es=g,es}var Co;function ex(){if(Co)return kn;Co=1;var e=kn&&kn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(kn,"__esModule",{value:!0}),kn.default=n;const t=e(Qg());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(u=>{if(u.type!=="declaration")return;const{property:l,value:f}=u;o?i(l,f,u):f&&(s=s||{},s[l]=f)}),s}return kn}var Wn={},Eo;function tx(){if(Eo)return Wn;Eo=1,Object.defineProperty(Wn,"__esModule",{value:!0}),Wn.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(l){return!l||n.test(l)||e.test(l)},a=function(l,f){return f.toUpperCase()},o=function(l,f){return"".concat(f,"-")},u=function(l,f){return f===void 0&&(f={}),s(l)?l:(l=l.toLowerCase(),f.reactCompat?l=l.replace(i,o):l=l.replace(r,o),l.replace(t,a))};return Wn.camelCase=u,Wn}var Gn,Io;function nx(){if(Io)return Gn;Io=1;var e=Gn&&Gn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(ex()),n=tx();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,u){o&&u&&(a[(0,n.camelCase)(o,s)]=u)}),a}return r.default=r,Gn=r,Gn}var rx=nx();const ix=sa(rx),sd=ad("end"),_a=ad("start");function ad(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function sx(e){const t=_a(e),n=sd(e);if(t&&n)return{start:t,end:n}}function ur(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?To(e.position):"start"in e||"end"in e?To(e):"line"in e||"column"in e?$s(e):""}function $s(e){return Ao(e&&e.line)+":"+Ao(e&&e.column)}function To(e){return $s(e&&e.start)+"-"+$s(e&&e.end)}function Ao(e){return e&&typeof e=="number"?e:1}class et extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?s.ruleId=r:(s.source=r.slice(0,u),s.ruleId=r.slice(u+1))}if(!s.place&&s.ancestors&&s.ancestors){const u=s.ancestors[s.ancestors.length-1];u&&(s.place=u.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=ur(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}et.prototype.file="";et.prototype.name="";et.prototype.reason="";et.prototype.message="";et.prototype.stack="";et.prototype.column=void 0;et.prototype.line=void 0;et.prototype.ancestors=void 0;et.prototype.cause=void 0;et.prototype.fatal=void 0;et.prototype.place=void 0;et.prototype.ruleId=void 0;et.prototype.source=void 0;const Sa={}.hasOwnProperty,ax=new Map,ox=/[A-Z]/g,lx=new Set(["table","tbody","thead","tfoot","tr"]),ux=new Set(["td","th"]),od="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cx(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=yx(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=xx(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ka:Yg,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=ld(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function ld(e,t,n){if(t.type==="element")return dx(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return fx(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return hx(e,t,n);if(t.type==="mdxjsEsm")return px(e,t);if(t.type==="root")return mx(e,t,n);if(t.type==="text")return gx(e,t)}function dx(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ka,e.schema=i),e.ancestors.push(t);const s=cd(e,t.tagName,!1),a=bx(e,t);let o=Na(e,t);return lx.has(t.tagName)&&(o=o.filter(function(u){return typeof u=="string"?!Zg(u):!0})),ud(e,a,s,t),ja(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function fx(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}mr(e,t.position)}function px(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);mr(e,t.position)}function hx(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=ka,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:cd(e,t.name,!0),a=vx(e,t),o=Na(e,t);return ud(e,a,s,t),ja(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function mx(e,t,n){const r={};return ja(r,Na(e,t)),e.create(t,e.Fragment,r,n)}function gx(e,t){return t.value}function ud(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ja(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function xx(e,t,n){return r;function r(i,s,a,o){const l=Array.isArray(a.children)?n:t;return o?l(s,a,o):l(s,a)}}function yx(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),u=_a(r);return t(i,s,a,o,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function bx(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Sa.call(t.properties,i)){const s=wx(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&ux.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function vx(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else mr(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else mr(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Na(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:ax;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const u=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(u){const l=i.get(u)||0;a=u+"-"+l,i.set(u,l+1)}}const o=ld(e,s,a);o!==void 0&&n.push(o)}return n}function wx(e,t,n){const r=Wg(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Rg(n):Xg(n)),r.property==="style"){let i=typeof n=="object"?n:kx(e,String(n));return e.stylePropertyNameCase==="css"&&(i=_x(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Jg[r.property]||r.property:r.attribute,n]}}function kx(e,t){try{return ix(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new et("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=od+"#cannot-parse-style-attribute",i}}function cd(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=ko(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=ko(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Sa.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);mr(e)}function mr(e,t){const n=new et("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=od+"#cannot-handle-mdx-estrees-without-createevaluater",n}function _x(e){const t={};let n;for(n in e)Sa.call(e,n)&&(t[Sx(n)]=e[n]);return t}function Sx(e){let t=e.replace(ox,jx);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function jx(e){return"-"+e.toLowerCase()}const ts={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Nx={};function Ca(e,t){const n=Nx,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return dd(e,r,i)}function dd(e,t,n){if(Cx(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return zo(e.children,t,n)}return Array.isArray(e)?zo(e,t,n):""}function zo(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=dd(e[i],t,n);return r.join("")}function Cx(e){return!!(e&&typeof e=="object")}const Oo=document.createElement("i");function Ea(e){const t="&"+e+";";Oo.innerHTML=t;const n=Oo.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function pt(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function yt(e,t){return e.length>0?(pt(e,e.length,0,t),e):t}const Po={}.hasOwnProperty;function fd(e){const t={};let n=-1;for(;++n<e.length;)Ex(t,e[n]);return t}function Ex(e,t){let n;for(n in t){const i=(Po.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Po.call(i,a)||(i[a]=[]);const o=s[a];Ix(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Ix(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);pt(e,0,0,r)}function pd(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Nt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const st=Qt(/[A-Za-z]/),Qe=Qt(/[\dA-Za-z]/),Tx=Qt(/[#-'*+\--9=?A-Z^-~]/);function oi(e){return e!==null&&(e<32||e===127)}const Ls=Qt(/\d/),Ax=Qt(/[\dA-Fa-f]/),zx=Qt(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Ie(e){return e!==null&&(e<0||e===32)}function ye(e){return e===-2||e===-1||e===32}const Ai=Qt(new RegExp("\\p{P}|\\p{S}","u")),xn=Qt(/\s/);function Qt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Vn(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&Qe(e.charCodeAt(n+1))&&Qe(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ke(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(u){return ye(u)?(e.enter(n),o(u)):t(u)}function o(u){return ye(u)&&s++<i?(e.consume(u),o):(e.exit(n),t(u))}}const Ox={tokenize:Px};function Px(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ke(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return ue(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Dx={tokenize:Rx},Do={tokenize:Mx};function Rx(e){const t=this,n=[];let r=0,i,s,a;return o;function o(x){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,u,l)(x)}return l(x)}function u(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const D=t.events.length;let I=D,k;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){k=t.events[I][1].end;break}y(r);let E=D;for(;E<t.events.length;)t.events[E][1].end={...k},E++;return pt(t.events,I+1,0,t.events.slice(D)),t.events.length=E,l(x)}return o(x)}function l(x){if(r===n.length){if(!i)return h(x);if(i.currentConstruct&&i.currentConstruct.concrete)return g(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Do,f,d)(x)}function f(x){return i&&_(),y(r),h(x)}function d(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(x)}function h(x){return t.containerState={},e.attempt(Do,p,g)(x)}function p(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function g(x){if(x===null){i&&_(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(x)}function w(x){if(x===null){S(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return ue(x)?(e.consume(x),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(x),w)}function S(x,D){const I=t.sliceStream(x);if(D&&I.push(null),x.previous=s,s&&(s.next=x),s=x,i.defineSkip(x.start),i.write(I),t.parser.lazy[x.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<a&&(!i.events[k][1].end||i.events[k][1].end.offset>a))return;const E=t.events.length;let L=E,G,C;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(G){C=t.events[L][1].end;break}G=!0}for(y(r),k=E;k<t.events.length;)t.events[k][1].end={...C},k++;pt(t.events,L+1,0,t.events.slice(E)),t.events.length=k}}function y(x){let D=n.length;for(;D-- >x;){const I=n[D];t.containerState=I[1],I[0].exit.call(t,e)}n.length=x}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Mx(e,t,n){return ke(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Rn(e){if(e===null||Ie(e)||xn(e))return 1;if(Ai(e))return 2}function zi(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Zs={name:"attention",resolveAll:Fx,tokenize:$x};function Fx(e,t){let n=-1,r,i,s,a,o,u,l,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},h={...e[n][1].start};Ro(d,-u),Ro(h,u),a={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=yt(l,[["enter",e[r][1],t],["exit",e[r][1],t]])),l=yt(l,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),l=yt(l,zi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=yt(l,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=yt(l,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,pt(e,r-1,n-r+3,l),n=r+l.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function $x(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Rn(r);let s;return a;function a(u){return s=u,e.enter("attentionSequence"),o(u)}function o(u){if(u===s)return e.consume(u),o;const l=e.exit("attentionSequence"),f=Rn(u),d=!f||f===2&&i||n.includes(u),h=!i||i===2&&f||n.includes(r);return l._open=!!(s===42?d:d&&(i||!h)),l._close=!!(s===42?h:h&&(f||!d)),t(u)}}function Ro(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Lx={name:"autolink",tokenize:Zx};function Zx(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return st(p)?(e.consume(p),a):p===64?n(p):l(p)}function a(p){return p===43||p===45||p===46||Qe(p)?(r=1,o(p)):l(p)}function o(p){return p===58?(e.consume(p),r=0,u):(p===43||p===45||p===46||Qe(p))&&r++<32?(e.consume(p),o):(r=0,l(p))}function u(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||oi(p)?n(p):(e.consume(p),u)}function l(p){return p===64?(e.consume(p),f):Tx(p)?(e.consume(p),l):n(p)}function f(p){return Qe(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,f):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||Qe(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const Nr={partial:!0,tokenize:Vx};function Vx(e,t,n){return r;function r(s){return ye(s)?ke(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ue(s)?t(s):n(s)}}const hd={continuation:{tokenize:Ux},exit:Jx,name:"blockQuote",tokenize:Bx};function Bx(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return ye(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Ux(e,t,n){const r=this;return i;function i(a){return ye(a)?ke(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(hd,t,n)(a)}}function Jx(e){e.exit("blockQuote")}const md={name:"characterEscape",tokenize:qx};function qx(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return zx(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const gd={name:"characterReference",tokenize:Hx};function Hx(e,t,n){const r=this;let i=0,s,a;return o;function o(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),u}function u(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),s=31,a=Qe,f(d))}function l(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Ax,f):(e.enter("characterReferenceValue"),s=7,a=Ls,f(d))}function f(d){if(d===59&&i){const h=e.exit("characterReferenceValue");return a===Qe&&!Ea(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&i++<s?(e.consume(d),f):n(d)}}const Mo={partial:!0,tokenize:Gx},Fo={concrete:!0,name:"codeFenced",tokenize:Wx};function Wx(e,t,n){const r=this,i={partial:!0,tokenize:I};let s=0,a=0,o;return u;function u(k){return l(k)}function l(k){const E=r.events[r.events.length-1];return s=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,o=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(k)}function f(k){return k===o?(a++,e.consume(k),f):a<3?n(k):(e.exit("codeFencedFenceSequence"),ye(k)?ke(e,d,"whitespace")(k):d(k))}function d(k){return k===null||ue(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Mo,w,D)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):ye(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ke(e,p,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),h)}function p(k){return k===null||ue(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===null||ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===o?n(k):(e.consume(k),g)}function w(k){return e.attempt(i,D,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),y}function y(k){return s>0&&ye(k)?ke(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||ue(k)?e.check(Mo,w,D)(k):(e.enter("codeFlowValue"),x(k))}function x(k){return k===null||ue(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),x)}function D(k){return e.exit("codeFenced"),t(k)}function I(k,E,L){let G=0;return C;function C(A){return k.enter("lineEnding"),k.consume(A),k.exit("lineEnding"),J}function J(A){return k.enter("codeFencedFence"),ye(A)?ke(k,Z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):Z(A)}function Z(A){return A===o?(k.enter("codeFencedFenceSequence"),V(A)):L(A)}function V(A){return A===o?(G++,k.consume(A),V):G>=a?(k.exit("codeFencedFenceSequence"),ye(A)?ke(k,z,"whitespace")(A):z(A)):L(A)}function z(A){return A===null||ue(A)?(k.exit("codeFencedFence"),E(A)):L(A)}}}function Gx(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const ns={name:"codeIndented",tokenize:Yx},Kx={partial:!0,tokenize:Xx};function Yx(e,t,n){const r=this;return i;function i(l){return e.enter("codeIndented"),ke(e,s,"linePrefix",5)(l)}function s(l){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(l):n(l)}function a(l){return l===null?u(l):ue(l)?e.attempt(Kx,a,u)(l):(e.enter("codeFlowValue"),o(l))}function o(l){return l===null||ue(l)?(e.exit("codeFlowValue"),a(l)):(e.consume(l),o)}function u(l){return e.exit("codeIndented"),t(l)}}function Xx(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):ue(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ke(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):ue(a)?i(a):n(a)}}const Qx={name:"codeText",previous:ty,resolve:ey,tokenize:ny};function ey(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function ty(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ny(e,t,n){let r=0,i,s;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),o(d)}function o(d){return d===96?(e.consume(d),r++,o):(e.exit("codeTextSequence"),u(d))}function u(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),u):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):ue(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):(e.enter("codeTextData"),l(d))}function l(d){return d===null||d===32||d===96||ue(d)?(e.exit("codeTextData"),u(d)):(e.consume(d),l)}function f(d){return d===96?(e.consume(d),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",l(d))}}class ry{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Kn(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Kn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Kn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Kn(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Kn(this.left,n.reverse())}}}function Kn(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function xd(e){const t={};let n=-1,r,i,s,a,o,u,l;const f=new ry(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,s=0,s<u.length&&u[s][1].type==="lineEndingBlank"&&(s+=2),s<u.length&&u[s][1].type==="content"))for(;++s<u.length&&u[s][1].type!=="content";)u[s][1].type==="chunkText"&&(u[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,iy(f,n)),n=t[n],l=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return pt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function iy(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,u=[],l={};let f,d,h=-1,p=n,g=0,w=0;const S=[w];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),d&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<o.length;)o[h][0]==="exit"&&o[h-1][0]==="enter"&&o[h][1].type===o[h-1][1].type&&o[h][1].start.line!==o[h][1].end.line&&(w=h+1,S.push(w),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):S.pop(),h=S.length;h--;){const y=o.slice(S[h],S[h+1]),_=s.pop();u.push([_,_+y.length-1]),e.splice(_,2,y)}for(u.reverse(),h=-1;++h<u.length;)l[g+u[h][0]]=g+u[h][1],g+=u[h][1]-u[h][0]-1;return l}const sy={resolve:oy,tokenize:ly},ay={partial:!0,tokenize:uy};function oy(e){return xd(e),e}function ly(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):ue(o)?e.check(ay,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function uy(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ke(e,s,"linePrefix")}function s(a){if(a===null||ue(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function yd(e,t,n,r,i,s,a,o,u){const l=u||Number.POSITIVE_INFINITY;let f=0;return d;function d(y){return y===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(y),e.exit(s),h):y===null||y===32||y===41||oi(y)?n(y):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(y))}function h(y){return y===62?(e.enter(s),e.consume(y),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(o),h(y)):y===null||y===60||ue(y)?n(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function w(y){return!f&&(y===null||y===41||Ie(y))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(y)):f<l&&y===40?(e.consume(y),f++,w):y===41?(e.consume(y),f--,w):y===null||y===32||y===40||oi(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function bd(e,t,n,r,i,s){const a=this;let o=0,u;return l;function l(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),f}function f(p){return o>999||p===null||p===91||p===93&&!u||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):ue(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||ue(p)||o++>999?(e.exit("chunkString"),f(p)):(e.consume(p),u||(u=!ye(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function vd(e,t,n,r,i,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,u):n(h)}function u(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),l(h))}function l(h){return h===a?(e.exit(s),u(a)):h===null?n(h):ue(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),ke(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===a||h===null||ue(h)?(e.exit("chunkString"),l(h)):(e.consume(h),h===92?d:f)}function d(h){return h===a||h===92?(e.consume(h),f):f(h)}}function cr(e,t){let n;return r;function r(i){return ue(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ye(i)?ke(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const cy={name:"definition",tokenize:fy},dy={partial:!0,tokenize:py};function fy(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return bd.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return i=Nt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),u):n(p)}function u(p){return Ie(p)?cr(e,l)(p):l(p)}function l(p){return yd(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(dy,d,d)(p)}function d(p){return ye(p)?ke(e,h,"whitespace")(p):h(p)}function h(p){return p===null||ue(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function py(e,t,n){return r;function r(o){return Ie(o)?cr(e,i)(o):n(o)}function i(o){return vd(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return ye(o)?ke(e,a,"whitespace")(o):a(o)}function a(o){return o===null||ue(o)?t(o):n(o)}}const hy={name:"hardBreakEscape",tokenize:my};function my(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ue(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const gy={name:"headingAtx",resolve:xy,tokenize:yy};function xy(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},pt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function yy(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),s(f)}function s(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Ie(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),u(f)):f===null||ue(f)?(e.exit("atxHeading"),t(f)):ye(f)?ke(e,o,"whitespace")(f):(e.enter("atxHeadingText"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit("atxHeadingSequence"),o(f))}function l(f){return f===null||f===35||Ie(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),l)}}const by=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],$o=["pre","script","style","textarea"],vy={concrete:!0,name:"htmlFlow",resolveTo:_y,tokenize:Sy},wy={partial:!0,tokenize:Ny},ky={partial:!0,tokenize:jy};function _y(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Sy(e,t,n){const r=this;let i,s,a,o,u;return l;function l(v){return f(v)}function f(v){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(v),d}function d(v){return v===33?(e.consume(v),h):v===47?(e.consume(v),s=!0,w):v===63?(e.consume(v),i=3,r.interrupt?t:m):st(v)?(e.consume(v),a=String.fromCharCode(v),S):n(v)}function h(v){return v===45?(e.consume(v),i=2,p):v===91?(e.consume(v),i=5,o=0,g):st(v)?(e.consume(v),i=4,r.interrupt?t:m):n(v)}function p(v){return v===45?(e.consume(v),r.interrupt?t:m):n(v)}function g(v){const re="CDATA[";return v===re.charCodeAt(o++)?(e.consume(v),o===re.length?r.interrupt?t:Z:g):n(v)}function w(v){return st(v)?(e.consume(v),a=String.fromCharCode(v),S):n(v)}function S(v){if(v===null||v===47||v===62||Ie(v)){const re=v===47,fe=a.toLowerCase();return!re&&!s&&$o.includes(fe)?(i=1,r.interrupt?t(v):Z(v)):by.includes(a.toLowerCase())?(i=6,re?(e.consume(v),y):r.interrupt?t(v):Z(v)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(v):s?_(v):x(v))}return v===45||Qe(v)?(e.consume(v),a+=String.fromCharCode(v),S):n(v)}function y(v){return v===62?(e.consume(v),r.interrupt?t:Z):n(v)}function _(v){return ye(v)?(e.consume(v),_):C(v)}function x(v){return v===47?(e.consume(v),C):v===58||v===95||st(v)?(e.consume(v),D):ye(v)?(e.consume(v),x):C(v)}function D(v){return v===45||v===46||v===58||v===95||Qe(v)?(e.consume(v),D):I(v)}function I(v){return v===61?(e.consume(v),k):ye(v)?(e.consume(v),I):x(v)}function k(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),u=v,E):ye(v)?(e.consume(v),k):L(v)}function E(v){return v===u?(e.consume(v),u=null,G):v===null||ue(v)?n(v):(e.consume(v),E)}function L(v){return v===null||v===34||v===39||v===47||v===60||v===61||v===62||v===96||Ie(v)?I(v):(e.consume(v),L)}function G(v){return v===47||v===62||ye(v)?x(v):n(v)}function C(v){return v===62?(e.consume(v),J):n(v)}function J(v){return v===null||ue(v)?Z(v):ye(v)?(e.consume(v),J):n(v)}function Z(v){return v===45&&i===2?(e.consume(v),q):v===60&&i===1?(e.consume(v),F):v===62&&i===4?(e.consume(v),ee):v===63&&i===3?(e.consume(v),m):v===93&&i===5?(e.consume(v),R):ue(v)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(wy,ne,V)(v)):v===null||ue(v)?(e.exit("htmlFlowData"),V(v)):(e.consume(v),Z)}function V(v){return e.check(ky,z,ne)(v)}function z(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),A}function A(v){return v===null||ue(v)?V(v):(e.enter("htmlFlowData"),Z(v))}function q(v){return v===45?(e.consume(v),m):Z(v)}function F(v){return v===47?(e.consume(v),a="",N):Z(v)}function N(v){if(v===62){const re=a.toLowerCase();return $o.includes(re)?(e.consume(v),ee):Z(v)}return st(v)&&a.length<8?(e.consume(v),a+=String.fromCharCode(v),N):Z(v)}function R(v){return v===93?(e.consume(v),m):Z(v)}function m(v){return v===62?(e.consume(v),ee):v===45&&i===2?(e.consume(v),m):Z(v)}function ee(v){return v===null||ue(v)?(e.exit("htmlFlowData"),ne(v)):(e.consume(v),ee)}function ne(v){return e.exit("htmlFlow"),t(v)}}function jy(e,t,n){const r=this;return i;function i(a){return ue(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Ny(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Nr,t,n)}}const Cy={name:"htmlText",tokenize:Ey};function Ey(e,t,n){const r=this;let i,s,a;return o;function o(m){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),I):m===63?(e.consume(m),x):st(m)?(e.consume(m),L):n(m)}function l(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),s=0,g):st(m)?(e.consume(m),_):n(m)}function f(m){return m===45?(e.consume(m),p):n(m)}function d(m){return m===null?n(m):m===45?(e.consume(m),h):ue(m)?(a=d,F(m)):(e.consume(m),d)}function h(m){return m===45?(e.consume(m),p):d(m)}function p(m){return m===62?q(m):m===45?h(m):d(m)}function g(m){const ee="CDATA[";return m===ee.charCodeAt(s++)?(e.consume(m),s===ee.length?w:g):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),S):ue(m)?(a=w,F(m)):(e.consume(m),w)}function S(m){return m===93?(e.consume(m),y):w(m)}function y(m){return m===62?q(m):m===93?(e.consume(m),y):w(m)}function _(m){return m===null||m===62?q(m):ue(m)?(a=_,F(m)):(e.consume(m),_)}function x(m){return m===null?n(m):m===63?(e.consume(m),D):ue(m)?(a=x,F(m)):(e.consume(m),x)}function D(m){return m===62?q(m):x(m)}function I(m){return st(m)?(e.consume(m),k):n(m)}function k(m){return m===45||Qe(m)?(e.consume(m),k):E(m)}function E(m){return ue(m)?(a=E,F(m)):ye(m)?(e.consume(m),E):q(m)}function L(m){return m===45||Qe(m)?(e.consume(m),L):m===47||m===62||Ie(m)?G(m):n(m)}function G(m){return m===47?(e.consume(m),q):m===58||m===95||st(m)?(e.consume(m),C):ue(m)?(a=G,F(m)):ye(m)?(e.consume(m),G):q(m)}function C(m){return m===45||m===46||m===58||m===95||Qe(m)?(e.consume(m),C):J(m)}function J(m){return m===61?(e.consume(m),Z):ue(m)?(a=J,F(m)):ye(m)?(e.consume(m),J):G(m)}function Z(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):ue(m)?(a=Z,F(m)):ye(m)?(e.consume(m),Z):(e.consume(m),z)}function V(m){return m===i?(e.consume(m),i=void 0,A):m===null?n(m):ue(m)?(a=V,F(m)):(e.consume(m),V)}function z(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||Ie(m)?G(m):(e.consume(m),z)}function A(m){return m===47||m===62||Ie(m)?G(m):n(m)}function q(m){return m===62?(e.consume(m),e.exit("htmlTextData"),e.exit("htmlText"),t):n(m)}function F(m){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),N}function N(m){return ye(m)?ke(e,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):R(m)}function R(m){return e.enter("htmlTextData"),a(m)}}const Ia={name:"labelEnd",resolveAll:zy,resolveTo:Oy,tokenize:Py},Iy={tokenize:Dy},Ty={tokenize:Ry},Ay={tokenize:My};function zy(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&pt(e,0,e.length,n),e}function Oy(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const u={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},l={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",u,t],["enter",l,t]],o=yt(o,e.slice(s+1,s+r+3)),o=yt(o,[["enter",f,t]]),o=yt(o,zi(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=yt(o,[["exit",f,t],e[a-2],e[a-1],["exit",l,t]]),o=yt(o,e.slice(a+1)),o=yt(o,[["exit",u,t]]),pt(e,s,e.length,o),e}function Py(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(h){return s?s._inactive?d(h):(a=r.parser.defined.includes(Nt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),u):n(h)}function u(h){return h===40?e.attempt(Iy,f,a?f:d)(h):h===91?e.attempt(Ty,f,a?l:d)(h):a?f(h):d(h)}function l(h){return e.attempt(Ay,f,d)(h)}function f(h){return t(h)}function d(h){return s._balanced=!0,n(h)}}function Dy(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Ie(d)?cr(e,s)(d):s(d)}function s(d){return d===41?f(d):yd(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return Ie(d)?cr(e,u)(d):f(d)}function o(d){return n(d)}function u(d){return d===34||d===39||d===40?vd(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function l(d){return Ie(d)?cr(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Ry(e,t,n){const r=this;return i;function i(o){return bd.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Nt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function My(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const Fy={name:"labelStartImage",resolveAll:Ia.resolveAll,tokenize:$y};function $y(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Ly={name:"labelStartLink",resolveAll:Ia.resolveAll,tokenize:Zy};function Zy(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const rs={name:"lineEnding",tokenize:Vy};function Vy(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ke(e,t,"linePrefix")}}const Hr={name:"thematicBreak",tokenize:By};function By(e,t,n){let r=0,i;return s;function s(l){return e.enter("thematicBreak"),a(l)}function a(l){return i=l,o(l)}function o(l){return l===i?(e.enter("thematicBreakSequence"),u(l)):r>=3&&(l===null||ue(l))?(e.exit("thematicBreak"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit("thematicBreakSequence"),ye(l)?ke(e,o,"whitespace")(l):o(l))}}const ot={continuation:{tokenize:Hy},exit:Gy,name:"list",tokenize:qy},Uy={partial:!0,tokenize:Ky},Jy={partial:!0,tokenize:Wy};function qy(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Ls(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Hr,n,l)(p):l(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(p)}return n(p)}function u(p){return Ls(p)&&++a<10?(e.consume(p),u):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),l(p)):n(p)}function l(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Nr,r.interrupt?n:f,e.attempt(Uy,h,d))}function f(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function d(p){return ye(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Hy(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Nr,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ke(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!ye(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Jy,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ke(e,e.attempt(ot,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function Wy(e,t,n){const r=this;return ke(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function Gy(e){e.exit(this.containerState.type)}function Ky(e,t,n){const r=this;return ke(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!ye(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Lo={name:"setextUnderline",resolveTo:Yy,tokenize:Xy};function Yy(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function Xy(e,t,n){const r=this;let i;return s;function s(l){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=l,a(l)):n(l)}function a(l){return e.enter("setextHeadingLineSequence"),o(l)}function o(l){return l===i?(e.consume(l),o):(e.exit("setextHeadingLineSequence"),ye(l)?ke(e,u,"lineSuffix")(l):u(l))}function u(l){return l===null||ue(l)?(e.exit("setextHeadingLine"),t(l)):n(l)}}const Qy={tokenize:eb};function eb(e){const t=this,n=e.attempt(Nr,r,e.attempt(this.parser.constructs.flowInitial,i,ke(e,e.attempt(this.parser.constructs.flow,i,e.attempt(sy,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const tb={resolveAll:kd()},nb=wd("string"),rb=wd("text");function wd(e){return{resolveAll:kd(e==="text"?ib:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(f){return l(f)?s(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),u}function u(f){return l(f)?(n.exit("data"),s(f)):(n.consume(f),u)}function l(f){if(f===null)return!0;const d=i[f];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function kd(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function ib(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,u;for(;s--;){const l=i[s];if(typeof l=="string"){for(a=l.length;l.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(l===-2)u=!0,o++;else if(l!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const l={type:n===e.length||u||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,["enter",l,t],["exit",l,t]),n+=2)}n++}return e}const sb={42:ot,43:ot,45:ot,48:ot,49:ot,50:ot,51:ot,52:ot,53:ot,54:ot,55:ot,56:ot,57:ot,62:hd},ab={91:cy},ob={[-2]:ns,[-1]:ns,32:ns},lb={35:gy,42:Hr,45:[Lo,Hr],60:vy,61:Lo,95:Hr,96:Fo,126:Fo},ub={38:gd,92:md},cb={[-5]:rs,[-4]:rs,[-3]:rs,33:Fy,38:gd,42:Zs,60:[Lx,Cy],91:Ly,92:[hy,md],93:Ia,95:Zs,96:Qx},db={null:[Zs,tb]},fb={null:[42,95]},pb={null:[]},hb=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:fb,contentInitial:ab,disable:pb,document:sb,flow:lb,flowInitial:ob,insideSpan:db,string:ub,text:cb},Symbol.toStringTag,{value:"Module"}));function mb(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const u={attempt:E(I),check:E(k),consume:_,enter:x,exit:D,interrupt:E(k,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let f=t.tokenize.call(l,u);return t.resolveAll&&s.push(t),l;function d(J){return a=yt(a,J),S(),a[a.length-1]!==null?[]:(L(t,0),l.events=zi(s,l.events,l),l.events)}function h(J,Z){return xb(p(J),Z)}function p(J){return gb(a,J)}function g(){const{_bufferIndex:J,_index:Z,line:V,column:z,offset:A}=r;return{_bufferIndex:J,_index:Z,line:V,column:z,offset:A}}function w(J){i[J.line]=J.column,C()}function S(){let J;for(;r._index<a.length;){const Z=a[r._index];if(typeof Z=="string")for(J=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===J&&r._bufferIndex<Z.length;)y(Z.charCodeAt(r._bufferIndex));else y(Z)}}function y(J){f=f(J)}function _(J){ue(J)?(r.line++,r.column=1,r.offset+=J===-3?2:1,C()):J!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=J}function x(J,Z){const V=Z||{};return V.type=J,V.start=g(),l.events.push(["enter",V,l]),o.push(V),V}function D(J){const Z=o.pop();return Z.end=g(),l.events.push(["exit",Z,l]),Z}function I(J,Z){L(J,Z.from)}function k(J,Z){Z.restore()}function E(J,Z){return V;function V(z,A,q){let F,N,R,m;return Array.isArray(z)?ne(z):"tokenize"in z?ne([z]):ee(z);function ee(de){return ae;function ae(le){const je=le!==null&&de[le],Le=le!==null&&de.null,Be=[...Array.isArray(je)?je:je?[je]:[],...Array.isArray(Le)?Le:Le?[Le]:[]];return ne(Be)(le)}}function ne(de){return F=de,N=0,de.length===0?q:v(de[N])}function v(de){return ae;function ae(le){return m=G(),R=de,de.partial||(l.currentConstruct=de),de.name&&l.parser.constructs.disable.null.includes(de.name)?fe():de.tokenize.call(Z?Object.assign(Object.create(l),Z):l,u,re,fe)(le)}}function re(de){return J(R,m),A}function fe(de){return m.restore(),++N<F.length?v(F[N]):q}}}function L(J,Z){J.resolveAll&&!s.includes(J)&&s.push(J),J.resolve&&pt(l.events,Z,l.events.length-Z,J.resolve(l.events.slice(Z),l)),J.resolveTo&&(l.events=J.resolveTo(l.events,l))}function G(){const J=g(),Z=l.previous,V=l.currentConstruct,z=l.events.length,A=Array.from(o);return{from:z,restore:q};function q(){r=J,l.previous=Z,l.currentConstruct=V,l.events.length=z,o=A,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function gb(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function xb(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
|
|
4
4
|
`;break}case-3:{a=`\r
|
|
5
5
|
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function yb(e){const r={constructs:fd([hb,...(e||{}).extensions||[]]),content:i(Ox),defined:[],document:i(Dx),flow:i(Qy),lazy:{},string:i(nb),text:i(rb)};return r;function i(s){return a;function a(o){return mb(r,s,o)}}}function bb(e){for(;!xd(e););return e}const Zo=/[\0\t\n\r]/g;function vb(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const u=[];let l,f,d,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(Zo.lastIndex=d,l=Zo.exec(s),h=l&&l.index!==void 0?l.index:s.length,p=s.charCodeAt(h),!l){t=s.slice(d);break}if(p===10&&d===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<h&&(u.push(s.slice(d,h)),e+=h-d),p){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}d=h+1}return o&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const wb=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function kb(e){return e.replace(wb,_b)}function _b(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return pd(n.slice(s?2:1),s?16:10)}return Ea(n)||e}const _d={}.hasOwnProperty;function Sb(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),jb(n)(bb(yb(n).document().write(vb()(e,t,!0))))}function jb(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(T),autolinkProtocol:G,autolinkEmail:G,atxHeading:s(Dt),blockQuote:s(Le),characterEscape:G,characterReference:G,codeFenced:s(Be),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(Be,a),codeText:s(mt,a),codeTextData:G,data:G,codeFlowValue:G,definition:s(wt),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(Me),hardBreakEscape:s(nn),hardBreakTrailing:s(nn),htmlFlow:s(Rt,a),htmlFlowData:G,htmlText:s(Rt,a),htmlTextData:G,image:s(j),label:a,link:s(T),listItem:s(Q),listItemValue:h,listOrdered:s(M,d),listUnordered:s(M),paragraph:s(K),reference:v,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Dt),strong:s(W),thematicBreak:s(he)},exit:{atxHeading:u(),atxHeadingSequence:I,autolink:u(),autolinkEmail:je,autolinkProtocol:le,blockQuote:u(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:fe,characterReferenceMarkerNumeric:fe,characterReferenceValue:de,characterReference:ae,codeFenced:u(S),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:C,codeIndented:u(y),codeText:u(A),codeTextData:C,data:C,definition:u(),definitionDestinationString:D,definitionLabelString:_,definitionTitleString:x,emphasis:u(),hardBreakEscape:u(Z),hardBreakTrailing:u(Z),htmlFlow:u(V),htmlFlowData:C,htmlText:u(z),htmlTextData:C,image:u(F),label:R,labelText:N,lineEnding:J,link:u(q),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:re,resourceDestinationString:m,resourceTitleString:ee,resource:ne,setextHeading:u(L),setextHeadingLineSequence:E,setextHeadingText:k,strong:u(),thematicBreak:u()}};Sd(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(P){let U={type:"root",children:[]};const se={stack:[U],tokenStack:[],config:t,enter:o,exit:l,buffer:a,resume:f,data:n},ge=[];let O=-1;for(;++O<P.length;)if(P[O][1].type==="listOrdered"||P[O][1].type==="listUnordered")if(P[O][0]==="enter")ge.push(O);else{const oe=ge.pop();O=i(P,oe,O)}for(O=-1;++O<P.length;){const oe=t[P[O][0]];_d.call(oe,P[O][1].type)&&oe[P[O][1].type].call(Object.assign({sliceSerialize:P[O][2].sliceSerialize},se),P[O][1])}if(se.tokenStack.length>0){const oe=se.tokenStack[se.tokenStack.length-1];(oe[1]||Vo).call(se,void 0,oe[0])}for(U.position={start:Bt(P.length>0?P[0][1].start:{line:1,column:1,offset:0}),end:Bt(P.length>0?P[P.length-2][1].end:{line:1,column:1,offset:0})},O=-1;++O<t.transforms.length;)U=t.transforms[O](U)||U;return U}function i(P,U,se){let ge=U-1,O=-1,oe=!1,be,Te,He,Ue;for(;++ge<=se;){const Xe=P[ge];switch(Xe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Xe[0]==="enter"?O++:O--,Ue=void 0;break}case"lineEndingBlank":{Xe[0]==="enter"&&(be&&!Ue&&!O&&!He&&(He=ge),Ue=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ue=void 0}if(!O&&Xe[0]==="enter"&&Xe[1].type==="listItemPrefix"||O===-1&&Xe[0]==="exit"&&(Xe[1].type==="listUnordered"||Xe[1].type==="listOrdered")){if(be){let Vt=ge;for(Te=void 0;Vt--;){const Mt=P[Vt];if(Mt[1].type==="lineEnding"||Mt[1].type==="lineEndingBlank"){if(Mt[0]==="exit")continue;Te&&(P[Te][1].type="lineEndingBlank",oe=!0),Mt[1].type="lineEnding",Te=Vt}else if(!(Mt[1].type==="linePrefix"||Mt[1].type==="blockQuotePrefix"||Mt[1].type==="blockQuotePrefixWhitespace"||Mt[1].type==="blockQuoteMarker"||Mt[1].type==="listItemIndent"))break}He&&(!Te||He<Te)&&(be._spread=!0),be.end=Object.assign({},Te?P[Te][1].start:Xe[1].end),P.splice(Te||ge,0,["exit",be,Xe[2]]),ge++,se++}if(Xe[1].type==="listItemPrefix"){const Vt={type:"listItem",_spread:!1,start:Object.assign({},Xe[1].start),end:void 0};be=Vt,P.splice(ge,0,["enter",Vt,Xe[2]]),ge++,se++,He=void 0,Ue=!0}}}return P[U][1]._spread=oe,se}function s(P,U){return se;function se(ge){o.call(this,P(ge),ge),U&&U.call(this,ge)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(P,U,se){this.stack[this.stack.length-1].children.push(P),this.stack.push(P),this.tokenStack.push([U,se||void 0]),P.position={start:Bt(U.start),end:void 0}}function u(P){return U;function U(se){P&&P.call(this,se),l.call(this,se)}}function l(P,U){const se=this.stack.pop(),ge=this.tokenStack.pop();if(ge)ge[0].type!==P.type&&(U?U.call(this,P,ge[0]):(ge[1]||Vo).call(this,P,ge[0]));else throw new Error("Cannot close `"+P.type+"` ("+ur({start:P.start,end:P.end})+"): it’s not open");se.position.end=Bt(P.end)}function f(){return Ca(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(P){if(this.data.expectingFirstListItemValue){const U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(P),10),this.data.expectingFirstListItemValue=void 0}}function p(){const P=this.resume(),U=this.stack[this.stack.length-1];U.lang=P}function g(){const P=this.resume(),U=this.stack[this.stack.length-1];U.meta=P}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const P=this.resume(),U=this.stack[this.stack.length-1];U.value=P.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const P=this.resume(),U=this.stack[this.stack.length-1];U.value=P.replace(/(\r?\n|\r)$/g,"")}function _(P){const U=this.resume(),se=this.stack[this.stack.length-1];se.label=U,se.identifier=Nt(this.sliceSerialize(P)).toLowerCase()}function x(){const P=this.resume(),U=this.stack[this.stack.length-1];U.title=P}function D(){const P=this.resume(),U=this.stack[this.stack.length-1];U.url=P}function I(P){const U=this.stack[this.stack.length-1];if(!U.depth){const se=this.sliceSerialize(P).length;U.depth=se}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function E(P){const U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(P).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function G(P){const se=this.stack[this.stack.length-1].children;let ge=se[se.length-1];(!ge||ge.type!=="text")&&(ge=ie(),ge.position={start:Bt(P.start),end:void 0},se.push(ge)),this.stack.push(ge)}function C(P){const U=this.stack.pop();U.value+=this.sliceSerialize(P),U.position.end=Bt(P.end)}function J(P){const U=this.stack[this.stack.length-1];if(this.data.atHardBreak){const se=U.children[U.children.length-1];se.position.end=Bt(P.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(G.call(this,P),C.call(this,P))}function Z(){this.data.atHardBreak=!0}function V(){const P=this.resume(),U=this.stack[this.stack.length-1];U.value=P}function z(){const P=this.resume(),U=this.stack[this.stack.length-1];U.value=P}function A(){const P=this.resume(),U=this.stack[this.stack.length-1];U.value=P}function q(){const P=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";P.type+="Reference",P.referenceType=U,delete P.url,delete P.title}else delete P.identifier,delete P.label;this.data.referenceType=void 0}function F(){const P=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";P.type+="Reference",P.referenceType=U,delete P.url,delete P.title}else delete P.identifier,delete P.label;this.data.referenceType=void 0}function N(P){const U=this.sliceSerialize(P),se=this.stack[this.stack.length-2];se.label=kb(U),se.identifier=Nt(U).toLowerCase()}function R(){const P=this.stack[this.stack.length-1],U=this.resume(),se=this.stack[this.stack.length-1];if(this.data.inReference=!0,se.type==="link"){const ge=P.children;se.children=ge}else se.alt=U}function m(){const P=this.resume(),U=this.stack[this.stack.length-1];U.url=P}function ee(){const P=this.resume(),U=this.stack[this.stack.length-1];U.title=P}function ne(){this.data.inReference=void 0}function v(){this.data.referenceType="collapsed"}function re(P){const U=this.resume(),se=this.stack[this.stack.length-1];se.label=U,se.identifier=Nt(this.sliceSerialize(P)).toLowerCase(),this.data.referenceType="full"}function fe(P){this.data.characterReferenceType=P.type}function de(P){const U=this.sliceSerialize(P),se=this.data.characterReferenceType;let ge;se?(ge=pd(U,se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ge=Ea(U);const O=this.stack[this.stack.length-1];O.value+=ge}function ae(P){const U=this.stack.pop();U.position.end=Bt(P.end)}function le(P){C.call(this,P);const U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(P)}function je(P){C.call(this,P);const U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(P)}function Le(){return{type:"blockquote",children:[]}}function Be(){return{type:"code",lang:null,meta:null,value:""}}function mt(){return{type:"inlineCode",value:""}}function wt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Me(){return{type:"emphasis",children:[]}}function Dt(){return{type:"heading",depth:0,children:[]}}function nn(){return{type:"break"}}function Rt(){return{type:"html",value:""}}function j(){return{type:"image",title:null,url:"",alt:null}}function T(){return{type:"link",title:null,url:"",children:[]}}function M(P){return{type:"list",ordered:P.type==="listOrdered",start:null,spread:P._spread,children:[]}}function Q(P){return{type:"listItem",spread:P._spread,checked:null,children:[]}}function K(){return{type:"paragraph",children:[]}}function W(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function he(){return{type:"thematicBreak"}}}function Bt(e){return{line:e.line,column:e.column,offset:e.offset}}function Sd(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Sd(e,r):Nb(e,r)}}function Nb(e,t){let n;for(n in t)if(_d.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Vo(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ur({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ur({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ur({start:t.start,end:t.end})+") is still open")}function Cb(e){const t=this;t.parser=n;function n(r){return Sb(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Eb(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Ib(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -96,4 +96,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
96
96
|
`;)t++;return!0}return!1}function l(N){if(f(N)){if(iu(e[t]))for(;t<e.length&&su(e[t]);)t++;return a(),!0}return!1}function f(N){o(!0);for(const R of N){const m=t+R.length;if(e.slice(t,m)===R)return t=m,!0}return!1}function d(N){return e[t]===N?(n+=e[t],t++,!0):!1}function h(N){return e[t]===N?(t++,!0):!1}function p(){return h("\\")}function g(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),h(","),!0):!1}function w(){if(e[t]==="{"){n+="{",t++,a(),h(",")&&a();let N=!0;for(;t<e.length&&e[t]!=="}";){let R;if(N?(R=!0,N=!1):(R=d(","),R||(n=St(n,",")),a()),g(),!(_()||E(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=Xn(n,","):A();break}a();const ee=d(":"),ne=t>=e.length;ee||(uu(e[t])||ne?n=St(n,":"):q()),s()||(ee||ne?n+="null":q())}return e[t]==="}"?(n+="}",t++):n=St(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,a(),h(",")&&a();let N=!0;for(;t<e.length&&e[t]!=="]";)if(N?N=!1:d(",")||(n=St(n,",")),g(),!s()){n=Xn(n,",");break}return e[t]==="]"?(n+="]",t++):n=St(n,"]"),!0}return!1}function y(){let N=!0,R=!0;for(;R;)N?N=!1:d(",")||(n=St(n,",")),R=s();R||(n=Xn(n,",")),n=`[
|
|
97
97
|
${n}
|
|
98
98
|
]`}function _(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,m=e[t]==="\\";if(m&&(t++,m=!0),Kr(e[t])){const ee=cu(e[t])?cu:du(e[t])?du:ra(e[t])?ra:Lp,ne=t,v=n.length;let re='"';for(t++;;){if(t>=e.length){const fe=G(t-1);return!N&&Vr(e.charAt(fe))?(t=ne,n=n.substring(0,v),_(!0)):(re=St(re,'"'),n+=re,!0)}if(t===R)return re=St(re,'"'),n+=re,!0;if(ee(e[t])){const fe=t,de=re.length;if(re+='"',t++,n+=re,a(!1),N||t>=e.length||Vr(e[t])||Kr(e[t])||an(e[t]))return x(),!0;const ae=G(fe-1),le=e.charAt(ae);if(le===",")return t=ne,n=n.substring(0,v),_(!1,ae);if(Vr(le))return t=ne,n=n.substring(0,v),_(!0);n=n.substring(0,v),t=fe+1,re=`${re.substring(0,de)}\\${re.substring(de)}`}else if(N&&lu(e[t])){if(e[t-1]===":"&&au.test(e.substring(ne+1,t+2)))for(;t<e.length&&ou.test(e[t]);)re+=e[t],t++;return re=St(re,'"'),n+=re,x(),!0}else if(e[t]==="\\"){const fe=e.charAt(t+1);if(cE[fe]!==void 0)re+=e.slice(t,t+2),t+=2;else if(fe==="u"){let ae=2;for(;ae<6&&tE(e[t+ae]);)ae++;ae===6?(re+=e.slice(t,t+6),t+=6):t+ae>=e.length?t=e.length:F()}else re+=fe,t+=2}else{const fe=e.charAt(t);fe==='"'&&e[t-1]!=="\\"?(re+=`\\${fe}`,t++):iE(fe)?(re+=uE[fe],t++):(nE(fe)||Z(fe),re+=fe,t++)}m&&p()}}return!1}function x(){let N=!1;for(a();e[t]==="+";){N=!0,t++,a(),n=Xn(n,'"',!0);const R=n.length;_()?n=oE(n,R,1):n=St(n,'"')}return N}function D(){const N=t;if(e[t]==="-"){if(t++,C())return J(N),!0;if(!an(e[t]))return t=N,!1}for(;an(e[t]);)t++;if(e[t]==="."){if(t++,C())return J(N),!0;if(!an(e[t]))return t=N,!1;for(;an(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,C())return J(N),!0;if(!an(e[t]))return t=N,!1;for(;an(e[t]);)t++}if(!C())return t=N,!1;if(t>N){const R=e.slice(N,t),m=/^0\d/.test(R);return n+=m?`"${R}"`:R,!0}return!1}function I(){return k("true","true")||k("false","false")||k("null","null")||k("True","true")||k("False","false")||k("None","null")}function k(N,R){return e.slice(t,t+N.length)===N?(n+=R,t+=N.length,!0):!1}function E(N){const R=t;if(iu(e[t])){for(;t<e.length&&su(e[t]);)t++;let m=t;for(;cn(e,m);)m++;if(e[m]==="(")return t=m+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!lu(e[t])&&!Kr(e[t])&&(!N||e[t]!==":");)t++;if(e[t-1]===":"&&au.test(e.substring(R,t+2)))for(;t<e.length&&ou.test(e[t]);)t++;if(t>R){for(;cn(e,t-1)&&t>0;)t--;const m=e.slice(R,t);return n+=m==="undefined"?"null":JSON.stringify(m),e[t]==='"'&&t++,!0}}function L(){if(e[t]==="/"){const N=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(N,t)),!0}}function G(N){let R=N;for(;R>0&&cn(e,R);)R--;return R}function C(){return t>=e.length||Vr(e[t])||cn(e,t)}function J(N){n+=`${e.slice(N,t)}0`}function Z(N){throw new jn(`Invalid character ${JSON.stringify(N)}`,t)}function V(){throw new jn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function z(){throw new jn("Unexpected end of json string",e.length)}function A(){throw new jn("Object key expected",t)}function q(){throw new jn("Colon expected",t)}function F(){const N=e.slice(t,t+6);throw new jn(`Invalid unicode character "${N}"`,t)}}function dE(e,t){return e[t]==="*"&&e[t+1]==="/"}function fE({json:e,context:t,scope:n}){const[r,i]=b.useState(!1),[s,a]=b.useState(null),o=b.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return fu(e)}catch{}const y=`{${e}}`;try{return JSON.parse(y),y}catch{}try{return fu(y)}catch{return null}},[e]),u=b.useMemo(()=>Op(o||e),[o,e]),l=qe(y=>y.activeTab),f=qe(y=>y.documents),d=qe(y=>(y.acceptedApplyIds||[]).includes(u)),h=qe(y=>y.setPendingDiff),p=qe(y=>y.createDocument),g=qe(y=>y.openDocument),w=b.useCallback(()=>{if(o){a(null);try{if(l){const y=f.find(k=>k.name===l),_=(y==null?void 0:y.text)||"";if(n==="templates")try{const k=JSON.parse(_),E=JSON.parse(o);if(Array.isArray(E.templates)){k.props||(k.props={}),k.props.templates=zp(k.props.templates||[],E.templates);const L=JSON.stringify(k,null,2);h(l,_,L,u);return}}catch{}const x=t==null?void 0:t[0],{original:D,modified:I}=Pp(_,o,x);h(l,D,I,u)}else{const y=`ai-generated-${Date.now()}`;p(y,o),g(y)}}catch(y){a(y instanceof Error?y.message:"Merge failed")}}},[o,l,f,h,p,g,t,n,u]),S=b.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return c.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx(xe,{variant:"secondary",size:"sm",onClick:w,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),c.jsx(xe,{variant:"ghost",size:"sm",onClick:S,children:r?c.jsx(Kt,{className:"h-3.5 w-3.5"}):c.jsx(aa,{className:"h-3.5 w-3.5"})})]}),s&&c.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function pE({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,u]=b.useState(null),[l,f]=b.useState(""),[d,h]=b.useState(null),p=b.useRef(null),g=(t==null?void 0:t.title)||"New Chat",w=g.length>24?g.slice(0,24)+"...":g;b.useEffect(()=>{o&&requestAnimationFrame(()=>{var E;return(E=p.current)==null?void 0:E.focus()})},[o]);const S=b.useCallback((E,L)=>{L.stopPropagation(),L.preventDefault(),u(E.id),f(E.title),h(null)},[]),y=b.useCallback(()=>{o&&l.trim()&&a(o,l.trim()),u(null),f("")},[o,l,a]),_=b.useCallback(()=>{u(null),f("")},[]),x=b.useCallback(E=>{E.stopPropagation(),E.key==="Enter"?(E.preventDefault(),y()):E.key==="Escape"&&(E.preventDefault(),_())},[y,_]),D=b.useCallback((E,L)=>{L.stopPropagation(),L.preventDefault(),h(E),u(null)},[]),I=b.useCallback(E=>{E.stopPropagation(),E.preventDefault(),d&&(s(d),h(null))},[d,s]),k=b.useCallback(E=>{E.stopPropagation(),E.preventDefault(),h(null)},[]);return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(Gc,{onOpenChange:E=>{E||(u(null),h(null))},children:[c.jsx(Kc,{asChild:!0,disabled:n,children:c.jsxs("button",{className:"flex items-center gap-1 text-sm font-semibold tracking-tight hover:text-foreground/80 transition-colors max-w-[180px] cursor-pointer",children:[c.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),c.jsx("span",{className:"truncate",children:w}),c.jsx(pn,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),c.jsxs(va,{align:"start",className:"w-64",children:[e.map(E=>{const L=o===E.id;return d===E.id?c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[c.jsx("span",{className:"text-red-400 text-xs flex-1 truncate",children:"Delete this thread?"}),c.jsx("button",{className:"shrink-0 text-red-400 hover:text-red-300 transition-colors cursor-pointer",onClick:I,children:c.jsx(Kt,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:k,children:c.jsx(hn,{className:"h-3.5 w-3.5"})})]},E.id):L?c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:C=>C.stopPropagation(),onPointerDown:C=>C.stopPropagation(),children:[c.jsx("input",{ref:p,type:"text",value:l,onChange:C=>f(C.target.value),onKeyDown:x,onBlur:y,className:"flex-1 min-w-0 text-sm rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),c.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),y()},children:c.jsx(Kt,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),_()},children:c.jsx(hn,{className:"h-3.5 w-3.5"})})]},E.id):c.jsxs(Wt,{onSelect:()=>r(E.id),className:`group ${E.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[c.jsx("span",{className:"truncate flex-1",children:E.title.length>30?E.title.slice(0,30)+"...":E.title}),c.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[c.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:C=>S(E,C),children:c.jsx(Mh,{className:"h-3 w-3"})}),e.length>1&&c.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:C=>D(E.id,C),children:c.jsx(oa,{className:"h-3 w-3"})})]})]},E.id)}),c.jsx(ai,{}),c.jsxs(Wt,{onSelect:E=>{E.preventDefault();const L=i();L&&(u(L),f(xa()),h(null))},children:[c.jsx(Xr,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),c.jsx(xe,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:c.jsx(Xr,{className:"h-3.5 w-3.5"})})]})}const Zp=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),hE=Array.from(Zp).join(","),mE=20*1024*1024,pu=10;function gE(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t({type:"file",mediaType:e.type,filename:e.name,url:r.result}),r.onerror=n,r.readAsDataURL(e)})}function hu(e){return Array.from(e).filter(t=>Zp.has(t.type)&&t.size<=mE)}function Vp(e){return e.startsWith("image/")}function mu(){var U,se,ge;const e=Se(O=>O.contextAttachments),t=Se(O=>O.addContext),n=Se(O=>O.removeContext),r=Se(O=>O.scope),i=Se(O=>O.setScope),s=Se(O=>O.model),a=Se(O=>O.setModel),o=Se(O=>O.openChat),u=Se(O=>O.closeChat),l=Se(O=>O.threads),f=Se(O=>O.activeThreadId),d=Se(O=>O.createThread),h=Se(O=>O.deleteThread),p=Se(O=>O.switchThread),g=Se(O=>O.updateThreadMessages),w=Se(O=>O.updateThreadTitle),S=Se(O=>O.deleteThreadsForDocument),y=qe(O=>O.activeTab),_=qe(O=>O.documents),{messages:x,sendMessage:D,status:I,error:k,setMessages:E,stop:L,getMessageContext:G,getMessageScope:C}=BC(),[J,Z]=b.useState(""),[V,z]=b.useState([]),[A,q]=b.useState(!1),[F,N]=b.useState(!1),R=b.useRef(null),m=b.useRef(null),ee=b.useRef(null),ne=b.useCallback(async O=>{const oe=hu(O);if(oe.length===0)return;const be=await Promise.all(oe.map(gE));z(Te=>{const He=[...Te,...be];return He.length>pu?He.slice(0,pu):He})},[]),v=b.useCallback(O=>{z(oe=>oe.filter((be,Te)=>Te!==O))},[]),re=b.useCallback(O=>{var be;const oe=(be=O.clipboardData)==null?void 0:be.files;if(oe&&oe.length>0){const Te=hu(oe);Te.length>0&&(O.preventDefault(),ne(Te))}},[ne]),fe=b.useCallback(O=>{var be;O.preventDefault(),N(!1);const oe=(be=O.dataTransfer)==null?void 0:be.files;oe&&oe.length>0&&ne(Array.from(oe))},[ne]),de=b.useCallback(O=>{O.preventDefault(),N(!0)},[]),ae=b.useCallback(()=>N(!1),[]),le=y?f[y]:void 0,je=le?l[le]:void 0,Le=b.useMemo(()=>y?Object.values(l).filter(O=>O.documentName===y).sort((O,oe)=>oe.updatedAt-O.updatedAt):[],[l,y]);b.useEffect(()=>{y&&Le.length===0&&d(y)},[y,Le.length,d]);const Be=b.useRef(l);Be.current=l,b.useEffect(()=>{const O=new Set(_.map(be=>be.name)),oe=new Set;for(const be of Object.values(Be.current))!O.has(be.documentName)&&be.documentName!=="__migrated__"&&oe.add(be.documentName);for(const be of oe)S(be)},[_,S]);const mt=b.useRef(null);b.useEffect(()=>{mt.current!==le&&(mt.current=le,E((je==null?void 0:je.messages)??[]))},[le,je,E]),b.useEffect(()=>{var O;(O=R.current)==null||O.scrollIntoView({behavior:"smooth"})},[x,I]),b.useEffect(()=>{const O=oe=>{var He;const{documentName:be,selection:Te}=oe.detail;t({...Te,documentName:be}),o(),(He=m.current)==null||He.focus()};return window.addEventListener("monaco-selection-to-ai",O),()=>window.removeEventListener("monaco-selection-to-ai",O)},[t,o]);const wt=I==="streaming",Me=I==="submitted"||wt,Dt=b.useCallback(O=>{O.preventDefault(),!(!J.trim()&&V.length===0||Me)&&(D(J,V.length>0?V:void 0),Z(""),z([]))},[J,V,Me,D]),nn=b.useCallback(O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),Dt(O))},[Dt]),Rt=b.useCallback(()=>{x.length!==0&&q(!0)},[x.length]),j=b.useCallback(()=>{q(!1),E([]),le&&(g(le,[]),w(le,xa()))},[E,le,g,w]),[T,M]=b.useState(null),Q=b.useCallback(O=>{M(O)},[]),K=b.useCallback(()=>{var He,Ue;if(!T)return;const O=x.findIndex(Xe=>Xe.id===T);if(O===-1){M(null);return}const oe=x[O],be=new Set([O]);oe.role==="user"&&((He=x[O+1])==null?void 0:He.role)==="assistant"?be.add(O+1):oe.role==="assistant"&&O>0&&((Ue=x[O-1])==null?void 0:Ue.role)==="user"&&be.add(O-1);const Te=x.filter((Xe,Vt)=>!be.has(Vt));E(Te),le&&g(le,Te),M(null)},[T,x,E,le,g]),W=b.useCallback(O=>{if(!Me){if(Le.length<=1){Rt();return}h(O)}},[Me,Le.length,Rt,h]),ie=b.useCallback(()=>{if(!(!y||Me))return d(y)},[y,Me,d]),he=b.useCallback(O=>{Me||O===le||p(O)},[Me,le,p]),P=b.useCallback((O,oe)=>{w(O,oe)},[w]);return c.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[c.jsx(pE,{threads:Le,activeThread:je,disabled:Me,onSwitch:he,onCreate:ie,onDelete:W,onRename:P}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(xe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:Rt,disabled:Me||x.length===0,children:"Clear"}),c.jsx(xe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:u,title:"Close chat",children:c.jsx(hn,{className:"h-3.5 w-3.5"})})]})]}),c.jsx(fn,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:c.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[x.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[c.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:c.jsx(to,{className:"h-5 w-5 text-primary"})}),c.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-1",children:"JSON Assistant"}),c.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[200px] mb-4",children:"Generate, edit, and refine your JSON document definitions with AI."}),c.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5",children:[c.jsx(Ds,{shortcut:"mod+k"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),x.map((O,oe)=>{let be;if(O.role==="user"){const Ue=G(O.id);Ue&&Ue.length>0&&(be=Ue)}else if(O.role==="assistant"){for(let Ue=oe-1;Ue>=0;Ue--)if(x[Ue].role==="user"){be=G(x[Ue].id);break}}const Te=wt&&oe===x.length-1&&O.role==="assistant",He=O.role==="user"?C(O.id):void 0;return c.jsx(xE,{msg:O,isStreaming:Te,context:be,scope:He,onDelete:Me?void 0:Q},O.id)}),Me&&((U=x[x.length-1])==null?void 0:U.role)!=="assistant"&&c.jsx("div",{className:"flex justify-start",children:c.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(Fh,{className:"h-3.5 w-3.5 animate-spin text-primary"}),c.jsx("span",{children:"Thinking..."})]})})}),k&&!Me&&c.jsx("div",{className:"flex justify-start",children:c.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:k.message||"Something went wrong"})}),c.jsx("div",{ref:R})]})}),c.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${F?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:fe,onDragOver:de,onDragLeave:ae,children:[e.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((O,oe)=>c.jsx(Rp,{context:O,onRemove:()=>n(oe)},oe))}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(vE,{model:s,setModel:a}),bt==="pptx"&&y&&c.jsx(kE,{scope:r,setScope:i,docSize:((ge=(se=_.find(O=>O.name===y))==null?void 0:se.text)==null?void 0:ge.length)??0})]}),V.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.map((O,oe)=>c.jsxs("div",{className:"relative group",children:[Vp(O.mediaType)?c.jsx("img",{src:O.url,alt:O.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):c.jsxs("div",{className:"h-14 px-2.5 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/60 max-w-[140px]",children:[c.jsx(_s,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-xs truncate text-muted-foreground",children:O.filename||"file"})]}),c.jsx("button",{type:"button",onClick:()=>v(oe),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:c.jsx(hn,{className:"h-3 w-3"})})]},oe))}),c.jsxs("form",{onSubmit:Dt,className:"flex items-end gap-2",children:[c.jsx("input",{ref:ee,type:"file",accept:hE,multiple:!0,className:"hidden",onChange:O=>{O.target.files&&ne(Array.from(O.target.files)),O.target.value=""}}),c.jsx(xe,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var O;return(O=ee.current)==null?void 0:O.click()},title:"Attach file",children:c.jsx(_s,{className:"h-4 w-4"})}),c.jsx("textarea",{ref:m,value:J,onChange:O=>{Z(O.target.value);const oe=O.target;oe.style.height="auto",oe.style.height=`${Math.min(oe.scrollHeight,128)}px`},onKeyDown:nn,onPaste:re,placeholder:e.length>0?"Describe how to edit the selection...":r==="slides"?"Add, edit, or remove slides...":r==="templates"?"Edit template layouts and placeholders...":"Ask AI to generate or edit JSON...",className:"flex-1 min-h-[36px] max-h-32 resize-none overflow-y-auto rounded-lg border border-border/60 bg-background px-3 py-1.5 text-sm placeholder:text-muted-foreground placeholder:whitespace-nowrap placeholder:overflow-hidden placeholder:text-ellipsis focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:border-primary/50 transition-shadow",rows:1}),Me?c.jsx(xe,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:L,title:"Stop generating",children:c.jsx($h,{className:"h-4 w-4"})}):c.jsx(xe,{type:"submit",size:"icon",disabled:!J.trim()&&V.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:c.jsx(to,{className:"h-4 w-4"})})]})]}),c.jsx(Lt,{open:A,onOpenChange:q,children:c.jsxs(zt,{className:"max-w-sm",children:[c.jsxs(mn,{children:[c.jsx(gn,{children:"Clear thread"}),c.jsx(Dn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),c.jsxs(pr,{children:[c.jsx(po,{asChild:!0,children:c.jsx(xe,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(xe,{variant:"destructive",size:"sm",onClick:j,children:"Clear"})]})]})}),c.jsx(Lt,{open:T!==null,onOpenChange:O=>{O||M(null)},children:c.jsxs(zt,{className:"max-w-sm",children:[c.jsxs(mn,{children:[c.jsx(gn,{children:"Delete message"}),c.jsx(Dn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),c.jsxs(pr,{children:[c.jsx(po,{asChild:!0,children:c.jsx(xe,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(xe,{variant:"destructive",size:"sm",onClick:K,children:"Delete"})]})]})})]})}const xE=b.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var u,l;const a=((u=t.parts)==null?void 0:u.filter(f=>f.type==="text").map(f=>f.text).join(""))||"",o=((l=t.parts)==null?void 0:l.filter(f=>f.type==="file"))||[];return c.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:c.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?c.jsxs("div",{children:[o.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((f,d)=>Vp(f.mediaType)?c.jsx("img",{src:f.url,alt:f.filename||"image",className:"h-20 max-w-[160px] rounded object-cover"},d):c.jsxs("div",{className:"flex items-center gap-1.5 rounded bg-primary-foreground/20 px-2 py-1",children:[c.jsx(_s,{className:"h-3 w-3 shrink-0"}),c.jsx("span",{className:"text-xs truncate max-w-[120px]",children:f.filename||"file"})]},d))}),r&&r.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((f,d)=>c.jsx(Rp,{context:f,variant:"sent"},d))}),a&&c.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&c.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):c.jsx(yE,{text:a,isStreaming:n,context:r,scope:i}),s&&!n&&c.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity mt-1",children:c.jsx("button",{type:"button",onClick:()=>s(t.id),className:`p-0.5 rounded cursor-pointer ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:c.jsx(oa,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function yE({text:e,isStreaming:t,context:n,scope:r}){return t?c.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1",children:c.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm m-0 p-0 bg-transparent border-none",children:e})}):c.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_h1]:my-2 [&_h2]:my-1.5 [&_h3]:my-1",children:c.jsx(qv,{remarkPlugins:[sk],components:{pre:({children:i})=>c.jsx(c.Fragment,{children:i}),code:({className:i,children:s})=>{const a=i==null?void 0:i.startsWith("language-"),o=(i==null?void 0:i.replace("language-",""))||"",u=String(s).replace(/\n$/,"");if(!a)return c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs font-mono",children:s});const l=o==="json"||o==="jsonc";return c.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[c.jsx("span",{className:"font-mono",children:o||"code"}),!l&&c.jsx(_E,{text:u})]}),c.jsx("pre",{className:"p-3 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto m-0",children:c.jsx("code",{children:u})}),l&&c.jsx(fE,{json:u,context:n,scope:r})]})}},children:e})})}const bE=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function vE({model:e,setModel:t}){return c.jsxs(ma,{value:e,onValueChange:n=>t(n),children:[c.jsx(Ei,{className:"h-6 w-auto gap-1 border-none bg-muted/40 px-2 py-0 text-[10px] shadow-none focus:ring-0",children:c.jsx(ga,{})}),c.jsx(Ii,{children:bE.map(n=>c.jsx(hr,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const gu={global:"AI sees and edits the entire document",slides:"AI sees and edits only slides — templates stay unchanged",templates:"AI sees and edits only template layouts — slides stay unchanged"},wE=1e5;function kE({scope:e,setScope:t,docSize:n}){return c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Scope"}),c.jsx("div",{className:"flex items-center bg-muted/40 rounded-md p-0.5 gap-px",children:Object.keys(gu).map(r=>c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),c.jsx(Ye,{side:"top",className:"text-xs max-w-[200px]",children:gu[r]})]},r))})]}),e==="global"&&n>wE&&c.jsxs("div",{className:"text-[10px] text-amber-500 flex items-center gap-1",children:[c.jsx(sc,{className:"h-3 w-3 shrink-0"}),c.jsxs("span",{children:["Large doc — switch to"," ",c.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-amber-400",children:"slides"})," ","or"," ",c.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-amber-400",children:"templates"})]})]})]})}function _E({text:e}){const[t,n]=b.useState(!1),r=b.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return c.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function SE({discoveryData:e}){const t=Mc(),n=Vm(),r=Se(L=>L.chatOpen),i=Se(L=>L.toggleChat),[s,a]=b.useState(()=>{try{const L=localStorage.getItem("dev-env.sidebar-open");return L?L==="true":!0}catch{return!0}}),[o,u]=b.useState(()=>{try{const L=localStorage.getItem("dev-env.preview-open");return L?L==="true":!0}catch{return!0}}),[l,f]=b.useState("editor"),[d,h]=b.useState(!1),p=120,[g,w]=b.useState(!s),[S,y]=b.useState(!1);b.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),b.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=b.useRef(n);b.useEffect(()=>{n&&!_.current&&s&&(y(!0),setTimeout(()=>{a(!1),w(!0)},p)),!n&&_.current&&!s&&(y(!0),setTimeout(()=>{a(!0),w(!1)},p)),_.current=n},[n,s]);const x=b.useCallback(()=>{if(t){h(L=>!L);return}y(!0),setTimeout(()=>{a(L=>!L),w(L=>!L)},p)},[t]),D=b.useCallback(()=>u(L=>!L),[]),I=b.useRef(i),k=b.useRef(x),E=b.useRef(D);return b.useEffect(()=>{I.current=i}),b.useEffect(()=>{k.current=x}),b.useEffect(()=>{E.current=D}),b.useEffect(()=>{const L=G=>{(G.metaKey||G.ctrlKey)&&(G.code==="KeyB"&&!G.shiftKey&&(G.preventDefault(),k.current()),G.code==="KeyJ"&&G.shiftKey&&(G.preventDefault(),G.stopPropagation(),I.current()),G.code==="KeyP"&&G.shiftKey&&(G.preventDefault(),E.current()))};return window.addEventListener("keydown",L,!0),()=>window.removeEventListener("keydown",L,!0)},[]),t?c.jsx(ru,{children:c.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[c.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-sidebar shrink-0",children:[c.jsxs(Dc,{open:d,onOpenChange:h,children:[c.jsx(Mm,{asChild:!0,children:c.jsx(xe,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:c.jsx(ic,{className:"h-4 w-4"})})}),c.jsx(ya,{side:"left",className:"p-0 w-72",children:c.jsx(go,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),c.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:[{key:"editor",icon:ac,label:"Editor"},{key:"preview",icon:Yr,label:"Preview"},{key:"chat",icon:oc,label:"Chat"}].map(({key:L,icon:G,label:C})=>c.jsxs(xe,{variant:l===L?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(L),children:[c.jsx(G,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"hidden xs:inline",children:C})]},L))})]}),l!=="chat"&&c.jsx(wo,{previewOpen:o,onTogglePreview:D}),c.jsxs("div",{className:"flex-1 min-h-0",children:[l==="editor"&&c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(xo,{})}),l==="preview"&&c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(yo,{})}),l==="chat"&&c.jsx(mu,{})]})]})}):c.jsx(ru,{children:c.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[c.jsx("div",{className:B("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-[280ms] ease-[cubic-bezier(0.22,1,0.36,1)]",s?"w-64":"w-10"),onTransitionEnd:L=>{L.propertyName==="width"&&L.target===L.currentTarget&&y(!1)},children:c.jsx(go,{discoveryData:e,onToggleSidebar:x,isCollapsed:g,isAnimating:S})}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[c.jsx(wo,{previewOpen:o,onTogglePreview:D}),c.jsxs(Ng,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[c.jsx(Yi,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(xo,{})})}),o&&c.jsxs(c.Fragment,{children:[c.jsx(bo,{withHandle:!0}),c.jsx(Yi,{defaultSize:50,minSize:20,id:"preview",order:2,children:c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(yo,{})})})]}),r&&c.jsxs(c.Fragment,{children:[c.jsx(bo,{withHandle:!0}),c.jsx(Yi,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:c.jsx(mu,{})})]})]})]})]})})}function jE(){const[e,t]=b.useState(null),[n,r]=b.useState(!0),[i,s]=b.useState(null),a=b.useCallback(async()=>{r(!0),s(null);try{const o=await fetch("/api/discovery/all");if(!o.ok)throw new Error(`Discovery failed: ${o.statusText}`);const u=await o.json();if(!u.success)throw new Error(u.error||"Discovery failed");t(u.data)}catch(o){console.error("Discovery error:",o),s(o instanceof Error?o.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return b.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function NE(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[i,s]=b.useState(0);return{loadPlugins:b.useCallback(async()=>{t(!0),r(null);try{const o=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!o.ok)throw new Error(`Failed to load plugins: ${o.statusText}`);const u=await o.json();if(!u.success)throw new Error(u.error||"Failed to load plugins");return s(u.data.loaded),!0}catch(o){return console.error("Plugin loading error:",o),r(o instanceof Error?o.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function CE(){const{data:e,loading:t,error:n}=jE(),{loadPlugins:r}=NE(),i=$t(s=>s.applyPluginsWithValidation);return b.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=$t.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),c.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):c.jsx(Zh,{children:c.jsx(Vh,{children:c.jsx(Bh,{children:c.jsx(Uh,{children:c.jsx(Sm,{children:c.jsx($c,{children:c.jsx("section",{className:"flex h-screen w-full flex-col",children:c.jsx("div",{className:"grow overflow-hidden",children:c.jsx(SE,{discoveryData:e})})})})})})})})})}const ME=Object.freeze(Object.defineProperty({__proto__:null,HomePage:CE},Symbol.toStringTag,{value:"Module"}));export{ln as B,Lt as D,ME as H,Dg as P,lr as S,zn as T,Wc as a,Pc as b,zt as c,mn as d,gn as e,zg as u};
|
|
99
|
-
//# sourceMappingURL=HomePage-
|
|
99
|
+
//# sourceMappingURL=HomePage-D9PVR0H8.js.map
|