@blinkk/root-cms 3.1.6 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +1 -1
- package/dist/{chunk-U4TMO2LI.js → chunk-NIBAHWGP.js} +2 -2
- package/dist/plugin.js +1 -1
- package/dist/ui/AIPage-XPE7F5AF.js +1 -0
- package/dist/ui/AssetsPage-C3ZEENBO.js +1 -0
- package/dist/ui/CollectionPage-VQ4WJHJB.js +1 -0
- package/dist/ui/ComparePage-VKOXKID4.js +1 -0
- package/dist/ui/{DataPage-YEIS7HBN.js → DataPage-JXZ2Z3DG.js} +1 -1
- package/dist/ui/{DataSourcePage-VD6YBDRW.js → DataSourcePage-X3NSUOTP.js} +1 -1
- package/dist/ui/{DocTranslationsPage-6XLREBPQ.js → DocTranslationsPage-AJGT52XQ.js} +1 -1
- package/dist/ui/DocumentPage-ZFD2KE3A.js +1 -0
- package/dist/ui/{EditDataSourcePage-E4PSKSG3.js → EditDataSourcePage-EMK3F6HD.js} +1 -1
- package/dist/ui/EditReleasePage-3IAERDSH.js +1 -0
- package/dist/ui/EmbeddedAIPage-2W5F7QFL.js +1 -0
- package/dist/ui/EmbeddedDocumentPage-BESFW2YZ.js +1 -0
- package/dist/ui/{ImageEditorDialog-YDKOGVJV.js → ImageEditorDialog-JDXMU2FC.js} +1 -1
- package/dist/ui/LogsPage-KCD4XZ2N.js +1 -0
- package/dist/ui/{NewDataSourcePage-NJJDHGPX.js → NewDataSourcePage-EZDU7HGA.js} +1 -1
- package/dist/ui/NewReleasePage-FFTRUIP4.js +1 -0
- package/dist/ui/{NotFoundPage-CA7XVXUO.js → NotFoundPage-JGG2NTUE.js} +1 -1
- package/dist/ui/{ProjectPage-XUBJSCWB.js → ProjectPage-HT5JKR33.js} +1 -1
- package/dist/ui/ReleasePage-OYWLGV4D.js +1 -0
- package/dist/ui/{ReleasesPage-OY7OKC3C.js → ReleasesPage-XEII7FBC.js} +1 -1
- package/dist/ui/{SettingsPage-5EQUY52A.js → SettingsPage-7GIBTPB5.js} +1 -1
- package/dist/ui/SidebarToolsPage-GQYTZDAC.js +1 -0
- package/dist/ui/TaskPage-SNDDYDZY.js +1 -0
- package/dist/ui/TasksPage-CEVWOY67.js +1 -0
- package/dist/ui/{TranslationsArbPage-PG5USRYB.js → TranslationsArbPage-ADRLLAIW.js} +1 -1
- package/dist/ui/{TranslationsEditPage-GV3ZJXTY.js → TranslationsEditPage-PSKA7K44.js} +1 -1
- package/dist/ui/{TranslationsPage-3AKSMCNF.js → TranslationsPage-NGCLDSK7.js} +2 -2
- package/dist/ui/{chunk-75NMQ3LW.js → chunk-3YBRRPAN.js} +1 -1
- package/dist/ui/{chunk-QLIIVG5Q.js → chunk-5F5XJPKD.js} +1 -1
- package/dist/ui/{chunk-ST6QNIWT.js → chunk-6ZVMJXLE.js} +7 -7
- package/dist/ui/chunk-7OU4ERTS.js +87 -0
- package/dist/ui/chunk-A2JZYRE3.js +1 -0
- package/dist/ui/chunk-B74M7NEV.js +1 -0
- package/dist/ui/{chunk-UOKVF54Y.js → chunk-BLHXP3SR.js} +1 -1
- package/dist/ui/{chunk-UJX25CXD.js → chunk-BOIY4J2R.js} +1 -1
- package/dist/ui/chunk-CEWU5VSJ.js +1 -0
- package/dist/ui/{chunk-34W6H4YG.js → chunk-CXMVFNX3.js} +1 -1
- package/dist/ui/{chunk-F7RQT4XN.js → chunk-EET5AS64.js} +1 -1
- package/dist/ui/{chunk-WASID5UU.js → chunk-GJ7ES2LA.js} +1 -1
- package/dist/ui/{chunk-2RRM4HEQ.js → chunk-H5JL376P.js} +1 -1
- package/dist/ui/{chunk-H37RXS4R.js → chunk-HKCOKHA2.js} +1 -1
- package/dist/ui/{chunk-QGAPMQEJ.js → chunk-HUYP5U4K.js} +1 -1
- package/dist/ui/{chunk-NCZD5IWS.js → chunk-HWON6MV4.js} +1 -1
- package/dist/ui/{chunk-HXSB6YB2.js → chunk-I3H465Z6.js} +1 -1
- package/dist/ui/{chunk-535JU7FU.js → chunk-ILFWJKSS.js} +1 -1
- package/dist/ui/chunk-K7IG7PO2.js +1 -0
- package/dist/ui/{chunk-LAXQZPE3.js → chunk-LKTN7YVM.js} +1 -1
- package/dist/ui/{chunk-PLYSJ7W5.js → chunk-LS2JH5QF.js} +1 -1
- package/dist/ui/{chunk-QFDU6FXP.js → chunk-MALK5YEV.js} +1 -1
- package/dist/ui/{chunk-YP6ZH3MT.js → chunk-MFRPYPCF.js} +1 -1
- package/dist/ui/{chunk-RB23LLKL.js → chunk-OKNBFTYR.js} +1 -1
- package/dist/ui/{chunk-A7IZAHBZ.js → chunk-P2RVKNG4.js} +1 -1
- package/dist/ui/{chunk-JBLSUM6W.js → chunk-P57AFOMR.js} +1 -1
- package/dist/ui/{chunk-HV3JJ5UT.js → chunk-PLTI4NG7.js} +1 -1
- package/dist/ui/chunk-PY4JH5SN.js +1 -0
- package/dist/ui/{chunk-44ZU5WMI.js → chunk-SBAY52SC.js} +1 -1
- package/dist/ui/{chunk-Y5EOMMNI.js → chunk-TCKR2BL4.js} +1 -1
- package/dist/ui/{chunk-C5FRMXDS.js → chunk-TCRDGNM4.js} +1 -1
- package/dist/ui/chunk-TCWN5YRW.js +1 -0
- package/dist/ui/{chunk-U7LSFUHT.js → chunk-TZWCCNSA.js} +1 -1
- package/dist/ui/{chunk-2PTLQRTU.js → chunk-U5OXKKBN.js} +1 -1
- package/dist/ui/{chunk-O7ESOZQO.js → chunk-VZGDXWRK.js} +1 -1
- package/dist/ui/{chunk-3LEYSXZP.js → chunk-X3VDQDHP.js} +1 -1
- package/dist/ui/chunk-XBYMUPZF.js +19 -0
- package/dist/ui/{chunk-QRAFYIAW.js → chunk-XYXL5HSZ.js} +1 -1
- package/dist/ui/chunk-Y7RYSRP7.js +7 -0
- package/dist/ui/{chunk-WRA24P66.js.LEGAL.txt → chunk-Y7RYSRP7.js.LEGAL.txt} +1 -0
- package/dist/ui/chunk-YIKHJONY.js +1 -0
- package/dist/ui/{chunk-UCYWQEAS.js → chunk-ZD3ORGA6.js} +1 -1
- package/dist/ui/{chunk-YBHFGQ3Z.js → chunk-ZQDUWURP.js} +1 -1
- package/dist/ui/{chunk-PIJ3E47R.js → chunk-ZYSR5UIW.js} +1 -1
- package/dist/ui/ui.css +1 -1
- package/dist/ui/ui.js +1 -1
- package/package.json +3 -3
- package/dist/ui/AIPage-EO5WH25R.js +0 -1
- package/dist/ui/AssetsPage-ESLB4R3I.js +0 -1
- package/dist/ui/CollectionPage-MXN7XKUX.js +0 -1
- package/dist/ui/ComparePage-TY7VJVE3.js +0 -1
- package/dist/ui/DocumentPage-2HNNEGRI.js +0 -1
- package/dist/ui/EditReleasePage-DOMXJXCU.js +0 -1
- package/dist/ui/EmbeddedAIPage-U5LONYH2.js +0 -1
- package/dist/ui/EmbeddedDocumentPage-HYV5GPK6.js +0 -1
- package/dist/ui/LogsPage-6KV3CQLH.js +0 -1
- package/dist/ui/NewReleasePage-FXHPFUVG.js +0 -1
- package/dist/ui/ReleasePage-NLGRYJX7.js +0 -1
- package/dist/ui/SidebarToolsPage-FWG6TIDI.js +0 -1
- package/dist/ui/TaskPage-APNRUOYG.js +0 -1
- package/dist/ui/TasksPage-FTEELXVZ.js +0 -1
- package/dist/ui/chunk-235TRWJF.js +0 -81
- package/dist/ui/chunk-56NMZYX6.js +0 -19
- package/dist/ui/chunk-6WJQBFN5.js +0 -1
- package/dist/ui/chunk-EYJ6GKZR.js +0 -1
- package/dist/ui/chunk-G5647K25.js +0 -1
- package/dist/ui/chunk-OWYV43BT.js +0 -1
- package/dist/ui/chunk-QWB6MAPJ.js +0 -7
- package/dist/ui/chunk-VJRMR2JM.js +0 -1
- package/dist/ui/chunk-WRA24P66.js +0 -7
- package/dist/ui/chunk-Z3ZJJWFT.js +0 -1
- package/dist/ui/chunk-ZAJPNVYS.js +0 -1
- /package/dist/ui/{ImageEditorDialog-YDKOGVJV.js.LEGAL.txt → ImageEditorDialog-JDXMU2FC.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-ST6QNIWT.js.LEGAL.txt → chunk-6ZVMJXLE.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-235TRWJF.js.LEGAL.txt → chunk-7OU4ERTS.js.LEGAL.txt} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{c as bw,e as Ow}from"./chunk-UCYWQEAS.js";import{b as Sw}from"./chunk-MYPLMHFW.js";import{a as lu}from"./chunk-U7LSFUHT.js";import{a as ww,b as Tw}from"./chunk-6WJQBFN5.js";import{a as vw}from"./chunk-34W6H4YG.js";import{a as yw,b as xw,c as Zh}from"./chunk-SYDHFYRC.js";import{a as la}from"./chunk-535JU7FU.js";import{a as kw}from"./chunk-FBSBL476.js";import{a as iw,b as sw,k as aw,m as lw,p as cw,q as dw,r as uw}from"./chunk-LAXQZPE3.js";import{a as ow}from"./chunk-QWB6MAPJ.js";import{c as Xh}from"./chunk-235TRWJF.js";import{T as rw}from"./chunk-AAR7DBEN.js";import{a as fw}from"./chunk-JBLSUM6W.js";import{a as wr}from"./chunk-HXSB6YB2.js";import{a as mE,d as Cw,e as Ew,h as Dw}from"./chunk-ZAJPNVYS.js";import{g as gw,h as aa,i as mw}from"./chunk-EYJ6GKZR.js";import{d as hE,e as gE,g as Ud}from"./chunk-G5647K25.js";import{a as hw}from"./chunk-QFDU6FXP.js";import{c as $C}from"./chunk-JDW4UORS.js";import{a as Nw}from"./chunk-UJX25CXD.js";import{a as St,c as ot}from"./chunk-QRAFYIAW.js";import{a as na,b as oa,c as Fd,d as UC}from"./chunk-ATTW36EM.js";import{a as Pn,b as yn,d as zh,e as et,g as pE}from"./chunk-5MV6XVGA.js";import{a as fE}from"./chunk-PLYSJ7W5.js";import{a as au,b as pw}from"./chunk-W5DOO6ID.js";import{a as su}from"./chunk-YBHFGQ3Z.js";import{a as Al,b as vr}from"./chunk-2PTLQRTU.js";import{a as ae,b as kt,c as Il}from"./chunk-PIJ3E47R.js";import{a as os}from"./chunk-NCZD5IWS.js";import{a as Io,b as _w}from"./chunk-AAHM6RYJ.js";import{$ as Hd,B as rE,D as iE,M as sE,N as aE,Q as ra,S as lE,U as cE,V as $d,W as dE,X as uE,_ as zd,a as Bd,b as Qi,c as KC,d as No,e as GC,f as YC,l as qC,v as JC,w as XC,x as Bh}from"./chunk-ISUGBMXC.js";import{b as ZC,c as QC,f as $h,g as Er,i as eE,k as tE,l as Ll,m as nE,n as Rl,o as oE}from"./chunk-DZYYWCHX.js";import{B as zC,C as HC,D as Pd,a as Id,c as Ad,e as PC,p as FC,q as Md,s as Ld,u as Rd,v as ta,y as Zi}from"./chunk-XOWWPE7X.js";import{d as BC,e as xe}from"./chunk-WASID5UU.js";import{$a as es,A as NC,Ab as Do,Ba as ho,Bb as SE,Bc as ns,Cb as kE,Cc as Vh,Da as RC,Db as Bl,Dc as Qd,Ea as Od,Ec as Wh,Fa as we,Fb as NE,Fc as XE,Ga as f,Gc as eu,Hc as ZE,Ia as Pl,Ic as QE,Ja as _E,Kb as DE,Kc as Oo,Lb as Yd,Lc as Gh,Ma as li,Mb as OE,Mc as ew,Nb as IE,Nc as tu,Ob as AE,Oc as nu,Pb as ME,Pc as ou,Qa as ia,Qb as LE,Qc as ru,R as DC,Tb as $l,U as Rh,Ub as qd,Uc as Yh,V as xt,Va as Kd,Vb as RE,Vc as Zn,W as Ae,Wa as Hh,Wb as PE,Wc as iu,Xa as bE,Xb as ts,Xc as tw,Y as Bt,Yb as FE,Za as yE,Zb as BE,_ as xr,a as L,aa as OC,ab as go,ac as $E,ad as qh,b as CC,ba as IC,bb as Fl,bc as Jd,c as F,cc as zE,cd as Jh,d as _n,da as Z,db as xE,dc as HE,e as J,ea as fo,eb as vE,ec as UE,ed as nw,fa as fn,fb as CE,fc as Xd,g as X,ga as AC,gb as jd,h as De,hb as Uh,hc as KE,i as ft,j as ke,jb as Vd,jc as jE,k as EC,l as wC,la as ea,m as po,mb as Wd,na as bn,o as Sd,oa as kd,oc as VE,p as TC,pa as Nd,pb as Gd,pc as zl,q as si,qa as G,qc as Zd,r as SC,ra as Xi,rb as EE,rc as Kh,s as kC,sa as MC,sc as jh,tc as WE,u as Ol,ua as Xn,ub as wE,uc as GE,v as nt,va as LC,w as yr,wc as YE,x as Mh,xb as sa,xc as qE,y as yt,ya as Dd,yc as JE,z as Lh,za as Rn,zb as TE}from"./chunk-WRA24P66.js";import{b as Ji,d as Ne,e as Td,j as pt,k as br}from"./chunk-KUCVLANF.js";import{h as ai,i as jC,j as VC,k as Ph,l as Cr,m as Fh,n as Ml,p as WC}from"./chunk-7SK47HHZ.js";import{b as Ih,c as $e,d as Ah,e as iP}from"./chunk-PVAE643M.js";var a0=Ih(s0=>{"use strict";var Hl=(yt(),iP(Mh));function VP(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var WP=typeof Object.is=="function"?Object.is:VP,GP=Hl.useSyncExternalStore,YP=Hl.useRef,qP=Hl.useEffect,JP=Hl.useMemo,XP=Hl.useDebugValue;s0.useSyncExternalStoreWithSelector=function(t,e,n,o,r){var i=YP(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=JP(function(){function l(h){if(!c){if(c=!0,d=h,h=o(h),r!==void 0&&s.hasValue){var g=s.value;if(r(g,h))return u=g}return u=h}if(g=u,WP(d,h))return g;var m=o(h);return r!==void 0&&r(g,m)?(d=h,g):(d=h,u=m)}var c=!1,d,u,p=n===void 0?null:n;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,n,o,r]);var a=GP(t,i[0],i[1]);return qP(function(){s.hasValue=!0,s.value=a},[a]),XP(a),a}});var c0=Ih((Xq,l0)=>{"use strict";l0.exports=a0()});var eC=Ih((Fce,bh)=>{"use strict";var AW=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var ie=(function(t){var e=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,o={},r={manual:t.Prism&&t.Prism.manual,disableWorkerMessageHandler:t.Prism&&t.Prism.disableWorkerMessageHandler,util:{encode:function m(_){return _ instanceof i?new i(_.type,m(_.content),_.alias):Array.isArray(_)?_.map(m):_.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(m){return Object.prototype.toString.call(m).slice(8,-1)},objId:function(m){return m.__id||Object.defineProperty(m,"__id",{value:++n}),m.__id},clone:function m(_,b){b=b||{};var y,v;switch(r.util.type(_)){case"Object":if(v=r.util.objId(_),b[v])return b[v];y={},b[v]=y;for(var x in _)_.hasOwnProperty(x)&&(y[x]=m(_[x],b));return y;case"Array":return v=r.util.objId(_),b[v]?b[v]:(y=[],b[v]=y,_.forEach(function(C,E){y[E]=m(C,b)}),y);default:return _}},getLanguage:function(m){for(;m;){var _=e.exec(m.className);if(_)return _[1].toLowerCase();m=m.parentElement}return"none"},setLanguage:function(m,_){m.className=m.className.replace(RegExp(e,"gi"),""),m.classList.add("language-"+_)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(y){var m=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(y.stack)||[])[1];if(m){var _=document.getElementsByTagName("script");for(var b in _)if(_[b].src==m)return _[b]}return null}},isActive:function(m,_,b){for(var y="no-"+_;m;){var v=m.classList;if(v.contains(_))return!0;if(v.contains(y))return!1;m=m.parentElement}return!!b}},languages:{plain:o,plaintext:o,text:o,txt:o,extend:function(m,_){var b=r.util.clone(r.languages[m]);for(var y in _)b[y]=_[y];return b},insertBefore:function(m,_,b,y){y=y||r.languages;var v=y[m],x={};for(var C in v)if(v.hasOwnProperty(C)){if(C==_)for(var E in b)b.hasOwnProperty(E)&&(x[E]=b[E]);b.hasOwnProperty(C)||(x[C]=v[C])}var k=y[m];return y[m]=x,r.languages.DFS(r.languages,function(T,w){w===k&&T!=m&&(this[T]=x)}),x},DFS:function m(_,b,y,v){v=v||{};var x=r.util.objId;for(var C in _)if(_.hasOwnProperty(C)){b.call(_,C,_[C],y||C);var E=_[C],k=r.util.type(E);k==="Object"&&!v[x(E)]?(v[x(E)]=!0,m(E,b,null,v)):k==="Array"&&!v[x(E)]&&(v[x(E)]=!0,m(E,b,C,v))}}},plugins:{},highlightAll:function(m,_){r.highlightAllUnder(document,m,_)},highlightAllUnder:function(m,_,b){var y={callback:b,container:m,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};r.hooks.run("before-highlightall",y),y.elements=Array.prototype.slice.apply(y.container.querySelectorAll(y.selector)),r.hooks.run("before-all-elements-highlight",y);for(var v=0,x;x=y.elements[v++];)r.highlightElement(x,_===!0,y.callback)},highlightElement:function(m,_,b){var y=r.util.getLanguage(m),v=r.languages[y];r.util.setLanguage(m,y);var x=m.parentElement;x&&x.nodeName.toLowerCase()==="pre"&&r.util.setLanguage(x,y);var C=m.textContent,E={element:m,language:y,grammar:v,code:C};function k(w){E.highlightedCode=w,r.hooks.run("before-insert",E),E.element.innerHTML=E.highlightedCode,r.hooks.run("after-highlight",E),r.hooks.run("complete",E),b&&b.call(E.element)}if(r.hooks.run("before-sanity-check",E),x=E.element.parentElement,x&&x.nodeName.toLowerCase()==="pre"&&!x.hasAttribute("tabindex")&&x.setAttribute("tabindex","0"),!E.code){r.hooks.run("complete",E),b&&b.call(E.element);return}if(r.hooks.run("before-highlight",E),!E.grammar){k(r.util.encode(E.code));return}if(_&&t.Worker){var T=new Worker(r.filename);T.onmessage=function(w){k(w.data)},T.postMessage(JSON.stringify({language:E.language,code:E.code,immediateClose:!0}))}else k(r.highlight(E.code,E.grammar,E.language))},highlight:function(m,_,b){var y={code:m,grammar:_,language:b};if(r.hooks.run("before-tokenize",y),!y.grammar)throw new Error('The language "'+y.language+'" has no grammar.');return y.tokens=r.tokenize(y.code,y.grammar),r.hooks.run("after-tokenize",y),i.stringify(r.util.encode(y.tokens),y.language)},tokenize:function(m,_){var b=_.rest;if(b){for(var y in b)_[y]=b[y];delete _.rest}var v=new l;return c(v,v.head,m),a(m,v,_,v.head,0),u(v)},hooks:{all:{},add:function(m,_){var b=r.hooks.all;b[m]=b[m]||[],b[m].push(_)},run:function(m,_){var b=r.hooks.all[m];if(!(!b||!b.length))for(var y=0,v;v=b[y++];)v(_)}},Token:i};t.Prism=r;function i(m,_,b,y){this.type=m,this.content=_,this.alias=b,this.length=(y||"").length|0}i.stringify=function m(_,b){if(typeof _=="string")return _;if(Array.isArray(_)){var y="";return _.forEach(function(k){y+=m(k,b)}),y}var v={type:_.type,content:m(_.content,b),tag:"span",classes:["token",_.type],attributes:{},language:b},x=_.alias;x&&(Array.isArray(x)?Array.prototype.push.apply(v.classes,x):v.classes.push(x)),r.hooks.run("wrap",v);var C="";for(var E in v.attributes)C+=" "+E+'="'+(v.attributes[E]||"").replace(/"/g,""")+'"';return"<"+v.tag+' class="'+v.classes.join(" ")+'"'+C+">"+v.content+"</"+v.tag+">"};function s(m,_,b,y){m.lastIndex=_;var v=m.exec(b);if(v&&y&&v[1]){var x=v[1].length;v.index+=x,v[0]=v[0].slice(x)}return v}function a(m,_,b,y,v,x){for(var C in b)if(!(!b.hasOwnProperty(C)||!b[C])){var E=b[C];E=Array.isArray(E)?E:[E];for(var k=0;k<E.length;++k){if(x&&x.cause==C+","+k)return;var T=E[k],w=T.inside,S=!!T.lookbehind,N=!!T.greedy,D=T.alias;if(N&&!T.pattern.global){var O=T.pattern.toString().match(/[imsuy]*$/)[0];T.pattern=RegExp(T.pattern.source,O+"g")}for(var A=T.pattern||T,I=y.next,R=v;I!==_.tail&&!(x&&R>=x.reach);R+=I.value.length,I=I.next){var $=I.value;if(_.length>m.length)return;if(!($ instanceof i)){var W=1,P;if(N){if(P=s(A,R,m,S),!P||P.index>=m.length)break;var Tt=P.index,q=P.index+P[0].length,de=R;for(de+=I.value.length;Tt>=de;)I=I.next,de+=I.value.length;if(de-=I.value.length,R=de,I.value instanceof i)continue;for(var rt=I;rt!==_.tail&&(de<q||typeof rt.value=="string");rt=rt.next)W++,de+=rt.value.length;W--,$=m.slice(R,de),P.index-=R}else if(P=s(A,0,$,S),!P)continue;var Tt=P.index,_t=P[0],dt=$.slice(0,Tt),ut=$.slice(Tt+_t.length),oe=R+$.length;x&&oe>x.reach&&(x.reach=oe);var ee=I.prev;dt&&(ee=c(_,ee,dt),R+=dt.length),d(_,ee,W);var ye=new i(C,w?r.tokenize(_t,w):_t,D,_t);if(I=c(_,ee,ye),ut&&c(_,I,ut),W>1){var Fe={cause:C+","+k,reach:oe};a(m,_,b,I.prev,R,Fe),x&&Fe.reach>x.reach&&(x.reach=Fe.reach)}}}}}}function l(){var m={value:null,prev:null,next:null},_={value:null,prev:m,next:null};m.next=_,this.head=m,this.tail=_,this.length=0}function c(m,_,b){var y=_.next,v={value:b,prev:_,next:y};return _.next=v,y.prev=v,m.length++,v}function d(m,_,b){for(var y=_.next,v=0;v<b&&y!==m.tail;v++)y=y.next;_.next=y,y.prev=_,m.length-=v}function u(m){for(var _=[],b=m.head.next;b!==m.tail;)_.push(b.value),b=b.next;return _}if(!t.document)return t.addEventListener&&(r.disableWorkerMessageHandler||t.addEventListener("message",function(m){var _=JSON.parse(m.data),b=_.language,y=_.code,v=_.immediateClose;t.postMessage(r.highlight(y,r.languages[b],b)),v&&t.close()},!1)),r;var p=r.util.currentScript();p&&(r.filename=p.src,p.hasAttribute("data-manual")&&(r.manual=!0));function h(){r.manual||r.highlightAll()}if(!r.manual){var g=document.readyState;g==="loading"||g==="interactive"&&p&&p.defer?document.addEventListener("DOMContentLoaded",h):window.requestAnimationFrame?window.requestAnimationFrame(h):window.setTimeout(h,16)}return r})(AW);typeof bh<"u"&&bh.exports&&(bh.exports=ie);typeof global<"u"&&(global.Prism=ie);ie.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};ie.languages.markup.tag.inside["attr-value"].inside.entity=ie.languages.markup.entity;ie.languages.markup.doctype.inside["internal-subset"].inside=ie.languages.markup;ie.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&/,"&"))});Object.defineProperty(ie.languages.markup.tag,"addInlined",{value:function(e,n){var o={};o["language-"+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:ie.languages[n]},o.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:o}};r["language-"+n]={pattern:/[\s\S]+/,inside:ie.languages[n]};var i={};i[e]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return e}),"i"),lookbehind:!0,greedy:!0,inside:r},ie.languages.insertBefore("markup","cdata",i)}});Object.defineProperty(ie.languages.markup.tag,"addAttribute",{value:function(t,e){ie.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:ie.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});ie.languages.html=ie.languages.markup;ie.languages.mathml=ie.languages.markup;ie.languages.svg=ie.languages.markup;ie.languages.xml=ie.languages.extend("markup",{});ie.languages.ssml=ie.languages.xml;ie.languages.atom=ie.languages.xml;ie.languages.rss=ie.languages.xml;(function(t){var e=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+e.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+e.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+e.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+e.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:e,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var n=t.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(ie);ie.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};ie.languages.javascript=ie.languages.extend("clike",{"class-name":[ie.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});ie.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;ie.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:ie.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:ie.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:ie.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:ie.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:ie.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});ie.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:ie.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});ie.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});ie.languages.markup&&(ie.languages.markup.tag.addInlined("script","javascript"),ie.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));ie.languages.js=ie.languages.javascript;(function(){if(typeof ie>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var t="Loading\u2026",e=function(p,h){return"\u2716 Error "+p+" while fetching file: "+h},n="\u2716 Error: File does not exist or is empty",o={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},r="data-src-status",i="loading",s="loaded",a="failed",l="pre[data-src]:not(["+r+'="'+s+'"]):not(['+r+'="'+i+'"])';function c(p,h,g){var m=new XMLHttpRequest;m.open("GET",p,!0),m.onreadystatechange=function(){m.readyState==4&&(m.status<400&&m.responseText?h(m.responseText):m.status>=400?g(e(m.status,m.statusText)):g(n))},m.send(null)}function d(p){var h=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(p||"");if(h){var g=Number(h[1]),m=h[2],_=h[3];return m?_?[g,Number(_)]:[g,void 0]:[g,g]}}ie.hooks.add("before-highlightall",function(p){p.selector+=", "+l}),ie.hooks.add("before-sanity-check",function(p){var h=p.element;if(h.matches(l)){p.code="",h.setAttribute(r,i);var g=h.appendChild(document.createElement("CODE"));g.textContent=t;var m=h.getAttribute("data-src"),_=p.language;if(_==="none"){var b=(/\.(\w+)$/.exec(m)||[,"none"])[1];_=o[b]||b}ie.util.setLanguage(g,_),ie.util.setLanguage(h,_);var y=ie.plugins.autoloader;y&&y.loadLanguages(_),c(m,function(v){h.setAttribute(r,s);var x=d(h.getAttribute("data-range"));if(x){var C=v.split(/\r\n?|\n/g),E=x[0],k=x[1]==null?C.length:x[1];E<0&&(E+=C.length),E=Math.max(0,Math.min(E-1,C.length)),k<0&&(k+=C.length),k=Math.max(0,Math.min(k,C.length)),v=C.slice(E,k).join(`
|
|
2
|
-
`),h.hasAttribute("data-start")||h.setAttribute("data-start",String(E+1))}g.textContent=v,ie.highlightElement(g)},function(v){h.setAttribute(r,a),g.textContent=v})}}),ie.plugins.fileHighlight={highlight:function(h){for(var g=(h||document).querySelectorAll(l),m=0,_;_=g[m++];)ie.highlightElement(_)}};var u=!1;ie.fileHighlight=function(){u||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),u=!0),ie.plugins.fileHighlight.highlight.apply(this,arguments)}})()});ke();ke();ke();function cu(t){return f(ns,{className:t.className,size:t.size})}function Lw(t){let[e,n]=L(null),[o,r]=L("");if(F(()=>{let a=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let c=await l.json();a&&n(c)}).catch(l=>{a&&r(String(l))}),()=>{a=!1}},[]),!e&&!o)return f("div",{className:"AiEditModal__ChatPanel__loading",children:f(xt,{size:"sm",color:"gray"})});if(!(!!e?.enabled&&(e.models?.length||0)>0))return f("div",{className:"AiEditModal__ChatPanel__notConfigured",children:[f("div",{className:"AiEditModal__ChatPanel__notConfigured__icon",children:f(ns,{size:32})}),f("div",{className:"AiEditModal__ChatPanel__notConfigured__title",children:"Root AI is not configured for this project."}),f("div",{className:"AiEditModal__ChatPanel__notConfigured__body",children:["Add an ",f("code",{children:"ai.models"})," entry to ",f("code",{children:"cmsPlugin()"})," in"," ",f("code",{children:"root.config.ts"}),"."]}),o&&f("pre",{className:"AiEditModal__ChatPanel__notConfigured__error",children:o})]});let s=e.models.find(a=>a.id===e.defaultModel)||e.models[0];return f(sP,{model:s,editModeData:t.editModeData,onEditModeResponse:t.onEditModeResponse,welcome:t.children})}function sP(t){let e=J(t.editModeData);e.current=t.editModeData;let n=X(()=>
|
|
1
|
+
import{c as xw,e as Ow}from"./chunk-ZD3ORGA6.js";import{b as Sw}from"./chunk-MYPLMHFW.js";import{a as lu}from"./chunk-TZWCCNSA.js";import{a as Ew}from"./chunk-CXMVFNX3.js";import{a as vw,b as Cw,c as Zh}from"./chunk-SYDHFYRC.js";import{a as la}from"./chunk-ILFWJKSS.js";import{a as kw}from"./chunk-FBSBL476.js";import{a as lw,b as cw,k as dw,m as uw,p as pw,q as fw,r as hw}from"./chunk-LKTN7YVM.js";import{T as aw}from"./chunk-AAR7DBEN.js";import{a as mw}from"./chunk-P57AFOMR.js";import{a as wr}from"./chunk-I3H465Z6.js";import{a as sw,c as ww,d as Tw,f as Dw}from"./chunk-A2JZYRE3.js";import{c as bw,d as aa,e as yw}from"./chunk-PY4JH5SN.js";import{m as rw,n as iw,p as iu}from"./chunk-CEWU5VSJ.js";import{a as ew,b as nw}from"./chunk-YIKHJONY.js";import{a as _w}from"./chunk-MALK5YEV.js";import{c as $C}from"./chunk-JDW4UORS.js";import{a as Nw}from"./chunk-BOIY4J2R.js";import{a as St,c as ot}from"./chunk-XYXL5HSZ.js";import{a as na,b as oa,c as Fd,d as UC}from"./chunk-ATTW36EM.js";import{c as Xh,d as tw}from"./chunk-7OU4ERTS.js";import{a as Pn,b as yn,d as Jh,e as et,g as ZE}from"./chunk-5MV6XVGA.js";import{a as ow}from"./chunk-LS2JH5QF.js";import{a as au,b as gw}from"./chunk-W5DOO6ID.js";import{a as su}from"./chunk-ZQDUWURP.js";import{a as Al,b as vr}from"./chunk-U5OXKKBN.js";import{a as ae,b as kt,c as Il}from"./chunk-ZYSR5UIW.js";import{a as os}from"./chunk-HWON6MV4.js";import{a as Io,b as QE}from"./chunk-AAHM6RYJ.js";import{$ as Hd,B as rE,D as iE,M as sE,N as aE,Q as ra,S as lE,U as cE,V as $d,W as dE,X as uE,_ as zd,a as Bd,b as Qi,c as KC,d as No,e as GC,f as YC,l as qC,v as JC,w as XC,x as Bh}from"./chunk-ISUGBMXC.js";import{b as ZC,c as QC,f as $h,g as Er,i as eE,k as tE,l as Ll,m as nE,n as Rl,o as oE}from"./chunk-DZYYWCHX.js";import{B as zC,C as HC,D as Pd,a as Id,c as Ad,e as PC,p as FC,q as Md,s as Ld,u as Rd,v as ta,y as Zi}from"./chunk-XOWWPE7X.js";import{d as BC,e as xe}from"./chunk-GJ7ES2LA.js";import{$a as go,A as NC,Ab as vE,Ba as ho,Bb as CE,Bc as ns,Cc as jh,Da as RC,Db as Bl,Dc as Zd,Ea as Od,Ec as Vh,Fa as we,Fb as EE,Fc as WE,Gc as Qd,Ha as Pl,Hc as GE,Ia as pE,Ic as YE,Kb as wE,Kc as Oo,La as li,Lb as Gd,Lc as Wh,Mb as TE,Mc as qE,Nb as SE,Nc as eu,Ob as kE,Oc as tu,Pa as ia,Pb as NE,Pc as nu,Qb as DE,Qc as ou,R as DC,Tb as $l,U as Rh,Ua as Ud,Ub as Yd,Uc as Gh,V as xt,Va as zh,Vb as OE,Vc as Zn,W as Ae,Wa as fE,Wb as IE,Wc as ru,Xb as ts,Xc as JE,Y as Bt,Ya as hE,Yb as AE,Zb as ME,_ as xr,_a as es,a as L,aa as OC,ab as Fl,ac as LE,ad as Yh,b as CC,ba as IC,bc as qd,c as F,cb as gE,cc as RE,cd as qh,d as _n,da as Z,db as mE,dc as PE,e as J,ea as fo,eb as _E,ec as FE,ed as XE,fa as fn,fb as Kd,fc as Jd,fd as f,g as X,ga as AC,gb as Hh,h as De,hc as BE,i as ft,ib as jd,j as ke,jc as $E,k as EC,l as wC,la as ea,lb as Vd,m as po,na as bn,o as Sd,oa as kd,ob as Wd,oc as zE,p as TC,pa as Nd,pc as zl,q as si,qa as G,qb as bE,qc as Xd,r as SC,ra as Xi,rc as Uh,s as kC,sa as MC,sc as Kh,tb as yE,tc as HE,u as Ol,ua as Xn,uc as UE,v as nt,va as LC,w as yr,wb as sa,wc as KE,x as Mh,xc as jE,y as yt,ya as Dd,yb as xE,yc as VE,z as Lh,za as Rn,zb as Do}from"./chunk-Y7RYSRP7.js";import{b as Ji,d as Ne,e as Td,j as pt,k as br}from"./chunk-KUCVLANF.js";import{h as ai,i as jC,j as VC,k as Ph,l as Cr,m as Fh,n as Ml,p as WC}from"./chunk-7SK47HHZ.js";import{b as Ih,c as $e,d as Ah,e as iP}from"./chunk-PVAE643M.js";var a0=Ih(s0=>{"use strict";var Hl=(yt(),iP(Mh));function VP(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var WP=typeof Object.is=="function"?Object.is:VP,GP=Hl.useSyncExternalStore,YP=Hl.useRef,qP=Hl.useEffect,JP=Hl.useMemo,XP=Hl.useDebugValue;s0.useSyncExternalStoreWithSelector=function(t,e,n,o,r){var i=YP(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=JP(function(){function l(h){if(!c){if(c=!0,d=h,h=o(h),r!==void 0&&s.hasValue){var g=s.value;if(r(g,h))return u=g}return u=h}if(g=u,WP(d,h))return g;var m=o(h);return r!==void 0&&r(g,m)?(d=h,g):(d=h,u=m)}var c=!1,d,u,p=n===void 0?null:n;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,n,o,r]);var a=GP(t,i[0],i[1]);return qP(function(){s.hasValue=!0,s.value=a},[a]),XP(a),a}});var c0=Ih((Xq,l0)=>{"use strict";l0.exports=a0()});var eC=Ih((Fce,bh)=>{"use strict";var AW=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var ie=(function(t){var e=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,o={},r={manual:t.Prism&&t.Prism.manual,disableWorkerMessageHandler:t.Prism&&t.Prism.disableWorkerMessageHandler,util:{encode:function m(_){return _ instanceof i?new i(_.type,m(_.content),_.alias):Array.isArray(_)?_.map(m):_.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(m){return Object.prototype.toString.call(m).slice(8,-1)},objId:function(m){return m.__id||Object.defineProperty(m,"__id",{value:++n}),m.__id},clone:function m(_,b){b=b||{};var y,v;switch(r.util.type(_)){case"Object":if(v=r.util.objId(_),b[v])return b[v];y={},b[v]=y;for(var x in _)_.hasOwnProperty(x)&&(y[x]=m(_[x],b));return y;case"Array":return v=r.util.objId(_),b[v]?b[v]:(y=[],b[v]=y,_.forEach(function(C,E){y[E]=m(C,b)}),y);default:return _}},getLanguage:function(m){for(;m;){var _=e.exec(m.className);if(_)return _[1].toLowerCase();m=m.parentElement}return"none"},setLanguage:function(m,_){m.className=m.className.replace(RegExp(e,"gi"),""),m.classList.add("language-"+_)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(y){var m=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(y.stack)||[])[1];if(m){var _=document.getElementsByTagName("script");for(var b in _)if(_[b].src==m)return _[b]}return null}},isActive:function(m,_,b){for(var y="no-"+_;m;){var v=m.classList;if(v.contains(_))return!0;if(v.contains(y))return!1;m=m.parentElement}return!!b}},languages:{plain:o,plaintext:o,text:o,txt:o,extend:function(m,_){var b=r.util.clone(r.languages[m]);for(var y in _)b[y]=_[y];return b},insertBefore:function(m,_,b,y){y=y||r.languages;var v=y[m],x={};for(var C in v)if(v.hasOwnProperty(C)){if(C==_)for(var E in b)b.hasOwnProperty(E)&&(x[E]=b[E]);b.hasOwnProperty(C)||(x[C]=v[C])}var k=y[m];return y[m]=x,r.languages.DFS(r.languages,function(T,w){w===k&&T!=m&&(this[T]=x)}),x},DFS:function m(_,b,y,v){v=v||{};var x=r.util.objId;for(var C in _)if(_.hasOwnProperty(C)){b.call(_,C,_[C],y||C);var E=_[C],k=r.util.type(E);k==="Object"&&!v[x(E)]?(v[x(E)]=!0,m(E,b,null,v)):k==="Array"&&!v[x(E)]&&(v[x(E)]=!0,m(E,b,C,v))}}},plugins:{},highlightAll:function(m,_){r.highlightAllUnder(document,m,_)},highlightAllUnder:function(m,_,b){var y={callback:b,container:m,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};r.hooks.run("before-highlightall",y),y.elements=Array.prototype.slice.apply(y.container.querySelectorAll(y.selector)),r.hooks.run("before-all-elements-highlight",y);for(var v=0,x;x=y.elements[v++];)r.highlightElement(x,_===!0,y.callback)},highlightElement:function(m,_,b){var y=r.util.getLanguage(m),v=r.languages[y];r.util.setLanguage(m,y);var x=m.parentElement;x&&x.nodeName.toLowerCase()==="pre"&&r.util.setLanguage(x,y);var C=m.textContent,E={element:m,language:y,grammar:v,code:C};function k(w){E.highlightedCode=w,r.hooks.run("before-insert",E),E.element.innerHTML=E.highlightedCode,r.hooks.run("after-highlight",E),r.hooks.run("complete",E),b&&b.call(E.element)}if(r.hooks.run("before-sanity-check",E),x=E.element.parentElement,x&&x.nodeName.toLowerCase()==="pre"&&!x.hasAttribute("tabindex")&&x.setAttribute("tabindex","0"),!E.code){r.hooks.run("complete",E),b&&b.call(E.element);return}if(r.hooks.run("before-highlight",E),!E.grammar){k(r.util.encode(E.code));return}if(_&&t.Worker){var T=new Worker(r.filename);T.onmessage=function(w){k(w.data)},T.postMessage(JSON.stringify({language:E.language,code:E.code,immediateClose:!0}))}else k(r.highlight(E.code,E.grammar,E.language))},highlight:function(m,_,b){var y={code:m,grammar:_,language:b};if(r.hooks.run("before-tokenize",y),!y.grammar)throw new Error('The language "'+y.language+'" has no grammar.');return y.tokens=r.tokenize(y.code,y.grammar),r.hooks.run("after-tokenize",y),i.stringify(r.util.encode(y.tokens),y.language)},tokenize:function(m,_){var b=_.rest;if(b){for(var y in b)_[y]=b[y];delete _.rest}var v=new l;return c(v,v.head,m),a(m,v,_,v.head,0),u(v)},hooks:{all:{},add:function(m,_){var b=r.hooks.all;b[m]=b[m]||[],b[m].push(_)},run:function(m,_){var b=r.hooks.all[m];if(!(!b||!b.length))for(var y=0,v;v=b[y++];)v(_)}},Token:i};t.Prism=r;function i(m,_,b,y){this.type=m,this.content=_,this.alias=b,this.length=(y||"").length|0}i.stringify=function m(_,b){if(typeof _=="string")return _;if(Array.isArray(_)){var y="";return _.forEach(function(k){y+=m(k,b)}),y}var v={type:_.type,content:m(_.content,b),tag:"span",classes:["token",_.type],attributes:{},language:b},x=_.alias;x&&(Array.isArray(x)?Array.prototype.push.apply(v.classes,x):v.classes.push(x)),r.hooks.run("wrap",v);var C="";for(var E in v.attributes)C+=" "+E+'="'+(v.attributes[E]||"").replace(/"/g,""")+'"';return"<"+v.tag+' class="'+v.classes.join(" ")+'"'+C+">"+v.content+"</"+v.tag+">"};function s(m,_,b,y){m.lastIndex=_;var v=m.exec(b);if(v&&y&&v[1]){var x=v[1].length;v.index+=x,v[0]=v[0].slice(x)}return v}function a(m,_,b,y,v,x){for(var C in b)if(!(!b.hasOwnProperty(C)||!b[C])){var E=b[C];E=Array.isArray(E)?E:[E];for(var k=0;k<E.length;++k){if(x&&x.cause==C+","+k)return;var T=E[k],w=T.inside,S=!!T.lookbehind,N=!!T.greedy,D=T.alias;if(N&&!T.pattern.global){var O=T.pattern.toString().match(/[imsuy]*$/)[0];T.pattern=RegExp(T.pattern.source,O+"g")}for(var A=T.pattern||T,I=y.next,R=v;I!==_.tail&&!(x&&R>=x.reach);R+=I.value.length,I=I.next){var $=I.value;if(_.length>m.length)return;if(!($ instanceof i)){var W=1,P;if(N){if(P=s(A,R,m,S),!P||P.index>=m.length)break;var Tt=P.index,q=P.index+P[0].length,de=R;for(de+=I.value.length;Tt>=de;)I=I.next,de+=I.value.length;if(de-=I.value.length,R=de,I.value instanceof i)continue;for(var rt=I;rt!==_.tail&&(de<q||typeof rt.value=="string");rt=rt.next)W++,de+=rt.value.length;W--,$=m.slice(R,de),P.index-=R}else if(P=s(A,0,$,S),!P)continue;var Tt=P.index,_t=P[0],dt=$.slice(0,Tt),ut=$.slice(Tt+_t.length),oe=R+$.length;x&&oe>x.reach&&(x.reach=oe);var ee=I.prev;dt&&(ee=c(_,ee,dt),R+=dt.length),d(_,ee,W);var ye=new i(C,w?r.tokenize(_t,w):_t,D,_t);if(I=c(_,ee,ye),ut&&c(_,I,ut),W>1){var Fe={cause:C+","+k,reach:oe};a(m,_,b,I.prev,R,Fe),x&&Fe.reach>x.reach&&(x.reach=Fe.reach)}}}}}}function l(){var m={value:null,prev:null,next:null},_={value:null,prev:m,next:null};m.next=_,this.head=m,this.tail=_,this.length=0}function c(m,_,b){var y=_.next,v={value:b,prev:_,next:y};return _.next=v,y.prev=v,m.length++,v}function d(m,_,b){for(var y=_.next,v=0;v<b&&y!==m.tail;v++)y=y.next;_.next=y,y.prev=_,m.length-=v}function u(m){for(var _=[],b=m.head.next;b!==m.tail;)_.push(b.value),b=b.next;return _}if(!t.document)return t.addEventListener&&(r.disableWorkerMessageHandler||t.addEventListener("message",function(m){var _=JSON.parse(m.data),b=_.language,y=_.code,v=_.immediateClose;t.postMessage(r.highlight(y,r.languages[b],b)),v&&t.close()},!1)),r;var p=r.util.currentScript();p&&(r.filename=p.src,p.hasAttribute("data-manual")&&(r.manual=!0));function h(){r.manual||r.highlightAll()}if(!r.manual){var g=document.readyState;g==="loading"||g==="interactive"&&p&&p.defer?document.addEventListener("DOMContentLoaded",h):window.requestAnimationFrame?window.requestAnimationFrame(h):window.setTimeout(h,16)}return r})(AW);typeof bh<"u"&&bh.exports&&(bh.exports=ie);typeof global<"u"&&(global.Prism=ie);ie.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};ie.languages.markup.tag.inside["attr-value"].inside.entity=ie.languages.markup.entity;ie.languages.markup.doctype.inside["internal-subset"].inside=ie.languages.markup;ie.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&/,"&"))});Object.defineProperty(ie.languages.markup.tag,"addInlined",{value:function(e,n){var o={};o["language-"+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:ie.languages[n]},o.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:o}};r["language-"+n]={pattern:/[\s\S]+/,inside:ie.languages[n]};var i={};i[e]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return e}),"i"),lookbehind:!0,greedy:!0,inside:r},ie.languages.insertBefore("markup","cdata",i)}});Object.defineProperty(ie.languages.markup.tag,"addAttribute",{value:function(t,e){ie.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:ie.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});ie.languages.html=ie.languages.markup;ie.languages.mathml=ie.languages.markup;ie.languages.svg=ie.languages.markup;ie.languages.xml=ie.languages.extend("markup",{});ie.languages.ssml=ie.languages.xml;ie.languages.atom=ie.languages.xml;ie.languages.rss=ie.languages.xml;(function(t){var e=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+e.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+e.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+e.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+e.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:e,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var n=t.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(ie);ie.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};ie.languages.javascript=ie.languages.extend("clike",{"class-name":[ie.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});ie.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;ie.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:ie.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:ie.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:ie.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:ie.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:ie.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});ie.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:ie.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});ie.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});ie.languages.markup&&(ie.languages.markup.tag.addInlined("script","javascript"),ie.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));ie.languages.js=ie.languages.javascript;(function(){if(typeof ie>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var t="Loading\u2026",e=function(p,h){return"\u2716 Error "+p+" while fetching file: "+h},n="\u2716 Error: File does not exist or is empty",o={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},r="data-src-status",i="loading",s="loaded",a="failed",l="pre[data-src]:not(["+r+'="'+s+'"]):not(['+r+'="'+i+'"])';function c(p,h,g){var m=new XMLHttpRequest;m.open("GET",p,!0),m.onreadystatechange=function(){m.readyState==4&&(m.status<400&&m.responseText?h(m.responseText):m.status>=400?g(e(m.status,m.statusText)):g(n))},m.send(null)}function d(p){var h=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(p||"");if(h){var g=Number(h[1]),m=h[2],_=h[3];return m?_?[g,Number(_)]:[g,void 0]:[g,g]}}ie.hooks.add("before-highlightall",function(p){p.selector+=", "+l}),ie.hooks.add("before-sanity-check",function(p){var h=p.element;if(h.matches(l)){p.code="",h.setAttribute(r,i);var g=h.appendChild(document.createElement("CODE"));g.textContent=t;var m=h.getAttribute("data-src"),_=p.language;if(_==="none"){var b=(/\.(\w+)$/.exec(m)||[,"none"])[1];_=o[b]||b}ie.util.setLanguage(g,_),ie.util.setLanguage(h,_);var y=ie.plugins.autoloader;y&&y.loadLanguages(_),c(m,function(v){h.setAttribute(r,s);var x=d(h.getAttribute("data-range"));if(x){var C=v.split(/\r\n?|\n/g),E=x[0],k=x[1]==null?C.length:x[1];E<0&&(E+=C.length),E=Math.max(0,Math.min(E-1,C.length)),k<0&&(k+=C.length),k=Math.max(0,Math.min(k,C.length)),v=C.slice(E,k).join(`
|
|
2
|
+
`),h.hasAttribute("data-start")||h.setAttribute("data-start",String(E+1))}g.textContent=v,ie.highlightElement(g)},function(v){h.setAttribute(r,a),g.textContent=v})}}),ie.plugins.fileHighlight={highlight:function(h){for(var g=(h||document).querySelectorAll(l),m=0,_;_=g[m++];)ie.highlightElement(_)}};var u=!1;ie.fileHighlight=function(){u||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),u=!0),ie.plugins.fileHighlight.highlight.apply(this,arguments)}})()});ke();ke();ke();function cu(t){return f(ns,{className:t.className,size:t.size})}function Lw(t){let[e,n]=L(null),[o,r]=L("");if(F(()=>{let a=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let c=await l.json();a&&n(c)}).catch(l=>{a&&r(String(l))}),()=>{a=!1}},[]),!e&&!o)return f("div",{className:"AiEditModal__ChatPanel__loading",children:f(xt,{size:"sm",color:"gray"})});if(!(!!e?.enabled&&(e.models?.length||0)>0))return f("div",{className:"AiEditModal__ChatPanel__notConfigured",children:[f("div",{className:"AiEditModal__ChatPanel__notConfigured__icon",children:f(ns,{size:32})}),f("div",{className:"AiEditModal__ChatPanel__notConfigured__title",children:"Root AI is not configured for this project."}),f("div",{className:"AiEditModal__ChatPanel__notConfigured__body",children:["Add an ",f("code",{children:"ai.models"})," entry to ",f("code",{children:"cmsPlugin()"})," in"," ",f("code",{children:"root.config.ts"}),"."]}),o&&f("pre",{className:"AiEditModal__ChatPanel__notConfigured__error",children:o})]});let s=e.models.find(a=>a.id===e.defaultModel)||e.models[0];return f(sP,{model:s,editModeData:t.editModeData,onEditModeResponse:t.onEditModeResponse,welcome:t.children})}function sP(t){let e=J(t.editModeData);e.current=t.editModeData;let n=X(()=>dw({loadTurnConfig:async()=>{let p=await fetch("/cms/api/ai.edit.prepare",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({modelId:t.model.id,editData:e.current})}),h=await p.json();if(!p.ok||!h.success)throw new Error(h.error||`ai.edit.prepare failed: ${p.status}`);return{model:h.model,system:h.system,maxSteps:h.maxSteps}},buildTools:p=>p.capabilities.tools?uw():{}}),[t.model.id]),o=J(t.onEditModeResponse);o.current=t.onEditModeResponse;let r=J(new Map),{messages:i,sendMessage:s,status:a,error:l,stop:c,addToolOutput:d}=lw({transport:n,sendAutomaticallyWhen:aw,onToolCall:async({toolCall:p})=>{let h=await pw(p.toolName,p.input);d({tool:p.toolName,toolCallId:p.toolCallId,output:h})}}),u=a==="streaming"||a==="submitted";return F(()=>{let p=o.current;if(p)for(let h=i.length-1;h>=0;h--){let g=i[h];if(g.role!=="assistant")continue;let m=bP(g),_=yP(m);if(!_||r.current.get(g.id)===_)return;try{let y=JSON.parse(_);y&&typeof y=="object"&&(r.current.set(g.id,_),p({message:"",data:y}))}catch{}return}},[i]),f(Ne,{children:[f(aP,{messages:i,isStreaming:u,welcome:t.welcome}),l&&f("div",{className:"AiEditModal__ChatPanel__error",children:[f("strong",{children:"Error:"})," ",l.message]}),f(pP,{canAttach:t.model.capabilities.attachments,isStreaming:u,onStop:c,onSend:(p,h)=>{if(!p&&h.length===0)return;let g=fP(h),m=[p,g.text].filter(Boolean).join(`
|
|
3
3
|
|
|
4
|
-
`);s({text:m,files:g.files.map(_=>({type:"file",mediaType:_.mediaType,url:_.url,filename:_.filename}))})}})]})}function aP(t){let e=J(null);return F(()=>{let n=e.current;n&&(n.scrollTop=n.scrollHeight)},[t.messages]),t.messages.length===0?f("div",{className:"AiEditModal__ChatPanel__transcript AiEditModal__ChatPanel__transcript--empty",ref:e,children:f("div",{className:"AiEditModal__ChatPanel__welcome",children:[f("div",{className:"AiEditModal__ChatPanel__welcome__icon",children:f(cu,{})}),f("div",{className:"AiEditModal__ChatPanel__welcome__title",children:"Edit with Root AI"}),t.welcome&&f("div",{className:"AiEditModal__ChatPanel__welcome__body",children:t.welcome})]})}):f("div",{className:"AiEditModal__ChatPanel__transcript",ref:e,children:f("div",{className:"AiEditModal__ChatPanel__transcript__inner",children:[t.messages.map(n=>f(lP,{message:n},n.id)),t.isStreaming&&f("div",{className:"RootAIChat__streamingIndicator",children:f(
|
|
4
|
+
`);s({text:m,files:g.files.map(_=>({type:"file",mediaType:_.mediaType,url:_.url,filename:_.filename}))})}})]})}function aP(t){let e=J(null);return F(()=>{let n=e.current;n&&(n.scrollTop=n.scrollHeight)},[t.messages]),t.messages.length===0?f("div",{className:"AiEditModal__ChatPanel__transcript AiEditModal__ChatPanel__transcript--empty",ref:e,children:f("div",{className:"AiEditModal__ChatPanel__welcome",children:[f("div",{className:"AiEditModal__ChatPanel__welcome__icon",children:f(cu,{})}),f("div",{className:"AiEditModal__ChatPanel__welcome__title",children:"Edit with Root AI"}),t.welcome&&f("div",{className:"AiEditModal__ChatPanel__welcome__body",children:t.welcome})]})}):f("div",{className:"AiEditModal__ChatPanel__transcript",ref:e,children:f("div",{className:"AiEditModal__ChatPanel__transcript__inner",children:[t.messages.map(n=>f(lP,{message:n},n.id)),t.isStreaming&&f("div",{className:"RootAIChat__streamingIndicator",children:f(cw,{size:6})})]})})}function lP(t){let e=t.message,n=e.role==="user",o=n?"You":"Root AI",r=n?window.firebase.user?.photoURL:null;return f("div",{className:xe("AiEditModal__ChatPanel__message",`AiEditModal__ChatPanel__message--${e.role}`),children:[f("div",{className:"AiEditModal__ChatPanel__message__avatar",children:r?f("img",{src:r,alt:o}):f(ns,{size:18})}),f("div",{className:"AiEditModal__ChatPanel__message__body",children:[f("div",{className:"AiEditModal__ChatPanel__message__username",children:o}),f("div",{className:"AiEditModal__ChatPanel__message__parts",children:(e.parts||[]).map((i,s)=>f(cP,{part:i},s))})]})]})}function cP(t){let e=t.part;if(e.type==="text"){if(!e.text)return null;let n=xP(e.text);return n?f("div",{className:"AiEditModal__ChatPanel__textPart",children:f(Xh,{code:n})}):null}return e.type==="reasoning"?f(dP,{text:e.text}):e.type==="file"?f(uP,{part:e}):typeof e.type=="string"&&e.type.startsWith("tool-")?f(Iw,{part:e}):e.type==="dynamic-tool"?f(Iw,{part:e}):(e.type==="step-start",null)}function dP(t){let[e,n]=L(!1);return t.text?f("div",{className:xe("RootAIChat__reasoning",e&&"RootAIChat__reasoning--open"),children:[f("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>n(!e),children:[f(go,{size:14,style:{transform:e?"rotate(0deg)":"rotate(-90deg)"}}),f("span",{children:"Thinking"})]}),e&&f("div",{className:"RootAIChat__reasoning__body",children:f(Xh,{code:t.text})})]}):null}function uP(t){let e=t.part;return e.mediaType?.startsWith("image/")?f("div",{className:"AiEditModal__ChatPanel__filePart",children:f("img",{src:e.url,alt:e.filename||"attachment"})}):f("a",{className:"AiEditModal__ChatPanel__filePart AiEditModal__ChatPanel__filePart--link",href:e.url,target:"_blank",children:[f(zl,{size:14}),f("span",{children:e.filename||e.url})]})}function Iw(t){let e=t.part,n=typeof e.type=="string"&&e.type.startsWith("tool-")?e.type.slice(5):e.toolName||"tool",o=e.state||"",[r,i]=L(!1);return f("div",{className:"RootAIChat__tool",children:[f("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>i(!r),children:[f(go,{className:xe("RootAIChat__tool__header__icon",r&&"RootAIChat__tool__header__icon--open"),size:14}),f(IC,{color:"dark",variant:"filled",size:"xs",children:n}),f("span",{className:"RootAIChat__tool__title",children:fw(n,e.input)}),f("span",{className:"RootAIChat__tool__state",children:hw(o)})]}),r&&f("div",{className:"RootAIChat__tool__body",children:[e.input&&f("details",{children:[f("summary",{children:[f(Fl,{size:14,className:"RootAIChat__tool__json__icon"}),f("span",{children:"Input"})]}),f("pre",{children:JSON.stringify(e.input,null,2)})]}),e.output&&f("details",{children:[f("summary",{children:[f(Fl,{size:14,className:"RootAIChat__tool__json__icon"}),f("span",{children:"Output"})]}),f("pre",{children:JSON.stringify(e.output,null,2)})]}),e.errorText&&f("div",{className:"RootAIChat__tool__error",children:e.errorText})]})]})}function pP(t){let[e,n]=L(""),[o,r]=L([]),[i,s]=L(!1),a=J(null),l=J(null);F(()=>{window.requestAnimationFrame(()=>{let g=l.current;g&&(g.style.height="auto",g.style.height=`${Math.min(g.scrollHeight,200)}px`)})},[e,o]);let d=De(()=>{t.isStreaming||!e&&o.length===0||(t.onSend(e,o),n(""),r([]),a.current&&(a.current.value=""))},[e,o,t.isStreaming]),u=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),d())},p=async g=>{s(!0);try{let m=g.type||_P(g.name),_=await gP(g,m),b=await ai(g,{disableGci:!0});r(y=>[...y,{url:b.src,filename:b.filename||g.name,mediaType:m,textContent:_?.text,textTruncated:_?.truncated,width:b.width,height:b.height}])}catch(m){console.error("upload failed",m)}finally{s(!1),a.current&&(a.current.value="")}},h=g=>{let m=g.target;Array.from(m.files||[]).forEach(p)};return f("div",{className:"AiEditModal__ChatPanel__composer",children:[f("div",{className:xe("AiEditModal__ChatPanel__composer__prompt",(i||o.length>0)&&"AiEditModal__ChatPanel__composer__prompt--hasImage"),children:[t.canAttach&&f("label",{className:"AiEditModal__ChatPanel__composer__imageUpload",children:[f("input",{ref:a,type:"file",className:"AiEditModal__ChatPanel__composer__imageUpload__input",onChange:h}),f(we,{label:"Upload file",children:f(Ae,{component:"div",className:"AiEditModal__ChatPanel__composer__imageUpload__icon",radius:"xl",children:f(zl,{size:18})})})]}),f("textarea",{ref:l,className:"AiEditModal__ChatPanel__composer__textInput",placeholder:"Tell me what you want to change...",value:e,rows:1,autofocus:!0,onKeyDown:u,onChange:g=>n(g.target.value),onPaste:g=>{let m=g.clipboardData?.items||[];for(let _ of m)if(_.kind==="file"){let b=_.getAsFile();b&&t.canAttach&&p(b)}}}),(i||o.length>0)&&f("div",{className:"AiEditModal__ChatPanel__composer__attachments",children:[i&&f(xt,{size:"sm"}),o.map((g,m)=>f(we,{label:g.filename,transition:"pop",position:"top",withArrow:!0,children:f("button",{className:"AiEditModal__ChatPanel__composer__attachment",onClick:()=>r(_=>_.filter((b,y)=>y!==m)),children:[g.mediaType.startsWith("image/")?f("img",{src:g.url,alt:g.filename}):f("span",{className:"AiEditModal__ChatPanel__composer__attachment__name",children:g.filename}),f("div",{className:"AiEditModal__ChatPanel__composer__attachment__close",children:f(Yh,{size:20,color:"white"})})]})},m))]}),t.isStreaming?f(Ae,{className:"AiEditModal__ChatPanel__composer__submit",variant:"filled",color:"dark",radius:"xl",onClick:t.onStop,title:"Stop",children:f(Yh,{size:18})}):f(Ae,{className:"AiEditModal__ChatPanel__composer__submit",variant:"filled",color:"dark",radius:"xl",disabled:i||!e&&o.length===0,onClick:d,title:"Send",children:f(GE,{size:18})})]}),f("div",{className:"AiEditModal__ChatPanel__composer__disclaimer",children:"Root AI is experimental and makes mistakes. Check all info."})]})}var Aw=1e5;function fP(t){let e=t.filter(Mw),n=t.filter(o=>!Mw(o)).map(hP);return{files:e,text:n.length?`Attached files:
|
|
5
5
|
|
|
6
6
|
${n.join(`
|
|
7
7
|
|
|
@@ -15,7 +15,7 @@ ${t.textContent}${n}
|
|
|
15
15
|
~~~`}return`${e}
|
|
16
16
|
URL: ${t.url}
|
|
17
17
|
|
|
18
|
-
[The file was uploaded, but its binary content was not inlined into this chat message.]`}async function gP(t,e){if(!mP(t.name,e))return null;let n=await t.text();return n.length<=Aw?{text:n,truncated:!1}:{text:n.slice(0,Aw),truncated:!0}}function mP(t,e){return e.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(n=>t.toLowerCase().endsWith(n))}function _P(t){let e=t.toLowerCase();return e.endsWith(".png")?"image/png":e.endsWith(".webp")?"image/webp":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".gif")?"image/gif":e.endsWith(".svg")?"image/svg+xml":e.endsWith(".pdf")?"application/pdf":e.endsWith(".json")?"application/json":e.endsWith(".csv")?"text/csv":e.endsWith(".md")?"text/markdown":e.endsWith(".txt")?"text/plain":"application/octet-stream"}function bP(t){return(t.parts||[]).filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function yP(t){if(!t)return null;let e=/```(?:json)?\s*\n([\s\S]*?)```/gi,n,o=null;for(;(n=e.exec(t))!==null;)o=n[1].trim();return o}function xP(t){if(!t)return t;let e=/```(?:json)?\s*\n[\s\S]*?```/gi,n=Array.from(t.matchAll(e)),o=t;if(n.length>0){let i=n[n.length-1],s=i.index??-1,a=s+i[0].length;s!==-1&&/^\s*$/.test(o.slice(a))&&(o=o.slice(0,s))}if((o.match(/```/g)||[]).length%2===1){let i=o.lastIndexOf("```");i!==-1&&(o=o.slice(0,i))}return o.trim()}var Qh="AiEditModal";function Rw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(Qh,{...e,title:n.title||"Edit with AI (Experimental)",innerProps:n,size:"calc(min(1920px, calc(100% - 96px)))",centered:!0})},close:()=>{t.closeModal(Qh)}}}function vP(t){let{innerProps:e,context:n,id:o}=t,r=J(null),i=X(()=>JSON.stringify(e.data||{},null,2),[e.data]),[s,a]=L(i),l=X(()=>{if(!s)return null;try{return JSON.parse(s)}catch{return null}},[s]),c=X(()=>s!==i,[s,i]),d=De(()=>{if(!l)return;let p=Hd(l);e.onSave&&e.onSave(p)},[l]),u=De(p=>{if(p?.data){let h=JSON.stringify(p.data,null,2);a(h),r.current?.click()}},[]);return f("div",{className:"AiEditModal",children:[f("div",{className:"AiEditModal__SplitPanel",children:[f("div",{className:"AiEditModal__SplitPanel__ChatPanel",children:f(Lw,{editModeData:l,onEditModeResponse:u,children:[f("p",{children:"Tell me what you want to change. I can make simple text edits, replace content within a module, or answer questions about the content."}),f("p",{children:"Just enter simple instructions, or attach a screenshot and ask me to use it as reference."})]})}),f("div",{className:"AiEditModal__SplitPanel__JsonPanel",children:f(Od,{className:"AiEditModal__Tabs",grow:!0,children:[f(Od.Tab,{label:"JSON",icon:f(RE,{size:20}),children:f("div",{className:"AiEditModal__JsonEditor",children:f(kd,{value:s,onChange:p=>a(p),formatOnBlur:!0,height:"100%",className:"AiEditModal__JsonInput"})})}),f(Od.Tab,{ref:r,label:"Diff",icon:f(SE,{size:20}),children:f("div",{className:"AiEditModal__JsonDiffViewer",children:e.data&&s&&f(ow,{oldCode:i,newCode:s})})})]})})]}),f("div",{className:"AiEditModal__buttons",children:[f(Z,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>n.closeModal(o),children:"Cancel"}),f(Z,{variant:"default",size:"xs",type:"button",leftIcon:f(li,{size:16}),disabled:!c,onClick:()=>a(i),children:"Reset"}),f(Z,{leftIcon:f(es,{size:16}),variant:"filled",size:"xs",color:"green",disabled:!l||!c,onClick:d,children:"Accept changes"})]})]})}vP.id=Qh;var eg="AssetPickerModal";function Pw(){let t=null;try{t=St()}catch{t=null}let e=ot();return{enabled:t!==null,open:n=>{if(!t){console.warn("useAssetPickerModal() requires a <ModalsProvider> context.");return}t.openContextModal(eg,{...e,title:"Select from asset library",innerProps:n,size:"800px",overflow:"inside"})},close:()=>{t?.closeModal(eg)}}}function CP(t){let{innerProps:e,context:n,id:o}=t;function r(i){e.onSelect&&e.onSelect(i),n.closeModal(o)}return f("div",{className:"AssetPickerModal",children:f(fw,{mode:"pick",accept:e.accept,initialFolder:e.initialFolder,onFolderChange:YC,onPickFile:r})})}CP.id=eg;ke();var tg="ComponentPickerModal",EP="root::ComponentPickerModal:layout",wP=3;function Fw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(tg,{...e,innerProps:n,size:"720px",overflow:"inside",title:"Select a component"})},close:()=>{t.closeModal(tg)}}}function ng(t){let{innerProps:e}=t,[n,o]=L(""),[r,i]=hw(EP,"list"),[s,a]=L(0),l=J(null),c=X(()=>{let h=n.trim().toLowerCase();return h?e.options.filter(g=>[g.schema.name,g.schema.label,g.schema.description,g.preset?.id,g.preset?.label,g.preset?.description].filter(Boolean).join(" ").toLowerCase().includes(h)):e.options},[e.options,n]);F(()=>{a(c.length>0?0:-1)},[c]),F(()=>{if(s<0||!l.current)return;l.current.querySelectorAll(".ComponentPickerModal__Card")[s]?.scrollIntoView({block:"nearest"})},[s]);function d(h){if(c.length===0)return;let g=r==="grid"?wP:1,m=c.length-1;if(h.key==="ArrowDown")h.preventDefault(),a(_=>Math.min(m,Math.max(0,_)+g));else if(h.key==="ArrowUp")h.preventDefault(),a(_=>Math.max(0,_-g));else if(h.key==="ArrowRight"&&r==="grid")h.preventDefault(),a(_=>Math.min(m,Math.max(0,_)+1));else if(h.key==="ArrowLeft"&&r==="grid")h.preventDefault(),a(_=>Math.max(0,_-1));else if(h.key==="Enter"&&s>=0){let _=c[s];_&&(h.preventDefault(),e.onSelect(_))}}let u=!!e.onRemove&&!n.trim();return f("div",{className:`ComponentPickerModal ${r==="grid"?"ComponentPickerModal--grid":"ComponentPickerModal--list"}`,onKeyDown:d,children:[f("div",{className:"ComponentPickerModal__controls",children:[f(Xn,{"data-autofocus":!0,placeholder:e.searchPlaceholder||"Search components...",value:n,onChange:h=>o(h.target.value),icon:f(eu,{size:16}),size:"xs",className:"ComponentPickerModal__controls__search"}),f(Dd,{className:"ComponentPickerModal__controls__layout",size:"xs",value:r,onChange:h=>i(h),data:[{value:"list",label:f("span",{className:"ComponentPickerModal__controls__layout__option","aria-label":"List layout",title:"List layout",children:f(BE,{size:14})})},{value:"grid",label:f("span",{className:"ComponentPickerModal__controls__layout__option","aria-label":"Grid layout",title:"Grid layout",children:f(FE,{size:14})})}]})]}),c.length===0?f("div",{className:"ComponentPickerModal__empty",children:e.options.length===0?"No component types available.":"No components match your search."}):f("div",{className:"ComponentPickerModal__cards",ref:l,children:c.map((h,g)=>f(ng.Card,{option:h,layout:r,focused:g===s,onMouseEnter:()=>a(g),onSelect:()=>e.onSelect(h)},h.key))}),u&&f("div",{className:"ComponentPickerModal__footer",children:f(Z,{variant:"subtle",color:"red",size:"xs",leftIcon:f(Zn,{size:14}),onClick:()=>e.onRemove?.(),children:"Clear selection"})})]})}ng.Card=t=>{let{schema:e,preset:n}=t.option,o=n?.label||n?.id||e.label||e.name,r=n?.description??e.description??"",i=n?.image||e.image,s=n?e.label||e.name:"",l=t.layout==="grid"?180:120,c=t.layout==="grid"?120:90,d=["ComponentPickerModal__Card",t.focused?"ComponentPickerModal__Card--focused":""].filter(Boolean).join(" ");return f("button",{type:"button",className:d,onClick:t.onSelect,onMouseEnter:t.onMouseEnter,children:[f("div",{className:"ComponentPickerModal__Card__image",children:f(ea,{src:i,width:l,height:c,withPlaceholder:!i,alt:o})}),f("div",{className:"ComponentPickerModal__Card__content",children:[s&&f("div",{className:"ComponentPickerModal__Card__content__subtitle",children:s}),f("div",{className:"ComponentPickerModal__Card__content__title",children:o}),r&&f("div",{className:"ComponentPickerModal__Card__content__description",children:r})]})]})};ng.id=tg;ke();var og="EditJsonModal";function rg(){let t=St(),e=ot();return{open:n=>{t.openContextModal(og,{...e,title:n.title||"Edit JSON",innerProps:n,size:"680px",centered:!0})},close:()=>{t.closeModal(og)}}}function TP(t){let{innerProps:e,context:n,id:o}=t,r=JSON.stringify(e.data||{},null,2),[i,s]=L(r),[a,l]=L(!0),[c,d]=L(!1),[u,p]=L(!1);function h(_){s(_),d(!1);try{JSON.parse(_),l(!0)}catch{l(!1)}p(_!==r)}function g(){navigator.clipboard.writeText(i).then(()=>d(!0))}function m(){let _=JSON.parse(i),b=Hd(_);e.onSave&&e.onSave(b)}return f("div",{className:"EditJsonModal",children:[f(kd,{value:i,onChange:h,formatOnBlur:!0,autosize:!0,minRows:4,maxRows:25}),f("div",{className:"EditJsonModal__buttons",children:[f(Z,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>n.closeModal(o),children:"Cancel"}),f(Z,{leftIcon:f(Vd,{size:16}),variant:"filled",size:"xs",color:"dark",disabled:!a,type:"button",onClick:g,children:c?"Copied!":"Copy"}),f(Z,{variant:"default",size:"xs",type:"button",leftIcon:f(li,{size:16}),disabled:!u,onClick:()=>{s(r),l(!0),p(!1)},children:"Reset"}),f(Z,{leftIcon:f(wE,{size:16}),variant:"filled",size:"xs",color:"blue",disabled:!a||!u,onClick:m,children:"Save"})]})]})}TP.id=og;ke();ke();function $w(t){let{docId:e,deepKey:n,translatable:o}=t,[r,i]=L(!0),[s,a]=L([]),l=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return F(()=>{async function c(){i(!0);let[d,u]=await Promise.all([lE(e),cE(e,"draft")]),p=d.versions,h=[];if(u){let m=yn(u,n);h.push({value:Bw(m),modifiedBy:u.sys?.modifiedBy||"Unknown",modifiedAt:u.sys?.modifiedAt?.toDate?.()||new Date,versionId:"draft"})}for(let m of p){let _=yn(m,n);h.push({value:Bw(_),modifiedBy:m.sys?.modifiedBy||"Unknown",modifiedAt:m.sys?.modifiedAt?.toDate?.()||new Date,versionId:m._versionId})}let g=[];for(let m of h){let _=g[g.length-1];(!_||_.value!==m.value)&&g.push(m)}a(g),i(!1)}c()},[e,n]),r?f("div",{className:"FieldHistory__loading",children:f(xt,{size:"sm"})}):s.length===0?f("div",{className:"FieldHistory__empty",children:"No history available."}):f("div",{className:"FieldHistory",children:s.map((c,d)=>f("div",{className:"FieldHistory__entry",children:[f("div",{className:"FieldHistory__entry__header",children:[f("span",{className:"FieldHistory__entry__author",children:c.modifiedBy}),f("span",{className:"FieldHistory__entry__date",children:l.format(c.modifiedAt)}),d===0&&f("span",{className:"FieldHistory__entry__badge",children:"Current"}),o&&c.value&&f("span",{className:"FieldHistory__entry__translationsLink",children:f(SP,{value:c.value})})]}),f("div",{className:"FieldHistory__entry__value",children:c.value||f("span",{className:"FieldHistory__entry__empty",children:"(empty)"})})]},c.versionId))})}function SP(t){let[e,n]=L("");return F(()=>{Er(t.value).then(o=>{n(`/cms/translations/${o}`)})},[t.value]),e?f(we,{label:"Open in Translations Editor",withArrow:!0,position:"right",children:f(Ae,{component:"a",href:e,target:"_blank",variant:"transparent",size:"sm",children:f(ts,{size:16})})}):null}function Bw(t){return t==null?"":typeof t=="string"?t:JSON.stringify(t)}var ig="EditTranslationsModal";function Hw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(ig,{...e,innerProps:n,size:"900px",title:"Edit translations",overflow:"inside",className:"EditTranslationsModalWrap"})},close:()=>{t.closeModal(ig)}}}function sg(t){let{innerProps:e,context:n,id:o}=t,r=e.strings||[],i=window.__ROOT_CTX.rootConfig.i18n||{},s=Ll(i.locales||["en"]),[a,l]=L({}),[c,d]=L([]),[u,p]=L(!1),[h,g]=L(!1),[m,_]=L(!0),[b,y]=L(!1),[v,x]=L(""),[C,E]=L(!1),[k,T]=L("translations"),w=e.draft||null;F(()=>{if(e.field?.deepKey&&w?.controller){let A=zw(e.field.deepKey),I=w.controller.getValue(A)||{};y(I.translate===!1),x(I.description||"")}},[e.field?.deepKey,w?.controller]),F(()=>{ZC({tags:[e.docId]}).then(A=>{let I={};Object.values(A).forEach(R=>{let $={source:R.source};s.forEach(W=>{let P=Rl(R,W);P&&($[W]=P)}),I[R.source]=$}),l(I),_(!1)})},[e.docId]);async function S(){g(!0),await vr(async()=>{let A=`edit-translations-${e.docId}`;if(ae({id:A,loading:!0,title:"Saving translations",message:`Updating for ${e.docId}...`,autoClose:!1,disallowClose:!0}),e.field?.deepKey&&w?.controller){let I=zw(e.field.deepKey),R=w.controller.getValue(I)||{};b?R.translate=!1:delete R.translate,v?R.description=v:delete R.description,Object.keys(R).length>0?await w.controller.updateKey(I,R):await w.controller.removeKey(I),await w.controller.flush()}if(!b&&c.length>0){let I=[];c.forEach(R=>{let $=a[R];I.push($)}),await ra(e.docId,I)}kt({id:A,title:"Saved translations",message:`Updated translations for ${e.docId}!`,autoClose:!1})}),g(!1)}function N(A){l(I=>{let R={...I};return R[A.source]=A,R}),d(I=>{let R=new Set(I);return R.add(A.source),Array.from(R)}),p(!0)}async function D(){if(r.length!==0){E(!0);try{await vr(async()=>{for(let A of r){let I=a[A]||{source:A},R={};s.forEach(q=>{I[q]&&(R[q]=I[q])});let $=s.filter(q=>!I[q]);if($.length===0)continue;let W=await window.fetch("/cms/api/ai.translate",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:A,targetLocales:$,description:v||void 0,existingTranslations:R})});if(W.status!==200){let q=await W.text();throw new Error(`Translation failed: ${q}`)}let P=await W.json();if(P.success&&P.translations){let q={...I};Object.entries(P.translations).forEach(([de,rt])=>{q[de]=rt}),N(q)}}ae({message:"Finished generating AI translations",color:"green"})})}finally{E(!1)}}}function O(){if(!Io())return!1;for(let A of r){let I=a[A]||{};for(let R of s)if(!I[R])return!0}return!1}return f("div",{className:"EditTranslationsModal",children:[m?f(xt,{}):f(Ne,{children:[e.field?.deepKey&&f("div",{className:"EditTranslationsModal__tabs",children:[f("button",{type:"button",className:xe("EditTranslationsModal__tabs__tab",k==="translations"&&"active"),onClick:()=>T("translations"),children:"Translations"}),f("button",{type:"button",className:xe("EditTranslationsModal__tabs__tab",k==="history"&&"active"),onClick:()=>T("history"),children:"History"})]}),k==="history"&&e.field?.deepKey?f($w,{docId:e.docId,deepKey:e.field.deepKey,translatable:!0}):f(Ne,{children:[f("div",{className:"EditTranslationsModal__controls",children:[f("div",{className:"EditTranslationsModal__controls__doNotTranslate",children:[f(fo,{label:"Do not translate",checked:b,onChange:A=>{y(A.currentTarget.checked),p(!0)},size:"sm"}),f(we,{label:"Prevent the string from being included for translation",withArrow:!0,position:"right",children:f($l,{size:14,style:{marginLeft:"6px"}})})]}),f("div",{className:"EditTranslationsModal__controls__description",children:[f("div",{className:"EditTranslationsModal__controls__description__label",children:[f("span",{children:"Description"}),f(we,{label:"Translator notes may be included when the string is extracted and sent for translation",withArrow:!0,position:"right",children:f($l,{size:14,style:{marginLeft:"6px"}})})]}),f(bn,{size:"sm",autosize:!0,minRows:1,maxRows:6,value:v,placeholder:"Add context or notes for translators...",onChange:A=>{x(A.currentTarget.value),p(!0)}})]})]}),f("table",{className:"EditTranslationsModal__table",children:[f("thead",{style:{display:b?"none":"table-header-group"},children:f("tr",{children:[f("th",{children:f(wr,{size:"h4",weight:"semi-bold",children:"SOURCE"})}),f("th",{children:f("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f(wr,{size:"h4",weight:"semi-bold",children:"TRANSLATIONS"}),O()&&f(we,{label:"Generate quick translations using AI",withArrow:!0,position:"left",children:f(Ae,{variant:"outline",onClick:D,loading:C,disabled:C,sx:{height:30,width:30,borderColor:"#ced4da"},children:C?f(Xd,{size:16}):f(Oo,{size:16,fill:"currentColor",stroke:1.5})})})]})})]})}),f("tbody",{children:r.map(A=>f("tr",{style:{display:b?"none":"table-row"},children:[f("td",{children:f("div",{className:"EditTranslationsModal__table__source",children:A})}),f("td",{children:f(sg.StringsEditor,{source:A,locales:s,translations:a[A]||{},onChange:N})})]}))})]})]})]}),f("div",{className:"EditTranslationsModal__footer",children:[f("div",{className:"EditTranslationsModal__footer__left",children:[f(Z,{component:"a",href:`/cms/translations/${e.docId}`,target:"_blank",variant:"default",size:"xs",rightIcon:f(Do,{size:14}),children:"Open Translations Editor"}),e.l10nSheet&&f("div",{className:"EditTranslationsModal__footer__gsheet",children:[f("strong",{children:"NOTE:"})," Translations for this doc are managed in"," ",f("a",{href:oa(e.l10nSheet),target:"_blank",rel:"noopener noreferrer",children:"Google Sheets"})]})]}),f("div",{className:"EditTranslationsModal__footer__buttons",children:[f(Z,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>n.closeModal(o),children:"Cancel"}),f(Z,{variant:"filled",size:"xs",color:"dark",onClick:()=>S(),disabled:!u,loading:h,children:"Save"})]})]})]})}sg.StringsEditor=t=>{let e=t.locales,[n,o]=L(t.translations||{}),[r,i]=L(!1);F(()=>{o(t.translations||{})},[t.translations]);function s(a,l){i(!0),o(c=>{let d={...c,source:t.source};return d[a]=l,d})}return F(()=>{r&&t.onChange(n)},[r,n]),f("div",{className:"EditTranslationsModal__StringsEditor",children:e.map(a=>f("div",{className:"EditTranslationsModal__StringsEditor__row",children:[f("div",{className:"EditTranslationsModal__StringsEditor__row__locale",children:a}),f("div",{className:xe("EditTranslationsModal__StringsEditor__row__translation",n[a]?"hasValue":"empty"),children:f(bn,{size:"xs",radius:0,autosize:!0,minRows:1,maxRows:10,value:n[a],onChange:l=>{s(a,l.currentTarget.value)}})})]}))})};sg.id=ig;function zw(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}yr();ke();var Uw="ExportSheetModal";function Kw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(Uw,{...e,title:"Export to Google Sheet",innerProps:n,size:"650px"})}}}function ag(t){let{innerProps:e,context:n,id:o}=t,[r,i]=L(!1),[s,a]=L("new-sheet"),[l,c]=L(""),[d,u]=L(!1),p=la(),h=bw(),g=J(),m=UC(h.settings.googleDriveFolder),_=[{value:"new-sheet",label:"Create Google Sheet",help:"Creates a new Google Sheet and exports strings to the sheet."},{value:"add-tab",label:"Add tab in Google Sheet",help:"Adds a new tab in an existing Google Sheet and exports strings to the sheet."},{value:"link-sheet",label:"Link Google Sheet",help:"Links an existing Google Sheet without exporting strings."}],b=!1;(s==="add-tab"||s==="link-sheet")&&(b=!0,l&&Fd(l)?.spreadsheetId&&(b=!1));async function y(k,T){let w=T?.isNew||!1,{headers:S,rows:N}=e.csvData;w?(await k.replaceSheet(S,N),await k.applyL10nTheme()):await k.updateValuesMap(N,{keyedBy:"source",preserveColumns:e.locales})}async function v(){p.isLoggedIn()||await p.login();let k=window.__ROOT_CTX.rootConfig,T=k.projectName||k.projectId||"Root CMS",w,S,N="create-google-sheet";try{if(ae({id:N,loading:!0,title:"Creating Google Sheet...",message:"Creating Google Sheet for localization.",autoClose:!1,disallowClose:!0}),w=await na.create({title:`${T} Localization`,parent:m,share:g.current?.checked}),S=await w.getSheet(0),!S)throw new Error("could not find sheet gid=0");S.setTitle(e.docId)}catch(D){console.error(D);let O=D;typeof D=="object"&&D.body&&(O=String(D.body)),kt({id:N,title:"Failed to create Google Sheet",message:String(O),color:"red",autoClose:!1});return}try{kt({id:N,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let D={spreadsheetId:w.spreadsheetId,gid:0};await $d(e.docId,D)}catch(D){console.error(D),kt({id:N,title:"Failed to link Google Sheet",message:String(D),color:"red",autoClose:!1});return}try{kt({id:N,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await y(S,{isNew:!0})}catch(D){console.error(D);let O=D;typeof D=="object"&&D.body&&(O=String(D.body)),kt({id:N,title:"Failed to export strings to Google Sheet",message:O,color:"red",autoClose:!1});return}c(S.getUrl()),u(!0),kt({id:N,title:"Done! Exported strings to Google Sheet.",message:w.getUrl(),autoClose:!1})}async function x(){p.isLoggedIn()||await p.login();let k=Fd(l);if(!k?.spreadsheetId)throw new Error("failed to parse spreadsheet id");let T=new na(k.spreadsheetId),w,S="add-tab-google-sheet";try{ae({id:S,loading:!0,title:"Creating tab in Google Sheet...",message:"Adding tab in existing Google Sheet",autoClose:!1,disallowClose:!0}),w=await T.createSheet({title:e.docId})}catch(N){console.error(N);let D=N;typeof N=="object"&&N.body&&(D=String(N.body)),kt({id:S,title:"Failed to create Google Sheet",message:String(D),color:"red",autoClose:!1});return}try{kt({id:S,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let N={spreadsheetId:T.spreadsheetId,gid:w.gid};await $d(e.docId,N)}catch(N){console.error(N),kt({id:S,title:"Failed to link Google Sheet",message:String(N),color:"red",autoClose:!1});return}try{kt({id:S,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await y(w,{isNew:!0})}catch(N){console.error(N);let D=N;typeof N=="object"&&N.body&&(D=String(N.body)),kt({id:S,title:"Failed to export strings to Google Sheet",message:D,color:"red",autoClose:!1});return}u(!0),kt({id:S,title:"Done! Exported strings to Google Sheet.",message:w.getUrl(),autoClose:!1})}async function C(){let k="link-google-sheet",T=Fd(l);if(!T?.spreadsheetId)throw new Error("failed to parse spreadsheet id");try{ae({id:k,loading:!0,title:"Link Google Sheet",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0}),await $d(e.docId,T)}catch(w){console.error(w),kt({id:k,title:"Failed to link Google Sheet",message:String(w),color:"red",autoClose:!1});return}u(!0),kt({id:k,title:`Done! Linked ${e.docId} to Google Sheet.`,message:oa(T),autoClose:!1})}async function E(){console.log(s),i(!0),s==="new-sheet"?await vr(v):s==="add-tab"?await vr(x):s==="link-sheet"&&await vr(C),i(!1)}return f("div",{className:"ExportSheetModal",children:f("div",{className:"ExportSheetModal__content",children:[f("div",{className:"ExportSheetModal__content__body",children:"Export strings to Google Sheet or link an existing Google Sheet for managing translations."}),f("form",{className:"ExportSheetModal__form",children:[f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Export options:"}),f(Rn,{disabled:d||r,itemComponent:ag.SelectItem,data:_,onChange:k=>{a(k),k==="new-sheet"&&c("")},value:s})]}),f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Google Sheet URL:"}),s==="new-sheet"?f(Xn,{disabled:!0,placeholder:h.settings.googleDriveFolder?"A new Google Sheet will be created in the project's Google Drive folder.":'A new Google Sheet will be created in your "My Drive" folder.'}):f(Xn,{placeholder:"https://docs.google.com/spreadsheets/d/...",value:l,disabled:d||r,onChange:k=>c(k.currentTarget.value)})]}),s==="new-sheet"&&f("div",{className:"ExportSheetModal__form__section",children:f(we,{label:"Whether to share the Google Sheet with Admins and Editors upon creation. If your site has a Google Drive folder configured, the sheet will be created within it and inherit its permissions.",wrapLines:!0,width:320,withArrow:!0,position:"bottom",children:f(fo,{disabled:d||r,ref:g,name:"share",value:"true",label:"Share Google Sheet with collaborators",defaultChecked:!m})})}),f("div",{className:"ExportSheetModal__form__buttons",children:d?f(Ne,{children:[f(Z,{component:"a",target:"_blank",rel:"noopener noreferrer",href:l,variant:"default",size:"xs",color:"dark",rightIcon:f(Do,{size:16}),children:"Open Google Sheet"}),f(Z,{variant:"filled",onClick:()=>n.closeModal(o),type:"button",size:"xs",color:"primary",children:"Done"})]}):f(Ne,{children:[f(Z,{variant:"outline",onClick:()=>n.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(Z,{variant:"filled",size:"xs",color:"primary",loading:r,disabled:b,onClick:()=>E(),children:s==="link-sheet"?"Link Google Sheet":"Export to Google Sheet"})]})})]})]})})}ag.SelectItem=po(t=>{let{label:e,help:n,...o}=t;return f("div",{className:"ExportSheetModal__SelectItem",...o,children:[f(os,{className:"ExportSheetModal__SelectItem__label",size:"body",children:e}),f(os,{className:"ExportSheetModal__SelectItem__help",size:"body-sm",children:n})]})});ag.id=Uw;ke();ke();function jw(t){let{labels:e}=t,[n,o]=L(0);return F(()=>{let r=setTimeout(()=>{o(i=>(i+1)%e.length)},2e3);return()=>clearTimeout(r)},[n,e.length]),f("div",{className:"ProgressiveLoader",children:[f(xt,{color:"gray",size:"md"}),f("div",{className:"ProgressiveLoader__labels",children:f(Bt,{size:"sm",color:"dimmed",className:"ProgressiveLoader__label--entering",children:e[n]},n)})]})}var Vw="LocalizationModal";function Ww(){let t=St(),e=ot();return{open:n=>{let o=new URLSearchParams(window.location.search);o.set("modal","localization"),window.history.replaceState(null,"",`${window.location.pathname}?${o}`),t.openContextModal(Vw,{...e,innerProps:n,size:"clamp(80%, 1024px, 1280px)",onClose:()=>{n.draft?.flush({quiet:!0});let r=new URLSearchParams(window.location.search);r.delete("modal");let i=r.toString()?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState(null,"",i)}})}}}function Jo(t){let e=t.innerProps;return f("div",{className:"LocalizationModal",children:f("div",{className:"LocalizationModal__layout",children:[f(Jo.ConfigLocales,{...e}),f(Jo.Translations,{...e})]})})}Jo.id=Vw;Jo.ConfigLocales=t=>{let[e,n]=L(()=>t.draft?t.draft.getLocales():["en"]),o=window.__ROOT_CTX.rootConfig.i18n||{},r=o.locales||["en"],i=o.groups||{default:{label:"",locales:r}};function s(c){return e.filter(d=>(i[c].locales||[]).includes(d))}function a(c,d){let u=new Set(e),p=i[c].locales||[];for(let g of p)d.includes(g)?u.add(g):u.delete(g);let h=Array.from(u.values()).sort();l(h)}function l(c){n(c),t.draft.setLocales(c)}return f("div",{className:"LocalizationModal__locales",children:f(ho,{spacing:30,children:[f(fn,{children:[f(wr,{className:"LocalizationModal__iconTitle LocalizationModal__locales__title",size:"h2",children:[f(jE,{strokeWidth:1.5}),f("span",{children:"Locales"})]}),f(Jo.AllNoneButtons,{onAllClicked:()=>l(r),onNoneClicked:()=>l([])})]}),f(ho,{spacing:40,children:Object.keys(i).map(c=>{let d=i[c],u=s(c);return f(Jo.LocaleGroup,{group:d,groupEnabledLocales:u,allEnabledLocales:e,onChange:p=>a(c,p)})})})]})})};Jo.LocaleGroup=t=>{let e=t.groupEnabledLocales||[],n=t.group.locales||[],o=t.allEnabledLocales||[];function r(s){t.onChange&&t.onChange(s)}function i(s){let a=e.indexOf(s);a===-1?e.push(s):e.splice(a,1),r(e)}return f(ho,{spacing:16,children:[t.group.label&&f(fn,{position:"apart",children:[f(wr,{size:"h4",weight:"semi-bold",children:t.group.label}),f(Jo.AllNoneButtons,{onAllClicked:()=>r(n),onNoneClicked:()=>r([])})]}),f(fn,{children:n.map(s=>{let a=e.includes(s),l=o.length<=1&&a;return f(fo,{value:s,checked:a,disabled:l,label:Gw(s),onChange:()=>i(s),size:"xs"})})})]})};Jo.AllNoneButtons=t=>f(fn,{spacing:"8px",children:[f(Z,{className:"LocalizationModal__allNoneBtn",variant:"subtle",size:"xs",compact:!0,onClick:t.onAllClicked,children:"All"}),"/",f(Z,{className:"LocalizationModal__allNoneBtn",variant:"subtle",size:"xs",compact:!0,onClick:t.onNoneClicked,children:"None"})]});Jo.Translations=t=>{let[e,n]=L(!0),[o,r]=L([]),i=window.__ROOT_CTX.rootConfig.i18n?.locales||[],s=Ll(i),a=t.locale&&tE(t.locale)||s.find(H=>H!=="en")||"en",[l,c]=L(a),[d,u]=L(!1),[p,h]=L({}),g=X(()=>{if(!l)return{};let H={};return Object.values(p).forEach(re=>{H[re.source]=Rl(re,l)}),H},[l,p]),m=la(),[_,b]=L(null),y=Kw(),v=vw(),[x,C]=L(new Set),E=x.size,[k,T]=L({}),[w,S]=L(!1),[N,D]=L(!1),[O,A]=L(null),I=J(!1),R=J(null),$=Object.keys(k).length;function W(H,re,Ce){T(ce=>{let be={...ce};be[H]||(be[H]={}),be[H]={...be[H],[re]:Ce};let je=g[H]||"";return Ce===je&&(delete be[H][re],Object.keys(be[H]).length===0&&delete be[H]),be})}async function P(){S(!0);try{let H=Object.entries(k).map(([ce,be])=>({source:ce,locales:be}));await oE(H,{tags:[t.docId]});let re=await Promise.all(H.map(async ce=>({hash:await Er(ce.source),source:ce.source,locales:ce.locales}))),Ce=[t.docId];h(ce=>{let be={...ce};for(let{hash:je,source:bt,locales:Ft}of re){let pn=be[je],oi=pn?.tags||[],Mn=Array.from(new Set([...oi,...Ce]));pn?be[je]={...pn,...Ft,tags:Mn}:be[je]={source:bt,...Ft,tags:Mn}}return be}),T({}),ae({title:"Saved!",message:`Updated ${H.length} translation(s).`,autoClose:2500})}catch(H){console.error(H),ae({title:"Error saving translations",message:String(H),color:"red",autoClose:!1})}S(!1)}function q(){return!Io()||!l?!1:o.some(H=>{let re=k[H]?.[l];return re!==void 0?!re:!g[H]})}function de(){I.current=!0,R.current?.abort()}async function rt(){if(!(!l||o.length===0)){I.current=!1,D(!0);try{for(let H of o){if(I.current)break;if(k[H]?.[l]||g[H])continue;A(H);let Ce=new AbortController;R.current=Ce;let ce={},be=_t[H];be&&i.forEach(Ft=>{be[Ft]&&(ce[Ft]=be[Ft])});let je=await window.fetch("/cms/api/ai.translate",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:H,targetLocales:[l],existingTranslations:ce}),signal:Ce.signal});if(je.status!==200){let Ft=await je.text();throw new Error(`Translation failed: ${Ft}`)}let bt=await je.json();bt.success&&bt.translations?.[l]&&W(H,l,bt.translations[l])}I.current?ae({message:"AI translation stopped",color:"yellow"}):ae({message:"Finished generating AI translations",color:"green"})}catch(H){H instanceof DOMException&&H.name==="AbortError"||(console.error(H),ae({title:"Error generating translations",message:String(H),color:"red"}))}finally{D(!1),A(null),I.current=!1,R.current=null}}}let Tt=J(!1);F(()=>{if(e)return;if(!Tt.current){Tt.current=!0;return}let H=!1;async function re(){let Ce=[t.docId],ce=await Promise.all(o.map(async je=>({source:je,hash:await Er(je)})));if(H)return;let be=new Set;for(let{source:je,hash:bt}of ce)if(p[bt]){let Ft=p[bt].tags||[];Ce.every(oi=>Ft.includes(oi))||be.add(je)}H||C(be)}return re(),()=>{H=!0}},[t.docId,o,p,e]);let _t=X(()=>{let H={};return Object.values(p).forEach(re=>{H[re.source]=re}),H},[p]),dt=s.map(H=>({value:H,label:Gw(H)})),ut=X(()=>!l||o.length===0?0:o.filter(H=>{let re=k[H]?.[l];return re!==void 0?!re:!g[H]}).length,[o,g,l,k]);F(()=>{n(!0),Promise.all([yw(t.docId),uE(t.docId)]).then(async([H,re])=>{let Ce=[t.docId],ce=await Promise.all(H.map(async bt=>({source:bt,hash:await Er(bt)}))),be=await QC(ce.map(bt=>bt.hash)),je=new Set;for(let{source:bt,hash:Ft}of ce)if(be[Ft]){let pn=be[Ft].tags||[];Ce.every(Mn=>pn.includes(Mn))||je.add(bt)}r(H),h(be),b(re),C(je),n(!1)}).catch(H=>{console.error("Failed to load translations:",H),n(!1),ae({title:"Error",message:String(H?.message||H),color:"red",autoClose:!1})})},[t.docId]);function oe(H,re){let Ce=_t[H];return Ce?Rl(Ce,re):""}function ee(){let H=Ll(i.filter(ce=>!eE(ce))).filter(ce=>ce!=="en"),re=["source","en",...H],Ce=[];return o.forEach(ce=>{let be={source:ce,en:oe(ce,"en")||ce};H.forEach(je=>{be[je]=oe(ce,je)}),Ce.push(be)}),{headers:re,rows:Ce}}async function ye(){let{headers:H,rows:re}=ee(),Ce=await window.fetch("/cms/api/csv.download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:H,rows:re})});if(Ce.status!==200){console.error("csv.download failed:");let je=await Ce.text();console.error(je)}let ce=await Ce.blob(),be=window.URL.createObjectURL(ce);window.location.assign(be),window.URL.revokeObjectURL(be)}async function Fe(){let H=document.createElement("input");H.type="file",H.accept=".csv",H.addEventListener("change",async()=>{let re=H.files?.[0];if(re){let Ce=new FormData;Ce.append("file",re);try{let ce=await fetch("/cms/api/csv.import",{method:"POST",body:Ce});if(ce.status!==200){let bt=await ce.text();throw new Error(`RPCError: ${bt}`)}let be=(await ce.json()).data,je=await ra(t.docId,be);h(bt=>lg(bt,je)),ae({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}catch(ce){console.error(ce),ae({title:"Failed to import CSV",message:String(ce),color:"red",autoClose:!1})}}}),H.click()}async function un(){if(m.isLoggedIn()||await m.login(),!_?.spreadsheetId)throw new Error("no sheet linked");let re=await new na(_.spreadsheetId).getSheet(_.gid??0);if(!re)throw new Error(`sheet not found: ${JSON.stringify(_)}`);await Be(re),ae({title:"Exported strings to Google Sheet",message:re.getUrl(),autoClose:!1})}async function Be(H,re){let Ce=re?.isNew||!1,{headers:ce,rows:be}=ee();Ce?(await H.replaceSheet(ce,be),await H.applyL10nTheme()):await H.updateValuesMap(be,{keyedBy:"source",preserveColumns:s}),Pd("doc.export_to_sheet",{metadata:{docId:t.docId,sheetId:{spreadsheetId:H.spreadsheet.spreadsheetId,gid:H.gid}}})}async function on(){if(m.isLoggedIn()||await m.login(),!_?.spreadsheetId)throw new Error("no sheet linked");let re=await new na(_.spreadsheetId).getSheet(_.gid??0);if(!re)throw new Error(`sheet not found: ${JSON.stringify(_)}`);console.log("importing google sheet");let Ce=await re.getValuesMap(),ce=await ra(t.docId,Ce);h(be=>lg(be,ce)),ae({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}async function kl(){await dE(t.docId),b(null),ae({title:"Unlinked Google Sheet",message:`${t.docId} is no longer connected to a Google Sheet.`,autoClose:5e3})}async function Oh(){n(!0);let H=[],re=[t.docId];for(let Ce of o){let ce=await Er(Ce);if(p[ce]){let be=p[ce].tags||[],je=Array.from(new Set([...be,...re]));H.push({hash:ce,tags:je})}}H.length>0?(await $h(H,{mode:"union"}),h(Ce=>{let ce={...Ce};return H.forEach(({hash:be,tags:je})=>{ce[be]&&(ce[be]={...ce[be],tags:je})}),ce}),ae({title:"Tags Applied",message:`Applied tag "${t.docId}" to ${H.length} string(s).`,color:"green"})):ae({title:"No strings updated",message:"No existing translations found to tag.",color:"blue"}),n(!1)}async function rn(H){try{await H()}catch(re){console.error(re);let Ce;typeof re=="object"&&re.body?Ce=String(re.body):Ce=String(re),ae({title:"Error",message:Ce,color:"red",autoClose:!1})}}function Ed(H){switch(H){case"EXPORT_DOWNLOAD_CSV":{rn(ye);return}case"EXPORT_GOOGLE_SHEET_LINKED":{rn(un);return}case"EXPORT_GOOGLE_SHEET_SHOW_OPTIONS":{y.open({docId:t.docId,csvData:ee(),locales:s});return}case"IMPORT_CSV":{rn(Fe);return}case"IMPORT_GOOGLE_SHEET_LINKED":{rn(on);return}case"UNLINK_GOOGLE_SHEET":{rn(kl);return}default:console.log("unhandled action: "+H)}}async function wd(H,re){let ce=(window.__ROOT_CTX.translations||[]).find(be=>be.id===H)?.label||H;await rn(async()=>{let be=re==="export"?await xw(t.docId):null,je=o.map(pn=>{let oi={};s.forEach(Vt=>{oi[Vt]=oe(pn,Vt)??""});let Mn=be?.get(pn)?.description;return{source:pn,translations:oi,...Mn?{description:Mn}:{}}}),bt=re==="import"||re==="export"?re:(()=>{throw new Error("Invalid translations action")})(),Ft=`translations-${bt}-${H}`;ae({id:Ft,message:re==="import"?`Importing from ${ce}...`:`Exporting to ${ce}...`,loading:!0,autoClose:!1,disallowClose:!0});try{let pn=await window.fetch(`/cms/api/translations.${bt}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:H,docId:t.docId,data:je})});if(!(pn.headers.get("content-type")||"").includes("application/json"))throw new Error(`Unexpected response (${pn.status}). Please reload the page and try again.`);let Mn=await pn.json();if(!Mn.success)throw new Error(Mn.error||"Unknown error");if(re==="import")if(Array.isArray(Mn.data)){let Vt=Mn.data.map(ri=>{let qo={source:String(ri?.source??"")},ii=ri?.translations;return ii&&typeof ii=="object"&&Object.entries(ii).forEach(([Qs,Dl])=>{Dl!=null&&nE(Qs).length!==0&&(qo[Qs]=String(Dl))}),qo}),Nl=await ra(t.docId,Vt,{actionMetadata:{service:H,numStrings:Vt.length,locales:i},actionLinks:[{label:"Open translations",url:`/cms/content/${t.docId}?modal=localization`}]});h(ri=>lg(ri,Nl));let qi=[t.docId],Ln=[];for(let ri of Vt){let qo=await Er(ri.source),Qs=p[qo]?.tags||[],Dl=Array.from(new Set([...Qs,...qi]));Ln.push({hash:qo,tags:Dl})}Ln.length>0&&(await $h(Ln,{mode:"union"}),h(ri=>{let qo={...ri};return Ln.forEach(({hash:ii,tags:Qs})=>{qo[ii]&&(qo[ii]={...qo[ii],tags:Qs})}),qo})),kt({id:Ft,title:"Imported!",message:`Imported translations from ${ce}.`,loading:!1,autoClose:5e3})}else{let Vt=Mn.data||{},Nl=Vt.title||"Import complete",qi=Vt.message||`Imported translations from ${ce}.`,Ln=Vt.link;kt({id:Ft,title:Nl,color:Vt.status==="success"?"green":Vt.status==="error"?"red":void 0,message:Ln?.url?f("div",{children:[f("div",{children:qi}),f(Z,{component:"a",href:Ln.url,target:"_blank",rel:"noopener noreferrer",size:"xs",variant:"default",rightIcon:f(ia,{size:14}),style:{marginTop:"8px"},children:Ln.label||"Open"})]}):qi,loading:!1,autoClose:Ln?.url?1e4:5e3})}else{let Vt=Mn.data||{},Nl=Vt.title||"Exported!",qi=Vt.message||`Exported translations to ${ce}.`,Ln=Vt.link;kt({id:Ft,title:Nl,color:Vt.status==="success"?"green":Vt.status==="error"?"red":void 0,message:Ln?.url?f("div",{children:[f("div",{children:qi}),f(Z,{component:"a",href:Ln.url,target:"_blank",rel:"noopener noreferrer",size:"xs",variant:"default",rightIcon:f(ia,{size:14}),style:{marginTop:"8px"},children:Ln.label||"Open"})]}):qi,loading:!1,autoClose:Ln?.url?1e4:5e3})}}catch(pn){throw Il(Ft),pn}})}return f("div",{className:"LocalizationModal__translations",children:[f("div",{className:"LocalizationModal__translations__topWrapper",children:[f("div",{className:"LocalizationModal__translations__header",children:[f("div",{className:"LocalizationModal__translations__titleWrap",children:f(wr,{className:"LocalizationModal__translations__title LocalizationModal__iconTitle",size:"h2",children:[f(ts,{strokeWidth:1.5})," ",f("span",{children:"Translations"})]})}),f("div",{className:"LocalizationModal__translations__header__buttons",children:[m.enabled&&_?.spreadsheetId&&f(we,{label:"Open Google Sheet",children:f(Ae,{component:"a",href:oa(_),target:"_blank",variant:"filled",color:"green",size:"sm",children:f(ru,{size:16,strokeWidth:2.25})})}),f(Z,{component:"a",href:`/cms/translations/${t.docId}`,target:"_blank",variant:"default",size:"xs",rightIcon:f(ia,{size:14,strokeWidth:1.75}),children:"Open Editor"}),f(NP,{onAction:Ed,onServiceAction:wd,gapiClient:m,linkedSheet:_}),f(DP,{onAction:Ed,onServiceAction:wd,gapiClient:m,linkedSheet:_}),f(G,{className:"LocalizationModal__translations__menu",control:f(we,{label:"Tools",children:f(Ae,{className:"LocalizationModal__translations__menu__dots",variant:"default",children:f(Yh,{size:16})})}),size:220,children:f(G.Item,{className:"LocalizationModal__translations__menu__item",icon:f(XE,{size:16}),onClick:()=>v.open({docId:t.docId,sourceStrings:o,onPruned:H=>{h(re=>{let Ce={...re};return H.forEach(ce=>delete Ce[ce]),Ce})}}),children:"Prune unused strings"})})]})]}),e&&f(jw,{labels:["Transmogrifying...","Deciphering the vibes...","Consulting the Rosetta Stone...","Untangling the syntax...","Babel-ing..."]}),!e&&E>0&&f("div",{className:"LocalizationModal__missingTags",children:[f("div",{className:"LocalizationModal__missingTags__message",children:[f(Pl,{}),E>1?f(Bt,{size:"sm",children:[f("b",{children:[E," strings"]}),' are missing the "',t.docId,'" tag.']}):f(Bt,{size:"sm",children:[f("b",{children:[E," string"]}),' is missing the "',t.docId,'" tag.']})]}),f(Z,{variant:"filled",size:"xs",onClick:()=>rn(Oh),loading:e,leftIcon:f(Yh,{size:16}),children:"Fix missing tags"})]}),!e&&f("table",{className:"LocalizationModal__translations__table",children:[f("tr",{className:"LocalizationModal__translations__table__row LocalizationModal__translations__table__row--header",children:[f("th",{className:"LocalizationModal__translations__table__header",children:f(wr,{size:"h4",weight:"semi-bold",children:"SOURCE STRING"})}),f("th",{className:"LocalizationModal__translations__table__header",children:f("div",{className:"LocalizationModal__translations__localeHeader",children:[f(wr,{className:"LocalizationModal__translations__localeSelect",size:"h4",weight:"semi-bold",children:[f("span",{children:"LOCALE: "})," ",f(Rn,{data:dt,size:"xs",placeholder:"select locale",allowDeselect:!0,value:l,onChange:H=>c(H)})]}),f("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[l&&ut>0&&f(we,{label:d?"Show all translations":"Show only missing translations",position:"top",withArrow:!0,children:f("button",{className:`LocalizationModal__translations__missingToggle${d?" LocalizationModal__translations__missingToggle--active":""}`,onClick:()=>u(H=>!H),children:[f(NE,{size:14}),f("span",{children:[ut," missing"]})]})},d?"active":"inactive"),l&&o.length>0&&ut===0&&$===0&&f("div",{className:"LocalizationModal__translations__fullyTranslated",children:[f(es,{size:14}),f("span",{children:"Translated"})]}),q()&&!N&&f(we,{label:"Generate translations using AI",withArrow:!0,position:"top",children:f(Ae,{variant:"default",size:"sm",onClick:rt,children:f(Oo,{size:14,fill:"black"})})}),N&&f(we,{label:"Stop generating",withArrow:!0,position:"top",children:f(Ae,{variant:"default",size:"sm",onClick:de,children:f(YE,{size:14,fill:"black"})})}),N&&f(Xd,{size:18,className:"LocalizationModal__spinner"})]})]})})]}),o.filter(H=>!d||!l?!0:!g[H]).map((H,re)=>f("tr",{className:"LocalizationModal__translations__table__row",children:[f("td",{className:"LocalizationModal__translations__table__col",children:f("div",{className:"LocalizationModal__sourceCell",children:[f("span",{className:"LocalizationModal__sourceCell__text",children:H}),(_t[H]||x.has(H))&&f("div",{className:"LocalizationModal__sourceCell__icons",children:[_t[H]&&f(Ae,{className:"LocalizationModal__sourceCell__link",size:"sm",variant:"subtle",onClick:async()=>{let Ce=await Er(H);window.open(`/cms/translations/${Ce}`,"_blank")},children:f(Do,{size:16})}),x.has(H)&&f(we,{label:`Missing "${t.docId}" tag`,position:"top",withArrow:!0,children:f(Ae,{className:"LocalizationModal__sourceCell__missingTag",size:"sm",variant:"subtle",children:f(Pl,{size:14})})})]})]})}),f("td",{className:"LocalizationModal__translations__table__col",children:f(kP,{source:H,locale:l,savedValue:g[H]||"",pendingValue:k[H]?.[l],isAiGenerating:O===H,readOnly:N,onEdit:Ce=>W(H,l,Ce)})})]},re))]})]}),f("div",{className:"LocalizationModal__translations__saveBar",children:[f("span",{className:"LocalizationModal__translations__saveBar__status",children:$>0?`${$} unsaved change${$!==1?"s":""}`:""}),$>0&&f(Z,{variant:"default",size:"xs",leftIcon:f(li,{size:14}),onClick:()=>T({}),children:"Discard changes"}),f(Z,{variant:"filled",size:"xs",color:"dark",leftIcon:f(es,{size:14}),onClick:P,loading:w,disabled:$===0,children:"Save"})]})]})};function kP(t){let e=t.pendingValue!==void 0?t.pendingValue:t.savedValue,o=[t.pendingValue!==void 0?"LocalizationModal__translations__cell--edited":"",t.isAiGenerating?"LocalizationModal__translations__cell--ai-generating":"",e?"":"LocalizationModal__translations__cell--empty"].filter(Boolean).join(" ")||void 0;return f(bn,{size:"xs",autosize:!0,minRows:1,value:e,placeholder:"",readOnly:t.readOnly,onChange:r=>t.onEdit(r.currentTarget.value),className:o,styles:{root:{height:"100%"},wrapper:{height:"100%"},input:{fontSize:"12px",minHeight:"100%"}}})}function NP(t){function e(r){t.onAction&&t.onAction(r)}let n=t.linkedSheet,o=(window.__ROOT_CTX.translations||[]).filter(r=>r.hasImport);return f(G,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"end",control:f(Z,{variant:"default",color:"dark",size:"xs",leftIcon:f(Bl,{size:16,strokeWidth:1.75}),rightIcon:f(go,{size:16,strokeWidth:1.75}),children:"Import"}),children:[t.gapiClient.enabled&&f(Ne,{children:[f(G.Label,{children:"Google Sheets"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",disabled:!n?.spreadsheetId,onClick:()=>e("IMPORT_GOOGLE_SHEET_LINKED"),children:"Import Google Sheet"}),f(xr,{})]}),f(G.Label,{children:"File"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("IMPORT_CSV"),children:"Import .csv"}),o.length>0&&f(Ne,{children:[f(xr,{}),f(G.Label,{children:"Services"}),o.map(r=>f(G.Item,{className:"LocalizationModal__translations__menu__item",icon:r.icon?f("img",{src:r.icon,alt:r.label,style:{width:16,height:16}}):void 0,onClick:()=>t.onServiceAction?.(r.id,"import"),children:["Import from ",r.label]},r.id))]})]})}function DP(t){async function e(i){t.onAction&&t.onAction(i)}let o=!!t.linkedSheet?.spreadsheetId,r=(window.__ROOT_CTX.translations||[]).filter(i=>i.hasExport);return f(G,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"start",control:f(Z,{variant:"default",color:"dark",size:"xs",leftIcon:f(kE,{size:16,strokeWidth:1.75}),rightIcon:f(go,{size:16,strokeWidth:1.75}),children:"Export"}),children:[t.gapiClient.enabled&&f(Ne,{children:[f(G.Label,{children:"Google Sheets"}),o?f(Ne,{children:f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_LINKED"),children:"Export to Google Sheet"})}):f(Ne,{children:f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_SHOW_OPTIONS"),children:"Export to Google Sheet"})}),f(xr,{})]}),f(G.Label,{children:"File"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_DOWNLOAD_CSV"),children:"Download .csv"}),r.length>0&&f(Ne,{children:[f(xr,{}),f(G.Label,{children:"Services"}),r.map(i=>f(G.Item,{className:"LocalizationModal__translations__menu__item",icon:i.icon?f("img",{src:i.icon,alt:i.label,style:{width:16,height:16}}):void 0,onClick:()=>t.onServiceAction?.(i.id,"export"),children:["Export to ",i.label]},i.id))]}),o&&f(Ne,{children:[f(xr,{}),f(G.Label,{children:"Danger zone"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("UNLINK_GOOGLE_SHEET"),color:"red",children:"Unlink Google Sheet"})]})]})}function lg(t,e){let n={...t};for(let[o,r]of Object.entries(e)){let i=n[o];n[o]=i?{...i,...r}:r}return n}function Gw(t){let e=t.split("_"),n=e[0];if(n==="ALL"){let i=String(e[1]).toUpperCase();return`${new Intl.DisplayNames(["en"],{type:"region"}).of(i)||t} (${t})`}return`${new Intl.DisplayNames(["en"],{type:"language"}).of(n)||t} (${t})`}ke();function Yw(t){let e=new Set;return cg(t,e),Array.from(e)}function cg(t,e){if(!(!t||typeof t!="object")){if(Array.isArray(t)){for(let n of t)cg(n,e);return}if(OP(t)){e.add(t.id);return}for(let n of Object.keys(t))cg(t[n],e)}}function OP(t){return typeof t.id=="string"&&typeof t.collection=="string"&&typeof t.slug=="string"&&t.id.includes("/")}var qw="PublishDocModal";function Jw(t){let e=St(),n=ot();return{open:()=>{e.openContextModal(qw,{...n,title:`Publish ${t.docId}`,innerProps:t,size:"850px"})}}}function IP(t){let{innerProps:e,context:n,id:o}=t,[r,i]=L(""),[s,a]=L(""),[l,c]=L(!1),[d,u]=L(""),[p,h]=L(!1),g=J(null),m=St(),_=ot(),b=Io(),{roles:y,loading:v}=su(),x=window.firebase.user.email||"",C=au(y,x),E=r==="scheduled"?"Schedule":"Publish";async function k(){try{c(!0),await rE(e.docId,{publishMessage:d.trim()||void 0}),c(!1),ae({title:"Published!",message:`Succesfully published ${e.docId}.`,autoClose:1e4}),m.closeAll()}catch(D){console.error(D);let O=Al(D);ae({title:"Publish failed",message:`Failed to publish ${e.docId}: ${O}`,color:"red",autoClose:!1})}}async function T(){try{c(!0);let D=Math.floor(new Date(s).getTime());await iE(e.docId,D,{publishMessage:d.trim()||void 0}),c(!1),ae({title:"Scheduled!",message:`${e.docId} will go live ${s}.`,autoClose:1e4}),m.closeAll()}catch(D){console.error(D);let O=Al(D);ae({title:"Schedule failed",message:`Failed to schedule ${e.docId}: ${O}`,color:"red",autoClose:!1})}}async function w(){try{h(!0);let O=await(await window.fetch("/cms/api/ai.publish_message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({docId:e.docId})})).json();O.success&&O.message?u(O.message):ae({title:"Generation failed",message:"Failed to generate publish message.",color:"red",autoClose:5e3})}catch(D){console.error(D),ae({title:"Generation failed",message:"Failed to generate publish message.",color:"red",autoClose:5e3})}finally{h(!1)}}function S(){m.openConfirmModal({..._,title:`${E} ${e.docId}`,children:f(Ne,{children:[f(os,{size:"body-sm",weight:"semi-bold",className:"PublishDocModal__confirmText",children:["Are you sure you want to publish the following doc? The doc will go live ",r==="now"?"now":`at ${s}`,"."]}),f(Cw,{docId:e.docId})]}),labels:{confirm:E,cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{r==="now"?k():r==="scheduled"&&T()}})}let N=!0;return(r==="now"||r==="scheduled"&&s)&&(N=!1),(v||!C)&&(N=!0),f("div",{className:"PublishDocModal",children:f("div",{className:"PublishDocModal__content",children:[f("form",{className:"PublishDocModal__form",onSubmit:D=>{D.preventDefault(),S()},children:[f("div",{className:"PublishDocModal__form__publishOptions",children:f("div",{className:"PublishDocModal__form__publishOptions__options",children:[f("label",{className:xe("PublishDocModal__form__publishOptions__option",r==="now"&&"PublishDocModal__form__publishOptions__option--selected",r&&r!=="now"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"now",checked:r==="now",onChange:()=>i("now")})," ","Now"]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live immediately."})]}),f("label",{className:xe("PublishDocModal__form__publishOptions__option",r==="scheduled"&&"PublishDocModal__form__publishOptions__option--selected",r&&r!=="scheduled"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"scheduled",checked:r==="scheduled",onChange:()=>i("scheduled")}),f("div",{children:"Scheduled"})]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live at the date and time specified below."}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2",children:[f("input",{ref:g,type:"datetime-local",disabled:r!=="scheduled",value:s,min:HC(),onChange:D=>{let O=D.target;a(O.value)}}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})]})]})}),f("div",{className:"PublishDocModal__form__publishMessage",children:f("div",{className:"PublishDocModal__form__publishMessage__wrapper",children:[f("textarea",{className:"PublishDocModal__form__publishMessage__textarea",placeholder:"Optional: Add a message to describe the changes",value:d,rows:3,onInput:D=>{let O=D.target;u(O.value)}}),b&&f("button",{type:"button",className:"PublishDocModal__form__publishMessage__sparkle",onClick:w,disabled:p,children:f(we,{label:"Generate message",withArrow:!0,position:"left",allowPointerEvents:!0,wrapLines:!0,children:p?f(xt,{size:16}):f(Oo,{size:16,stroke:1.5})})})]})}),f("div",{className:"PublishDocModal__form__buttons",children:[f(Z,{variant:"outline",onClick:()=>n.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(Z,{variant:"filled",size:"xs",color:"dark",disabled:N,loading:l,type:"submit",children:E})]})]}),f("div",{className:"PublishDocModal__DiffWrapper",children:[f(LP,{docId:e.docId}),b&&f(ww,{docId:e.docId,beforeVersion:"published",afterVersion:"draft"}),f(AP,{docId:e.docId})]})]})})}function AP(t){let e=t.docId,[n,o]=L(!1);function r(){o(!0)}return f("div",{className:"PublishDocModal__ShowChanges",children:f(Rh,{iconPosition:"right",onChange:()=>r(),disableIconRotation:!0,children:f(Rh.Item,{label:"Compare JSON data",icon:f(DE,{stroke:1.5}),iconPosition:"left",children:n&&f(Tw,{left:{docId:e,versionId:"published"},right:{docId:e,versionId:"draft"},showExpandButton:!0,showAiSummary:!1})})})})}function MP(t){let e=t?.sys;return e?!!(!e.publishedAt||e.modifiedAt&&e.modifiedAt>e.publishedAt):!1}function LP(t){let[e,n]=L(!0),[o,r]=L([]);F(()=>{async function a(){n(!0);try{let l=await Qi(t.docId);if(!l?.fields){n(!1);return}let c=Yw(l.fields).filter(u=>u!==t.docId);if(c.length===0){n(!1);return}let d=[];await Promise.all(c.map(async u=>{try{let p=await Qi(u);p&&MP(p)&&d.push(u)}catch(p){console.warn(`Failed to fetch reference doc: ${u}`,p)}})),r(d.sort())}catch(l){console.error("Failed to load reference docs",l)}n(!1)}a()},[t.docId]);let i=[t.docId,...o],s=mE({docIds:i});return e?f("div",{className:"PublishDocModal__ReferenceDocs",children:f(xt,{color:"gray",size:"sm"})}):o.length===0?null:f("div",{className:"PublishDocModal__ReferenceDocs",children:[f("div",{className:"PublishDocModal__ReferenceDocs__header",children:[f("div",{className:"PublishDocModal__ReferenceDocs__header__label",children:["Referenced docs with unpublished changes (",o.length,")"]}),f(Z,{variant:"outline",size:"xs",color:"dark",leftIcon:f(VE,{size:16}),onClick:()=>s.open(),children:"Bundle all docs into a release"})]}),f("div",{className:"PublishDocModal__ReferenceDocs__list",children:o.map(a=>f(Ud,{docId:a,variant:"compact",statusBadges:!0,clickable:!0},a))})]})}IP.id=qw;br();ke();function du(t,e){let n;return(...o)=>{window.clearTimeout(n),n=window.setTimeout(()=>{t(...o)},e)}}var mo=class{constructor(){this.events=new Map}on(e,n){let o=No(6),r=this.events.get(e);return r||(r=new Map,this.events.set(e,r)),r.set(o,n),()=>{this.off(e,o)}}off(e,n){let o=this.events.get(e);o&&(o.delete(n),o.size===0&&this.events.delete(e))}dispatch(e,...n){let o=this.events.get(e);o&&o.forEach(r=>r(...n))}dispose(){this.events.clear()}};var uu=class{constructor(){this.subscribers=new Set;this.subtreeSubscribers=new Set;this.children=new Map}},pu=class extends mo{constructor(n){super();this.root=new uu;this.data=n||{}}get(n){return this.getValueFromPath(n,this.data)}set(n,o){if(n===""){Pn(o)&&this.setData(o);return}this.update({[n]:o})}update(n){let o=new Map,r=(s,a,l)=>{if(o.set(s,l),!Pn(a)&&!Pn(l))return;let c=Pn(a)?Object.keys(a):[],d=Pn(l)?Object.keys(l):[];new Set([...c,...d]).forEach(p=>{let h=Pn(a)?a[p]:void 0,g=Pn(l)?l[p]:void 0;zh(h,g)||r(`${s}.${p}`,h,g)})};Object.entries(n).forEach(([s,a])=>{let l=this.data,c=s.split("."),d=c.pop();for(let p of c)l[p]||(l[p]={}),l=l[p];let u=l[d];l[d]=a,this.dispatch("VALUE_CHANGE",s,a),r(s,u,a)});let i=new Map;o.forEach((s,a)=>{this.collectSubtreeNotifications(a,i)}),o.forEach((s,a)=>{let l=this.getTrieNode(a);l&&l.subscribers.size>0&&l.subscribers.forEach(c=>c(s))}),i.forEach((s,a)=>{let l=this.get(a);s.subtreeSubscribers.forEach(c=>c(l))}),this.dispatch("CHANGE",this.data)}setData(n){let o=this.data;this.notifyOnUpdate(this.root,"",o,n),this.data=n,this.dispatch("CHANGE",this.data)}subscribe(n,o){let r=this.getTrieNode(n,!0);return r.subscribers.add(o),window.setTimeout(()=>{let i=this.get(n);i!==void 0&&o(i)}),()=>{r.subscribers.delete(o)}}subscribeSubtree(n,o){let r=this.getTrieNode(n,!0);return r.subtreeSubscribers.add(o),window.setTimeout(()=>{let i=this.get(n);i!==void 0&&o(i)}),()=>{r.subtreeSubscribers.delete(o)}}getDataSnapshot(){return this.data}dispose(){super.dispose(),this.data={},this.root.subscribers.clear(),this.root.subtreeSubscribers.clear(),this.root.children.clear()}notifyOnUpdate(n,o,r,i){let s=this.getValueFromPath(o,r),a=this.getValueFromPath(o,i);zh(s,a)||(n.subscribers.forEach(l=>l(a)),n.subtreeSubscribers.forEach(l=>l(a))),n.children.forEach((l,c)=>{let d=o?`${o}.${c}`:c;this.notifyOnUpdate(l,d,r,i)})}collectSubtreeNotifications(n,o){let r=this.root;if(r.subtreeSubscribers.size>0&&o.set("",r),!n)return;let i="";for(let s of n.split(".")){if(r=r.children.get(s),!r)return;i=i?`${i}.${s}`:s,r.subtreeSubscribers.size>0&&o.set(i,r)}}getValueFromPath(n,o){if(!n)return o;let r=n.split("."),i=o;for(let s of r){if(i===null||typeof i!="object"||!(s in i))return;i=i[s]}return i}getTrieNode(n,o=!1){if(!n)return this.root;let r=n.split("."),i=this.root;for(let s of r){if(!i.children.has(s))if(o)i.children.set(s,new uu);else return;i=i.children.get(s)}return i}};var Xw=3*Zi.second,RP=5*Zi.minute;var PP=30*Zi.second,dg=class extends mo{constructor(n){super();this.pendingUpdates=new Map;this.saveState="NO_CHANGES";this.autolock=!1;this.autolockReason="autolock";this.autolockApplied=!1;this.mightHaveAssetChanges=!1;this.readOnly=!1;this.autoSave=!0;this.flushOnStop=!0;this.started=!1;this.queueChanges=du(()=>this.flush(),Xw);this.projectId=window.__ROOT_CTX.rootConfig.projectId;let[o,r]=n.split("/");this.docId=n,this.collectionId=o,this.slug=r,this.db=window.firebase.db,this.docRef=Ad(this.db,"Projects",this.projectId,"Collections",o,"Drafts",r),this.store=new pu({id:this.docId,collection:this.collectionId,slug:this.slug,sys:{}}),this.store.on("CHANGE",s=>{this.dispatch("CHANGE",s)}),this.store.on("VALUE_CHANGE",(s,a)=>{this.dispatch("VALUE_CHANGE",s,a)});let i=window.__ROOT_CTX.collections[o];i&&(this.autolock=!!i.autolock,i.autolockReason&&(this.autolockReason=i.autolockReason))}async start(){if(this.started)return;this.started=!0;let n=!0;this.dbUnsubscribe=Ld(this.docRef,o=>{if(o.metadata.hasPendingWrites)return;let r=o.data()||{};this.pendingUpdates.size>0&&Qw(r,Object.fromEntries(this.pendingUpdates)),this.store.setData(r),n&&(n=!1,Array.isArray(r?.sys?.assets)||(this.mightHaveAssetChanges=!0))})}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.flushOnStop&&this.flush(),this.started=!1)}onChange(n){return this.on("CHANGE",n)}onSaveStateChange(n){return this.on("SAVE_STATE_CHANGE",n)}onFlush(n){return this.on("FLUSH",n)}subscribe(n,o){return this.store.subscribe(n,o)}subscribeSubtree(n,o){return this.store.subscribeSubtree(n,o)}getData(){return this.store.getDataSnapshot()}getValue(n){return this.store.get(n)}async updateKey(n,o){this.readOnly||(o===void 0?this.setPendingUpdate(n,Rd()):this.setPendingUpdate(n,o),this.store.set(n,o),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}async updateKeys(n){if(!this.readOnly){for(let o in n){let r=n[o];r==null?this.setPendingUpdate(o,Rd()):this.setPendingUpdate(o,r)}this.store.update(n),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges()}}async removeKey(n){this.readOnly||(this.setPendingUpdate(n,Rd()),this.store.set(n,void 0),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}setPendingUpdate(n,o){for(let r of this.pendingUpdates.keys())zP(r,n)&&this.pendingUpdates.delete(r);this.pendingUpdates.set(n,o),!this.mightHaveAssetChanges&&n.startsWith("fields")&&(Bh(o)||Bh(this.store.get(n)))&&(this.mightHaveAssetChanges=!0)}getPendingUpdates(){return BP(Object.fromEntries(this.pendingUpdates))}setSaveState(n){let o=this.saveState;n==="SAVED"&&o!=="SAVING"||(this.saveState=n,n==="SAVED"&&window.setTimeout(()=>{this.saveState==="SAVED"&&this.setSaveState("NO_CHANGES")},Xw),this.dispatch("SAVE_STATE_CHANGE",n))}removePublishingLock(){this.autolockApplied=!0,this.removeKey("sys.publishingLocked"),this.flush()}async flush(n){if(this.readOnly||this.pendingUpdates.size===0)return;let o=this.getPendingUpdates();if(o["sys.modifiedAt"]=ta(),o["sys.modifiedBy"]=window.firebase.user.email,this.mightHaveAssetChanges){let r=XC(this.store.get("fields")||{}),i=this.store.get("sys.assets")||[];HP(r,i)||(o["sys.assets"]=r)}this.autolock&&!this.autolockApplied&&!this.store.get("sys.publishingLocked")&&(this.autolockApplied=!0,o["sys.publishingLocked"]={lockedAt:ta(),lockedBy:window.firebase.user.email,reason:this.autolockReason}),this.pendingUpdates.clear();try{this.setSaveState("SAVING"),await Md(this.docRef,o),this.mightHaveAssetChanges=!1,this.setSaveState("SAVED"),n?.quiet||this.dispatch("FLUSH"),Pd("doc.save",{metadata:{docId:this.docId},throttle:RP,throttleId:this.docId})}catch(r){console.error("failed to update doc:",r),this.setSaveState("ERROR");let i=Al(r);ae({title:`Failed to save ${this.slug}`,message:i||`Something went wrong while saving ${this.slug}`,color:"red",autoClose:!1});for(let s in o)s.startsWith("sys.")||this.pendingUpdates.has(s)||(this.pendingUpdates.set(s,o[s]),this.queueChanges(),console.log("re-queued updates"),console.log(this.pendingUpdates))}}getLocales(){let n=this.store.get("sys.locales");return n||["en"]}setLocales(n){this.updateKey("sys.locales",n)}async dispose(){super.dispose(),this.stop()}};function Qw(t,e){for(let n in e){let o=e[n];if(n.includes(".")){let[r,i]=FP(n);t[r]??={},Qw(t[r],{[i]:o})}else typeof o>"u"?delete t[n]:t[n]=o}}function FP(t){let e=t.indexOf("."),n=t.substring(0,e),o=t.substring(e+1);return[n,o]}function BP(t){let e={...t};for(let n in e)$P(n,e)&&delete e[n];return e}function $P(t,e){let n=t.split(".");for(let o=1;o<n.length;o++)if(n.slice(0,o).join(".")in e)return!0;return!1}function zP(t,e){return t.startsWith(`${e}.`)}function HP(t,e){return t.length===e.length&&t.every((n,o)=>n===e[o])}var ug=pt(null);function e0(t){let[e,n]=L(!0),o=X(()=>new dg(t.docId),[t.docId]);o.readOnly=t.readOnly??!1,o.autoSave=t.autoSave??!0,o.flushOnStop=t.flushOnStop??!0,F(()=>(n(!0),o.onChange(i=>{n(!1),KC(i.id,i)}),o.start(),()=>o.dispose()),[o]),F(()=>{let i,s=()=>{document.hidden||document.visibilityState!=="visible"?i=window.setTimeout(()=>{o.stop()},PP):(i&&(clearTimeout(i),i=void 0),o.started||o.start())};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),i&&clearTimeout(i)}},[o]);let r=X(()=>({loading:e,controller:o}),[e,o]);return f(ug.Provider,{value:r,children:t.children})}function fu(t){return f(ug.Provider,{value:t.value,children:t.children})}function sn(){let t=ft(ug);if(!t)throw new Error("useDraftDoc() should be used within a <DraftDocProvider>");return t}function t0(t){let{controller:e}=sn();F(()=>e.onSaveStateChange(t),[e])}function Kq(t){let{controller:e}=sn();F(()=>e.onChange(t),[e])}function Xo(t,e){let{controller:n}=sn();F(()=>n.subscribe(t,e),[n])}function At(t,e){let{controller:n}=sn(),[o,r]=L(n.getValue(t)??e);return F(()=>n.subscribe(t,s=>{r(s)}),[n]),[o,s=>{r(s),s==null?n.removeKey(t):n.updateKey(t,s)}]}yt();yt();function xn(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var UP=typeof Symbol=="function"&&Symbol.observable||"@@observable",n0=UP,pg=()=>Math.random().toString(36).substring(7).split("").join("."),KP={INIT:`@@redux/INIT${pg()}`,REPLACE:`@@redux/REPLACE${pg()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${pg()}`},o0=KP;function jP(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function fg(t,e,n){if(typeof t!="function")throw new Error(xn(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(xn(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(xn(1));return n(fg)(t,e)}let o=t,r=e,i=new Map,s=i,a=0,l=!1;function c(){s===i&&(s=new Map,i.forEach((_,b)=>{s.set(b,_)}))}function d(){if(l)throw new Error(xn(3));return r}function u(_){if(typeof _!="function")throw new Error(xn(4));if(l)throw new Error(xn(5));let b=!0;c();let y=a++;return s.set(y,_),function(){if(b){if(l)throw new Error(xn(6));b=!1,c(),s.delete(y),i=null}}}function p(_){if(!jP(_))throw new Error(xn(7));if(typeof _.type>"u")throw new Error(xn(8));if(typeof _.type!="string")throw new Error(xn(17));if(l)throw new Error(xn(9));try{l=!0,r=o(r,_)}finally{l=!1}return(i=s).forEach(y=>{y()}),_}function h(_){if(typeof _!="function")throw new Error(xn(10));o=_,p({type:o0.REPLACE})}function g(){let _=u;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(xn(11));function y(){let x=b;x.next&&x.next(d())}return y(),{unsubscribe:_(y)}},[n0](){return this}}}return p({type:o0.INIT}),{dispatch:p,subscribe:u,getState:d,replaceReducer:h,[n0]:g}}function r0(t,e){return function(...n){return e(t.apply(this,n))}}function hg(t,e){if(typeof t=="function")return r0(t,e);if(typeof t!="object"||t===null)throw new Error(xn(16));let n={};for(let o in t){let r=t[o];typeof r=="function"&&(n[o]=r0(r,e))}return n}function gg(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...o)=>e(n(...o)))}function i0(...t){return e=>(n,o)=>{let r=e(n,o),i=()=>{throw new Error(xn(15))},s={getState:r.getState,dispatch:(l,...c)=>i(l,...c)},a=t.map(l=>l(s));return i=gg(...a)(r.dispatch),{...r,dispatch:i}}}yt();var WF=Ah(c0(),1),ZP=SC.startsWith("19"),QP=Symbol.for(ZP?"react.transitional.element":"react.element"),eF=Symbol.for("react.portal"),tF=Symbol.for("react.fragment"),nF=Symbol.for("react.strict_mode"),oF=Symbol.for("react.profiler"),rF=Symbol.for("react.consumer"),iF=Symbol.for("react.context"),m0=Symbol.for("react.forward_ref"),sF=Symbol.for("react.suspense"),aF=Symbol.for("react.suspense_list"),yg=Symbol.for("react.memo"),lF=Symbol.for("react.lazy");var cF=m0,dF=yg;function uF(t){if(typeof t=="object"&&t!==null){let{$$typeof:e}=t;switch(e){case QP:switch(t=t.type,t){case tF:case oF:case nF:case sF:case aF:return t;default:switch(t=t&&t.$$typeof,t){case iF:case m0:case lF:case yg:return t;case rF:return t;default:return e}}case eF:return e}}}function pF(t){return uF(t)===yg}function fF(t,e,n,o,{areStatesEqual:r,areOwnPropsEqual:i,areStatePropsEqual:s}){let a=!1,l,c,d,u,p;function h(y,v){return l=y,c=v,d=t(l,c),u=e(o,c),p=n(d,u,c),a=!0,p}function g(){return d=t(l,c),e.dependsOnOwnProps&&(u=e(o,c)),p=n(d,u,c),p}function m(){return t.dependsOnOwnProps&&(d=t(l,c)),e.dependsOnOwnProps&&(u=e(o,c)),p=n(d,u,c),p}function _(){let y=t(l,c),v=!s(y,d);return d=y,v&&(p=n(d,u,c)),p}function b(y,v){let x=!i(v,c),C=!r(y,l,v,c);return l=y,c=v,x&&C?g():x?m():C?_():p}return function(v,x){return a?b(v,x):h(v,x)}}function hF(t,{initMapStateToProps:e,initMapDispatchToProps:n,initMergeProps:o,...r}){let i=e(t,r),s=n(t,r),a=o(t,r);return fF(i,s,a,t,r)}function gF(t,e){let n={};for(let o in t){let r=t[o];typeof r=="function"&&(n[o]=(...i)=>e(r(...i)))}return n}function _g(t){return function(n){let o=t(n);function r(){return o}return r.dependsOnOwnProps=!1,r}}function d0(t){return t.dependsOnOwnProps?!!t.dependsOnOwnProps:t.length!==1}function _0(t,e){return function(o,{displayName:r}){let i=function(a,l){return i.dependsOnOwnProps?i.mapToProps(a,l):i.mapToProps(a,void 0)};return i.dependsOnOwnProps=!0,i.mapToProps=function(a,l){i.mapToProps=t,i.dependsOnOwnProps=d0(t);let c=i(a,l);return typeof c=="function"&&(i.mapToProps=c,i.dependsOnOwnProps=d0(c),c=i(a,l)),c},i}}function xg(t,e){return(n,o)=>{throw new Error(`Invalid value of type ${typeof t} for ${e} argument when connecting component ${o.wrappedComponentName}.`)}}function mF(t){return t&&typeof t=="object"?_g(e=>gF(t,e)):t?typeof t=="function"?_0(t,"mapDispatchToProps"):xg(t,"mapDispatchToProps"):_g(e=>({dispatch:e}))}function _F(t){return t?typeof t=="function"?_0(t,"mapStateToProps"):xg(t,"mapStateToProps"):_g(()=>({}))}function bF(t,e,n){return{...n,...t,...e}}function yF(t){return function(n,{displayName:o,areMergedPropsEqual:r}){let i=!1,s;return function(l,c,d){let u=t(l,c,d);return i?r(u,s)||(s=u):(i=!0,s=u),s}}}function xF(t){return t?typeof t=="function"?yF(t):xg(t,"mergeProps"):()=>bF}function vF(t){t()}function CF(){let t=null,e=null;return{clear(){t=null,e=null},notify(){vF(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){let n=[],o=t;for(;o;)n.push(o),o=o.next;return n},subscribe(n){let o=!0,r=e={callback:n,next:null,prev:e};return r.prev?r.prev.next=r:t=r,function(){!o||t===null||(o=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:t=r.next)}}}}var u0={notify(){},get:()=>[]};function b0(t,e){let n,o=u0,r=0,i=!1;function s(m){d();let _=o.subscribe(m),b=!1;return()=>{b||(b=!0,_(),u())}}function a(){o.notify()}function l(){g.onStateChange&&g.onStateChange()}function c(){return i}function d(){r++,n||(n=e?e.addNestedSub(l):t.subscribe(l),o=CF())}function u(){r--,n&&r===0&&(n(),n=void 0,o.clear(),o=u0)}function p(){i||(i=!0,d())}function h(){i&&(i=!1,u())}let g={addNestedSub:s,notifyNestedSubs:a,handleChangeWrapper:l,isSubscribed:c,trySubscribe:p,tryUnsubscribe:h,getListeners:()=>o};return g}var EF=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",wF=EF(),TF=()=>typeof navigator<"u"&&navigator.product==="ReactNative",SF=TF(),kF=()=>wF||SF?_n:F,hu=kF();function p0(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function mg(t,e){if(p0(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(e,n[r])||!p0(t[n[r]],e[n[r]]))return!1;return!0}var NF={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},DF={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},OF={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},y0={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},IF={[cF]:OF,[dF]:y0};function f0(t){return pF(t)?y0:IF[t.$$typeof]||NF}var AF=Object.defineProperty,MF=Object.getOwnPropertyNames,h0=Object.getOwnPropertySymbols,LF=Object.getOwnPropertyDescriptor,RF=Object.getPrototypeOf,g0=Object.prototype;function bg(t,e){if(typeof e!="string"){if(g0){let i=RF(e);i&&i!==g0&&bg(t,i)}let n=MF(e);h0&&(n=n.concat(h0(e)));let o=f0(t),r=f0(e);for(let i=0;i<n.length;++i){let s=n[i];if(!DF[s]&&!(r&&r[s])&&!(o&&o[s])){let a=LF(e,s);try{AF(t,s,a)}catch{}}}}return t}var PF=Symbol.for("react-redux-context"),FF=typeof globalThis<"u"?globalThis:{};function BF(){if(!pt)return{};let t=FF[PF]??=new Map,e=t.get(pt);return e||(e=pt(null),t.set(pt,e)),e}var x0=BF(),$F=[null,null];function zF(t,e,n){hu(()=>t(...e),n)}function HF(t,e,n,o,r,i){t.current=o,n.current=!1,r.current&&(r.current=null,i())}function UF(t,e,n,o,r,i,s,a,l,c,d){if(!t)return()=>{};let u=!1,p=null,h=()=>{if(u||!a.current)return;let m=e.getState(),_,b;try{_=o(m,r.current)}catch(y){b=y,p=y}b||(p=null),_===i.current?s.current||c():(i.current=_,l.current=_,s.current=!0,d())};return n.onStateChange=h,n.trySubscribe(),h(),()=>{if(u=!0,n.tryUnsubscribe(),n.onStateChange=null,p)throw p}}function KF(t,e){return t===e}function jF(t,e,n,{pure:o,areStatesEqual:r=KF,areOwnPropsEqual:i=mg,areStatePropsEqual:s=mg,areMergedPropsEqual:a=mg,forwardRef:l=!1,context:c=x0}={}){let d=c,u=_F(t),p=mF(e),h=xF(n),g=!!t;return _=>{let b=_.displayName||_.name||"Component",y=`Connect(${b})`,v={shouldHandleStateChanges:g,displayName:y,wrappedComponentName:b,WrappedComponent:_,initMapStateToProps:u,initMapDispatchToProps:p,initMergeProps:h,areStatesEqual:r,areStatePropsEqual:s,areOwnPropsEqual:i,areMergedPropsEqual:a};function x(k){let[T,w,S]=X(()=>{let{reactReduxForwardedRef:Be,...on}=k;return[k.context,Be,on]},[k]),N=X(()=>{let Be=d;return T?.Consumer,Be},[T,d]),D=ft(N),O=!!k.store&&!!k.store.getState&&!!k.store.dispatch,A=!!D&&!!D.store,I=O?k.store:D.store,R=A?D.getServerState:I.getState,$=X(()=>hF(I.dispatch,v),[I]),[W,P]=X(()=>{if(!g)return $F;let Be=b0(I,O?void 0:D.subscription),on=Be.notifyNestedSubs.bind(Be);return[Be,on]},[I,O,D]),q=X(()=>O?D:{...D,subscription:W},[O,D,W]),de=J(void 0),rt=J(S),Tt=J(void 0),_t=J(!1),dt=J(!1),ut=J(void 0);hu(()=>(dt.current=!0,()=>{dt.current=!1}),[]);let oe=X(()=>()=>Tt.current&&S===rt.current?Tt.current:$(I.getState(),S),[I,S]),ee=X(()=>on=>W?UF(g,I,W,$,rt,de,_t,dt,Tt,P,on):()=>{},[W]);zF(HF,[rt,de,_t,S,Tt,P]);let ye;try{ye=EC(ee,oe,R?()=>$(R(),S):oe)}catch(Be){throw ut.current&&(Be.message+=`
|
|
18
|
+
[The file was uploaded, but its binary content was not inlined into this chat message.]`}async function gP(t,e){if(!mP(t.name,e))return null;let n=await t.text();return n.length<=Aw?{text:n,truncated:!1}:{text:n.slice(0,Aw),truncated:!0}}function mP(t,e){return e.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(n=>t.toLowerCase().endsWith(n))}function _P(t){let e=t.toLowerCase();return e.endsWith(".png")?"image/png":e.endsWith(".webp")?"image/webp":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".gif")?"image/gif":e.endsWith(".svg")?"image/svg+xml":e.endsWith(".pdf")?"application/pdf":e.endsWith(".json")?"application/json":e.endsWith(".csv")?"text/csv":e.endsWith(".md")?"text/markdown":e.endsWith(".txt")?"text/plain":"application/octet-stream"}function bP(t){return(t.parts||[]).filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function yP(t){if(!t)return null;let e=/```(?:json)?\s*\n([\s\S]*?)```/gi,n,o=null;for(;(n=e.exec(t))!==null;)o=n[1].trim();return o}function xP(t){if(!t)return t;let e=/```(?:json)?\s*\n[\s\S]*?```/gi,n=Array.from(t.matchAll(e)),o=t;if(n.length>0){let i=n[n.length-1],s=i.index??-1,a=s+i[0].length;s!==-1&&/^\s*$/.test(o.slice(a))&&(o=o.slice(0,s))}if((o.match(/```/g)||[]).length%2===1){let i=o.lastIndexOf("```");i!==-1&&(o=o.slice(0,i))}return o.trim()}var Qh="AiEditModal";function Rw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(Qh,{...e,title:n.title||"Edit with AI (Experimental)",innerProps:n,size:"calc(min(1920px, calc(100% - 96px)))",centered:!0})},close:()=>{t.closeModal(Qh)}}}function vP(t){let{innerProps:e,context:n,id:o}=t,r=J(null),i=X(()=>JSON.stringify(e.data||{},null,2),[e.data]),[s,a]=L(i),l=X(()=>{if(!s)return null;try{return JSON.parse(s)}catch{return null}},[s]),c=X(()=>s!==i,[s,i]),d=De(()=>{if(!l)return;let p=Hd(l);e.onSave&&e.onSave(p)},[l]),u=De(p=>{if(p?.data){let h=JSON.stringify(p.data,null,2);a(h),r.current?.click()}},[]);return f("div",{className:"AiEditModal",children:[f("div",{className:"AiEditModal__SplitPanel",children:[f("div",{className:"AiEditModal__SplitPanel__ChatPanel",children:f(Lw,{editModeData:l,onEditModeResponse:u,children:[f("p",{children:"Tell me what you want to change. I can make simple text edits, replace content within a module, or answer questions about the content."}),f("p",{children:"Just enter simple instructions, or attach a screenshot and ask me to use it as reference."})]})}),f("div",{className:"AiEditModal__SplitPanel__JsonPanel",children:f(Od,{className:"AiEditModal__Tabs",grow:!0,children:[f(Od.Tab,{label:"JSON",icon:f(OE,{size:20}),children:f("div",{className:"AiEditModal__JsonEditor",children:f(kd,{value:s,onChange:p=>a(p),formatOnBlur:!0,height:"100%",className:"AiEditModal__JsonInput"})})}),f(Od.Tab,{ref:r,label:"Diff",icon:f(vE,{size:20}),children:f("div",{className:"AiEditModal__JsonDiffViewer",children:e.data&&s&&f(tw,{oldCode:i,newCode:s})})})]})})]}),f("div",{className:"AiEditModal__buttons",children:[f(Z,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>n.closeModal(o),children:"Cancel"}),f(Z,{variant:"default",size:"xs",type:"button",leftIcon:f(li,{size:16}),disabled:!c,onClick:()=>a(i),children:"Reset"}),f(Z,{leftIcon:f(es,{size:16}),variant:"filled",size:"xs",color:"green",disabled:!l||!c,onClick:d,children:"Accept changes"})]})]})}vP.id=Qh;var eg="AssetPickerModal";function Pw(){let t=null;try{t=St()}catch{t=null}let e=ot();return{enabled:t!==null,open:n=>{if(!t){console.warn("useAssetPickerModal() requires a <ModalsProvider> context.");return}t.openContextModal(eg,{...e,title:"Select from asset library",innerProps:n,size:"800px",overflow:"inside"})},close:()=>{t?.closeModal(eg)}}}function CP(t){let{innerProps:e,context:n,id:o}=t;function r(i){e.onSelect&&e.onSelect(i),n.closeModal(o)}return f("div",{className:"AssetPickerModal",children:f(mw,{mode:"pick",accept:e.accept,initialFolder:e.initialFolder,onFolderChange:YC,onPickFile:r})})}CP.id=eg;ke();var tg="ComponentPickerModal",EP="root::ComponentPickerModal:layout",wP=3;function Fw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(tg,{...e,innerProps:n,size:"720px",overflow:"inside",title:"Select a component"})},close:()=>{t.closeModal(tg)}}}function ng(t){let{innerProps:e}=t,[n,o]=L(""),[r,i]=_w(EP,"list"),[s,a]=L(0),l=J(null),c=X(()=>{let h=n.trim().toLowerCase();return h?e.options.filter(g=>[g.schema.name,g.schema.label,g.schema.description,g.preset?.id,g.preset?.label,g.preset?.description].filter(Boolean).join(" ").toLowerCase().includes(h)):e.options},[e.options,n]);F(()=>{a(c.length>0?0:-1)},[c]),F(()=>{if(s<0||!l.current)return;l.current.querySelectorAll(".ComponentPickerModal__Card")[s]?.scrollIntoView({block:"nearest"})},[s]);function d(h){if(c.length===0)return;let g=r==="grid"?wP:1,m=c.length-1;if(h.key==="ArrowDown")h.preventDefault(),a(_=>Math.min(m,Math.max(0,_)+g));else if(h.key==="ArrowUp")h.preventDefault(),a(_=>Math.max(0,_-g));else if(h.key==="ArrowRight"&&r==="grid")h.preventDefault(),a(_=>Math.min(m,Math.max(0,_)+1));else if(h.key==="ArrowLeft"&&r==="grid")h.preventDefault(),a(_=>Math.max(0,_-1));else if(h.key==="Enter"&&s>=0){let _=c[s];_&&(h.preventDefault(),e.onSelect(_))}}let u=!!e.onRemove&&!n.trim();return f("div",{className:`ComponentPickerModal ${r==="grid"?"ComponentPickerModal--grid":"ComponentPickerModal--list"}`,onKeyDown:d,children:[f("div",{className:"ComponentPickerModal__controls",children:[f(Xn,{"data-autofocus":!0,placeholder:e.searchPlaceholder||"Search components...",value:n,onChange:h=>o(h.target.value),icon:f(Qd,{size:16}),size:"xs",className:"ComponentPickerModal__controls__search"}),f(Dd,{className:"ComponentPickerModal__controls__layout",size:"xs",value:r,onChange:h=>i(h),data:[{value:"list",label:f("span",{className:"ComponentPickerModal__controls__layout__option","aria-label":"List layout",title:"List layout",children:f(ME,{size:14})})},{value:"grid",label:f("span",{className:"ComponentPickerModal__controls__layout__option","aria-label":"Grid layout",title:"Grid layout",children:f(AE,{size:14})})}]})]}),c.length===0?f("div",{className:"ComponentPickerModal__empty",children:e.options.length===0?"No component types available.":"No components match your search."}):f("div",{className:"ComponentPickerModal__cards",ref:l,children:c.map((h,g)=>f(ng.Card,{option:h,layout:r,focused:g===s,onMouseEnter:()=>a(g),onSelect:()=>e.onSelect(h)},h.key))}),u&&f("div",{className:"ComponentPickerModal__footer",children:f(Z,{variant:"subtle",color:"red",size:"xs",leftIcon:f(Zn,{size:14}),onClick:()=>e.onRemove?.(),children:"Clear selection"})})]})}ng.Card=t=>{let{schema:e,preset:n}=t.option,o=n?.label||n?.id||e.label||e.name,r=n?.description??e.description??"",i=n?.image||e.image,s=n?e.label||e.name:"",l=t.layout==="grid"?180:120,c=t.layout==="grid"?120:90,d=["ComponentPickerModal__Card",t.focused?"ComponentPickerModal__Card--focused":""].filter(Boolean).join(" ");return f("button",{type:"button",className:d,onClick:t.onSelect,onMouseEnter:t.onMouseEnter,children:[f("div",{className:"ComponentPickerModal__Card__image",children:f(ea,{src:i,width:l,height:c,withPlaceholder:!i,alt:o})}),f("div",{className:"ComponentPickerModal__Card__content",children:[s&&f("div",{className:"ComponentPickerModal__Card__content__subtitle",children:s}),f("div",{className:"ComponentPickerModal__Card__content__title",children:o}),r&&f("div",{className:"ComponentPickerModal__Card__content__description",children:r})]})]})};ng.id=tg;ke();var og="EditJsonModal";function rg(){let t=St(),e=ot();return{open:n=>{t.openContextModal(og,{...e,title:n.title||"Edit JSON",innerProps:n,size:"680px",centered:!0})},close:()=>{t.closeModal(og)}}}function TP(t){let{innerProps:e,context:n,id:o}=t,r=JSON.stringify(e.data||{},null,2),[i,s]=L(r),[a,l]=L(!0),[c,d]=L(!1),[u,p]=L(!1);function h(_){s(_),d(!1);try{JSON.parse(_),l(!0)}catch{l(!1)}p(_!==r)}function g(){navigator.clipboard.writeText(i).then(()=>d(!0))}function m(){let _=JSON.parse(i),b=Hd(_);e.onSave&&e.onSave(b)}return f("div",{className:"EditJsonModal",children:[f(kd,{value:i,onChange:h,formatOnBlur:!0,autosize:!0,minRows:4,maxRows:25}),f("div",{className:"EditJsonModal__buttons",children:[f(Z,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>n.closeModal(o),children:"Cancel"}),f(Z,{leftIcon:f(jd,{size:16}),variant:"filled",size:"xs",color:"dark",disabled:!a,type:"button",onClick:g,children:c?"Copied!":"Copy"}),f(Z,{variant:"default",size:"xs",type:"button",leftIcon:f(li,{size:16}),disabled:!u,onClick:()=>{s(r),l(!0),p(!1)},children:"Reset"}),f(Z,{leftIcon:f(yE,{size:16}),variant:"filled",size:"xs",color:"blue",disabled:!a||!u,onClick:m,children:"Save"})]})]})}TP.id=og;ke();ke();function $w(t){let{docId:e,deepKey:n,translatable:o}=t,[r,i]=L(!0),[s,a]=L([]),l=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return F(()=>{async function c(){i(!0);let[d,u]=await Promise.all([lE(e),cE(e,"draft")]),p=d.versions,h=[];if(u){let m=yn(u,n);h.push({value:Bw(m),modifiedBy:u.sys?.modifiedBy||"Unknown",modifiedAt:u.sys?.modifiedAt?.toDate?.()||new Date,versionId:"draft"})}for(let m of p){let _=yn(m,n);h.push({value:Bw(_),modifiedBy:m.sys?.modifiedBy||"Unknown",modifiedAt:m.sys?.modifiedAt?.toDate?.()||new Date,versionId:m._versionId})}let g=[];for(let m of h){let _=g[g.length-1];(!_||_.value!==m.value)&&g.push(m)}a(g),i(!1)}c()},[e,n]),r?f("div",{className:"FieldHistory__loading",children:f(xt,{size:"sm"})}):s.length===0?f("div",{className:"FieldHistory__empty",children:"No history available."}):f("div",{className:"FieldHistory",children:s.map((c,d)=>f("div",{className:"FieldHistory__entry",children:[f("div",{className:"FieldHistory__entry__header",children:[f("span",{className:"FieldHistory__entry__author",children:c.modifiedBy}),f("span",{className:"FieldHistory__entry__date",children:l.format(c.modifiedAt)}),d===0&&f("span",{className:"FieldHistory__entry__badge",children:"Current"}),o&&c.value&&f("span",{className:"FieldHistory__entry__translationsLink",children:f(SP,{value:c.value})})]}),f("div",{className:"FieldHistory__entry__value",children:c.value||f("span",{className:"FieldHistory__entry__empty",children:"(empty)"})})]},c.versionId))})}function SP(t){let[e,n]=L("");return F(()=>{Er(t.value).then(o=>{n(`/cms/translations/${o}`)})},[t.value]),e?f(we,{label:"Open in Translations Editor",withArrow:!0,position:"right",children:f(Ae,{component:"a",href:e,target:"_blank",variant:"transparent",size:"sm",children:f(ts,{size:16})})}):null}function Bw(t){return t==null?"":typeof t=="string"?t:JSON.stringify(t)}var ig="EditTranslationsModal";function Hw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(ig,{...e,innerProps:n,size:"900px",title:"Edit translations",overflow:"inside",className:"EditTranslationsModalWrap"})},close:()=>{t.closeModal(ig)}}}function sg(t){let{innerProps:e,context:n,id:o}=t,r=e.strings||[],i=window.__ROOT_CTX.rootConfig.i18n||{},s=Ll(i.locales||["en"]),[a,l]=L({}),[c,d]=L([]),[u,p]=L(!1),[h,g]=L(!1),[m,_]=L(!0),[b,y]=L(!1),[v,x]=L(""),[C,E]=L(!1),[k,T]=L("translations"),w=e.draft||null;F(()=>{if(e.field?.deepKey&&w?.controller){let A=zw(e.field.deepKey),I=w.controller.getValue(A)||{};y(I.translate===!1),x(I.description||"")}},[e.field?.deepKey,w?.controller]),F(()=>{ZC({tags:[e.docId]}).then(A=>{let I={};Object.values(A).forEach(R=>{let $={source:R.source};s.forEach(W=>{let P=Rl(R,W);P&&($[W]=P)}),I[R.source]=$}),l(I),_(!1)})},[e.docId]);async function S(){g(!0),await vr(async()=>{let A=`edit-translations-${e.docId}`;if(ae({id:A,loading:!0,title:"Saving translations",message:`Updating for ${e.docId}...`,autoClose:!1,disallowClose:!0}),e.field?.deepKey&&w?.controller){let I=zw(e.field.deepKey),R=w.controller.getValue(I)||{};b?R.translate=!1:delete R.translate,v?R.description=v:delete R.description,Object.keys(R).length>0?await w.controller.updateKey(I,R):await w.controller.removeKey(I),await w.controller.flush()}if(!b&&c.length>0){let I=[];c.forEach(R=>{let $=a[R];I.push($)}),await ra(e.docId,I)}kt({id:A,title:"Saved translations",message:`Updated translations for ${e.docId}!`,autoClose:!1})}),g(!1)}function N(A){l(I=>{let R={...I};return R[A.source]=A,R}),d(I=>{let R=new Set(I);return R.add(A.source),Array.from(R)}),p(!0)}async function D(){if(r.length!==0){E(!0);try{await vr(async()=>{for(let A of r){let I=a[A]||{source:A},R={};s.forEach(q=>{I[q]&&(R[q]=I[q])});let $=s.filter(q=>!I[q]);if($.length===0)continue;let W=await window.fetch("/cms/api/ai.translate",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:A,targetLocales:$,description:v||void 0,existingTranslations:R})});if(W.status!==200){let q=await W.text();throw new Error(`Translation failed: ${q}`)}let P=await W.json();if(P.success&&P.translations){let q={...I};Object.entries(P.translations).forEach(([de,rt])=>{q[de]=rt}),N(q)}}ae({message:"Finished generating AI translations",color:"green"})})}finally{E(!1)}}}function O(){if(!Io())return!1;for(let A of r){let I=a[A]||{};for(let R of s)if(!I[R])return!0}return!1}return f("div",{className:"EditTranslationsModal",children:[m?f(xt,{}):f(Ne,{children:[e.field?.deepKey&&f("div",{className:"EditTranslationsModal__tabs",children:[f("button",{type:"button",className:xe("EditTranslationsModal__tabs__tab",k==="translations"&&"active"),onClick:()=>T("translations"),children:"Translations"}),f("button",{type:"button",className:xe("EditTranslationsModal__tabs__tab",k==="history"&&"active"),onClick:()=>T("history"),children:"History"})]}),k==="history"&&e.field?.deepKey?f($w,{docId:e.docId,deepKey:e.field.deepKey,translatable:!0}):f(Ne,{children:[f("div",{className:"EditTranslationsModal__controls",children:[f("div",{className:"EditTranslationsModal__controls__doNotTranslate",children:[f(fo,{label:"Do not translate",checked:b,onChange:A=>{y(A.currentTarget.checked),p(!0)},size:"sm"}),f(we,{label:"Prevent the string from being included for translation",withArrow:!0,position:"right",children:f($l,{size:14,style:{marginLeft:"6px"}})})]}),f("div",{className:"EditTranslationsModal__controls__description",children:[f("div",{className:"EditTranslationsModal__controls__description__label",children:[f("span",{children:"Description"}),f(we,{label:"Translator notes may be included when the string is extracted and sent for translation",withArrow:!0,position:"right",children:f($l,{size:14,style:{marginLeft:"6px"}})})]}),f(bn,{size:"sm",autosize:!0,minRows:1,maxRows:6,value:v,placeholder:"Add context or notes for translators...",onChange:A=>{x(A.currentTarget.value),p(!0)}})]})]}),f("table",{className:"EditTranslationsModal__table",children:[f("thead",{style:{display:b?"none":"table-header-group"},children:f("tr",{children:[f("th",{children:f(wr,{size:"h4",weight:"semi-bold",children:"SOURCE"})}),f("th",{children:f("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f(wr,{size:"h4",weight:"semi-bold",children:"TRANSLATIONS"}),O()&&f(we,{label:"Generate quick translations using AI",withArrow:!0,position:"left",children:f(Ae,{variant:"outline",onClick:D,loading:C,disabled:C,sx:{height:30,width:30,borderColor:"#ced4da"},children:C?f(Jd,{size:16}):f(Oo,{size:16,fill:"currentColor",stroke:1.5})})})]})})]})}),f("tbody",{children:r.map(A=>f("tr",{style:{display:b?"none":"table-row"},children:[f("td",{children:f("div",{className:"EditTranslationsModal__table__source",children:A})}),f("td",{children:f(sg.StringsEditor,{source:A,locales:s,translations:a[A]||{},onChange:N})})]}))})]})]})]}),f("div",{className:"EditTranslationsModal__footer",children:[f("div",{className:"EditTranslationsModal__footer__left",children:[f(Z,{component:"a",href:`/cms/translations/${e.docId}`,target:"_blank",variant:"default",size:"xs",rightIcon:f(Do,{size:14}),children:"Open Translations Editor"}),e.l10nSheet&&f("div",{className:"EditTranslationsModal__footer__gsheet",children:[f("strong",{children:"NOTE:"})," Translations for this doc are managed in"," ",f("a",{href:oa(e.l10nSheet),target:"_blank",rel:"noopener noreferrer",children:"Google Sheets"})]})]}),f("div",{className:"EditTranslationsModal__footer__buttons",children:[f(Z,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>n.closeModal(o),children:"Cancel"}),f(Z,{variant:"filled",size:"xs",color:"dark",onClick:()=>S(),disabled:!u,loading:h,children:"Save"})]})]})]})}sg.StringsEditor=t=>{let e=t.locales,[n,o]=L(t.translations||{}),[r,i]=L(!1);F(()=>{o(t.translations||{})},[t.translations]);function s(a,l){i(!0),o(c=>{let d={...c,source:t.source};return d[a]=l,d})}return F(()=>{r&&t.onChange(n)},[r,n]),f("div",{className:"EditTranslationsModal__StringsEditor",children:e.map(a=>f("div",{className:"EditTranslationsModal__StringsEditor__row",children:[f("div",{className:"EditTranslationsModal__StringsEditor__row__locale",children:a}),f("div",{className:xe("EditTranslationsModal__StringsEditor__row__translation",n[a]?"hasValue":"empty"),children:f(bn,{size:"xs",radius:0,autosize:!0,minRows:1,maxRows:10,value:n[a],onChange:l=>{s(a,l.currentTarget.value)}})})]}))})};sg.id=ig;function zw(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}yr();ke();var Uw="ExportSheetModal";function Kw(){let t=St(),e=ot();return{open:n=>{t.openContextModal(Uw,{...e,title:"Export to Google Sheet",innerProps:n,size:"650px"})}}}function ag(t){let{innerProps:e,context:n,id:o}=t,[r,i]=L(!1),[s,a]=L("new-sheet"),[l,c]=L(""),[d,u]=L(!1),p=la(),h=xw(),g=J(),m=UC(h.settings.googleDriveFolder),_=[{value:"new-sheet",label:"Create Google Sheet",help:"Creates a new Google Sheet and exports strings to the sheet."},{value:"add-tab",label:"Add tab in Google Sheet",help:"Adds a new tab in an existing Google Sheet and exports strings to the sheet."},{value:"link-sheet",label:"Link Google Sheet",help:"Links an existing Google Sheet without exporting strings."}],b=!1;(s==="add-tab"||s==="link-sheet")&&(b=!0,l&&Fd(l)?.spreadsheetId&&(b=!1));async function y(k,T){let w=T?.isNew||!1,{headers:S,rows:N}=e.csvData;w?(await k.replaceSheet(S,N),await k.applyL10nTheme()):await k.updateValuesMap(N,{keyedBy:"source",preserveColumns:e.locales})}async function v(){p.isLoggedIn()||await p.login();let k=window.__ROOT_CTX.rootConfig,T=k.projectName||k.projectId||"Root CMS",w,S,N="create-google-sheet";try{if(ae({id:N,loading:!0,title:"Creating Google Sheet...",message:"Creating Google Sheet for localization.",autoClose:!1,disallowClose:!0}),w=await na.create({title:`${T} Localization`,parent:m,share:g.current?.checked}),S=await w.getSheet(0),!S)throw new Error("could not find sheet gid=0");S.setTitle(e.docId)}catch(D){console.error(D);let O=D;typeof D=="object"&&D.body&&(O=String(D.body)),kt({id:N,title:"Failed to create Google Sheet",message:String(O),color:"red",autoClose:!1});return}try{kt({id:N,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let D={spreadsheetId:w.spreadsheetId,gid:0};await $d(e.docId,D)}catch(D){console.error(D),kt({id:N,title:"Failed to link Google Sheet",message:String(D),color:"red",autoClose:!1});return}try{kt({id:N,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await y(S,{isNew:!0})}catch(D){console.error(D);let O=D;typeof D=="object"&&D.body&&(O=String(D.body)),kt({id:N,title:"Failed to export strings to Google Sheet",message:O,color:"red",autoClose:!1});return}c(S.getUrl()),u(!0),kt({id:N,title:"Done! Exported strings to Google Sheet.",message:w.getUrl(),autoClose:!1})}async function x(){p.isLoggedIn()||await p.login();let k=Fd(l);if(!k?.spreadsheetId)throw new Error("failed to parse spreadsheet id");let T=new na(k.spreadsheetId),w,S="add-tab-google-sheet";try{ae({id:S,loading:!0,title:"Creating tab in Google Sheet...",message:"Adding tab in existing Google Sheet",autoClose:!1,disallowClose:!0}),w=await T.createSheet({title:e.docId})}catch(N){console.error(N);let D=N;typeof N=="object"&&N.body&&(D=String(N.body)),kt({id:S,title:"Failed to create Google Sheet",message:String(D),color:"red",autoClose:!1});return}try{kt({id:S,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let N={spreadsheetId:T.spreadsheetId,gid:w.gid};await $d(e.docId,N)}catch(N){console.error(N),kt({id:S,title:"Failed to link Google Sheet",message:String(N),color:"red",autoClose:!1});return}try{kt({id:S,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await y(w,{isNew:!0})}catch(N){console.error(N);let D=N;typeof N=="object"&&N.body&&(D=String(N.body)),kt({id:S,title:"Failed to export strings to Google Sheet",message:D,color:"red",autoClose:!1});return}u(!0),kt({id:S,title:"Done! Exported strings to Google Sheet.",message:w.getUrl(),autoClose:!1})}async function C(){let k="link-google-sheet",T=Fd(l);if(!T?.spreadsheetId)throw new Error("failed to parse spreadsheet id");try{ae({id:k,loading:!0,title:"Link Google Sheet",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0}),await $d(e.docId,T)}catch(w){console.error(w),kt({id:k,title:"Failed to link Google Sheet",message:String(w),color:"red",autoClose:!1});return}u(!0),kt({id:k,title:`Done! Linked ${e.docId} to Google Sheet.`,message:oa(T),autoClose:!1})}async function E(){console.log(s),i(!0),s==="new-sheet"?await vr(v):s==="add-tab"?await vr(x):s==="link-sheet"&&await vr(C),i(!1)}return f("div",{className:"ExportSheetModal",children:f("div",{className:"ExportSheetModal__content",children:[f("div",{className:"ExportSheetModal__content__body",children:"Export strings to Google Sheet or link an existing Google Sheet for managing translations."}),f("form",{className:"ExportSheetModal__form",children:[f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Export options:"}),f(Rn,{disabled:d||r,itemComponent:ag.SelectItem,data:_,onChange:k=>{a(k),k==="new-sheet"&&c("")},value:s})]}),f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Google Sheet URL:"}),s==="new-sheet"?f(Xn,{disabled:!0,placeholder:h.settings.googleDriveFolder?"A new Google Sheet will be created in the project's Google Drive folder.":'A new Google Sheet will be created in your "My Drive" folder.'}):f(Xn,{placeholder:"https://docs.google.com/spreadsheets/d/...",value:l,disabled:d||r,onChange:k=>c(k.currentTarget.value)})]}),s==="new-sheet"&&f("div",{className:"ExportSheetModal__form__section",children:f(we,{label:"Whether to share the Google Sheet with Admins and Editors upon creation. If your site has a Google Drive folder configured, the sheet will be created within it and inherit its permissions.",wrapLines:!0,width:320,withArrow:!0,position:"bottom",children:f(fo,{disabled:d||r,ref:g,name:"share",value:"true",label:"Share Google Sheet with collaborators",defaultChecked:!m})})}),f("div",{className:"ExportSheetModal__form__buttons",children:d?f(Ne,{children:[f(Z,{component:"a",target:"_blank",rel:"noopener noreferrer",href:l,variant:"default",size:"xs",color:"dark",rightIcon:f(Do,{size:16}),children:"Open Google Sheet"}),f(Z,{variant:"filled",onClick:()=>n.closeModal(o),type:"button",size:"xs",color:"primary",children:"Done"})]}):f(Ne,{children:[f(Z,{variant:"outline",onClick:()=>n.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(Z,{variant:"filled",size:"xs",color:"primary",loading:r,disabled:b,onClick:()=>E(),children:s==="link-sheet"?"Link Google Sheet":"Export to Google Sheet"})]})})]})]})})}ag.SelectItem=po(t=>{let{label:e,help:n,...o}=t;return f("div",{className:"ExportSheetModal__SelectItem",...o,children:[f(os,{className:"ExportSheetModal__SelectItem__label",size:"body",children:e}),f(os,{className:"ExportSheetModal__SelectItem__help",size:"body-sm",children:n})]})});ag.id=Uw;ke();ke();function jw(t){let{labels:e}=t,[n,o]=L(0);return F(()=>{let r=setTimeout(()=>{o(i=>(i+1)%e.length)},2e3);return()=>clearTimeout(r)},[n,e.length]),f("div",{className:"ProgressiveLoader",children:[f(xt,{color:"gray",size:"md"}),f("div",{className:"ProgressiveLoader__labels",children:f(Bt,{size:"sm",color:"dimmed",className:"ProgressiveLoader__label--entering",children:e[n]},n)})]})}var Vw="LocalizationModal";function Ww(){let t=St(),e=ot();return{open:n=>{let o=new URLSearchParams(window.location.search);o.set("modal","localization"),window.history.replaceState(null,"",`${window.location.pathname}?${o}`),t.openContextModal(Vw,{...e,innerProps:n,size:"clamp(80%, 1024px, 1280px)",onClose:()=>{n.draft?.flush({quiet:!0});let r=new URLSearchParams(window.location.search);r.delete("modal");let i=r.toString()?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState(null,"",i)}})}}}function Jo(t){let e=t.innerProps;return f("div",{className:"LocalizationModal",children:f("div",{className:"LocalizationModal__layout",children:[f(Jo.ConfigLocales,{...e}),f(Jo.Translations,{...e})]})})}Jo.id=Vw;Jo.ConfigLocales=t=>{let[e,n]=L(()=>t.draft?t.draft.getLocales():["en"]),o=window.__ROOT_CTX.rootConfig.i18n||{},r=o.locales||["en"],i=o.groups||{default:{label:"",locales:r}};function s(c){return e.filter(d=>(i[c].locales||[]).includes(d))}function a(c,d){let u=new Set(e),p=i[c].locales||[];for(let g of p)d.includes(g)?u.add(g):u.delete(g);let h=Array.from(u.values()).sort();l(h)}function l(c){n(c),t.draft.setLocales(c)}return f("div",{className:"LocalizationModal__locales",children:f(ho,{spacing:30,children:[f(fn,{children:[f(wr,{className:"LocalizationModal__iconTitle LocalizationModal__locales__title",size:"h2",children:[f($E,{strokeWidth:1.5}),f("span",{children:"Locales"})]}),f(Jo.AllNoneButtons,{onAllClicked:()=>l(r),onNoneClicked:()=>l([])})]}),f(ho,{spacing:40,children:Object.keys(i).map(c=>{let d=i[c],u=s(c);return f(Jo.LocaleGroup,{group:d,groupEnabledLocales:u,allEnabledLocales:e,onChange:p=>a(c,p)})})})]})})};Jo.LocaleGroup=t=>{let e=t.groupEnabledLocales||[],n=t.group.locales||[],o=t.allEnabledLocales||[];function r(s){t.onChange&&t.onChange(s)}function i(s){let a=e.indexOf(s);a===-1?e.push(s):e.splice(a,1),r(e)}return f(ho,{spacing:16,children:[t.group.label&&f(fn,{position:"apart",children:[f(wr,{size:"h4",weight:"semi-bold",children:t.group.label}),f(Jo.AllNoneButtons,{onAllClicked:()=>r(n),onNoneClicked:()=>r([])})]}),f(fn,{children:n.map(s=>{let a=e.includes(s),l=o.length<=1&&a;return f(fo,{value:s,checked:a,disabled:l,label:Gw(s),onChange:()=>i(s),size:"xs"})})})]})};Jo.AllNoneButtons=t=>f(fn,{spacing:"8px",children:[f(Z,{className:"LocalizationModal__allNoneBtn",variant:"subtle",size:"xs",compact:!0,onClick:t.onAllClicked,children:"All"}),"/",f(Z,{className:"LocalizationModal__allNoneBtn",variant:"subtle",size:"xs",compact:!0,onClick:t.onNoneClicked,children:"None"})]});Jo.Translations=t=>{let[e,n]=L(!0),[o,r]=L([]),i=window.__ROOT_CTX.rootConfig.i18n?.locales||[],s=Ll(i),a=t.locale&&tE(t.locale)||s.find(H=>H!=="en")||"en",[l,c]=L(a),[d,u]=L(!1),[p,h]=L({}),g=X(()=>{if(!l)return{};let H={};return Object.values(p).forEach(re=>{H[re.source]=Rl(re,l)}),H},[l,p]),m=la(),[_,b]=L(null),y=Kw(),v=Ew(),[x,C]=L(new Set),E=x.size,[k,T]=L({}),[w,S]=L(!1),[N,D]=L(!1),[O,A]=L(null),I=J(!1),R=J(null),$=Object.keys(k).length;function W(H,re,Ce){T(ce=>{let be={...ce};be[H]||(be[H]={}),be[H]={...be[H],[re]:Ce};let je=g[H]||"";return Ce===je&&(delete be[H][re],Object.keys(be[H]).length===0&&delete be[H]),be})}async function P(){S(!0);try{let H=Object.entries(k).map(([ce,be])=>({source:ce,locales:be}));await oE(H,{tags:[t.docId]});let re=await Promise.all(H.map(async ce=>({hash:await Er(ce.source),source:ce.source,locales:ce.locales}))),Ce=[t.docId];h(ce=>{let be={...ce};for(let{hash:je,source:bt,locales:Ft}of re){let pn=be[je],oi=pn?.tags||[],Mn=Array.from(new Set([...oi,...Ce]));pn?be[je]={...pn,...Ft,tags:Mn}:be[je]={source:bt,...Ft,tags:Mn}}return be}),T({}),ae({title:"Saved!",message:`Updated ${H.length} translation(s).`,autoClose:2500})}catch(H){console.error(H),ae({title:"Error saving translations",message:String(H),color:"red",autoClose:!1})}S(!1)}function q(){return!Io()||!l?!1:o.some(H=>{let re=k[H]?.[l];return re!==void 0?!re:!g[H]})}function de(){I.current=!0,R.current?.abort()}async function rt(){if(!(!l||o.length===0)){I.current=!1,D(!0);try{for(let H of o){if(I.current)break;if(k[H]?.[l]||g[H])continue;A(H);let Ce=new AbortController;R.current=Ce;let ce={},be=_t[H];be&&i.forEach(Ft=>{be[Ft]&&(ce[Ft]=be[Ft])});let je=await window.fetch("/cms/api/ai.translate",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:H,targetLocales:[l],existingTranslations:ce}),signal:Ce.signal});if(je.status!==200){let Ft=await je.text();throw new Error(`Translation failed: ${Ft}`)}let bt=await je.json();bt.success&&bt.translations?.[l]&&W(H,l,bt.translations[l])}I.current?ae({message:"AI translation stopped",color:"yellow"}):ae({message:"Finished generating AI translations",color:"green"})}catch(H){H instanceof DOMException&&H.name==="AbortError"||(console.error(H),ae({title:"Error generating translations",message:String(H),color:"red"}))}finally{D(!1),A(null),I.current=!1,R.current=null}}}let Tt=J(!1);F(()=>{if(e)return;if(!Tt.current){Tt.current=!0;return}let H=!1;async function re(){let Ce=[t.docId],ce=await Promise.all(o.map(async je=>({source:je,hash:await Er(je)})));if(H)return;let be=new Set;for(let{source:je,hash:bt}of ce)if(p[bt]){let Ft=p[bt].tags||[];Ce.every(oi=>Ft.includes(oi))||be.add(je)}H||C(be)}return re(),()=>{H=!0}},[t.docId,o,p,e]);let _t=X(()=>{let H={};return Object.values(p).forEach(re=>{H[re.source]=re}),H},[p]),dt=s.map(H=>({value:H,label:Gw(H)})),ut=X(()=>!l||o.length===0?0:o.filter(H=>{let re=k[H]?.[l];return re!==void 0?!re:!g[H]}).length,[o,g,l,k]);F(()=>{n(!0),Promise.all([vw(t.docId),uE(t.docId)]).then(async([H,re])=>{let Ce=[t.docId],ce=await Promise.all(H.map(async bt=>({source:bt,hash:await Er(bt)}))),be=await QC(ce.map(bt=>bt.hash)),je=new Set;for(let{source:bt,hash:Ft}of ce)if(be[Ft]){let pn=be[Ft].tags||[];Ce.every(Mn=>pn.includes(Mn))||je.add(bt)}r(H),h(be),b(re),C(je),n(!1)}).catch(H=>{console.error("Failed to load translations:",H),n(!1),ae({title:"Error",message:String(H?.message||H),color:"red",autoClose:!1})})},[t.docId]);function oe(H,re){let Ce=_t[H];return Ce?Rl(Ce,re):""}function ee(){let H=Ll(i.filter(ce=>!eE(ce))).filter(ce=>ce!=="en"),re=["source","en",...H],Ce=[];return o.forEach(ce=>{let be={source:ce,en:oe(ce,"en")||ce};H.forEach(je=>{be[je]=oe(ce,je)}),Ce.push(be)}),{headers:re,rows:Ce}}async function ye(){let{headers:H,rows:re}=ee(),Ce=await window.fetch("/cms/api/csv.download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:H,rows:re})});if(Ce.status!==200){console.error("csv.download failed:");let je=await Ce.text();console.error(je)}let ce=await Ce.blob(),be=window.URL.createObjectURL(ce);window.location.assign(be),window.URL.revokeObjectURL(be)}async function Fe(){let H=document.createElement("input");H.type="file",H.accept=".csv",H.addEventListener("change",async()=>{let re=H.files?.[0];if(re){let Ce=new FormData;Ce.append("file",re);try{let ce=await fetch("/cms/api/csv.import",{method:"POST",body:Ce});if(ce.status!==200){let bt=await ce.text();throw new Error(`RPCError: ${bt}`)}let be=(await ce.json()).data,je=await ra(t.docId,be);h(bt=>lg(bt,je)),ae({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}catch(ce){console.error(ce),ae({title:"Failed to import CSV",message:String(ce),color:"red",autoClose:!1})}}}),H.click()}async function un(){if(m.isLoggedIn()||await m.login(),!_?.spreadsheetId)throw new Error("no sheet linked");let re=await new na(_.spreadsheetId).getSheet(_.gid??0);if(!re)throw new Error(`sheet not found: ${JSON.stringify(_)}`);await Be(re),ae({title:"Exported strings to Google Sheet",message:re.getUrl(),autoClose:!1})}async function Be(H,re){let Ce=re?.isNew||!1,{headers:ce,rows:be}=ee();Ce?(await H.replaceSheet(ce,be),await H.applyL10nTheme()):await H.updateValuesMap(be,{keyedBy:"source",preserveColumns:s}),Pd("doc.export_to_sheet",{metadata:{docId:t.docId,sheetId:{spreadsheetId:H.spreadsheet.spreadsheetId,gid:H.gid}}})}async function on(){if(m.isLoggedIn()||await m.login(),!_?.spreadsheetId)throw new Error("no sheet linked");let re=await new na(_.spreadsheetId).getSheet(_.gid??0);if(!re)throw new Error(`sheet not found: ${JSON.stringify(_)}`);console.log("importing google sheet");let Ce=await re.getValuesMap(),ce=await ra(t.docId,Ce);h(be=>lg(be,ce)),ae({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}async function kl(){await dE(t.docId),b(null),ae({title:"Unlinked Google Sheet",message:`${t.docId} is no longer connected to a Google Sheet.`,autoClose:5e3})}async function Oh(){n(!0);let H=[],re=[t.docId];for(let Ce of o){let ce=await Er(Ce);if(p[ce]){let be=p[ce].tags||[],je=Array.from(new Set([...be,...re]));H.push({hash:ce,tags:je})}}H.length>0?(await $h(H,{mode:"union"}),h(Ce=>{let ce={...Ce};return H.forEach(({hash:be,tags:je})=>{ce[be]&&(ce[be]={...ce[be],tags:je})}),ce}),ae({title:"Tags Applied",message:`Applied tag "${t.docId}" to ${H.length} string(s).`,color:"green"})):ae({title:"No strings updated",message:"No existing translations found to tag.",color:"blue"}),n(!1)}async function rn(H){try{await H()}catch(re){console.error(re);let Ce;typeof re=="object"&&re.body?Ce=String(re.body):Ce=String(re),ae({title:"Error",message:Ce,color:"red",autoClose:!1})}}function Ed(H){switch(H){case"EXPORT_DOWNLOAD_CSV":{rn(ye);return}case"EXPORT_GOOGLE_SHEET_LINKED":{rn(un);return}case"EXPORT_GOOGLE_SHEET_SHOW_OPTIONS":{y.open({docId:t.docId,csvData:ee(),locales:s});return}case"IMPORT_CSV":{rn(Fe);return}case"IMPORT_GOOGLE_SHEET_LINKED":{rn(on);return}case"UNLINK_GOOGLE_SHEET":{rn(kl);return}default:console.log("unhandled action: "+H)}}async function wd(H,re){let ce=(window.__ROOT_CTX.translations||[]).find(be=>be.id===H)?.label||H;await rn(async()=>{let be=re==="export"?await Cw(t.docId):null,je=o.map(pn=>{let oi={};s.forEach(Vt=>{oi[Vt]=oe(pn,Vt)??""});let Mn=be?.get(pn)?.description;return{source:pn,translations:oi,...Mn?{description:Mn}:{}}}),bt=re==="import"||re==="export"?re:(()=>{throw new Error("Invalid translations action")})(),Ft=`translations-${bt}-${H}`;ae({id:Ft,message:re==="import"?`Importing from ${ce}...`:`Exporting to ${ce}...`,loading:!0,autoClose:!1,disallowClose:!0});try{let pn=await window.fetch(`/cms/api/translations.${bt}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:H,docId:t.docId,data:je})});if(!(pn.headers.get("content-type")||"").includes("application/json"))throw new Error(`Unexpected response (${pn.status}). Please reload the page and try again.`);let Mn=await pn.json();if(!Mn.success)throw new Error(Mn.error||"Unknown error");if(re==="import")if(Array.isArray(Mn.data)){let Vt=Mn.data.map(ri=>{let qo={source:String(ri?.source??"")},ii=ri?.translations;return ii&&typeof ii=="object"&&Object.entries(ii).forEach(([Qs,Dl])=>{Dl!=null&&nE(Qs).length!==0&&(qo[Qs]=String(Dl))}),qo}),Nl=await ra(t.docId,Vt,{actionMetadata:{service:H,numStrings:Vt.length,locales:i},actionLinks:[{label:"Open translations",url:`/cms/content/${t.docId}?modal=localization`}]});h(ri=>lg(ri,Nl));let qi=[t.docId],Ln=[];for(let ri of Vt){let qo=await Er(ri.source),Qs=p[qo]?.tags||[],Dl=Array.from(new Set([...Qs,...qi]));Ln.push({hash:qo,tags:Dl})}Ln.length>0&&(await $h(Ln,{mode:"union"}),h(ri=>{let qo={...ri};return Ln.forEach(({hash:ii,tags:Qs})=>{qo[ii]&&(qo[ii]={...qo[ii],tags:Qs})}),qo})),kt({id:Ft,title:"Imported!",message:`Imported translations from ${ce}.`,loading:!1,autoClose:5e3})}else{let Vt=Mn.data||{},Nl=Vt.title||"Import complete",qi=Vt.message||`Imported translations from ${ce}.`,Ln=Vt.link;kt({id:Ft,title:Nl,color:Vt.status==="success"?"green":Vt.status==="error"?"red":void 0,message:Ln?.url?f("div",{children:[f("div",{children:qi}),f(Z,{component:"a",href:Ln.url,target:"_blank",rel:"noopener noreferrer",size:"xs",variant:"default",rightIcon:f(ia,{size:14}),style:{marginTop:"8px"},children:Ln.label||"Open"})]}):qi,loading:!1,autoClose:Ln?.url?1e4:5e3})}else{let Vt=Mn.data||{},Nl=Vt.title||"Exported!",qi=Vt.message||`Exported translations to ${ce}.`,Ln=Vt.link;kt({id:Ft,title:Nl,color:Vt.status==="success"?"green":Vt.status==="error"?"red":void 0,message:Ln?.url?f("div",{children:[f("div",{children:qi}),f(Z,{component:"a",href:Ln.url,target:"_blank",rel:"noopener noreferrer",size:"xs",variant:"default",rightIcon:f(ia,{size:14}),style:{marginTop:"8px"},children:Ln.label||"Open"})]}):qi,loading:!1,autoClose:Ln?.url?1e4:5e3})}}catch(pn){throw Il(Ft),pn}})}return f("div",{className:"LocalizationModal__translations",children:[f("div",{className:"LocalizationModal__translations__topWrapper",children:[f("div",{className:"LocalizationModal__translations__header",children:[f("div",{className:"LocalizationModal__translations__titleWrap",children:f(wr,{className:"LocalizationModal__translations__title LocalizationModal__iconTitle",size:"h2",children:[f(ts,{strokeWidth:1.5})," ",f("span",{children:"Translations"})]})}),f("div",{className:"LocalizationModal__translations__header__buttons",children:[m.enabled&&_?.spreadsheetId&&f(we,{label:"Open Google Sheet",children:f(Ae,{component:"a",href:oa(_),target:"_blank",variant:"filled",color:"green",size:"sm",children:f(ou,{size:16,strokeWidth:2.25})})}),f(Z,{component:"a",href:`/cms/translations/${t.docId}`,target:"_blank",variant:"default",size:"xs",rightIcon:f(ia,{size:14,strokeWidth:1.75}),children:"Open Editor"}),f(NP,{onAction:Ed,onServiceAction:wd,gapiClient:m,linkedSheet:_}),f(DP,{onAction:Ed,onServiceAction:wd,gapiClient:m,linkedSheet:_}),f(G,{className:"LocalizationModal__translations__menu",control:f(we,{label:"Tools",children:f(Ae,{className:"LocalizationModal__translations__menu__dots",variant:"default",children:f(Gh,{size:16})})}),size:220,children:f(G.Item,{className:"LocalizationModal__translations__menu__item",icon:f(WE,{size:16}),onClick:()=>v.open({docId:t.docId,sourceStrings:o,onPruned:H=>{h(re=>{let Ce={...re};return H.forEach(ce=>delete Ce[ce]),Ce})}}),children:"Prune unused strings"})})]})]}),e&&f(jw,{labels:["Transmogrifying...","Deciphering the vibes...","Consulting the Rosetta Stone...","Untangling the syntax...","Babel-ing..."]}),!e&&E>0&&f("div",{className:"LocalizationModal__missingTags",children:[f("div",{className:"LocalizationModal__missingTags__message",children:[f(Pl,{}),E>1?f(Bt,{size:"sm",children:[f("b",{children:[E," strings"]}),' are missing the "',t.docId,'" tag.']}):f(Bt,{size:"sm",children:[f("b",{children:[E," string"]}),' is missing the "',t.docId,'" tag.']})]}),f(Z,{variant:"filled",size:"xs",onClick:()=>rn(Oh),loading:e,leftIcon:f(Gh,{size:16}),children:"Fix missing tags"})]}),!e&&f("table",{className:"LocalizationModal__translations__table",children:[f("tr",{className:"LocalizationModal__translations__table__row LocalizationModal__translations__table__row--header",children:[f("th",{className:"LocalizationModal__translations__table__header",children:f(wr,{size:"h4",weight:"semi-bold",children:"SOURCE STRING"})}),f("th",{className:"LocalizationModal__translations__table__header",children:f("div",{className:"LocalizationModal__translations__localeHeader",children:[f(wr,{className:"LocalizationModal__translations__localeSelect",size:"h4",weight:"semi-bold",children:[f("span",{children:"LOCALE: "})," ",f(Rn,{data:dt,size:"xs",placeholder:"select locale",allowDeselect:!0,value:l,onChange:H=>c(H)})]}),f("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[l&&ut>0&&f(we,{label:d?"Show all translations":"Show only missing translations",position:"top",withArrow:!0,children:f("button",{className:`LocalizationModal__translations__missingToggle${d?" LocalizationModal__translations__missingToggle--active":""}`,onClick:()=>u(H=>!H),children:[f(EE,{size:14}),f("span",{children:[ut," missing"]})]})},d?"active":"inactive"),l&&o.length>0&&ut===0&&$===0&&f("div",{className:"LocalizationModal__translations__fullyTranslated",children:[f(es,{size:14}),f("span",{children:"Translated"})]}),q()&&!N&&f(we,{label:"Generate translations using AI",withArrow:!0,position:"top",children:f(Ae,{variant:"default",size:"sm",onClick:rt,children:f(Oo,{size:14,fill:"black"})})}),N&&f(we,{label:"Stop generating",withArrow:!0,position:"top",children:f(Ae,{variant:"default",size:"sm",onClick:de,children:f(KE,{size:14,fill:"black"})})}),N&&f(Jd,{size:18,className:"LocalizationModal__spinner"})]})]})})]}),o.filter(H=>!d||!l?!0:!g[H]).map((H,re)=>f("tr",{className:"LocalizationModal__translations__table__row",children:[f("td",{className:"LocalizationModal__translations__table__col",children:f("div",{className:"LocalizationModal__sourceCell",children:[f("span",{className:"LocalizationModal__sourceCell__text",children:H}),(_t[H]||x.has(H))&&f("div",{className:"LocalizationModal__sourceCell__icons",children:[_t[H]&&f(Ae,{className:"LocalizationModal__sourceCell__link",size:"sm",variant:"subtle",onClick:async()=>{let Ce=await Er(H);window.open(`/cms/translations/${Ce}`,"_blank")},children:f(Do,{size:16})}),x.has(H)&&f(we,{label:`Missing "${t.docId}" tag`,position:"top",withArrow:!0,children:f(Ae,{className:"LocalizationModal__sourceCell__missingTag",size:"sm",variant:"subtle",children:f(Pl,{size:14})})})]})]})}),f("td",{className:"LocalizationModal__translations__table__col",children:f(kP,{source:H,locale:l,savedValue:g[H]||"",pendingValue:k[H]?.[l],isAiGenerating:O===H,readOnly:N,onEdit:Ce=>W(H,l,Ce)})})]},re))]})]}),f("div",{className:"LocalizationModal__translations__saveBar",children:[f("span",{className:"LocalizationModal__translations__saveBar__status",children:$>0?`${$} unsaved change${$!==1?"s":""}`:""}),$>0&&f(Z,{variant:"default",size:"xs",leftIcon:f(li,{size:14}),onClick:()=>T({}),children:"Discard changes"}),f(Z,{variant:"filled",size:"xs",color:"dark",leftIcon:f(es,{size:14}),onClick:P,loading:w,disabled:$===0,children:"Save"})]})]})};function kP(t){let e=t.pendingValue!==void 0?t.pendingValue:t.savedValue,o=[t.pendingValue!==void 0?"LocalizationModal__translations__cell--edited":"",t.isAiGenerating?"LocalizationModal__translations__cell--ai-generating":"",e?"":"LocalizationModal__translations__cell--empty"].filter(Boolean).join(" ")||void 0;return f(bn,{size:"xs",autosize:!0,minRows:1,value:e,placeholder:"",readOnly:t.readOnly,onChange:r=>t.onEdit(r.currentTarget.value),className:o,styles:{root:{height:"100%"},wrapper:{height:"100%"},input:{fontSize:"12px",minHeight:"100%"}}})}function NP(t){function e(r){t.onAction&&t.onAction(r)}let n=t.linkedSheet,o=(window.__ROOT_CTX.translations||[]).filter(r=>r.hasImport);return f(G,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"end",control:f(Z,{variant:"default",color:"dark",size:"xs",leftIcon:f(Bl,{size:16,strokeWidth:1.75}),rightIcon:f(go,{size:16,strokeWidth:1.75}),children:"Import"}),children:[t.gapiClient.enabled&&f(Ne,{children:[f(G.Label,{children:"Google Sheets"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",disabled:!n?.spreadsheetId,onClick:()=>e("IMPORT_GOOGLE_SHEET_LINKED"),children:"Import Google Sheet"}),f(xr,{})]}),f(G.Label,{children:"File"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("IMPORT_CSV"),children:"Import .csv"}),o.length>0&&f(Ne,{children:[f(xr,{}),f(G.Label,{children:"Services"}),o.map(r=>f(G.Item,{className:"LocalizationModal__translations__menu__item",icon:r.icon?f("img",{src:r.icon,alt:r.label,style:{width:16,height:16}}):void 0,onClick:()=>t.onServiceAction?.(r.id,"import"),children:["Import from ",r.label]},r.id))]})]})}function DP(t){async function e(i){t.onAction&&t.onAction(i)}let o=!!t.linkedSheet?.spreadsheetId,r=(window.__ROOT_CTX.translations||[]).filter(i=>i.hasExport);return f(G,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"start",control:f(Z,{variant:"default",color:"dark",size:"xs",leftIcon:f(CE,{size:16,strokeWidth:1.75}),rightIcon:f(go,{size:16,strokeWidth:1.75}),children:"Export"}),children:[t.gapiClient.enabled&&f(Ne,{children:[f(G.Label,{children:"Google Sheets"}),o?f(Ne,{children:f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_LINKED"),children:"Export to Google Sheet"})}):f(Ne,{children:f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_SHOW_OPTIONS"),children:"Export to Google Sheet"})}),f(xr,{})]}),f(G.Label,{children:"File"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_DOWNLOAD_CSV"),children:"Download .csv"}),r.length>0&&f(Ne,{children:[f(xr,{}),f(G.Label,{children:"Services"}),r.map(i=>f(G.Item,{className:"LocalizationModal__translations__menu__item",icon:i.icon?f("img",{src:i.icon,alt:i.label,style:{width:16,height:16}}):void 0,onClick:()=>t.onServiceAction?.(i.id,"export"),children:["Export to ",i.label]},i.id))]}),o&&f(Ne,{children:[f(xr,{}),f(G.Label,{children:"Danger zone"}),f(G.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("UNLINK_GOOGLE_SHEET"),color:"red",children:"Unlink Google Sheet"})]})]})}function lg(t,e){let n={...t};for(let[o,r]of Object.entries(e)){let i=n[o];n[o]=i?{...i,...r}:r}return n}function Gw(t){let e=t.split("_"),n=e[0];if(n==="ALL"){let i=String(e[1]).toUpperCase();return`${new Intl.DisplayNames(["en"],{type:"region"}).of(i)||t} (${t})`}return`${new Intl.DisplayNames(["en"],{type:"language"}).of(n)||t} (${t})`}ke();function Yw(t){let e=new Set;return cg(t,e),Array.from(e)}function cg(t,e){if(!(!t||typeof t!="object")){if(Array.isArray(t)){for(let n of t)cg(n,e);return}if(OP(t)){e.add(t.id);return}for(let n of Object.keys(t))cg(t[n],e)}}function OP(t){return typeof t.id=="string"&&typeof t.collection=="string"&&typeof t.slug=="string"&&t.id.includes("/")}var qw="PublishDocModal";function Jw(t){let e=St(),n=ot();return{open:()=>{e.openContextModal(qw,{...n,title:`Publish ${t.docId}`,innerProps:t,size:"850px"})}}}function IP(t){let{innerProps:e,context:n,id:o}=t,[r,i]=L(""),[s,a]=L(""),[l,c]=L(!1),[d,u]=L(""),[p,h]=L(!1),g=J(null),m=St(),_=ot(),b=Io(),{roles:y,loading:v}=su(),x=window.firebase.user.email||"",C=au(y,x),E=r==="scheduled"?"Schedule":"Publish";async function k(){try{c(!0),await rE(e.docId,{publishMessage:d.trim()||void 0}),c(!1),ae({title:"Published!",message:`Succesfully published ${e.docId}.`,autoClose:1e4}),m.closeAll()}catch(D){console.error(D);let O=Al(D);ae({title:"Publish failed",message:`Failed to publish ${e.docId}: ${O}`,color:"red",autoClose:!1})}}async function T(){try{c(!0);let D=Math.floor(new Date(s).getTime());await iE(e.docId,D,{publishMessage:d.trim()||void 0}),c(!1),ae({title:"Scheduled!",message:`${e.docId} will go live ${s}.`,autoClose:1e4}),m.closeAll()}catch(D){console.error(D);let O=Al(D);ae({title:"Schedule failed",message:`Failed to schedule ${e.docId}: ${O}`,color:"red",autoClose:!1})}}async function w(){try{h(!0);let O=await(await window.fetch("/cms/api/ai.publish_message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({docId:e.docId})})).json();O.success&&O.message?u(O.message):ae({title:"Generation failed",message:"Failed to generate publish message.",color:"red",autoClose:5e3})}catch(D){console.error(D),ae({title:"Generation failed",message:"Failed to generate publish message.",color:"red",autoClose:5e3})}finally{h(!1)}}function S(){m.openConfirmModal({..._,title:`${E} ${e.docId}`,children:f(Ne,{children:[f(os,{size:"body-sm",weight:"semi-bold",className:"PublishDocModal__confirmText",children:["Are you sure you want to publish the following doc? The doc will go live ",r==="now"?"now":`at ${s}`,"."]}),f(ww,{docId:e.docId})]}),labels:{confirm:E,cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{r==="now"?k():r==="scheduled"&&T()}})}let N=!0;return(r==="now"||r==="scheduled"&&s)&&(N=!1),(v||!C)&&(N=!0),f("div",{className:"PublishDocModal",children:f("div",{className:"PublishDocModal__content",children:[f("form",{className:"PublishDocModal__form",onSubmit:D=>{D.preventDefault(),S()},children:[f("div",{className:"PublishDocModal__form__publishOptions",children:f("div",{className:"PublishDocModal__form__publishOptions__options",children:[f("label",{className:xe("PublishDocModal__form__publishOptions__option",r==="now"&&"PublishDocModal__form__publishOptions__option--selected",r&&r!=="now"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"now",checked:r==="now",onChange:()=>i("now")})," ","Now"]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live immediately."})]}),f("label",{className:xe("PublishDocModal__form__publishOptions__option",r==="scheduled"&&"PublishDocModal__form__publishOptions__option--selected",r&&r!=="scheduled"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"scheduled",checked:r==="scheduled",onChange:()=>i("scheduled")}),f("div",{children:"Scheduled"})]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live at the date and time specified below."}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2",children:[f("input",{ref:g,type:"datetime-local",disabled:r!=="scheduled",value:s,min:HC(),onChange:D=>{let O=D.target;a(O.value)}}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})]})]})}),f("div",{className:"PublishDocModal__form__publishMessage",children:f("div",{className:"PublishDocModal__form__publishMessage__wrapper",children:[f("textarea",{className:"PublishDocModal__form__publishMessage__textarea",placeholder:"Optional: Add a message to describe the changes",value:d,rows:3,onInput:D=>{let O=D.target;u(O.value)}}),b&&f("button",{type:"button",className:"PublishDocModal__form__publishMessage__sparkle",onClick:w,disabled:p,children:f(we,{label:"Generate message",withArrow:!0,position:"left",allowPointerEvents:!0,wrapLines:!0,children:p?f(xt,{size:16}):f(Oo,{size:16,stroke:1.5})})})]})}),f("div",{className:"PublishDocModal__form__buttons",children:[f(Z,{variant:"outline",onClick:()=>n.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(Z,{variant:"filled",size:"xs",color:"dark",disabled:N,loading:l,type:"submit",children:E})]})]}),f("div",{className:"PublishDocModal__DiffWrapper",children:[f(LP,{docId:e.docId}),b&&f(ew,{docId:e.docId,beforeVersion:"published",afterVersion:"draft"}),f(AP,{docId:e.docId})]})]})})}function AP(t){let e=t.docId,[n,o]=L(!1);function r(){o(!0)}return f("div",{className:"PublishDocModal__ShowChanges",children:f(Rh,{iconPosition:"right",onChange:()=>r(),disableIconRotation:!0,children:f(Rh.Item,{label:"Compare JSON data",icon:f(wE,{stroke:1.5}),iconPosition:"left",children:n&&f(nw,{left:{docId:e,versionId:"published"},right:{docId:e,versionId:"draft"},showExpandButton:!0,showAiSummary:!1})})})})}function MP(t){let e=t?.sys;return e?!!(!e.publishedAt||e.modifiedAt&&e.modifiedAt>e.publishedAt):!1}function LP(t){let[e,n]=L(!0),[o,r]=L([]);F(()=>{async function a(){n(!0);try{let l=await Qi(t.docId);if(!l?.fields){n(!1);return}let c=Yw(l.fields).filter(u=>u!==t.docId);if(c.length===0){n(!1);return}let d=[];await Promise.all(c.map(async u=>{try{let p=await Qi(u);p&&MP(p)&&d.push(u)}catch(p){console.warn(`Failed to fetch reference doc: ${u}`,p)}})),r(d.sort())}catch(l){console.error("Failed to load reference docs",l)}n(!1)}a()},[t.docId]);let i=[t.docId,...o],s=sw({docIds:i});return e?f("div",{className:"PublishDocModal__ReferenceDocs",children:f(xt,{color:"gray",size:"sm"})}):o.length===0?null:f("div",{className:"PublishDocModal__ReferenceDocs",children:[f("div",{className:"PublishDocModal__ReferenceDocs__header",children:[f("div",{className:"PublishDocModal__ReferenceDocs__header__label",children:["Referenced docs with unpublished changes (",o.length,")"]}),f(Z,{variant:"outline",size:"xs",color:"dark",leftIcon:f(zE,{size:16}),onClick:()=>s.open(),children:"Bundle all docs into a release"})]}),f("div",{className:"PublishDocModal__ReferenceDocs__list",children:o.map(a=>f(iu,{docId:a,variant:"compact",statusBadges:!0,clickable:!0},a))})]})}IP.id=qw;br();ke();function du(t,e){let n;return(...o)=>{window.clearTimeout(n),n=window.setTimeout(()=>{t(...o)},e)}}var mo=class{constructor(){this.events=new Map}on(e,n){let o=No(6),r=this.events.get(e);return r||(r=new Map,this.events.set(e,r)),r.set(o,n),()=>{this.off(e,o)}}off(e,n){let o=this.events.get(e);o&&(o.delete(n),o.size===0&&this.events.delete(e))}dispatch(e,...n){let o=this.events.get(e);o&&o.forEach(r=>r(...n))}dispose(){this.events.clear()}};var uu=class{constructor(){this.subscribers=new Set;this.subtreeSubscribers=new Set;this.children=new Map}},pu=class extends mo{constructor(n){super();this.root=new uu;this.data=n||{}}get(n){return this.getValueFromPath(n,this.data)}set(n,o){if(n===""){Pn(o)&&this.setData(o);return}this.update({[n]:o})}update(n){let o=new Map,r=(s,a,l)=>{if(o.set(s,l),!Pn(a)&&!Pn(l))return;let c=Pn(a)?Object.keys(a):[],d=Pn(l)?Object.keys(l):[];new Set([...c,...d]).forEach(p=>{let h=Pn(a)?a[p]:void 0,g=Pn(l)?l[p]:void 0;Jh(h,g)||r(`${s}.${p}`,h,g)})};Object.entries(n).forEach(([s,a])=>{let l=this.data,c=s.split("."),d=c.pop();for(let p of c)l[p]||(l[p]={}),l=l[p];let u=l[d];l[d]=a,this.dispatch("VALUE_CHANGE",s,a),r(s,u,a)});let i=new Map;o.forEach((s,a)=>{this.collectSubtreeNotifications(a,i)}),o.forEach((s,a)=>{let l=this.getTrieNode(a);l&&l.subscribers.size>0&&l.subscribers.forEach(c=>c(s))}),i.forEach((s,a)=>{let l=this.get(a);s.subtreeSubscribers.forEach(c=>c(l))}),this.dispatch("CHANGE",this.data)}setData(n){let o=this.data;this.notifyOnUpdate(this.root,"",o,n),this.data=n,this.dispatch("CHANGE",this.data)}subscribe(n,o){let r=this.getTrieNode(n,!0);return r.subscribers.add(o),window.setTimeout(()=>{let i=this.get(n);i!==void 0&&o(i)}),()=>{r.subscribers.delete(o)}}subscribeSubtree(n,o){let r=this.getTrieNode(n,!0);return r.subtreeSubscribers.add(o),window.setTimeout(()=>{let i=this.get(n);i!==void 0&&o(i)}),()=>{r.subtreeSubscribers.delete(o)}}getDataSnapshot(){return this.data}dispose(){super.dispose(),this.data={},this.root.subscribers.clear(),this.root.subtreeSubscribers.clear(),this.root.children.clear()}notifyOnUpdate(n,o,r,i){let s=this.getValueFromPath(o,r),a=this.getValueFromPath(o,i);Jh(s,a)||(n.subscribers.forEach(l=>l(a)),n.subtreeSubscribers.forEach(l=>l(a))),n.children.forEach((l,c)=>{let d=o?`${o}.${c}`:c;this.notifyOnUpdate(l,d,r,i)})}collectSubtreeNotifications(n,o){let r=this.root;if(r.subtreeSubscribers.size>0&&o.set("",r),!n)return;let i="";for(let s of n.split(".")){if(r=r.children.get(s),!r)return;i=i?`${i}.${s}`:s,r.subtreeSubscribers.size>0&&o.set(i,r)}}getValueFromPath(n,o){if(!n)return o;let r=n.split("."),i=o;for(let s of r){if(i===null||typeof i!="object"||!(s in i))return;i=i[s]}return i}getTrieNode(n,o=!1){if(!n)return this.root;let r=n.split("."),i=this.root;for(let s of r){if(!i.children.has(s))if(o)i.children.set(s,new uu);else return;i=i.children.get(s)}return i}};var Xw=3*Zi.second,RP=5*Zi.minute;var PP=30*Zi.second,dg=class extends mo{constructor(n){super();this.pendingUpdates=new Map;this.saveState="NO_CHANGES";this.autolock=!1;this.autolockReason="autolock";this.autolockApplied=!1;this.mightHaveAssetChanges=!1;this.readOnly=!1;this.autoSave=!0;this.flushOnStop=!0;this.started=!1;this.queueChanges=du(()=>this.flush(),Xw);this.projectId=window.__ROOT_CTX.rootConfig.projectId;let[o,r]=n.split("/");this.docId=n,this.collectionId=o,this.slug=r,this.db=window.firebase.db,this.docRef=Ad(this.db,"Projects",this.projectId,"Collections",o,"Drafts",r),this.store=new pu({id:this.docId,collection:this.collectionId,slug:this.slug,sys:{}}),this.store.on("CHANGE",s=>{this.dispatch("CHANGE",s)}),this.store.on("VALUE_CHANGE",(s,a)=>{this.dispatch("VALUE_CHANGE",s,a)});let i=window.__ROOT_CTX.collections[o];i&&(this.autolock=!!i.autolock,i.autolockReason&&(this.autolockReason=i.autolockReason))}async start(){if(this.started)return;this.started=!0;let n=!0;this.dbUnsubscribe=Ld(this.docRef,o=>{if(o.metadata.hasPendingWrites)return;let r=o.data()||{};this.pendingUpdates.size>0&&Qw(r,Object.fromEntries(this.pendingUpdates)),this.store.setData(r),n&&(n=!1,Array.isArray(r?.sys?.assets)||(this.mightHaveAssetChanges=!0))})}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.flushOnStop&&this.flush(),this.started=!1)}onChange(n){return this.on("CHANGE",n)}onSaveStateChange(n){return this.on("SAVE_STATE_CHANGE",n)}onFlush(n){return this.on("FLUSH",n)}subscribe(n,o){return this.store.subscribe(n,o)}subscribeSubtree(n,o){return this.store.subscribeSubtree(n,o)}getData(){return this.store.getDataSnapshot()}getValue(n){return this.store.get(n)}async updateKey(n,o){this.readOnly||(o===void 0?this.setPendingUpdate(n,Rd()):this.setPendingUpdate(n,o),this.store.set(n,o),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}async updateKeys(n){if(!this.readOnly){for(let o in n){let r=n[o];r==null?this.setPendingUpdate(o,Rd()):this.setPendingUpdate(o,r)}this.store.update(n),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges()}}async removeKey(n){this.readOnly||(this.setPendingUpdate(n,Rd()),this.store.set(n,void 0),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}setPendingUpdate(n,o){for(let r of this.pendingUpdates.keys())zP(r,n)&&this.pendingUpdates.delete(r);this.pendingUpdates.set(n,o),!this.mightHaveAssetChanges&&n.startsWith("fields")&&(Bh(o)||Bh(this.store.get(n)))&&(this.mightHaveAssetChanges=!0)}getPendingUpdates(){return BP(Object.fromEntries(this.pendingUpdates))}setSaveState(n){let o=this.saveState;n==="SAVED"&&o!=="SAVING"||(this.saveState=n,n==="SAVED"&&window.setTimeout(()=>{this.saveState==="SAVED"&&this.setSaveState("NO_CHANGES")},Xw),this.dispatch("SAVE_STATE_CHANGE",n))}removePublishingLock(){this.autolockApplied=!0,this.removeKey("sys.publishingLocked"),this.flush()}async flush(n){if(this.readOnly||this.pendingUpdates.size===0)return;let o=this.getPendingUpdates();if(o["sys.modifiedAt"]=ta(),o["sys.modifiedBy"]=window.firebase.user.email,this.mightHaveAssetChanges){let r=XC(this.store.get("fields")||{}),i=this.store.get("sys.assets")||[];HP(r,i)||(o["sys.assets"]=r)}this.autolock&&!this.autolockApplied&&!this.store.get("sys.publishingLocked")&&(this.autolockApplied=!0,o["sys.publishingLocked"]={lockedAt:ta(),lockedBy:window.firebase.user.email,reason:this.autolockReason}),this.pendingUpdates.clear();try{this.setSaveState("SAVING"),await Md(this.docRef,o),this.mightHaveAssetChanges=!1,this.setSaveState("SAVED"),n?.quiet||this.dispatch("FLUSH"),Pd("doc.save",{metadata:{docId:this.docId},throttle:RP,throttleId:this.docId})}catch(r){console.error("failed to update doc:",r),this.setSaveState("ERROR");let i=Al(r);ae({title:`Failed to save ${this.slug}`,message:i||`Something went wrong while saving ${this.slug}`,color:"red",autoClose:!1});for(let s in o)s.startsWith("sys.")||this.pendingUpdates.has(s)||(this.pendingUpdates.set(s,o[s]),this.queueChanges(),console.log("re-queued updates"),console.log(this.pendingUpdates))}}getLocales(){let n=this.store.get("sys.locales");return n||["en"]}setLocales(n){this.updateKey("sys.locales",n)}async dispose(){super.dispose(),this.stop()}};function Qw(t,e){for(let n in e){let o=e[n];if(n.includes(".")){let[r,i]=FP(n);t[r]??={},Qw(t[r],{[i]:o})}else typeof o>"u"?delete t[n]:t[n]=o}}function FP(t){let e=t.indexOf("."),n=t.substring(0,e),o=t.substring(e+1);return[n,o]}function BP(t){let e={...t};for(let n in e)$P(n,e)&&delete e[n];return e}function $P(t,e){let n=t.split(".");for(let o=1;o<n.length;o++)if(n.slice(0,o).join(".")in e)return!0;return!1}function zP(t,e){return t.startsWith(`${e}.`)}function HP(t,e){return t.length===e.length&&t.every((n,o)=>n===e[o])}var ug=pt(null);function e0(t){let[e,n]=L(!0),o=X(()=>new dg(t.docId),[t.docId]);o.readOnly=t.readOnly??!1,o.autoSave=t.autoSave??!0,o.flushOnStop=t.flushOnStop??!0,F(()=>(n(!0),o.onChange(i=>{n(!1),KC(i.id,i)}),o.start(),()=>o.dispose()),[o]),F(()=>{let i,s=()=>{document.hidden||document.visibilityState!=="visible"?i=window.setTimeout(()=>{o.stop()},PP):(i&&(clearTimeout(i),i=void 0),o.started||o.start())};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),i&&clearTimeout(i)}},[o]);let r=X(()=>({loading:e,controller:o}),[e,o]);return f(ug.Provider,{value:r,children:t.children})}function fu(t){return f(ug.Provider,{value:t.value,children:t.children})}function sn(){let t=ft(ug);if(!t)throw new Error("useDraftDoc() should be used within a <DraftDocProvider>");return t}function t0(t){let{controller:e}=sn();F(()=>e.onSaveStateChange(t),[e])}function Kq(t){let{controller:e}=sn();F(()=>e.onChange(t),[e])}function Xo(t,e){let{controller:n}=sn();F(()=>n.subscribe(t,e),[n])}function At(t,e){let{controller:n}=sn(),[o,r]=L(n.getValue(t)??e);return F(()=>n.subscribe(t,s=>{r(s)}),[n]),[o,s=>{r(s),s==null?n.removeKey(t):n.updateKey(t,s)}]}yt();yt();function xn(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var UP=typeof Symbol=="function"&&Symbol.observable||"@@observable",n0=UP,pg=()=>Math.random().toString(36).substring(7).split("").join("."),KP={INIT:`@@redux/INIT${pg()}`,REPLACE:`@@redux/REPLACE${pg()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${pg()}`},o0=KP;function jP(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function fg(t,e,n){if(typeof t!="function")throw new Error(xn(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(xn(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(xn(1));return n(fg)(t,e)}let o=t,r=e,i=new Map,s=i,a=0,l=!1;function c(){s===i&&(s=new Map,i.forEach((_,b)=>{s.set(b,_)}))}function d(){if(l)throw new Error(xn(3));return r}function u(_){if(typeof _!="function")throw new Error(xn(4));if(l)throw new Error(xn(5));let b=!0;c();let y=a++;return s.set(y,_),function(){if(b){if(l)throw new Error(xn(6));b=!1,c(),s.delete(y),i=null}}}function p(_){if(!jP(_))throw new Error(xn(7));if(typeof _.type>"u")throw new Error(xn(8));if(typeof _.type!="string")throw new Error(xn(17));if(l)throw new Error(xn(9));try{l=!0,r=o(r,_)}finally{l=!1}return(i=s).forEach(y=>{y()}),_}function h(_){if(typeof _!="function")throw new Error(xn(10));o=_,p({type:o0.REPLACE})}function g(){let _=u;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(xn(11));function y(){let x=b;x.next&&x.next(d())}return y(),{unsubscribe:_(y)}},[n0](){return this}}}return p({type:o0.INIT}),{dispatch:p,subscribe:u,getState:d,replaceReducer:h,[n0]:g}}function r0(t,e){return function(...n){return e(t.apply(this,n))}}function hg(t,e){if(typeof t=="function")return r0(t,e);if(typeof t!="object"||t===null)throw new Error(xn(16));let n={};for(let o in t){let r=t[o];typeof r=="function"&&(n[o]=r0(r,e))}return n}function gg(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...o)=>e(n(...o)))}function i0(...t){return e=>(n,o)=>{let r=e(n,o),i=()=>{throw new Error(xn(15))},s={getState:r.getState,dispatch:(l,...c)=>i(l,...c)},a=t.map(l=>l(s));return i=gg(...a)(r.dispatch),{...r,dispatch:i}}}yt();var WF=Ah(c0(),1),ZP=SC.startsWith("19"),QP=Symbol.for(ZP?"react.transitional.element":"react.element"),eF=Symbol.for("react.portal"),tF=Symbol.for("react.fragment"),nF=Symbol.for("react.strict_mode"),oF=Symbol.for("react.profiler"),rF=Symbol.for("react.consumer"),iF=Symbol.for("react.context"),m0=Symbol.for("react.forward_ref"),sF=Symbol.for("react.suspense"),aF=Symbol.for("react.suspense_list"),yg=Symbol.for("react.memo"),lF=Symbol.for("react.lazy");var cF=m0,dF=yg;function uF(t){if(typeof t=="object"&&t!==null){let{$$typeof:e}=t;switch(e){case QP:switch(t=t.type,t){case tF:case oF:case nF:case sF:case aF:return t;default:switch(t=t&&t.$$typeof,t){case iF:case m0:case lF:case yg:return t;case rF:return t;default:return e}}case eF:return e}}}function pF(t){return uF(t)===yg}function fF(t,e,n,o,{areStatesEqual:r,areOwnPropsEqual:i,areStatePropsEqual:s}){let a=!1,l,c,d,u,p;function h(y,v){return l=y,c=v,d=t(l,c),u=e(o,c),p=n(d,u,c),a=!0,p}function g(){return d=t(l,c),e.dependsOnOwnProps&&(u=e(o,c)),p=n(d,u,c),p}function m(){return t.dependsOnOwnProps&&(d=t(l,c)),e.dependsOnOwnProps&&(u=e(o,c)),p=n(d,u,c),p}function _(){let y=t(l,c),v=!s(y,d);return d=y,v&&(p=n(d,u,c)),p}function b(y,v){let x=!i(v,c),C=!r(y,l,v,c);return l=y,c=v,x&&C?g():x?m():C?_():p}return function(v,x){return a?b(v,x):h(v,x)}}function hF(t,{initMapStateToProps:e,initMapDispatchToProps:n,initMergeProps:o,...r}){let i=e(t,r),s=n(t,r),a=o(t,r);return fF(i,s,a,t,r)}function gF(t,e){let n={};for(let o in t){let r=t[o];typeof r=="function"&&(n[o]=(...i)=>e(r(...i)))}return n}function _g(t){return function(n){let o=t(n);function r(){return o}return r.dependsOnOwnProps=!1,r}}function d0(t){return t.dependsOnOwnProps?!!t.dependsOnOwnProps:t.length!==1}function _0(t,e){return function(o,{displayName:r}){let i=function(a,l){return i.dependsOnOwnProps?i.mapToProps(a,l):i.mapToProps(a,void 0)};return i.dependsOnOwnProps=!0,i.mapToProps=function(a,l){i.mapToProps=t,i.dependsOnOwnProps=d0(t);let c=i(a,l);return typeof c=="function"&&(i.mapToProps=c,i.dependsOnOwnProps=d0(c),c=i(a,l)),c},i}}function xg(t,e){return(n,o)=>{throw new Error(`Invalid value of type ${typeof t} for ${e} argument when connecting component ${o.wrappedComponentName}.`)}}function mF(t){return t&&typeof t=="object"?_g(e=>gF(t,e)):t?typeof t=="function"?_0(t,"mapDispatchToProps"):xg(t,"mapDispatchToProps"):_g(e=>({dispatch:e}))}function _F(t){return t?typeof t=="function"?_0(t,"mapStateToProps"):xg(t,"mapStateToProps"):_g(()=>({}))}function bF(t,e,n){return{...n,...t,...e}}function yF(t){return function(n,{displayName:o,areMergedPropsEqual:r}){let i=!1,s;return function(l,c,d){let u=t(l,c,d);return i?r(u,s)||(s=u):(i=!0,s=u),s}}}function xF(t){return t?typeof t=="function"?yF(t):xg(t,"mergeProps"):()=>bF}function vF(t){t()}function CF(){let t=null,e=null;return{clear(){t=null,e=null},notify(){vF(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){let n=[],o=t;for(;o;)n.push(o),o=o.next;return n},subscribe(n){let o=!0,r=e={callback:n,next:null,prev:e};return r.prev?r.prev.next=r:t=r,function(){!o||t===null||(o=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:t=r.next)}}}}var u0={notify(){},get:()=>[]};function b0(t,e){let n,o=u0,r=0,i=!1;function s(m){d();let _=o.subscribe(m),b=!1;return()=>{b||(b=!0,_(),u())}}function a(){o.notify()}function l(){g.onStateChange&&g.onStateChange()}function c(){return i}function d(){r++,n||(n=e?e.addNestedSub(l):t.subscribe(l),o=CF())}function u(){r--,n&&r===0&&(n(),n=void 0,o.clear(),o=u0)}function p(){i||(i=!0,d())}function h(){i&&(i=!1,u())}let g={addNestedSub:s,notifyNestedSubs:a,handleChangeWrapper:l,isSubscribed:c,trySubscribe:p,tryUnsubscribe:h,getListeners:()=>o};return g}var EF=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",wF=EF(),TF=()=>typeof navigator<"u"&&navigator.product==="ReactNative",SF=TF(),kF=()=>wF||SF?_n:F,hu=kF();function p0(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function mg(t,e){if(p0(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(e,n[r])||!p0(t[n[r]],e[n[r]]))return!1;return!0}var NF={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},DF={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},OF={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},y0={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},IF={[cF]:OF,[dF]:y0};function f0(t){return pF(t)?y0:IF[t.$$typeof]||NF}var AF=Object.defineProperty,MF=Object.getOwnPropertyNames,h0=Object.getOwnPropertySymbols,LF=Object.getOwnPropertyDescriptor,RF=Object.getPrototypeOf,g0=Object.prototype;function bg(t,e){if(typeof e!="string"){if(g0){let i=RF(e);i&&i!==g0&&bg(t,i)}let n=MF(e);h0&&(n=n.concat(h0(e)));let o=f0(t),r=f0(e);for(let i=0;i<n.length;++i){let s=n[i];if(!DF[s]&&!(r&&r[s])&&!(o&&o[s])){let a=LF(e,s);try{AF(t,s,a)}catch{}}}}return t}var PF=Symbol.for("react-redux-context"),FF=typeof globalThis<"u"?globalThis:{};function BF(){if(!pt)return{};let t=FF[PF]??=new Map,e=t.get(pt);return e||(e=pt(null),t.set(pt,e)),e}var x0=BF(),$F=[null,null];function zF(t,e,n){hu(()=>t(...e),n)}function HF(t,e,n,o,r,i){t.current=o,n.current=!1,r.current&&(r.current=null,i())}function UF(t,e,n,o,r,i,s,a,l,c,d){if(!t)return()=>{};let u=!1,p=null,h=()=>{if(u||!a.current)return;let m=e.getState(),_,b;try{_=o(m,r.current)}catch(y){b=y,p=y}b||(p=null),_===i.current?s.current||c():(i.current=_,l.current=_,s.current=!0,d())};return n.onStateChange=h,n.trySubscribe(),h(),()=>{if(u=!0,n.tryUnsubscribe(),n.onStateChange=null,p)throw p}}function KF(t,e){return t===e}function jF(t,e,n,{pure:o,areStatesEqual:r=KF,areOwnPropsEqual:i=mg,areStatePropsEqual:s=mg,areMergedPropsEqual:a=mg,forwardRef:l=!1,context:c=x0}={}){let d=c,u=_F(t),p=mF(e),h=xF(n),g=!!t;return _=>{let b=_.displayName||_.name||"Component",y=`Connect(${b})`,v={shouldHandleStateChanges:g,displayName:y,wrappedComponentName:b,WrappedComponent:_,initMapStateToProps:u,initMapDispatchToProps:p,initMergeProps:h,areStatesEqual:r,areStatePropsEqual:s,areOwnPropsEqual:i,areMergedPropsEqual:a};function x(k){let[T,w,S]=X(()=>{let{reactReduxForwardedRef:Be,...on}=k;return[k.context,Be,on]},[k]),N=X(()=>{let Be=d;return T?.Consumer,Be},[T,d]),D=ft(N),O=!!k.store&&!!k.store.getState&&!!k.store.dispatch,A=!!D&&!!D.store,I=O?k.store:D.store,R=A?D.getServerState:I.getState,$=X(()=>hF(I.dispatch,v),[I]),[W,P]=X(()=>{if(!g)return $F;let Be=b0(I,O?void 0:D.subscription),on=Be.notifyNestedSubs.bind(Be);return[Be,on]},[I,O,D]),q=X(()=>O?D:{...D,subscription:W},[O,D,W]),de=J(void 0),rt=J(S),Tt=J(void 0),_t=J(!1),dt=J(!1),ut=J(void 0);hu(()=>(dt.current=!0,()=>{dt.current=!1}),[]);let oe=X(()=>()=>Tt.current&&S===rt.current?Tt.current:$(I.getState(),S),[I,S]),ee=X(()=>on=>W?UF(g,I,W,$,rt,de,_t,dt,Tt,P,on):()=>{},[W]);zF(HF,[rt,de,_t,S,Tt,P]);let ye;try{ye=EC(ee,oe,R?()=>$(R(),S):oe)}catch(Be){throw ut.current&&(Be.message+=`
|
|
19
19
|
The error may be correlated with this previous error:
|
|
20
20
|
${ut.current.stack}
|
|
21
21
|
|
|
@@ -79,7 +79,7 @@ ${ut.current.stack}
|
|
|
79
79
|
-ms-user-select: none;
|
|
80
80
|
overflow-anchor: none;
|
|
81
81
|
`}}];return{always:Vl(s,"always"),resting:Vl(s,"resting"),dragging:Vl(s,"dragging"),dropAnimating:Vl(s,"dropAnimating"),userCancel:Vl(s,"userCancel")}},to=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?_n:F,Og=()=>{let t=document.querySelector("head");return t||j(),t},U0=t=>{let e=document.createElement("style");return t&&e.setAttribute("nonce",t),e.type="text/css",e};function O2(t,e){let n=Pe(()=>D2(t),[t]),o=J(null),r=J(null),i=le(Wt(u=>{let p=r.current;p||j(),p.textContent=u}),[]),s=le(u=>{let p=o.current;p||j(),p.textContent=u},[]);to(()=>{!o.current&&!r.current||j();let u=U0(e),p=U0(e);return o.current=u,r.current=p,u.setAttribute(`${ua}-always`,t),p.setAttribute(`${ua}-dynamic`,t),Og().appendChild(u),Og().appendChild(p),s(n.always),i(n.resting),()=>{let h=g=>{let m=g.current;m||j(),Og().removeChild(m),g.current=null};h(o),h(r)}},[e,s,i,n.always,n.resting,t]);let a=le(()=>i(n.dragging),[i,n.dragging]),l=le(u=>{if(u==="DROP"){i(n.dropAnimating);return}i(n.userCancel)},[i,n.dropAnimating,n.userCancel]),c=le(()=>{r.current&&i(n.resting)},[i,n.resting]);return Pe(()=>({dragging:a,dropping:l,resting:c}),[a,l,c])}function RT(t,e){return Array.from(t.querySelectorAll(e))}var PT=t=>t&&t.ownerDocument&&t.ownerDocument.defaultView?t.ownerDocument.defaultView:window;function sc(t){return t instanceof PT(t).HTMLElement}function FT(t,e){let n=`[${pa.contextId}="${t}"]`,o=RT(document,n);if(!o.length)return null;let r=o.find(i=>i.getAttribute(pa.draggableId)===e);return!r||!sc(r)?null:r}function I2(t){let e=J({}),n=J(null),o=J(null),r=J(!1),i=le(function(p,h){let g={id:p,focus:h};return e.current[p]=g,function(){let _=e.current;_[p]!==g&&delete _[p]}},[]),s=le(function(p){let h=FT(t,p);h&&h!==document.activeElement&&h.focus()},[t]),a=le(function(p,h){n.current===p&&(n.current=h)},[]),l=le(function(){o.current||r.current&&(o.current=requestAnimationFrame(()=>{o.current=null;let p=n.current;p&&s(p)}))},[s]),c=le(function(p){n.current=null;let h=document.activeElement;h&&h.getAttribute(pa.draggableId)===p&&(n.current=p)},[]);return to(()=>(r.current=!0,function(){r.current=!1;let p=o.current;p&&cancelAnimationFrame(p)}),[]),Pe(()=>({register:i,tryRecordFocus:c,tryRestoreFocusRecorded:l,tryShiftRecord:a}),[i,c,l,a])}function A2(){let t={draggables:{},droppables:{}},e=[];function n(u){return e.push(u),function(){let h=e.indexOf(u);h!==-1&&e.splice(h,1)}}function o(u){e.length&&e.forEach(p=>p(u))}function r(u){return t.draggables[u]||null}function i(u){let p=r(u);return p||j(),p}let s={register:u=>{t.draggables[u.descriptor.id]=u,o({type:"ADDITION",value:u})},update:(u,p)=>{let h=t.draggables[p.descriptor.id];h&&h.uniqueId===u.uniqueId&&(delete t.draggables[p.descriptor.id],t.draggables[u.descriptor.id]=u)},unregister:u=>{let p=u.descriptor.id,h=r(p);h&&u.uniqueId===h.uniqueId&&(delete t.draggables[p],t.droppables[u.descriptor.droppableId]&&o({type:"REMOVAL",value:u}))},getById:i,findById:r,exists:u=>!!r(u),getAllByType:u=>Object.values(t.draggables).filter(p=>p.descriptor.type===u)};function a(u){return t.droppables[u]||null}function l(u){let p=a(u);return p||j(),p}let c={register:u=>{t.droppables[u.descriptor.id]=u},unregister:u=>{let p=a(u.descriptor.id);p&&u.uniqueId===p.uniqueId&&delete t.droppables[u.descriptor.id]},getById:l,findById:a,exists:u=>!!a(u),getAllByType:u=>Object.values(t.droppables).filter(p=>p.descriptor.type===u)};function d(){t.draggables={},t.droppables={},e.length=0}return{draggable:s,droppable:c,subscribe:n,clean:d}}function M2(){let t=Pe(A2,[]);return F(()=>function(){t.clean()},[t]),t}var rm=nt.createContext(null),ec=()=>{let t=document.body;return t||j(),t},L2={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},R2=t=>`rfd-announcement-${t}`;function P2(t){let e=Pe(()=>R2(t),[t]),n=J(null);return F(function(){let i=document.createElement("div");return n.current=i,i.id=e,i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),Lh(i.style,L2),ec().appendChild(i),function(){setTimeout(function(){let l=ec();l.contains(i)&&l.removeChild(i),i===n.current&&(n.current=null)})}},[e]),le(r=>{let i=n.current;if(i){i.textContent=r;return}},[])}var F2={separator:"::"};function im(t,e=F2){let n=nt.useId();return Pe(()=>`${t}${e.separator}${n}`,[e.separator,t,n])}function B2({contextId:t,uniqueId:e}){return`rfd-hidden-text-${t}-${e}`}function $2({contextId:t,text:e}){let n=im("hidden-text",{separator:"-"}),o=Pe(()=>B2({contextId:t,uniqueId:n}),[n,t]);return F(function(){let i=document.createElement("div");return i.id=o,i.textContent=e,i.style.display="none",ec().appendChild(i),function(){let a=ec();a.contains(i)&&a.removeChild(i)}},[o,e]),o}var Nu=nt.createContext(null),z2={react:"^18.0.0 || ^19.0.0"},H2=/(\d+)\.(\d+)\.(\d+)/,K0=t=>{let e=H2.exec(t);e==null&&j();let n=Number(e[1]),o=Number(e[2]),r=Number(e[3]);return{major:n,minor:o,patch:r,raw:t}},U2=(t,e)=>e.major>t.major?!0:e.major<t.major?!1:e.minor>t.minor?!0:e.minor<t.minor?!1:e.patch>=t.patch,K2=(t,e)=>{let n=K0(t),o=K0(e);U2(n,o)};var j2=t=>{let e=t.doctype;e&&(e.name.toLowerCase(),e.publicId)};function ac(t,e){}function V2(){ac(()=>{K2(z2.react,nt.version),j2(document)},[])}function sm(t){let e=J(t);return F(()=>{e.current=t}),e}function W2(){let t=null;function e(){return!!t}function n(s){return s===t}function o(s){t&&j();let a={abandon:s};return t=a,a}function r(){t||j(),t=null}function i(){t&&(t.abandon(),r())}return{isClaimed:e,isActive:n,claim:o,release:r,tryAbandon:i}}function tc(t){return t.phase==="IDLE"||t.phase==="DROP_ANIMATING"?!1:t.isDragging}var G2=9,Y2=13,am=27,BT=32,q2=33,J2=34,X2=35,Z2=36,Q2=37,ez=38,tz=39,nz=40,oz={[Y2]:!0,[G2]:!0},$T=t=>{oz[t.keyCode]&&t.preventDefault()},Du=(()=>{let t="visibilitychange";return typeof document>"u"?t:[t,`ms${t}`,`webkit${t}`,`moz${t}`,`o${t}`].find(o=>`on${o}`in document)||t})(),zT=0,j0=5;function rz(t,e){return Math.abs(e.x-t.x)>=j0||Math.abs(e.y-t.y)>=j0}var V0={type:"IDLE"};function iz({cancel:t,completed:e,getPhase:n,setPhase:o}){return[{eventName:"mousemove",fn:r=>{let{button:i,clientX:s,clientY:a}=r;if(i!==zT)return;let l={x:s,y:a},c=n();if(c.type==="DRAGGING"){r.preventDefault(),c.actions.move(l);return}c.type!=="PENDING"&&j();let d=c.point;if(!rz(d,l))return;r.preventDefault();let u=c.actions.fluidLift(l);o({type:"DRAGGING",actions:u})}},{eventName:"mouseup",fn:r=>{let i=n();if(i.type!=="DRAGGING"){t();return}r.preventDefault(),i.actions.drop({shouldBlockNextClick:!0}),e()}},{eventName:"mousedown",fn:r=>{n().type==="DRAGGING"&&r.preventDefault(),t()}},{eventName:"keydown",fn:r=>{if(n().type==="PENDING"){t();return}if(r.keyCode===am){r.preventDefault(),t();return}$T(r)}},{eventName:"resize",fn:t},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{n().type==="PENDING"&&t()}},{eventName:"webkitmouseforcedown",fn:r=>{let i=n();if(i.type==="IDLE"&&j(),i.actions.shouldRespectForcePress()){t();return}r.preventDefault()}},{eventName:Du,fn:t}]}function sz(t){let e=J(V0),n=J(ci),o=Pe(()=>({eventName:"mousedown",fn:function(u){if(u.defaultPrevented||u.button!==zT||u.ctrlKey||u.metaKey||u.shiftKey||u.altKey)return;let p=t.findClosestDraggableId(u);if(!p)return;let h=t.tryGetLock(p,s,{sourceEvent:u});if(!h)return;u.preventDefault();let g={x:u.clientX,y:u.clientY};n.current(),c(h,g)}}),[t]),r=Pe(()=>({eventName:"webkitmouseforcewillbegin",fn:d=>{if(d.defaultPrevented)return;let u=t.findClosestDraggableId(d);if(!u)return;let p=t.findOptionsForDraggable(u);p&&(p.shouldRespectForcePress||t.canGetLock(u)&&d.preventDefault())}}),[t]),i=le(function(){let u={passive:!1,capture:!0};n.current=yo(window,[r,o],u)},[r,o]),s=le(()=>{e.current.type!=="IDLE"&&(e.current=V0,n.current(),i())},[i]),a=le(()=>{let d=e.current;s(),d.type==="DRAGGING"&&d.actions.cancel({shouldBlockNextClick:!0}),d.type==="PENDING"&&d.actions.abort()},[s]),l=le(function(){let u={capture:!0,passive:!1},p=iz({cancel:a,completed:s,getPhase:()=>e.current,setPhase:h=>{e.current=h}});n.current=yo(window,p,u)},[a,s]),c=le(function(u,p){e.current.type!=="IDLE"&&j(),e.current={type:"PENDING",point:p,actions:u},l()},[l]);to(function(){return i(),function(){n.current()}},[i])}function az(){}var lz={[J2]:!0,[q2]:!0,[Z2]:!0,[X2]:!0};function cz(t,e){function n(){e(),t.cancel()}function o(){e(),t.drop()}return[{eventName:"keydown",fn:r=>{if(r.keyCode===am){r.preventDefault(),n();return}if(r.keyCode===BT){r.preventDefault(),o();return}if(r.keyCode===nz){r.preventDefault(),t.moveDown();return}if(r.keyCode===ez){r.preventDefault(),t.moveUp();return}if(r.keyCode===tz){r.preventDefault(),t.moveRight();return}if(r.keyCode===Q2){r.preventDefault(),t.moveLeft();return}if(lz[r.keyCode]){r.preventDefault();return}$T(r)}},{eventName:"mousedown",fn:n},{eventName:"mouseup",fn:n},{eventName:"click",fn:n},{eventName:"touchstart",fn:n},{eventName:"resize",fn:n},{eventName:"wheel",fn:n,options:{passive:!0}},{eventName:Du,fn:n}]}function dz(t){let e=J(az),n=Pe(()=>({eventName:"keydown",fn:function(i){if(i.defaultPrevented||i.keyCode!==BT)return;let s=t.findClosestDraggableId(i);if(!s)return;let a=t.tryGetLock(s,d,{sourceEvent:i});if(!a)return;i.preventDefault();let l=!0,c=a.snapLift();e.current();function d(){l||j(),l=!1,e.current(),o()}e.current=yo(window,cz(c,d),{capture:!0,passive:!1})}}),[t]),o=le(function(){let i={passive:!1,capture:!0};e.current=yo(window,[n],i)},[n]);to(function(){return o(),function(){e.current()}},[o])}var Ig={type:"IDLE"},uz=120,pz=.15;function fz({cancel:t,getPhase:e}){return[{eventName:"orientationchange",fn:t},{eventName:"resize",fn:t},{eventName:"contextmenu",fn:n=>{n.preventDefault()}},{eventName:"keydown",fn:n=>{if(e().type!=="DRAGGING"){t();return}n.keyCode===am&&n.preventDefault(),t()}},{eventName:Du,fn:t}]}function hz({cancel:t,completed:e,getPhase:n}){return[{eventName:"touchmove",options:{capture:!1},fn:o=>{let r=n();if(r.type!=="DRAGGING"){t();return}r.hasMoved=!0;let{clientX:i,clientY:s}=o.touches[0],a={x:i,y:s};o.preventDefault(),r.actions.move(a)}},{eventName:"touchend",fn:o=>{let r=n();if(r.type!=="DRAGGING"){t();return}o.preventDefault(),r.actions.drop({shouldBlockNextClick:!0}),e()}},{eventName:"touchcancel",fn:o=>{if(n().type!=="DRAGGING"){t();return}o.preventDefault(),t()}},{eventName:"touchforcechange",fn:o=>{let r=n();r.type==="IDLE"&&j();let i=o.touches[0];if(!i||!(i.force>=pz))return;let a=r.actions.shouldRespectForcePress();if(r.type==="PENDING"){a&&t();return}if(a){if(r.hasMoved){o.preventDefault();return}t();return}o.preventDefault()}},{eventName:Du,fn:t}]}function gz(t){let e=J(Ig),n=J(ci),o=le(function(){return e.current},[]),r=le(function(h){e.current=h},[]),i=Pe(()=>({eventName:"touchstart",fn:function(h){if(h.defaultPrevented)return;let g=t.findClosestDraggableId(h);if(!g)return;let m=t.tryGetLock(g,a,{sourceEvent:h});if(!m)return;let _=h.touches[0],{clientX:b,clientY:y}=_,v={x:b,y};n.current(),u(m,v)}}),[t]),s=le(function(){let h={capture:!0,passive:!1};n.current=yo(window,[i],h)},[i]),a=le(()=>{let p=e.current;p.type!=="IDLE"&&(p.type==="PENDING"&&clearTimeout(p.longPressTimerId),r(Ig),n.current(),s())},[s,r]),l=le(()=>{let p=e.current;a(),p.type==="DRAGGING"&&p.actions.cancel({shouldBlockNextClick:!0}),p.type==="PENDING"&&p.actions.abort()},[a]),c=le(function(){let h={capture:!0,passive:!1},g={cancel:l,completed:a,getPhase:o},m=yo(window,hz(g),h),_=yo(window,fz(g),h);n.current=function(){m(),_()}},[l,o,a]),d=le(function(){let h=o();h.type!=="PENDING"&&j();let g=h.actions.fluidLift(h.point);r({type:"DRAGGING",actions:g,hasMoved:!1})},[o,r]),u=le(function(h,g){o().type!=="IDLE"&&j();let m=setTimeout(d,uz);r({type:"PENDING",point:g,actions:h,longPressTimerId:m}),c()},[c,o,r,d]);to(function(){return s(),function(){n.current();let g=o();g.type==="PENDING"&&(clearTimeout(g.longPressTimerId),r(Ig))}},[o,s,r]),to(function(){return yo(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}function mz(t){}var _z=["input","button","textarea","select","option","optgroup","video","audio"];function HT(t,e){if(e==null)return!1;if(_z.includes(e.tagName.toLowerCase()))return!0;let o=e.getAttribute("contenteditable");return o==="true"||o===""?!0:e===t?!1:HT(t,e.parentElement)}function bz(t,e){let n=e.target;return sc(n)?HT(t,n):!1}var yz=t=>bo(t.getBoundingClientRect()).center;function xz(t){return t instanceof PT(t).Element}var vz=(()=>{let t="matches";return typeof document>"u"?t:[t,"msMatchesSelector","webkitMatchesSelector"].find(o=>o in Element.prototype)||t})();function UT(t,e){return t==null?null:t[vz](e)?t:UT(t.parentElement,e)}function Cz(t,e){return t.closest?t.closest(e):UT(t,e)}function Ez(t){return`[${pa.contextId}="${t}"]`}function wz(t,e){let n=e.target;if(!xz(n))return null;let o=Ez(t),r=Cz(n,o);return!r||!sc(r)?null:r}function Tz(t,e){let n=wz(t,e);return n?n.getAttribute(pa.draggableId):null}function Sz(t,e){let n=`[${Hg.contextId}="${t}"]`,r=RT(document,n).find(i=>i.getAttribute(Hg.id)===e);return!r||!sc(r)?null:r}function kz(t){t.preventDefault()}function bu({expected:t,phase:e,isLockActive:n,shouldWarn:o}){return!(!n()||t!==e)}function KT({lockAPI:t,store:e,registry:n,draggableId:o}){if(t.isClaimed())return!1;let r=n.draggable.findById(o);return!(!r||!r.options.isEnabled||!IT(e.getState(),o))}function Nz({lockAPI:t,contextId:e,store:n,registry:o,draggableId:r,forceSensorStop:i,sourceEvent:s}){if(!KT({lockAPI:t,store:n,registry:o,draggableId:r}))return null;let l=o.draggable.getById(r),c=Sz(e,l.descriptor.id);if(!c||s&&!l.options.canDragInteractiveElements&&bz(c,s))return null;let d=t.claim(i||ci),u="PRE_DRAG";function p(){return l.options.shouldRespectForcePress}function h(){return t.isActive(d)}function g(C,E){bu({expected:C,phase:u,isLockActive:h,shouldWarn:!0})&&n.dispatch(E())}let m=g.bind(null,"DRAGGING");function _(C){function E(){t.release(),u="COMPLETED"}u!=="PRE_DRAG"&&(E(),j()),n.dispatch(m$(C.liftActionArgs)),u="DRAGGING";function k(T,w={shouldBlockNextClick:!1}){if(C.cleanup(),w.shouldBlockNextClick){let S=yo(window,[{eventName:"click",fn:kz,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(S)}E(),n.dispatch(ET({reason:T}))}return{isActive:()=>bu({expected:"DRAGGING",phase:u,isLockActive:h,shouldWarn:!1}),shouldRespectForcePress:p,drop:T=>k("DROP",T),cancel:T=>k("CANCEL",T),...C.actions}}function b(C){let E=ca(T=>{m(()=>CT({client:T}))});return{..._({liftActionArgs:{id:r,clientSelection:C,movementMode:"FLUID"},cleanup:()=>E.cancel(),actions:{move:E}}),move:E}}function y(){let C={moveUp:()=>m(T$),moveRight:()=>m(k$),moveDown:()=>m(S$),moveLeft:()=>m(N$)};return _({liftActionArgs:{id:r,clientSelection:yz(c),movementMode:"SNAP"},cleanup:ci,actions:C})}function v(){bu({expected:"PRE_DRAG",phase:u,isLockActive:h,shouldWarn:!0})&&t.release()}return{isActive:()=>bu({expected:"PRE_DRAG",phase:u,isLockActive:h,shouldWarn:!1}),shouldRespectForcePress:p,fluidLift:b,snapLift:y,abort:v}}var Dz=[sz,dz,gz];function Oz({contextId:t,store:e,registry:n,customSensors:o,enableDefaultSensors:r}){let i=[...r?Dz:[],...o||[]],s=L(()=>W2())[0],a=le(function(_,b){tc(_)&&!tc(b)&&s.tryAbandon()},[s]);to(function(){let _=e.getState();return e.subscribe(()=>{let y=e.getState();a(_,y),_=y})},[s,e,a]),to(()=>s.tryAbandon,[s.tryAbandon]);let l=le(m=>KT({lockAPI:s,registry:n,store:e,draggableId:m}),[s,n,e]),c=le((m,_,b)=>Nz({lockAPI:s,registry:n,contextId:t,store:e,draggableId:m,forceSensorStop:_||null,sourceEvent:b&&b.sourceEvent?b.sourceEvent:null}),[t,s,n,e]),d=le(m=>Tz(t,m),[t]),u=le(m=>{let _=n.draggable.findById(m);return _?_.options:null},[n.draggable]),p=le(function(){s.isClaimed()&&(s.tryAbandon(),e.getState().phase!=="IDLE"&&e.dispatch(Xg()))},[s,e]),h=le(()=>s.isClaimed(),[s]),g=Pe(()=>({canGetLock:l,tryGetLock:c,findClosestDraggableId:d,findOptionsForDraggable:u,tryReleaseLock:p,isLockClaimed:h}),[l,c,d,u,p,h]);mz(i);for(let m=0;m<i.length;m++)i[m](g)}var Iz=t=>({onBeforeCapture:e=>{Ol(()=>{t.onBeforeCapture&&t.onBeforeCapture(e)})},onBeforeDragStart:t.onBeforeDragStart,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd,onDragUpdate:t.onDragUpdate}),Az=t=>({...Ql,...t.autoScrollerOptions,durationDampening:{...Ql.durationDampening,...t.autoScrollerOptions}});function Wl(t){return t.current||j(),t.current}function Mz(t){let{contextId:e,setCallbacks:n,sensors:o,nonce:r,dragHandleUsageInstructions:i}=t,s=J(null);V2();let a=sm(t),l=le(()=>Iz(a.current),[a]),c=le(()=>Az(a.current),[a]),d=P2(e),u=$2({contextId:e,text:i}),p=O2(e,r),h=le(S=>{Wl(s).dispatch(S)},[]),g=Pe(()=>hg({publishWhileDragging:b$,updateDroppableScroll:x$,updateDroppableIsEnabled:v$,updateDroppableIsCombineEnabled:C$,collectionStarting:y$},h),[h]),m=M2(),_=Pe(()=>l2(m,g),[m,g]),b=Pe(()=>T2({scrollWindow:c2,scrollDroppable:_.scrollDroppable,getAutoScrollerOptions:c,...hg({move:CT},h)}),[_.scrollDroppable,h,c]),y=I2(e),v=Pe(()=>r2({announce:d,autoScroller:b,dimensionMarshal:_,focusMarshal:y,getResponders:l,styleMarshal:p}),[d,b,_,y,l,p]);s.current=v;let x=le(()=>{let S=Wl(s);S.getState().phase!=="IDLE"&&S.dispatch(Xg())},[]),C=le(()=>{let S=Wl(s).getState();return S.phase==="DROP_ANIMATING"?!0:S.phase==="IDLE"?!1:S.isDragging},[]),E=Pe(()=>({isDragging:C,tryAbort:x}),[C,x]);n(E);let k=le(S=>IT(Wl(s).getState(),S),[]),T=le(()=>is(Wl(s).getState()),[]),w=Pe(()=>({marshal:_,focus:y,contextId:e,canLift:k,isMovementAllowed:T,dragHandleUsageInstructionsId:u,registry:m}),[e,_,u,y,k,T,m]);return Oz({contextId:e,store:v,registry:m,customSensors:o||null,enableDefaultSensors:t.enableDefaultSensors!==!1}),F(()=>x,[x]),nt.createElement(Nu.Provider,{value:w},nt.createElement(v0,{context:rm,store:v},t.children))}function Lz(){return nt.useId()}function Ou(t){let e=Lz(),n=t.dragHandleUsageInstructions||xu.dragHandleUsageInstructions;return nt.createElement(Pg,null,o=>nt.createElement(Mz,{nonce:t.nonce,contextId:e,setCallbacks:o,dragHandleUsageInstructions:n,enableDefaultSensors:t.enableDefaultSensors,sensors:t.sensors,onBeforeCapture:t.onBeforeCapture,onBeforeDragStart:t.onBeforeDragStart,onDragStart:t.onDragStart,onDragUpdate:t.onDragUpdate,onDragEnd:t.onDragEnd,autoScrollerOptions:t.autoScrollerOptions},t.children))}var W0={dragging:5e3,dropAnimating:4500},Rz=(t,e)=>e?Yl.drop(e.duration):t?Yl.snap:Yl.fluid,Pz=(t,e)=>{if(t)return e?Zl.opacity.drop:Zl.opacity.combining},Fz=t=>t.forceShouldAnimate!=null?t.forceShouldAnimate:t.mode==="SNAP";function Bz(t){let n=t.dimension.client,{offset:o,combineWith:r,dropping:i}=t,s=!!r,a=Fz(t),l=!!i,c=l?$g.drop(o,s):$g.moveTo(o);return{position:"fixed",top:n.marginBox.top,left:n.marginBox.left,boxSizing:"border-box",width:n.borderBox.width,height:n.borderBox.height,transition:Rz(a,i),transform:c,opacity:Pz(s,l),zIndex:l?W0.dropAnimating:W0.dragging,pointerEvents:"none"}}function $z(t){return{transform:$g.moveTo(t.offset),transition:t.shouldAnimateDisplacement?void 0:"none"}}function zz(t){return t.type==="DRAGGING"?Bz(t):$z(t)}function Hz(t,e,n=Gt){let o=window.getComputedStyle(e),r=e.getBoundingClientRect(),i=wg(r,o),s=Kl(i,n),a={client:i,tagName:e.tagName.toLowerCase(),display:o.display},l={x:i.marginBox.width,y:i.marginBox.height};return{descriptor:t,placeholder:a,displaceBy:l,client:i,page:s}}function Uz(t){let e=im("draggable"),{descriptor:n,registry:o,getDraggableRef:r,canDragInteractiveElements:i,shouldRespectForcePress:s,isEnabled:a}=t,l=Pe(()=>({canDragInteractiveElements:i,shouldRespectForcePress:s,isEnabled:a}),[i,a,s]),c=le(h=>{let g=r();return g||j(),Hz(n,g,h)},[n,r]),d=Pe(()=>({uniqueId:e,descriptor:n,options:l,getDimension:c}),[n,c,l,e]),u=J(d),p=J(!0);to(()=>(o.draggable.register(u.current),()=>o.draggable.unregister(u.current)),[o.draggable]),to(()=>{if(p.current){p.current=!1;return}let h=u.current;u.current=d,o.draggable.update(d,h)},[d,o.draggable])}var lm=nt.createContext(null);function jT(t){t&&sc(t)||j()}function Kz(t,e,n){ac(()=>{function o(i){return`Draggable[id: ${i}]: `}let r=t.draggableId;r||j(!1),typeof r!="string"&&j(!1),Number.isInteger(t.index)||j(!1),t.mapped.type!=="DRAGGING"&&(jT(n()),t.isEnabled&&(FT(e,r)||j(!1)))})}function jz(t){}function Eu(t){let e=ft(t);return e||j(),e}function Vz(t){t.preventDefault()}var Wz=t=>{let e=J(null),n=le((E=null)=>{e.current=E},[]),o=le(()=>e.current,[]),{contextId:r,dragHandleUsageInstructionsId:i,registry:s}=Eu(Nu),{type:a,droppableId:l}=Eu(lm),c=Pe(()=>({id:t.draggableId,index:t.index,type:a,droppableId:l}),[t.draggableId,t.index,a,l]),{children:d,draggableId:u,isEnabled:p,shouldRespectForcePress:h,canDragInteractiveElements:g,isClone:m,mapped:_,dropAnimationFinished:b}=t;if(Kz(t,r,o),jz(m),!m){let E=Pe(()=>({descriptor:c,registry:s,getDraggableRef:o,canDragInteractiveElements:g,shouldRespectForcePress:h,isEnabled:p}),[c,s,o,g,h,p]);Uz(E)}let y=Pe(()=>p?{tabIndex:0,role:"button","aria-describedby":i,"data-rfd-drag-handle-draggable-id":u,"data-rfd-drag-handle-context-id":r,draggable:!1,onDragStart:Vz}:null,[r,i,u,p]),v=le(E=>{_.type==="DRAGGING"&&_.dropping&&E.propertyName==="transform"&&Ol(b)},[b,_]),x=Pe(()=>{let E=zz(_),k=_.type==="DRAGGING"&&_.dropping?v:void 0;return{innerRef:n,draggableProps:{"data-rfd-draggable-context-id":r,"data-rfd-draggable-id":u,style:E,onTransitionEnd:k},dragHandleProps:y}},[r,y,u,_,v,n]),C=Pe(()=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}}),[c.droppableId,c.id,c.index,c.type]);return nt.createElement(nt.Fragment,null,d(x,_.snapshot,C))},VT=(t,e)=>t===e,WT=t=>{let{combine:e,destination:n}=t;return n?n.droppableId:e?e.droppableId:null},Gz=t=>t.combine?t.combine.draggableId:null,Yz=t=>t.at&&t.at.type==="COMBINE"?t.at.combine.draggableId:null;function qz(){let t=Wt((r,i)=>({x:r,y:i})),e=Wt((r,i,s=null,a=null,l=null)=>({isDragging:!0,isClone:i,isDropAnimating:!!l,dropAnimation:l,mode:r,draggingOver:s,combineWith:a,combineTargetFor:null})),n=Wt((r,i,s,a,l=null,c=null,d=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:l,combineWith:c,mode:i,offset:r,dimension:s,forceShouldAnimate:d,snapshot:e(i,a,l,c,null)}}));return(r,i)=>{if(tc(r)){if(r.critical.draggable.id!==i.draggableId)return null;let s=r.current.client.offset,a=r.dimensions.draggables[i.draggableId],l=eo(r.impact),c=Yz(r.impact),d=r.forceShouldAnimate;return n(t(s.x,s.y),r.movementMode,a,i.isClone,l,c,d)}if(r.phase==="DROP_ANIMATING"){let s=r.completed;if(s.result.draggableId!==i.draggableId)return null;let a=i.isClone,l=r.dimensions.draggables[i.draggableId],c=s.result,d=c.mode,u=WT(c),p=Gz(c),g={duration:r.dropDuration,curve:Qg.drop,moveTo:r.newHomeClientOffset,opacity:p?Zl.opacity.drop:null,scale:p?Zl.scale.drop:null};return{mapped:{type:"DRAGGING",offset:r.newHomeClientOffset,dimension:l,dropping:g,draggingOver:u,combineWith:p,mode:d,forceShouldAnimate:null,snapshot:e(d,a,u,p,g)}}}return null}}function GT(t=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:t,combineWith:null}}var Jz={mapped:{type:"SECONDARY",offset:Gt,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:GT(null)}};function Xz(){let t=Wt((s,a)=>({x:s,y:a})),e=Wt(GT),n=Wt((s,a=null,l)=>({mapped:{type:"SECONDARY",offset:s,combineTargetFor:a,shouldAnimateDisplacement:l,snapshot:e(a)}})),o=s=>s?n(Gt,s,!0):null,r=(s,a,l,c)=>{let d=l.displaced.visible[s],u=!!(c.inVirtualList&&c.effected[s]),p=Tu(l),h=p&&p.draggableId===s?a:null;if(!d){if(!u)return o(h);if(l.displaced.invisible[s])return null;let _=fa(c.displacedBy.point),b=t(_.x,_.y);return n(b,h,!0)}if(u)return o(h);let g=l.displacedBy.point,m=t(g.x,g.y);return n(m,h,d.shouldAnimate)};return(s,a)=>{if(tc(s))return s.critical.draggable.id===a.draggableId?null:r(a.draggableId,s.critical.draggable.id,s.impact,s.afterCritical);if(s.phase==="DROP_ANIMATING"){let l=s.completed;return l.result.draggableId===a.draggableId?null:r(a.draggableId,l.result.draggableId,l.impact,l.afterCritical)}return null}}var Zz=()=>{let t=qz(),e=Xz();return(o,r)=>t(o,r)||e(o,r)||Jz},Qz={dropAnimationFinished:wT},eH=vg(Zz,Qz,null,{context:rm,areStatePropsEqual:VT})(Wz);function YT(t){return Eu(lm).isUsingCloneFor===t.draggableId&&!t.isClone?null:nt.createElement(eH,t)}function Iu(t){let e=typeof t.isDragDisabled=="boolean"?!t.isDragDisabled:!0,n=!!t.disableInteractiveElementBlocking,o=!!t.shouldRespectForcePress;return nt.createElement(YT,Lh({},t,{isClone:!1,isEnabled:e,canDragInteractiveElements:n,shouldRespectForcePress:o}))}var cm=t=>e=>t===e,tH=cm("scroll"),nH=cm("auto"),oH=cm("visible"),G0=(t,e)=>e(t.overflowX)||e(t.overflowY),rH=(t,e)=>e(t.overflowX)&&e(t.overflowY),qT=t=>{let e=window.getComputedStyle(t),n={overflowX:e.overflowX,overflowY:e.overflowY};return G0(n,tH)||G0(n,nH)},iH=()=>!1,JT=t=>t==null?null:t===document.body?iH()?t:null:t===document.documentElement?null:qT(t)?t:JT(t.parentElement);var Ug=t=>({x:t.scrollLeft,y:t.scrollTop}),XT=t=>t?window.getComputedStyle(t).position==="fixed"?!0:XT(t.parentElement):!1,sH=t=>{let e=JT(t),n=XT(t);return{closestScrollable:e,isFixedOnPage:n}},aH=({descriptor:t,isEnabled:e,isCombineEnabled:n,isFixedOnPage:o,direction:r,client:i,page:s,closest:a})=>{let l=(()=>{if(!a)return null;let{scrollSize:p,client:h}=a,g=NT({scrollHeight:p.scrollHeight,scrollWidth:p.scrollWidth,height:h.paddingBox.height,width:h.paddingBox.width});return{pageMarginBox:a.page.marginBox,frameClient:h,scrollSize:p,shouldClipSubject:a.shouldClipSubject,scroll:{initial:a.scroll,current:a.scroll,max:g,diff:{value:Gt,displacement:Gt}}}})(),c=r==="vertical"?Wg:aT,d=da({page:s,withPlaceholder:null,axis:c,frame:l});return{descriptor:t,isCombineEnabled:n,isFixedOnPage:o,axis:c,isEnabled:e,client:i,page:s,frame:l,subject:d}},lH=(t,e)=>{let n=Tg(t);if(!e||t!==e)return n;let o=n.paddingBox.top-e.scrollTop,r=n.paddingBox.left-e.scrollLeft,i=o+e.scrollHeight,s=r+e.scrollWidth,l=gu({top:o,right:s,bottom:i,left:r},n.border);return mu({borderBox:l,margin:n.margin,border:n.border,padding:n.padding})},cH=({ref:t,descriptor:e,env:n,windowScroll:o,direction:r,isDropDisabled:i,isCombineEnabled:s,shouldClipSubject:a})=>{let l=n.closestScrollable,c=lH(t,l),d=Kl(c,o),u=(()=>{if(!l)return null;let h=Tg(l),g={scrollHeight:l.scrollHeight,scrollWidth:l.scrollWidth};return{client:h,page:Kl(h,o),scroll:Ug(l),scrollSize:g,shouldClipSubject:a}})();return aH({descriptor:e,isEnabled:!i,isCombineEnabled:s,isFixedOnPage:n.isFixedOnPage,direction:r,client:c,page:d,closest:u})},dH={passive:!1},uH={passive:!0},Y0=t=>t.shouldPublishImmediately?dH:uH,yu=t=>t&&t.env.closestScrollable||null;function pH(t){let e=J(null),n=Eu(Nu),o=im("droppable"),{registry:r,marshal:i}=n,s=sm(t),a=Pe(()=>({id:t.droppableId,type:t.type,mode:t.mode}),[t.droppableId,t.mode,t.type]),l=J(a),c=Pe(()=>Wt((x,C)=>{e.current||j();let E={x,y:C};i.updateDroppableScroll(a.id,E)}),[a.id,i]),d=le(()=>{let x=e.current;return!x||!x.env.closestScrollable?Gt:Ug(x.env.closestScrollable)},[]),u=le(()=>{let x=d();c(x.x,x.y)},[d,c]),p=Pe(()=>ca(u),[u]),h=le(()=>{let x=e.current,C=yu(x);if(x&&C||j(),x.scrollOptions.shouldPublishImmediately){u();return}p()},[p,u]),g=le((x,C)=>{e.current&&j();let E=s.current,k=E.getDroppableRef();k||j();let T=sH(k),w={ref:k,descriptor:a,env:T,scrollOptions:C};e.current=w;let S=cH({ref:k,descriptor:a,env:T,windowScroll:x,direction:E.direction,isDropDisabled:E.isDropDisabled,isCombineEnabled:E.isCombineEnabled,shouldClipSubject:!E.ignoreContainerClipping}),N=T.closestScrollable;return N&&(N.setAttribute(H0.contextId,n.contextId),N.addEventListener("scroll",h,Y0(w.scrollOptions))),S},[n.contextId,a,h,s]),m=le(()=>{let x=e.current,C=yu(x);return x&&C||j(),Ug(C)},[]),_=le(()=>{let x=e.current;x||j();let C=yu(x);e.current=null,C&&(p.cancel(),C.removeAttribute(H0.contextId),C.removeEventListener("scroll",h,Y0(x.scrollOptions)))},[h,p]),b=le(x=>{let C=e.current;C||j();let E=yu(C);E||j(),E.scrollTop+=x.y,E.scrollLeft+=x.x},[]),y=Pe(()=>({getDimensionAndWatchScroll:g,getScrollWhileDragging:m,dragStopped:_,scroll:b}),[_,g,m,b]),v=Pe(()=>({uniqueId:o,descriptor:a,callbacks:y}),[y,a,o]);to(()=>(l.current=v.descriptor,r.droppable.register(v),()=>{e.current&&_(),r.droppable.unregister(v)}),[y,a,_,v,i,r.droppable]),to(()=>{e.current&&i.updateDroppableIsEnabled(l.current.id,!t.isDropDisabled)},[t.isDropDisabled,i]),to(()=>{e.current&&i.updateDroppableIsCombineEnabled(l.current.id,t.isCombineEnabled)},[t.isCombineEnabled,i])}function Ag(){}var q0={width:0,height:0,margin:pB},fH=({isAnimatingOpenOnMount:t,placeholder:e,animate:n})=>t||n==="close"?q0:{height:e.client.borderBox.height,width:e.client.borderBox.width,margin:e.client.margin},hH=({isAnimatingOpenOnMount:t,placeholder:e,animate:n})=>{let o=fH({isAnimatingOpenOnMount:t,placeholder:e,animate:n});return{display:e.display,boxSizing:"border-box",width:o.width,height:o.height,marginTop:o.margin.top,marginRight:o.margin.right,marginBottom:o.margin.bottom,marginLeft:o.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:n!=="none"?Yl.placeholder:null}},gH=t=>{let e=J(null),n=le(()=>{e.current&&(clearTimeout(e.current),e.current=null)},[]),{animate:o,onTransitionEnd:r,onClose:i,contextId:s}=t,[a,l]=L(t.animate==="open");F(()=>a?o!=="open"?(n(),l(!1),Ag):e.current?Ag:(e.current=setTimeout(()=>{e.current=null,l(!1)}),n):Ag,[o,a,n]);let c=le(u=>{u.propertyName==="height"&&(r(),o==="close"&&i())},[o,i,r]),d=hH({isAnimatingOpenOnMount:a,animate:t.animate,placeholder:t.placeholder});return nt.createElement(t.placeholder.tagName,{style:d,"data-rfd-placeholder-context-id":s,onTransitionEnd:c,ref:t.innerRef})},mH=nt.memo(gH);function Mg(t){return typeof t=="boolean"}function Lg(t,e){e.forEach(n=>n(t))}var _H=[function({props:e}){e.droppableId||j(),typeof e.droppableId!="string"&&j()},function({props:e}){Mg(e.isDropDisabled)||j(),Mg(e.isCombineEnabled)||j(),Mg(e.ignoreContainerClipping)||j()},function({getDroppableRef:e}){jT(e())}],bH=[function({props:e,getPlaceholderRef:n}){!e.placeholder||n()}],yH=[function({props:e}){e.renderClone||j()},function({getPlaceholderRef:e}){e()&&j()}];function xH(t){ac(()=>{Lg(t,_H),t.props.mode==="standard"&&Lg(t,bH),t.props.mode==="virtual"&&Lg(t,yH)})}var Kg=class extends nt.PureComponent{constructor(...e){super(...e),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(e,n){return e.shouldAnimate?e.on?{isVisible:!0,data:e.on,animate:"open"}:n.isVisible?{isVisible:!0,data:n.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!e.on,data:e.on,animate:"none"}}render(){if(!this.state.isVisible)return null;let e={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(e)}},vH=t=>{let e=ft(Nu);e||j();let{contextId:n,isMovementAllowed:o}=e,r=J(null),i=J(null),{children:s,droppableId:a,type:l,mode:c,direction:d,ignoreContainerClipping:u,isDropDisabled:p,isCombineEnabled:h,snapshot:g,useClone:m,updateViewportMaxScroll:_,getContainerForClone:b}=t,y=le(()=>r.current,[]),v=le((D=null)=>{r.current=D},[]),x=le(()=>i.current,[]),C=le((D=null)=>{i.current=D},[]);xH({props:t,getDroppableRef:y,getPlaceholderRef:x});let E=le(()=>{o()&&_({maxScroll:OT()})},[o,_]);pH({droppableId:a,type:l,mode:c,direction:d,isDropDisabled:p,isCombineEnabled:h,ignoreContainerClipping:u,getDroppableRef:y});let k=Pe(()=>nt.createElement(Kg,{on:t.placeholder,shouldAnimate:t.shouldAnimatePlaceholder},({onClose:D,data:O,animate:A})=>nt.createElement(mH,{placeholder:O,onClose:D,innerRef:C,animate:A,contextId:n,onTransitionEnd:E})),[n,E,t.placeholder,t.shouldAnimatePlaceholder,C]),T=Pe(()=>({innerRef:v,placeholder:k,droppableProps:{"data-rfd-droppable-id":a,"data-rfd-droppable-context-id":n}}),[n,a,k,v]),w=m?m.dragging.draggableId:null,S=Pe(()=>({droppableId:a,type:l,isUsingCloneFor:w}),[a,w,l]);function N(){if(!m)return null;let{dragging:D,render:O}=m,A=nt.createElement(YT,{draggableId:D.draggableId,index:D.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(I,R)=>O(I,R,D));return nt.createPortal(A,b())}return nt.createElement(lm.Provider,{value:S},s(T,g),N())};function CH(){return document.body||j(),document.body}var J0={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:CH},ZT=t=>{let e={...t},n;for(n in J0)t[n]===void 0&&(e={...e,[n]:J0[n]});return e},Rg=(t,e)=>t===e.droppable.type,X0=(t,e)=>e.draggables[t.draggable.id],EH=()=>{let t={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},e={...t,shouldAnimatePlaceholder:!1},n=Wt(i=>({draggableId:i.id,type:i.type,source:{index:i.index,droppableId:i.droppableId}})),o=Wt((i,s,a,l,c,d)=>{let u=c.descriptor.id;if(c.descriptor.droppableId===i){let g=d?{render:d,dragging:n(c.descriptor)}:null,m={isDraggingOver:a,draggingOverWith:a?u:null,draggingFromThisWith:u,isUsingPlaceholder:!0};return{placeholder:c.placeholder,shouldAnimatePlaceholder:!1,snapshot:m,useClone:g}}if(!s)return e;if(!l)return t;let h={isDraggingOver:a,draggingOverWith:u,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:c.placeholder,shouldAnimatePlaceholder:!0,snapshot:h,useClone:null}});return(i,s)=>{let a=ZT(s),l=a.droppableId,c=a.type,d=!a.isDropDisabled,u=a.renderClone;if(tc(i)){let p=i.critical;if(!Rg(c,p))return e;let h=X0(p,i.dimensions),g=eo(i.impact)===l;return o(l,d,g,g,h,u)}if(i.phase==="DROP_ANIMATING"){let p=i.completed;if(!Rg(c,p.critical))return e;let h=X0(p.critical,i.dimensions);return o(l,d,WT(p.result)===l,eo(p.impact)===l,h,u)}if(i.phase==="IDLE"&&i.completed&&!i.shouldFlush){let p=i.completed;if(!Rg(c,p.critical))return e;let h=eo(p.impact)===l,g=!!(p.impact.at&&p.impact.at.type==="COMBINE"),m=p.critical.droppable.id===l;return h?g?t:e:m?t:e}return e}},wH={updateViewportMaxScroll:w$},Au=vg(EH,wH,(t,e,n)=>({...ZT(n),...t,...e}),{context:rm,areStatePropsEqual:VT})(vH);br();ke();br();ke();function TH(){return new URLSearchParams(window.location.search).get("deeplink")||""}var QT=pt(null);function eS(t){let e=TH(),[n,o]=L(e),r={value:n,setValue:o};return F(()=>{o(e)},[e]),F(()=>{let i=s=>{if(kw(s.origin)&&Sw(s.data)){let a=s.data.scrollToDeeplink.deepKey,l=document.getElementById(a);if(l){o(a),dm(l,{behavior:"smooth",force:!0});let c=new URL(window.location.href);c.searchParams.set("deeplink",a),window.history.replaceState({},"",c.toString())}}};return window.addEventListener("message",i),()=>{window.removeEventListener("message",i)}},[]),f(QT.Provider,{value:r,children:t.children})}function lc(){let t=ft(QT);if(!t)throw new Error("[useDeeplink()] DeeplinkContext not found, be sure to add <DeeplinkProvider>");return t}function SH(t){let e=t;for(;e&&e!==document.body;){let n=e.closest("details");if(n&&n.parentElement)n.open=!0,e=n.parentElement;else break}}function kH(t){let e=[],n=t;for(;n&&n!==document.body;){let o=n.closest(".DocEditor__ArrayField__item");if(!o)break;let r=o.querySelector(".DocEditor__ArrayField__item__header");if(r&&!e.includes(r))e.push(r),n=o.parentElement;else break}return e}function dm(t,e={behavior:"auto"}){setTimeout(()=>{let n=document.querySelector(".DocumentPage__side");if(!n||n.scrollTop>0&&!e.force)return;SH(t);let r=kH(t).reduce((s,a)=>s+a.offsetHeight,0),i=t.offsetTop-r;n.scroll({top:i,behavior:e.behavior})},e.force?0:300)}function tS(t){let e=new URL(window.location.href);return e.searchParams.set("deeplink",t),e.toString()}var NH={get:async()=>{try{let t=await DH();return t?JSON.parse(t):null}catch{return null}},set:t=>{navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(JSON.stringify(t,void 0,2)).catch(console.error)}};function um(){return NH}async function DH(){try{if(navigator.clipboard&&navigator.clipboard.readText)return await navigator.clipboard.readText()}catch{}return null}function no(t,e){if(!IH())return;let n=OH();if(n.length===0)return;let o={highlightNode:{deepKey:t,options:e}};n.forEach(r=>{r.contentWindow?.postMessage(o,window.location.origin)})}function OH(){return Array.from(document.querySelectorAll('iframe[title="iframe preview"]'))}function IH(){let t=window.__ROOT_CTX.preview||{};return[!0,"to-preview"].includes(t.channel)}function nS(t,e){return t.replace(/\{(.+?)\}/g,(n,o)=>{let r=e(o);return r??n})}var Mu=class extends Error{};function oS(t,e,n){let o=t.preview?.title;if(o)return ma(o,e,n)}function rS(t,e,n){let o=t.preview?.image;if(o)return ma(o,e,n)}function ma(t,e,n){if(!t)return;let o=Array.isArray(t)?t:[t],r=n?.index,i=s=>{if(r!==void 0){if(s==="_index"||s==="_index0")return String(r);if(s==="_index1")return String(r+1);if(s==="_index:02")return String(r).padStart(2,"0");if(s==="_index:03")return String(r).padStart(3,"0")}let a=yn(e,s);if(!a)throw new Mu(s);if(Bd(a)){let l=AH(a);if(l)return l}return String(a)};for(let s of o)try{return nS(s,i)}catch(a){if(a instanceof Mu)continue;throw a}}function AH(t){let e=t?.blocks||[];for(let n of e)if(n.type==="paragraph"){let o=n.data?.text||"";o=o.replace(/<br\s*\/?>/gi,`
|
|
82
|
-
`),o=o.replace(/<[^>]+>/g,"").replace(/ /g," ");let r=o.split(/\r?\n/)[0].trim();if(r)return r}}function ls(t,e,n={}){if(e==null)return!0;switch(t.type){case"string":case"select":case"date":case"datetime":return e==="";case"multiselect":return!Array.isArray(e)||e.length===0;case"number":case"boolean":return e==null;case"image":case"file":return!e||!e.src;case"reference":return!e||!e.id;case"references":return!Array.isArray(e)||e.length===0;case"richtext":return!Bd(e);case"object":if(!Pn(e)||Object.keys(e).length===0)return!0;for(let o of t.fields||[])if(o.id&&!ls(o,e[o.id],n))return!1;return!0;case"array":if(Array.isArray(e)){if(e.length===0)return!0;for(let o of e)if(!ls(t.of,o,n))return!1;return!0}if(!Pn(e)||!Array.isArray(e._array)||e._array.length===0)return!0;for(let o of e._array)if(!ls(t.of,e[o],n))return!1;return!0;case"oneof":{if(!Pn(e)||!e._type)return!0;let o,r=t.types||[];if(typeof r[0]=="string"?r.includes(e._type)&&(o=n[e._type]):o=r.find(i=>i.name===e._type),!o)return!0;for(let i of o.fields||[])if(i.id&&!ls(i,e[i.id],n))return!1;return!0}default:return!1}}br();var Lu=class extends Td{constructor(){super(...arguments);this.state={error:null}}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n){console.error(`Error rendering field${this.props.deepKey?` "${this.props.deepKey}"`:""}:`,n)}render(){if(this.state.error){let n=this.state.error instanceof Error?this.state.error.message:String(this.state.error);return f("div",{className:"FieldErrorBoundary",children:[f("div",{className:"FieldErrorBoundary__icon",children:f(Pl,{size:16})}),f("div",{className:"FieldErrorBoundary__body",children:[f("div",{className:"FieldErrorBoundary__title",children:"This field failed to render."}),f("div",{className:"FieldErrorBoundary__message",children:n})]})]})}return this.props.children}};ke();function iS(t,e){let n=!1;return(...o)=>{n||(t(...o),n=!0,setTimeout(()=>{n=!1},e))}}var cc=class extends mo{constructor(n){super();this.interval=0;this.timeout=0;this.interval=n}start(){this.timeout=window.setTimeout(()=>{this.tick()},this.interval)}tick(){this.dispatch("tick"),this.start()}reset(){this.stop(),this.start()}stop(){this.timeout&&(window.clearTimeout(this.timeout),this.timeout=0)}};var MH=60*Zi.second,sS=5*Zi.minute,pm=class extends mo{constructor(n){super();this.started=!1;this.timer=new cc(MH);this.idleTimer=new cc(sS);this.onUserInteraction=iS(()=>{this.idleTimer.reset()},5e3);this.id=n;let o=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db;this.docRef=Ad(r,"Projects",o,"Viewers",n),this.timer.on("tick",()=>this.onTick()),this.idleTimer.on("tick",()=>this.onIdle()),window.addEventListener("mousemove",this.onUserInteraction),window.addEventListener("keypress",this.onUserInteraction)}async start(){this.started||(this.started=!0,this.dbUnsubscribe=Ld(this.docRef,n=>{let o=n.data();this.onData(o)}),this.onTick(),this.timer.start())}onData(n){let o=window.firebase.user,r=Id.now(),i=Object.values(n).filter(s=>!(s.email===o.email||r.toMillis()-s.lastViewedAt.toMillis()>sS));this.dispatch("change",i)}async onTick(){let n=window.firebase.user;if(!n.email){console.log("no user email:",n);return}await FC(this.docRef,{[n.email]:{email:n.email,photoURL:n.photoURL,lastViewedAt:ta()}},{merge:!0})}async onIdle(){this.stop()}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.timer.stop(),this.idleTimer.stop(),this.onDisconnect(),this.started=!1)}async onDisconnect(){let n=window.firebase.user;if(!n.email){console.log("no user email:",n);return}let o=new PC(n.email,"disconnectedAt");await Md(this.docRef,o,ta())}async dispose(){super.dispose(),this.stop(),this.timer.dispose(),this.idleTimer.dispose()}};function aS(t){let e=$C(t.id),[n,o]=L([]);if(F(()=>{let l=new pm(e);l.on("change",d=>o(d)),l.start();let c=()=>{document.hidden||document.visibilityState!=="visible"?l.stop():l.started||l.start()};return document.addEventListener("visibilitychange",c),()=>{l.dispose(),document.removeEventListener("visibilitychange",c)}},[e]),n.length===0)return null;function r(l){return l.disconnectedAt?l.disconnectedAt>l.lastViewedAt:!1}let i=t.max||3,s=n.slice(0,i),a=n.length-i;return f("div",{className:"Viewers",children:[s.map(l=>f(fE,{email:l.email,size:30,inactive:r(l),className:"Viewers__avatar"},l.email)),a>0&&f(OC,{className:"Viewers__avatar",size:30,radius:"xl",children:["+",a]})]})}function lS(t){let n=t.field.checkboxLabel||"Enabled",[o,r]=At(t.deepKey,!1);return f("div",{className:"DocEditor__BooleanField",children:f(fo,{label:n,onChange:i=>{let s=i.currentTarget;r(s.checked)},checked:o,size:"xs"})})}ke();function cS(t){let[e,n]=At(t.deepKey),[o,r]=L(null),i=(s,a)=>{if(a&&!a.valid){r("Invalid date");return}if(s){let l=new Date(s);if(isNaN(l.getTime())){r("Invalid date");return}r(null),n(s)}else r(null),n(null)};return f("div",{className:"DocEditor__DateField",children:[f("input",{type:"date",value:e||"",onChange:s=>{let a=s.currentTarget;i(a.value,a.validity)}}),o&&f("div",{style:{color:"red",fontSize:"12px",marginTop:"4px"},children:o})]})}var LH={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},dS=(t,e,n)=>{let o,r=LH[t];return typeof r=="string"?o=r:e===1?o=r.one:o=r.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+o:o+" ago":o};function Ru(t){return(e={})=>{let n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}var RH={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},PH={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},FH={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},uS={date:Ru({formats:RH,defaultWidth:"full"}),time:Ru({formats:PH,defaultWidth:"full"}),dateTime:Ru({formats:FH,defaultWidth:"full"})};var BH={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pS=(t,e,n,o)=>BH[t];function _a(t){return(e,n)=>{let o=n?.context?String(n.context):"standalone",r;if(o==="formatting"&&t.formattingValues){let s=t.defaultFormattingWidth||t.defaultWidth,a=n?.width?String(n.width):s;r=t.formattingValues[a]||t.formattingValues[s]}else{let s=t.defaultWidth,a=n?.width?String(n.width):t.defaultWidth;r=t.values[a]||t.values[s]}let i=t.argumentCallback?t.argumentCallback(e):e;return r[i]}}var $H={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zH={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},HH={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},UH={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},KH={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},jH={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},VH=(t,e)=>{let n=Number(t),o=n%100;if(o>20||o<10)switch(o%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},fS={ordinalNumber:VH,era:_a({values:$H,defaultWidth:"wide"}),quarter:_a({values:zH,defaultWidth:"wide",argumentCallback:t=>t-1}),month:_a({values:HH,defaultWidth:"wide"}),day:_a({values:UH,defaultWidth:"wide"}),dayPeriod:_a({values:KH,defaultWidth:"wide",formattingValues:jH,defaultFormattingWidth:"wide"})};function ba(t){return(e,n={})=>{let o=n.width,r=o&&t.matchPatterns[o]||t.matchPatterns[t.defaultMatchWidth],i=e.match(r);if(!i)return null;let s=i[0],a=o&&t.parsePatterns[o]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(a)?GH(a,u=>u.test(s)):WH(a,u=>u.test(s)),c;c=t.valueCallback?t.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;let d=e.slice(s.length);return{value:c,rest:d}}}function WH(t,e){for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function GH(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function hS(t){return(e,n={})=>{let o=e.match(t.matchPattern);if(!o)return null;let r=o[0],i=e.match(t.parsePattern);if(!i)return null;let s=t.valueCallback?t.valueCallback(i[0]):i[0];s=n.valueCallback?n.valueCallback(s):s;let a=e.slice(r.length);return{value:s,rest:a}}}var YH=/^(\d+)(th|st|nd|rd)?/i,qH=/\d+/i,JH={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},XH={any:[/^b/i,/^(a|c)/i]},ZH={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},QH={any:[/1/i,/2/i,/3/i,/4/i]},e4={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},t4={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},n4={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},o4={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},r4={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},i4={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},gS={ordinalNumber:hS({matchPattern:YH,parsePattern:qH,valueCallback:t=>parseInt(t,10)}),era:ba({matchPatterns:JH,defaultMatchWidth:"wide",parsePatterns:XH,defaultParseWidth:"any"}),quarter:ba({matchPatterns:ZH,defaultMatchWidth:"wide",parsePatterns:QH,defaultParseWidth:"any",valueCallback:t=>t+1}),month:ba({matchPatterns:e4,defaultMatchWidth:"wide",parsePatterns:t4,defaultParseWidth:"any"}),day:ba({matchPatterns:n4,defaultMatchWidth:"wide",parsePatterns:o4,defaultParseWidth:"any"}),dayPeriod:ba({matchPatterns:r4,defaultMatchWidth:"any",parsePatterns:i4,defaultParseWidth:"any"})};var fm={code:"en-US",formatDistance:dS,formatLong:uS,formatRelative:pS,localize:fS,match:gS,options:{weekStartsOn:0,firstWeekContainsDate:1}};var s4={};function Zo(){return s4}var a4=Math.pow(10,8)*24*60*60*1e3,MX=-a4,Pu=6048e5,mS=864e5;var l4=3600;var _S=l4*24,LX=_S*7,c4=_S*365.2425,d4=c4/12,RX=d4*3,hm=Symbol.for("constructDateFrom");function Fn(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&hm in t?t[hm](e):t instanceof Date?new t.constructor(e):new Date(e)}function vt(t,e){return Fn(e||t,t)}function gm(t){let e=vt(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function bS(t,...e){let n=Fn.bind(null,t||e.find(o=>typeof o=="object"));return e.map(n)}function mm(t,e){let n=vt(t,e?.in);return n.setHours(0,0,0,0),n}function yS(t,e,n){let[o,r]=bS(n?.in,t,e),i=mm(o),s=mm(r),a=+i-gm(i),l=+s-gm(s);return Math.round((a-l)/mS)}function xS(t,e){let n=vt(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function vS(t,e){let n=vt(t,e?.in);return yS(n,xS(n))+1}function Tr(t,e){let n=Zo(),o=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=vt(t,e?.in),i=r.getDay(),s=(i<o?7:0)+i-o;return r.setDate(r.getDate()-s),r.setHours(0,0,0,0),r}function cs(t,e){return Tr(t,{...e,weekStartsOn:1})}function Fu(t,e){let n=vt(t,e?.in),o=n.getFullYear(),r=Fn(n,0);r.setFullYear(o+1,0,4),r.setHours(0,0,0,0);let i=cs(r),s=Fn(n,0);s.setFullYear(o,0,4),s.setHours(0,0,0,0);let a=cs(s);return n.getTime()>=i.getTime()?o+1:n.getTime()>=a.getTime()?o:o-1}function CS(t,e){let n=Fu(t,e),o=Fn(e?.in||t,0);return o.setFullYear(n,0,4),o.setHours(0,0,0,0),cs(o)}function ES(t,e){let n=vt(t,e?.in),o=+cs(n)-+CS(n);return Math.round(o/Pu)+1}function Bu(t,e){let n=vt(t,e?.in),o=n.getFullYear(),r=Zo(),i=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=Fn(e?.in||t,0);s.setFullYear(o+1,0,i),s.setHours(0,0,0,0);let a=Tr(s,e),l=Fn(e?.in||t,0);l.setFullYear(o,0,i),l.setHours(0,0,0,0);let c=Tr(l,e);return+n>=+a?o+1:+n>=+c?o:o-1}function wS(t,e){let n=Zo(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=Bu(t,e),i=Fn(e?.in||t,0);return i.setFullYear(r,0,o),i.setHours(0,0,0,0),Tr(i,e)}function TS(t,e){let n=vt(t,e?.in),o=+Tr(n,e)-+wS(n,e);return Math.round(o/Pu)+1}function Ue(t,e){let n=t<0?"-":"",o=Math.abs(t).toString().padStart(e,"0");return n+o}var Sr={y(t,e){let n=t.getFullYear(),o=n>0?n:1-n;return Ue(e==="yy"?o%100:o,e.length)},M(t,e){let n=t.getMonth();return e==="M"?String(n+1):Ue(n+1,2)},d(t,e){return Ue(t.getDate(),e.length)},a(t,e){let n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Ue(t.getHours()%12||12,e.length)},H(t,e){return Ue(t.getHours(),e.length)},m(t,e){return Ue(t.getMinutes(),e.length)},s(t,e){return Ue(t.getSeconds(),e.length)},S(t,e){let n=e.length,o=t.getMilliseconds(),r=Math.trunc(o*Math.pow(10,n-3));return Ue(r,e.length)}};var ya={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},_m={G:function(t,e,n){let o=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(o,{width:"abbreviated"});case"GGGGG":return n.era(o,{width:"narrow"});default:return n.era(o,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){let o=t.getFullYear(),r=o>0?o:1-o;return n.ordinalNumber(r,{unit:"year"})}return Sr.y(t,e)},Y:function(t,e,n,o){let r=Bu(t,o),i=r>0?r:1-r;if(e==="YY"){let s=i%100;return Ue(s,2)}return e==="Yo"?n.ordinalNumber(i,{unit:"year"}):Ue(i,e.length)},R:function(t,e){let n=Fu(t);return Ue(n,e.length)},u:function(t,e){let n=t.getFullYear();return Ue(n,e.length)},Q:function(t,e,n){let o=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(o);case"QQ":return Ue(o,2);case"Qo":return n.ordinalNumber(o,{unit:"quarter"});case"QQQ":return n.quarter(o,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(o,{width:"narrow",context:"formatting"});default:return n.quarter(o,{width:"wide",context:"formatting"})}},q:function(t,e,n){let o=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(o);case"qq":return Ue(o,2);case"qo":return n.ordinalNumber(o,{unit:"quarter"});case"qqq":return n.quarter(o,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(o,{width:"narrow",context:"standalone"});default:return n.quarter(o,{width:"wide",context:"standalone"})}},M:function(t,e,n){let o=t.getMonth();switch(e){case"M":case"MM":return Sr.M(t,e);case"Mo":return n.ordinalNumber(o+1,{unit:"month"});case"MMM":return n.month(o,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(o,{width:"narrow",context:"formatting"});default:return n.month(o,{width:"wide",context:"formatting"})}},L:function(t,e,n){let o=t.getMonth();switch(e){case"L":return String(o+1);case"LL":return Ue(o+1,2);case"Lo":return n.ordinalNumber(o+1,{unit:"month"});case"LLL":return n.month(o,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(o,{width:"narrow",context:"standalone"});default:return n.month(o,{width:"wide",context:"standalone"})}},w:function(t,e,n,o){let r=TS(t,o);return e==="wo"?n.ordinalNumber(r,{unit:"week"}):Ue(r,e.length)},I:function(t,e,n){let o=ES(t);return e==="Io"?n.ordinalNumber(o,{unit:"week"}):Ue(o,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Sr.d(t,e)},D:function(t,e,n){let o=vS(t);return e==="Do"?n.ordinalNumber(o,{unit:"dayOfYear"}):Ue(o,e.length)},E:function(t,e,n){let o=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(o,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(o,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},e:function(t,e,n,o){let r=t.getDay(),i=(r-o.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return Ue(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},c:function(t,e,n,o){let r=t.getDay(),i=(r-o.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return Ue(i,e.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(r,{width:"narrow",context:"standalone"});case"cccccc":return n.day(r,{width:"short",context:"standalone"});default:return n.day(r,{width:"wide",context:"standalone"})}},i:function(t,e,n){let o=t.getDay(),r=o===0?7:o;switch(e){case"i":return String(r);case"ii":return Ue(r,e.length);case"io":return n.ordinalNumber(r,{unit:"day"});case"iii":return n.day(o,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(o,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},a:function(t,e,n){let r=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(t,e,n){let o=t.getHours(),r;switch(o===12?r=ya.noon:o===0?r=ya.midnight:r=o/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(t,e,n){let o=t.getHours(),r;switch(o>=17?r=ya.evening:o>=12?r=ya.afternoon:o>=4?r=ya.morning:r=ya.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let o=t.getHours()%12;return o===0&&(o=12),n.ordinalNumber(o,{unit:"hour"})}return Sr.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Sr.H(t,e)},K:function(t,e,n){let o=t.getHours()%12;return e==="Ko"?n.ordinalNumber(o,{unit:"hour"}):Ue(o,e.length)},k:function(t,e,n){let o=t.getHours();return o===0&&(o=24),e==="ko"?n.ordinalNumber(o,{unit:"hour"}):Ue(o,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Sr.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Sr.s(t,e)},S:function(t,e){return Sr.S(t,e)},X:function(t,e,n){let o=t.getTimezoneOffset();if(o===0)return"Z";switch(e){case"X":return kS(o);case"XXXX":case"XX":return ds(o);default:return ds(o,":")}},x:function(t,e,n){let o=t.getTimezoneOffset();switch(e){case"x":return kS(o);case"xxxx":case"xx":return ds(o);default:return ds(o,":")}},O:function(t,e,n){let o=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+SS(o,":");default:return"GMT"+ds(o,":")}},z:function(t,e,n){let o=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+SS(o,":");default:return"GMT"+ds(o,":")}},t:function(t,e,n){let o=Math.trunc(+t/1e3);return Ue(o,e.length)},T:function(t,e,n){return Ue(+t,e.length)}};function SS(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=Math.trunc(o/60),i=o%60;return i===0?n+String(r):n+String(r)+e+Ue(i,2)}function kS(t,e){return t%60===0?(t>0?"-":"+")+Ue(Math.abs(t)/60,2):ds(t,e)}function ds(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=Ue(Math.trunc(o/60),2),i=Ue(o%60,2);return n+r+e+i}var NS=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},DS=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},u4=(t,e)=>{let n=t.match(/(P+)(p+)?/)||[],o=n[1],r=n[2];if(!r)return NS(t,e);let i;switch(o){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",NS(o,e)).replace("{{time}}",DS(r,e))},OS={p:DS,P:u4};var p4=/^D+$/,f4=/^Y+$/,h4=["D","DD","YY","YYYY"];function IS(t){return p4.test(t)}function AS(t){return f4.test(t)}function MS(t,e,n){let o=g4(t,e,n);if(console.warn(o),h4.includes(t))throw new RangeError(o)}function g4(t,e,n){let o=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${o} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}function LS(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function RS(t){return!(!LS(t)&&typeof t!="number"||isNaN(+vt(t)))}var m4=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,_4=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,b4=/^'([^]*?)'?$/,y4=/''/g,x4=/[a-zA-Z]/;function PS(t,e,n){let o=Zo(),r=n?.locale??o.locale??fm,i=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0,a=vt(t,n?.in);if(!RS(a))throw new RangeError("Invalid time value");let l=e.match(_4).map(d=>{let u=d[0];if(u==="p"||u==="P"){let p=OS[u];return p(d,r.formatLong)}return d}).join("").match(m4).map(d=>{if(d==="''")return{isToken:!1,value:"'"};let u=d[0];if(u==="'")return{isToken:!1,value:v4(d)};if(_m[u])return{isToken:!0,value:d};if(u.match(x4))throw new RangeError("Format string contains an unescaped latin alphabet character `"+u+"`");return{isToken:!1,value:d}});r.localize.preprocessor&&(l=r.localize.preprocessor(a,l));let c={firstWeekContainsDate:i,weekStartsOn:s,locale:r};return l.map(d=>{if(!d.isToken)return d.value;let u=d.value;(!n?.useAdditionalWeekYearTokens&&AS(u)||!n?.useAdditionalDayOfYearTokens&&IS(u))&&MS(u,e,String(t));let p=_m[u[0]];return p(a,u,r.localize,c)}).join("")}function v4(t){let e=t.match(b4);return e?e[1].replace(y4,"'"):t}function FS(){return Object.assign({},Zo())}function bm(t,e,n){let o=FS(),r=w4(t,n.timeZone,n.locale??o.locale);return"formatToParts"in r?C4(r,e):E4(r,e)}function C4(t,e){let n=t.formatToParts(e);for(let o=n.length-1;o>=0;--o)if(n[o].type==="timeZoneName")return n[o].value}function E4(t,e){let n=t.format(e).replace(/\u200E/g,""),o=/ [\w-+ ]+$/.exec(n);return o?o[0].substr(1):""}function w4(t,e,n){return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:e,timeZoneName:t})}function $S(t,e){let n=D4(e);return"formatToParts"in n?S4(n,t):k4(n,t)}var T4={year:0,month:1,day:2,hour:3,minute:4,second:5};function S4(t,e){try{let n=t.formatToParts(e),o=[];for(let r=0;r<n.length;r++){let i=T4[n[r].type];i!==void 0&&(o[i]=parseInt(n[r].value,10))}return o}catch(n){if(n instanceof RangeError)return[NaN];throw n}}function k4(t,e){let n=t.format(e),o=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[parseInt(o[3],10),parseInt(o[1],10),parseInt(o[2],10),parseInt(o[4],10),parseInt(o[5],10),parseInt(o[6],10)]}var ym={},BS=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),N4=BS==="06/25/2014, 00:00:00"||BS==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";function D4(t){return ym[t]||(ym[t]=N4?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:t,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),ym[t]}function dc(t,e,n,o,r,i,s){let a=new Date(0);return a.setUTCFullYear(t,e,n),a.setUTCHours(o,r,i,s),a}var zS=36e5,O4=6e4,xm={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function kr(t,e,n){if(!t)return 0;let o=xm.timezoneZ.exec(t);if(o)return 0;let r,i;if(o=xm.timezoneHH.exec(t),o)return r=parseInt(o[1],10),HS(r)?-(r*zS):NaN;if(o=xm.timezoneHHMM.exec(t),o){r=parseInt(o[2],10);let s=parseInt(o[3],10);return HS(r,s)?(i=Math.abs(r)*zS+s*O4,o[1]==="+"?-i:i):NaN}if(M4(t)){e=new Date(e||Date.now());let s=n?e:I4(e),a=vm(s,t);return-(n?a:A4(e,a,t))}return NaN}function I4(t){return dc(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}function vm(t,e){let n=$S(t,e),o=dc(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),r=t.getTime(),i=r%1e3;return r-=i>=0?i:1e3+i,o-r}function A4(t,e,n){let r=t.getTime()-e,i=vm(new Date(r),n);if(e===i)return e;r-=i-e;let s=vm(new Date(r),n);return i===s?i:Math.max(i,s)}function HS(t,e){return-23<=t&&t<=23&&(e==null||0<=e&&e<=59)}var US={};function M4(t){if(US[t])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:t}),US[t]=!0,!0}catch{return!1}}var L4=60*1e3,jS={X:function(t,e,n){let o=Cm(n.timeZone,t);if(o===0)return"Z";switch(e){case"X":return KS(o);case"XXXX":case"XX":return xa(o);default:return xa(o,":")}},x:function(t,e,n){let o=Cm(n.timeZone,t);switch(e){case"x":return KS(o);case"xxxx":case"xx":return xa(o);default:return xa(o,":")}},O:function(t,e,n){let o=Cm(n.timeZone,t);switch(e){case"O":case"OO":case"OOO":return"GMT"+R4(o,":");default:return"GMT"+xa(o,":")}},z:function(t,e,n){switch(e){case"z":case"zz":case"zzz":return bm("short",t,n);default:return bm("long",t,n)}}};function Cm(t,e){let n=t?kr(t,e,!0)/L4:e?.getTimezoneOffset()??0;if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+t);return n}function $u(t,e){let n=t<0?"-":"",o=Math.abs(t).toString();for(;o.length<e;)o="0"+o;return n+o}function xa(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=$u(Math.floor(o/60),2),i=$u(Math.floor(o%60),2);return n+r+e+i}function KS(t,e){return t%60===0?(t>0?"-":"+")+$u(Math.abs(t)/60,2):xa(t,e)}function R4(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=Math.floor(o/60),i=o%60;return i===0?n+String(r):n+String(r)+e+$u(i,2)}function Em(t){let e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+t-+e}var zu=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/;var wm=36e5,VS=6e4,P4=2,Cn={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:zu};function pi(t,e={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(t===null)return new Date(NaN);let n=e.additionalDigits==null?P4:Number(e.additionalDigits);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]")return new Date(t.getTime());if(typeof t=="number"||Object.prototype.toString.call(t)==="[object Number]")return new Date(t);if(Object.prototype.toString.call(t)!=="[object String]")return new Date(NaN);let o=F4(t),{year:r,restDateString:i}=B4(o.date,n),s=$4(i,r);if(s===null||isNaN(s.getTime()))return new Date(NaN);if(s){let a=s.getTime(),l=0,c;if(o.time&&(l=z4(o.time),l===null||isNaN(l)))return new Date(NaN);if(o.timeZone||e.timeZone){if(c=kr(o.timeZone||e.timeZone,new Date(a+l)),isNaN(c))return new Date(NaN)}else c=Em(new Date(a+l)),c=Em(new Date(a+l+c));return new Date(a+l+c)}else return new Date(NaN)}function F4(t){let e={},n=Cn.dateTimePattern.exec(t),o;if(n?(e.date=n[1],o=n[3]):(n=Cn.datePattern.exec(t),n?(e.date=n[1],o=n[2]):(e.date=null,o=t)),o){let r=Cn.timeZone.exec(o);r?(e.time=o.replace(r[1],""),e.timeZone=r[1].trim()):e.time=o}return e}function B4(t,e){if(t){let n=Cn.YYY[e],o=Cn.YYYYY[e],r=Cn.YYYY.exec(t)||o.exec(t);if(r){let i=r[1];return{year:parseInt(i,10),restDateString:t.slice(i.length)}}if(r=Cn.YY.exec(t)||n.exec(t),r){let i=r[1];return{year:parseInt(i,10)*100,restDateString:t.slice(i.length)}}}return{year:null}}function $4(t,e){if(e===null)return null;let n,o,r;if(!t||!t.length)return n=new Date(0),n.setUTCFullYear(e),n;let i=Cn.MM.exec(t);if(i)return n=new Date(0),o=parseInt(i[1],10)-1,GS(e,o)?(n.setUTCFullYear(e,o),n):new Date(NaN);if(i=Cn.DDD.exec(t),i){n=new Date(0);let s=parseInt(i[1],10);return K4(e,s)?(n.setUTCFullYear(e,0,s),n):new Date(NaN)}if(i=Cn.MMDD.exec(t),i){n=new Date(0),o=parseInt(i[1],10)-1;let s=parseInt(i[2],10);return GS(e,o,s)?(n.setUTCFullYear(e,o,s),n):new Date(NaN)}if(i=Cn.Www.exec(t),i)return r=parseInt(i[1],10)-1,YS(r)?WS(e,r):new Date(NaN);if(i=Cn.WwwD.exec(t),i){r=parseInt(i[1],10)-1;let s=parseInt(i[2],10)-1;return YS(r,s)?WS(e,r,s):new Date(NaN)}return null}function z4(t){let e,n,o=Cn.HH.exec(t);if(o)return e=parseFloat(o[1].replace(",",".")),Tm(e)?e%24*wm:NaN;if(o=Cn.HHMM.exec(t),o)return e=parseInt(o[1],10),n=parseFloat(o[2].replace(",",".")),Tm(e,n)?e%24*wm+n*VS:NaN;if(o=Cn.HHMMSS.exec(t),o){e=parseInt(o[1],10),n=parseInt(o[2],10);let r=parseFloat(o[3].replace(",","."));return Tm(e,n,r)?e%24*wm+n*VS+r*1e3:NaN}return null}function WS(t,e,n){e=e||0,n=n||0;let o=new Date(0);o.setUTCFullYear(t,0,4);let r=o.getUTCDay()||7,i=e*7+n+1-r;return o.setUTCDate(o.getUTCDate()+i),o}var H4=[31,28,31,30,31,30,31,31,30,31,30,31],U4=[31,29,31,30,31,30,31,31,30,31,30,31];function qS(t){return t%400===0||t%4===0&&t%100!==0}function GS(t,e,n){if(e<0||e>11)return!1;if(n!=null){if(n<1)return!1;let o=qS(t);if(o&&n>U4[e]||!o&&n>H4[e])return!1}return!0}function K4(t,e){if(e<1)return!1;let n=qS(t);return!(n&&e>366||!n&&e>365)}function YS(t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function Tm(t,e,n){return!(t<0||t>=25||e!=null&&(e<0||e>=60)||n!=null&&(n<0||n>=60))}var j4=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Sm(t,e,n={}){e=String(e);let o=e.match(j4);if(o){let r=pi(n.originalDate||t,n);e=o.reduce(function(i,s){if(s[0]==="'")return i;let a=i.indexOf(s),l=i[a-1]==="'",c=i.replace(s,"'"+jS[s[0]](r,s,n)+"'");return l?c.substring(0,a-1)+c.substring(a+1):c},e)}return PS(t,e,n)}function km(t,e,n){t=pi(t,n);let o=kr(e,t,!0),r=new Date(t.getTime()-o),i=new Date(0);return i.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),i.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),i}function Nm(t,e,n,o){return o={...o,timeZone:e,originalDate:t},Sm(km(t,e,{timeZone:o.timeZone}),n,o)}function Dm(t,e,n){if(typeof t=="string"&&!t.match(zu))return pi(t,{...n,timeZone:e});t=pi(t,n);let o=dc(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()).getTime(),r=kr(e,new Date(o));return new Date(o+r)}ke();function JS(t){let e=t.field,[n,o]=At(t.deepKey),r=`${V4(t.deepKey)}.timezone`,[i,s]=At(r),a=e.timezone||i||Intl.DateTimeFormat().resolvedOptions().timeZone,l=X(()=>{if(!n)return"";try{return Nm(n.toDate(),a,"yyyy-MM-dd'T'HH:mm")}catch(h){return console.error("Error formatting date:",h),""}},[n,a]),[c,d]=L(null),u=(h,g)=>{if(g&&!g.valid){console.warn("Invalid date input"),d("Invalid datetime");return}if(h)try{let m=Dm(h,a);if(isNaN(m.getTime())){console.warn("Invalid date:",h),d("Invalid datetime");return}d(null),o(Id.fromDate(m))}catch(m){console.error("Error parsing date:",m),d("Invalid datetime")}else d(null),o(null)},p=h=>{s(h)};return f("div",{className:"DocEditor__DateTimeField",children:[f("div",{className:"DocEditor__DateTimeField__row",children:[f("input",{type:"datetime-local",value:l,onChange:h=>{let g=h.target;u(g.value,g.validity)},className:"DocEditor__DateTimeField__input"}),e.timezone?f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",e.timezone]}):f(Rn,{className:"DocEditor__DateTimeField__timezoneSelect",value:a,onChange:h=>{h&&p(h)},data:Intl.supportedValuesOf("timeZone"),searchable:!0,size:"xs"})]}),c&&f("div",{className:"DocEditor__DateTimeField__error",children:c})]})}function V4(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}br();yr();yr();ke();var W4=["drive.google.com","docs.google.com"];function Hu(t){try{let e=new URL(t);if(!W4.includes(e.hostname))return null;if(e.searchParams.has("id"))return e.searchParams.get("id");let n=e.pathname.split("/"),o=n.findIndex(r=>r==="d");if(o!==-1&&o<n.length-1)return n[o+1]}catch{return null}return null}async function XS(t,e){let n="https://www.googleapis.com/auth/drive.readonly";(!t.isLoggedIn()||!t.hasScope(n))&&await t.login({scopes:[n]});let o=window.gapi;if(!o||!o.client||!o.client.drive)throw new Error("Google Drive API not loaded");let r=o.auth.getToken()?.access_token;if(!r)throw new Error("No Google Drive access token found");let[i,s]=await Promise.all([o.client.drive.files.get({fileId:e,fields:"name,mimeType,size",supportsAllDrives:!0}),fetch(`https://www.googleapis.com/drive/v3/files/${e}?alt=media&supportsAllDrives=true`,{headers:{Authorization:`Bearer ${r}`}})]),a=i.result;if(!s.ok)throw new Error(`Failed to download file from Drive: ${s.statusText}`);let l=await s.blob();return new File([l],a.name,{type:a.mimeType})}ke();var G4=["1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"],Y4=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"];function ZS(t){let[e,n]=L("simple"),[o,r]=L(!1),[i,s]=L(!1),[a,l]=L(null),[c,d]=L(""),[u,p]=L(t.initialWidth||1600),[h,g]=L(t.initialHeight||900),[m,_]=L("16:9"),b=_w();async function y(){if(!c){ae({title:"Prompt required",message:"Please enter a prompt to generate an image.",color:"red"});return}r(!0);try{let E=await(await fetch("/cms/api/ai.generate_image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:c,aspectRatio:m})})).json();if(E.success&&E.image)l(E.image);else throw new Error(E.error||"Failed to generate image")}catch(C){console.error(C),ae({title:"Generation failed",message:C.message||"Unknown error",color:"red"})}finally{r(!1)}}function v(C){C.preventDefault();let E=new FormData(C.target),k=parseInt(E.get("width"),10),T=parseInt(E.get("height"),10),w=E.get("backgroundColor"),S=E.get("label")||`${k}x${T}`,N=[];if(N.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${k}" height="${T}" viewBox="0 0 ${k} ${T}"><rect width="${k}" height="${T}" fill="${w}" />`),S){let P=k*.5/(S.length*.6);N.push(`<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-size="${P}" fill="#fff">${S}</text>`)}N.push("</svg>");let D=N.join(""),A=new TextEncoder().encode(D),R={src:`data:image/svg+xml;base64,${btoa(String.fromCharCode(...A))}`,filename:"placeholder.svg",width:k,height:T,alt:""};t.onSubmit(R)}async function x(){if(a){s(!0);try{let E=await(await fetch(a)).blob(),k=new File([E],"generated-image.png",{type:"image/png"}),{uploadFileToGCS:T}=await import("./gcs-ECSDFCIU.js"),w=await T(k),[S,N]=m.split(":").map(Number),D=1600,O=Math.round(D*N/S),A={...w,width:D,height:O,alt:c};t.onSubmit(A)}catch(C){console.error(C),ae({title:"Save failed",message:C.message||"Failed to upload image",color:"red"})}finally{s(!1)}}}return f(ho,{gap:"md",children:[b&&f(Dd,{value:e,onChange:C=>n(C),data:[{label:"Simple",value:"simple"},{label:f(fn,{gap:5,children:[f(Oo,{size:16}),f("span",{children:"Generate with AI"})]}),value:"ai"}],fullWidth:!0}),e==="simple"?f("form",{onSubmit:v,children:[f(ho,{gap:"xs",children:[f(Xn,{label:"Width",name:"width",type:"number",value:u,onChange:C=>p(parseInt(C.currentTarget.value,10)),"data-autofocus":!0}),f(Xn,{label:"Height",name:"height",type:"number",value:h,onChange:C=>g(parseInt(C.currentTarget.value,10))}),f(Xn,{name:"label",label:"Label",defaultValue:""}),f(AC,{name:"backgroundColor",label:"Background color",format:"hex",defaultValue:"#868e96",swatches:Y4})]}),f(fn,{justify:"flex-end",mt:"md",children:f(Z,{variant:"filled",type:"submit",children:"Create"})})]}):f(ho,{gap:"xs",children:[f(Rn,{label:"Aspect Ratio",data:G4,value:m,onChange:C=>_(C)}),f(bn,{label:"Prompt",placeholder:"Describe the image you want to generate...",minRows:3,value:c,onChange:C=>d(C.currentTarget.value),"data-autofocus":!0,required:!0}),a&&f(ea,{src:a,alt:"Generated preview",height:200,fit:"contain"}),f(fn,{justify:"flex-end",mt:"md",children:[f(Z,{variant:"light",onClick:y,loading:o,disabled:i||!c,leftIcon:f(Oo,{size:16}),children:o?"Generating...":"Preview"}),f(Z,{variant:"filled",onClick:x,loading:i,disabled:!a||o,children:i?"Saving...":"Save"})]})]})]})}var q4=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"],QS=pt(null),J4=TC(()=>import("./ImageEditorDialog-YDKOGVJV.js").then(t=>({default:t.ImageEditorDialog})));function uc(){let t=ft(QS);if(!t)throw new Error("useFileField() should be called within a <FileFieldContext.Provider>");return t}function X4(t){let{field:e,value:n,setValue:o,loadingState:r,setLoadingState:i}=t,s=NC(),a=J(null),[l,c]=L(!1),[d,u]=L(!1),[p,h]=L(!1),g=la(),m=Pw(),_=t.allowEditing!==!1,[b,y]=L("hash"),[v,x]=L(null),[C,E]=L(!1),[k,T]=L(null),w=t.accept??e.exts??(t.variant==="image"?q4:[]),S=n?.alt||"",N=t.altDisabledByMetadata===!0,D=n?.altDisabled===!0,O=e.alt!==!1&&!N&&!D;async function A(oe,ee,ye){try{i("loading");let Fe=ye?.namingMode||(e.preserveFilename?"clean":"hash"),un=e.cacheControl||(Fe==="clean"?"no-cache":void 0),Be=await ai(oe,{namingMode:Fe,checkExists:ye?.checkExists??!1,cacheControl:un});!Be.alt&&ek(Be.filename)&&S&&(Be.alt=S),ee&&(Be.originalSrc=ee),o(Be),i("complete"),x(null),T(null)}catch(Fe){console.error("upload failed"),console.error(Fe),i("error"),ae({title:"Upload failed",message:"Failed to upload: "+String(Fe),color:"red",autoClose:!1})}}async function I(){i("loading");try{let oe=n?.gcsPath||n?.src;oe&&await jC(oe),o(null),i(null),ae({message:"File deleted from GCS",color:"green"})}catch(oe){console.error(oe),i("error"),ae({title:"Delete failed",message:String(oe),color:"red"})}finally{u(!1)}}function R(){if(!_&&n?.src){u(!0);return}o(null)}async function $(oe,ee){if(!oe)return;if(x(null),T(null),E(!1),typeof oe=="string"&&!ee?.as){let un=Hu(oe);if(un){try{if(!g.enabled){console.warn("Google API integration is not enabled for this project. Specify the `gapi` config in your root.config.ts to enable pasting from Google Drive URLs.");return}i("loading"),ae({message:"Downloading from Google Drive...",loading:!0,autoClose:!1,id:"gdrive-download"});let Be=await XS(g,un);Il("gdrive-download"),$(Be)}catch(Be){console.error(Be),i("error"),Il("gdrive-download"),ae({title:"Google Drive import failed",message:Be.message||"Failed to download",color:"red"})}return}}ee?.as==="svg"&&typeof oe=="string"&&(oe=new File([new Blob([oe],{type:"image/svg+xml"})],"untitled.svg",{type:"image/svg+xml"}));let ye=oe,Fe=Ph(ye.name);if(w.length>0&&!w.some(un=>un.endsWith(Fe)||un===`*/${Fe}`||un==="*/*"||un===ye.type)){ae({title:"Invalid file type",message:`File type ${Fe} is not allowed.`,color:"red",autoClose:!0});return}if(b==="clean"&&t.showNamingOptions){i("loading");let Be=`${window.__ROOT_CTX.rootConfig.projectId}/uploads/${ye.name}`;try{if(await VC(Be)){x(ye),T(`https://storage.googleapis.com/${window.firebase.storage.app.options.storageBucket}/${Be}`),i(null);return}}catch(on){console.warn("Failed to check file existence",on)}}A(ye,void 0,{namingMode:b})}function W(){a.current?.focus()}function P(){if(n?.src)if(Fh(n.src)){let oe=document.createElement("a");oe.href=WC(n.src),n.filename&&(oe.download=n.filename),document.body.appendChild(oe),oe.click(),document.body.removeChild(oe)}else window.open(n.src,"_blank")}function q(){let oe=document.createElement("input");oe.type="file",w.length>0&&(oe.accept=w.join(",")),oe.onchange=ee=>{let ye=ee.target;ye.files&&ye.files.length>0&&$(ye.files[0])},oe.click(),oe.remove()}function de(){c(!0)}function rt(){h(!0)}async function Tt(){let oe=GC();if(n?.assetId)try{let ee=await qC(n.assetId);ee&&(oe=ee.parent||"")}catch(ee){console.warn("failed to resolve linked asset folder:",ee)}m.open({accept:w,initialFolder:oe,onSelect:ee=>{let ye=JC(ee);!ye.alt&&S&&(ye.alt=S),o(ye),i("complete")}})}function _t(){if(!n?.assetId)return;let oe={...n};delete oe.assetId,o(oe)}function dt(oe){n?.src&&o({...n,alt:oe||""})}async function ut(){let oe=n;if(oe?.src){i("loading");try{let ee=await window.fetch("/cms/api/ai.generate_alt_text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({imageUrl:oe.src})}),ye=await ee.json();if(!ee.ok||!ye.success)throw new Error(ye.error||"Failed to generate alt text");ye.altText&&dt(ye.altText)}catch(ee){ae({title:"Sorry, something went wrong.",message:ee.message||"Unknown error",color:"red",autoClose:!0})}finally{i("complete")}}}return f(QS.Provider,{value:{field:e,variant:t.variant,value:n,setValue:o,loadingState:r,removeFile:R,acceptedFileTypes:w,handleFile:$,focusDropZone:W,requestGenerateAltText:ut,requestFileUpload:q,requestFileDownload:P,requestPlaceholderModalOpen:de,requestImageEditorOpen:rt,assetPickerEnabled:m.enabled,requestAssetPicker:Tt,unlinkAsset:_t,showAltText:O,altText:S,setAltText:dt,altDisabledByMetadata:N,setAltDisabledByMetadata:t.setAltDisabledByMetadata,allowEditing:_},children:[f(Xi,{size:"sm",opened:l,onClose:()=>c(!1),title:"Placeholder image",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:f(ZS,{onSubmit:oe=>{o(oe),c(!1)}})}),f(Xi,{size:"sm",opened:d,onClose:()=>u(!1),title:"Delete file?",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:[f(Bt,{size:"sm",mb:"lg",children:"Are you sure you want to delete this file from GCS? This action cannot be undone."}),f(fn,{grow:!0,spacing:"xs",children:[f(Z,{variant:"default",onClick:()=>u(!1),disabled:r==="loading",children:"Cancel"}),f(Z,{color:"red",onClick:I,loading:r==="loading",children:"Delete"})]})]}),p&&n?.src&&f(Sd,{fallback:null,children:f(J4,{opened:p,onClose:()=>h(!1),src:n.src,originalSrc:n.originalSrc,filename:n.filename,initialWidth:parseInt(n.width),initialHeight:parseInt(n.height),onSave:oe=>{A(oe,n.originalSrc||n.src),h(!1)}},n.src)}),v?f("div",{className:"FileField__overwriteWarning",children:[f("div",{className:"FileField__overwriteWarning__header",children:f(Bt,{size:"sm",color:"red",weight:700,children:"File already exists"})}),f(Bt,{size:"sm",children:["A file named ",f("strong",{children:v.name})," already exists."]}),k&&f(Bt,{size:"sm",className:"FileField__overwriteWarning__link",children:f("a",{href:k,target:"_blank",rel:"noopener noreferrer",children:["View existing file ",f(Do,{size:12})]})}),f("div",{className:"FileField__overwriteWarning__checkbox",children:f(fo,{label:"Confirm overwrite",checked:C,onChange:oe=>E(oe.currentTarget.checked)})}),f(fn,{grow:!0,spacing:"xs",className:"FileField__overwriteWarning__actions",children:[f(Z,{variant:"default",onClick:()=>{x(null),T(null),E(!1)},disabled:r==="loading",children:"Cancel"}),f(Z,{disabled:!C,onClick:()=>A(v,void 0,{namingMode:"clean"}),color:"red",loading:r==="loading",children:"Overwrite"})]})]}):f(Ne,{children:[f("div",{className:xe("FileField",t.showNamingOptions&&"FileField--withOptions"),children:[f(En.Dropzone,{ref:a}),n?.src?f(En.Preview,{}):f(En.InvisibleDropzone,{children:f(En.Empty,{})})]}),t.showNamingOptions&&!n&&f("div",{className:"FileField__settings",style:{marginTop:8},children:f(Rn,{label:"File name options",size:"xs",itemComponent:Z4,data:[{value:"hash",label:"Hash the file name",description:"The filename will be hashed so the file's original name won't be exposed."},{value:"hash-path",label:"Use a hashed path with the original file name",description:"Use the original file name, but put it inside a hashed directory."},{value:"clean",label:"Use the original file name only",description:"The file will be uploaded to the bucket as-is, without a hashed directory."}],value:b,onChange:oe=>y(oe||"hash"),disabled:r==="loading"||!!n})})]})]})}function En(t){let e=t.field,[n,o]=At(t.deepKey),[r,i]=L(null),s=e5(t.deepKey),[a,l]=At(s),c=a?.alt===!1,d=u=>{let p={...a||{}};u?p.alt=!1:delete p.alt,l(Object.keys(p).length===0?null:p)};return f(X4,{field:e,value:n,setValue:o,loadingState:r,setLoadingState:i,variant:t.variant,allowEditing:t.allowEditing,altDisabledByMetadata:c,setAltDisabledByMetadata:t.variant==="image"&&e.alt!==!1?d:void 0})}En.Preview=()=>{let t=uc(),[e,n]=L(!1),[o,r]=L(!1),i=Io(),s=!!t.value?.width&&!!t.value?.height&&Number(t.value.width)>0&&Number(t.value.height)>0,a=t.value?.filename||"",l=Ml(a),c=Cr(a)||l&&s,[d,u]=L(!c),p=J(t.value?.src);if(t.value?.src!==p.current){p.current=t.value?.src;let h=t.value?.filename||"",g=Cr(h)||Ml(h)&&s;!g&&!d?u(!0):g&&d&&u(!1)}return t.value?.src?f("div",{className:"FileField__Preview",children:[f("div",{className:"FileField__Preview__InfoButton",children:[c&&f(we,{label:"Toggle file info",position:"top",withArrow:!0,children:f(Ae,{onClick:()=>u(h=>!h),size:"sm",variant:"outline",className:"FileField__Preview__InfoButton__Icon","aria-label":"Toggle file info",children:f($l,{size:16})})}),f(G,{classNames:{body:"FileField__Preview__Menu"},shadow:"sm",control:f(Ae,{variant:"outline",size:"sm",radius:"sm",c:"black",className:"FileField__Preview__InfoButton__Icon",children:f(sa,{size:16})}),children:[t.allowEditing&&f(Ne,{children:[f(G.Label,{size:"sm",children:"REPLACE"}),f(G.Item,{icon:t.variant==="image"?f(jh,{size:16}):f(Bl,{size:16}),onClick:()=>t.requestFileUpload(),children:["Upload ",t.variant==="image"?"image":"file"]}),t.assetPickerEnabled&&f(G.Item,{icon:f($E,{size:16}),onClick:()=>t.requestAssetPicker(),children:"Select from asset library"}),tk(t.acceptedFileTypes)&&f(G.Item,{disabled:!t.value?.src,icon:f(Kh,{size:16}),onClick:()=>{t.requestPlaceholderModalOpen()},children:"Placeholder image"}),Cr(t.value?.src)&&!t.value?.src?.endsWith(".svg")&&f(G.Item,{disabled:!t.value?.src,icon:f(EE,{size:16}),closeMenuOnClick:!0,onClick:()=>{t.requestImageEditorOpen()},children:"Edit image"}),f(xr,{})]}),f(G.Item,{disabled:t.value?.src?.startsWith("data:"),onClick:()=>{t?.requestFileDownload()},icon:f(TE,{size:16}),children:"Download file"}),f(G.Item,{closeOnItemClick:!1,icon:f(Gd,{size:16}),onClick:()=>{r(!1);let h=t.value?.src||"";Fh(h)&&(h=h.split("=")[0]+"=s0"),navigator.clipboard.writeText(h).then(()=>r(!0)).finally(()=>setTimeout(()=>{r(!1)},2e3))},children:o?"Copied!":"Copy URL"}),t.value?.assetId&&f(G.Item,{component:"a",href:`/cms/assets?asset=${t.value.assetId}`,target:"_blank",rel:"noreferrer",icon:f(Do,{size:16}),children:"View in asset library"}),t.allowEditing&&t.value?.assetId&&f(G.Item,{icon:f(tw,{size:16}),onClick:()=>t.unlinkAsset(),children:"Unlink from asset library"}),t.allowEditing&&Cr(t.value?.src||"")&&t.value?.canvasBgColor&&f(G.Item,{icon:t.value?.canvasBgColor==="dark"?f(Jh,{size:16}):f(Gh,{size:16,style:{opacity:.25}}),closeOnItemClick:!1,onClick:()=>{let h=t.value?.canvasBgColor==="dark"?"light":"dark";t.value&&t.setValue({...t.value,canvasBgColor:h})},children:"Use dark canvas"}),t.allowEditing&&t.setAltDisabledByMetadata&&f(G.Item,{icon:t.altDisabledByMetadata?f(Jh,{size:16}):f(Gh,{size:16,style:{opacity:.25}}),closeOnItemClick:!1,onClick:()=>{t.setAltDisabledByMetadata?.(!t.altDisabledByMetadata)},children:"Disable alt text"}),f(xr,{}),f(G.Item,{color:"red",onClick:()=>{t?.removeFile()},icon:f(Zn,{size:16}),children:"Remove file"})]})]}),f("div",{className:xe("FileField__Canvas",d&&"FileField__Canvas--infoOpened",e&&"dragging"),style:Q4(t.value),onDragOver:h=>{h.preventDefault(),n(!0)},onDragLeave:h=>{h.preventDefault(),n(!1)},onDrop:h=>{h.preventDefault(),n(!1);let g=h.dataTransfer?.files[0];g&&t&&t.handleFile(g)},onPaste:h=>{h.preventDefault();let g=h.clipboardData?.files[0];if(g){t.handleFile(g);return}let m=h.clipboardData?.getData("text/plain");if(m){if(Hu(m)){t.handleFile(m);return}if(nk(m)){t.handleFile(m,{as:"svg"});return}}},children:[f(Nd,{visible:t.loadingState==="loading"}),d?f("div",{className:"FileField__Canvas__Info",children:[f(zl,{size:16,className:"FileField__Canvas__Info__Icon"}),f(RC,{className:"FileField__Canvas__Info__Table",verticalSpacing:"xs",fontSize:"xs",children:f("tbody",{children:[t.value?.filename&&f("tr",{children:[f("td",{children:f("b",{children:"Name"})}),f("td",{children:t.value.filename})]}),t.value?.assetId&&f("tr",{children:[f("td",{children:f("b",{children:"Asset"})}),f("td",{children:f("a",{href:`/cms/assets?asset=${t.value.assetId}`,target:"_blank",rel:"noreferrer",children:"Open in asset library"})})]}),t.value?.uploadedAt&&f("tr",{children:[f("td",{children:f("b",{children:"Uploaded"})}),f("td",{children:[new Date(parseInt(t.value.uploadedAt,10)).toLocaleString(),t.value.uploadedBy&&f(Ne,{children:[" by ",t.value.uploadedBy]})]})]}),!!(t.value?.width&&t.value?.height)&&f("tr",{children:[f("td",{children:f("b",{children:"Dimensions"})}),f("td",{children:[t.value.width,"x",t.value.height]})]}),f("tr",{children:[f("td",{children:f("b",{children:"URL"})}),f("td",{children:f(bn,{readOnly:!0,value:t.value?.src,size:"xs",radius:0,autosize:!0,maxRows:10})})]})]})})]}):f(Ne,{children:[!!(t.value?.width&&t.value?.height)&&f(DC,{radius:"sm",className:"FileField__Preview__Info",children:[t.value.width,"x",t.value.height]}),t.value?.assetId&&f("a",{className:"FileField__Preview__AssetLibraryBadge",href:`/cms/assets?asset=${t.value?.assetId}`,target:"_blank",children:"ASSET LIBRARY"}),Cr(t.value?.src)&&f("img",{onClick:()=>{t?.focusDropZone()},onDblClick:()=>{t.allowEditing&&t?.requestFileUpload()},src:t.value.src,alt:t.value.alt||"Uploaded file preview",className:"FileField__Preview__Image"}),Ml(t.value?.src)&&f(Ne,{children:f("video",{className:"FileField__Preview__Image",controls:!0,muted:!0,preload:"metadata",children:f("source",{src:t.value.src,type:`video/${Ph(t.value.src)}`})})})]}),t.allowEditing&&f("div",{className:"FileField__reupload",children:f(En.UploadButton,{className:"FileField__reupload__button",compact:!0})})]}),t.allowEditing&&t.showAltText&&(t.altText||ek(t.value?.filename)||t.variant==="image")&&f("div",{className:"DocEditor__ImageField__imagePreview__Image__Alt",children:[f(bn,{radius:0,className:"DocEditor__ImageField__imagePreview__Image__Alt__Textarea",value:t.altText,placeholder:"Alt text",size:"xs",autosize:!0,disabled:t.loadingState==="loading",onChange:h=>{t?.setAltText(h.currentTarget.value)}}),i&&!t.altText&&t.value?.src?.startsWith("http")&&f(we,{label:"Generate alt text with AI",position:"top",withArrow:!0,children:f(Ae,{className:"DocEditor__ImageField__imagePreview__Image__Alt__AiButton",onClick:()=>{t.requestGenerateAltText()},disabled:t.loadingState==="loading",children:f(Oo,{size:20,stroke:"1.75"})})})]})]}):null};En.UploadButton=t=>{let e=uc(),n=e.loadingState==="loading",o=t.compact?14:16;return f(Z,{color:"black",variant:"default",disabled:n,size:t.compact?"compact-xs":"compact-md",className:xe("FileField__FileUploadButton",t.compact&&"FileField__FileUploadButton--compact"),onClick:()=>{e.requestFileUpload()},leftIcon:f(Ne,{children:n&&!t.compact?f(xt,{size:o}):e?.variant==="image"?f(jh,{size:o}):f(Bl,{size:o})}),children:n&&!t.compact?"Uploading...":e.value?.src?"Upload":"Paste, drop, or click to upload"})};En.InvisibleDropzone=t=>{let[e,n]=L(!1),o=uc();return f("div",{className:xe("FileField__InvisibleDropzone",e&&"dragging"),onDragOver:r=>{r.preventDefault(),r.stopPropagation(),n(!0)},onDragLeave:r=>{r.preventDefault(),r.stopPropagation(),n(!1)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),n(!1);let i=r.dataTransfer?.files[0];i&&o.handleFile(i)},children:t.children})};En.Empty=()=>{let t=uc(),e=X(()=>{if(t.acceptedFileTypes.length===0)return"";let n=t.acceptedFileTypes.filter(o=>o!=="*/*"&&o!=="*");return n.length===0?"":n.map(o=>o.split("/").pop().split("+")[0].replaceAll(".","")).sort().join(", ")},[t.acceptedFileTypes]);return f("div",{className:"FileField__Empty",children:[f("div",{className:"FileField__Empty__Label",children:[f(En.UploadButton,{}),tk(t.acceptedFileTypes)&&f("div",{children:f(we,{label:"Create placeholder image",children:f(Ae,{className:"FileField__Empty__Label__PlaceholderButton",onClick:()=>{t.requestPlaceholderModalOpen()},title:"Create placeholder image",children:f(Kh,{size:16})})})})]}),t.allowEditing&&t.assetPickerEnabled&&f("div",{className:"FileField__Empty__AssetLibrary",children:["or select from"," ",f("button",{type:"button",className:"FileField__Empty__AssetLibrary__link",onClick:()=>t.requestAssetPicker(),children:"asset library"})]}),e&&f("div",{children:f("div",{className:"FileField__Empty__AcceptTypes",children:["Allowed file types: ",e]})})]})};En.Dropzone=po((t,e)=>{let[n,o]=L(!1),r=uc();return f("button",{ref:e,className:xe("FileField__Dropzone",n&&"dragging"),onDblClick:()=>{r?.requestFileUpload()},onCopy:i=>{r.value?.src&&(i.preventDefault(),i.clipboardData?.setData("text/plain",r.value.src),i.clipboardData?.setData("application/json",JSON.stringify(r.value)))},onKeyDown:i=>{((i.metaKey||i.ctrlKey)&&i.key==="Backspace"||i.key==="Delete")&&(i.preventDefault(),r.value?.src&&r.removeFile())},onDragOver:i=>{i.preventDefault(),o(!0)},onDragLeave:i=>{i.preventDefault(),o(!1)},onDrop:i=>{i.preventDefault(),o(!1);let s=i.dataTransfer?.files[0];s&&r&&r.handleFile(s)},onPaste:i=>{if(i.preventDefault(),!r)return;let s=i.clipboardData?.getData("application/json");if(s)try{let c=JSON.parse(s);if(c&&c.src&&c.filename&&r){console.log("Parsed JSON file:",c),r.setValue(c);return}}catch(c){console.error("error parsing json",c)}let a=i.clipboardData?.files[0];if(a){r.handleFile(a);return}let l=i.clipboardData?.getData("text/plain");if(l){if(Hu(l)){r.handleFile(l);return}if(nk(l)){r.handleFile(l,{as:"svg"});return}}},title:"Drop or paste to upload a file"})});var Z4=po(t=>{let{label:e,description:n,...o}=t;return f("div",{className:"FileField__NamingModeItem",...o,children:[f(Bt,{size:"sm",weight:500,children:e}),f(Bt,{size:"xs",color:"dimmed",children:n})]})});function ek(t){return t?Cr(t)||Ml(t):!1}function tk(t){return t.some(e=>e.startsWith("image/"))||t.length===0}function Q4(t){let e={};if(t.width&&t.height){e["--canvas-aspect-ratio"]=`${t.width} / ${t.height}`,e["--canvas-asset-width"]=`${t.width}px`;let n=Math.min(t.height,280);n<80&&(n=80),e["--canvas-max-height"]=`${n}px`}return t.canvasBgColor==="dark"&&(e["--canvas-bg-color"]="#000"),e}function e5(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}function nk(t){return/^(?:\uFEFF)?\s*(?:<!--[\s\S]*?-->\s*)*(?:<\?xml[\s\S]*?\?>\s*)?(?:<!DOCTYPE\s+svg[\s\S]*?>\s*)?<svg\b[^>]*?(?:\/>|>[\s\S]*?<\/svg>)\s*$/.test(t)}function ok(t){return f(En,{...t,variant:"image"})}ke();async function Uu(t){return t&&t.doc?t5(t):[]}async function t5(t){if(!t.doc||!t.field)return[];let e=await Qi(t.doc);if(!e)return[];let n=e.fields||{},o=n5(yn(n,t.field)),r=[],i=new Set;for(let s of o){let a,l,c;if(s&&typeof s=="object"?(a=t.valueKey?yn(s,t.valueKey):void 0,l=t.labelKey?yn(s,t.labelKey):void 0,c=t.helpKey?yn(s,t.helpKey):void 0):a=s,a==null||a==="")continue;let d=String(a);if(i.has(d))continue;i.add(d);let u=l==null||l===""?d:String(l),p=c==null||c===""?void 0:String(c);r.push(p?{value:d,label:u,description:p}:{value:d,label:u})}return r}function n5(t){return Array.isArray(t)?t:t&&typeof t=="object"&&Array.isArray(t._array)?t._array.map(e=>t[e]).filter(e=>e!=null):[]}yr();var Ku=po(t=>{let{label:e,description:n,...o}=t;return f("div",{...o,children:[f(Bt,{size:"sm",children:e}),n&&f(Bt,{size:"xs",color:"dimmed",children:n})]})});function ju(t){let e=t.source;if(!e||!e.doc)return null;let n=`Open ${e.doc}`,o=`/cms/content/${e.doc}`;if(e.field){let r=`fields.${e.field}`;o+=`?deeplink=${encodeURIComponent(r)}`}return f(we,{label:n,position:"top",withArrow:!0,children:f(Ae,{component:"a",href:o,target:"_blank",rel:"noopener noreferrer","aria-label":n,children:f(Do,{size:16})})})}function rk(t){let e=t.field,[n,o]=At(t.deepKey,[]),[r,i]=L([]),[s,a]=L([]),[l,c]=L(!!e.source);F(()=>{if(!e.source)return;let h=!0;return c(!0),Uu(e.source).then(g=>{h&&i(g)}).catch(g=>{console.error("failed to resolve field source:",g)}).finally(()=>{h&&c(!1)}),()=>{h=!1}},[e.source]);let d=X(()=>(e.options||[]).map(h=>typeof h=="string"?{label:h,value:h}:{label:h.label??h.value??"",value:h.value??h.label??""}),[e.options]),u=X(()=>{let h=new Map,g=e.source?r:d;for(let m of g)h.set(m.value,m);for(let m of s)h.has(m.value)||h.set(m.value,m);for(let m of n||[])m&&!h.has(m)&&h.set(m,{value:m,label:m});return Array.from(h.values())},[e.source,r,d,s,n]),p=f(MC,{data:u,size:"xs",radius:0,placeholder:e.placeholder,value:n,searchable:!0,creatable:e.creatable||!1,getCreateLabel:h=>`+ Add "${h}"`,onCreate:h=>{let g={value:h,label:h};return a(m=>[...m,g]),g},onChange:h=>o(h),itemComponent:e.source?.helpKey?Ku:void 0,nothingFound:l?"Loading\u2026":void 0,rightSection:l?f(xt,{size:"xs"}):void 0,dropdownComponent:"div"});return e.source?.doc?f("div",{className:"DocEditor__MultiSelectField",style:{display:"flex",alignItems:"center",gap:8},children:[f("div",{style:{flex:1,minWidth:0},children:p}),f(ju,{source:e.source})]}):f("div",{className:"DocEditor__MultiSelectField",children:p})}function ik(t){let[e,n]=At(t.deepKey,0);return f(LC,{size:"xs",radius:0,value:e,onChange:o=>n(o),hideControls:!0})}ke();var sk="ReferenceFieldEditorModal";function Vu(){let t=St(),e=ot();return{open:n=>{t.openContextModal(sk,{...e,className:"ReferenceFieldEditorModalWrap",innerProps:n,title:`Edit ${n.docId}`,size:"xl",overflow:"inside",closeOnClickOutside:!1,closeOnEscape:!1})}}}function Om(t){let{id:e,context:n,innerProps:o}=t,r=o.docId;return f("div",{className:"ReferenceFieldEditorModal",children:f(e0,{docId:r,autoSave:!1,flushOnStop:!1,children:[f(Ie,{className:"ReferenceFieldEditorModal__DocEditor",docId:o.docId,hideStatusBar:!0}),f(Om.Footer,{docId:r,onCancel:()=>n.closeModal(e)})]})})}Om.Footer=t=>{let e=sn();return f("div",{className:"ReferenceFieldEditorModal__footer",children:[f("div",{className:"ReferenceFieldEditorModal__footer__start",children:f(Z,{component:"a",variant:"default",size:"xs",rightIcon:f(ia,{size:16}),href:`/cms/content/${t.docId}`,target:"_blank",children:["Open ",t.docId]})}),f(Z,{variant:"default",size:"xs",onClick:t.onCancel,children:"Cancel"}),f(Z,{color:"dark",size:"xs",onClick:async()=>{await e.controller.flush(),t.onCancel()},children:"Save"})]})};Om.id=sk;function va(t){let e=t.field,[n,o]=At(t.deepKey),r=n?.id||"";function i(c){o(c?zd(c):null)}let s=lu(),a=Vu();function l(){let c=r?zd(r).collection:e.initialCollection;s.open({collections:e.collections,initialCollection:c,onChange:d=>{i(d),s.close()}})}return f("div",{className:"ReferenceField",children:[r?f("div",{className:"ReferenceField__ref",children:[f(va.Preview,{id:r}),f("div",{className:"ReferenceField__remove",children:[f(we,{label:"Quick edit",children:f(Ae,{className:"ReferenceField__remove__icon",onClick:()=>a.open({docId:r}),children:f(Zd,{size:16})})}),f(we,{label:"Remove",children:f(Ae,{className:"ReferenceField__remove__icon",onClick:()=>o(null),children:f(Zn,{size:16})})})]})]}):f("div",{className:"ReferenceField__none",children:"None selected"}),f(Z,{color:"dark",size:"xs",onClick:()=>l(),children:e.buttonLabel||"Select"})]})}va.Preview=t=>{let[e,n]=L(!0),[o,r]=L(null);async function i(){n(!0),await vr(async()=>{let s=await Qi(t.id);r(s)}),n(!1)}return F(()=>{i()},[t.id]),f("div",{className:"ReferenceField__Preview",children:e?f("div",{className:"ReferenceField__Preview__loading",children:f(xt,{color:"gray",size:"sm"})}):o?f(va.DocCard,{doc:o}):f("div",{className:"ReferenceField__Preview__notfound",children:["Doc not found: ",f("b",{children:t.id})," (was it deleted?). Select a new doc or remove using the trash icon to the right."]})})};va.DocCard=t=>{let e=t.doc,n=e.id||e.sys?.id||"";if(!n)return f("div",{className:"ReferenceField__DocCard ReferenceField__DocCard--error",children:JSON.stringify(e)});let o=zd(n).collection,r=e.fields||{},i=window.__ROOT_CTX.collections[o];if(!i)throw new Error(`could not find collection: ${o}`);let s=yn(r,i.preview?.title||"meta.title"),a=yn(r,i.preview?.image||"meta.image")||i.preview?.defaultImage;return f("a",{className:"ReferenceField__DocCard",href:`/cms/content/${n}`,target:"_blank",children:[f("div",{className:"ReferenceField__DocCard__image",children:f(ea,{src:a?.src,width:80,height:60,withPlaceholder:!a?.src})}),f("div",{className:"ReferenceField__DocCard__content",children:[f("div",{className:"ReferenceField__DocCard__content__header",children:f("div",{className:"ReferenceField__DocCard__content__header__docId",children:n})}),f("div",{className:"ReferenceField__DocCard__content__title",children:s||"[UNTITLED]"})]})]})};ke();function ak(t){let e=t.field,[n,o]=L([]),r=sn().controller;function i(d){if(d.length){let u=d.map(p=>{let[h,g]=p.split("/");return{id:p,collection:h,slug:g}});r.updateKey(t.deepKey,u)}else r.removeKey(t.deepKey);o(d)}Xo(t.deepKey,d=>{Array.isArray(d)?o(d.map(u=>u.id)):o([])});let s=lu(),a=Vu();function l(){s.open({collections:e.collections,initialCollection:e.initialCollection,multiSelect:!0,selectedDocIds:n,onChangeMulti:(d,u)=>{o(p=>{let h=[...p];if(u)h.includes(d)||h.push(d);else{let g=h.indexOf(d);g>-1&&h.splice(g,1)}return i(h),h})}})}function c(d){let u=n.filter(p=>p!==d);i(u)}return f("div",{className:"ReferencesField",children:[n.length>0?f(Ou,{onDragEnd:d=>{let{destination:u,source:p}=d;if(!u||u.index===p.index)return;let h=[...n],[g]=h.splice(p.index,1);h.splice(u.index,0,g),i(h)},children:f(Au,{droppableId:"ReferencesField__droppable",direction:"vertical",children:d=>f("div",{ref:d.innerRef,...d.droppableProps,className:"ReferencesField__refs",children:[n.map((u,p)=>f(Iu,{draggableId:u,index:p,children:(h,g)=>f("div",{ref:h.innerRef,...h.draggableProps,className:xe("ReferencesField__card",g.isDragging&&"ReferencesField__card--dragging"),children:[f("div",{className:"ReferencesField__card__handle",...h.dragHandleProps,children:f(Yd,{size:16,stroke:"1.5"})}),f(Ud,{className:"ReferencesField__card__preview",docId:u,variant:"compact",clickable:!0,statusBadges:!0}),f("div",{className:"ReferencesField__card__controls",children:[f(we,{label:"Quick edit",children:f(Ae,{onClick:()=>a.open({docId:u}),children:f(Zd,{size:16})})}),f(we,{label:"Remove",children:f(Ae,{className:"ReferencesField__card__controls__remove",onClick:()=>c(u),children:f(Zn,{size:16})})})]})]})},u)),d.placeholder]})})}):f("div",{className:"ReferencesField__none",children:"None selected"}),f(Z,{color:"dark",size:"xs",onClick:()=>l(),children:e.buttonLabel||"Select"})]})}ke();(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-hint--align-start{text-align:left}.ce-hint--align-center{text-align:center}.ce-hint__description{opacity:.6;margin-top:3px}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var bc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function o5(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function o(){return this instanceof o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return t[o]}})}),n}function Im(){}Object.assign(Im,{default:Im,register:Im,revert:function(){},__esModule:!0});Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){let e=(this.document||this.ownerDocument).querySelectorAll(t),n=e.length;for(;--n>=0&&e.item(n)!==this;);return n>-1});Element.prototype.closest||(Element.prototype.closest=function(t){let e=this;if(!document.documentElement.contains(e))return null;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(e!==null);return null});Element.prototype.prepend||(Element.prototype.prepend=function(t){let e=document.createDocumentFragment();Array.isArray(t)||(t=[t]),t.forEach(n=>{let o=n instanceof Node;e.appendChild(o?n:document.createTextNode(n))}),this.insertBefore(e,this.firstChild)});Element.prototype.scrollIntoViewIfNeeded||(Element.prototype.scrollIntoViewIfNeeded=function(t){t=arguments.length===0?!0:!!t;let e=this.parentNode,n=window.getComputedStyle(e,null),o=parseInt(n.getPropertyValue("border-top-width")),r=parseInt(n.getPropertyValue("border-left-width")),i=this.offsetTop-e.offsetTop<e.scrollTop,s=this.offsetTop-e.offsetTop+this.clientHeight-o>e.scrollTop+e.clientHeight,a=this.offsetLeft-e.offsetLeft<e.scrollLeft,l=this.offsetLeft-e.offsetLeft+this.clientWidth-r>e.scrollLeft+e.clientWidth,c=i&&!s;(i||s)&&t&&(e.scrollTop=this.offsetTop-e.offsetTop-e.clientHeight/2-o+this.clientHeight/2),(a||l)&&t&&(e.scrollLeft=this.offsetLeft-e.offsetLeft-e.clientWidth/2-r+this.clientWidth/2),(i||s||a||l)&&!t&&this.scrollIntoView(c)});window.requestIdleCallback=window.requestIdleCallback||function(t){let e=Date.now();return setTimeout(function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})},1)};window.cancelIdleCallback=window.cancelIdleCallback||function(t){clearTimeout(t)};var r5=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,n)=>(n&=63,n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n>62?e+="-":e+="_",e),""),vk=(t=>(t.VERBOSE="VERBOSE",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t))(vk||{}),Te={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},i5={LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4};function Sc(t,e,n="log",o,r="color: inherit"){if(!("console"in window)||!window.console[n])return;let i=["info","log","warn","error"].includes(n),s=[];switch(Sc.logLevel){case"ERROR":if(n!=="error")return;break;case"WARN":if(!["error","warn"].includes(n))return;break;case"INFO":if(!i||t)return;break}o&&s.push(o);let a="Editor.js 2.31.0-rc.7";t&&(i?(s.unshift(`line-height: 1em;
|
|
82
|
+
`),o=o.replace(/<[^>]+>/g,"").replace(/ /g," ");let r=o.split(/\r?\n/)[0].trim();if(r)return r}}function ls(t,e,n={}){if(e==null)return!0;switch(t.type){case"string":case"select":case"date":case"datetime":return e==="";case"multiselect":return!Array.isArray(e)||e.length===0;case"number":case"boolean":return e==null;case"image":case"file":return!e||!e.src;case"reference":return!e||!e.id;case"references":return!Array.isArray(e)||e.length===0;case"richtext":return!Bd(e);case"object":if(!Pn(e)||Object.keys(e).length===0)return!0;for(let o of t.fields||[])if(o.id&&!ls(o,e[o.id],n))return!1;return!0;case"array":if(Array.isArray(e)){if(e.length===0)return!0;for(let o of e)if(!ls(t.of,o,n))return!1;return!0}if(!Pn(e)||!Array.isArray(e._array)||e._array.length===0)return!0;for(let o of e._array)if(!ls(t.of,e[o],n))return!1;return!0;case"oneof":{if(!Pn(e)||!e._type)return!0;let o,r=t.types||[];if(typeof r[0]=="string"?r.includes(e._type)&&(o=n[e._type]):o=r.find(i=>i.name===e._type),!o)return!0;for(let i of o.fields||[])if(i.id&&!ls(i,e[i.id],n))return!1;return!0}default:return!1}}br();var Lu=class extends Td{constructor(){super(...arguments);this.state={error:null}}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n){console.error(`Error rendering field${this.props.deepKey?` "${this.props.deepKey}"`:""}:`,n)}render(){if(this.state.error){let n=this.state.error instanceof Error?this.state.error.message:String(this.state.error);return f("div",{className:"FieldErrorBoundary",children:[f("div",{className:"FieldErrorBoundary__icon",children:f(Pl,{size:16})}),f("div",{className:"FieldErrorBoundary__body",children:[f("div",{className:"FieldErrorBoundary__title",children:"This field failed to render."}),f("div",{className:"FieldErrorBoundary__message",children:n})]})]})}return this.props.children}};ke();function iS(t,e){let n=!1;return(...o)=>{n||(t(...o),n=!0,setTimeout(()=>{n=!1},e))}}var cc=class extends mo{constructor(n){super();this.interval=0;this.timeout=0;this.interval=n}start(){this.timeout=window.setTimeout(()=>{this.tick()},this.interval)}tick(){this.dispatch("tick"),this.start()}reset(){this.stop(),this.start()}stop(){this.timeout&&(window.clearTimeout(this.timeout),this.timeout=0)}};var MH=60*Zi.second,sS=5*Zi.minute,pm=class extends mo{constructor(n){super();this.started=!1;this.timer=new cc(MH);this.idleTimer=new cc(sS);this.onUserInteraction=iS(()=>{this.idleTimer.reset()},5e3);this.id=n;let o=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db;this.docRef=Ad(r,"Projects",o,"Viewers",n),this.timer.on("tick",()=>this.onTick()),this.idleTimer.on("tick",()=>this.onIdle()),window.addEventListener("mousemove",this.onUserInteraction),window.addEventListener("keypress",this.onUserInteraction)}async start(){this.started||(this.started=!0,this.dbUnsubscribe=Ld(this.docRef,n=>{let o=n.data();this.onData(o)}),this.onTick(),this.timer.start())}onData(n){let o=window.firebase.user,r=Id.now(),i=Object.values(n).filter(s=>!(s.email===o.email||r.toMillis()-s.lastViewedAt.toMillis()>sS));this.dispatch("change",i)}async onTick(){let n=window.firebase.user;if(!n.email){console.log("no user email:",n);return}await FC(this.docRef,{[n.email]:{email:n.email,photoURL:n.photoURL,lastViewedAt:ta()}},{merge:!0})}async onIdle(){this.stop()}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.timer.stop(),this.idleTimer.stop(),this.onDisconnect(),this.started=!1)}async onDisconnect(){let n=window.firebase.user;if(!n.email){console.log("no user email:",n);return}let o=new PC(n.email,"disconnectedAt");await Md(this.docRef,o,ta())}async dispose(){super.dispose(),this.stop(),this.timer.dispose(),this.idleTimer.dispose()}};function aS(t){let e=$C(t.id),[n,o]=L([]);if(F(()=>{let l=new pm(e);l.on("change",d=>o(d)),l.start();let c=()=>{document.hidden||document.visibilityState!=="visible"?l.stop():l.started||l.start()};return document.addEventListener("visibilitychange",c),()=>{l.dispose(),document.removeEventListener("visibilitychange",c)}},[e]),n.length===0)return null;function r(l){return l.disconnectedAt?l.disconnectedAt>l.lastViewedAt:!1}let i=t.max||3,s=n.slice(0,i),a=n.length-i;return f("div",{className:"Viewers",children:[s.map(l=>f(ow,{email:l.email,size:30,inactive:r(l),className:"Viewers__avatar"},l.email)),a>0&&f(OC,{className:"Viewers__avatar",size:30,radius:"xl",children:["+",a]})]})}function lS(t){let n=t.field.checkboxLabel||"Enabled",[o,r]=At(t.deepKey,!1);return f("div",{className:"DocEditor__BooleanField",children:f(fo,{label:n,onChange:i=>{let s=i.currentTarget;r(s.checked)},checked:o,size:"xs"})})}ke();function cS(t){let[e,n]=At(t.deepKey),[o,r]=L(null),i=(s,a)=>{if(a&&!a.valid){r("Invalid date");return}if(s){let l=new Date(s);if(isNaN(l.getTime())){r("Invalid date");return}r(null),n(s)}else r(null),n(null)};return f("div",{className:"DocEditor__DateField",children:[f("input",{type:"date",value:e||"",onChange:s=>{let a=s.currentTarget;i(a.value,a.validity)}}),o&&f("div",{style:{color:"red",fontSize:"12px",marginTop:"4px"},children:o})]})}var LH={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},dS=(t,e,n)=>{let o,r=LH[t];return typeof r=="string"?o=r:e===1?o=r.one:o=r.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+o:o+" ago":o};function Ru(t){return(e={})=>{let n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}var RH={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},PH={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},FH={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},uS={date:Ru({formats:RH,defaultWidth:"full"}),time:Ru({formats:PH,defaultWidth:"full"}),dateTime:Ru({formats:FH,defaultWidth:"full"})};var BH={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pS=(t,e,n,o)=>BH[t];function _a(t){return(e,n)=>{let o=n?.context?String(n.context):"standalone",r;if(o==="formatting"&&t.formattingValues){let s=t.defaultFormattingWidth||t.defaultWidth,a=n?.width?String(n.width):s;r=t.formattingValues[a]||t.formattingValues[s]}else{let s=t.defaultWidth,a=n?.width?String(n.width):t.defaultWidth;r=t.values[a]||t.values[s]}let i=t.argumentCallback?t.argumentCallback(e):e;return r[i]}}var $H={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zH={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},HH={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},UH={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},KH={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},jH={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},VH=(t,e)=>{let n=Number(t),o=n%100;if(o>20||o<10)switch(o%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},fS={ordinalNumber:VH,era:_a({values:$H,defaultWidth:"wide"}),quarter:_a({values:zH,defaultWidth:"wide",argumentCallback:t=>t-1}),month:_a({values:HH,defaultWidth:"wide"}),day:_a({values:UH,defaultWidth:"wide"}),dayPeriod:_a({values:KH,defaultWidth:"wide",formattingValues:jH,defaultFormattingWidth:"wide"})};function ba(t){return(e,n={})=>{let o=n.width,r=o&&t.matchPatterns[o]||t.matchPatterns[t.defaultMatchWidth],i=e.match(r);if(!i)return null;let s=i[0],a=o&&t.parsePatterns[o]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(a)?GH(a,u=>u.test(s)):WH(a,u=>u.test(s)),c;c=t.valueCallback?t.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;let d=e.slice(s.length);return{value:c,rest:d}}}function WH(t,e){for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function GH(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function hS(t){return(e,n={})=>{let o=e.match(t.matchPattern);if(!o)return null;let r=o[0],i=e.match(t.parsePattern);if(!i)return null;let s=t.valueCallback?t.valueCallback(i[0]):i[0];s=n.valueCallback?n.valueCallback(s):s;let a=e.slice(r.length);return{value:s,rest:a}}}var YH=/^(\d+)(th|st|nd|rd)?/i,qH=/\d+/i,JH={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},XH={any:[/^b/i,/^(a|c)/i]},ZH={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},QH={any:[/1/i,/2/i,/3/i,/4/i]},e4={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},t4={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},n4={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},o4={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},r4={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},i4={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},gS={ordinalNumber:hS({matchPattern:YH,parsePattern:qH,valueCallback:t=>parseInt(t,10)}),era:ba({matchPatterns:JH,defaultMatchWidth:"wide",parsePatterns:XH,defaultParseWidth:"any"}),quarter:ba({matchPatterns:ZH,defaultMatchWidth:"wide",parsePatterns:QH,defaultParseWidth:"any",valueCallback:t=>t+1}),month:ba({matchPatterns:e4,defaultMatchWidth:"wide",parsePatterns:t4,defaultParseWidth:"any"}),day:ba({matchPatterns:n4,defaultMatchWidth:"wide",parsePatterns:o4,defaultParseWidth:"any"}),dayPeriod:ba({matchPatterns:r4,defaultMatchWidth:"any",parsePatterns:i4,defaultParseWidth:"any"})};var fm={code:"en-US",formatDistance:dS,formatLong:uS,formatRelative:pS,localize:fS,match:gS,options:{weekStartsOn:0,firstWeekContainsDate:1}};var s4={};function Zo(){return s4}var a4=Math.pow(10,8)*24*60*60*1e3,MX=-a4,Pu=6048e5,mS=864e5;var l4=3600;var _S=l4*24,LX=_S*7,c4=_S*365.2425,d4=c4/12,RX=d4*3,hm=Symbol.for("constructDateFrom");function Fn(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&hm in t?t[hm](e):t instanceof Date?new t.constructor(e):new Date(e)}function vt(t,e){return Fn(e||t,t)}function gm(t){let e=vt(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function bS(t,...e){let n=Fn.bind(null,t||e.find(o=>typeof o=="object"));return e.map(n)}function mm(t,e){let n=vt(t,e?.in);return n.setHours(0,0,0,0),n}function yS(t,e,n){let[o,r]=bS(n?.in,t,e),i=mm(o),s=mm(r),a=+i-gm(i),l=+s-gm(s);return Math.round((a-l)/mS)}function xS(t,e){let n=vt(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function vS(t,e){let n=vt(t,e?.in);return yS(n,xS(n))+1}function Tr(t,e){let n=Zo(),o=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=vt(t,e?.in),i=r.getDay(),s=(i<o?7:0)+i-o;return r.setDate(r.getDate()-s),r.setHours(0,0,0,0),r}function cs(t,e){return Tr(t,{...e,weekStartsOn:1})}function Fu(t,e){let n=vt(t,e?.in),o=n.getFullYear(),r=Fn(n,0);r.setFullYear(o+1,0,4),r.setHours(0,0,0,0);let i=cs(r),s=Fn(n,0);s.setFullYear(o,0,4),s.setHours(0,0,0,0);let a=cs(s);return n.getTime()>=i.getTime()?o+1:n.getTime()>=a.getTime()?o:o-1}function CS(t,e){let n=Fu(t,e),o=Fn(e?.in||t,0);return o.setFullYear(n,0,4),o.setHours(0,0,0,0),cs(o)}function ES(t,e){let n=vt(t,e?.in),o=+cs(n)-+CS(n);return Math.round(o/Pu)+1}function Bu(t,e){let n=vt(t,e?.in),o=n.getFullYear(),r=Zo(),i=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=Fn(e?.in||t,0);s.setFullYear(o+1,0,i),s.setHours(0,0,0,0);let a=Tr(s,e),l=Fn(e?.in||t,0);l.setFullYear(o,0,i),l.setHours(0,0,0,0);let c=Tr(l,e);return+n>=+a?o+1:+n>=+c?o:o-1}function wS(t,e){let n=Zo(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=Bu(t,e),i=Fn(e?.in||t,0);return i.setFullYear(r,0,o),i.setHours(0,0,0,0),Tr(i,e)}function TS(t,e){let n=vt(t,e?.in),o=+Tr(n,e)-+wS(n,e);return Math.round(o/Pu)+1}function Ue(t,e){let n=t<0?"-":"",o=Math.abs(t).toString().padStart(e,"0");return n+o}var Sr={y(t,e){let n=t.getFullYear(),o=n>0?n:1-n;return Ue(e==="yy"?o%100:o,e.length)},M(t,e){let n=t.getMonth();return e==="M"?String(n+1):Ue(n+1,2)},d(t,e){return Ue(t.getDate(),e.length)},a(t,e){let n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Ue(t.getHours()%12||12,e.length)},H(t,e){return Ue(t.getHours(),e.length)},m(t,e){return Ue(t.getMinutes(),e.length)},s(t,e){return Ue(t.getSeconds(),e.length)},S(t,e){let n=e.length,o=t.getMilliseconds(),r=Math.trunc(o*Math.pow(10,n-3));return Ue(r,e.length)}};var ya={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},_m={G:function(t,e,n){let o=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(o,{width:"abbreviated"});case"GGGGG":return n.era(o,{width:"narrow"});default:return n.era(o,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){let o=t.getFullYear(),r=o>0?o:1-o;return n.ordinalNumber(r,{unit:"year"})}return Sr.y(t,e)},Y:function(t,e,n,o){let r=Bu(t,o),i=r>0?r:1-r;if(e==="YY"){let s=i%100;return Ue(s,2)}return e==="Yo"?n.ordinalNumber(i,{unit:"year"}):Ue(i,e.length)},R:function(t,e){let n=Fu(t);return Ue(n,e.length)},u:function(t,e){let n=t.getFullYear();return Ue(n,e.length)},Q:function(t,e,n){let o=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(o);case"QQ":return Ue(o,2);case"Qo":return n.ordinalNumber(o,{unit:"quarter"});case"QQQ":return n.quarter(o,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(o,{width:"narrow",context:"formatting"});default:return n.quarter(o,{width:"wide",context:"formatting"})}},q:function(t,e,n){let o=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(o);case"qq":return Ue(o,2);case"qo":return n.ordinalNumber(o,{unit:"quarter"});case"qqq":return n.quarter(o,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(o,{width:"narrow",context:"standalone"});default:return n.quarter(o,{width:"wide",context:"standalone"})}},M:function(t,e,n){let o=t.getMonth();switch(e){case"M":case"MM":return Sr.M(t,e);case"Mo":return n.ordinalNumber(o+1,{unit:"month"});case"MMM":return n.month(o,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(o,{width:"narrow",context:"formatting"});default:return n.month(o,{width:"wide",context:"formatting"})}},L:function(t,e,n){let o=t.getMonth();switch(e){case"L":return String(o+1);case"LL":return Ue(o+1,2);case"Lo":return n.ordinalNumber(o+1,{unit:"month"});case"LLL":return n.month(o,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(o,{width:"narrow",context:"standalone"});default:return n.month(o,{width:"wide",context:"standalone"})}},w:function(t,e,n,o){let r=TS(t,o);return e==="wo"?n.ordinalNumber(r,{unit:"week"}):Ue(r,e.length)},I:function(t,e,n){let o=ES(t);return e==="Io"?n.ordinalNumber(o,{unit:"week"}):Ue(o,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Sr.d(t,e)},D:function(t,e,n){let o=vS(t);return e==="Do"?n.ordinalNumber(o,{unit:"dayOfYear"}):Ue(o,e.length)},E:function(t,e,n){let o=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(o,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(o,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},e:function(t,e,n,o){let r=t.getDay(),i=(r-o.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return Ue(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},c:function(t,e,n,o){let r=t.getDay(),i=(r-o.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return Ue(i,e.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(r,{width:"narrow",context:"standalone"});case"cccccc":return n.day(r,{width:"short",context:"standalone"});default:return n.day(r,{width:"wide",context:"standalone"})}},i:function(t,e,n){let o=t.getDay(),r=o===0?7:o;switch(e){case"i":return String(r);case"ii":return Ue(r,e.length);case"io":return n.ordinalNumber(r,{unit:"day"});case"iii":return n.day(o,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(o,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},a:function(t,e,n){let r=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(t,e,n){let o=t.getHours(),r;switch(o===12?r=ya.noon:o===0?r=ya.midnight:r=o/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(t,e,n){let o=t.getHours(),r;switch(o>=17?r=ya.evening:o>=12?r=ya.afternoon:o>=4?r=ya.morning:r=ya.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let o=t.getHours()%12;return o===0&&(o=12),n.ordinalNumber(o,{unit:"hour"})}return Sr.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Sr.H(t,e)},K:function(t,e,n){let o=t.getHours()%12;return e==="Ko"?n.ordinalNumber(o,{unit:"hour"}):Ue(o,e.length)},k:function(t,e,n){let o=t.getHours();return o===0&&(o=24),e==="ko"?n.ordinalNumber(o,{unit:"hour"}):Ue(o,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Sr.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Sr.s(t,e)},S:function(t,e){return Sr.S(t,e)},X:function(t,e,n){let o=t.getTimezoneOffset();if(o===0)return"Z";switch(e){case"X":return kS(o);case"XXXX":case"XX":return ds(o);default:return ds(o,":")}},x:function(t,e,n){let o=t.getTimezoneOffset();switch(e){case"x":return kS(o);case"xxxx":case"xx":return ds(o);default:return ds(o,":")}},O:function(t,e,n){let o=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+SS(o,":");default:return"GMT"+ds(o,":")}},z:function(t,e,n){let o=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+SS(o,":");default:return"GMT"+ds(o,":")}},t:function(t,e,n){let o=Math.trunc(+t/1e3);return Ue(o,e.length)},T:function(t,e,n){return Ue(+t,e.length)}};function SS(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=Math.trunc(o/60),i=o%60;return i===0?n+String(r):n+String(r)+e+Ue(i,2)}function kS(t,e){return t%60===0?(t>0?"-":"+")+Ue(Math.abs(t)/60,2):ds(t,e)}function ds(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=Ue(Math.trunc(o/60),2),i=Ue(o%60,2);return n+r+e+i}var NS=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},DS=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},u4=(t,e)=>{let n=t.match(/(P+)(p+)?/)||[],o=n[1],r=n[2];if(!r)return NS(t,e);let i;switch(o){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",NS(o,e)).replace("{{time}}",DS(r,e))},OS={p:DS,P:u4};var p4=/^D+$/,f4=/^Y+$/,h4=["D","DD","YY","YYYY"];function IS(t){return p4.test(t)}function AS(t){return f4.test(t)}function MS(t,e,n){let o=g4(t,e,n);if(console.warn(o),h4.includes(t))throw new RangeError(o)}function g4(t,e,n){let o=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${o} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}function LS(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function RS(t){return!(!LS(t)&&typeof t!="number"||isNaN(+vt(t)))}var m4=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,_4=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,b4=/^'([^]*?)'?$/,y4=/''/g,x4=/[a-zA-Z]/;function PS(t,e,n){let o=Zo(),r=n?.locale??o.locale??fm,i=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0,a=vt(t,n?.in);if(!RS(a))throw new RangeError("Invalid time value");let l=e.match(_4).map(d=>{let u=d[0];if(u==="p"||u==="P"){let p=OS[u];return p(d,r.formatLong)}return d}).join("").match(m4).map(d=>{if(d==="''")return{isToken:!1,value:"'"};let u=d[0];if(u==="'")return{isToken:!1,value:v4(d)};if(_m[u])return{isToken:!0,value:d};if(u.match(x4))throw new RangeError("Format string contains an unescaped latin alphabet character `"+u+"`");return{isToken:!1,value:d}});r.localize.preprocessor&&(l=r.localize.preprocessor(a,l));let c={firstWeekContainsDate:i,weekStartsOn:s,locale:r};return l.map(d=>{if(!d.isToken)return d.value;let u=d.value;(!n?.useAdditionalWeekYearTokens&&AS(u)||!n?.useAdditionalDayOfYearTokens&&IS(u))&&MS(u,e,String(t));let p=_m[u[0]];return p(a,u,r.localize,c)}).join("")}function v4(t){let e=t.match(b4);return e?e[1].replace(y4,"'"):t}function FS(){return Object.assign({},Zo())}function bm(t,e,n){let o=FS(),r=w4(t,n.timeZone,n.locale??o.locale);return"formatToParts"in r?C4(r,e):E4(r,e)}function C4(t,e){let n=t.formatToParts(e);for(let o=n.length-1;o>=0;--o)if(n[o].type==="timeZoneName")return n[o].value}function E4(t,e){let n=t.format(e).replace(/\u200E/g,""),o=/ [\w-+ ]+$/.exec(n);return o?o[0].substr(1):""}function w4(t,e,n){return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:e,timeZoneName:t})}function $S(t,e){let n=D4(e);return"formatToParts"in n?S4(n,t):k4(n,t)}var T4={year:0,month:1,day:2,hour:3,minute:4,second:5};function S4(t,e){try{let n=t.formatToParts(e),o=[];for(let r=0;r<n.length;r++){let i=T4[n[r].type];i!==void 0&&(o[i]=parseInt(n[r].value,10))}return o}catch(n){if(n instanceof RangeError)return[NaN];throw n}}function k4(t,e){let n=t.format(e),o=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[parseInt(o[3],10),parseInt(o[1],10),parseInt(o[2],10),parseInt(o[4],10),parseInt(o[5],10),parseInt(o[6],10)]}var ym={},BS=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),N4=BS==="06/25/2014, 00:00:00"||BS==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";function D4(t){return ym[t]||(ym[t]=N4?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:t,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),ym[t]}function dc(t,e,n,o,r,i,s){let a=new Date(0);return a.setUTCFullYear(t,e,n),a.setUTCHours(o,r,i,s),a}var zS=36e5,O4=6e4,xm={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function kr(t,e,n){if(!t)return 0;let o=xm.timezoneZ.exec(t);if(o)return 0;let r,i;if(o=xm.timezoneHH.exec(t),o)return r=parseInt(o[1],10),HS(r)?-(r*zS):NaN;if(o=xm.timezoneHHMM.exec(t),o){r=parseInt(o[2],10);let s=parseInt(o[3],10);return HS(r,s)?(i=Math.abs(r)*zS+s*O4,o[1]==="+"?-i:i):NaN}if(M4(t)){e=new Date(e||Date.now());let s=n?e:I4(e),a=vm(s,t);return-(n?a:A4(e,a,t))}return NaN}function I4(t){return dc(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}function vm(t,e){let n=$S(t,e),o=dc(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),r=t.getTime(),i=r%1e3;return r-=i>=0?i:1e3+i,o-r}function A4(t,e,n){let r=t.getTime()-e,i=vm(new Date(r),n);if(e===i)return e;r-=i-e;let s=vm(new Date(r),n);return i===s?i:Math.max(i,s)}function HS(t,e){return-23<=t&&t<=23&&(e==null||0<=e&&e<=59)}var US={};function M4(t){if(US[t])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:t}),US[t]=!0,!0}catch{return!1}}var L4=60*1e3,jS={X:function(t,e,n){let o=Cm(n.timeZone,t);if(o===0)return"Z";switch(e){case"X":return KS(o);case"XXXX":case"XX":return xa(o);default:return xa(o,":")}},x:function(t,e,n){let o=Cm(n.timeZone,t);switch(e){case"x":return KS(o);case"xxxx":case"xx":return xa(o);default:return xa(o,":")}},O:function(t,e,n){let o=Cm(n.timeZone,t);switch(e){case"O":case"OO":case"OOO":return"GMT"+R4(o,":");default:return"GMT"+xa(o,":")}},z:function(t,e,n){switch(e){case"z":case"zz":case"zzz":return bm("short",t,n);default:return bm("long",t,n)}}};function Cm(t,e){let n=t?kr(t,e,!0)/L4:e?.getTimezoneOffset()??0;if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+t);return n}function $u(t,e){let n=t<0?"-":"",o=Math.abs(t).toString();for(;o.length<e;)o="0"+o;return n+o}function xa(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=$u(Math.floor(o/60),2),i=$u(Math.floor(o%60),2);return n+r+e+i}function KS(t,e){return t%60===0?(t>0?"-":"+")+$u(Math.abs(t)/60,2):xa(t,e)}function R4(t,e=""){let n=t>0?"-":"+",o=Math.abs(t),r=Math.floor(o/60),i=o%60;return i===0?n+String(r):n+String(r)+e+$u(i,2)}function Em(t){let e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+t-+e}var zu=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/;var wm=36e5,VS=6e4,P4=2,Cn={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:zu};function pi(t,e={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(t===null)return new Date(NaN);let n=e.additionalDigits==null?P4:Number(e.additionalDigits);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]")return new Date(t.getTime());if(typeof t=="number"||Object.prototype.toString.call(t)==="[object Number]")return new Date(t);if(Object.prototype.toString.call(t)!=="[object String]")return new Date(NaN);let o=F4(t),{year:r,restDateString:i}=B4(o.date,n),s=$4(i,r);if(s===null||isNaN(s.getTime()))return new Date(NaN);if(s){let a=s.getTime(),l=0,c;if(o.time&&(l=z4(o.time),l===null||isNaN(l)))return new Date(NaN);if(o.timeZone||e.timeZone){if(c=kr(o.timeZone||e.timeZone,new Date(a+l)),isNaN(c))return new Date(NaN)}else c=Em(new Date(a+l)),c=Em(new Date(a+l+c));return new Date(a+l+c)}else return new Date(NaN)}function F4(t){let e={},n=Cn.dateTimePattern.exec(t),o;if(n?(e.date=n[1],o=n[3]):(n=Cn.datePattern.exec(t),n?(e.date=n[1],o=n[2]):(e.date=null,o=t)),o){let r=Cn.timeZone.exec(o);r?(e.time=o.replace(r[1],""),e.timeZone=r[1].trim()):e.time=o}return e}function B4(t,e){if(t){let n=Cn.YYY[e],o=Cn.YYYYY[e],r=Cn.YYYY.exec(t)||o.exec(t);if(r){let i=r[1];return{year:parseInt(i,10),restDateString:t.slice(i.length)}}if(r=Cn.YY.exec(t)||n.exec(t),r){let i=r[1];return{year:parseInt(i,10)*100,restDateString:t.slice(i.length)}}}return{year:null}}function $4(t,e){if(e===null)return null;let n,o,r;if(!t||!t.length)return n=new Date(0),n.setUTCFullYear(e),n;let i=Cn.MM.exec(t);if(i)return n=new Date(0),o=parseInt(i[1],10)-1,GS(e,o)?(n.setUTCFullYear(e,o),n):new Date(NaN);if(i=Cn.DDD.exec(t),i){n=new Date(0);let s=parseInt(i[1],10);return K4(e,s)?(n.setUTCFullYear(e,0,s),n):new Date(NaN)}if(i=Cn.MMDD.exec(t),i){n=new Date(0),o=parseInt(i[1],10)-1;let s=parseInt(i[2],10);return GS(e,o,s)?(n.setUTCFullYear(e,o,s),n):new Date(NaN)}if(i=Cn.Www.exec(t),i)return r=parseInt(i[1],10)-1,YS(r)?WS(e,r):new Date(NaN);if(i=Cn.WwwD.exec(t),i){r=parseInt(i[1],10)-1;let s=parseInt(i[2],10)-1;return YS(r,s)?WS(e,r,s):new Date(NaN)}return null}function z4(t){let e,n,o=Cn.HH.exec(t);if(o)return e=parseFloat(o[1].replace(",",".")),Tm(e)?e%24*wm:NaN;if(o=Cn.HHMM.exec(t),o)return e=parseInt(o[1],10),n=parseFloat(o[2].replace(",",".")),Tm(e,n)?e%24*wm+n*VS:NaN;if(o=Cn.HHMMSS.exec(t),o){e=parseInt(o[1],10),n=parseInt(o[2],10);let r=parseFloat(o[3].replace(",","."));return Tm(e,n,r)?e%24*wm+n*VS+r*1e3:NaN}return null}function WS(t,e,n){e=e||0,n=n||0;let o=new Date(0);o.setUTCFullYear(t,0,4);let r=o.getUTCDay()||7,i=e*7+n+1-r;return o.setUTCDate(o.getUTCDate()+i),o}var H4=[31,28,31,30,31,30,31,31,30,31,30,31],U4=[31,29,31,30,31,30,31,31,30,31,30,31];function qS(t){return t%400===0||t%4===0&&t%100!==0}function GS(t,e,n){if(e<0||e>11)return!1;if(n!=null){if(n<1)return!1;let o=qS(t);if(o&&n>U4[e]||!o&&n>H4[e])return!1}return!0}function K4(t,e){if(e<1)return!1;let n=qS(t);return!(n&&e>366||!n&&e>365)}function YS(t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function Tm(t,e,n){return!(t<0||t>=25||e!=null&&(e<0||e>=60)||n!=null&&(n<0||n>=60))}var j4=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Sm(t,e,n={}){e=String(e);let o=e.match(j4);if(o){let r=pi(n.originalDate||t,n);e=o.reduce(function(i,s){if(s[0]==="'")return i;let a=i.indexOf(s),l=i[a-1]==="'",c=i.replace(s,"'"+jS[s[0]](r,s,n)+"'");return l?c.substring(0,a-1)+c.substring(a+1):c},e)}return PS(t,e,n)}function km(t,e,n){t=pi(t,n);let o=kr(e,t,!0),r=new Date(t.getTime()-o),i=new Date(0);return i.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),i.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),i}function Nm(t,e,n,o){return o={...o,timeZone:e,originalDate:t},Sm(km(t,e,{timeZone:o.timeZone}),n,o)}function Dm(t,e,n){if(typeof t=="string"&&!t.match(zu))return pi(t,{...n,timeZone:e});t=pi(t,n);let o=dc(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()).getTime(),r=kr(e,new Date(o));return new Date(o+r)}ke();function JS(t){let e=t.field,[n,o]=At(t.deepKey),r=`${V4(t.deepKey)}.timezone`,[i,s]=At(r),a=e.timezone||i||Intl.DateTimeFormat().resolvedOptions().timeZone,l=X(()=>{if(!n)return"";try{return Nm(n.toDate(),a,"yyyy-MM-dd'T'HH:mm")}catch(h){return console.error("Error formatting date:",h),""}},[n,a]),[c,d]=L(null),u=(h,g)=>{if(g&&!g.valid){console.warn("Invalid date input"),d("Invalid datetime");return}if(h)try{let m=Dm(h,a);if(isNaN(m.getTime())){console.warn("Invalid date:",h),d("Invalid datetime");return}d(null),o(Id.fromDate(m))}catch(m){console.error("Error parsing date:",m),d("Invalid datetime")}else d(null),o(null)},p=h=>{s(h)};return f("div",{className:"DocEditor__DateTimeField",children:[f("div",{className:"DocEditor__DateTimeField__row",children:[f("input",{type:"datetime-local",value:l,onChange:h=>{let g=h.target;u(g.value,g.validity)},className:"DocEditor__DateTimeField__input"}),e.timezone?f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",e.timezone]}):f(Rn,{className:"DocEditor__DateTimeField__timezoneSelect",value:a,onChange:h=>{h&&p(h)},data:Intl.supportedValuesOf("timeZone"),searchable:!0,size:"xs"})]}),c&&f("div",{className:"DocEditor__DateTimeField__error",children:c})]})}function V4(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}br();yr();yr();ke();var W4=["drive.google.com","docs.google.com"];function Hu(t){try{let e=new URL(t);if(!W4.includes(e.hostname))return null;if(e.searchParams.has("id"))return e.searchParams.get("id");let n=e.pathname.split("/"),o=n.findIndex(r=>r==="d");if(o!==-1&&o<n.length-1)return n[o+1]}catch{return null}return null}async function XS(t,e){let n="https://www.googleapis.com/auth/drive.readonly";(!t.isLoggedIn()||!t.hasScope(n))&&await t.login({scopes:[n]});let o=window.gapi;if(!o||!o.client||!o.client.drive)throw new Error("Google Drive API not loaded");let r=o.auth.getToken()?.access_token;if(!r)throw new Error("No Google Drive access token found");let[i,s]=await Promise.all([o.client.drive.files.get({fileId:e,fields:"name,mimeType,size",supportsAllDrives:!0}),fetch(`https://www.googleapis.com/drive/v3/files/${e}?alt=media&supportsAllDrives=true`,{headers:{Authorization:`Bearer ${r}`}})]),a=i.result;if(!s.ok)throw new Error(`Failed to download file from Drive: ${s.statusText}`);let l=await s.blob();return new File([l],a.name,{type:a.mimeType})}ke();var G4=["1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"],Y4=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"];function ZS(t){let[e,n]=L("simple"),[o,r]=L(!1),[i,s]=L(!1),[a,l]=L(null),[c,d]=L(""),[u,p]=L(t.initialWidth||1600),[h,g]=L(t.initialHeight||900),[m,_]=L("16:9"),b=QE();async function y(){if(!c){ae({title:"Prompt required",message:"Please enter a prompt to generate an image.",color:"red"});return}r(!0);try{let E=await(await fetch("/cms/api/ai.generate_image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:c,aspectRatio:m})})).json();if(E.success&&E.image)l(E.image);else throw new Error(E.error||"Failed to generate image")}catch(C){console.error(C),ae({title:"Generation failed",message:C.message||"Unknown error",color:"red"})}finally{r(!1)}}function v(C){C.preventDefault();let E=new FormData(C.target),k=parseInt(E.get("width"),10),T=parseInt(E.get("height"),10),w=E.get("backgroundColor"),S=E.get("label")||`${k}x${T}`,N=[];if(N.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${k}" height="${T}" viewBox="0 0 ${k} ${T}"><rect width="${k}" height="${T}" fill="${w}" />`),S){let P=k*.5/(S.length*.6);N.push(`<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-size="${P}" fill="#fff">${S}</text>`)}N.push("</svg>");let D=N.join(""),A=new TextEncoder().encode(D),R={src:`data:image/svg+xml;base64,${btoa(String.fromCharCode(...A))}`,filename:"placeholder.svg",width:k,height:T,alt:""};t.onSubmit(R)}async function x(){if(a){s(!0);try{let E=await(await fetch(a)).blob(),k=new File([E],"generated-image.png",{type:"image/png"}),{uploadFileToGCS:T}=await import("./gcs-ECSDFCIU.js"),w=await T(k),[S,N]=m.split(":").map(Number),D=1600,O=Math.round(D*N/S),A={...w,width:D,height:O,alt:c};t.onSubmit(A)}catch(C){console.error(C),ae({title:"Save failed",message:C.message||"Failed to upload image",color:"red"})}finally{s(!1)}}}return f(ho,{gap:"md",children:[b&&f(Dd,{value:e,onChange:C=>n(C),data:[{label:"Simple",value:"simple"},{label:f(fn,{gap:5,children:[f(Oo,{size:16}),f("span",{children:"Generate with AI"})]}),value:"ai"}],fullWidth:!0}),e==="simple"?f("form",{onSubmit:v,children:[f(ho,{gap:"xs",children:[f(Xn,{label:"Width",name:"width",type:"number",value:u,onChange:C=>p(parseInt(C.currentTarget.value,10)),"data-autofocus":!0}),f(Xn,{label:"Height",name:"height",type:"number",value:h,onChange:C=>g(parseInt(C.currentTarget.value,10))}),f(Xn,{name:"label",label:"Label",defaultValue:""}),f(AC,{name:"backgroundColor",label:"Background color",format:"hex",defaultValue:"#868e96",swatches:Y4})]}),f(fn,{justify:"flex-end",mt:"md",children:f(Z,{variant:"filled",type:"submit",children:"Create"})})]}):f(ho,{gap:"xs",children:[f(Rn,{label:"Aspect Ratio",data:G4,value:m,onChange:C=>_(C)}),f(bn,{label:"Prompt",placeholder:"Describe the image you want to generate...",minRows:3,value:c,onChange:C=>d(C.currentTarget.value),"data-autofocus":!0,required:!0}),a&&f(ea,{src:a,alt:"Generated preview",height:200,fit:"contain"}),f(fn,{justify:"flex-end",mt:"md",children:[f(Z,{variant:"light",onClick:y,loading:o,disabled:i||!c,leftIcon:f(Oo,{size:16}),children:o?"Generating...":"Preview"}),f(Z,{variant:"filled",onClick:x,loading:i,disabled:!a||o,children:i?"Saving...":"Save"})]})]})]})}var q4=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"],QS=pt(null),J4=TC(()=>import("./ImageEditorDialog-JDXMU2FC.js").then(t=>({default:t.ImageEditorDialog})));function uc(){let t=ft(QS);if(!t)throw new Error("useFileField() should be called within a <FileFieldContext.Provider>");return t}function X4(t){let{field:e,value:n,setValue:o,loadingState:r,setLoadingState:i}=t,s=NC(),a=J(null),[l,c]=L(!1),[d,u]=L(!1),[p,h]=L(!1),g=la(),m=Pw(),_=t.allowEditing!==!1,[b,y]=L("hash"),[v,x]=L(null),[C,E]=L(!1),[k,T]=L(null),w=t.accept??e.exts??(t.variant==="image"?q4:[]),S=n?.alt||"",N=t.altDisabledByMetadata===!0,D=n?.altDisabled===!0,O=e.alt!==!1&&!N&&!D;async function A(oe,ee,ye){try{i("loading");let Fe=ye?.namingMode||(e.preserveFilename?"clean":"hash"),un=e.cacheControl||(Fe==="clean"?"no-cache":void 0),Be=await ai(oe,{namingMode:Fe,checkExists:ye?.checkExists??!1,cacheControl:un});!Be.alt&&ek(Be.filename)&&S&&(Be.alt=S),ee&&(Be.originalSrc=ee),o(Be),i("complete"),x(null),T(null)}catch(Fe){console.error("upload failed"),console.error(Fe),i("error"),ae({title:"Upload failed",message:"Failed to upload: "+String(Fe),color:"red",autoClose:!1})}}async function I(){i("loading");try{let oe=n?.gcsPath||n?.src;oe&&await jC(oe),o(null),i(null),ae({message:"File deleted from GCS",color:"green"})}catch(oe){console.error(oe),i("error"),ae({title:"Delete failed",message:String(oe),color:"red"})}finally{u(!1)}}function R(){if(!_&&n?.src){u(!0);return}o(null)}async function $(oe,ee){if(!oe)return;if(x(null),T(null),E(!1),typeof oe=="string"&&!ee?.as){let un=Hu(oe);if(un){try{if(!g.enabled){console.warn("Google API integration is not enabled for this project. Specify the `gapi` config in your root.config.ts to enable pasting from Google Drive URLs.");return}i("loading"),ae({message:"Downloading from Google Drive...",loading:!0,autoClose:!1,id:"gdrive-download"});let Be=await XS(g,un);Il("gdrive-download"),$(Be)}catch(Be){console.error(Be),i("error"),Il("gdrive-download"),ae({title:"Google Drive import failed",message:Be.message||"Failed to download",color:"red"})}return}}ee?.as==="svg"&&typeof oe=="string"&&(oe=new File([new Blob([oe],{type:"image/svg+xml"})],"untitled.svg",{type:"image/svg+xml"}));let ye=oe,Fe=Ph(ye.name);if(w.length>0&&!w.some(un=>un.endsWith(Fe)||un===`*/${Fe}`||un==="*/*"||un===ye.type)){ae({title:"Invalid file type",message:`File type ${Fe} is not allowed.`,color:"red",autoClose:!0});return}if(b==="clean"&&t.showNamingOptions){i("loading");let Be=`${window.__ROOT_CTX.rootConfig.projectId}/uploads/${ye.name}`;try{if(await VC(Be)){x(ye),T(`https://storage.googleapis.com/${window.firebase.storage.app.options.storageBucket}/${Be}`),i(null);return}}catch(on){console.warn("Failed to check file existence",on)}}A(ye,void 0,{namingMode:b})}function W(){a.current?.focus()}function P(){if(n?.src)if(Fh(n.src)){let oe=document.createElement("a");oe.href=WC(n.src),n.filename&&(oe.download=n.filename),document.body.appendChild(oe),oe.click(),document.body.removeChild(oe)}else window.open(n.src,"_blank")}function q(){let oe=document.createElement("input");oe.type="file",w.length>0&&(oe.accept=w.join(",")),oe.onchange=ee=>{let ye=ee.target;ye.files&&ye.files.length>0&&$(ye.files[0])},oe.click(),oe.remove()}function de(){c(!0)}function rt(){h(!0)}async function Tt(){let oe=GC();if(n?.assetId)try{let ee=await qC(n.assetId);ee&&(oe=ee.parent||"")}catch(ee){console.warn("failed to resolve linked asset folder:",ee)}m.open({accept:w,initialFolder:oe,onSelect:ee=>{let ye=JC(ee);!ye.alt&&S&&(ye.alt=S),o(ye),i("complete")}})}function _t(){if(!n?.assetId)return;let oe={...n};delete oe.assetId,o(oe)}function dt(oe){n?.src&&o({...n,alt:oe||""})}async function ut(){let oe=n;if(oe?.src){i("loading");try{let ee=await window.fetch("/cms/api/ai.generate_alt_text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({imageUrl:oe.src})}),ye=await ee.json();if(!ee.ok||!ye.success)throw new Error(ye.error||"Failed to generate alt text");ye.altText&&dt(ye.altText)}catch(ee){ae({title:"Sorry, something went wrong.",message:ee.message||"Unknown error",color:"red",autoClose:!0})}finally{i("complete")}}}return f(QS.Provider,{value:{field:e,variant:t.variant,value:n,setValue:o,loadingState:r,removeFile:R,acceptedFileTypes:w,handleFile:$,focusDropZone:W,requestGenerateAltText:ut,requestFileUpload:q,requestFileDownload:P,requestPlaceholderModalOpen:de,requestImageEditorOpen:rt,assetPickerEnabled:m.enabled,requestAssetPicker:Tt,unlinkAsset:_t,showAltText:O,altText:S,setAltText:dt,altDisabledByMetadata:N,setAltDisabledByMetadata:t.setAltDisabledByMetadata,allowEditing:_},children:[f(Xi,{size:"sm",opened:l,onClose:()=>c(!1),title:"Placeholder image",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:f(ZS,{onSubmit:oe=>{o(oe),c(!1)}})}),f(Xi,{size:"sm",opened:d,onClose:()=>u(!1),title:"Delete file?",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:[f(Bt,{size:"sm",mb:"lg",children:"Are you sure you want to delete this file from GCS? This action cannot be undone."}),f(fn,{grow:!0,spacing:"xs",children:[f(Z,{variant:"default",onClick:()=>u(!1),disabled:r==="loading",children:"Cancel"}),f(Z,{color:"red",onClick:I,loading:r==="loading",children:"Delete"})]})]}),p&&n?.src&&f(Sd,{fallback:null,children:f(J4,{opened:p,onClose:()=>h(!1),src:n.src,originalSrc:n.originalSrc,filename:n.filename,initialWidth:parseInt(n.width),initialHeight:parseInt(n.height),onSave:oe=>{A(oe,n.originalSrc||n.src),h(!1)}},n.src)}),v?f("div",{className:"FileField__overwriteWarning",children:[f("div",{className:"FileField__overwriteWarning__header",children:f(Bt,{size:"sm",color:"red",weight:700,children:"File already exists"})}),f(Bt,{size:"sm",children:["A file named ",f("strong",{children:v.name})," already exists."]}),k&&f(Bt,{size:"sm",className:"FileField__overwriteWarning__link",children:f("a",{href:k,target:"_blank",rel:"noopener noreferrer",children:["View existing file ",f(Do,{size:12})]})}),f("div",{className:"FileField__overwriteWarning__checkbox",children:f(fo,{label:"Confirm overwrite",checked:C,onChange:oe=>E(oe.currentTarget.checked)})}),f(fn,{grow:!0,spacing:"xs",className:"FileField__overwriteWarning__actions",children:[f(Z,{variant:"default",onClick:()=>{x(null),T(null),E(!1)},disabled:r==="loading",children:"Cancel"}),f(Z,{disabled:!C,onClick:()=>A(v,void 0,{namingMode:"clean"}),color:"red",loading:r==="loading",children:"Overwrite"})]})]}):f(Ne,{children:[f("div",{className:xe("FileField",t.showNamingOptions&&"FileField--withOptions"),children:[f(En.Dropzone,{ref:a}),n?.src?f(En.Preview,{}):f(En.InvisibleDropzone,{children:f(En.Empty,{})})]}),t.showNamingOptions&&!n&&f("div",{className:"FileField__settings",style:{marginTop:8},children:f(Rn,{label:"File name options",size:"xs",itemComponent:Z4,data:[{value:"hash",label:"Hash the file name",description:"The filename will be hashed so the file's original name won't be exposed."},{value:"hash-path",label:"Use a hashed path with the original file name",description:"Use the original file name, but put it inside a hashed directory."},{value:"clean",label:"Use the original file name only",description:"The file will be uploaded to the bucket as-is, without a hashed directory."}],value:b,onChange:oe=>y(oe||"hash"),disabled:r==="loading"||!!n})})]})]})}function En(t){let e=t.field,[n,o]=At(t.deepKey),[r,i]=L(null),s=e5(t.deepKey),[a,l]=At(s),c=a?.alt===!1,d=u=>{let p={...a||{}};u?p.alt=!1:delete p.alt,l(Object.keys(p).length===0?null:p)};return f(X4,{field:e,value:n,setValue:o,loadingState:r,setLoadingState:i,variant:t.variant,allowEditing:t.allowEditing,altDisabledByMetadata:c,setAltDisabledByMetadata:t.variant==="image"&&e.alt!==!1?d:void 0})}En.Preview=()=>{let t=uc(),[e,n]=L(!1),[o,r]=L(!1),i=Io(),s=!!t.value?.width&&!!t.value?.height&&Number(t.value.width)>0&&Number(t.value.height)>0,a=t.value?.filename||"",l=Ml(a),c=Cr(a)||l&&s,[d,u]=L(!c),p=J(t.value?.src);if(t.value?.src!==p.current){p.current=t.value?.src;let h=t.value?.filename||"",g=Cr(h)||Ml(h)&&s;!g&&!d?u(!0):g&&d&&u(!1)}return t.value?.src?f("div",{className:"FileField__Preview",children:[f("div",{className:"FileField__Preview__InfoButton",children:[c&&f(we,{label:"Toggle file info",position:"top",withArrow:!0,children:f(Ae,{onClick:()=>u(h=>!h),size:"sm",variant:"outline",className:"FileField__Preview__InfoButton__Icon","aria-label":"Toggle file info",children:f($l,{size:16})})}),f(G,{classNames:{body:"FileField__Preview__Menu"},shadow:"sm",control:f(Ae,{variant:"outline",size:"sm",radius:"sm",c:"black",className:"FileField__Preview__InfoButton__Icon",children:f(sa,{size:16})}),children:[t.allowEditing&&f(Ne,{children:[f(G.Label,{size:"sm",children:"REPLACE"}),f(G.Item,{icon:t.variant==="image"?f(Kh,{size:16}):f(Bl,{size:16}),onClick:()=>t.requestFileUpload(),children:["Upload ",t.variant==="image"?"image":"file"]}),t.assetPickerEnabled&&f(G.Item,{icon:f(LE,{size:16}),onClick:()=>t.requestAssetPicker(),children:"Select from asset library"}),tk(t.acceptedFileTypes)&&f(G.Item,{disabled:!t.value?.src,icon:f(Uh,{size:16}),onClick:()=>{t.requestPlaceholderModalOpen()},children:"Placeholder image"}),Cr(t.value?.src)&&!t.value?.src?.endsWith(".svg")&&f(G.Item,{disabled:!t.value?.src,icon:f(bE,{size:16}),closeMenuOnClick:!0,onClick:()=>{t.requestImageEditorOpen()},children:"Edit image"}),f(xr,{})]}),f(G.Item,{disabled:t.value?.src?.startsWith("data:"),onClick:()=>{t?.requestFileDownload()},icon:f(xE,{size:16}),children:"Download file"}),f(G.Item,{closeOnItemClick:!1,icon:f(Wd,{size:16}),onClick:()=>{r(!1);let h=t.value?.src||"";Fh(h)&&(h=h.split("=")[0]+"=s0"),navigator.clipboard.writeText(h).then(()=>r(!0)).finally(()=>setTimeout(()=>{r(!1)},2e3))},children:o?"Copied!":"Copy URL"}),t.value?.assetId&&f(G.Item,{component:"a",href:`/cms/assets?asset=${t.value.assetId}`,target:"_blank",rel:"noreferrer",icon:f(Do,{size:16}),children:"View in asset library"}),t.allowEditing&&t.value?.assetId&&f(G.Item,{icon:f(JE,{size:16}),onClick:()=>t.unlinkAsset(),children:"Unlink from asset library"}),t.allowEditing&&Cr(t.value?.src||"")&&t.value?.canvasBgColor&&f(G.Item,{icon:t.value?.canvasBgColor==="dark"?f(qh,{size:16}):f(Wh,{size:16,style:{opacity:.25}}),closeOnItemClick:!1,onClick:()=>{let h=t.value?.canvasBgColor==="dark"?"light":"dark";t.value&&t.setValue({...t.value,canvasBgColor:h})},children:"Use dark canvas"}),t.allowEditing&&t.setAltDisabledByMetadata&&f(G.Item,{icon:t.altDisabledByMetadata?f(qh,{size:16}):f(Wh,{size:16,style:{opacity:.25}}),closeOnItemClick:!1,onClick:()=>{t.setAltDisabledByMetadata?.(!t.altDisabledByMetadata)},children:"Disable alt text"}),f(xr,{}),f(G.Item,{color:"red",onClick:()=>{t?.removeFile()},icon:f(Zn,{size:16}),children:"Remove file"})]})]}),f("div",{className:xe("FileField__Canvas",d&&"FileField__Canvas--infoOpened",e&&"dragging"),style:Q4(t.value),onDragOver:h=>{h.preventDefault(),n(!0)},onDragLeave:h=>{h.preventDefault(),n(!1)},onDrop:h=>{h.preventDefault(),n(!1);let g=h.dataTransfer?.files[0];g&&t&&t.handleFile(g)},onPaste:h=>{h.preventDefault();let g=h.clipboardData?.files[0];if(g){t.handleFile(g);return}let m=h.clipboardData?.getData("text/plain");if(m){if(Hu(m)){t.handleFile(m);return}if(nk(m)){t.handleFile(m,{as:"svg"});return}}},children:[f(Nd,{visible:t.loadingState==="loading"}),d?f("div",{className:"FileField__Canvas__Info",children:[f(zl,{size:16,className:"FileField__Canvas__Info__Icon"}),f(RC,{className:"FileField__Canvas__Info__Table",verticalSpacing:"xs",fontSize:"xs",children:f("tbody",{children:[t.value?.filename&&f("tr",{children:[f("td",{children:f("b",{children:"Name"})}),f("td",{children:t.value.filename})]}),t.value?.assetId&&f("tr",{children:[f("td",{children:f("b",{children:"Asset"})}),f("td",{children:f("a",{href:`/cms/assets?asset=${t.value.assetId}`,target:"_blank",rel:"noreferrer",children:"Open in asset library"})})]}),t.value?.uploadedAt&&f("tr",{children:[f("td",{children:f("b",{children:"Uploaded"})}),f("td",{children:[new Date(parseInt(t.value.uploadedAt,10)).toLocaleString(),t.value.uploadedBy&&f(Ne,{children:[" by ",t.value.uploadedBy]})]})]}),!!(t.value?.width&&t.value?.height)&&f("tr",{children:[f("td",{children:f("b",{children:"Dimensions"})}),f("td",{children:[t.value.width,"x",t.value.height]})]}),f("tr",{children:[f("td",{children:f("b",{children:"URL"})}),f("td",{children:f(bn,{readOnly:!0,value:t.value?.src,size:"xs",radius:0,autosize:!0,maxRows:10})})]})]})})]}):f(Ne,{children:[!!(t.value?.width&&t.value?.height)&&f(DC,{radius:"sm",className:"FileField__Preview__Info",children:[t.value.width,"x",t.value.height]}),t.value?.assetId&&f("a",{className:"FileField__Preview__AssetLibraryBadge",href:`/cms/assets?asset=${t.value?.assetId}`,target:"_blank",children:"ASSET LIBRARY"}),Cr(t.value?.src)&&f("img",{onClick:()=>{t?.focusDropZone()},onDblClick:()=>{t.allowEditing&&t?.requestFileUpload()},src:t.value.src,alt:t.value.alt||"Uploaded file preview",className:"FileField__Preview__Image"}),Ml(t.value?.src)&&f(Ne,{children:f("video",{className:"FileField__Preview__Image",controls:!0,muted:!0,preload:"metadata",children:f("source",{src:t.value.src,type:`video/${Ph(t.value.src)}`})})})]}),t.allowEditing&&f("div",{className:"FileField__reupload",children:f(En.UploadButton,{className:"FileField__reupload__button",compact:!0})})]}),t.allowEditing&&t.showAltText&&(t.altText||ek(t.value?.filename)||t.variant==="image")&&f("div",{className:"DocEditor__ImageField__imagePreview__Image__Alt",children:[f(bn,{radius:0,className:"DocEditor__ImageField__imagePreview__Image__Alt__Textarea",value:t.altText,placeholder:"Alt text",size:"xs",autosize:!0,disabled:t.loadingState==="loading",onChange:h=>{t?.setAltText(h.currentTarget.value)}}),i&&!t.altText&&t.value?.src?.startsWith("http")&&f(we,{label:"Generate alt text with AI",position:"top",withArrow:!0,children:f(Ae,{className:"DocEditor__ImageField__imagePreview__Image__Alt__AiButton",onClick:()=>{t.requestGenerateAltText()},disabled:t.loadingState==="loading",children:f(Oo,{size:20,stroke:"1.75"})})})]})]}):null};En.UploadButton=t=>{let e=uc(),n=e.loadingState==="loading",o=t.compact?14:16;return f(Z,{color:"black",variant:"default",disabled:n,size:t.compact?"compact-xs":"compact-md",className:xe("FileField__FileUploadButton",t.compact&&"FileField__FileUploadButton--compact"),onClick:()=>{e.requestFileUpload()},leftIcon:f(Ne,{children:n&&!t.compact?f(xt,{size:o}):e?.variant==="image"?f(Kh,{size:o}):f(Bl,{size:o})}),children:n&&!t.compact?"Uploading...":e.value?.src?"Upload":"Paste, drop, or click to upload"})};En.InvisibleDropzone=t=>{let[e,n]=L(!1),o=uc();return f("div",{className:xe("FileField__InvisibleDropzone",e&&"dragging"),onDragOver:r=>{r.preventDefault(),r.stopPropagation(),n(!0)},onDragLeave:r=>{r.preventDefault(),r.stopPropagation(),n(!1)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),n(!1);let i=r.dataTransfer?.files[0];i&&o.handleFile(i)},children:t.children})};En.Empty=()=>{let t=uc(),e=X(()=>{if(t.acceptedFileTypes.length===0)return"";let n=t.acceptedFileTypes.filter(o=>o!=="*/*"&&o!=="*");return n.length===0?"":n.map(o=>o.split("/").pop().split("+")[0].replaceAll(".","")).sort().join(", ")},[t.acceptedFileTypes]);return f("div",{className:"FileField__Empty",children:[f("div",{className:"FileField__Empty__Label",children:[f(En.UploadButton,{}),tk(t.acceptedFileTypes)&&f("div",{children:f(we,{label:"Create placeholder image",children:f(Ae,{className:"FileField__Empty__Label__PlaceholderButton",onClick:()=>{t.requestPlaceholderModalOpen()},title:"Create placeholder image",children:f(Uh,{size:16})})})})]}),t.allowEditing&&t.assetPickerEnabled&&f("div",{className:"FileField__Empty__AssetLibrary",children:["or select from"," ",f("button",{type:"button",className:"FileField__Empty__AssetLibrary__link",onClick:()=>t.requestAssetPicker(),children:"asset library"})]}),e&&f("div",{children:f("div",{className:"FileField__Empty__AcceptTypes",children:["Allowed file types: ",e]})})]})};En.Dropzone=po((t,e)=>{let[n,o]=L(!1),r=uc();return f("button",{ref:e,className:xe("FileField__Dropzone",n&&"dragging"),onDblClick:()=>{r?.requestFileUpload()},onCopy:i=>{r.value?.src&&(i.preventDefault(),i.clipboardData?.setData("text/plain",r.value.src),i.clipboardData?.setData("application/json",JSON.stringify(r.value)))},onKeyDown:i=>{((i.metaKey||i.ctrlKey)&&i.key==="Backspace"||i.key==="Delete")&&(i.preventDefault(),r.value?.src&&r.removeFile())},onDragOver:i=>{i.preventDefault(),o(!0)},onDragLeave:i=>{i.preventDefault(),o(!1)},onDrop:i=>{i.preventDefault(),o(!1);let s=i.dataTransfer?.files[0];s&&r&&r.handleFile(s)},onPaste:i=>{if(i.preventDefault(),!r)return;let s=i.clipboardData?.getData("application/json");if(s)try{let c=JSON.parse(s);if(c&&c.src&&c.filename&&r){console.log("Parsed JSON file:",c),r.setValue(c);return}}catch(c){console.error("error parsing json",c)}let a=i.clipboardData?.files[0];if(a){r.handleFile(a);return}let l=i.clipboardData?.getData("text/plain");if(l){if(Hu(l)){r.handleFile(l);return}if(nk(l)){r.handleFile(l,{as:"svg"});return}}},title:"Drop or paste to upload a file"})});var Z4=po(t=>{let{label:e,description:n,...o}=t;return f("div",{className:"FileField__NamingModeItem",...o,children:[f(Bt,{size:"sm",weight:500,children:e}),f(Bt,{size:"xs",color:"dimmed",children:n})]})});function ek(t){return t?Cr(t)||Ml(t):!1}function tk(t){return t.some(e=>e.startsWith("image/"))||t.length===0}function Q4(t){let e={};if(t.width&&t.height){e["--canvas-aspect-ratio"]=`${t.width} / ${t.height}`,e["--canvas-asset-width"]=`${t.width}px`;let n=Math.min(t.height,280);n<80&&(n=80),e["--canvas-max-height"]=`${n}px`}return t.canvasBgColor==="dark"&&(e["--canvas-bg-color"]="#000"),e}function e5(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}function nk(t){return/^(?:\uFEFF)?\s*(?:<!--[\s\S]*?-->\s*)*(?:<\?xml[\s\S]*?\?>\s*)?(?:<!DOCTYPE\s+svg[\s\S]*?>\s*)?<svg\b[^>]*?(?:\/>|>[\s\S]*?<\/svg>)\s*$/.test(t)}function ok(t){return f(En,{...t,variant:"image"})}ke();async function Uu(t){return t&&t.doc?t5(t):[]}async function t5(t){if(!t.doc||!t.field)return[];let e=await Qi(t.doc);if(!e)return[];let n=e.fields||{},o=n5(yn(n,t.field)),r=[],i=new Set;for(let s of o){let a,l,c;if(s&&typeof s=="object"?(a=t.valueKey?yn(s,t.valueKey):void 0,l=t.labelKey?yn(s,t.labelKey):void 0,c=t.helpKey?yn(s,t.helpKey):void 0):a=s,a==null||a==="")continue;let d=String(a);if(i.has(d))continue;i.add(d);let u=l==null||l===""?d:String(l),p=c==null||c===""?void 0:String(c);r.push(p?{value:d,label:u,description:p}:{value:d,label:u})}return r}function n5(t){return Array.isArray(t)?t:t&&typeof t=="object"&&Array.isArray(t._array)?t._array.map(e=>t[e]).filter(e=>e!=null):[]}yr();var Ku=po(t=>{let{label:e,description:n,...o}=t;return f("div",{...o,children:[f(Bt,{size:"sm",children:e}),n&&f(Bt,{size:"xs",color:"dimmed",children:n})]})});function ju(t){let e=t.source;if(!e||!e.doc)return null;let n=`Open ${e.doc}`,o=`/cms/content/${e.doc}`;if(e.field){let r=`fields.${e.field}`;o+=`?deeplink=${encodeURIComponent(r)}`}return f(we,{label:n,position:"top",withArrow:!0,children:f(Ae,{component:"a",href:o,target:"_blank",rel:"noopener noreferrer","aria-label":n,children:f(Do,{size:16})})})}function rk(t){let e=t.field,[n,o]=At(t.deepKey,[]),[r,i]=L([]),[s,a]=L([]),[l,c]=L(!!e.source);F(()=>{if(!e.source)return;let h=!0;return c(!0),Uu(e.source).then(g=>{h&&i(g)}).catch(g=>{console.error("failed to resolve field source:",g)}).finally(()=>{h&&c(!1)}),()=>{h=!1}},[e.source]);let d=X(()=>(e.options||[]).map(h=>typeof h=="string"?{label:h,value:h}:{label:h.label??h.value??"",value:h.value??h.label??""}),[e.options]),u=X(()=>{let h=new Map,g=e.source?r:d;for(let m of g)h.set(m.value,m);for(let m of s)h.has(m.value)||h.set(m.value,m);for(let m of n||[])m&&!h.has(m)&&h.set(m,{value:m,label:m});return Array.from(h.values())},[e.source,r,d,s,n]),p=f(MC,{data:u,size:"xs",radius:0,placeholder:e.placeholder,value:n,searchable:!0,creatable:e.creatable||!1,getCreateLabel:h=>`+ Add "${h}"`,onCreate:h=>{let g={value:h,label:h};return a(m=>[...m,g]),g},onChange:h=>o(h),itemComponent:e.source?.helpKey?Ku:void 0,nothingFound:l?"Loading\u2026":void 0,rightSection:l?f(xt,{size:"xs"}):void 0,dropdownComponent:"div"});return e.source?.doc?f("div",{className:"DocEditor__MultiSelectField",style:{display:"flex",alignItems:"center",gap:8},children:[f("div",{style:{flex:1,minWidth:0},children:p}),f(ju,{source:e.source})]}):f("div",{className:"DocEditor__MultiSelectField",children:p})}function ik(t){let[e,n]=At(t.deepKey,0);return f(LC,{size:"xs",radius:0,value:e,onChange:o=>n(o),hideControls:!0})}ke();var sk="ReferenceFieldEditorModal";function Vu(){let t=St(),e=ot();return{open:n=>{t.openContextModal(sk,{...e,className:"ReferenceFieldEditorModalWrap",innerProps:n,title:`Edit ${n.docId}`,size:"xl",overflow:"inside",closeOnClickOutside:!1,closeOnEscape:!1})}}}function Om(t){let{id:e,context:n,innerProps:o}=t,r=o.docId;return f("div",{className:"ReferenceFieldEditorModal",children:f(e0,{docId:r,autoSave:!1,flushOnStop:!1,children:[f(Ie,{className:"ReferenceFieldEditorModal__DocEditor",docId:o.docId,hideStatusBar:!0}),f(Om.Footer,{docId:r,onCancel:()=>n.closeModal(e)})]})})}Om.Footer=t=>{let e=sn();return f("div",{className:"ReferenceFieldEditorModal__footer",children:[f("div",{className:"ReferenceFieldEditorModal__footer__start",children:f(Z,{component:"a",variant:"default",size:"xs",rightIcon:f(ia,{size:16}),href:`/cms/content/${t.docId}`,target:"_blank",children:["Open ",t.docId]})}),f(Z,{variant:"default",size:"xs",onClick:t.onCancel,children:"Cancel"}),f(Z,{color:"dark",size:"xs",onClick:async()=>{await e.controller.flush(),t.onCancel()},children:"Save"})]})};Om.id=sk;function va(t){let e=t.field,[n,o]=At(t.deepKey),r=n?.id||"";function i(c){o(c?zd(c):null)}let s=lu(),a=Vu();function l(){let c=r?zd(r).collection:e.initialCollection;s.open({collections:e.collections,initialCollection:c,onChange:d=>{i(d),s.close()}})}return f("div",{className:"ReferenceField",children:[r?f("div",{className:"ReferenceField__ref",children:[f(va.Preview,{id:r}),f("div",{className:"ReferenceField__remove",children:[f(we,{label:"Quick edit",children:f(Ae,{className:"ReferenceField__remove__icon",onClick:()=>a.open({docId:r}),children:f(Xd,{size:16})})}),f(we,{label:"Remove",children:f(Ae,{className:"ReferenceField__remove__icon",onClick:()=>o(null),children:f(Zn,{size:16})})})]})]}):f("div",{className:"ReferenceField__none",children:"None selected"}),f(Z,{color:"dark",size:"xs",onClick:()=>l(),children:e.buttonLabel||"Select"})]})}va.Preview=t=>{let[e,n]=L(!0),[o,r]=L(null);async function i(){n(!0),await vr(async()=>{let s=await Qi(t.id);r(s)}),n(!1)}return F(()=>{i()},[t.id]),f("div",{className:"ReferenceField__Preview",children:e?f("div",{className:"ReferenceField__Preview__loading",children:f(xt,{color:"gray",size:"sm"})}):o?f(va.DocCard,{doc:o}):f("div",{className:"ReferenceField__Preview__notfound",children:["Doc not found: ",f("b",{children:t.id})," (was it deleted?). Select a new doc or remove using the trash icon to the right."]})})};va.DocCard=t=>{let e=t.doc,n=e.id||e.sys?.id||"";if(!n)return f("div",{className:"ReferenceField__DocCard ReferenceField__DocCard--error",children:JSON.stringify(e)});let o=zd(n).collection,r=e.fields||{},i=window.__ROOT_CTX.collections[o];if(!i)throw new Error(`could not find collection: ${o}`);let s=yn(r,i.preview?.title||"meta.title"),a=yn(r,i.preview?.image||"meta.image")||i.preview?.defaultImage;return f("a",{className:"ReferenceField__DocCard",href:`/cms/content/${n}`,target:"_blank",children:[f("div",{className:"ReferenceField__DocCard__image",children:f(ea,{src:a?.src,width:80,height:60,withPlaceholder:!a?.src})}),f("div",{className:"ReferenceField__DocCard__content",children:[f("div",{className:"ReferenceField__DocCard__content__header",children:f("div",{className:"ReferenceField__DocCard__content__header__docId",children:n})}),f("div",{className:"ReferenceField__DocCard__content__title",children:s||"[UNTITLED]"})]})]})};ke();function ak(t){let e=t.field,[n,o]=L([]),r=sn().controller;function i(d){if(d.length){let u=d.map(p=>{let[h,g]=p.split("/");return{id:p,collection:h,slug:g}});r.updateKey(t.deepKey,u)}else r.removeKey(t.deepKey);o(d)}Xo(t.deepKey,d=>{Array.isArray(d)?o(d.map(u=>u.id)):o([])});let s=lu(),a=Vu();function l(){s.open({collections:e.collections,initialCollection:e.initialCollection,multiSelect:!0,selectedDocIds:n,onChangeMulti:(d,u)=>{o(p=>{let h=[...p];if(u)h.includes(d)||h.push(d);else{let g=h.indexOf(d);g>-1&&h.splice(g,1)}return i(h),h})}})}function c(d){let u=n.filter(p=>p!==d);i(u)}return f("div",{className:"ReferencesField",children:[n.length>0?f(Ou,{onDragEnd:d=>{let{destination:u,source:p}=d;if(!u||u.index===p.index)return;let h=[...n],[g]=h.splice(p.index,1);h.splice(u.index,0,g),i(h)},children:f(Au,{droppableId:"ReferencesField__droppable",direction:"vertical",children:d=>f("div",{ref:d.innerRef,...d.droppableProps,className:"ReferencesField__refs",children:[n.map((u,p)=>f(Iu,{draggableId:u,index:p,children:(h,g)=>f("div",{ref:h.innerRef,...h.draggableProps,className:xe("ReferencesField__card",g.isDragging&&"ReferencesField__card--dragging"),children:[f("div",{className:"ReferencesField__card__handle",...h.dragHandleProps,children:f(Gd,{size:16,stroke:"1.5"})}),f(iu,{className:"ReferencesField__card__preview",docId:u,variant:"compact",clickable:!0,statusBadges:!0}),f("div",{className:"ReferencesField__card__controls",children:[f(we,{label:"Quick edit",children:f(Ae,{onClick:()=>a.open({docId:u}),children:f(Xd,{size:16})})}),f(we,{label:"Remove",children:f(Ae,{className:"ReferencesField__card__controls__remove",onClick:()=>c(u),children:f(Zn,{size:16})})})]})]})},u)),d.placeholder]})})}):f("div",{className:"ReferencesField__none",children:"None selected"}),f(Z,{color:"dark",size:"xs",onClick:()=>l(),children:e.buttonLabel||"Select"})]})}ke();(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-hint--align-start{text-align:left}.ce-hint--align-center{text-align:center}.ce-hint__description{opacity:.6;margin-top:3px}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var bc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function o5(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function o(){return this instanceof o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return t[o]}})}),n}function Im(){}Object.assign(Im,{default:Im,register:Im,revert:function(){},__esModule:!0});Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){let e=(this.document||this.ownerDocument).querySelectorAll(t),n=e.length;for(;--n>=0&&e.item(n)!==this;);return n>-1});Element.prototype.closest||(Element.prototype.closest=function(t){let e=this;if(!document.documentElement.contains(e))return null;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(e!==null);return null});Element.prototype.prepend||(Element.prototype.prepend=function(t){let e=document.createDocumentFragment();Array.isArray(t)||(t=[t]),t.forEach(n=>{let o=n instanceof Node;e.appendChild(o?n:document.createTextNode(n))}),this.insertBefore(e,this.firstChild)});Element.prototype.scrollIntoViewIfNeeded||(Element.prototype.scrollIntoViewIfNeeded=function(t){t=arguments.length===0?!0:!!t;let e=this.parentNode,n=window.getComputedStyle(e,null),o=parseInt(n.getPropertyValue("border-top-width")),r=parseInt(n.getPropertyValue("border-left-width")),i=this.offsetTop-e.offsetTop<e.scrollTop,s=this.offsetTop-e.offsetTop+this.clientHeight-o>e.scrollTop+e.clientHeight,a=this.offsetLeft-e.offsetLeft<e.scrollLeft,l=this.offsetLeft-e.offsetLeft+this.clientWidth-r>e.scrollLeft+e.clientWidth,c=i&&!s;(i||s)&&t&&(e.scrollTop=this.offsetTop-e.offsetTop-e.clientHeight/2-o+this.clientHeight/2),(a||l)&&t&&(e.scrollLeft=this.offsetLeft-e.offsetLeft-e.clientWidth/2-r+this.clientWidth/2),(i||s||a||l)&&!t&&this.scrollIntoView(c)});window.requestIdleCallback=window.requestIdleCallback||function(t){let e=Date.now();return setTimeout(function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})},1)};window.cancelIdleCallback=window.cancelIdleCallback||function(t){clearTimeout(t)};var r5=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,n)=>(n&=63,n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n>62?e+="-":e+="_",e),""),vk=(t=>(t.VERBOSE="VERBOSE",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t))(vk||{}),Te={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},i5={LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4};function Sc(t,e,n="log",o,r="color: inherit"){if(!("console"in window)||!window.console[n])return;let i=["info","log","warn","error"].includes(n),s=[];switch(Sc.logLevel){case"ERROR":if(n!=="error")return;break;case"WARN":if(!["error","warn"].includes(n))return;break;case"INFO":if(!i||t)return;break}o&&s.push(o);let a="Editor.js 2.31.0-rc.7";t&&(i?(s.unshift(`line-height: 1em;
|
|
83
83
|
color: #006FEA;
|
|
84
84
|
display: inline-block;
|
|
85
85
|
font-size: 11px;
|
|
@@ -126,7 +126,7 @@ ${ut.current.stack}
|
|
|
126
126
|
`+ ++s);n.setAttribute("data-gutter",i)}var oC=new Set;function OL(t,e,n){let o=t.getKey();oC.has(o)||(oC.add(o),t.getLanguage()===void 0&&t.setLanguage(n.defaultLanguage),e.update((()=>{(function(r,i){let s=Lt(r);if(!Go(s)||!s.isAttached())return;let a=z();if(!B(a))return void i();let l=a.anchor,c=l.offset,d=l.type==="element"&&Ze(s.getChildAtIndex(l.offset-1)),u=0;if(!d){let p=l.getNode();u=c+p.getPreviousSiblings().reduce(((h,g)=>h+g.getTextContentSize()),0)}if(i()){if(d)return void l.getNode().select(c,c);s.getChildren().some((p=>{let h=te(p);if(h||Ze(p)){let g=p.getTextContentSize();if(h&&g>=u)return p.select(u,u),!0;u-=g}return!1}))}})(o,(()=>{let r=Lt(o);if(!Go(r)||!r.isAttached())return!1;let i=r.getLanguage()||n.defaultLanguage,s=/^diff-([\w-]+)/i.exec(i),a=r.getTextContent(),l=n.tokenize(a,s?"diff":i);s&&(l=(function(g,m){let _=m,b=ko.languages[_],y={tokens:g},v=ko.languages.diff.PREFIXES;for(let x of y.tokens){if(typeof x=="string"||!(x.type in v)||!Array.isArray(x.content))continue;let C=x.type,E=0,k=()=>(E++,new ko.Token("prefix",v[C],C.replace(/^(\w+).*/,"$1"))),T=x.content.filter((A=>typeof A=="string"||A.type!=="prefix")),w=x.content.length-T.length,S=ko.tokenize(rC(T),b);S.unshift(k());let N=/\r\n|\n/g,D=A=>{let I=[];N.lastIndex=0;let R,$=0;for(;E<w&&(R=N.exec(A));){let W=R.index+R[0].length;I.push(A.slice($,W)),$=W,I.push(k())}if(I.length!==0)return $<A.length&&I.push(A.slice($)),I},O=A=>{for(let I=0;I<A.length&&E<w;I++){let R=A[I];if(typeof R=="string"){let $=D(R);$&&(A.splice(I,1,...$),I+=$.length-1)}else if(typeof R.content=="string"){let $=D(R.content);$&&(R.content=$)}else Array.isArray(R.content)?O(R.content):O([R.content])}};O(S),E<w&&S.push(k()),x.content=S}return y.tokens})(l,s[1]));let c=iC(l),d=(function(g,m){let _=0;for(;_<g.length&&xL(g[_],m[_]);)_++;let b=g.length,y=m.length,v=Math.min(b,y)-_,x=0;for(;x<v;)if(x++,!xL(g[b-x],m[y-x])){x--;break}let C=_,E=b-x,k=m.slice(_,y-x);return{from:C,nodesForReplacement:k,to:E}})(r.getChildren(),c),{from:u,to:p,nodesForReplacement:h}=d;return!(u===p&&!h.length)&&(t.splice(u,p-u,h),!0)}))}),{onUpdate:()=>{oC.delete(o)},skipTransforms:!0}))}function iC(t,e){let n=[];for(let o of t)if(typeof o=="string"){let r=o.split(/(\n|\t)/),i=r.length;for(let s=0;s<i;s++){let a=r[s];a===`
|
|
127
127
|
`||a===`\r
|
|
128
128
|
`?n.push(zo()):a===" "?n.push(Ho()):a.length>0&&n.push(vh(a,e))}}else{let{content:r,alias:i}=o;typeof r=="string"?n.push(...iC([r],o.type==="prefix"&&typeof i=="string"?i:o.type)):Array.isArray(r)&&n.push(...iC(r,o.type==="unchanged"?void 0:o.type))}return n}function xL(t,e){return Pt(t)&&Pt(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||Kn(t)&&Kn(e)||Ze(t)&&Ze(e)}function Ws(t){if(!B(t))return!1;let e=t.anchor.getNode(),n=Go(e)?e:e.getParent(),o=t.focus.getNode(),r=Go(o)?o:o.getParent();return Go(n)&&n.is(r)}function IL(t){let e=t.getNodes(),n=[];if(e.length===1&&Go(e[0]))return n;let o=[];for(let r=0;r<e.length;r++){let i=e[r];Pt(i)||Kn(i)||Ze(i)||xh(169),Ze(i)?o.length>0&&(n.push(o),o=[]):o.push(i)}if(o.length>0){let r=t.isBackward()?t.anchor:t.focus,i=sr(o[0].getKey(),0,"text");r.is(i)||n.push(o)}return n}function vL(t){let e=z();if(!B(e)||!Ws(e))return!1;let n=IL(e),o=n.length;if(o===0&&e.isCollapsed())return t===jn&&e.insertNodes([Ho()]),!0;if(o===0&&t===jn&&e.getTextContent()===`
|
|
129
|
-
`){let r=Ho(),i=zo(),s=e.isBackward()?"previous":"next";return e.insertNodes([r,i]),xf(sO(gf(dO(r,"next",0),cr(Dn(i,"next"))),s)),!0}for(let r=0;r<o;r++){let i=n[r];if(i.length>0){let s=i[0];if(r===0&&(s=Wi(s)),t===jn){let a=Ho();if(s.insertBefore(a),r===0){let l=e.isBackward()?"focus":"anchor",c=sr(s.getKey(),0,"text");e[l].is(c)&&e[l].set(a.getKey(),0,"text")}}else Kn(s)&&s.remove()}}return!0}function CL(t,e){let n=z();if(!B(n))return!1;let{anchor:o,focus:r}=n,i=o.offset,s=r.offset,a=o.getNode(),l=r.getNode(),c=t===Ko;if(!Ws(n)||!Pt(a)&&!Kn(a)||!Pt(l)&&!Kn(l))return!1;if(!e.altKey){if(n.isCollapsed()){let b=a.getParentOrThrow();if(c&&i===0&&a.getPreviousSibling()===null){if(b.getPreviousSibling()===null)return b.selectPrevious(),e.preventDefault(),!0}else if(!c&&i===a.getTextContentSize()&&a.getNextSibling()===null&&b.getNextSibling()===null)return b.selectNext(),e.preventDefault(),!0}return!1}let d,u;if(a.isBefore(l)?(d=Wi(a),u=Gs(l)):(d=Wi(l),u=Gs(a)),d==null||u==null)return!1;let p=d.getNodesBetween(u);for(let b=0;b<p.length;b++){let y=p[b];if(!Pt(y)&&!Kn(y)&&!Ze(y))return!1}e.preventDefault(),e.stopPropagation();let h=c?d.getPreviousSibling():u.getNextSibling();if(!Ze(h))return!0;let g=c?h.getPreviousSibling():h.getNextSibling();if(g==null)return!0;let m=Pt(g)||Kn(g)||Ze(g)?c?Wi(g):Gs(g):null,_=m??g;return h.remove(),p.forEach((b=>b.remove())),t===Ko?(p.forEach((b=>_.insertBefore(b))),_.insertBefore(h)):(_.insertAfter(h),_=h,p.forEach((b=>{_.insertAfter(b),_=b}))),n.setTextNodeRange(a,i,l,s),!0}function EL(t,e){let n=z();if(!B(n))return!1;let{anchor:o,focus:r}=n,i=o.getNode(),s=r.getNode(),a=t===If;if(!Ws(n)||!Pt(i)&&!Kn(i)||!Pt(s)&&!Kn(s))return!1;if(a){let l=aC(s,r.offset);if(l!==null){let{node:c,offset:d}=l;Ze(c)?c.selectNext(0,0):n.setTextNodeRange(c,d,c,d)}else s.getParentOrThrow().selectStart()}else lC(s).select();return e.preventDefault(),e.stopPropagation(),!0}function $W(t,e){if(!t.hasNodes([Vi,Ys]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");e==null&&(e=DL);let n=[];return t._headless!==!0&&n.push(t.registerMutationListener(Vi,(o=>{t.update((()=>{for(let[r,i]of o)if(i!=="destroyed"){let s=Lt(r);s!==null&&BW(s,t)}}))}),{skipInitialization:!1})),n.push(t.registerNodeTransform(Vi,(o=>OL(o,t,e))),t.registerNodeTransform(Kt,(o=>yL(o,t,e))),t.registerNodeTransform(Ys,(o=>yL(o,t,e))),t.registerCommand(Ri,(o=>{let r=(function(i){let s=z();if(!B(s)||!Ws(s))return null;let a=i?To:jn,l=i?To:Ls,c=s.anchor,d=s.focus;if(c.is(d))return l;let u=IL(s);if(u.length!==1)return a;let p=u[0],h,g;p.length===0&&xh(285),s.isBackward()?(h=d,g=c):(h=c,g=d);let m=Wi(p[0]),_=Gs(p[0]),b=sr(m.getKey(),0,"text"),y=sr(_.getKey(),_.getTextContentSize(),"text");return h.isBefore(b)||y.isBefore(g)?a:b.isBefore(h)||g.isBefore(y)?l:a})(o.shiftKey);return r!==null&&(o.preventDefault(),t.dispatchCommand(r,void 0),!0)}),Re),t.registerCommand(Ls,(()=>!!Ws(z())&&(Uo([Ho()]),!0)),Re),t.registerCommand(jn,(o=>vL(jn)),Re),t.registerCommand(To,(o=>vL(To)),Re),t.registerCommand(Ko,(o=>{let r=z();if(!B(r))return!1;let{anchor:i}=r,s=i.getNode();return!!Ws(r)&&(r.isCollapsed()&&i.offset===0&&s.getPreviousSibling()===null&&Go(s.getParentOrThrow())?(o.preventDefault(),!0):CL(Ko,o))}),Re),t.registerCommand(Gr,(o=>{let r=z();if(!B(r))return!1;let{anchor:i}=r,s=i.getNode();return!!Ws(r)&&(r.isCollapsed()&&i.offset===s.getTextContentSize()&&s.getNextSibling()===null&&Go(s.getParentOrThrow())?(o.preventDefault(),!0):CL(Gr,o))}),Re),t.registerCommand(If,(o=>EL(If,o)),Re),t.registerCommand(hx,(o=>EL(hx,o)),Re)),He(...n)}var zW=Wi,HW=Gs,UW=lC,KW=aC;var mt=cC,vde=mt.$createCodeHighlightNode,vd=mt.$createCodeNode,Cde=mt.$getEndOfCodeInLine,Ede=mt.$getFirstCodeNodeOfLine,wde=mt.$getLastCodeNodeOfLine,Tde=mt.$getStartOfCodeInLine,AL=mt.$isCodeHighlightNode,dC=mt.$isCodeNode,Sde=mt.CODE_LANGUAGE_FRIENDLY_NAME_MAP,kde=mt.CODE_LANGUAGE_MAP,Nde=mt.CodeHighlightNode,ML=mt.CodeNode,Dde=mt.DEFAULT_CODE_LANGUAGE,Ode=mt.PrismTokenizer,Ide=mt.getCodeLanguages,Ade=mt.getDefaultCodeLanguage,Mde=mt.getEndOfCodeInLine,Lde=mt.getFirstCodeNodeOfLine,Rde=mt.getLanguageFriendlyName,Pde=mt.getLastCodeNodeOfLine,Fde=mt.getStartOfCodeInLine,Bde=mt.normalizeCodeLang,$de=mt.registerCodeHighlighting;yr();ke();var nn=Object.freeze({NORMAL:It?"\u2318+Opt+0":"Ctrl+Alt+0",HEADING1:It?"\u2318+Opt+1":"Ctrl+Alt+1",HEADING2:It?"\u2318+Opt+2":"Ctrl+Alt+2",HEADING3:It?"\u2318+Opt+3":"Ctrl+Alt+3",NUMBERED_LIST:It?"\u2318+Shift+7":"Ctrl+Shift+7",BULLET_LIST:It?"\u2318+Shift+8":"Ctrl+Shift+8",STRIKETHROUGH:It?"\u2318+Shift+X":"Ctrl+Shift+X",SUBSCRIPT:It?"\u2318+,":"Ctrl+,",SUPERSCRIPT:It?"\u2318+.":"Ctrl+.",INDENT:It?"\u2318+]":"Ctrl+]",OUTDENT:It?"\u2318+[":"Ctrl+[",CLEAR_FORMATTING:It?"\u2318+\\":"Ctrl+\\",REDO:It?"\u2318+Shift+Z":"Ctrl+Y",UNDO:It?"\u2318+Z":"Ctrl+Z",BOLD:It?"\u2318+B":"Ctrl+B",ITALIC:It?"\u2318+I":"Ctrl+I",UNDERLINE:It?"\u2318+U":"Ctrl+U",INSERT_LINK:It?"\u2318+K":"Ctrl+K"}),Yo={ctrlKey:!It,metaKey:It};function LL(t){let{code:e}=t;return(e==="Numpad0"||e==="Digit0")&&Wn(t,{...Yo,altKey:!0})}function RL(t){let{code:e}=t,n=e[e.length-1];return["1","2","3","4","5"].includes(n)&&Wn(t,{...Yo,altKey:!0})}function PL(t){let{code:e}=t;return(e==="Numpad7"||e==="Digit7")&&Wn(t,{...Yo,shiftKey:!0})}function FL(t){let{code:e}=t;return(e==="Numpad8"||e==="Digit8")&&Wn(t,{...Yo,shiftKey:!0})}function BL(t){let{code:e}=t;return e==="KeyX"&&Wn(t,{...Yo,shiftKey:!0})}function $L(t){let{code:e}=t;return e==="BracketRight"&&Wn(t,Yo)}function zL(t){let{code:e}=t;return e==="BracketLeft"&&Wn(t,Yo)}function HL(t){let{code:e}=t;return e==="Comma"&&Wn(t,Yo)}function UL(t){let{code:e}=t;return e==="Period"&&Wn(t,Yo)}function KL(t){let{code:e}=t;return e==="Backslash"&&Wn(t,Yo)}function jL(t){let{code:e}=t;return e==="KeyK"&&Wn(t,Yo)}var qs=t=>{t.update(()=>{let e=z();Lf(e,()=>ge())})},Gi=(t,e,n)=>{e!==n&&t.update(()=>{let o=z();Lf(o,()=>zs(n))})},Ch=(t,e)=>{e!=="bullet"?t.dispatchCommand(JI,void 0):qs(t)},Eh=(t,e)=>{console.log("formatNumberedList"),e!=="number"?t.dispatchCommand(qI,void 0):qs(t)},Sl=t=>{t.update(()=>{let e=z();if(B(e)){let n=e.anchor,o=e.focus,r=e.getNodes(),i=e.extract();if(n.key===o.key&&n.offset===o.offset)return;r.forEach((s,a)=>{if(te(s)){let l=s;a===0&&n.offset!==0&&(l=l.splitText(n.offset)[1]||l),a===r.length-1&&(l=l.splitText(o.offset)[0]||l);let c=i[0];r.length===1&&te(c)&&(l=c),l.__style!==""&&l.setStyle(""),l.__format!==0&&l.setFormat(0);let d=Ps(l);d.__format!==0&&d.setFormat(""),d.__indent!==0&&d.setIndent(0)}else qr(s)||Jr(s)?s.replace(ge(),!0):lL(s)&&s.setFormat("")})}})},VL=(t,e)=>{e!=="quote"?t.update(()=>{let n=z();Lf(n,()=>Hs())}):qs(t)};yr();var jW=new Set(["http:","https:","mailto:","sms:","tel:"]);function WL(t){try{let e=new URL(t);if(!jW.has(e.protocol))return"about:blank"}catch{return t}return t}var Qde=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function uo(t){return t?"active dropdown-item-active":""}function _r(t){let{blockType:e}=t;return e==="paragraph"?f(_E,{size:16}):e==="h1"?f(OE,{size:16}):e==="h2"?f(IE,{size:16}):e==="h3"?f(AE,{size:16}):e==="h4"?f(ME,{size:16}):e==="h5"?f(LE,{size:16}):e==="number"?f(HE,{size:16}):e==="bullet"?f(UE,{size:16}):e==="quote"?f(JE,{size:16}):null}function VW(t){let{editor:e,blockType:n}=t;return f(G,{control:f(Z,{className:xe("LexicalEditor__toolbar__dropdown","LexicalEditor__toolbar__blockFormatDropdown"),variant:"default",compact:!0,leftIcon:f(_r,{blockType:n}),rightIcon:f(go,{size:16}),children:hh[n]}),children:[f(G.Item,{icon:f(_r,{blockType:"paragraph"}),className:uo(n==="paragraph"),onClick:()=>qs(e),children:"Normal"}),f(G.Item,{icon:f(_r,{blockType:"bullet"}),className:uo(n==="bullet"),onClick:()=>Ch(e,n),children:"Bullet List"}),f(G.Item,{icon:f(_r,{blockType:"number"}),className:uo(n==="number"),onClick:()=>Eh(e,n),children:"Numbered List"}),f(G.Item,{icon:f(_r,{blockType:"h1"}),className:uo(n==="h1"),onClick:()=>Gi(e,n,"h1"),children:"Heading 1"}),f(G.Item,{icon:f(_r,{blockType:"h2"}),className:uo(n==="h2"),onClick:()=>Gi(e,n,"h2"),children:"Heading 2"}),f(G.Item,{icon:f(_r,{blockType:"h3"}),className:uo(n==="h3"),onClick:()=>Gi(e,n,"h3"),children:"Heading 3"}),f(G.Item,{icon:f(_r,{blockType:"h4"}),className:uo(n==="h4"),onClick:()=>Gi(e,n,"h4"),children:"Heading 4"}),f(G.Item,{icon:f(_r,{blockType:"h5"}),className:uo(n==="h5"),onClick:()=>Gi(e,n,"h5"),children:"Heading 5"}),f(G.Item,{icon:f(_r,{blockType:"quote"}),className:uo(n==="quote"),onClick:()=>VL(e,n),children:"Quote"})]})}function Cd(){return f("div",{className:"divider"})}function WW(t){let{editor:e,isStrikethrough:n,isSuperscript:o,isSubscript:r,isCode:i}=t;return f(G,{styles:{body:{minWidth:"240px"}},control:f(we,{className:xe("LexicalEditor__toolbar__actionIcon",(n||o||r||i)&&"LexicalEditor__toolbar__actionIcon--active"),label:"More formatting",position:"top",withArrow:!0,children:f(Ae,{variant:"default",title:"More formatting",children:f(go,{size:16})})}),children:[f(G.Item,{icon:f(tu,{size:16}),className:uo(n),onClick:()=>{e.dispatchCommand(at,"strikethrough")},children:["Strikethrough (",nn.STRIKETHROUGH,")"]}),f(G.Item,{icon:f(ou,{size:16}),className:uo(o),onClick:()=>{e.dispatchCommand(at,"superscript")},children:["Superscript (",nn.SUPERSCRIPT,")"]}),f(G.Item,{icon:f(nu,{size:16}),className:uo(r),onClick:()=>{e.dispatchCommand(at,"subscript")},children:["Subscript (",nn.SUBSCRIPT,")"]}),f(G.Item,{icon:f(Wd,{size:16}),className:uo(i),onClick:()=>{e.dispatchCommand(at,"code")},children:"Code"})]})}function GL(t){let{editor:e,blockComponents:n,inlineComponents:o,activeEditor:r,setActiveEditor:i,setIsLinkEditMode:s,variant:a="document",onInsertBlockComponent:l,onInsertInlineComponent:c}=t,[d,u]=L(()=>e.isEditable()),{toolbarState:p,updateToolbarState:h}=gh(),g=De(()=>{let x=z();if(B(x)){if(r!==e&&SI(r)){let O=r.getRootElement();h("isImageCaption",!!O?.parentElement?.classList.contains("image-caption-container"))}else h("isImageCaption",!1);let C=x.anchor.getNode(),E=C.getKey()==="root"?C:ue(C,O=>{let A=O.getParent();return A!==null&&Ht(A)});E===null&&(E=C.getTopLevelElementOrThrow());let k=E.getKey(),T=r.getElementByKey(k);h("isRTL",rI(x));let w=ei(x),S=w.getParent(),N=Qe(S)||Qe(w);if(h("isLink",N),h("rootType","root"),T!==null)if(On(E)){let O=Bf(C,hr),A=O?O.getListType():E.getListType();h("blockType",A)}else{let O=qr(E)?E.getTag():E.getType();O in hh&&h("blockType",O)}let D;Qe(S)&&(D=ue(w,O=>Y(O)&&!O.isInline())),h("elementFormat",Y(D)?D.getFormatType():Y(w)?w.getFormatType():S?.getFormatType()||"left")}B(x)&&(h("isBold",x.hasFormat("bold")),h("isItalic",x.hasFormat("italic")),h("isUnderline",x.hasFormat("underline")),h("isStrikethrough",x.hasFormat("strikethrough")),h("isSuperscript",x.hasFormat("superscript")),h("isSubscript",x.hasFormat("subscript")),h("isCode",x.hasFormat("code")))},[r,e,h]);F(()=>e.registerCommand(gn,(x,C)=>(i(C),g(),!1),Ot),[e,g,i]),F(()=>{r.getEditorState().read(()=>{g()})},[r,g]),F(()=>He(e.registerEditableListener(x=>{u(x)}),r.registerUpdateListener(({editorState:x})=>{x.read(()=>{g()})}),r.registerCommand(Ms,x=>(h("canUndo",x),!1),Ot),r.registerCommand(As,x=>(h("canRedo",x),!1),Ot)),[g,r,e,h]);let m=De(()=>{p.isLink?(s(!1),r.dispatchCommand(Yn,null)):(s(!0),r.dispatchCommand(Yn,WL("https://")))},[r,s,p.isLink]),_=X(()=>n?[...n].sort((x,C)=>{let E=x.label||x.name,k=C.label||C.name;return E.localeCompare(k)}):[],[n]),b=X(()=>o?[...o].sort((x,C)=>{let E=x.label||x.name,k=C.label||C.name;return E.localeCompare(k)}):[],[o]),y=x=>{switch(x){case"image":return f(WE,{size:16});case"html":return f(bE,{size:16});default:break}return f(ew,{size:16})},v=a==="comment";return f("div",{className:xe("LexicalEditor__toolbar",v&&"LexicalEditor__toolbar--comment"),children:[!v&&p.blockType in hh&&r===e&&f(Ne,{children:[f(VW,{disabled:!d,blockType:p.blockType,rootType:p.rootType,editor:r}),f(Cd,{})]}),f(Ne,{children:[f("div",{className:"LexicalEditor__toolbar__group",children:[f(An,{tooltip:`Bold (${nn.BOLD})`,active:p.isBold,onClick:()=>{r.dispatchCommand(at,"bold")},children:f(Kd,{size:16})}),f(An,{tooltip:`Italic (${nn.ITALIC})`,active:p.isItalic,onClick:()=>{r.dispatchCommand(at,"italic")},children:f(qd,{size:16})}),f(An,{tooltip:`Underline (${nn.UNDERLINE})`,active:p.isUnderline,onClick:()=>{r.dispatchCommand(at,"underline")},children:f(iu,{size:16})}),f(WW,{editor:r,isStrikethrough:p.isStrikethrough,isSuperscript:p.isSuperscript,isSubscript:p.isSubscript,isCode:p.isCode})]}),f(Cd,{}),f("div",{className:"LexicalEditor__toolbar__group",children:f(An,{tooltip:`Insert link (${nn.INSERT_LINK})`,active:p.isLink,onClick:m,children:f(Jd,{size:16})})}),f(Cd,{}),f(An,{tooltip:`Clear formatting (${nn.CLEAR_FORMATTING})`,onClick:()=>{Sl(r)},children:f(jd,{size:16})}),f(Cd,{}),!v&&f(Ne,{children:[f(G,{control:f(Z,{className:xe("LexicalEditor__toolbar__dropdown","LexicalEditor__toolbar__insertDropdown"),variant:"default",compact:!0,leftIcon:f(qE,{size:16}),rightIcon:f(go,{size:16}),children:"Components"}),children:[f(G.Label,{children:"Insert"}),f(G.Item,{icon:f(ru,{size:16}),onClick:()=>{r.dispatchCommand(OM,{columns:"3",rows:"3"})},children:"Table"}),f(G.Item,{icon:f(QE,{size:16}),onClick:()=>{r.dispatchCommand(Xf,void 0)},children:"Horizontal Rule"}),b.length>0&&f(Ne,{children:[f(G.Label,{children:"Inline Components"}),b.map(x=>f(G.Item,{icon:f(yE,{size:16}),onClick:()=>c?.(x.name),children:x.label||x.name},x.name))]}),_.length>0&&f(Ne,{children:[f(G.Label,{children:"Block Components"}),_.map(x=>f(G.Item,{icon:y(x.name),onClick:()=>l?.(x.name),children:x.label||x.name},x.name))]})]}),f(Cd,{})]})]})]})}function An(t){return f(we,{className:xe("LexicalEditor__toolbar__actionIcon",t.active&&"LexicalEditor__toolbar__actionIcon--active"),label:t.tooltip,position:"top",withArrow:!0,children:f(Ae,{variant:t.variant||"default",onClick:t.onClick,title:t.tooltip,children:t.children})})}var GW=12,YW=5;function qW(t){let{editor:e,anchorElem:n,isLink:o,isBold:r,isCode:i,isItalic:s,isUnderline:a,isStrikethrough:l,isSubscript:c,isSuperscript:d,setIsLinkEditMode:u}=t,p=J(null),h=De(()=>{o?(u(!1),e.dispatchCommand(Yn,null)):(u(!0),e.dispatchCommand(Yn,""))},[e,o,u]);function g(b){if(p?.current&&(b.buttons===1||b.buttons===3)&&p.current.style.pointerEvents!=="none"){let y=b.clientX,v=b.clientY,x=document.elementFromPoint(y,v);p.current.contains(x)||(p.current.style.pointerEvents="none")}}function m(){p?.current&&p.current.style.pointerEvents!=="auto"&&(p.current.style.pointerEvents="auto")}F(()=>{if(p?.current)return document.addEventListener("mousemove",g),document.addEventListener("mouseup",m),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",m)}},[p]);let _=De(()=>{let b=z(),y=p.current,v=ao(e._window);if(y===null)return;let x=e.getRootElement();if(b!==null&&v!==null&&!v.isCollapsed&&x!==null&&x.contains(v.anchorNode)){let C=pL(v,x);XW(C,y,n,o)}},[e,n,o]);return F(()=>{let b=n.parentElement,y=()=>{e.getEditorState().read(()=>{_()})};return window.addEventListener("resize",y),b&&b.addEventListener("scroll",y),()=>{window.removeEventListener("resize",y),b&&b.removeEventListener("scroll",y)}},[e,_,n]),F(()=>(e.getEditorState().read(()=>{_()}),He(e.registerUpdateListener(({editorState:b})=>{b.read(()=>{_()})}),e.registerCommand(gn,()=>(_(),!1),Re))),[e,_]),f("div",{ref:p,className:"LexicalEditor__floatingToolbar",children:e.isEditable()&&f(Ne,{children:[f(An,{variant:"hover",tooltip:`Bold (${nn.BOLD})`,active:r,onClick:()=>{e.dispatchCommand(at,"bold")},children:f(Kd,{size:16})}),f(An,{variant:"hover",tooltip:`Italic (${nn.ITALIC})`,active:s,onClick:()=>{e.dispatchCommand(at,"italic")},children:f(qd,{size:16})}),f(An,{variant:"hover",tooltip:`Underline (${nn.UNDERLINE})`,active:a,onClick:()=>{e.dispatchCommand(at,"underline")},children:f(iu,{size:16})}),f(An,{variant:"hover",tooltip:`Strikethrough (${nn.STRIKETHROUGH})`,active:l,onClick:()=>{e.dispatchCommand(at,"strikethrough")},children:f(tu,{size:16})}),f(An,{variant:"hover",tooltip:`Superscript (${nn.SUPERSCRIPT})`,active:d,onClick:()=>{e.dispatchCommand(at,"superscript")},children:f(ou,{size:16})}),f(An,{variant:"hover",tooltip:`Subscript (${nn.SUBSCRIPT})`,active:c,onClick:()=>{e.dispatchCommand(at,"subscript")},children:f(nu,{size:16})}),f(An,{variant:"hover",tooltip:"Code",active:i,onClick:()=>{e.dispatchCommand(at,"code")},children:f(Wd,{size:16})}),f(An,{variant:"hover",tooltip:`Insert link (${nn.INSERT_LINK})`,active:o,onClick:h,children:f(Jd,{size:16})}),f(An,{variant:"hover",tooltip:`Clear formatting (${nn.CLEAR_FORMATTING})`,onClick:()=>{Sl(e)},children:f(jd,{size:16})})]})})}function JW(t,e,n){let[o,r]=L(!1),[i,s]=L(!1),[a,l]=L(!1),[c,d]=L(!1),[u,p]=L(!1),[h,g]=L(!1),[m,_]=L(!1),[b,y]=L(!1),[v,x]=L(!1),C=De(()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let E=z(),k=ao(t._window),T=t.getRootElement();if(k!==null&&(!B(E)||T===null||!T.contains(k.anchorNode))){r(!1);return}if(!B(E))return;let w=ei(E);l(E.hasFormat("bold")),d(E.hasFormat("code")),p(E.hasFormat("italic")),y(E.hasFormat("underline")),g(E.hasFormat("strikethrough")),_(E.hasFormat("subscript")),x(E.hasFormat("superscript"));let S=w.getParent();Qe(S)||Qe(w)?s(!0):s(!1),!AL(E.anchor.getNode())&&E.getTextContent()!==""?r(te(w)||en(w)):r(!1);let N=E.getTextContent().replace(/\n/g,"");if(!E.isCollapsed()&&N===""){r(!1);return}})},[t]);return F(()=>(document.addEventListener("selectionchange",C),()=>{document.removeEventListener("selectionchange",C)}),[C]),F(()=>He(t.registerUpdateListener(()=>{C()}),t.registerRootListener(()=>{t.getRootElement()===null&&r(!1)})),[t,C]),o?si(f(qW,{editor:t,anchorElem:e,isLink:i,isBold:a,isCode:c,isItalic:u,isStrikethrough:h,isSubscript:m,isSuperscript:v,isUnderline:b,setIsLinkEditMode:n}),e):null}function YL(t){let{anchorElem:e=document.body,setIsLinkEditMode:n}=t,[o]=ve();return JW(o,e,n)}function XW(t,e,n,o=!1,r=GW,i=YW){let s=n.parentElement;if(t===null||!s){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let a=e.getBoundingClientRect(),l=n.getBoundingClientRect(),c=s.getBoundingClientRect(),d=t.top-a.height-r,u=t.left-i,p=window.getSelection();if(p&&p.rangeCount>0){let g=p.getRangeAt(0).startContainer;if(g.nodeType===Node.ELEMENT_NODE||g.parentElement){let m=g.nodeType===Node.ELEMENT_NODE?g:g.parentElement,_=window.getComputedStyle(m).textAlign;(_==="right"||_==="end")&&(u=t.right-a.width+i)}}d<c.top&&(d+=a.height+t.height+r*(o?9:2)),u+a.width>c.right&&(u=c.right-a.width-i),u<c.left&&(u=c.left+i),d-=l.top,u-=l.left,e.style.opacity="1",e.style.transform=`translate(${u}px, ${d}px)`}ke();function qL(){let[t]=ve();F(()=>t.registerCommand(Pi,n=>{let{clipboardData:o}=n;if(!o)return!1;let i=Array.from(o.files).find(s=>s.type.startsWith("image/"));return i?(n.preventDefault(),e(i),!0):!1},Re),[t]);let e=async n=>{let o=URL.createObjectURL(n),r=null;t.update(()=>{let i=Vs("image",{file:{src:o,width:0,height:0},loading:!0}),s=z();if(B(s)){Uo([i]);let a=ge();i.insertAfter(a),a.select()}r=i.getKey()});try{let i=await ai(n);t.update(()=>{if(r){let s=Lt(r);Qr(s)&&s.setBlockData({file:i,loading:!1})}})}catch(i){console.error("Failed to upload image",i),ae({type:"error",message:"Failed to upload image"})}};return null}var mC={};$e(mC,{$convertFromMarkdownString:()=>dG,$convertToMarkdownString:()=>uG,BOLD_ITALIC_STAR:()=>hR,BOLD_ITALIC_UNDERSCORE:()=>gR,BOLD_STAR:()=>mR,BOLD_UNDERSCORE:()=>_R,CHECK_LIST:()=>cG,CODE:()=>cR,ELEMENT_TRANSFORMERS:()=>CR,HEADING:()=>aR,HIGHLIGHT:()=>fR,INLINE_CODE:()=>pR,ITALIC_STAR:()=>yR,ITALIC_UNDERSCORE:()=>xR,LINK:()=>vR,MULTILINE_ELEMENT_TRANSFORMERS:()=>ER,ORDERED_LIST:()=>uR,QUOTE:()=>lR,STRIKETHROUGH:()=>bR,TEXT_FORMAT_TRANSFORMERS:()=>wR,TEXT_MATCH_TRANSFORMERS:()=>TR,TRANSFORMERS:()=>Nh,UNORDERED_LIST:()=>dR,registerMarkdownShortcuts:()=>iG});function uC(t,e){let n={};for(let o of t){let r=e(o);r&&(n[r]?n[r].push(o):n[r]=[o])}return n}function hC(t){let e=uC(t,(n=>n.type));return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}var Th=/[!-/:-@[-`{-~\s]/,ZW=/^\s{0,3}$/;function pC(t){if(!en(t))return!1;let e=t.getFirstChild();return e==null||t.getChildrenSize()===1&&te(e)&&ZW.test(e.getTextContent())}function QW(t,e,n,o){for(let r of e){if(!r.export)continue;let i=r.export(t,(s=>Sh(s,n,o)));if(i!=null)return i}return Y(t)?Sh(t,n,o):Un(t)?t.getTextContent():null}function Sh(t,e,n,o,r){let i=[],s=t.getChildren();o||(o=[]),r||(r=[]);e:for(let a of s){for(let l of n){if(!l.export)continue;let c=l.export(a,(d=>Sh(d,e,n,o,[...r,...o])),((d,u)=>JL(d,u,e,o,r)));if(c!=null){i.push(c);continue e}}Ze(a)?i.push(`
|
|
129
|
+
`){let r=Ho(),i=zo(),s=e.isBackward()?"previous":"next";return e.insertNodes([r,i]),xf(sO(gf(dO(r,"next",0),cr(Dn(i,"next"))),s)),!0}for(let r=0;r<o;r++){let i=n[r];if(i.length>0){let s=i[0];if(r===0&&(s=Wi(s)),t===jn){let a=Ho();if(s.insertBefore(a),r===0){let l=e.isBackward()?"focus":"anchor",c=sr(s.getKey(),0,"text");e[l].is(c)&&e[l].set(a.getKey(),0,"text")}}else Kn(s)&&s.remove()}}return!0}function CL(t,e){let n=z();if(!B(n))return!1;let{anchor:o,focus:r}=n,i=o.offset,s=r.offset,a=o.getNode(),l=r.getNode(),c=t===Ko;if(!Ws(n)||!Pt(a)&&!Kn(a)||!Pt(l)&&!Kn(l))return!1;if(!e.altKey){if(n.isCollapsed()){let b=a.getParentOrThrow();if(c&&i===0&&a.getPreviousSibling()===null){if(b.getPreviousSibling()===null)return b.selectPrevious(),e.preventDefault(),!0}else if(!c&&i===a.getTextContentSize()&&a.getNextSibling()===null&&b.getNextSibling()===null)return b.selectNext(),e.preventDefault(),!0}return!1}let d,u;if(a.isBefore(l)?(d=Wi(a),u=Gs(l)):(d=Wi(l),u=Gs(a)),d==null||u==null)return!1;let p=d.getNodesBetween(u);for(let b=0;b<p.length;b++){let y=p[b];if(!Pt(y)&&!Kn(y)&&!Ze(y))return!1}e.preventDefault(),e.stopPropagation();let h=c?d.getPreviousSibling():u.getNextSibling();if(!Ze(h))return!0;let g=c?h.getPreviousSibling():h.getNextSibling();if(g==null)return!0;let m=Pt(g)||Kn(g)||Ze(g)?c?Wi(g):Gs(g):null,_=m??g;return h.remove(),p.forEach((b=>b.remove())),t===Ko?(p.forEach((b=>_.insertBefore(b))),_.insertBefore(h)):(_.insertAfter(h),_=h,p.forEach((b=>{_.insertAfter(b),_=b}))),n.setTextNodeRange(a,i,l,s),!0}function EL(t,e){let n=z();if(!B(n))return!1;let{anchor:o,focus:r}=n,i=o.getNode(),s=r.getNode(),a=t===If;if(!Ws(n)||!Pt(i)&&!Kn(i)||!Pt(s)&&!Kn(s))return!1;if(a){let l=aC(s,r.offset);if(l!==null){let{node:c,offset:d}=l;Ze(c)?c.selectNext(0,0):n.setTextNodeRange(c,d,c,d)}else s.getParentOrThrow().selectStart()}else lC(s).select();return e.preventDefault(),e.stopPropagation(),!0}function $W(t,e){if(!t.hasNodes([Vi,Ys]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");e==null&&(e=DL);let n=[];return t._headless!==!0&&n.push(t.registerMutationListener(Vi,(o=>{t.update((()=>{for(let[r,i]of o)if(i!=="destroyed"){let s=Lt(r);s!==null&&BW(s,t)}}))}),{skipInitialization:!1})),n.push(t.registerNodeTransform(Vi,(o=>OL(o,t,e))),t.registerNodeTransform(Kt,(o=>yL(o,t,e))),t.registerNodeTransform(Ys,(o=>yL(o,t,e))),t.registerCommand(Ri,(o=>{let r=(function(i){let s=z();if(!B(s)||!Ws(s))return null;let a=i?To:jn,l=i?To:Ls,c=s.anchor,d=s.focus;if(c.is(d))return l;let u=IL(s);if(u.length!==1)return a;let p=u[0],h,g;p.length===0&&xh(285),s.isBackward()?(h=d,g=c):(h=c,g=d);let m=Wi(p[0]),_=Gs(p[0]),b=sr(m.getKey(),0,"text"),y=sr(_.getKey(),_.getTextContentSize(),"text");return h.isBefore(b)||y.isBefore(g)?a:b.isBefore(h)||g.isBefore(y)?l:a})(o.shiftKey);return r!==null&&(o.preventDefault(),t.dispatchCommand(r,void 0),!0)}),Re),t.registerCommand(Ls,(()=>!!Ws(z())&&(Uo([Ho()]),!0)),Re),t.registerCommand(jn,(o=>vL(jn)),Re),t.registerCommand(To,(o=>vL(To)),Re),t.registerCommand(Ko,(o=>{let r=z();if(!B(r))return!1;let{anchor:i}=r,s=i.getNode();return!!Ws(r)&&(r.isCollapsed()&&i.offset===0&&s.getPreviousSibling()===null&&Go(s.getParentOrThrow())?(o.preventDefault(),!0):CL(Ko,o))}),Re),t.registerCommand(Gr,(o=>{let r=z();if(!B(r))return!1;let{anchor:i}=r,s=i.getNode();return!!Ws(r)&&(r.isCollapsed()&&i.offset===s.getTextContentSize()&&s.getNextSibling()===null&&Go(s.getParentOrThrow())?(o.preventDefault(),!0):CL(Gr,o))}),Re),t.registerCommand(If,(o=>EL(If,o)),Re),t.registerCommand(hx,(o=>EL(hx,o)),Re)),He(...n)}var zW=Wi,HW=Gs,UW=lC,KW=aC;var mt=cC,vde=mt.$createCodeHighlightNode,vd=mt.$createCodeNode,Cde=mt.$getEndOfCodeInLine,Ede=mt.$getFirstCodeNodeOfLine,wde=mt.$getLastCodeNodeOfLine,Tde=mt.$getStartOfCodeInLine,AL=mt.$isCodeHighlightNode,dC=mt.$isCodeNode,Sde=mt.CODE_LANGUAGE_FRIENDLY_NAME_MAP,kde=mt.CODE_LANGUAGE_MAP,Nde=mt.CodeHighlightNode,ML=mt.CodeNode,Dde=mt.DEFAULT_CODE_LANGUAGE,Ode=mt.PrismTokenizer,Ide=mt.getCodeLanguages,Ade=mt.getDefaultCodeLanguage,Mde=mt.getEndOfCodeInLine,Lde=mt.getFirstCodeNodeOfLine,Rde=mt.getLanguageFriendlyName,Pde=mt.getLastCodeNodeOfLine,Fde=mt.getStartOfCodeInLine,Bde=mt.normalizeCodeLang,$de=mt.registerCodeHighlighting;yr();ke();var nn=Object.freeze({NORMAL:It?"\u2318+Opt+0":"Ctrl+Alt+0",HEADING1:It?"\u2318+Opt+1":"Ctrl+Alt+1",HEADING2:It?"\u2318+Opt+2":"Ctrl+Alt+2",HEADING3:It?"\u2318+Opt+3":"Ctrl+Alt+3",NUMBERED_LIST:It?"\u2318+Shift+7":"Ctrl+Shift+7",BULLET_LIST:It?"\u2318+Shift+8":"Ctrl+Shift+8",STRIKETHROUGH:It?"\u2318+Shift+X":"Ctrl+Shift+X",SUBSCRIPT:It?"\u2318+,":"Ctrl+,",SUPERSCRIPT:It?"\u2318+.":"Ctrl+.",INDENT:It?"\u2318+]":"Ctrl+]",OUTDENT:It?"\u2318+[":"Ctrl+[",CLEAR_FORMATTING:It?"\u2318+\\":"Ctrl+\\",REDO:It?"\u2318+Shift+Z":"Ctrl+Y",UNDO:It?"\u2318+Z":"Ctrl+Z",BOLD:It?"\u2318+B":"Ctrl+B",ITALIC:It?"\u2318+I":"Ctrl+I",UNDERLINE:It?"\u2318+U":"Ctrl+U",INSERT_LINK:It?"\u2318+K":"Ctrl+K"}),Yo={ctrlKey:!It,metaKey:It};function LL(t){let{code:e}=t;return(e==="Numpad0"||e==="Digit0")&&Wn(t,{...Yo,altKey:!0})}function RL(t){let{code:e}=t,n=e[e.length-1];return["1","2","3","4","5"].includes(n)&&Wn(t,{...Yo,altKey:!0})}function PL(t){let{code:e}=t;return(e==="Numpad7"||e==="Digit7")&&Wn(t,{...Yo,shiftKey:!0})}function FL(t){let{code:e}=t;return(e==="Numpad8"||e==="Digit8")&&Wn(t,{...Yo,shiftKey:!0})}function BL(t){let{code:e}=t;return e==="KeyX"&&Wn(t,{...Yo,shiftKey:!0})}function $L(t){let{code:e}=t;return e==="BracketRight"&&Wn(t,Yo)}function zL(t){let{code:e}=t;return e==="BracketLeft"&&Wn(t,Yo)}function HL(t){let{code:e}=t;return e==="Comma"&&Wn(t,Yo)}function UL(t){let{code:e}=t;return e==="Period"&&Wn(t,Yo)}function KL(t){let{code:e}=t;return e==="Backslash"&&Wn(t,Yo)}function jL(t){let{code:e}=t;return e==="KeyK"&&Wn(t,Yo)}var qs=t=>{t.update(()=>{let e=z();Lf(e,()=>ge())})},Gi=(t,e,n)=>{e!==n&&t.update(()=>{let o=z();Lf(o,()=>zs(n))})},Ch=(t,e)=>{e!=="bullet"?t.dispatchCommand(JI,void 0):qs(t)},Eh=(t,e)=>{console.log("formatNumberedList"),e!=="number"?t.dispatchCommand(qI,void 0):qs(t)},Sl=t=>{t.update(()=>{let e=z();if(B(e)){let n=e.anchor,o=e.focus,r=e.getNodes(),i=e.extract();if(n.key===o.key&&n.offset===o.offset)return;r.forEach((s,a)=>{if(te(s)){let l=s;a===0&&n.offset!==0&&(l=l.splitText(n.offset)[1]||l),a===r.length-1&&(l=l.splitText(o.offset)[0]||l);let c=i[0];r.length===1&&te(c)&&(l=c),l.__style!==""&&l.setStyle(""),l.__format!==0&&l.setFormat(0);let d=Ps(l);d.__format!==0&&d.setFormat(""),d.__indent!==0&&d.setIndent(0)}else qr(s)||Jr(s)?s.replace(ge(),!0):lL(s)&&s.setFormat("")})}})},VL=(t,e)=>{e!=="quote"?t.update(()=>{let n=z();Lf(n,()=>Hs())}):qs(t)};yr();var jW=new Set(["http:","https:","mailto:","sms:","tel:"]);function WL(t){try{let e=new URL(t);if(!jW.has(e.protocol))return"about:blank"}catch{return t}return t}var Qde=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function uo(t){return t?"active dropdown-item-active":""}function _r(t){let{blockType:e}=t;return e==="paragraph"?f(pE,{size:16}):e==="h1"?f(TE,{size:16}):e==="h2"?f(SE,{size:16}):e==="h3"?f(kE,{size:16}):e==="h4"?f(NE,{size:16}):e==="h5"?f(DE,{size:16}):e==="number"?f(PE,{size:16}):e==="bullet"?f(FE,{size:16}):e==="quote"?f(VE,{size:16}):null}function VW(t){let{editor:e,blockType:n}=t;return f(G,{control:f(Z,{className:xe("LexicalEditor__toolbar__dropdown","LexicalEditor__toolbar__blockFormatDropdown"),variant:"default",compact:!0,leftIcon:f(_r,{blockType:n}),rightIcon:f(go,{size:16}),children:hh[n]}),children:[f(G.Item,{icon:f(_r,{blockType:"paragraph"}),className:uo(n==="paragraph"),onClick:()=>qs(e),children:"Normal"}),f(G.Item,{icon:f(_r,{blockType:"bullet"}),className:uo(n==="bullet"),onClick:()=>Ch(e,n),children:"Bullet List"}),f(G.Item,{icon:f(_r,{blockType:"number"}),className:uo(n==="number"),onClick:()=>Eh(e,n),children:"Numbered List"}),f(G.Item,{icon:f(_r,{blockType:"h1"}),className:uo(n==="h1"),onClick:()=>Gi(e,n,"h1"),children:"Heading 1"}),f(G.Item,{icon:f(_r,{blockType:"h2"}),className:uo(n==="h2"),onClick:()=>Gi(e,n,"h2"),children:"Heading 2"}),f(G.Item,{icon:f(_r,{blockType:"h3"}),className:uo(n==="h3"),onClick:()=>Gi(e,n,"h3"),children:"Heading 3"}),f(G.Item,{icon:f(_r,{blockType:"h4"}),className:uo(n==="h4"),onClick:()=>Gi(e,n,"h4"),children:"Heading 4"}),f(G.Item,{icon:f(_r,{blockType:"h5"}),className:uo(n==="h5"),onClick:()=>Gi(e,n,"h5"),children:"Heading 5"}),f(G.Item,{icon:f(_r,{blockType:"quote"}),className:uo(n==="quote"),onClick:()=>VL(e,n),children:"Quote"})]})}function Cd(){return f("div",{className:"divider"})}function WW(t){let{editor:e,isStrikethrough:n,isSuperscript:o,isSubscript:r,isCode:i}=t;return f(G,{styles:{body:{minWidth:"240px"}},control:f(we,{className:xe("LexicalEditor__toolbar__actionIcon",(n||o||r||i)&&"LexicalEditor__toolbar__actionIcon--active"),label:"More formatting",position:"top",withArrow:!0,children:f(Ae,{variant:"default",title:"More formatting",children:f(go,{size:16})})}),children:[f(G.Item,{icon:f(eu,{size:16}),className:uo(n),onClick:()=>{e.dispatchCommand(at,"strikethrough")},children:["Strikethrough (",nn.STRIKETHROUGH,")"]}),f(G.Item,{icon:f(nu,{size:16}),className:uo(o),onClick:()=>{e.dispatchCommand(at,"superscript")},children:["Superscript (",nn.SUPERSCRIPT,")"]}),f(G.Item,{icon:f(tu,{size:16}),className:uo(r),onClick:()=>{e.dispatchCommand(at,"subscript")},children:["Subscript (",nn.SUBSCRIPT,")"]}),f(G.Item,{icon:f(Vd,{size:16}),className:uo(i),onClick:()=>{e.dispatchCommand(at,"code")},children:"Code"})]})}function GL(t){let{editor:e,blockComponents:n,inlineComponents:o,activeEditor:r,setActiveEditor:i,setIsLinkEditMode:s,variant:a="document",onInsertBlockComponent:l,onInsertInlineComponent:c}=t,[d,u]=L(()=>e.isEditable()),{toolbarState:p,updateToolbarState:h}=gh(),g=De(()=>{let x=z();if(B(x)){if(r!==e&&SI(r)){let O=r.getRootElement();h("isImageCaption",!!O?.parentElement?.classList.contains("image-caption-container"))}else h("isImageCaption",!1);let C=x.anchor.getNode(),E=C.getKey()==="root"?C:ue(C,O=>{let A=O.getParent();return A!==null&&Ht(A)});E===null&&(E=C.getTopLevelElementOrThrow());let k=E.getKey(),T=r.getElementByKey(k);h("isRTL",rI(x));let w=ei(x),S=w.getParent(),N=Qe(S)||Qe(w);if(h("isLink",N),h("rootType","root"),T!==null)if(On(E)){let O=Bf(C,hr),A=O?O.getListType():E.getListType();h("blockType",A)}else{let O=qr(E)?E.getTag():E.getType();O in hh&&h("blockType",O)}let D;Qe(S)&&(D=ue(w,O=>Y(O)&&!O.isInline())),h("elementFormat",Y(D)?D.getFormatType():Y(w)?w.getFormatType():S?.getFormatType()||"left")}B(x)&&(h("isBold",x.hasFormat("bold")),h("isItalic",x.hasFormat("italic")),h("isUnderline",x.hasFormat("underline")),h("isStrikethrough",x.hasFormat("strikethrough")),h("isSuperscript",x.hasFormat("superscript")),h("isSubscript",x.hasFormat("subscript")),h("isCode",x.hasFormat("code")))},[r,e,h]);F(()=>e.registerCommand(gn,(x,C)=>(i(C),g(),!1),Ot),[e,g,i]),F(()=>{r.getEditorState().read(()=>{g()})},[r,g]),F(()=>He(e.registerEditableListener(x=>{u(x)}),r.registerUpdateListener(({editorState:x})=>{x.read(()=>{g()})}),r.registerCommand(Ms,x=>(h("canUndo",x),!1),Ot),r.registerCommand(As,x=>(h("canRedo",x),!1),Ot)),[g,r,e,h]);let m=De(()=>{p.isLink?(s(!1),r.dispatchCommand(Yn,null)):(s(!0),r.dispatchCommand(Yn,WL("https://")))},[r,s,p.isLink]),_=X(()=>n?[...n].sort((x,C)=>{let E=x.label||x.name,k=C.label||C.name;return E.localeCompare(k)}):[],[n]),b=X(()=>o?[...o].sort((x,C)=>{let E=x.label||x.name,k=C.label||C.name;return E.localeCompare(k)}):[],[o]),y=x=>{switch(x){case"image":return f(HE,{size:16});case"html":return f(fE,{size:16});default:break}return f(qE,{size:16})},v=a==="comment";return f("div",{className:xe("LexicalEditor__toolbar",v&&"LexicalEditor__toolbar--comment"),children:[!v&&p.blockType in hh&&r===e&&f(Ne,{children:[f(VW,{disabled:!d,blockType:p.blockType,rootType:p.rootType,editor:r}),f(Cd,{})]}),f(Ne,{children:[f("div",{className:"LexicalEditor__toolbar__group",children:[f(An,{tooltip:`Bold (${nn.BOLD})`,active:p.isBold,onClick:()=>{r.dispatchCommand(at,"bold")},children:f(Ud,{size:16})}),f(An,{tooltip:`Italic (${nn.ITALIC})`,active:p.isItalic,onClick:()=>{r.dispatchCommand(at,"italic")},children:f(Yd,{size:16})}),f(An,{tooltip:`Underline (${nn.UNDERLINE})`,active:p.isUnderline,onClick:()=>{r.dispatchCommand(at,"underline")},children:f(ru,{size:16})}),f(WW,{editor:r,isStrikethrough:p.isStrikethrough,isSuperscript:p.isSuperscript,isSubscript:p.isSubscript,isCode:p.isCode})]}),f(Cd,{}),f("div",{className:"LexicalEditor__toolbar__group",children:f(An,{tooltip:`Insert link (${nn.INSERT_LINK})`,active:p.isLink,onClick:m,children:f(qd,{size:16})})}),f(Cd,{}),f(An,{tooltip:`Clear formatting (${nn.CLEAR_FORMATTING})`,onClick:()=>{Sl(r)},children:f(Kd,{size:16})}),f(Cd,{}),!v&&f(Ne,{children:[f(G,{control:f(Z,{className:xe("LexicalEditor__toolbar__dropdown","LexicalEditor__toolbar__insertDropdown"),variant:"default",compact:!0,leftIcon:f(jE,{size:16}),rightIcon:f(go,{size:16}),children:"Components"}),children:[f(G.Label,{children:"Insert"}),f(G.Item,{icon:f(ou,{size:16}),onClick:()=>{r.dispatchCommand(OM,{columns:"3",rows:"3"})},children:"Table"}),f(G.Item,{icon:f(YE,{size:16}),onClick:()=>{r.dispatchCommand(Xf,void 0)},children:"Horizontal Rule"}),b.length>0&&f(Ne,{children:[f(G.Label,{children:"Inline Components"}),b.map(x=>f(G.Item,{icon:f(hE,{size:16}),onClick:()=>c?.(x.name),children:x.label||x.name},x.name))]}),_.length>0&&f(Ne,{children:[f(G.Label,{children:"Block Components"}),_.map(x=>f(G.Item,{icon:y(x.name),onClick:()=>l?.(x.name),children:x.label||x.name},x.name))]})]}),f(Cd,{})]})]})]})}function An(t){return f(we,{className:xe("LexicalEditor__toolbar__actionIcon",t.active&&"LexicalEditor__toolbar__actionIcon--active"),label:t.tooltip,position:"top",withArrow:!0,children:f(Ae,{variant:t.variant||"default",onClick:t.onClick,title:t.tooltip,children:t.children})})}var GW=12,YW=5;function qW(t){let{editor:e,anchorElem:n,isLink:o,isBold:r,isCode:i,isItalic:s,isUnderline:a,isStrikethrough:l,isSubscript:c,isSuperscript:d,setIsLinkEditMode:u}=t,p=J(null),h=De(()=>{o?(u(!1),e.dispatchCommand(Yn,null)):(u(!0),e.dispatchCommand(Yn,""))},[e,o,u]);function g(b){if(p?.current&&(b.buttons===1||b.buttons===3)&&p.current.style.pointerEvents!=="none"){let y=b.clientX,v=b.clientY,x=document.elementFromPoint(y,v);p.current.contains(x)||(p.current.style.pointerEvents="none")}}function m(){p?.current&&p.current.style.pointerEvents!=="auto"&&(p.current.style.pointerEvents="auto")}F(()=>{if(p?.current)return document.addEventListener("mousemove",g),document.addEventListener("mouseup",m),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",m)}},[p]);let _=De(()=>{let b=z(),y=p.current,v=ao(e._window);if(y===null)return;let x=e.getRootElement();if(b!==null&&v!==null&&!v.isCollapsed&&x!==null&&x.contains(v.anchorNode)){let C=pL(v,x);XW(C,y,n,o)}},[e,n,o]);return F(()=>{let b=n.parentElement,y=()=>{e.getEditorState().read(()=>{_()})};return window.addEventListener("resize",y),b&&b.addEventListener("scroll",y),()=>{window.removeEventListener("resize",y),b&&b.removeEventListener("scroll",y)}},[e,_,n]),F(()=>(e.getEditorState().read(()=>{_()}),He(e.registerUpdateListener(({editorState:b})=>{b.read(()=>{_()})}),e.registerCommand(gn,()=>(_(),!1),Re))),[e,_]),f("div",{ref:p,className:"LexicalEditor__floatingToolbar",children:e.isEditable()&&f(Ne,{children:[f(An,{variant:"hover",tooltip:`Bold (${nn.BOLD})`,active:r,onClick:()=>{e.dispatchCommand(at,"bold")},children:f(Ud,{size:16})}),f(An,{variant:"hover",tooltip:`Italic (${nn.ITALIC})`,active:s,onClick:()=>{e.dispatchCommand(at,"italic")},children:f(Yd,{size:16})}),f(An,{variant:"hover",tooltip:`Underline (${nn.UNDERLINE})`,active:a,onClick:()=>{e.dispatchCommand(at,"underline")},children:f(ru,{size:16})}),f(An,{variant:"hover",tooltip:`Strikethrough (${nn.STRIKETHROUGH})`,active:l,onClick:()=>{e.dispatchCommand(at,"strikethrough")},children:f(eu,{size:16})}),f(An,{variant:"hover",tooltip:`Superscript (${nn.SUPERSCRIPT})`,active:d,onClick:()=>{e.dispatchCommand(at,"superscript")},children:f(nu,{size:16})}),f(An,{variant:"hover",tooltip:`Subscript (${nn.SUBSCRIPT})`,active:c,onClick:()=>{e.dispatchCommand(at,"subscript")},children:f(tu,{size:16})}),f(An,{variant:"hover",tooltip:"Code",active:i,onClick:()=>{e.dispatchCommand(at,"code")},children:f(Vd,{size:16})}),f(An,{variant:"hover",tooltip:`Insert link (${nn.INSERT_LINK})`,active:o,onClick:h,children:f(qd,{size:16})}),f(An,{variant:"hover",tooltip:`Clear formatting (${nn.CLEAR_FORMATTING})`,onClick:()=>{Sl(e)},children:f(Kd,{size:16})})]})})}function JW(t,e,n){let[o,r]=L(!1),[i,s]=L(!1),[a,l]=L(!1),[c,d]=L(!1),[u,p]=L(!1),[h,g]=L(!1),[m,_]=L(!1),[b,y]=L(!1),[v,x]=L(!1),C=De(()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let E=z(),k=ao(t._window),T=t.getRootElement();if(k!==null&&(!B(E)||T===null||!T.contains(k.anchorNode))){r(!1);return}if(!B(E))return;let w=ei(E);l(E.hasFormat("bold")),d(E.hasFormat("code")),p(E.hasFormat("italic")),y(E.hasFormat("underline")),g(E.hasFormat("strikethrough")),_(E.hasFormat("subscript")),x(E.hasFormat("superscript"));let S=w.getParent();Qe(S)||Qe(w)?s(!0):s(!1),!AL(E.anchor.getNode())&&E.getTextContent()!==""?r(te(w)||en(w)):r(!1);let N=E.getTextContent().replace(/\n/g,"");if(!E.isCollapsed()&&N===""){r(!1);return}})},[t]);return F(()=>(document.addEventListener("selectionchange",C),()=>{document.removeEventListener("selectionchange",C)}),[C]),F(()=>He(t.registerUpdateListener(()=>{C()}),t.registerRootListener(()=>{t.getRootElement()===null&&r(!1)})),[t,C]),o?si(f(qW,{editor:t,anchorElem:e,isLink:i,isBold:a,isCode:c,isItalic:u,isStrikethrough:h,isSubscript:m,isSuperscript:v,isUnderline:b,setIsLinkEditMode:n}),e):null}function YL(t){let{anchorElem:e=document.body,setIsLinkEditMode:n}=t,[o]=ve();return JW(o,e,n)}function XW(t,e,n,o=!1,r=GW,i=YW){let s=n.parentElement;if(t===null||!s){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let a=e.getBoundingClientRect(),l=n.getBoundingClientRect(),c=s.getBoundingClientRect(),d=t.top-a.height-r,u=t.left-i,p=window.getSelection();if(p&&p.rangeCount>0){let g=p.getRangeAt(0).startContainer;if(g.nodeType===Node.ELEMENT_NODE||g.parentElement){let m=g.nodeType===Node.ELEMENT_NODE?g:g.parentElement,_=window.getComputedStyle(m).textAlign;(_==="right"||_==="end")&&(u=t.right-a.width+i)}}d<c.top&&(d+=a.height+t.height+r*(o?9:2)),u+a.width>c.right&&(u=c.right-a.width-i),u<c.left&&(u=c.left+i),d-=l.top,u-=l.left,e.style.opacity="1",e.style.transform=`translate(${u}px, ${d}px)`}ke();function qL(){let[t]=ve();F(()=>t.registerCommand(Pi,n=>{let{clipboardData:o}=n;if(!o)return!1;let i=Array.from(o.files).find(s=>s.type.startsWith("image/"));return i?(n.preventDefault(),e(i),!0):!1},Re),[t]);let e=async n=>{let o=URL.createObjectURL(n),r=null;t.update(()=>{let i=Vs("image",{file:{src:o,width:0,height:0},loading:!0}),s=z();if(B(s)){Uo([i]);let a=ge();i.insertAfter(a),a.select()}r=i.getKey()});try{let i=await ai(n);t.update(()=>{if(r){let s=Lt(r);Qr(s)&&s.setBlockData({file:i,loading:!1})}})}catch(i){console.error("Failed to upload image",i),ae({type:"error",message:"Failed to upload image"})}};return null}var mC={};$e(mC,{$convertFromMarkdownString:()=>dG,$convertToMarkdownString:()=>uG,BOLD_ITALIC_STAR:()=>hR,BOLD_ITALIC_UNDERSCORE:()=>gR,BOLD_STAR:()=>mR,BOLD_UNDERSCORE:()=>_R,CHECK_LIST:()=>cG,CODE:()=>cR,ELEMENT_TRANSFORMERS:()=>CR,HEADING:()=>aR,HIGHLIGHT:()=>fR,INLINE_CODE:()=>pR,ITALIC_STAR:()=>yR,ITALIC_UNDERSCORE:()=>xR,LINK:()=>vR,MULTILINE_ELEMENT_TRANSFORMERS:()=>ER,ORDERED_LIST:()=>uR,QUOTE:()=>lR,STRIKETHROUGH:()=>bR,TEXT_FORMAT_TRANSFORMERS:()=>wR,TEXT_MATCH_TRANSFORMERS:()=>TR,TRANSFORMERS:()=>Nh,UNORDERED_LIST:()=>dR,registerMarkdownShortcuts:()=>iG});function uC(t,e){let n={};for(let o of t){let r=e(o);r&&(n[r]?n[r].push(o):n[r]=[o])}return n}function hC(t){let e=uC(t,(n=>n.type));return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}var Th=/[!-/:-@[-`{-~\s]/,ZW=/^\s{0,3}$/;function pC(t){if(!en(t))return!1;let e=t.getFirstChild();return e==null||t.getChildrenSize()===1&&te(e)&&ZW.test(e.getTextContent())}function QW(t,e,n,o){for(let r of e){if(!r.export)continue;let i=r.export(t,(s=>Sh(s,n,o)));if(i!=null)return i}return Y(t)?Sh(t,n,o):Un(t)?t.getTextContent():null}function Sh(t,e,n,o,r){let i=[],s=t.getChildren();o||(o=[]),r||(r=[]);e:for(let a of s){for(let l of n){if(!l.export)continue;let c=l.export(a,(d=>Sh(d,e,n,o,[...r,...o])),((d,u)=>JL(d,u,e,o,r)));if(c!=null){i.push(c);continue e}}Ze(a)?i.push(`
|
|
130
130
|
`):te(a)?i.push(JL(a,a.getTextContent(),e,o,r)):Y(a)?i.push(Sh(a,e,n,o,r)):Un(a)&&i.push(a.getTextContent())}return i.join("")}function JL(t,e,n,o,r){let i=t.getFormat()===0?e:(function(p){return p.replace(/^\s+|\s+$/g,(h=>[...h].map((g=>"&#"+g.codePointAt(0)+";")).join("")))})(e);t.hasFormat("code")||(i=i.replace(/([*_`~\\])/g,"\\$1"));let s="",a="",l="",c=XL(t,!0),d=XL(t,!1),u=new Set;for(let p of n){let h=p.format[0],g=p.tag;wh(t,h)&&!u.has(h)&&(u.add(h),wh(c,h)&&o.find((m=>m.tag===g))||(o.push({format:h,tag:g}),s+=g))}for(let p=0;p<o.length;p++){let h=wh(t,o[p].format),g=wh(d,o[p].format);if(h&&g)continue;let m=[...o];for(;m.length>p;){let _=m.pop();r&&_&&r.find((b=>b.tag===_.tag))||(_&&typeof _.tag=="string"&&(h?g||(l+=_.tag):a+=_.tag),o.pop())}break}return i=s+i+l,a+i}function XL(t,e){let n=e?t.getPreviousSibling():t.getNextSibling();if(!n){let o=t.getParentOrThrow();o.isInline()&&(n=e?o.getPreviousSibling():o.getNextSibling())}for(;n;){if(Y(n)){if(!n.isInline())break;let o=e?n.getLastDescendant():n.getFirstDescendant();if(te(o))return o;n=e?n.getPreviousSibling():n.getNextSibling()}if(te(n))return n;if(!Y(n))return null}return null}function wh(t,e){return te(t)&&t.hasFormat(e)}function eG(t,e){let n=(function(r,i){let s=r.match(i.openTagsRegExp);if(s==null)return null;for(let a of s){let l=a.replace(/^\s/,""),c=i.fullMatchRegExpByTag[l];if(c==null)continue;let d=r.match(c),u=i.transformersByTag[l];if(d!=null&&u!=null){if(u.intraword!==!1)return d;let{index:p=0}=d,h=r[p-1],g=r[p+d[0].length];if((!h||Th.test(h))&&(!g||Th.test(g)))return d}}return null})(t.getTextContent(),e);if(!n)return null;let o=n.index||0;return{endIndex:o+n[0].length,match:n,startIndex:o,transformer:e.transformersByTag[n[1]]}}function Js(t){return te(t)&&!t.hasFormat("code")}function Xs(t,e,n){let o=eG(t,e),r=(function(s,a){let l=s,c,d,u,p;for(let h of a){if(!h.replace||!h.importRegExp)continue;let g=l.getTextContent().match(h.importRegExp);if(!g)continue;let m=g.index||0,_=h.getEndIndex?h.getEndIndex(l,g):m+g[0].length;_!==!1&&(c===void 0||d===void 0||m<c&&_>d)&&(c=m,d=_,u=h,p=g)}return c===void 0||d===void 0||u===void 0||p===void 0?null:{endIndex:d,match:p,startIndex:c,transformer:u}})(t,n);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){let s=(function(a,l,c,d,u){let p=a.getTextContent(),h,g,m;if(u[0]===p?h=a:l===0?[h,g]=a.splitText(c):[m,h,g]=a.splitText(l,c),h.setTextContent(u[2]),d)for(let _ of d.format)h.hasFormat(_)||h.toggleFormat(_);return{nodeAfter:g,nodeBefore:m,transformedNode:h}})(t,o.startIndex,o.endIndex,o.transformer,o.match);Js(s.nodeAfter)&&Xs(s.nodeAfter,e,n),Js(s.nodeBefore)&&Xs(s.nodeBefore,e,n),Js(s.transformedNode)&&Xs(s.transformedNode,e,n)}else if(r){let s=(function(a,l,c,d,u){let p,h,g;return l===0?[p,h]=a.splitText(c):[g,p,h]=a.splitText(l,c),d.replace?{nodeAfter:h,nodeBefore:g,transformedNode:d.replace(p,u)||void 0}:null})(t,r.startIndex,r.endIndex,r.transformer,r.match);if(!s)return;Js(s.nodeAfter)&&Xs(s.nodeAfter,e,n),Js(s.nodeBefore)&&Xs(s.nodeBefore,e,n),Js(s.transformedNode)&&Xs(s.transformedNode,e,n)}let i=t.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,((s,a)=>String.fromCodePoint(a)));t.setTextContent(i)}function tG(t,e=!1){let n=hC(t),o=(function(r){let i={},s={},a=[],l="(?<![\\\\])";for(let c of r){let{tag:d}=c;i[d]=c;let u=d.replace(/(\*|\^|\+)/g,"\\$1");a.push(u),d.length===1?s[d]=new RegExp(`(?<![\\\\${u}])(${u})((\\\\${u})?.*?[^${u}\\s](\\\\${u})?)((?<!\\\\)|(?<=\\\\\\\\))(${u})(?![\\\\${u}])`):s[d]=new RegExp(`(?<!\\\\)(${u})((\\\\${u})?.*?[^\\s](\\\\${u})?)((?<!\\\\)|(?<=\\\\\\\\))(${u})(?!\\\\)`)}return{fullMatchRegExpByTag:s,openTagsRegExp:new RegExp(`${l}(${a.join("|")})`,"g"),transformersByTag:i}})(n.textFormat);return(r,i)=>{let s=r.split(`
|
|
131
131
|
`),a=s.length,l=i||tt();l.clear();for(let d=0;d<a;d++){let u=s[d],[p,h]=nG(s,d,n.multilineElement,l);p?d=h:oG(u,l,n.element,o,n.textMatch,e)}let c=l.getChildren();for(let d of c)!e&&pC(d)&&l.getChildrenSize()>1&&d.remove();z()!==null&&l.selectStart()}}function nG(t,e,n,o){for(let r of n){let{handleImportAfterStartMatch:i,regExpEnd:s,regExpStart:a,replace:l}=r,c=t[e].match(a);if(!c)continue;if(i){let g=i({lines:t,rootNode:o,startLineIndex:e,startMatch:c,transformer:r});if(g===null)continue;if(g)return g}let d=typeof s=="object"&&"regExp"in s?s.regExp:s,u=s&&typeof s=="object"&&"optional"in s?s.optional:!s,p=e,h=t.length;for(;p<h;){let g=d?t[p].match(d):null;if(!g&&(!u||u&&p<h-1)){p++;continue}if(g&&e===p&&g.index===c.index){p++;continue}let m=[];if(g&&e===p)m.push(t[e].slice(c[0].length,-g[0].length));else for(let _=e;_<=p;_++)if(_===e){let b=t[_].slice(c[0].length);m.push(b)}else if(_===p&&g){let b=t[_].slice(0,-g[0].length);m.push(b)}else m.push(t[_]);if(l(o,null,c,g,m,!0)!==!1)return[!0,p];break}}return[!1,e]}function oG(t,e,n,o,r,i){let s=Dt(t),a=ge();a.append(s),e.append(a);for(let{regExp:l,replace:c}of n){let d=t.match(l);if(d&&(s.setTextContent(t.slice(d[0].length)),c(a,[s],d,!0)!==!1))break}if(Xs(s,o,r),a.isAttached()&&t.length>0){let l=a.getPreviousSibling();if(!i&&(en(l)||Jr(l)||On(l))){let c=l;if(On(l)){let d=l.getLastDescendant();c=d==null?null:ue(d,dd)}c!=null&&c.getTextContentSize()>0&&(c.splice(c.getChildrenSize(),0,[zo(),...a.getChildren()]),a.remove())}}}function rG(t,...e){let n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(let r of e)o.append("v",r);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ZL(t,e,n){let o=n.length;for(let r=e;r>=o;r--){let i=r-o;if(QL(t,i,n,0,o)&&t[i+o]!==" ")return i}return-1}function QL(t,e,n,o,r){for(let i=0;i<r;i++)if(t[e+i]!==n[o+i])return!1;return!0}function iG(t,e=Nh){let n=hC(e),o=uC(n.textFormat,(({tag:s})=>s[s.length-1])),r=uC(n.textMatch,(({trigger:s})=>s));for(let s of e){let a=s.type;if(a==="element"||a==="text-match"||a==="multiline-element"){let l=s.dependencies;for(let c of l)t.hasNode(c)||rG(173,c.getType())}}let i=(s,a,l)=>{(function(c,d,u,p){let h=c.getParent();if(!Ht(h)||c.getFirstChild()!==d)return!1;let g=d.getTextContent();if(g[u-1]!==" ")return!1;for(let{regExp:m,replace:_}of p){let b=g.match(m);if(b&&b[0].length===(b[0].endsWith(" ")?u:u-1)){let y=d.getNextSiblings(),[v,x]=d.splitText(u);if(_(c,x?[x,...y]:y,b,!1)!==!1)return v.remove(),!0}}return!1})(s,a,l,n.element)||(function(c,d,u,p){let h=c.getParent();if(!Ht(h)||c.getFirstChild()!==d)return!1;let g=d.getTextContent();if(g[u-1]!==" ")return!1;for(let{regExpStart:m,replace:_,regExpEnd:b}of p){if(b&&!("optional"in b)||b&&"optional"in b&&!b.optional)continue;let y=g.match(m);if(y&&y[0].length===(y[0].endsWith(" ")?u:u-1)){let v=d.getNextSiblings(),[x,C]=d.splitText(u);if(_(c,C?[C,...v]:v,y,null,null,!1)!==!1)return x.remove(),!0}}return!1})(s,a,l,n.multilineElement)||(function(c,d,u){let p=c.getTextContent(),h=u[p[d-1]];if(h==null)return!1;d<p.length&&(p=p.slice(0,d));for(let g of h){if(!g.replace||!g.regExp)continue;let m=p.match(g.regExp);if(m===null)continue;let _=m.index||0,b=_+m[0].length,y;return _===0?[y]=c.splitText(b):[,y]=c.splitText(_,b),y.selectNext(0,0),g.replace(y,m),!0}return!1})(a,l,r)||(function(c,d,u){let p=c.getTextContent(),h=d-1,g=p[h],m=u[g];if(!m)return!1;for(let _ of m){let{tag:b}=_,y=b.length,v=h-y+1;if(y>1&&!QL(p,v,b,0,y)||p[v-1]===" ")continue;let x=p[h+1];if(_.intraword===!1&&x&&!Th.test(x))continue;let C=c,E=C,k=ZL(p,v,b),T=E;for(;k<0&&(T=T.getPreviousSibling())&&!Ze(T);)if(te(T)){if(T.hasFormat("code"))continue;let $=T.getTextContent();E=T,k=ZL($,$.length,b)}if(k<0||E===C&&k+y===v)continue;let w=E.getTextContent();if(k>0&&w[k-1]===g)continue;let S=w[k-1];if(_.intraword===!1&&S&&!Th.test(S))continue;let N=C.getTextContent(),D=N.slice(0,v)+N.slice(h+1);C.setTextContent(D);let O=E===C?D:w;E.setTextContent(O.slice(0,k)+O.slice(k+y));let A=z(),I=ar();Et(I);let R=h-y*(E===C?2:1)+1;I.anchor.set(E.__key,k,"text"),I.focus.set(C.__key,R,"text");for(let $ of _.format)I.hasFormat($)||I.formatText($);I.anchor.set(I.focus.key,I.focus.offset,I.focus.type);for(let $ of _.format)I.hasFormat($)&&I.toggleFormat($);return B(A)&&(I.format=A.format),!0}})(a,l,o)};return t.registerUpdateListener((({tags:s,dirtyLeaves:a,editorState:l,prevEditorState:c})=>{if(s.has(xO)||s.has(ol)||t.isComposing())return;let d=l.read(z),u=c.read(z);if(!B(u)||!B(d)||!d.isCollapsed()||d.is(u))return;let p=d.anchor.key,h=d.anchor.offset,g=l._nodeMap.get(p);!te(g)||!a.has(p)||h!==1&&h>u.anchor.offset+1||t.update((()=>{if(!Js(g))return;let m=g.getParent();m===null||dC(m)||i(m,g,d.anchor.offset)}))}))}var eR=/^(\s*)(\d{1,})\.\s/,tR=/^(\s*)[-*+]\s/,nR=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,fC=/^(#{1,6})\s/,oR=/^>\s/,rR=/^[ \t]*```([\w-]+)?/,iR=/[ \t]*```$/,sG=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,aG=/^(?:\|)(.+)(?:\|)\s?$/,lG=/^(\| ?:?-*:? ?)+\|\s?$/,sR=t=>(e,n,o,r)=>{let i=t(o);i.append(...n),e.replace(i),r||i.select(0,0)},gC=t=>(e,n,o,r)=>{let i=e.getPreviousSibling(),s=e.getNextSibling(),a=cd(t==="check"?o[3]==="x":void 0);if(On(s)&&s.getListType()===t){let c=s.getFirstChild();c!==null?c.insertBefore(a):s.append(a),e.remove()}else if(On(i)&&i.getListType()===t)i.append(a),e.remove();else{let c=dl(t,t==="number"?Number(o[2]):void 0);c.append(a),e.replace(c)}a.append(...n),r||a.select(0,0);let l=(function(c){let d=c.match(/\t/g),u=c.match(/ /g),p=0;return d&&(p+=d.length),u&&(p+=Math.floor(u.length/4)),p})(o[1]);l&&a.setIndent(l)},kh=(t,e,n)=>{let o=[],r=t.getChildren(),i=0;for(let s of r)if(dd(s)){if(s.getChildrenSize()===1){let d=s.getFirstChild();if(On(d)){o.push(kh(d,e,n+1));continue}}let a=" ".repeat(4*n),l=t.getListType(),c=l==="number"?`${t.getStart()+i}. `:l==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(a+c+e(s)),i++}return o.join(`
|
|
132
132
|
`)},aR={dependencies:[eh],export:(t,e)=>{if(!qr(t))return null;let n=Number(t.getTag().slice(1));return"#".repeat(n)+" "+e(t)},regExp:fC,replace:sR((t=>{let e="h"+t[1].length;return zs(e)})),type:"element"},lR={dependencies:[th],export:(t,e)=>{if(!Jr(t))return null;let n=e(t).split(`
|
|
@@ -138,4 +138,4 @@ ${ut.current.stack}
|
|
|
138
138
|
`)})(t,r);return tG(e,o)(i,n)}function uG(t=Nh,e,n=!1){return(function(r,i=!1){let s=hC(r),a=[...s.multilineElement,...s.element],l=!i,c=s.textFormat.filter((d=>d.format.length===1)).sort(((d,u)=>Number(d.format.includes("code"))-Number(u.format.includes("code"))));return d=>{let u=[],p=(d||tt()).getChildren();for(let h=0;h<p.length;h++){let g=p[h],m=QW(g,a,c,s.textMatch);m!=null&&u.push(l&&h>0&&!pC(g)&&!pC(p[h-1])?`
|
|
139
139
|
`.concat(m):m)}return u.join(`
|
|
140
140
|
`)}})(t,n)(e)}var ct=mC,epe=ct.$convertFromMarkdownString,tpe=ct.$convertToMarkdownString,npe=ct.BOLD_ITALIC_STAR,ope=ct.BOLD_ITALIC_UNDERSCORE,rpe=ct.BOLD_STAR,ipe=ct.BOLD_UNDERSCORE,spe=ct.CHECK_LIST,ape=ct.CODE,lpe=ct.ELEMENT_TRANSFORMERS,SR=ct.HEADING,cpe=ct.HIGHLIGHT,kR=ct.INLINE_CODE,dpe=ct.ITALIC_STAR,upe=ct.ITALIC_UNDERSCORE,ppe=ct.LINK,fpe=ct.MULTILINE_ELEMENT_TRANSFORMERS,NR=ct.ORDERED_LIST,DR=ct.QUOTE,hpe=ct.STRIKETHROUGH,gpe=ct.TEXT_FORMAT_TRANSFORMERS,mpe=ct.TEXT_MATCH_TRANSFORMERS,OR=ct.TRANSFORMERS,IR=ct.UNORDERED_LIST,AR=ct.registerMarkdownShortcuts;var _C={};$e(_C,{DEFAULT_TRANSFORMERS:()=>MR,MarkdownShortcutPlugin:()=>pG});yt();var MR=[{dependencies:[Jf],export:t=>CA(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,n,o)=>{let r=ul();o||t.getNextSibling()!=null?t.replace(r):t.insertBefore(r),r.selectNext()},type:"element"},...OR];function pG({transformers:t=MR}){let[e]=ve();return F((()=>AR(e,t)),[e,t]),null}var LR=_C,Cpe=LR.DEFAULT_TRANSFORMERS,RR=LR.MarkdownShortcutPlugin;function PR(){return f(RR,{transformers:[SR,IR,NR,DR,kR]})}var bC={};$e(bC,{OnChangePlugin:()=>hG});yt();var fG=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?_n:F;function hG({ignoreHistoryMergeTagChange:t=!0,ignoreSelectionChange:e=!1,onChange:n}){let[o]=ve();return fG((()=>{if(n)return o.registerUpdateListener((({editorState:r,dirtyElements:i,dirtyLeaves:s,prevEditorState:a,tags:l})=>{e&&i.size===0&&s.size===0||t&&l.has(rl)||a.isEmpty()||n(r,o,l)}))}),[o,t,e,n]),null}var gG=bC,FR=gG.OnChangePlugin;ke();function mG(){return{text:"",components:{}}}var _G=[{tag:"code",format:"code"},{tag:"s",format:"strikethrough"},{tag:"u",format:"underline"},{tag:"i",format:"italic"},{tag:"b",format:"bold"},{tag:"sup",format:"superscript"},{tag:"sub",format:"subscript"}];function $R(t){let e=[];return _G.forEach(({tag:n,format:o})=>{t.hasFormat(o)&&e.push(n)}),e}function yC(t,e){t.text+=e.text,Object.assign(t.components,e.components)}function bG(t,e,n){for(let o=t.length-1;o>=0;o-=1){let r=t[o];e.includes(r)||(n.text+=`</${r}>`,t.splice(o,1))}e.forEach(o=>{t.includes(o)||(n.text+=`<${o}>`,t.push(o))})}function BR(t,e){for(let n=t.length-1;n>=0;n-=1)e.text+=`</${t[n]}>`;t.length=0}function zR(t,e){let n=t.getChildren();for(let o of n)if(te(o)){let r=$R(o);if(r.length!==e.length)return!1;for(let i=0;i<r.length;i+=1)if(r[i]!==e[i])return!1}else{if(Ze(o)||wl(o))continue;if(o instanceof Ut){if(!zR(o,e))return!1}else return!1}return!0}function yG(t){let e=t.getComponentId(),n=t.getComponentName(),o=et(t.getComponentData()),r={[e]:{type:n,data:o}};return{text:`{${n}:${e}}`,components:r}}function xG(t){let e=Qe(t)&&t.getURL()||"",n=Qe(t)&&t.getTarget()||"",o=ni(t),r=SG(n)?` target="${n}"`:"";return{text:`<a href="${e}"${r}>${o.text}</a>`,components:o.components}}function ni(t){let e=mG(),n=[];return t.getChildren().forEach(r=>{if(Ze(r)){e.text+="<br>";return}if(wl(r)){yC(e,yG(r));return}if(te(r)){let i=$R(r);bG(n,i,e);let s=r.getTextContent();s&&(e.text+=wG(s));return}if(Qe(r)){n.length>0&&!zR(r,n)&&BR(n,e),yC(e,xG(r));return}if(r instanceof Ut){yC(e,ni(r));return}console.log("unhandled node"),console.log(r)}),n.length>0&&BR(n,e),e}function xC(t){let e=[];return t.getChildren().forEach(n=>{dd(n)&&e.push(vG(n))}),TG(e)}function vG(t){let e=t.getFirstChild();if(e&&On(e))return{itemsType:e.getTag()==="ol"?"orderedList":"unorderedList",items:xC(e)};let n=ni(t),o={content:n.text};return Yi(n.components)&&(o.components=n.components),o}function CG(t){let e=[];return t.getChildren().forEach(n=>{if(So(n)){let o=[];n.getChildren().forEach(r=>{if(Wo(r)){let s=r.getHeaderStyles()>0,a=r.getChildren(),l=[];a.forEach(c=>{if(Qr(c))l.push({type:c.getBlockName(),data:et(c.getBlockData())});else if(en(c)){let d=ni(c),u={type:"paragraph",data:{text:d.text}};Yi(d.components)&&(u.data.components=d.components),l.push(u)}else if(qr(c)){let d=c.getTag().slice(1),u=ni(c),p={type:"heading",data:{text:u.text,level:parseInt(d)}};Yi(u.components)&&(p.data.components=u.components),l.push(p)}else if(Jr(c)){let d=ni(c),u={type:"quote",data:{text:d.text}};Yi(d.components)&&(u.data.components=d.components),l.push(u)}else if(On(c)){let d=c.getTag(),u={type:d==="ol"?"orderedList":"unorderedList",data:{style:d==="ol"?"ordered":"unordered",items:xC(c)}};l.push(u)}}),o.push({blocks:l,type:s?"header":"data"})}}),e.push({cells:o})}}),{rows:e}}function HR(){let t=[];for(tt().getChildren().forEach(o=>{if(en(o)){let r=ni(o),i={type:"paragraph",data:{text:r.text}};Yi(r.components)&&(i.data.components=r.components),t.push(i)}else if(qr(o)){let r=o.getTag().slice(1),i=ni(o),s={type:"heading",data:{text:i.text,level:parseInt(r)}};Yi(i.components)&&(s.data.components=i.components),t.push(s)}else if(Jr(o)){let r=ni(o),i={type:"quote",data:{text:r.text}};Yi(r.components)&&(i.data.components=r.components),t.push(i)}else if(On(o)){let r=o.getTag(),i={type:r==="ol"?"orderedList":"unorderedList",data:{style:r==="ol"?"ordered":"unordered",items:xC(o)}};t.push(i)}else if(NM(o)){let i={type:"table",data:CG(o)};t.push(i)}else if(Qr(o)){let r={type:o.getBlockName(),data:et(o.getBlockData())};t.push(r)}else if(Un(o)&&o.getType()==="horizontalrule"){let r={type:"delimiter",data:{}};t.push(r)}});EG(t);)t.pop();return t.length===0?null:{time:Date.now(),blocks:t,version:"lexical-0.31.2"}}function EG(t){let e=t.length>0&&t.at(-1);return!!(e&&e.type==="paragraph"&&!e.data?.text&&!Yi(e.data?.components||{}))}function Yi(t){return t?Object.keys(t).length>0:!1}function wG(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function TG(t){let e=[];return t.forEach(n=>{n.itemsType&&n.items&&e.length>0?(e.at(-1).itemsType=n.itemsType,e.at(-1).items=n.items):e.push(n)}),e}function SG(t){return["_blank","_self","_parent","_top"].includes(t)}function UR(t){let e=tt();e.clear();let n=t?.blocks||[];for(let o of n)if(o.type==="paragraph"){let r=ge();if(o.data.text){let i=Zs(o.data.text,o.data.components);r.append(...i)}e.append(r)}else if(o.type==="heading"){let r=`h${o.data?.level||2}`,i=zs(r);if(o.data.text){let s=Zs(o.data.text,o.data.components);i.append(...s)}e.append(i)}else if(o.type==="quote"){let r=Hs();if(o.data?.text){let i=Zs(o.data.text,o.data.components);r.append(...i)}e.append(r)}else if(o.type==="orderedList"||o.type==="unorderedList"){let r=o.data.style==="ordered"?"number":"bullet",i=dl(r);for(let s of o.data.items)i.append(...vC(s,r));e.append(i)}else if(o.type==="table"){let r=EM();(o.data?.rows||[]).forEach(s=>{let a=wM();(s.cells||[]).forEach(c=>{let d=c.blocks||[],p=(c.type||"data")==="header"?1:0,h=CM(p);d.forEach(g=>{if(g.type==="paragraph"){let m=ge();if(g.data?.text){let _=Zs(g.data.text,g.data.components);m.append(..._)}h.append(m)}else if(g.type==="heading"){let m=`h${g.data?.level||2}`,_=zs(m);if(g.data?.text){let b=Zs(g.data.text,g.data.components);_.append(...b)}h.append(_)}else if(g.type==="quote"){let m=Hs();if(g.data?.text){let _=Zs(g.data.text,g.data.components);m.append(..._)}h.append(m)}else if(g.type==="orderedList"||g.type==="unorderedList"){let m=g.data.style==="ordered"?"number":"bullet",_=dl(m);for(let b of g.data.items)_.append(...vC(b,m));h.append(_)}else{let m=Vs(g.type,g.data||{});h.append(m)}}),a.append(h)}),r.append(a)}),e.append(r)}else if(o.type==="delimiter"){let r=ul();e.append(r)}else if(o.type){let r=Vs(o.type,o.data||{});e.append(r)}}function Zs(t,e){let n=document.createElement("template");n.innerHTML=t;let o=n.content,r=[];function i(s){if(s.nodeType===Node.TEXT_NODE)return kG(s.textContent||"",e);if(s.nodeType===Node.ELEMENT_NODE){let a=s,l=Array.from(a.childNodes).map(i).filter(c=>!!c).flat();switch(a.tagName.toLowerCase()){case"b":case"strong":return l.map(c=>(c instanceof Kt&&c.toggleFormat("bold"),c));case"i":case"em":return l.map(c=>(c instanceof Kt&&c.toggleFormat("italic"),c));case"u":return l.map(c=>(c instanceof Kt&&c.toggleFormat("underline"),c));case"s":return l.map(c=>(c instanceof Kt&&c.toggleFormat("strikethrough"),c));case"sup":return l.map(c=>(c instanceof Kt&&c.toggleFormat("superscript"),c));case"sub":return l.map(c=>(c instanceof Kt&&c.toggleFormat("subscript"),c));case"code":return l.map(c=>(c instanceof Kt&&c.toggleFormat("code"),c));case"br":return[];case"a":{let c=zf(a.getAttribute("href")||""),d=a.getAttribute("target");return d&&c.setTarget(d),c.append(...l),[Mt(c)]}default:return console.log("unhandled tag: "+a.tagName),console.log(l),l}}return null}return o.childNodes.forEach(s=>{let a=i(s);Array.isArray(a)?r.push(...a):a&&r.push(a)}),r}function kG(t,e){let n=[];if(!t)return n;let o=/\{([^:{}]+):([^}]+)\}/g,r=0,i;for(;(i=o.exec(t))!==null;){let a=t.slice(r,i.index);a&&n.push(Dt(a));let l=i[1],c=i[2],d=e?.[c];d?n.push(_h(l||d.type,c,d.data?et(d.data):{})):n.push(Dt(i[0])),r=o.lastIndex}let s=t.slice(r);return s&&n.push(Dt(s)),n}function vC(t,e){let n=[];if(t.content){let o=NG(t);n.push(o)}if(t.items&&t.items.length>0){let o=DG(t,e);n.push(o)}return n}function NG(t){let e=cd();if(t.content){let n=Zs(t.content,t.components);e.append(...n)}return e}function DG(t,e){let n=cd();if(t.items&&t.items.length>0){let o=e;t.itemsType==="orderedList"?o="number":t.itemsType==="unorderedList"&&(o="bullet");let r=dl(o);for(let i of t.items)r.append(...vC(i,o));n.append(r)}return n}function KR(t){let[e]=ve(),n=J(0),o=J(!1);return F(()=>{let i=t.value?.time||0;i>n.current&&(n.current=i,e.update(()=>{o.current=!0,UR(t.value)}))},[e,t.value]),f(FR,{onChange:i=>{if(o.current){o.current=!1;return}i.read(()=>{let s=HR();n.current=s?.time||0,t.onChange&&t.onChange(s)})},ignoreSelectionChange:!0})}ke();function OG(t){let e=!1;return t.querySelectorAll("a [style]").forEach(n=>{if(!(n instanceof HTMLElement))return;let o=n.style;(o.textDecoration?.includes("underline")||o.getPropertyValue("text-decoration")?.includes("underline"))&&(o.removeProperty("text-decoration"),o.removeProperty("text-decoration-skip-ink"),o.removeProperty("-webkit-text-decoration-skip"),e=!0)}),e}function IG(t){let e=!1;return t.querySelectorAll("[style]").forEach(n=>{n instanceof HTMLElement&&n.style.textAlign&&(n.style.removeProperty("text-align"),e=!0)}),e}function jR(){let[t]=ve();return F(()=>t.registerCommand(Pi,e=>{let{clipboardData:n}=e;if(!n)return!1;let o=n.getData("text/html");if(!o)return!1;let i=new DOMParser().parseFromString(o,"text/html"),s=!1;if(s=OG(i)||s,s=IG(i)||s,!s)return!1;e.preventDefault();let a=Zf(t,i),l=z();return B(l)?l.insertNodes(a):Uo(a),!0},vf),[t]),null}ke();function VR(t){let{editor:e,setIsLinkEditMode:n}=t,{toolbarState:o}=gh();return F(()=>{let r=i=>{if(Wn(i,{}))return!1;if(LL(i))qs(e);else if(RL(i)){let{code:s}=i,a=`h${s[s.length-1]}`;Gi(e,o.blockType,a)}else if(FL(i))Ch(e,o.blockType);else if(PL(i))Eh(e,o.blockType);else if(BL(i))e.dispatchCommand(at,"strikethrough");else if($L(i))e.dispatchCommand(jn,void 0);else if(zL(i))e.dispatchCommand(To,void 0);else if(HL(i))e.dispatchCommand(at,"subscript");else if(UL(i))e.dispatchCommand(at,"superscript");else if(KL(i))Sl(e);else if(jL(i)){let s=o.isLink?null:"";n(!o.isLink),e.dispatchCommand(Yn,s)}else return!1;return i.preventDefault(),!0};return e.registerCommand(SO,r,vf)},[e,o.isLink,o.blockType,n]),null}ke();var AG=/[\u00A0\u2011]/;function WR(){let[t]=ve();return F(()=>{if(!t.hasNodes([ji]))throw new Error("SpecialCharacterPlugin: SpecialCharacterNode not registered on editor");return t.registerNodeTransform(Kt,e=>{if(uL(e))return;let n=e.getTextContent(),o=AG.exec(n);if(o){let r=o.index,i=o[0],s;r===0?[s]=e.splitText(r+1):[,s]=e.splitText(r,r+1);let a=Zv(i);s.replace(a)}})},[t]),null}yr();ke();function GR(t){let{editor:e}=t,n=J(null),o=J(null),[r,i]=L(null),[s,a]=L(!1),[l,c]=L(!1),[d,u]=L(!1),p=De(()=>{if(!r){c(!1),u(!1);return}e.getEditorState().read(()=>{try{let w=yd(r).getChildren(),S=-1;for(let D=0;D<w.length;D++){let O=w[D];if(!So(O))continue;if(O.getChildren().some(I=>I.getKey()===r.getKey())){S=D;break}}if(S!==-1){let D=w[S];if(So(D)){let A=D.getChildren()[0];if(Wo(A)){let I=A.getHeaderStyles();c((I&In.ROW)===In.ROW)}}}let N=-1;for(let D=0;D<w.length;D++){let O=w[D];if(!So(O))continue;let A=O.getChildren();for(let I=0;I<A.length;I++)if(A[I].getKey()===r.getKey()){N=I;break}if(N!==-1)break}if(N!==-1){let D=w[0];if(So(D)){let A=D.getChildren()[N];if(Wo(A)){let I=A.getHeaderStyles();u((I&In.COLUMN)===In.COLUMN)}}}}catch{c(!1),u(!1)}})},[e,r]);F(()=>{r&&s&&p()},[r,s,p]),F(()=>{if(!(!r||!s))return e.registerUpdateListener(()=>{p()})},[e,r,s,p]);let h=De(()=>{let T=o.current,w=n.current;if(!w||!r)return;let S=e.getElementByKey(r.getKey());if(!S)return;let N=S.getBoundingClientRect(),D=window.innerWidth,O=window.innerHeight;if(w.style.left=`${N.right-25}px`,w.style.top=`${N.top+5}px`,w.style.display="flex",T)if(s){let R=N.right-185,$=N.top+30;R<10&&(R=N.left),R+185>D-10&&(R=D-185-10),$+280>O-10&&($=N.top-280-5,$<10&&($=10)),T.style.left=`${R}px`,T.style.top=`${$}px`,T.style.display="block"}else T.style.display="none"},[e,r,s]);F(()=>{if(!r){n.current&&(n.current.style.display="none"),o.current&&(o.current.style.display="none"),a(!1);return}h();let T=()=>{h()},w=N=>{N.key==="Escape"&&s&&(a(!1),N.preventDefault(),N.stopPropagation())},S=N=>{o.current&&n.current&&!o.current.contains(N.target)&&!n.current.contains(N.target)&&a(!1)};return window.addEventListener("scroll",T,!0),document.addEventListener("keydown",w),document.addEventListener("mousedown",S),()=>{window.removeEventListener("scroll",T,!0),document.removeEventListener("keydown",w),document.removeEventListener("mousedown",S)}},[r,h,s]),F(()=>e.registerCommand(gn,()=>{let T=z();if(B(T)){let w=T.anchor.getNode(),S=Hv(w);Wo(S)?(r&&S.getKey()!==r.getKey()&&a(!1),i(S)):i(null)}else if(DM(T)){let w=T.getNodes();if(w.length>0){let S=Hv(w[0]);Wo(S)&&(r&&S.getKey()!==r.getKey()&&a(!1),i(S))}}else i(null);return!1},Ai),[e,r]);let g=De(()=>{e.update(()=>{r&&Kv(!1)}),a(!1)},[e,r]),m=De(()=>{e.update(()=>{r&&Kv(!0)}),a(!1)},[e,r]),_=De(()=>{e.update(()=>{r&&Uv(!1)}),a(!1)},[e,r]),b=De(()=>{e.update(()=>{r&&Uv(!0)}),a(!1)},[e,r]),y=De(()=>{e.update(()=>{r&&TM()}),a(!1)},[e,r]),v=De(()=>{e.update(()=>{r&&SM()}),a(!1)},[e,r]),x=De(()=>{e.update(()=>{if(!r)return;yd(r).remove()}),a(!1)},[e,r]),C=De(()=>{e.update(()=>{if(!r)return;let w=yd(r).getChildren(),S=-1;for(let R=0;R<w.length;R++){let $=w[R];if(!So($))continue;if($.getChildren().some(P=>P.getKey()===r.getKey())){S=R;break}}if(S===-1)return;let N=w[S];if(!So(N))return;let D=N.getChildren(),O=D[0],I=((Wo(O)?O.getHeaderStyles():0)&In.ROW)===In.ROW;D.forEach(R=>{if(Wo(R)){let $=R.getHeaderStyles(),W=I?$^In.ROW:$|In.ROW;R.setHeaderStyles(W,In.ROW)}})}),a(!1)},[e,r]),E=De(()=>{e.update(()=>{if(!r)return;let w=yd(r).getChildren(),S=-1;for(let R=0;R<w.length;R++){let $=w[R];if(!So($))continue;let W=$.getChildren();for(let P=0;P<W.length;P++)if(W[P].getKey()===r.getKey()){S=P;break}if(S!==-1)break}if(S===-1)return;let N=w[0];if(!So(N))return;let O=N.getChildren()[S],I=((Wo(O)?O.getHeaderStyles():0)&In.COLUMN)===In.COLUMN;w.forEach(R=>{if(!So(R))return;let W=R.getChildren()[S];if(Wo(W)){let P=W.getHeaderStyles(),q=I?P^In.COLUMN:P|In.COLUMN;W.setHeaderStyles(q,In.COLUMN)}})}),a(!1)},[e,r]);if(!r)return null;let k=e.getRootElement();return k?si(f(Ne,{children:[f("button",{ref:n,className:"LexicalEditor__tableActionMenuButton",onClick:()=>a(!s),type:"button",children:"\u22EE"}),s&&f("div",{ref:o,className:"LexicalEditor__tableActionMenu",children:[f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:g,children:"Insert row above"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:m,children:"Insert row below"}),f("div",{className:"LexicalEditor__tableActionMenuDivider"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:_,children:"Insert column left"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:b,children:"Insert column right"}),f("div",{className:"LexicalEditor__tableActionMenuDivider"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:y,children:"Delete column"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:v,children:"Delete row"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:x,children:"Delete table"}),f("div",{className:"LexicalEditor__tableActionMenuDivider"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:C,children:l?"Remove row header":"Convert to row header"}),f("button",{className:"LexicalEditor__tableActionMenuItem",onClick:E,children:d?"Remove column header":"Convert to column header"})]})]}),k.parentElement||document.body):null}ke();function YR(){let[t]=ve();return F(()=>t.registerNodeTransform(IO,e=>{let n=e.getLastChild();en(n)||e.append(ge())}),[t]),null}var MG={namespace:"RootCMS",theme:rL,nodes:[II,eh,th,ll,hr,zi,Jf,ph,uh,IM,Cl,El,ji],onError:t=>{throw console.error("[LexicalEditor] error:",t),t}};function JR(t){return f(rA,{initialConfig:MG,children:f(eL,{children:f(oL,{children:f("div",{className:xe(t.className,"LexicalEditor",t.variant==="comment"&&"LexicalEditor--comment",!t.autosize&&"LexicalEditor--withMaxHeight"),children:f(FG,{deepKey:t.deepKey,placeholder:t.placeholder,value:t.value,onChange:t.onChange,onFocus:t.onFocus,onBlur:t.onBlur,variant:t.variant,autoFocus:t.autoFocus,blockComponents:t.blockComponents,inlineComponents:t.inlineComponents})})})})})}var LG=Wv({name:"image",label:"Image Embed",preview:{title:"{file.alt}",image:"{file.src}"},fields:[FM({id:"file",label:"Image"}),Vv({id:"caption",label:"Caption",variant:"textarea",translate:!0,deprecated:!0})]}),RG=Wv({name:"html",label:"HTML Code",preview:{title:"{html}"},fields:[Vv({id:"html",label:"HTML",help:"HTML code to embed. Please use caution when inserting HTML.",variant:"textarea",autosize:!0,maxRows:50})]}),PG=[LG,RG];function FG(t){let{historyState:e}=tL(),[n]=ve(),[o,r]=L(n),[i,s]=L(!1),[a,l]=L(null),c=X(()=>{let D=new Map;return t.variant!=="comment"&&PG.forEach(O=>{D.set(O.name,O)}),t.blockComponents?.forEach(O=>{D.set(O.name,O)}),D},[t.blockComponents]),d=Array.from(c.values()),[u,p]=L(null),h=X(()=>{let D=new Map;return t.inlineComponents?.forEach(O=>{D.set(O.name,O)}),D},[t.inlineComponents]),g=Array.from(h.values()),[m,_]=L(null),b=D=>{D&&l(D)},y=(D,O)=>{let A=c.get(D);if(!A)return;let I=O?.initialValue?et(O.initialValue):aa(A);p({schema:A,mode:O?.mode??"create",initialValue:I,nodeKey:O?.nodeKey})},v=(D,O)=>{n.update(()=>{let A=Vs(D,O);Uo([A]),A.selectNext()})},x=(D,O)=>{n.update(()=>{let A=Lt(D);Qr(A)&&A.setBlockData(O)})},C=()=>{p(null)};F(()=>{if(!t.deepKey)return;let D=O=>{let A=O.detail;if(!A||A.richTextDeepKey!==t.deepKey)return;let I=c.get(A.blockName);if(!I)return;let R=null,$=null;n.getEditorState().read(()=>{let W=tt(),P=-1;for(let q of W.getChildren())if(Qr(q)){P+=1;let de=q.getBlockName();if(P===A.blockIndex&&de===A.blockName){R=q.getKey(),$=q.getBlockData();break}}if(!R){for(let q of W.getChildren())if(Qr(q)&&q.getBlockName()===A.blockName){R=q.getKey(),$=q.getBlockData();break}}}),R&&p({schema:I,mode:"edit",initialValue:$?et($):{},nodeKey:R})};return window.addEventListener(qv,D),()=>window.removeEventListener(qv,D)},[n,t.deepKey,c]),F(()=>{if(!t.deepKey)return;let D=O=>{let A=O.detail;if(!A||A.richTextDeepKey!==t.deepKey)return;let I=h.get(A.componentName);if(!I)return;let R=null,$=null,W=null;n.getEditorState().read(()=>{for(let{node:P}of CI())if(wl(P)&&P.getComponentId()===A.componentId){R=P.getKey(),$=P.getComponentData(),W=P.getComponentName();break}}),R&&_({schema:I,componentName:W||A.componentName,componentId:A.componentId,mode:"edit",initialValue:$?et($):{},nodeKey:R})};return window.addEventListener(Jv,D),()=>window.removeEventListener(Jv,D)},[n,t.deepKey,h]);let E=D=>{u&&(u.mode==="edit"&&u.nodeKey?x(u.nodeKey,D):v(u.schema.name,D),C())},k=(D,O)=>{let A=h.get(D);if(!A)return;let I=O?.initialValue?et(O.initialValue):aa(A);_({schema:A,componentName:D,componentId:O?.componentId||No(),mode:O?.mode??"create",initialValue:I,nodeKey:O?.nodeKey})},T=(D,O,A)=>{n.update(()=>{let I=_h(D,O,A);Uo([I]),I.selectNext()})},w=(D,O,A,I)=>{n.update(()=>{let R=Lt(D);wl(R)&&(R.setComponentName(O),R.setComponentId(A),R.setComponentData(I))})},S=()=>{_(null)},N=D=>{if(!m)return;let{componentName:O,mode:A,nodeKey:I}=m;A==="edit"&&I?w(I,O,D.componentId,D.data):T(O,D.componentId,D.data),S()};return f(XM,{components:h,onEditComponent:(D,O)=>k(D,{mode:O?.mode??"edit",initialValue:O?.initialValue,componentId:O?.componentId,nodeKey:O?.nodeKey}),children:f(YM,{blocks:c,onEditBlock:y,children:[f(KR,{value:t.value,onChange:t.onChange}),f(GL,{editor:n,activeEditor:o,setActiveEditor:r,setIsLinkEditMode:s,variant:t.variant,blockComponents:d,inlineComponents:g,onInsertBlockComponent:D=>y(D,{mode:"create"}),onInsertInlineComponent:D=>k(D,{mode:"create"})}),f(VR,{editor:o,setIsLinkEditMode:s}),f(yA,{externalHistoryState:e}),f(qA,{contentEditable:f("div",{className:"LexicalEditor__scroller",children:f("div",{className:"LexicalEditor__root",ref:b,children:f(uA,{className:"LexicalEditor__editor",placeholder:f($G,{placeholder:t.placeholder})})})}),ErrorBoundary:fA}),f(wA,{}),f(TA,{}),t.variant!=="comment"&&f(Ne,{children:[f(EA,{}),f(PM,{}),f(GR,{editor:o}),f(ZA,{maxIndent:7})]}),f(PR,{}),t.autoFocus&&f(nA,{}),f(YR,{}),f(WR,{}),f(jR,{}),t.variant!=="comment"&&f(qL,{}),a&&f(Ne,{children:[f(YL,{anchorElem:a,setIsLinkEditMode:s}),f(hL,{anchorElem:a,isLinkEditMode:i,setIsLinkEditMode:s})]}),u&&f(sL,{schema:u.schema,opened:!0,initialValue:u.initialValue,mode:u.mode,onClose:C,onSubmit:E}),m&&f(dL,{schema:m.schema,opened:!0,componentId:m.componentId,initialValue:m.initialValue,mode:m.mode,onClose:S,onSubmit:N})]})})}var qR=["Once upon a placeholder...","Start writing something legendary...","Words go here. Preferably brilliant ones...","Compose like nobody\u2019s watching...","Add text that makes Hemingway jealous...","Here lies your unwritten brilliance...","This is where the magic happens...","Let the words flow...","In the beginning, there was a blank page...","To write, or not to write, that is the question..."];function BG(){let t=Math.floor(Math.random()*qR.length);return qR[t]}function $G(t){let e=X(()=>t.placeholder||BG(),[]);return f("div",{className:"LexicalEditor__placeholder",children:e})}function XR(t){if(Ow().preferences.EnableEditorJSEditor){let{deepKey:n,...o}=t;return f(ON,{...o})}return f(JR,{...t})}function ZR(t){let e=t.field,[n,o]=L(null),r=sn().controller,i=s=>{o(a=>(a?.time!==s?.time&&r.updateKey(t.deepKey,s),s))};return Xo(t.deepKey,s=>{o(s)}),f(XR,{deepKey:t.deepKey,value:n,placeholder:e.placeholder,blockComponents:e.blockComponents,inlineComponents:e.inlineComponents,onChange:i,onFocus:t.onFocus,onBlur:t.onBlur,autosize:e.autosize})}ke();function QR(t){let e=t.field,[n,o]=At(t.deepKey,""),[r,i]=L([]),[s,a]=L([]),[l,c]=L(!!e.source);F(()=>{if(!e.source)return;let h=!0;return c(!0),Uu(e.source).then(g=>{h&&i(g)}).catch(g=>{console.error("failed to resolve field source:",g)}).finally(()=>{h&&c(!1)}),()=>{h=!1}},[e.source]);let d=X(()=>(e.options||[]).map(h=>typeof h=="string"?{label:h,value:h}:{label:h.label??h.value??"",value:h.value??h.label??""}),[e.options]),u=X(()=>{let h=new Map,g=e.source?r:d;for(let m of g)h.set(m.value,m);for(let m of s)h.has(m.value)||h.set(m.value,m);return n&&!h.has(n)&&h.set(n,{value:n,label:n}),Array.from(h.values())},[e.source,r,d,s,n]),p=f(Rn,{data:u,placeholder:e.placeholder,value:n||null,onChange:h=>o(h||""),size:"xs",radius:0,searchable:e.searchable??!0,clearable:!0,creatable:e.creatable||!1,getCreateLabel:h=>`+ Add "${h}"`,onCreate:h=>{let g={value:h,label:h};return a(m=>[...m,g]),g},itemComponent:e.source?.helpKey?Ku:void 0,nothingFound:l?"Loading\u2026":void 0,rightSection:l?f(xt,{size:"xs"}):void 0,dropdownComponent:"div"});return e.source?.doc?f("div",{className:"DocEditor__SelectField",style:{display:"flex",alignItems:"center",gap:8},children:[f("div",{style:{flex:1,minWidth:0},children:p}),f(ju,{source:e.source})]}):f("div",{className:"DocEditor__SelectField",children:p})}ke();function eP(t){let{variant:e,scrollRef:n}=t,o=typeof t.value=="string"?t.value:"",r=o.split(/([\u00A0\u2011])/g);return f("div",{ref:n,className:`StringField__highlighter StringField__highlighter--${e}`,"aria-hidden":"true",children:[r.map((i,s)=>i==="\xA0"||i==="\u2011"?f("span",{className:"StringField__highlight",children:i},s):f("span",{children:i},s)),e==="textarea"&&o.endsWith(`
|
|
141
|
-
`)&&f("br",{})]})}function tP(t){let e=t.field,[n,o]=At(t.deepKey,""),r=J(null),i=J(null),[s,a]=L(null);if(n!=null&&typeof n!="string")throw new Error(`Expected a string value but got ${typeof n}. The stored data for this field may be corrupted. Fix it using "Edit JSON" or restore a previous version.`);let l=g=>{o(g.currentTarget.value)},c=g=>{t.onFocus?.(g),no(t.deepKey,{scroll:!0})},d=g=>{t.onBlur?.(g),no(null)},u=g=>{let m=g.target.value;if(m.trim()){let _=m;try{let b=m.replace(/'([^'\\]*(?:\\.[^'\\]*)*)'/g,'"$1"').replace(/,\s*([\]}])/g,"$1");JSON.parse(b),_=b}catch{}try{let b=JSON.parse(_),y=JSON.stringify(b,null,2);o(y),a(null)}catch(b){a(b.message)}}else a(null);t.onBlur?.(g),no(null)},p=g=>{r.current&&(r.current.scrollTop=g.target.scrollTop,r.current.scrollLeft=g.target.scrollLeft)},h=g=>{i.current&&(i.current.scrollLeft=g.target.scrollLeft)};return e.variant==="json"?f("div",{className:"StringField__container",children:[f(bn,{className:xe("StringField__input","StringField__input--json",s&&"StringField__input--error"),size:"xs",radius:0,autosize:e.autosize,minRows:4,maxRows:e.maxRows||20,value:n,onChange:l,onFocus:c,onBlur:u,onScroll:p}),s&&f("div",{className:"StringField__jsonError",children:["Invalid JSON: ",s]})]}):e.variant==="textarea"?f("div",{className:"StringField__container",children:[f(eP,{value:n||"",variant:"textarea",scrollRef:r}),f(bn,{className:"StringField__input",size:"xs",radius:0,autosize:e.autosize,minRows:4,maxRows:e.maxRows||12,value:n,onChange:l,onFocus:c,onBlur:d,onScroll:p})]}):f("div",{className:"StringField__container",children:[f(eP,{value:n||"",variant:"input",scrollRef:i}),f(Xn,{className:"StringField__input",size:"xs",radius:0,value:n,onChange:l,onFocus:c,onBlur:d,onScroll:h})]})}var oP=pt({});function Dh(){return ft(oP)}function Ie(t){let e=t.docId.split("/")[0],n=gw(e),o=sn(),r=n.loading||o.loading,i=n.schema?.fields||[];return f(oP.Provider,{value:n?.schema?.types||{},children:f(eS,{children:f("div",{className:xe(t.className,"DocEditor"),children:[f(Nd,{visible:r,loaderProps:{color:"gray",size:"xl"}}),!r&&!t.hideStatusBar&&f(Ie.StatusBar,{...t,draft:o,collection:n.schema}),f("div",{className:"DocEditor__fields",children:i.map(s=>f(Ie.Field,{field:s,deepKey:`fields.${s.id}`},s.id))})]})})})}Ie.StatusBar=t=>{let{route:e,query:n}=BC(),{roles:o}=su(),r=window.firebase.user.email||"",i=au(o,r),s=pw(o,r),a=t.draft,[l,c]=L(a.controller.getData());Xo("sys",S=>{c({sys:S})});let d=De(S=>{S==="unlocked"&&a.controller.removePublishingLock()},[a.controller]),u=Ew({docId:t.docId,onChange:d}),p=De(S=>{if(S.action==="delete"){let N=t.docId.split("/")[0];e(`/cms/content/${N}`)}else S.action==="unlocked"&&a.controller.removePublishingLock()},[t.docId]),h=De(()=>{if(!s)return;let S=l?.sys?.publishingLocked;S&&u.open({existingLock:{reason:S.reason,until:S.until?S.until.toMillis():void 0}})},[s,l?.sys?.publishingLocked,u]),g=Jw({docId:t.docId}),m=Ww(),[_,b]=L(()=>{try{let S=window.localStorage.getItem("root::DocumentPage::checksVisible");return S?JSON.parse(S)===!0:!1}catch{return!1}}),[y,v]=L(()=>{try{let S=window.localStorage.getItem("root::DocumentPage::searchVisible");return S?JSON.parse(S)===!0:!1}catch{return!1}}),[x,C]=L(()=>{try{let S=window.localStorage.getItem("root::DocumentPage::aiVisible");return S?JSON.parse(S)===!0:!1}catch{return!1}}),E=Io();F(()=>{let S=N=>{b(N.detail===!0)};return window.addEventListener("root:checks-visible",S),()=>window.removeEventListener("root:checks-visible",S)},[]),F(()=>{let S=N=>{v(N.detail===!0)};return window.addEventListener("root:search-visible",S),()=>window.removeEventListener("root:search-visible",S)},[]),F(()=>{let S=N=>{C(N.detail===!0)};return window.addEventListener("root:ai-visible",S),()=>window.removeEventListener("root:ai-visible",S)},[]);let k=n.locale||"",T=n.modal||"";F(()=>{T==="localization"&&a.controller&&m.open({docId:t.docId,collection:t.collection,draft:a.controller,locale:k||void 0})},[]);let w=!l?.sys;return w?null:f("div",{className:"DocEditor__statusBar",children:[f("div",{className:"DocEditor__statusBar__viewers",children:f(aS,{id:`doc/${t.docId}`})}),f(Ie.SaveState,{}),l?.sys&&f("div",{className:"DocEditor__statusBar__statusBadges",children:f(hE,{doc:l,docId:t.docId,onPublishingLockClick:s?h:void 0})}),f("div",{className:"DocEditor__statusBar__buttonGroup",children:[f("div",{className:"DocEditor__statusBar__search",children:f(we,{label:"\u2318 + Shift + f",transition:"pop",withArrow:!0,children:f(Z,{className:xe("DocEditor__statusBar__buttonGroup__button",y?"DocEditor__statusBar__buttonGroup__button--active":""),variant:"default",color:"dark",size:"xs",leftIcon:f(eu,{size:16}),onClick:()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},children:"Search"})})}),(window.__ROOT_CTX.checks||[]).length>0&&f("div",{className:"DocEditor__statusBar__checks",children:f(Z,{className:xe("DocEditor__statusBar__buttonGroup__button",_?"DocEditor__statusBar__buttonGroup__button--active":""),variant:"default",color:"dark",size:"xs",leftIcon:f(zE,{size:16}),onClick:()=>{window.dispatchEvent(new CustomEvent("root:toggle-checks"))},children:"Checks"})}),E&&f("div",{className:"DocEditor__statusBar__ai",children:f(we,{label:"\u2318 + i",transition:"pop",withArrow:!0,children:f(Z,{className:xe("DocEditor__statusBar__buttonGroup__button",x?"DocEditor__statusBar__buttonGroup__button--active":""),variant:"default",color:"dark",size:"xs",leftIcon:f(ns,{size:16}),onClick:()=>{window.dispatchEvent(new CustomEvent("root:toggle-ai"))},children:"Root AI"})})})]}),f("div",{className:"DocEditor__statusBar__i18n",children:f(Z,{variant:"default",color:"dark",size:"xs",leftIcon:f(GE,{size:16}),onClick:()=>{m.open({docId:t.docId,collection:t.collection,draft:a.controller,locale:n.locale||void 0})},children:"Localization"})}),f("div",{className:"DocEditor__statusBar__publishButton",children:w?f(Z,{color:"dark",size:"xs",onClick:()=>g.open(),loading:!0,disabled:!0,children:"Publish"}):sE(l)?f(we,{label:`Scheduled ${zC(l.sys.scheduledAt)} by ${l.sys.scheduledBy}`,transition:"pop",children:f(Z,{color:"dark",size:"xs",leftIcon:f(Vh,{size:16}),disabled:!0,children:"Publish"})}):aE(l)?f(we,{label:gE(l),transition:"pop",children:f(Z,{color:"dark",size:"xs",leftIcon:f(KE,{size:16}),disabled:!0,children:"Publish"})}):f(Nw,{label:"You don't have access to publish this document",condition:!i,children:f(Z,{color:"dark",size:"xs",leftIcon:f(Vh,{size:16}),onClick:()=>g.open(),disabled:!i,children:"Publish"})})}),f("div",{className:"DocEditor__statusBar__actionsMenu",children:f(Dw,{docId:t.docId,data:l,onAction:p})})]})};Ie.SaveState=()=>{let[t,e]=L("NO_CHANGES");return t0(n=>{e(n)}),f("div",{className:"DocEditor__statusBar__saveState",children:[t==="SAVED"&&"saved!",t==="SAVING"&&"saving...",t==="UPDATE_PENDING"&&"saving...",t==="ERROR"&&"error saving"]})};Ie.Field=t=>t.field.deprecated?f(Ie.DeprecatedField,{...t}):f(Ie.FieldBody,{...t});Ie.DeprecatedField=t=>{let[e,n]=L(!0),o=Dh();return Xo(t.deepKey,r=>{n(ls(t.field,r,o))}),e?null:f(Ie.FieldBody,{...t})};Ie.FieldBody=t=>{let e=t.field,n=t.level??0,r=lc().value===t.deepKey,i=J(null),s=X(()=>e.type==="object"&&(e.variant||"drawer")==="drawer"?!1:!t.hideHeader&&!e.hideLabel,[t.hideHeader,e]);return F(()=>{r&&dm(i.current)},[r]),f("div",{className:xe("DocEditor__field",e.deprecated&&"DocEditor__field--deprecated",r&&"deeplink-target"),"data-type":e.type,"data-level":n,id:t.deepKey,ref:i,children:[s&&f(Ie.FieldHeader,{...t}),f("div",{className:"DocEditor__field__input",children:f(Lu,{deepKey:t.deepKey,children:e.type==="array"?f(Ie.ArrayField,{...t}):e.type==="boolean"?f(lS,{...t}):e.type==="date"?f(cS,{...t}):e.type==="datetime"?f(JS,{...t}):e.type==="file"?f(En,{...t}):e.type==="image"?f(ok,{...t}):e.type==="multiselect"?f(rk,{...t}):e.type==="number"?f(ik,{...t}):e.type==="object"?f(Ie.ObjectField,{...t}):e.type==="oneof"?f(Ie.OneOfField,{...t}):e.type==="reference"?f(va,{...t}):e.type==="references"?f(ak,{...t}):e.type==="richtext"?f(ZR,{...t}):e.type==="select"?f(QR,{...t}):e.type==="string"?f(tP,{...t}):f("div",{className:"DocEditor__field__input__unknown",children:["Unknown field type: ",e.type]})})})]})};Ie.FieldHeader=t=>{let e=t.field,n=e.label||e.id,o=lc(),r=X(()=>tS(t.deepKey||""),[t.deepKey]);return f("div",{className:xe(t.className,"DocEditor__FieldHeader"),children:[e.deprecated?f("div",{className:"DocEditor__FieldHeader__label",children:["DEPRECATED: ",n]}):f("div",{className:"DocEditor__FieldHeader__label",children:[f("span",{children:n}),t.deepKey&&f("a",{className:"DocEditor__FieldHeader__label__deeplink",href:r,tabIndex:-1,title:"Link to field",onClick:i=>{i.preventDefault(),window.history.replaceState({},"",r),o.setValue(t.deepKey)},children:"#"})]}),e.help&&f("div",{className:"DocEditor__FieldHeader__help",children:e.help}),f(Ie.FieldHeaderTranslationsActionIcon,{field:e,deepKey:t.deepKey})]})};Ie.FieldHeaderTranslationsActionIcon=t=>{let n=!!t.field.translate,r=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];return!n||r.length<=1?null:f(Ie.FieldHeaderTranslationsActionIconInner,{...t})};Ie.FieldHeaderTranslationsActionIconInner=t=>{let e=t.field,n=Hw(),o=sn(),[r,i]=L(()=>o.controller.getValue(t.deepKey));Xo(t.deepKey,d=>{i(d)});let s=Dh(),a=X(()=>ls(e,r,s),[e,s,r]),[l,c]=L(!1);return F(()=>{if(!t.deepKey||!o.controller)return;let d=jG(t.deepKey);return o.controller.subscribe(d,p=>{c(p?.translate===!1)})},[t.deepKey,o.controller]),f("div",{className:"DocEditor__FieldHeader__translate",children:l?f(we,{label:"Translations are disabled",children:f(Ae,{size:"xs",onClick:()=>{let d=o.controller.getData();if(!d)return;let u=new Set;Zh(u,e,r,s);let p=Array.from(u);n.open({docId:o.controller.docId,strings:p,l10nSheet:d?.sys?.l10nSheet,field:{id:e.id||t.deepKey,deepKey:t.deepKey},draft:o})},children:f(PE,{size:16})})}):a?f("div",{className:"DocEditor__FieldHeader__translate__iconDisabled",children:f(ts,{size:16})}):f(we,{label:"Show translations",children:f(Ae,{size:"xs",onClick:()=>{let d=o.controller.getData();if(!d)return;let u=new Set;Zh(u,e,r,s);let p=Array.from(u);n.open({docId:o.controller.docId,strings:p,l10nSheet:d?.sys?.l10nSheet,field:{id:e.id||t.deepKey,deepKey:t.deepKey},draft:o})},children:f(ts,{size:16})})})})};Ie.ObjectField=t=>{let e=t.field,n=e.variant;return n||(t.isArrayChild?n="inline":n="drawer"),n==="drawer"?f(Ie.ObjectFieldDrawer,{...t}):f("div",{className:"DocEditor__ObjectField",children:f("div",{className:"DocEditor__ObjectField__fields",children:e.fields.map(o=>f(Ie.Field,{field:o,deepKey:`${t.deepKey}.${o.id}`},o.id))})})};Ie.ObjectFieldDrawer=t=>{let e=t.field,n=e.drawerOptions?.collapsed||!1,o=e.drawerOptions?.inline||!1,r=sn().controller,i=um(),s=rg(),a=St(),l=ot(),c=lc(),d=!n||c.value.includes(t.deepKey),u=()=>{let _=r.getValue(t.deepKey)||{};i.set(_),ae({message:"Copied to clipboard",autoClose:2e3})},p=async()=>{let _=await i.get();if(!_||typeof _!="object"){ae({message:"Clipboard empty (nothing to paste)",color:"red",autoClose:2e3});return}r.updateKey(t.deepKey,_),ae({message:"Pasted from clipboard",autoClose:2e3})},h=async _=>{await r.removeKey(t.deepKey),ae({message:"Cleared",autoClose:2e3}),await r.flush(),_&&a.closeModal(_)},g=()=>{let _=e.label||e.id||"drawer",b=a.openConfirmModal({...l,title:`Clear ${_}?`,children:f(os,{size:"body-sm",weight:"semi-bold",className:"DocEditor__ObjectFieldDrawer__confirmText",children:"This will clear all values in this section. There is no undo."}),labels:{confirm:"Clear",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},closeOnConfirm:!1,onConfirm:()=>h(b)})},m=()=>{let _=r.getValue(t.deepKey)||{};s.open({data:_,onSave:b=>{r.updateKey(t.deepKey,b),s.close()}})};return f("div",{className:xe("DocEditor__ObjectFieldDrawer",o&&"DocEditor__ObjectFieldDrawer--inline"),children:f("details",{className:"DocEditor__ObjectFieldDrawer__drawer",open:d,children:[f("summary",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle",children:[f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__icon",children:f(Fl,{size:16})}),f(Ie.FieldHeader,{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__header",field:e,deepKey:t.deepKey}),f(G,{className:"DocEditor__ObjectFieldDrawer__drawer__menu",position:"bottom",transitionDuration:0,control:f(Ae,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__dots",onClick:_=>{_.stopPropagation(),_.preventDefault()},children:f(sa,{size:16})}),children:[f(G.Label,{children:"CLIPBOARD"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(Uh,{size:18}),onClick:u,children:"Copy"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(Vd,{size:18}),onClick:p,children:"Paste"}),f(G.Label,{children:"CODE"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(Hh,{size:18}),onClick:m,children:"Edit JSON"}),f(G.Label,{children:"ACTIONS"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(Zn,{size:18}),onClick:g,children:"Clear"})]})]}),f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__content DocEditor__ObjectFieldDrawer__fields",children:e.fields.map(_=>f(Ie.Field,{field:_,deepKey:`${t.deepKey}.${_.id}`},_.id))})]})})};function zG(t,e){switch(e.type){case"update":{let n=t._new||[];return{...e.newValue,_new:n}}case"updateItem":{let n=t??{},r=[...n._array||[]][e.index],i=e.newValue??{};return e.draft.updateKey(`${e.deepKey}.${r}`,i),{...n,[r]:i}}case"add":{let n=t??{},o=No(),r=structuredClone(e.defaultValue||{}),i=[...n._array||[],o];e.draft.updateKeys({[`${e.deepKey}._array`]:i,[`${e.deepKey}.${o}`]:r});let s=t._new||[];return{...n,[o]:r,_array:i,_new:[...s,o]}}case"insertBefore":{let n=t??{},o=[...n._array||[]],r=No(),i=structuredClone(e.defaultValue||{});o.splice(e.index,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:[...s,r]}}case"insertAfter":{let n=t??{},o=[...n._array||[]],r=No(),i=structuredClone(e.defaultValue||{});o.splice(e.index+1,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:[...s,r]}}case"duplicate":{let n=t??{},o=[...n._array||[]],r=No(),i=structuredClone(e.value);o.splice(e.index+1,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:[...s,r]}}case"moveUp":{if(e.index===0)return t;let n=t??{},o=[...n._array||[]];return nP(o,e.index,e.index-1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...n,_array:o,_moved:o[e.index-1]}}case"moveDown":{let n=t??{},o=[...n._array||[]];return e.index>=o.length-1?t:(nP(o,e.index,e.index+1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...n,_array:o,_moved:o[e.index+1]})}case"moveTo":{let n=t??{},o=[...n._array||[]];if(e.fromIndex<0||e.fromIndex>=o.length||e.toIndex<0||e.toIndex>=o.length)return console.error("Invalid moveTo index",e),t;let r=o[e.fromIndex];return HG(o,e.fromIndex,e.toIndex),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...n,_array:o,_moved:r}}case"removeAt":{let n={...t??{}},r=[...n._array||[]],i=r[e.index];return delete n[i],r.splice(e.index,1),e.draft.updateKeys({[`${e.deepKey}._array`]:r}),e.draft.removeKey(`${e.deepKey}.${i}`),{...n,_array:r}}case"pasteAfter":{let n=t??{},o=[...n._array||[]],r=No(),i=e.data;if(!i)return ae({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index+1,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:s,_pasted:r}}case"pasteBefore":{let n=t??{},o=[...n._array||[]],r=No(),i=e.data;if(!i)return ae({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:s,_pasted:r}}default:return console.error("unknown action",e),t}}Ie.ArrayField=t=>{let e=sn().controller,n=t.field,[o,r]=CC(zG,{_array:[]}),i=lc(),s=um(),l=(o??{})._array||[],c=o._new||[],[d,u]=L(null);Xo(t.deepKey,P=>{r({type:"update",newValue:P})}),F(()=>{o._moved?E(t.deepKey,l.indexOf(o._moved)):o._pasted&&E(t.deepKey,l.indexOf(o._pasted))},[o]);let p=P=>{let q=l[P],de=`${t.deepKey}.${q}`;return e.getValue(de)||{}},h=()=>{r({type:"add",draft:e,deepKey:t.deepKey,defaultValue:n.itemDefault||{}})},g=(P,q)=>{r({type:"pasteBefore",draft:e,deepKey:t.deepKey,index:P,data:q})},m=(P,q)=>{r({type:"pasteAfter",draft:e,deepKey:t.deepKey,index:P,data:q})},_=async P=>{g(P,await s.get())},b=async P=>{m(P,await s.get())},y=P=>{r({type:"insertBefore",draft:e,deepKey:t.deepKey,index:P,defaultValue:n.itemDefault||{}})},v=P=>{r({type:"insertAfter",draft:e,deepKey:t.deepKey,index:P,defaultValue:n.itemDefault||{}})},x=P=>{r({type:"duplicate",draft:e,deepKey:t.deepKey,index:P,value:p(P)})},C=P=>{r({type:"removeAt",draft:e,deepKey:t.deepKey,index:P})},E=(P,q)=>{document.getElementById(`summary-for-${P}.${l[q]}`)?.focus()},k=P=>{P>0&&r({type:"moveUp",draft:e,deepKey:t.deepKey,index:P})},T=P=>{P<l.length-1&&r({type:"moveDown",draft:e,deepKey:t.deepKey,index:P})},w=P=>{let q=p(P);s.set(q),u(null),ae({message:"Copied to clipboard",autoClose:2e3})},S=P=>{let q=p(P);s.set(q),u(P),ae({message:"Cut to clipboard",autoClose:2e3})},N=async P=>{let q=await s.get();if(!q){ae({message:"Clipboard empty (nothing to paste)",color:"red",autoClose:2e3});return}if(m(P,q),d!==null){let de=d;P<d&&(de+=1),C(de),u(null)}ae({message:"Pasted item",autoClose:2e3})},D=rg(),O=Rw(),A=P=>{let q=p(P);D.open({data:q,onSave:de=>{console.log("[edit json] onSave()",de),r({type:"updateItem",draft:e,index:P,newValue:de,deepKey:t.deepKey}),D.close()}})},I=P=>{let q=p(P);O.open({data:q,onSave:de=>{console.log("[ai edit] onSave()",de),r({type:"updateItem",draft:e,index:P,newValue:de,deepKey:t.deepKey}),O.close()}})};function R(P){return!!i.value.startsWith(`${t.deepKey}.${P}`)}let $=De((P,q)=>{if(!P.target)return;let de=l.indexOf(q);P.metaKey&&P.key==="x"?(P.preventDefault(),S(de)):P.metaKey&&P.key==="c"?(P.preventDefault(),w(de)):P.metaKey&&P.key==="v"?(P.preventDefault(),N(de)):P.metaKey&&(P.key==="Backspace"||P.key==="Delete")?(P.preventDefault(),C(de),ae({message:"Deleted item",autoClose:2e3})):P.key==="ArrowUp"?(P.preventDefault(),k(de)):P.key==="ArrowDown"?(P.preventDefault(),T(de)):P.key==="ArrowLeft"?P.target.closest("details").open=!1:P.key==="ArrowRight"&&(P.target.closest("details").open=!0)},[t.deepKey,l,d]),W=f("div",{className:"DocEditor__ArrayField__add",children:[f(Z,{className:"DocEditor__ArrayField__add__button",color:"dark",size:"xs",leftIcon:f(CE,{size:16}),onClick:()=>h(),children:n.buttonLabel||"Add"}),f(G,{className:"DocEditor__ArrayField__add__menu",control:f(Ae,{className:"DocEditor__ArrayField__item__header__controls__dots",children:f(sa,{size:16})}),children:[f(G.Label,{children:"CLIPBOARD"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Qd,{size:18}),onClick:()=>N(l.length-1),children:"Paste item to end"})]})]});return l.length===0&&!o._new?f("div",{className:"DocEditor__ArrayField",children:[f("div",{className:"DocEditor__ArrayField__items",children:f("div",{className:"DocEditor__ArrayField__items__empty",children:"No items"})}),W]}):f("div",{className:"DocEditor__ArrayField",children:[f(Ou,{onDragEnd:P=>{let{source:q,destination:de}=P;de&&r({type:"moveTo",fromIndex:q.index,toIndex:de.index,draft:e,deepKey:t.deepKey})},children:f(Au,{droppableId:"dnd-list",direction:"vertical",children:P=>f("div",{...P.droppableProps,ref:P.innerRef,className:"DocEditor__ArrayField__items",children:[l.map((q,de)=>f(Ie.ArrayFieldItem,{field:n,parentDeepKey:t.deepKey,itemKey:q,index:de,initialOpen:c.includes(q)||R(q)||!!n.defaultOpen,isCut:d===de,aiEnabled:Io(),onFocusHeader:E,onHeaderKeyDown:$,onMoveUp:k,onMoveDown:T,onInsertBefore:y,onInsertAfter:v,onDuplicate:x,onCopy:w,onPasteBefore:_,onPasteAfter:b,onEditJson:A,onAiEdit:I,onRemove:C},q)),P.placeholder]})})}),W]})};Ie.ArrayFieldItem=t=>{let e=`${t.parentDeepKey}.${t.itemKey}`;return f(Iu,{index:t.index,draggableId:t.itemKey,children:(n,o)=>f("div",{ref:n.innerRef,...n.draggableProps,className:xe("DocEditor__ArrayField__item__wrapper",o.isDragging&&"DocEditor__ArrayField__item__wrapper--dragging",t.isCut&&"DocEditor__ArrayField__item__wrapper--cut"),children:[f("div",{className:"DocEditor__ArrayField__item__handle",...n.dragHandleProps,onClick:()=>t.onFocusHeader(t.parentDeepKey,t.index),children:f(Yd,{size:18,stroke:"1.5"})}),f("details",{className:"DocEditor__ArrayField__item",open:t.initialOpen,onToggle:r=>{r.target.open?no(e,{scroll:!0}):no(null)},onMouseEnter:()=>{no(e)},onMouseLeave:()=>{no(null)},children:[f("summary",{id:`summary-for-${e}`,className:"DocEditor__ArrayField__item__header",onKeyDown:r=>t.onHeaderKeyDown(r,t.itemKey),tabIndex:0,children:[f("div",{className:"DocEditor__ArrayField__item__header__icon",children:f(nw,{size:6})}),f(Ie.ArrayFieldPreview,{field:t.field,deepKey:e,index:t.index}),f("div",{className:"DocEditor__ArrayField__item__header__controls",children:[f("div",{className:"DocEditor__ArrayField__item__header__controls__arrows",children:[f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--up",onClick:()=>t.onMoveUp(t.index),children:f(vE,{size:20,strokeWidth:1.75})}),f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--down",onClick:()=>t.onMoveDown(t.index),children:f(xE,{size:20,strokeWidth:1.75})})]}),f(G,{className:"DocEditor__ArrayField__item__header__controls__menu",position:"bottom",transitionDuration:0,control:f(Ae,{className:"DocEditor__ArrayField__item__header__controls__dots",children:f(sa,{size:16})}),children:[f(G.Label,{children:"INSERT"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Wh,{size:18}),onClick:()=>t.onInsertBefore(t.index),children:"Add before"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Qd,{size:18}),onClick:()=>t.onInsertAfter(t.index),children:"Add after"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Gd,{size:18}),onClick:()=>t.onDuplicate(t.index),children:"Duplicate"}),f(G.Label,{children:"CLIPBOARD"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Uh,{size:18}),onClick:()=>t.onCopy(t.index),children:"Copy"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Wh,{size:18}),onClick:()=>t.onPasteBefore(t.index),children:"Paste before"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Qd,{size:18}),onClick:()=>t.onPasteAfter(t.index),children:"Paste after"}),f(G.Label,{children:"CODE"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Hh,{size:18}),onClick:()=>t.onEditJson(t.index),children:"Edit JSON"}),t.aiEnabled&&f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(cu,{size:16}),onClick:()=>t.onAiEdit(t.index),children:"Edit with Root AI"}),f(G.Label,{children:"REMOVE"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Zn,{size:18}),onClick:()=>t.onRemove(t.index),children:"Remove"})]})]})]}),f("div",{className:"DocEditor__ArrayField__item__body",children:f(Ie.Field,{field:t.field.of,deepKey:e,hideHeader:!0,isArrayChild:!0,onFocus:()=>{no(e,{scroll:!0})},onBlur:()=>{no(null)}},e)})]})]})},t.itemKey)};Ie.ArrayFieldPreview=t=>{let e=sn().controller,n=Dh(),[o,r]=L(e.getValue(t.deepKey)),i=X(()=>UG(t.field,o,n),[t.field,n,o]),s=X(()=>KG(t.field,o,t.index,n),[t.field,t.index,n,o]),a=X(()=>du(l=>{r(l&&typeof l=="object"?{...l}:l)},250),[]);return F(()=>e.subscribeSubtree(t.deepKey,a),[t.deepKey,e,a]),f("div",{className:"DocEditor__ArrayField__item__header__preview",children:[i&&f("div",{className:"DocEditor__ArrayField__item__header__preview__image",children:f("img",{src:i,alt:"",className:"DocEditor__ArrayField__item__header__preview__image__img",loading:"lazy"})}),f("div",{className:"DocEditor__ArrayField__item__header__preview__title","data-preview":s})]})};Ie.OneOfField=t=>{let e=t.field,n=e.variant||window.__ROOT_CTX.defaultOneOfVariant||"dropdown",[o,r]=L(""),i=Dh(),s=Array.isArray(e.types)?e.types:[],a={},l=[],c=[{value:"",label:e.placeholder||"Select type"}];s.forEach(x=>{let C,E;typeof x=="string"?(C=i[x],E=x):(C=x,E=x.name),E&&(C&&(a[E]=C,l.push(C)),c.push({value:E,label:E}))});let d=a[o||""],u=sn().controller,p=Fw(),h=X(()=>({}),[]);async function g(x,C){let E={};if(x){let k=a[x];if(C&&k){let T=aa(k),w=mw(k,C,i);Object.assign(E,pE(T,w))}else x in h?Object.assign(E,h[x]):k&&Object.assign(E,aa(k))}E._type=x,await u.updateKey(t.deepKey,E),r(x)}async function m(x){await g(x)}Xo(t.deepKey,x=>{r(x?._type||""),x?._type&&(h[x._type]=x)});function _(x){let C=x.target;C&&C.select&&C.select()}function b(){let x=[];return l.forEach(C=>{x.push({key:`${C.name}::__blank__`,schema:C}),(C.presets||[]).forEach(E=>{x.push({key:`${C.name}::${E.id}`,schema:C,preset:E})})}),x}function y(){p.open({options:b(),onSelect:async x=>{await g(x.schema.name,x.preset?.data),p.close()},onRemove:d?async()=>{await g(""),p.close()}:void 0})}let v=d&&f("div",{className:"DocEditor__OneOfField__fields",children:d.fields.map(x=>f(Ie.Field,{field:x,deepKey:`${t.deepKey}.${x.id}`,onBlur:()=>{no(null)},onFocus:()=>{no(`${t.deepKey}.${x.id}`,{scroll:!0})}},`${o}::${x.id}`))});if(n==="picker"){let x=d?d.label||d.name:e.placeholder||"Select type";return f("div",{className:"DocEditor__OneOfField DocEditor__OneOfField--picker",children:[f("div",{className:"DocEditor__OneOfField__pickerButton",children:[f("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),f(Z,{variant:"default",color:"dark",size:"xs",onClick:y,rightIcon:f(go,{size:16}),children:x})]}),v]})}return f("div",{className:"DocEditor__OneOfField",children:[f("div",{className:"DocEditor__OneOfField__select",children:[f("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),f(Rn,{data:c,value:o,placeholder:e.placeholder,onChange:x=>m(x||""),onFocus:_,size:"xs",radius:0,searchable:!0,dropdownComponent:"div"})]}),v]})};function nP(t,e,n){if(t.length<=1)return t;let o=t[e];return t[e]=t[n],t[n]=o,t}function HG(t,e,n){let[o]=t.splice(e,1);t.splice(n,0,o)}function rP(t,e,n,o="title"){if(t.type==="oneof"){let r=t,i=e?._type;if(i){let s,a=Array.isArray(r.types)?r.types:[];return typeof a[0]=="string"?s=n[i]:s=a.find(l=>l.name===i),s?.preview?.[o]||null}}return null}function UG(t,e,n){let o=rP(t.of,e,n,"image");if(o)return ma(o,e)}function KG(t,e,n,o){let r=rP(t.of,e,o,"title");if(r){let i=ma(r,e,{index:n});if(i)return i}return t.preview?ma(t.preview,e,{index:n})??`item ${n}`:`item ${n}`}function jG(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}export{vP as a,CP as b,ng as c,rg as d,TP as e,sg as f,ag as g,Jo as h,IP as i,du as j,e0 as k,sn as l,t0 as m,Kq as n,qv as o,Jv as p,Mae as q,JR as r,Ie as s,Om as t};
|
|
141
|
+
`)&&f("br",{})]})}function tP(t){let e=t.field,[n,o]=At(t.deepKey,""),r=J(null),i=J(null),[s,a]=L(null);if(n!=null&&typeof n!="string")throw new Error(`Expected a string value but got ${typeof n}. The stored data for this field may be corrupted. Fix it using "Edit JSON" or restore a previous version.`);let l=g=>{o(g.currentTarget.value)},c=g=>{t.onFocus?.(g),no(t.deepKey,{scroll:!0})},d=g=>{t.onBlur?.(g),no(null)},u=g=>{let m=g.target.value;if(m.trim()){let _=m;try{let b=m.replace(/'([^'\\]*(?:\\.[^'\\]*)*)'/g,'"$1"').replace(/,\s*([\]}])/g,"$1");JSON.parse(b),_=b}catch{}try{let b=JSON.parse(_),y=JSON.stringify(b,null,2);o(y),a(null)}catch(b){a(b.message)}}else a(null);t.onBlur?.(g),no(null)},p=g=>{r.current&&(r.current.scrollTop=g.target.scrollTop,r.current.scrollLeft=g.target.scrollLeft)},h=g=>{i.current&&(i.current.scrollLeft=g.target.scrollLeft)};return e.variant==="json"?f("div",{className:"StringField__container",children:[f(bn,{className:xe("StringField__input","StringField__input--json",s&&"StringField__input--error"),size:"xs",radius:0,autosize:e.autosize,minRows:4,maxRows:e.maxRows||20,value:n,onChange:l,onFocus:c,onBlur:u,onScroll:p}),s&&f("div",{className:"StringField__jsonError",children:["Invalid JSON: ",s]})]}):e.variant==="textarea"?f("div",{className:"StringField__container",children:[f(eP,{value:n||"",variant:"textarea",scrollRef:r}),f(bn,{className:"StringField__input",size:"xs",radius:0,autosize:e.autosize,minRows:4,maxRows:e.maxRows||12,value:n,onChange:l,onFocus:c,onBlur:d,onScroll:p})]}):f("div",{className:"StringField__container",children:[f(eP,{value:n||"",variant:"input",scrollRef:i}),f(Xn,{className:"StringField__input",size:"xs",radius:0,value:n,onChange:l,onFocus:c,onBlur:d,onScroll:h})]})}var oP=pt({});function Dh(){return ft(oP)}function Ie(t){let e=t.docId.split("/")[0],n=bw(e),o=sn(),r=n.loading||o.loading,i=n.schema?.fields||[];return f(oP.Provider,{value:n?.schema?.types||{},children:f(eS,{children:f("div",{className:xe(t.className,"DocEditor"),children:[f(Nd,{visible:r,loaderProps:{color:"gray",size:"xl"}}),!r&&!t.hideStatusBar&&f(Ie.StatusBar,{...t,draft:o,collection:n.schema}),f("div",{className:"DocEditor__fields",children:i.map(s=>f(Ie.Field,{field:s,deepKey:`fields.${s.id}`},s.id))})]})})})}Ie.StatusBar=t=>{let{route:e,query:n}=BC(),{roles:o}=su(),r=window.firebase.user.email||"",i=au(o,r),s=gw(o,r),a=t.draft,[l,c]=L(a.controller.getData());Xo("sys",S=>{c({sys:S})});let d=De(S=>{S==="unlocked"&&a.controller.removePublishingLock()},[a.controller]),u=Tw({docId:t.docId,onChange:d}),p=De(S=>{if(S.action==="delete"){let N=t.docId.split("/")[0];e(`/cms/content/${N}`)}else S.action==="unlocked"&&a.controller.removePublishingLock()},[t.docId]),h=De(()=>{if(!s)return;let S=l?.sys?.publishingLocked;S&&u.open({existingLock:{reason:S.reason,until:S.until?S.until.toMillis():void 0}})},[s,l?.sys?.publishingLocked,u]),g=Jw({docId:t.docId}),m=Ww(),[_,b]=L(()=>{try{let S=window.localStorage.getItem("root::DocumentPage::checksVisible");return S?JSON.parse(S)===!0:!1}catch{return!1}}),[y,v]=L(()=>{try{let S=window.localStorage.getItem("root::DocumentPage::searchVisible");return S?JSON.parse(S)===!0:!1}catch{return!1}}),[x,C]=L(()=>{try{let S=window.localStorage.getItem("root::DocumentPage::aiVisible");return S?JSON.parse(S)===!0:!1}catch{return!1}}),E=Io();F(()=>{let S=N=>{b(N.detail===!0)};return window.addEventListener("root:checks-visible",S),()=>window.removeEventListener("root:checks-visible",S)},[]),F(()=>{let S=N=>{v(N.detail===!0)};return window.addEventListener("root:search-visible",S),()=>window.removeEventListener("root:search-visible",S)},[]),F(()=>{let S=N=>{C(N.detail===!0)};return window.addEventListener("root:ai-visible",S),()=>window.removeEventListener("root:ai-visible",S)},[]);let k=n.locale||"",T=n.modal||"";F(()=>{T==="localization"&&a.controller&&m.open({docId:t.docId,collection:t.collection,draft:a.controller,locale:k||void 0})},[]);let w=!l?.sys;return w?null:f("div",{className:"DocEditor__statusBar",children:[f("div",{className:"DocEditor__statusBar__viewers",children:f(aS,{id:`doc/${t.docId}`})}),f(Ie.SaveState,{}),l?.sys&&f("div",{className:"DocEditor__statusBar__statusBadges",children:f(rw,{doc:l,docId:t.docId,onPublishingLockClick:s?h:void 0})}),f("div",{className:"DocEditor__statusBar__buttonGroup",children:[f("div",{className:"DocEditor__statusBar__search",children:f(we,{label:"\u2318 + Shift + f",transition:"pop",withArrow:!0,children:f(Z,{className:xe("DocEditor__statusBar__buttonGroup__button",y?"DocEditor__statusBar__buttonGroup__button--active":""),variant:"default",color:"dark",size:"xs",leftIcon:f(Qd,{size:16}),onClick:()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},children:"Search"})})}),(window.__ROOT_CTX.checks||[]).length>0&&f("div",{className:"DocEditor__statusBar__checks",children:f(Z,{className:xe("DocEditor__statusBar__buttonGroup__button",_?"DocEditor__statusBar__buttonGroup__button--active":""),variant:"default",color:"dark",size:"xs",leftIcon:f(RE,{size:16}),onClick:()=>{window.dispatchEvent(new CustomEvent("root:toggle-checks"))},children:"Checks"})}),E&&f("div",{className:"DocEditor__statusBar__ai",children:f(we,{label:"\u2318 + i",transition:"pop",withArrow:!0,children:f(Z,{className:xe("DocEditor__statusBar__buttonGroup__button",x?"DocEditor__statusBar__buttonGroup__button--active":""),variant:"default",color:"dark",size:"xs",leftIcon:f(ns,{size:16}),onClick:()=>{window.dispatchEvent(new CustomEvent("root:toggle-ai"))},children:"Root AI"})})})]}),f("div",{className:"DocEditor__statusBar__i18n",children:f(Z,{variant:"default",color:"dark",size:"xs",leftIcon:f(UE,{size:16}),onClick:()=>{m.open({docId:t.docId,collection:t.collection,draft:a.controller,locale:n.locale||void 0})},children:"Localization"})}),f("div",{className:"DocEditor__statusBar__publishButton",children:w?f(Z,{color:"dark",size:"xs",onClick:()=>g.open(),loading:!0,disabled:!0,children:"Publish"}):sE(l)?f(we,{label:`Scheduled ${zC(l.sys.scheduledAt)} by ${l.sys.scheduledBy}`,transition:"pop",children:f(Z,{color:"dark",size:"xs",leftIcon:f(jh,{size:16}),disabled:!0,children:"Publish"})}):aE(l)?f(we,{label:iw(l),transition:"pop",children:f(Z,{color:"dark",size:"xs",leftIcon:f(BE,{size:16}),disabled:!0,children:"Publish"})}):f(Nw,{label:"You don't have access to publish this document",condition:!i,children:f(Z,{color:"dark",size:"xs",leftIcon:f(jh,{size:16}),onClick:()=>g.open(),disabled:!i,children:"Publish"})})}),f("div",{className:"DocEditor__statusBar__actionsMenu",children:f(Dw,{docId:t.docId,data:l,onAction:p})})]})};Ie.SaveState=()=>{let[t,e]=L("NO_CHANGES");return t0(n=>{e(n)}),f("div",{className:"DocEditor__statusBar__saveState",children:[t==="SAVED"&&"saved!",t==="SAVING"&&"saving...",t==="UPDATE_PENDING"&&"saving...",t==="ERROR"&&"error saving"]})};Ie.Field=t=>t.field.deprecated?f(Ie.DeprecatedField,{...t}):f(Ie.FieldBody,{...t});Ie.DeprecatedField=t=>{let[e,n]=L(!0),o=Dh();return Xo(t.deepKey,r=>{n(ls(t.field,r,o))}),e?null:f(Ie.FieldBody,{...t})};Ie.FieldBody=t=>{let e=t.field,n=t.level??0,r=lc().value===t.deepKey,i=J(null),s=X(()=>e.type==="object"&&(e.variant||"drawer")==="drawer"?!1:!t.hideHeader&&!e.hideLabel,[t.hideHeader,e]);return F(()=>{r&&dm(i.current)},[r]),f("div",{className:xe("DocEditor__field",e.deprecated&&"DocEditor__field--deprecated",r&&"deeplink-target"),"data-type":e.type,"data-level":n,id:t.deepKey,ref:i,children:[s&&f(Ie.FieldHeader,{...t}),f("div",{className:"DocEditor__field__input",children:f(Lu,{deepKey:t.deepKey,children:e.type==="array"?f(Ie.ArrayField,{...t}):e.type==="boolean"?f(lS,{...t}):e.type==="date"?f(cS,{...t}):e.type==="datetime"?f(JS,{...t}):e.type==="file"?f(En,{...t}):e.type==="image"?f(ok,{...t}):e.type==="multiselect"?f(rk,{...t}):e.type==="number"?f(ik,{...t}):e.type==="object"?f(Ie.ObjectField,{...t}):e.type==="oneof"?f(Ie.OneOfField,{...t}):e.type==="reference"?f(va,{...t}):e.type==="references"?f(ak,{...t}):e.type==="richtext"?f(ZR,{...t}):e.type==="select"?f(QR,{...t}):e.type==="string"?f(tP,{...t}):f("div",{className:"DocEditor__field__input__unknown",children:["Unknown field type: ",e.type]})})})]})};Ie.FieldHeader=t=>{let e=t.field,n=e.label||e.id,o=lc(),r=X(()=>tS(t.deepKey||""),[t.deepKey]);return f("div",{className:xe(t.className,"DocEditor__FieldHeader"),children:[e.deprecated?f("div",{className:"DocEditor__FieldHeader__label",children:["DEPRECATED: ",n]}):f("div",{className:"DocEditor__FieldHeader__label",children:[f("span",{children:n}),t.deepKey&&f("a",{className:"DocEditor__FieldHeader__label__deeplink",href:r,tabIndex:-1,title:"Link to field",onClick:i=>{i.preventDefault(),window.history.replaceState({},"",r),o.setValue(t.deepKey)},children:"#"})]}),e.help&&f("div",{className:"DocEditor__FieldHeader__help",children:e.help}),f(Ie.FieldHeaderTranslationsActionIcon,{field:e,deepKey:t.deepKey})]})};Ie.FieldHeaderTranslationsActionIcon=t=>{let n=!!t.field.translate,r=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];return!n||r.length<=1?null:f(Ie.FieldHeaderTranslationsActionIconInner,{...t})};Ie.FieldHeaderTranslationsActionIconInner=t=>{let e=t.field,n=Hw(),o=sn(),[r,i]=L(()=>o.controller.getValue(t.deepKey));Xo(t.deepKey,d=>{i(d)});let s=Dh(),a=X(()=>ls(e,r,s),[e,s,r]),[l,c]=L(!1);return F(()=>{if(!t.deepKey||!o.controller)return;let d=jG(t.deepKey);return o.controller.subscribe(d,p=>{c(p?.translate===!1)})},[t.deepKey,o.controller]),f("div",{className:"DocEditor__FieldHeader__translate",children:l?f(we,{label:"Translations are disabled",children:f(Ae,{size:"xs",onClick:()=>{let d=o.controller.getData();if(!d)return;let u=new Set;Zh(u,e,r,s);let p=Array.from(u);n.open({docId:o.controller.docId,strings:p,l10nSheet:d?.sys?.l10nSheet,field:{id:e.id||t.deepKey,deepKey:t.deepKey},draft:o})},children:f(IE,{size:16})})}):a?f("div",{className:"DocEditor__FieldHeader__translate__iconDisabled",children:f(ts,{size:16})}):f(we,{label:"Show translations",children:f(Ae,{size:"xs",onClick:()=>{let d=o.controller.getData();if(!d)return;let u=new Set;Zh(u,e,r,s);let p=Array.from(u);n.open({docId:o.controller.docId,strings:p,l10nSheet:d?.sys?.l10nSheet,field:{id:e.id||t.deepKey,deepKey:t.deepKey},draft:o})},children:f(ts,{size:16})})})})};Ie.ObjectField=t=>{let e=t.field,n=e.variant;return n||(t.isArrayChild?n="inline":n="drawer"),n==="drawer"?f(Ie.ObjectFieldDrawer,{...t}):f("div",{className:"DocEditor__ObjectField",children:f("div",{className:"DocEditor__ObjectField__fields",children:e.fields.map(o=>f(Ie.Field,{field:o,deepKey:`${t.deepKey}.${o.id}`},o.id))})})};Ie.ObjectFieldDrawer=t=>{let e=t.field,n=e.drawerOptions?.collapsed||!1,o=e.drawerOptions?.inline||!1,r=sn().controller,i=um(),s=rg(),a=St(),l=ot(),c=lc(),d=!n||c.value.includes(t.deepKey),u=()=>{let _=r.getValue(t.deepKey)||{};i.set(_),ae({message:"Copied to clipboard",autoClose:2e3})},p=async()=>{let _=await i.get();if(!_||typeof _!="object"){ae({message:"Clipboard empty (nothing to paste)",color:"red",autoClose:2e3});return}r.updateKey(t.deepKey,_),ae({message:"Pasted from clipboard",autoClose:2e3})},h=async _=>{await r.removeKey(t.deepKey),ae({message:"Cleared",autoClose:2e3}),await r.flush(),_&&a.closeModal(_)},g=()=>{let _=e.label||e.id||"drawer",b=a.openConfirmModal({...l,title:`Clear ${_}?`,children:f(os,{size:"body-sm",weight:"semi-bold",className:"DocEditor__ObjectFieldDrawer__confirmText",children:"This will clear all values in this section. There is no undo."}),labels:{confirm:"Clear",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},closeOnConfirm:!1,onConfirm:()=>h(b)})},m=()=>{let _=r.getValue(t.deepKey)||{};s.open({data:_,onSave:b=>{r.updateKey(t.deepKey,b),s.close()}})};return f("div",{className:xe("DocEditor__ObjectFieldDrawer",o&&"DocEditor__ObjectFieldDrawer--inline"),children:f("details",{className:"DocEditor__ObjectFieldDrawer__drawer",open:d,children:[f("summary",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle",children:[f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__icon",children:f(Fl,{size:16})}),f(Ie.FieldHeader,{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__header",field:e,deepKey:t.deepKey}),f(G,{className:"DocEditor__ObjectFieldDrawer__drawer__menu",position:"bottom",transitionDuration:0,control:f(Ae,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__dots",onClick:_=>{_.stopPropagation(),_.preventDefault()},children:f(sa,{size:16})}),children:[f(G.Label,{children:"CLIPBOARD"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(Hh,{size:18}),onClick:u,children:"Copy"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(jd,{size:18}),onClick:p,children:"Paste"}),f(G.Label,{children:"CODE"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(zh,{size:18}),onClick:m,children:"Edit JSON"}),f(G.Label,{children:"ACTIONS"}),f(G.Item,{className:"DocEditor__ObjectFieldDrawer__drawer__menu__item",icon:f(Zn,{size:18}),onClick:g,children:"Clear"})]})]}),f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__content DocEditor__ObjectFieldDrawer__fields",children:e.fields.map(_=>f(Ie.Field,{field:_,deepKey:`${t.deepKey}.${_.id}`},_.id))})]})})};function zG(t,e){switch(e.type){case"update":{let n=t._new||[];return{...e.newValue,_new:n}}case"updateItem":{let n=t??{},r=[...n._array||[]][e.index],i=e.newValue??{};return e.draft.updateKey(`${e.deepKey}.${r}`,i),{...n,[r]:i}}case"add":{let n=t??{},o=No(),r=structuredClone(e.defaultValue||{}),i=[...n._array||[],o];e.draft.updateKeys({[`${e.deepKey}._array`]:i,[`${e.deepKey}.${o}`]:r});let s=t._new||[];return{...n,[o]:r,_array:i,_new:[...s,o]}}case"insertBefore":{let n=t??{},o=[...n._array||[]],r=No(),i=structuredClone(e.defaultValue||{});o.splice(e.index,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:[...s,r]}}case"insertAfter":{let n=t??{},o=[...n._array||[]],r=No(),i=structuredClone(e.defaultValue||{});o.splice(e.index+1,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:[...s,r]}}case"duplicate":{let n=t??{},o=[...n._array||[]],r=No(),i=structuredClone(e.value);o.splice(e.index+1,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:[...s,r]}}case"moveUp":{if(e.index===0)return t;let n=t??{},o=[...n._array||[]];return nP(o,e.index,e.index-1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...n,_array:o,_moved:o[e.index-1]}}case"moveDown":{let n=t??{},o=[...n._array||[]];return e.index>=o.length-1?t:(nP(o,e.index,e.index+1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...n,_array:o,_moved:o[e.index+1]})}case"moveTo":{let n=t??{},o=[...n._array||[]];if(e.fromIndex<0||e.fromIndex>=o.length||e.toIndex<0||e.toIndex>=o.length)return console.error("Invalid moveTo index",e),t;let r=o[e.fromIndex];return HG(o,e.fromIndex,e.toIndex),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...n,_array:o,_moved:r}}case"removeAt":{let n={...t??{}},r=[...n._array||[]],i=r[e.index];return delete n[i],r.splice(e.index,1),e.draft.updateKeys({[`${e.deepKey}._array`]:r}),e.draft.removeKey(`${e.deepKey}.${i}`),{...n,_array:r}}case"pasteAfter":{let n=t??{},o=[...n._array||[]],r=No(),i=e.data;if(!i)return ae({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index+1,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:s,_pasted:r}}case"pasteBefore":{let n=t??{},o=[...n._array||[]],r=No(),i=e.data;if(!i)return ae({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index,0,r),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${r}`]:i});let s=t._new||[];return{...n,[r]:i,_array:o,_new:s,_pasted:r}}default:return console.error("unknown action",e),t}}Ie.ArrayField=t=>{let e=sn().controller,n=t.field,[o,r]=CC(zG,{_array:[]}),i=lc(),s=um(),l=(o??{})._array||[],c=o._new||[],[d,u]=L(null);Xo(t.deepKey,P=>{r({type:"update",newValue:P})}),F(()=>{o._moved?E(t.deepKey,l.indexOf(o._moved)):o._pasted&&E(t.deepKey,l.indexOf(o._pasted))},[o]);let p=P=>{let q=l[P],de=`${t.deepKey}.${q}`;return e.getValue(de)||{}},h=()=>{r({type:"add",draft:e,deepKey:t.deepKey,defaultValue:n.itemDefault||{}})},g=(P,q)=>{r({type:"pasteBefore",draft:e,deepKey:t.deepKey,index:P,data:q})},m=(P,q)=>{r({type:"pasteAfter",draft:e,deepKey:t.deepKey,index:P,data:q})},_=async P=>{g(P,await s.get())},b=async P=>{m(P,await s.get())},y=P=>{r({type:"insertBefore",draft:e,deepKey:t.deepKey,index:P,defaultValue:n.itemDefault||{}})},v=P=>{r({type:"insertAfter",draft:e,deepKey:t.deepKey,index:P,defaultValue:n.itemDefault||{}})},x=P=>{r({type:"duplicate",draft:e,deepKey:t.deepKey,index:P,value:p(P)})},C=P=>{r({type:"removeAt",draft:e,deepKey:t.deepKey,index:P})},E=(P,q)=>{document.getElementById(`summary-for-${P}.${l[q]}`)?.focus()},k=P=>{P>0&&r({type:"moveUp",draft:e,deepKey:t.deepKey,index:P})},T=P=>{P<l.length-1&&r({type:"moveDown",draft:e,deepKey:t.deepKey,index:P})},w=P=>{let q=p(P);s.set(q),u(null),ae({message:"Copied to clipboard",autoClose:2e3})},S=P=>{let q=p(P);s.set(q),u(P),ae({message:"Cut to clipboard",autoClose:2e3})},N=async P=>{let q=await s.get();if(!q){ae({message:"Clipboard empty (nothing to paste)",color:"red",autoClose:2e3});return}if(m(P,q),d!==null){let de=d;P<d&&(de+=1),C(de),u(null)}ae({message:"Pasted item",autoClose:2e3})},D=rg(),O=Rw(),A=P=>{let q=p(P);D.open({data:q,onSave:de=>{console.log("[edit json] onSave()",de),r({type:"updateItem",draft:e,index:P,newValue:de,deepKey:t.deepKey}),D.close()}})},I=P=>{let q=p(P);O.open({data:q,onSave:de=>{console.log("[ai edit] onSave()",de),r({type:"updateItem",draft:e,index:P,newValue:de,deepKey:t.deepKey}),O.close()}})};function R(P){return!!i.value.startsWith(`${t.deepKey}.${P}`)}let $=De((P,q)=>{if(!P.target)return;let de=l.indexOf(q);P.metaKey&&P.key==="x"?(P.preventDefault(),S(de)):P.metaKey&&P.key==="c"?(P.preventDefault(),w(de)):P.metaKey&&P.key==="v"?(P.preventDefault(),N(de)):P.metaKey&&(P.key==="Backspace"||P.key==="Delete")?(P.preventDefault(),C(de),ae({message:"Deleted item",autoClose:2e3})):P.key==="ArrowUp"?(P.preventDefault(),k(de)):P.key==="ArrowDown"?(P.preventDefault(),T(de)):P.key==="ArrowLeft"?P.target.closest("details").open=!1:P.key==="ArrowRight"&&(P.target.closest("details").open=!0)},[t.deepKey,l,d]),W=f("div",{className:"DocEditor__ArrayField__add",children:[f(Z,{className:"DocEditor__ArrayField__add__button",color:"dark",size:"xs",leftIcon:f(_E,{size:16}),onClick:()=>h(),children:n.buttonLabel||"Add"}),f(G,{className:"DocEditor__ArrayField__add__menu",control:f(Ae,{className:"DocEditor__ArrayField__item__header__controls__dots",children:f(sa,{size:16})}),children:[f(G.Label,{children:"CLIPBOARD"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Zd,{size:18}),onClick:()=>N(l.length-1),children:"Paste item to end"})]})]});return l.length===0&&!o._new?f("div",{className:"DocEditor__ArrayField",children:[f("div",{className:"DocEditor__ArrayField__items",children:f("div",{className:"DocEditor__ArrayField__items__empty",children:"No items"})}),W]}):f("div",{className:"DocEditor__ArrayField",children:[f(Ou,{onDragEnd:P=>{let{source:q,destination:de}=P;de&&r({type:"moveTo",fromIndex:q.index,toIndex:de.index,draft:e,deepKey:t.deepKey})},children:f(Au,{droppableId:"dnd-list",direction:"vertical",children:P=>f("div",{...P.droppableProps,ref:P.innerRef,className:"DocEditor__ArrayField__items",children:[l.map((q,de)=>f(Ie.ArrayFieldItem,{field:n,parentDeepKey:t.deepKey,itemKey:q,index:de,initialOpen:c.includes(q)||R(q)||!!n.defaultOpen,isCut:d===de,aiEnabled:Io(),onFocusHeader:E,onHeaderKeyDown:$,onMoveUp:k,onMoveDown:T,onInsertBefore:y,onInsertAfter:v,onDuplicate:x,onCopy:w,onPasteBefore:_,onPasteAfter:b,onEditJson:A,onAiEdit:I,onRemove:C},q)),P.placeholder]})})}),W]})};Ie.ArrayFieldItem=t=>{let e=`${t.parentDeepKey}.${t.itemKey}`;return f(Iu,{index:t.index,draggableId:t.itemKey,children:(n,o)=>f("div",{ref:n.innerRef,...n.draggableProps,className:xe("DocEditor__ArrayField__item__wrapper",o.isDragging&&"DocEditor__ArrayField__item__wrapper--dragging",t.isCut&&"DocEditor__ArrayField__item__wrapper--cut"),children:[f("div",{className:"DocEditor__ArrayField__item__handle",...n.dragHandleProps,onClick:()=>t.onFocusHeader(t.parentDeepKey,t.index),children:f(Gd,{size:18,stroke:"1.5"})}),f("details",{className:"DocEditor__ArrayField__item",open:t.initialOpen,onToggle:r=>{r.target.open?no(e,{scroll:!0}):no(null)},onMouseEnter:()=>{no(e)},onMouseLeave:()=>{no(null)},children:[f("summary",{id:`summary-for-${e}`,className:"DocEditor__ArrayField__item__header",onKeyDown:r=>t.onHeaderKeyDown(r,t.itemKey),tabIndex:0,children:[f("div",{className:"DocEditor__ArrayField__item__header__icon",children:f(XE,{size:6})}),f(Ie.ArrayFieldPreview,{field:t.field,deepKey:e,index:t.index}),f("div",{className:"DocEditor__ArrayField__item__header__controls",children:[f("div",{className:"DocEditor__ArrayField__item__header__controls__arrows",children:[f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--up",onClick:()=>t.onMoveUp(t.index),children:f(mE,{size:20,strokeWidth:1.75})}),f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--down",onClick:()=>t.onMoveDown(t.index),children:f(gE,{size:20,strokeWidth:1.75})})]}),f(G,{className:"DocEditor__ArrayField__item__header__controls__menu",position:"bottom",transitionDuration:0,control:f(Ae,{className:"DocEditor__ArrayField__item__header__controls__dots",children:f(sa,{size:16})}),children:[f(G.Label,{children:"INSERT"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Vh,{size:18}),onClick:()=>t.onInsertBefore(t.index),children:"Add before"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Zd,{size:18}),onClick:()=>t.onInsertAfter(t.index),children:"Add after"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Wd,{size:18}),onClick:()=>t.onDuplicate(t.index),children:"Duplicate"}),f(G.Label,{children:"CLIPBOARD"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Hh,{size:18}),onClick:()=>t.onCopy(t.index),children:"Copy"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Vh,{size:18}),onClick:()=>t.onPasteBefore(t.index),children:"Paste before"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Zd,{size:18}),onClick:()=>t.onPasteAfter(t.index),children:"Paste after"}),f(G.Label,{children:"CODE"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(zh,{size:18}),onClick:()=>t.onEditJson(t.index),children:"Edit JSON"}),t.aiEnabled&&f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(cu,{size:16}),onClick:()=>t.onAiEdit(t.index),children:"Edit with Root AI"}),f(G.Label,{children:"REMOVE"}),f(G.Item,{className:"DocEditor__ArrayField__menu__item",icon:f(Zn,{size:18}),onClick:()=>t.onRemove(t.index),children:"Remove"})]})]})]}),f("div",{className:"DocEditor__ArrayField__item__body",children:f(Ie.Field,{field:t.field.of,deepKey:e,hideHeader:!0,isArrayChild:!0,onFocus:()=>{no(e,{scroll:!0})},onBlur:()=>{no(null)}},e)})]})]})},t.itemKey)};Ie.ArrayFieldPreview=t=>{let e=sn().controller,n=Dh(),[o,r]=L(e.getValue(t.deepKey)),i=X(()=>UG(t.field,o,n),[t.field,n,o]),s=X(()=>KG(t.field,o,t.index,n),[t.field,t.index,n,o]),a=X(()=>du(l=>{r(l&&typeof l=="object"?{...l}:l)},250),[]);return F(()=>e.subscribeSubtree(t.deepKey,a),[t.deepKey,e,a]),f("div",{className:"DocEditor__ArrayField__item__header__preview",children:[i&&f("div",{className:"DocEditor__ArrayField__item__header__preview__image",children:f("img",{src:i,alt:"",className:"DocEditor__ArrayField__item__header__preview__image__img",loading:"lazy"})}),f("div",{className:"DocEditor__ArrayField__item__header__preview__title","data-preview":s})]})};Ie.OneOfField=t=>{let e=t.field,n=e.variant||window.__ROOT_CTX.defaultOneOfVariant||"dropdown",[o,r]=L(""),i=Dh(),s=Array.isArray(e.types)?e.types:[],a={},l=[],c=[{value:"",label:e.placeholder||"Select type"}];s.forEach(x=>{let C,E;typeof x=="string"?(C=i[x],E=x):(C=x,E=x.name),E&&(C&&(a[E]=C,l.push(C)),c.push({value:E,label:E}))});let d=a[o||""],u=sn().controller,p=Fw(),h=X(()=>({}),[]);async function g(x,C){let E={};if(x){let k=a[x];if(C&&k){let T=aa(k),w=yw(k,C,i);Object.assign(E,ZE(T,w))}else x in h?Object.assign(E,h[x]):k&&Object.assign(E,aa(k))}E._type=x,await u.updateKey(t.deepKey,E),r(x)}async function m(x){await g(x)}Xo(t.deepKey,x=>{r(x?._type||""),x?._type&&(h[x._type]=x)});function _(x){let C=x.target;C&&C.select&&C.select()}function b(){let x=[];return l.forEach(C=>{x.push({key:`${C.name}::__blank__`,schema:C}),(C.presets||[]).forEach(E=>{x.push({key:`${C.name}::${E.id}`,schema:C,preset:E})})}),x}function y(){p.open({options:b(),onSelect:async x=>{await g(x.schema.name,x.preset?.data),p.close()},onRemove:d?async()=>{await g(""),p.close()}:void 0})}let v=d&&f("div",{className:"DocEditor__OneOfField__fields",children:d.fields.map(x=>f(Ie.Field,{field:x,deepKey:`${t.deepKey}.${x.id}`,onBlur:()=>{no(null)},onFocus:()=>{no(`${t.deepKey}.${x.id}`,{scroll:!0})}},`${o}::${x.id}`))});if(n==="picker"){let x=d?d.label||d.name:e.placeholder||"Select type";return f("div",{className:"DocEditor__OneOfField DocEditor__OneOfField--picker",children:[f("div",{className:"DocEditor__OneOfField__pickerButton",children:[f("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),f(Z,{variant:"default",color:"dark",size:"xs",onClick:y,rightIcon:f(go,{size:16}),children:x})]}),v]})}return f("div",{className:"DocEditor__OneOfField",children:[f("div",{className:"DocEditor__OneOfField__select",children:[f("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),f(Rn,{data:c,value:o,placeholder:e.placeholder,onChange:x=>m(x||""),onFocus:_,size:"xs",radius:0,searchable:!0,dropdownComponent:"div"})]}),v]})};function nP(t,e,n){if(t.length<=1)return t;let o=t[e];return t[e]=t[n],t[n]=o,t}function HG(t,e,n){let[o]=t.splice(e,1);t.splice(n,0,o)}function rP(t,e,n,o="title"){if(t.type==="oneof"){let r=t,i=e?._type;if(i){let s,a=Array.isArray(r.types)?r.types:[];return typeof a[0]=="string"?s=n[i]:s=a.find(l=>l.name===i),s?.preview?.[o]||null}}return null}function UG(t,e,n){let o=rP(t.of,e,n,"image");if(o)return ma(o,e)}function KG(t,e,n,o){let r=rP(t.of,e,o,"title");if(r){let i=ma(r,e,{index:n});if(i)return i}return t.preview?ma(t.preview,e,{index:n})??`item ${n}`:`item ${n}`}function jG(t){let e=t.split("."),n=e.pop();return[...e,`@${n}`].join(".")}export{vP as a,CP as b,ng as c,rg as d,TP as e,sg as f,ag as g,Jo as h,IP as i,du as j,e0 as k,sn as l,t0 as m,Kq as n,qv as o,Jv as p,Mae as q,JR as r,Ie as s,Om as t};
|