@blinkk/root-cms 3.0.2 → 3.0.4
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 +5 -5
- package/dist/{chunk-2BSW7SIH.js → chunk-N4K6ICFR.js} +4 -4
- package/dist/{chunk-BGTUWIV6.js → chunk-PNLLZXVY.js} +4 -4
- package/dist/{chunk-3HARN4U6.js → chunk-RLZFZT42.js} +176 -83
- package/dist/{chunk-C245C557.js → chunk-RXWDB3K4.js} +3 -3
- package/dist/{chunk-XLX37FRL.js → chunk-TEKMLYXS.js} +3 -4
- package/dist/cli/cli.d.ts +12 -0
- package/dist/cli/docs.d.ts +49 -0
- package/dist/cli/export.d.ts +11 -0
- package/dist/cli/generate-types.d.ts +6 -0
- package/dist/cli/import.d.ts +13 -0
- package/dist/cli/init-firebase.d.ts +7 -0
- package/dist/cli/utils.d.ts +27 -0
- package/dist/cli.js +10 -10
- package/dist/client.js +1 -1
- package/dist/core/ai-tools.d.ts +156 -0
- package/dist/core/ai.d.ts +330 -0
- package/dist/core/api.d.ts +21 -0
- package/dist/core/app.d.ts +16 -0
- package/dist/core/checks-translations.d.ts +13 -0
- package/dist/core/checks.d.ts +48 -0
- package/dist/core/client.d.ts +715 -0
- package/dist/core/core.d.ts +5 -0
- package/dist/core/cron.d.ts +19 -0
- package/dist/core/csv.d.ts +5 -0
- package/dist/core/functions.d.ts +9 -0
- package/dist/core/plugin.d.ts +357 -0
- package/dist/{project.d.ts → core/project.d.ts} +8 -12
- package/dist/core/richtext.d.ts +101 -0
- package/dist/{core.d.ts → core/route.d.ts} +13 -66
- package/dist/core/runtime.d.ts +46 -0
- package/dist/{schema-Db_xODoi.d.ts → core/schema.d.ts} +47 -100
- package/dist/core/search-extract.d.ts +70 -0
- package/dist/core/search-index.d.ts +182 -0
- package/dist/core/search-query.d.ts +68 -0
- package/dist/core/security.d.ts +6 -0
- package/dist/core/server-version.d.ts +5 -0
- package/dist/core/services-notifications.d.ts +57 -0
- package/dist/core/services.d.ts +44 -0
- package/dist/core/sse.d.ts +10 -0
- package/dist/core/translations-manager.d.ts +187 -0
- package/dist/core/translations.d.ts +83 -0
- package/dist/core/url-safety.d.ts +19 -0
- package/dist/core/validation.d.ts +30 -0
- package/dist/core/values.d.ts +9 -0
- package/dist/core/versions.d.ts +48 -0
- package/dist/core.js +1 -1
- package/dist/edit-M4PN4SGX.js +7 -0
- package/dist/functions.js +4 -4
- package/dist/{generate-types-SPV7I3A5.js → generate-types-JWIG4QVI.js} +1 -1
- package/dist/plugin.js +128 -133
- package/dist/shared/marshal.d.ts +68 -0
- package/dist/shared/objects.d.ts +9 -0
- package/dist/shared/richtext.d.ts +74 -0
- package/dist/shared/safe-json.d.ts +11 -0
- package/dist/shared/sanitize.d.ts +12 -0
- package/dist/shared/slug.d.ts +19 -0
- package/dist/shared/sse.d.ts +16 -0
- package/dist/shared/strings.d.ts +23 -0
- package/dist/ui/AIPage-YI3RFK5F.js +1 -0
- package/dist/ui/AssetsPage-4JNAOFYF.js +1 -0
- package/dist/ui/CollectionPage-JWHH5G55.js +1 -0
- package/dist/ui/ComparePage-YZE3EMU4.js +1 -0
- package/dist/ui/DataPage-VRCQSZZG.js +1 -0
- package/dist/ui/DataSourcePage-WMSPBZ3W.js +1 -0
- package/dist/ui/DocTranslationsPage-RY2LOZBX.js +1 -0
- package/dist/ui/DocumentPage-EEGTJMIW.js +1 -0
- package/dist/ui/EditDataSourcePage-LLCX6K4J.js +1 -0
- package/dist/ui/EditReleasePage-WQYXXMZQ.js +1 -0
- package/dist/ui/ImageEditorDialog-4H665KK2.js +81 -0
- package/dist/ui/ImageEditorDialog-4H665KK2.js.LEGAL.txt +17 -0
- package/dist/ui/LogsPage-IP2DKEYR.js +1 -0
- package/dist/ui/NewDataSourcePage-RDYJC4DH.js +1 -0
- package/dist/ui/NewReleasePage-DGMFU2JN.js +1 -0
- package/dist/ui/NotFoundPage-WDZ2K7EF.js +1 -0
- package/dist/ui/ProjectPage-HYJOQUWR.js +1 -0
- package/dist/ui/ReleasePage-2KSF23TK.js +1 -0
- package/dist/ui/ReleasesPage-NZIBBXU4.js +1 -0
- package/dist/ui/SettingsPage-36XFWV62.js +1 -0
- package/dist/ui/SidebarToolsPage-5C6YBWJ7.js +1 -0
- package/dist/ui/TaskPage-SPIFPGPP.js +1 -0
- package/dist/ui/TasksPage-ZOXRPBQV.js +1 -0
- package/dist/ui/TranslationsArbPage-UHANA7JD.js +2 -0
- package/dist/ui/TranslationsEditPage-PQY6W5YG.js +1 -0
- package/dist/ui/TranslationsPage-V2PQFCN5.js +162 -0
- package/dist/ui/ai-tools-5E5ELLZX.js +1 -0
- package/dist/ui/chunk-3IYZCUPI.js +1 -0
- package/dist/ui/chunk-4KE2SZKH.js +1 -0
- package/dist/ui/chunk-4W73RW5I.js +1 -0
- package/dist/ui/chunk-54DVDYU6.js +1 -0
- package/dist/ui/chunk-5MV6XVGA.js +1 -0
- package/dist/ui/chunk-62UWGWON.js +1 -0
- package/dist/ui/chunk-767BAQ53.js +1 -0
- package/dist/ui/chunk-AFWBSIPL.js +1 -0
- package/dist/ui/chunk-AL3TN2KI.js +1 -0
- package/dist/ui/chunk-BZIRGB4W.js +1 -0
- package/dist/ui/chunk-C5NH23G4.js +3 -0
- package/dist/ui/chunk-CGCKJFL4.js +1 -0
- package/dist/ui/chunk-DEGMKEHP.js +1 -0
- package/dist/ui/chunk-DTMZLUNY.js +15 -0
- package/dist/ui/chunk-DTMZLUNY.js.LEGAL.txt +237 -0
- package/dist/ui/chunk-DUJYIOLE.js +5 -0
- package/dist/ui/chunk-E2RCCK2T.js +1 -0
- package/dist/ui/chunk-EGEB6N4J.js +22 -0
- package/dist/ui/chunk-EGEB6N4J.js.LEGAL.txt +1059 -0
- package/dist/ui/chunk-FBJURT7Z.js +1 -0
- package/dist/ui/chunk-GXSAEPU3.js +1 -0
- package/dist/ui/chunk-HHMG665Z.js +1 -0
- package/dist/ui/chunk-HKINZLMW.js +84 -0
- package/dist/ui/chunk-HLMBCVRX.js +1 -0
- package/dist/ui/chunk-HRGYNHZ3.js +1 -0
- package/dist/ui/chunk-I6ICVKEC.js +1 -0
- package/dist/ui/chunk-JDW4UORS.js +1 -0
- package/dist/ui/chunk-JHBAMPGB.js +1 -0
- package/dist/ui/chunk-JT5L6GPZ.js +141 -0
- package/dist/ui/chunk-JT5L6GPZ.js.LEGAL.txt +106 -0
- package/dist/ui/chunk-JYFLU7DM.js +19 -0
- package/dist/ui/chunk-JZFTZ4X4.js +87 -0
- package/dist/ui/chunk-JZFTZ4X4.js.LEGAL.txt +9 -0
- package/dist/ui/chunk-KFAZBEPV.js +1 -0
- package/dist/ui/chunk-KKEWCXVV.js +1 -0
- package/dist/ui/chunk-KUCVLANF.js +1 -0
- package/dist/ui/chunk-KYDOSLTO.js +1 -0
- package/dist/ui/chunk-L4RHGQUG.js +1 -0
- package/dist/ui/chunk-MDUBCXU2.js +1 -0
- package/dist/ui/chunk-NXQVLOTK.js +1 -0
- package/dist/ui/chunk-NZHF733K.js +7 -0
- package/dist/ui/chunk-NZHF733K.js.LEGAL.txt +146 -0
- package/dist/ui/chunk-ONTGW2VA.js +1 -0
- package/dist/ui/chunk-ORXEMIQC.js +1 -0
- package/dist/ui/chunk-P3NETZZP.js +1 -0
- package/dist/ui/chunk-PHBMVORG.js +1 -0
- package/dist/ui/chunk-PJA7YP4A.js +1 -0
- package/dist/ui/chunk-PVAE643M.js +1 -0
- package/dist/ui/chunk-PWKJDYE2.js +1 -0
- package/dist/ui/chunk-RSVO46S3.js +1 -0
- package/dist/ui/chunk-SKEP5WYH.js +10 -0
- package/dist/ui/chunk-SKEP5WYH.js.LEGAL.txt +176 -0
- package/dist/ui/chunk-SQRKKWRG.js +3 -0
- package/dist/ui/chunk-TJBVMFNQ.js +1 -0
- package/dist/ui/chunk-V7S4IAGB.js +1 -0
- package/dist/ui/chunk-VMT7JFAM.js +1 -0
- package/dist/ui/chunk-W3BJ2EZX.js +1 -0
- package/dist/ui/chunk-W3HIZQ4Z.js +1 -0
- package/dist/ui/chunk-X2WHBGTP.js +1 -0
- package/dist/ui/chunk-XOQ3KDSR.js +3 -0
- package/dist/ui/chunk-YDO2EDVY.js +1 -0
- package/dist/ui/chunk-YFA6U2CV.js +1 -0
- package/dist/ui/gcs-L33FIRZU.js +1 -0
- package/dist/ui/prerender-Q4YSDCPB.js +1 -0
- package/dist/ui/signin.js +1 -1
- package/dist/ui/ui.css +1 -1
- package/dist/ui/ui.js +1 -630
- package/dist/ui/ui.js.LEGAL.txt +19 -732
- package/package.json +20 -20
- package/dist/client-1puwLgNx.d.ts +0 -1552
- package/dist/client.d.ts +0 -5
- package/dist/edit-MT4B37QK.js +0 -7
- package/dist/functions.d.ts +0 -13
- package/dist/plugin.d.ts +0 -5
- package/dist/richtext.d.ts +0 -104
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as bt}from"./chunk-CGCKJFL4.js";import{f as ft,g as ht,h as mt,i as ke,j as R,k as Ae,l as Q,m as vt}from"./chunk-SKEP5WYH.js";import{c as nt}from"./chunk-AFWBSIPL.js";import{a as at}from"./chunk-62UWGWON.js";import{a as w,c as we}from"./chunk-I6ICVKEC.js";import{a as ce,f as ot}from"./chunk-ORXEMIQC.js";import{a as N,d as Se}from"./chunk-5MV6XVGA.js";import{c as et,q as tt,r as it,t as de,u as xe}from"./chunk-EGEB6N4J.js";import{f as j}from"./chunk-AL3TN2KI.js";import{$ as Fe,A as qe,Aa as le,Ab as Ce,Ca as se,Ea as Qe,Ec as Y,Fc as Ie,Ga as re,Ha as i,Ob as ut,Pc as gt,R as $e,V as We,W as X,Wc as Ee,Y as G,a as g,c as z,e as ve,ea as A,fa as Ke,g as J,ga as B,ha as Je,i as oe,j as be,jc as pt,lc as De,m as _e,ma as Xe,mb as lt,mc as Te,o as Ve,oa as Z,ob as st,p as He,qa as Ze,ra as T,sa as ye,ub as rt,va as ne,w as je,wb as dt,xb as ct,za as Ye}from"./chunk-NZHF733K.js";import{d as M,j as ae,k as Le}from"./chunk-KUCVLANF.js";Le();be();function _t(e,l){let t;return(...a)=>{window.clearTimeout(t),t=window.setTimeout(()=>{e(...a)},l)}}function Ft(e){e||(e=6);let l=[],t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=t.length;for(let o=0;o<e;o++)l.push(t.charAt(Math.floor(Math.random()*a)));return l.join("")}var q=class{constructor(){this.events=new Map}on(l,t){let a=Ft(6),o=this.events.get(l);return o||(o=new Map,this.events.set(l,o)),o.set(a,t),()=>{this.off(l,a)}}off(l,t){let a=this.events.get(l);a&&(a.delete(t),a.size===0&&this.events.delete(l))}dispatch(l,...t){let a=this.events.get(l);a&&a.forEach(o=>o(...t))}dispose(){this.events.clear()}};var ue=class{constructor(){this.subscribers=new Set;this.subtreeSubscribers=new Set;this.children=new Map}},pe=class extends q{constructor(t){super();this.root=new ue;this.data=t||{}}get(t){return this.getValueFromPath(t,this.data)}set(t,a){if(t===""){N(a)&&this.setData(a);return}this.update({[t]:a})}update(t){let a=new Map,o=(s,r,d)=>{if(a.set(s,d),!N(r)&&!N(d))return;let u=N(r)?Object.keys(r):[],m=N(d)?Object.keys(d):[];new Set([...u,...m]).forEach(h=>{let p=N(r)?r[h]:void 0,b=N(d)?d[h]:void 0;Se(p,b)||o(`${s}.${h}`,p,b)})};Object.entries(t).forEach(([s,r])=>{let d=this.data,u=s.split("."),m=u.pop();for(let h of u)d[h]||(d[h]={}),d=d[h];let F=d[m];d[m]=r,this.dispatch("VALUE_CHANGE",s,r),o(s,F,r)});let n=new Map;a.forEach((s,r)=>{this.collectSubtreeNotifications(r,n)}),a.forEach((s,r)=>{let d=this.getTrieNode(r);d&&d.subscribers.size>0&&d.subscribers.forEach(u=>u(s))}),n.forEach((s,r)=>{let d=this.get(r);s.subtreeSubscribers.forEach(u=>u(d))}),this.dispatch("CHANGE",this.data)}setData(t){let a=this.data;this.notifyOnUpdate(this.root,"",a,t),this.data=t,this.dispatch("CHANGE",this.data)}subscribe(t,a){let o=this.getTrieNode(t,!0);return o.subscribers.add(a),window.setTimeout(()=>{let n=this.get(t);n!==void 0&&a(n)}),()=>{o.subscribers.delete(a)}}subscribeSubtree(t,a){let o=this.getTrieNode(t,!0);return o.subtreeSubscribers.add(a),window.setTimeout(()=>{let n=this.get(t);n!==void 0&&a(n)}),()=>{o.subtreeSubscribers.delete(a)}}getDataSnapshot(){return this.data}dispose(){super.dispose(),this.data={},this.root.subscribers.clear(),this.root.subtreeSubscribers.clear(),this.root.children.clear()}notifyOnUpdate(t,a,o,n){let s=this.getValueFromPath(a,o),r=this.getValueFromPath(a,n);Se(s,r)||(t.subscribers.forEach(d=>d(r)),t.subtreeSubscribers.forEach(d=>d(r))),t.children.forEach((d,u)=>{let m=a?`${a}.${u}`:u;this.notifyOnUpdate(d,m,o,n)})}collectSubtreeNotifications(t,a){let o=this.root;if(o.subtreeSubscribers.size>0&&a.set("",o),!t)return;let n="";for(let s of t.split(".")){if(o=o.children.get(s),!o)return;n=n?`${n}.${s}`:s,o.subtreeSubscribers.size>0&&a.set(n,o)}}getValueFromPath(t,a){if(!t)return a;let o=t.split("."),n=a;for(let s of o){if(n===null||typeof n!="object"||!(s in n))return;n=n[s]}return n}getTrieNode(t,a=!1){if(!t)return this.root;let o=t.split("."),n=this.root;for(let s of o){if(!n.children.has(s))if(a)n.children.set(s,new ue);else return;n=n.children.get(s)}return n}};var yt=3*ce.second,kt=5*ce.minute;var At=30*ce.second,Pe=class extends q{constructor(t){super();this.pendingUpdates=new Map;this.saveState="NO_CHANGES";this.autolock=!1;this.autolockReason="autolock";this.autolockApplied=!1;this.readOnly=!1;this.autoSave=!0;this.flushOnStop=!0;this.started=!1;this.queueChanges=_t(()=>this.flush(),yt);this.projectId=window.__ROOT_CTX.rootConfig.projectId;let[a,o]=t.split("/");this.docId=t,this.collectionId=a,this.slug=o,this.db=window.firebase.db,this.docRef=et(this.db,"Projects",this.projectId,"Collections",a,"Drafts",o),this.store=new pe({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,r)=>{this.dispatch("VALUE_CHANGE",s,r)});let n=window.__ROOT_CTX.collections[a];n&&(this.autolock=!!n.autolock,n.autolockReason&&(this.autolockReason=n.autolockReason))}async start(){this.started||(this.started=!0,this.dbUnsubscribe=it(this.docRef,t=>{if(t.metadata.hasPendingWrites)return;let a=t.data()||{};this.pendingUpdates.size>0&&wt(a,Object.fromEntries(this.pendingUpdates)),this.store.setData(a)}))}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.flushOnStop&&this.flush(),this.started=!1)}onChange(t){return this.on("CHANGE",t)}onSaveStateChange(t){return this.on("SAVE_STATE_CHANGE",t)}onFlush(t){return this.on("FLUSH",t)}subscribe(t,a){return this.store.subscribe(t,a)}subscribeSubtree(t,a){return this.store.subscribeSubtree(t,a)}getData(){return this.store.getDataSnapshot()}getValue(t){return this.store.get(t)}async updateKey(t,a){this.readOnly||(a===void 0?this.setPendingUpdate(t,de()):this.setPendingUpdate(t,a),this.store.set(t,a),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}async updateKeys(t){if(!this.readOnly){for(let a in t){let o=t[a];o==null?this.setPendingUpdate(a,de()):this.setPendingUpdate(a,o)}this.store.update(t),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges()}}async removeKey(t){this.readOnly||(this.setPendingUpdate(t,de()),this.store.set(t,void 0),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}setPendingUpdate(t,a){for(let o of this.pendingUpdates.keys())Ut(o,t)&&this.pendingUpdates.delete(o);this.pendingUpdates.set(t,a)}getPendingUpdates(){return Nt(Object.fromEntries(this.pendingUpdates))}setSaveState(t){let a=this.saveState;t==="SAVED"&&a!=="SAVING"||(this.saveState=t,t==="SAVED"&&window.setTimeout(()=>{this.saveState==="SAVED"&&this.setSaveState("NO_CHANGES")},yt),this.dispatch("SAVE_STATE_CHANGE",t))}removePublishingLock(){this.autolockApplied=!0,this.removeKey("sys.publishingLocked"),this.flush()}async flush(t){if(this.readOnly||this.pendingUpdates.size===0)return;let a=this.getPendingUpdates();a["sys.modifiedAt"]=xe(),a["sys.modifiedBy"]=window.firebase.user.email,this.autolock&&!this.autolockApplied&&!this.store.get("sys.publishingLocked")&&(this.autolockApplied=!0,a["sys.publishingLocked"]={lockedAt:xe(),lockedBy:window.firebase.user.email,reason:this.autolockReason}),this.pendingUpdates.clear();try{this.setSaveState("SAVING"),await tt(this.docRef,a),this.setSaveState("SAVED"),t?.quiet||this.dispatch("FLUSH"),ot("doc.save",{metadata:{docId:this.docId},throttle:kt,throttleId:this.docId})}catch(o){console.error("failed to update doc:",o),this.setSaveState("ERROR");let n=at(o);w({title:`Failed to save ${this.slug}`,message:n||`Something went wrong while saving ${this.slug}`,color:"red",autoClose:!1});for(let s in a)s.startsWith("sys.")||this.pendingUpdates.has(s)||(this.pendingUpdates.set(s,a[s]),this.queueChanges(),console.log("re-queued updates"),console.log(this.pendingUpdates))}}getLocales(){let t=this.store.get("sys.locales");return t||["en"]}setLocales(t){this.updateKey("sys.locales",t)}async dispose(){super.dispose(),this.stop()}};function wt(e,l){for(let t in l){let a=l[t];if(t.includes(".")){let[o,n]=Pt(t);e[o]??={},wt(e[o],{[n]:a})}else typeof a>"u"?delete e[t]:e[t]=a}}function Pt(e){let l=e.indexOf("."),t=e.substring(0,l),a=e.substring(l+1);return[t,a]}function Nt(e){let l={...e};for(let t in l)Ot(t,l)&&delete l[t];return l}function Ot(e,l){let t=e.split(".");for(let a=1;a<t.length;a++)if(t.slice(0,a).join(".")in l)return!0;return!1}function Ut(e,l){return e.startsWith(`${l}.`)}var Ne=ae(null);function hi(e){let[l,t]=g(!0),a=J(()=>new Pe(e.docId),[e.docId]);a.readOnly=e.readOnly??!1,a.autoSave=e.autoSave??!0,a.flushOnStop=e.flushOnStop??!0,z(()=>(t(!0),a.onChange(n=>{t(!1),nt(n.id,n)}),a.start(),()=>a.dispose()),[a]),z(()=>{let n,s=()=>{document.hidden||document.visibilityState!=="visible"?n=window.setTimeout(()=>{a.stop()},At):(n&&(clearTimeout(n),n=void 0),a.started||a.start())};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),n&&clearTimeout(n)}},[a]);let o=J(()=>({loading:l,controller:a}),[l,a]);return i(Ne.Provider,{value:o,children:e.children})}function mi(e){return i(Ne.Provider,{value:e.value,children:e.children})}function ge(){let e=oe(Ne);if(!e)throw new Error("useDraftDoc() should be used within a <DraftDocProvider>");return e}function vi(e){let{controller:l}=ge();z(()=>l.onSaveStateChange(e),[l])}function bi(e){let{controller:l}=ge();z(()=>l.onChange(e),[l])}function _i(e,l){let{controller:t}=ge();z(()=>t.subscribe(e,l),[t])}function Oe(e,l){let{controller:t}=ge(),[a,o]=g(t.getValue(e)??l);return z(()=>t.subscribe(e,s=>{o(s)}),[t]),[a,s=>{o(s),s==null?t.removeKey(e):t.updateKey(e,s)}]}Le();je();je();be();var Mt=["drive.google.com","docs.google.com"];function fe(e){try{let l=new URL(e);if(!Mt.includes(l.hostname))return null;if(l.searchParams.has("id"))return l.searchParams.get("id");let t=l.pathname.split("/"),a=t.findIndex(o=>o==="d");if(a!==-1&&a<t.length-1)return t[a+1]}catch{return null}return null}async function xt(e,l){let t="https://www.googleapis.com/auth/drive.readonly";(!e.isLoggedIn()||!e.hasScope(t))&&await e.login({scopes:[t]});let a=window.gapi;if(!a||!a.client||!a.client.drive)throw new Error("Google Drive API not loaded");let o=a.auth.getToken()?.access_token;if(!o)throw new Error("No Google Drive access token found");let[n,s]=await Promise.all([a.client.drive.files.get({fileId:l,fields:"name,mimeType,size",supportsAllDrives:!0}),fetch(`https://www.googleapis.com/drive/v3/files/${l}?alt=media&supportsAllDrives=true`,{headers:{Authorization:`Bearer ${o}`}})]),r=n.result;if(!s.ok)throw new Error(`Failed to download file from Drive: ${s.statusText}`);let d=await s.blob();return new File([d],r.name,{type:r.mimeType})}be();var zt=["1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"],Gt=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"];function St(e){let[l,t]=g("simple"),[a,o]=g(!1),[n,s]=g(!1),[r,d]=g(null),[u,m]=g(""),[F,h]=g(e.initialWidth||1600),[p,b]=g(e.initialHeight||900),[S,$]=g("16:9"),W=!!(window.__ROOT_CTX?.experiments||{}).ai;async function L(){if(!u){w({title:"Prompt required",message:"Please enter a prompt to generate an image.",color:"red"});return}o(!0);try{let _=await(await fetch("/cms/api/ai.generate_image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u,aspectRatio:S})})).json();if(_.success&&_.image)d(_.image);else throw new Error(_.error||"Failed to generate image")}catch(f){console.error(f),w({title:"Generation failed",message:f.message||"Unknown error",color:"red"})}finally{o(!1)}}function te(f){f.preventDefault();let _=new FormData(f.target),y=parseInt(_.get("width"),10),D=parseInt(_.get("height"),10),V=_.get("backgroundColor"),O=_.get("label")||`${y}x${D}`,E=[];if(E.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${y}" height="${D}" viewBox="0 0 ${y} ${D}"><rect width="${y}" height="${D}" fill="${V}" />`),O){let me=y*.5/(O.length*.6);E.push(`<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-size="${me}" fill="#fff">${O}</text>`)}E.push("</svg>");let H=E.join(""),U=new TextEncoder().encode(H),he={src:`data:image/svg+xml;base64,${btoa(String.fromCharCode(...U))}`,filename:"placeholder.svg",width:y,height:D,alt:""};e.onSubmit(he)}async function K(){if(r){s(!0);try{let _=await(await fetch(r)).blob(),y=new File([_],"generated-image.png",{type:"image/png"}),{uploadFileToGCS:D}=await import("./gcs-L33FIRZU.js"),V=await D(y),[O,E]=S.split(":").map(Number),H=1600,ie=Math.round(H*E/O),U={...V,width:H,height:ie,alt:u};e.onSubmit(U)}catch(f){console.error(f),w({title:"Save failed",message:f.message||"Failed to upload image",color:"red"})}finally{s(!1)}}}return i(se,{gap:"md",children:[W&&i(Ye,{value:l,onChange:f=>t(f),data:[{label:"Simple",value:"simple"},{label:i(B,{gap:5,children:[i(Y,{size:16}),i("span",{children:"Generate with AI"})]}),value:"ai"}],fullWidth:!0}),l==="simple"?i("form",{onSubmit:te,children:[i(se,{gap:"xs",children:[i(ne,{label:"Width",name:"width",type:"number",value:F,onChange:f=>h(parseInt(f.currentTarget.value,10)),"data-autofocus":!0}),i(ne,{label:"Height",name:"height",type:"number",value:p,onChange:f=>b(parseInt(f.currentTarget.value,10))}),i(ne,{name:"label",label:"Label",defaultValue:""}),i(Je,{name:"backgroundColor",label:"Background color",format:"hex",defaultValue:"#868e96",swatches:Gt})]}),i(B,{justify:"flex-end",mt:"md",children:i(A,{variant:"filled",type:"submit",children:"Create"})})]}):i(se,{gap:"xs",children:[i(le,{label:"Aspect Ratio",data:zt,value:S,onChange:f=>$(f)}),i(Z,{label:"Prompt",placeholder:"Describe the image you want to generate...",minRows:3,value:u,onChange:f=>m(f.currentTarget.value),"data-autofocus":!0,required:!0}),r&&i(Xe,{src:r,alt:"Generated preview",height:200,fit:"contain"}),i(B,{justify:"flex-end",mt:"md",children:[i(A,{variant:"light",onClick:L,loading:a,disabled:n||!u,leftIcon:i(Y,{size:16}),children:a?"Generating...":"Preview"}),i(A,{variant:"filled",onClick:K,loading:n,disabled:!r||a,children:n?"Saving...":"Save"})]})]})]})}var Bt=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"],Ct=ae(null),Rt=He(()=>import("./ImageEditorDialog-4H665KK2.js").then(e=>({default:e.ImageEditorDialog})));function ee(){let e=oe(Ct);if(!e)throw new Error("useFileField() should be called within a <FileFieldContext.Provider>");return e}function Lt(e){let{field:l,value:t,setValue:a,loadingState:o,setLoadingState:n}=e,s=qe(),r=ve(null),[d,u]=g(!1),[m,F]=g(!1),[h,p]=g(!1),b=bt(),S=e.allowEditing!==!1,[$,Ue]=g("hash"),[W,L]=g(null),[te,K]=g(!1),[f,_]=g(null),y=e.accept??l.exts??(e.variant==="image"?Bt:[]),D=t?.alt||"",V=e.altDisabledByMetadata===!0,O=l.alt!==!1&&!V;async function E(c,C,v){try{n("loading");let P=v?.namingMode||(l.preserveFilename?"clean":"hash"),k=l.cacheControl||(P==="clean"?"no-cache":void 0),x=await ft(c,{namingMode:P,checkExists:v?.checkExists??!1,cacheControl:k});!x.alt&&Dt(x.filename)&&D&&(x.alt=D),C&&(x.originalSrc=C),a(x),n("complete"),L(null),_(null)}catch(P){console.error("upload failed"),console.error(P),n("error"),w({title:"Upload failed",message:"Failed to upload: "+String(P),color:"red",autoClose:!1})}}async function H(){n("loading");try{let c=t?.gcsPath||t?.src;c&&await ht(c),a(null),n(null),w({message:"File deleted from GCS",color:"green"})}catch(c){console.error(c),n("error"),w({title:"Delete failed",message:String(c),color:"red"})}finally{F(!1)}}function ie(){if(!S&&t?.src){F(!0);return}a(null)}async function U(c,C){if(!c)return;if(L(null),_(null),K(!1),typeof c=="string"&&!C?.as){let k=fe(c);if(k){try{if(!b.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}n("loading"),w({message:"Downloading from Google Drive...",loading:!0,autoClose:!1,id:"gdrive-download"});let x=await xt(b,k);we("gdrive-download"),U(x)}catch(x){console.error(x),n("error"),we("gdrive-download"),w({title:"Google Drive import failed",message:x.message||"Failed to download",color:"red"})}return}}C?.as==="svg"&&typeof c=="string"&&(c=new File([new Blob([c],{type:"image/svg+xml"})],"untitled.svg",{type:"image/svg+xml"}));let v=c,P=ke(v.name);if(y.length>0&&!y.some(k=>k.endsWith(P)||k===`*/${P}`||k==="*/*"||k===v.type)){w({title:"Invalid file type",message:`File type ${P} is not allowed.`,color:"red",autoClose:!0});return}if($==="clean"&&e.showNamingOptions){n("loading");let x=`${window.__ROOT_CTX.rootConfig.projectId}/uploads/${v.name}`;try{if(await mt(x)){L(v),_(`https://storage.googleapis.com/${window.firebase.storage.app.options.storageBucket}/${x}`),n(null);return}}catch(Re){console.warn("Failed to check file existence",Re)}}E(v,void 0,{namingMode:$})}function Me(){r.current?.focus()}function he(){if(t?.src)if(Ae(t.src)){let c=document.createElement("a");c.href=vt(t.src),t.filename&&(c.download=t.filename),document.body.appendChild(c),c.click(),document.body.removeChild(c)}else window.open(t.src,"_blank")}function ze(){let c=document.createElement("input");c.type="file",y.length>0&&(c.accept=y.join(",")),c.onchange=C=>{let v=C.target;v.files&&v.files.length>0&&U(v.files[0])},c.click(),c.remove()}function Ge(){u(!0)}function me(){p(!0)}function Be(c){t?.src&&a({...t,alt:c||""})}async function Et(){let c=t;if(c?.src){n("loading");try{let C=await window.fetch("/cms/api/ai.generate_alt_text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({imageUrl:c.src})}),v=await C.json();if(!C.ok||!v.success)throw new Error(v.error||"Failed to generate alt text");v.altText&&Be(v.altText)}catch(C){w({title:"Sorry, something went wrong.",message:C.message||"Unknown error",color:"red",autoClose:!0})}finally{n("complete")}}}return i(Ct.Provider,{value:{field:l,variant:e.variant,value:t,setValue:a,loadingState:o,removeFile:ie,acceptedFileTypes:y,handleFile:U,focusDropZone:Me,requestGenerateAltText:Et,requestFileUpload:ze,requestFileDownload:he,requestPlaceholderModalOpen:Ge,requestImageEditorOpen:me,showAltText:O,altText:D,setAltText:Be,altDisabledByMetadata:V,setAltDisabledByMetadata:e.setAltDisabledByMetadata,allowEditing:S},children:[i(ye,{size:"sm",opened:d,onClose:()=>u(!1),title:"Placeholder image",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:i(St,{onSubmit:c=>{a(c),u(!1)}})}),i(ye,{size:"sm",opened:m,onClose:()=>F(!1),title:"Delete file?",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:[i(G,{size:"sm",mb:"lg",children:"Are you sure you want to delete this file from GCS? This action cannot be undone."}),i(B,{grow:!0,spacing:"xs",children:[i(A,{variant:"default",onClick:()=>F(!1),disabled:o==="loading",children:"Cancel"}),i(A,{color:"red",onClick:H,loading:o==="loading",children:"Delete"})]})]}),h&&t?.src&&i(Ve,{fallback:null,children:i(Rt,{opened:h,onClose:()=>p(!1),src:t.src,originalSrc:t.originalSrc,filename:t.filename,initialWidth:parseInt(t.width),initialHeight:parseInt(t.height),onSave:c=>{E(c,t.originalSrc||t.src),p(!1)}},t.src)}),W?i("div",{className:"FileField__overwriteWarning",children:[i("div",{className:"FileField__overwriteWarning__header",children:i(G,{size:"sm",color:"red",weight:700,children:"File already exists"})}),i(G,{size:"sm",children:["A file named ",i("strong",{children:W.name})," already exists."]}),f&&i(G,{size:"sm",className:"FileField__overwriteWarning__link",children:i("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:["View existing file ",i(ct,{size:12})]})}),i("div",{className:"FileField__overwriteWarning__checkbox",children:i(Ke,{label:"Confirm overwrite",checked:te,onChange:c=>K(c.currentTarget.checked)})}),i(B,{grow:!0,spacing:"xs",className:"FileField__overwriteWarning__actions",children:[i(A,{variant:"default",onClick:()=>{L(null),_(null),K(!1)},disabled:o==="loading",children:"Cancel"}),i(A,{disabled:!te,onClick:()=>E(W,void 0,{namingMode:"clean"}),color:"red",loading:o==="loading",children:"Overwrite"})]})]}):i(M,{children:[i("div",{className:j("FileField",e.showNamingOptions&&"FileField--withOptions"),children:[i(I.Dropzone,{ref:r}),t?.src?i(I.Preview,{}):i(I.InvisibleDropzone,{children:i(I.Empty,{})})]}),e.showNamingOptions&&!t&&i("div",{className:"FileField__settings",style:{marginTop:8},children:i(le,{label:"File name options",size:"xs",itemComponent:Vt,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:$,onChange:c=>Ue(c||"hash"),disabled:o==="loading"||!!t})})]})]})}function I(e){let l=e.field,[t,a]=Oe(e.deepKey),[o,n]=g(null),s=jt(e.deepKey),[r,d]=Oe(s),u=r?.alt===!1,m=F=>{let h={...r||{}};F?h.alt=!1:delete h.alt,d(Object.keys(h).length===0?null:h)};return i(Lt,{field:l,value:t,setValue:a,loadingState:o,setLoadingState:n,variant:e.variant,allowEditing:e.allowEditing,altDisabledByMetadata:u,setAltDisabledByMetadata:e.variant==="image"&&l.alt!==!1?m:void 0})}I.Preview=()=>{let e=ee(),[l,t]=g(!1),[a,o]=g(!1),n=window.__ROOT_CTX.experiments||{},s=!!e.value?.width&&!!e.value?.height&&Number(e.value.width)>0&&Number(e.value.height)>0,r=e.value?.filename||"",d=Q(r),u=R(r)||d&&s,[m,F]=g(!u),h=ve(e.value?.src);if(e.value?.src!==h.current){h.current=e.value?.src;let p=e.value?.filename||"",b=R(p)||Q(p)&&s;!b&&!m?F(!0):b&&m&&F(!1)}return e.value?.src?i("div",{className:"FileField__Preview",children:[i("div",{className:"FileField__Preview__InfoButton",children:[u&&i(re,{label:"Toggle file info",position:"top",withArrow:!0,children:i(X,{onClick:()=>F(p=>!p),size:"sm",variant:"outline",className:"FileField__Preview__InfoButton__Icon","aria-label":"Toggle file info",children:i(ut,{size:16})})}),i(T,{shadow:"sm",control:i(X,{variant:"outline",size:"sm",radius:"sm",c:"black",className:"FileField__Preview__InfoButton__Icon",children:i(rt,{size:16})}),children:[e.allowEditing&&i(M,{children:[i(T.Label,{size:"sm",children:"REPLACE"}),i(T.Item,{icon:e.variant==="image"?i(Te,{size:16}):i(Ce,{size:16}),onClick:()=>e.requestFileUpload(),children:["Upload ",e.variant==="image"?"image":"file"]}),Tt(e.acceptedFileTypes)&&i(T.Item,{disabled:!e.value?.src,icon:i(De,{size:16}),onClick:()=>{e.requestPlaceholderModalOpen()},children:"Placeholder image"}),R(e.value?.src)&&!e.value?.src?.endsWith(".svg")&&i(T.Item,{disabled:!e.value?.src,icon:i(st,{size:16}),closeMenuOnClick:!0,onClick:()=>{e.requestImageEditorOpen()},children:"Edit image"}),i(Fe,{})]}),i(T.Item,{disabled:e.value?.src?.startsWith("data:"),onClick:()=>{e?.requestFileDownload()},icon:i(dt,{size:16}),children:"Download file"}),i(T.Item,{closeOnItemClick:!1,icon:i(lt,{size:16}),onClick:()=>{o(!1);let p=e.value?.src||"";Ae(p)&&(p=p.split("=")[0]+"=s0"),navigator.clipboard.writeText(p).then(()=>o(!0)).finally(()=>setTimeout(()=>{o(!1)},2e3))},children:a?"Copied!":"Copy URL"}),e.allowEditing&&R(e.value?.src||"")&&e.value?.canvasBgColor&&i(T.Item,{icon:e.value?.canvasBgColor==="dark"?i(Ee,{size:16}):i(Ie,{size:16,style:{opacity:.25}}),closeOnItemClick:!1,onClick:()=>{let p=e.value?.canvasBgColor==="dark"?"light":"dark";e.value&&e.setValue({...e.value,canvasBgColor:p})},children:"Use dark canvas"}),e.allowEditing&&e.setAltDisabledByMetadata&&i(T.Item,{icon:e.altDisabledByMetadata?i(Ee,{size:16}):i(Ie,{size:16,style:{opacity:.25}}),closeOnItemClick:!1,onClick:()=>{e.setAltDisabledByMetadata?.(!e.altDisabledByMetadata)},children:"Disable alt text"}),i(Fe,{}),i(T.Item,{color:"red",onClick:()=>{e?.removeFile()},icon:i(gt,{size:16}),children:"Remove file"})]})]}),i("div",{className:j("FileField__Canvas",m&&"FileField__Canvas--infoOpened",l&&"dragging"),style:Ht(e.value),onDragOver:p=>{p.preventDefault(),t(!0)},onDragLeave:p=>{p.preventDefault(),t(!1)},onDrop:p=>{p.preventDefault(),t(!1);let b=p.dataTransfer?.files[0];b&&e&&e.handleFile(b)},onPaste:p=>{p.preventDefault();let b=p.clipboardData?.files[0];if(b){e.handleFile(b);return}let S=p.clipboardData?.getData("text/plain");if(S){if(fe(S)){e.handleFile(S);return}if(It(S)){e.handleFile(S,{as:"svg"});return}}},children:[i(Ze,{visible:e.loadingState==="loading"}),m?i("div",{className:"FileField__Canvas__Info",children:[i(pt,{size:16,className:"FileField__Canvas__Info__Icon"}),i(Qe,{className:"FileField__Canvas__Info__Table",verticalSpacing:"xs",fontSize:"xs",children:i("tbody",{children:[e.value?.filename&&i("tr",{children:[i("td",{children:i("b",{children:"Name"})}),i("td",{children:e.value.filename})]}),e.value?.uploadedAt&&i("tr",{children:[i("td",{children:i("b",{children:"Uploaded"})}),i("td",{children:[new Date(parseInt(e.value.uploadedAt,10)).toLocaleString(),e.value.uploadedBy&&i(M,{children:[" by ",e.value.uploadedBy]})]})]}),!!(e.value?.width&&e.value?.height)&&i("tr",{children:[i("td",{children:i("b",{children:"Dimensions"})}),i("td",{children:[e.value.width,"x",e.value.height]})]}),i("tr",{children:[i("td",{children:i("b",{children:"URL"})}),i("td",{children:i(Z,{readOnly:!0,value:e.value?.src,size:"xs",radius:0,autosize:!0,maxRows:10})})]})]})})]}):i(M,{children:[!!(e.value?.width&&e.value?.height)&&i($e,{radius:"sm",className:"FileField__Preview__Info",children:[e.value.width,"x",e.value.height]}),R(e.value?.src)&&i("img",{onClick:()=>{e?.focusDropZone()},onDblClick:()=>{e.allowEditing&&e?.requestFileUpload()},src:e.value.src,alt:e.value.alt||"Uploaded file preview",className:"FileField__Preview__Image"}),Q(e.value?.src)&&i(M,{children:i("video",{className:"FileField__Preview__Image",controls:!0,muted:!0,preload:"metadata",children:i("source",{src:e.value.src,type:`video/${ke(e.value.src)}`})})})]}),e.allowEditing&&i("div",{className:"FileField__reupload",children:i(I.UploadButton,{className:"FileField__reupload__button",compact:!0})})]}),e.allowEditing&&e.showAltText&&(e.altText||Dt(e.value?.filename)||e.variant==="image")&&i("div",{className:"DocEditor__ImageField__imagePreview__Image__Alt",children:[i(Z,{radius:0,className:"DocEditor__ImageField__imagePreview__Image__Alt__Textarea",value:e.altText,placeholder:"Alt text",size:"xs",autosize:!0,disabled:e.loadingState==="loading",onChange:p=>{e?.setAltText(p.currentTarget.value)}}),n.ai&&!e.altText&&e.value?.src?.startsWith("http")&&i(re,{label:"Generate alt text with AI",position:"top",withArrow:!0,children:i(X,{className:"DocEditor__ImageField__imagePreview__Image__Alt__AiButton",onClick:()=>{e.requestGenerateAltText()},disabled:e.loadingState==="loading",children:i(Y,{size:20,stroke:"1.75"})})})]})]}):null};I.UploadButton=e=>{let l=ee(),t=l.loadingState==="loading",a=e.compact?14:16;return i(A,{color:"black",variant:"default",disabled:t,size:e.compact?"compact-xs":"compact-md",className:j("FileField__FileUploadButton",e.compact&&"FileField__FileUploadButton--compact"),onClick:()=>{l.requestFileUpload()},leftIcon:i(M,{children:t&&!e.compact?i(We,{size:a}):l?.variant==="image"?i(Te,{size:a}):i(Ce,{size:a})}),children:t&&!e.compact?"Uploading...":l.value?.src?"Upload":"Paste, drop, or click to upload"})};I.InvisibleDropzone=e=>{let[l,t]=g(!1),a=ee();return i("div",{className:j("FileField__InvisibleDropzone",l&&"dragging"),onDragOver:o=>{o.preventDefault(),o.stopPropagation(),t(!0)},onDragLeave:o=>{o.preventDefault(),o.stopPropagation(),t(!1)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),t(!1);let n=o.dataTransfer?.files[0];n&&a.handleFile(n)},children:e.children})};I.Empty=()=>{let e=ee(),l=J(()=>{if(e.acceptedFileTypes.length===0)return"";let t=e.acceptedFileTypes.filter(a=>a!=="*/*"&&a!=="*");return t.length===0?"":t.map(a=>a.split("/").pop().split("+")[0].replaceAll(".","")).sort().join(", ")},[e.acceptedFileTypes]);return i("div",{className:"FileField__Empty",children:[i("div",{className:"FileField__Empty__Label",children:[i(I.UploadButton,{}),Tt(e.acceptedFileTypes)&&i("div",{children:i(re,{label:"Create placeholder image",children:i(X,{className:"FileField__Empty__Label__PlaceholderButton",onClick:()=>{e.requestPlaceholderModalOpen()},title:"Create placeholder image",children:i(De,{size:16})})})})]}),l&&i("div",{children:i("div",{className:"FileField__Empty__AcceptTypes",children:["Allowed file types: ",l]})})]})};I.Dropzone=_e((e,l)=>{let[t,a]=g(!1),o=ee();return i("button",{ref:l,className:j("FileField__Dropzone",t&&"dragging"),onDblClick:()=>{o?.requestFileUpload()},onCopy:n=>{o.value?.src&&(n.preventDefault(),n.clipboardData?.setData("text/plain",o.value.src),n.clipboardData?.setData("application/json",JSON.stringify(o.value)))},onKeyDown:n=>{((n.metaKey||n.ctrlKey)&&n.key==="Backspace"||n.key==="Delete")&&(n.preventDefault(),o.value?.src&&o.removeFile())},onDragOver:n=>{n.preventDefault(),a(!0)},onDragLeave:n=>{n.preventDefault(),a(!1)},onDrop:n=>{n.preventDefault(),a(!1);let s=n.dataTransfer?.files[0];s&&o&&o.handleFile(s)},onPaste:n=>{if(n.preventDefault(),!o)return;let s=n.clipboardData?.getData("application/json");if(s)try{let u=JSON.parse(s);if(u&&u.src&&u.filename&&o){console.log("Parsed JSON file:",u),o.setValue(u);return}}catch(u){console.error("error parsing json",u)}let r=n.clipboardData?.files[0];if(r){o.handleFile(r);return}let d=n.clipboardData?.getData("text/plain");if(d){if(fe(d)){o.handleFile(d);return}if(It(d)){o.handleFile(d,{as:"svg"});return}}},title:"Drop or paste to upload a file"})});var Vt=_e(e=>{let{label:l,description:t,...a}=e;return i("div",{className:"FileField__NamingModeItem",...a,children:[i(G,{size:"sm",weight:500,children:l}),i(G,{size:"xs",color:"dimmed",children:t})]})});function Dt(e){return e?R(e)||Q(e):!1}function Tt(e){return e.some(l=>l.startsWith("image/"))||e.length===0}function Ht(e){let l={};if(e.width&&e.height){l["--canvas-aspect-ratio"]=`${e.width} / ${e.height}`,l["--canvas-asset-width"]=`${e.width}px`;let t=Math.min(e.height,280);t<80&&(t=80),l["--canvas-max-height"]=`${t}px`}return e.canvasBgColor==="dark"&&(l["--canvas-bg-color"]="#000"),l}function jt(e){let l=e.split("."),t=l.pop();return[...l,`@${t}`].join(".")}function It(e){return/^(?:\uFEFF)?\s*(?:<!--[\s\S]*?-->\s*)*(?:<\?xml[\s\S]*?\?>\s*)?(?:<!DOCTYPE\s+svg[\s\S]*?>\s*)?<svg\b[^>]*?(?:\/>|>[\s\S]*?<\/svg>)\s*$/.test(e)}export{_t as a,Ft as b,q as c,hi as d,mi as e,ge as f,vi as g,bi as h,_i as i,Oe as j,Lt as k,I as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as z,j as I}from"./chunk-NXQVLOTK.js";import{c as N,e as L}from"./chunk-3IYZCUPI.js";import{a as C}from"./chunk-X2WHBGTP.js";import{a as w,c as y}from"./chunk-HRGYNHZ3.js";import{b as v}from"./chunk-5MV6XVGA.js";import{Aa as f,Ac as B,Ha as e,V as P,a as g,ea as p,g as M,j as x,va as S}from"./chunk-NZHF733K.js";x();x();function O(o,t){return M(()=>{if(!t.trim())return o;let l=t.toLowerCase();return o.filter(c=>{let[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],s=v(r,n.preview?.title||"meta.title")||"";return c.id.toLowerCase().includes(l)||s.toLowerCase().includes(l)||u.toLowerCase().includes(l)})},[o,t])}var h="DocPickerModal";function ee(){let o=w(),t=y();return{open:l=>{o.openContextModal(h,{...t,innerProps:l,size:"700px",overflow:"inside"})},close:()=>{o.closeModal(h)}}}function k(o){let{innerProps:t}=o,l=Object.keys(window.__ROOT_CTX.collections);t.collections?.length&&(l=l.filter(i=>t.collections?.includes(i)));let c=[{value:"",label:"Select"}];l.forEach(i=>{c.push({value:i,label:i})});let[a,u]=C("DocPickerModal.lastSelectedCollection",""),r=()=>t.initialCollection?t.initialCollection:a&&l.includes(a)?a:l.length===1?l[0]:"",[n,D]=g(r()),s=i=>{D(i),u(i)};function m(i){t.multiSelect&&t.onChangeMulti?t.onChangeMulti(i.id,!0):t.onChange&&t.onChange(i.id)}function b(i){t.multiSelect&&t.onChangeMulti&&t.onChangeMulti(i.id,!1)}return e("div",{className:"DocPickerModal",children:[l.length===0&&e("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),l.length>0&&e(k.DocsList,{collection:n,onDocSelected:m,onDocUnselected:b,onCollectionChange:s,multiSelect:t.multiSelect,selectedDocIds:t.selectedDocIds,options:{enableSearch:t.enableSearch??!0,enableSort:t.enableSort??!0,enableCreate:t.enableCreate??!0,enableStatusBadges:t.enableStatusBadges??!0,showCollectionSelect:l.length>1,collectionSelectValue:n,collectionSelectOptions:c}})]})}k.DocsList=o=>{let[t,l]=g(""),[c,a]=C(`root::DocPickerModal:${o.collection}:sortBy`,"modifiedAt"),[u,r]=g(!1),[n,D,s]=z(o.collection||"",{orderBy:c}),m=O(s,t),b=[{value:"modifiedAt",label:"Last Modified"},{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"}],i=o.selectedDocIds||[],d=o.options||{};return e("div",{className:"DocPickerModal__DocsList",children:[e("div",{className:"DocPickerModal__DocsList__stickyHeader",children:[d.showCollectionSelect&&e("div",{className:"DocPickerModal__collection__select",children:[e("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),e(f,{data:d.collectionSelectOptions||[],value:d.collectionSelectValue,placeholder:"Select",onChange:_=>{o.onCollectionChange?.(_||"")},size:"xs",radius:0,searchable:!0,autoFocus:!0,dropdownComponent:"div"}),d.collectionSelectValue&&e(p,{variant:"outline",color:"dark",size:"xs",onClick:()=>r(!0),children:"New"})]}),d.enableSearch&&d.collectionSelectValue&&e("div",{className:"DocPickerModal__DocsList__controls",children:[e(S,{placeholder:"Search documents...",value:t,onChange:_=>l(_.target.value),icon:e(B,{size:16}),size:"xs",className:"DocPickerModal__DocsList__controls__search"}),d.enableSort&&e(f,{data:b,value:c,onChange:_=>a(_||"modifiedAt"),size:"xs",className:"DocPickerModal__DocsList__controls__sort"})]}),!n&&s.length>0&&e("div",{className:"DocPickerModal__DocsList__count",children:["Showing ",m.length," of ",s.length," documents"]})]}),e("div",{className:"DocPickerModal__DocsList__docsContainer",children:o.collection?n?e("div",{className:"DocPickerModal__DocsList__loading",children:e(P,{color:"gray",size:"xl"})}):m.length===0?e("div",{className:"DocPickerModal__DocsList__empty",children:s.length===0?"Collection is empty.":"No documents match your search."}):e("div",{className:"DocPickerModal__DocsList__docs",children:m.map(_=>e(k.DocCard,{doc:_,onDocSelected:o.onDocSelected,onDocUnselected:o.onDocUnselected,multiSelect:o.multiSelect,selected:i.includes(_.id),enableStatusBadges:d.enableStatusBadges},_.id))}):e("div",{className:"DocPickerModal__DocsList__empty",children:"Select a content type to view documents"})}),d.collectionSelectValue&&e(I,{collection:d.collectionSelectValue,opened:u,skipNavigation:!0,onClose:()=>{r(!1),D()}})]})};k.DocCard=o=>{let[t,l]=g(!!o.selected),c=o.doc,[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],D=`/cms/content/${a}/${u}`,s=v(r,n.preview?.title||"meta.title"),m=v(r,n.preview?.image||"meta.image")||n.preview?.defaultImage;return e("div",{className:"DocPickerModal__DocCard",children:[e("div",{className:"DocPickerModal__DocCard__image",onClick:()=>window.open(D,"_blank"),children:e(L,{file:m,width:120,height:90,withPlaceholder:!m?.src})}),e("div",{className:"DocPickerModal__DocCard__content",children:[e("div",{className:"DocPickerModal__DocCard__content__header",children:e("div",{className:"DocPickerModal__DocCard__content__header__docId",onClick:()=>window.open(D,"_blank"),children:c.id})}),e("div",{className:"DocPickerModal__DocCard__content__title",children:e("div",{className:"DocPickerModal__DocCard__content__link",onClick:()=>window.open(D,"_blank"),children:s||"[UNTITLED]"})}),o.enableStatusBadges&&e("div",{className:"DocPickerModal__DocCard__content__badges",children:e(N,{doc:c})})]}),e("div",{className:"DocPickerModal__DocCard__controls",children:e("div",{className:"DocPickerModal__DocCard__controls__buttons",children:o.multiSelect?t?e(p,{variant:"light",color:"blue",size:"xs",onClick:()=>{l(!1),o.onDocUnselected(o.doc)},children:"Unselect"}):e(p,{variant:"filled",color:"blue",size:"xs",onClick:()=>{l(!0),o.onDocSelected(o.doc)},children:"Select"}):e(p,{color:"blue",size:"xs",onClick:()=>o.onDocSelected(o.doc),children:"Select"})})})]})};k.id=h;export{ee as a,k as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as n}from"./chunk-AL3TN2KI.js";import{Ha as t}from"./chunk-NZHF733K.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as C}from"./chunk-X2WHBGTP.js";import{f as p}from"./chunk-AL3TN2KI.js";import{Eb as u,Ha as o,U as _,g,j as b}from"./chunk-NZHF733K.js";b();function m(s){let e={},t=[],r={};if(Object.entries(s).forEach(([n,i])=>{e[n]={id:n,name:i.name||n,description:i.description,isGroup:!1,collection:i,children:[]}}),Object.entries(s).forEach(([n,i])=>{let c=e[n],d=i.group||"Content";d?(r[d]||(r[d]={id:`group:${d}`,name:d,isGroup:!0,children:[]}),r[d].children.push(c)):t.push(c)}),Object.keys(r).length>0&&t.length>0){let n={id:"group:Content",name:"Content",isGroup:!0,children:t},i=Object.values(r).sort((c,d)=>c.name.localeCompare(d.name));return[n,...i]}Object.values(r).forEach(n=>{t.push(n)});let l=n=>{n.sort((i,c)=>i.name.localeCompare(c.name)),n.forEach(i=>{i.children.length>0&&l(i.children)})};return l(t),t}function O(s){let{collections:e,activeCollectionId:t,projectId:r}=s,[a,l]=C(`root-cms::${r}::closed_groups`,[]),n=g(()=>m(e),[]),i=(c,d)=>{d?l(a.filter(v=>v!==c)):a.includes(c)||l([...a,c])};return o("div",{className:p(s.className,"CollectionTree"),children:[n.map(c=>o(h,{node:c,depth:0,activeCollectionId:t,closedGroups:a,onAccordionChange:i},c.id)),n.length===0&&o("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function h(s){let{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l}=s,n=e.children.length>0;return e.isGroup?n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__group__label",children:o("span",{children:e.name})})}):o("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${t*16}px`},children:[o(u,{size:20,strokeWidth:"1.75"}),o("span",{children:e.name})]}):n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__collection__label",children:o("a",{className:p("CollectionTree__collection-link",e.id===r&&"active"),href:`/cms/content/${e.id}`,onClick:i=>i.stopPropagation(),children:e.name})})}):o("a",{className:p("CollectionTree__collection",e.id===r&&"active"),href:`/cms/content/${e.id}`,children:[o("div",{className:"CollectionTree__collection__icon",children:o(u,{size:20,strokeWidth:"1.75"})}),o("div",{className:"CollectionTree__collection__content",children:[o("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&o("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function f(s){let{node:e,depth:t,label:r,activeCollectionId:a,closedGroups:l,onAccordionChange:n}=s,i=!l.includes(e.id);return o("div",{className:"CollectionTree__accordion",children:o(_,{iconPosition:"left",initialItem:i?0:-1,offsetIcon:!1,onChange:()=>n(e.id,!i),children:o(_.Item,{label:r,children:o("div",{className:"CollectionTree__accordion__children",children:e.children.map(c=>o(h,{node:c,depth:t+1,activeCollectionId:a,closedGroups:l,onAccordionChange:n},c.id))})})})})}export{O as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as b,n as x}from"./chunk-EGEB6N4J.js";async function A(){let r=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",t=b(r,"Projects",e),s=await x(t);if(!s.exists)return[];let n=(s.data()||{}).roles||{},o=[];return Object.entries(n).forEach(([p,d])=>{(d==="ADMIN"||d==="EDITOR"||d==="CONTRIBUTOR")&&o.push(p)}),o}var E=class r{constructor(e){this.spreadsheetId=e}static async create(e){let t=e.share??!1,s={fields:"spreadsheetId"};e?.title&&(s.resource={properties:{title:e.title}});let n=(await gapi.client.sheets.spreadsheets.create(s)).result,o=new r(n.spreadsheetId);if(o.setSpreadsheet(n),e?.parent&&await gapi.client.drive.files.update({fileId:o.spreadsheetId,addParents:e.parent,removeParents:"root",fields:"id, parents",resource:{},supportsAllDrives:!0}),t)try{let p=await A();await o.share(p,"writer")}catch(p){console.warn("Failed to share spreadsheet:",p)}return o}getUrl(){return U({spreadsheetId:this.spreadsheetId})}async getSheet(e){if(this.sheets||await this.fetchSheets(),this.sheets){for(let t=0;t<this.sheets.length;t++)if(this.sheets[t].gid===e)return this.sheets[t]}return null}async createSheet(e){console.log("createSheet",this.spreadsheetId);let t=await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheetId,resource:{requests:[{addSheet:{properties:{title:e.title}}}]}}),s=t.result.replies||[];if(s&&s.length>0){let i=s[0].addSheet?.properties?.sheetId;if(typeof i=="number")return new I(this,i,e.title)}throw console.error(t),new Error("failed to get gid of new tab")}async fetchSheets(){let t=(await gapi.client.sheets.spreadsheets.get({spreadsheetId:this.spreadsheetId,fields:"sheets.properties"})).result;this.setSpreadsheet(t)}setSpreadsheet(e){this.spreadsheet=e,this.spreadsheet.sheets&&this.setSheets(this.spreadsheet.sheets)}setSheets(e){let t=[];e.forEach(s=>{let i=s.properties?.sheetId,n=s.properties?.title,o=new I(this,i??0,n);t.push(o)}),this.sheets=t}async share(e,t){await Promise.all(e.map(async s=>{let i;s.startsWith("*@")?i={type:"domain",domain:s.slice(2),role:t}:i={type:"user",emailAddress:s,role:t},await gapi.client.drive.permissions.create({fileId:this.spreadsheetId,resource:i,sendNotificationEmail:!1,fields:"id",supportsAllDrives:!0})}))}},I=class{constructor(e,t,s){this.spreadsheet=e,this.gid=t,this.title=s}async updateValuesMap(e,t){let s=t.keyedBy,i=t.preserveColumns||[];if(!s)throw new Error('missing "keyedBy" argument');let[n,o]=await this.getValues(),p=[...n],d=[],w=-1,S=new Set;d.push(n.map((a,u)=>(a===s&&(w=u),i.includes(a)&&S.add(u),{hasChanges:!1,value:a})));function v(a){d[0].push({hasChanges:!0,value:a}),p.push(a)}w===-1&&v(s);let y={};o.forEach((a,u)=>{let h=u+1;d.push(a.map((c,l)=>(l===w&&c&&(c in y?console.warn(`multiple rows keyed by "${c}"`):y[c]=h),{hasChanges:!1,value:c})))});function O(a){for(let h in a)p.includes(h)||v(h);return p.map(h=>a[h]??null)}e.forEach(a=>{let u=O(a),h=a[s],c=y[h];if(c){let l=d[c];u.map((m,g)=>{g>=l.length?l.push({hasChanges:!0,value:m||""}):m!==null&&l[g].value!==m&&(!S.has(g)||!l[g].value)&&(l[g]={hasChanges:!0,value:m})})}else d.push(u.map(l=>({hasChanges:!!l,value:l||""})))});let C=p.length,R=d.length,$=n.length,F=o.length+1;(C>$||R>F)&&await this.resizeSheet({numCols:C+2,numRows:R+20});let f=[];d.forEach((a,u)=>{for(;a.length>0&&a.at(-1)?.hasChanges===!1;)a.pop();if(a.length!==0){if(a.every(h=>h.hasChanges)){f.push({range:`${this.title}!A${u+1}`,majorDimension:"ROWS",values:[a.map(h=>h.value||"")]});return}a.forEach((h,c)=>{if(h.hasChanges){let l=P(c);f.push({range:`${this.title}!${l}${u+1}`,majorDimension:"ROWS",values:[[h.value||""]]})}})}}),f.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:f,valueInputOption:"RAW"}})}async replaceSheet(e,t){let s=e.length,i=t.length+1,n=[];n.push(e),n.push(...t.map(p=>e.map(d=>p[d]||""))),await this.resizeSheet({numCols:s+2,numRows:i+20}),console.log("updating cell values");let o=P(s-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${o}${i}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${o}${i}`,majorDimension:"ROWS",values:n}})}async resizeSheet(e){let t=[];e.numCols&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{columnCount:e.numCols}},fields:"gridProperties.columnCount"}}),e.numRows&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{rowCount:e.numRows}},fields:"gridProperties.rowCount"}}),t.length>0&&(console.log("resizing sheet"),await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:t}}))}async getValues(){let t=(await gapi.client.sheets.spreadsheets.values.get({spreadsheetId:this.spreadsheet.spreadsheetId,range:this.title})).result.values;if(!t||t.length===0)return[[],[]];let s=t[0],i=t.slice(1);return[s,i]}async getValuesMap(){let[e,t]=await this.getValues();return t.map(i=>{let n={};return i.forEach((o,p)=>{let d=e[p];d&&(n[d]=String(o||""))}),n})}async setTitle(e){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{updateSheetProperties:{properties:{title:e,sheetId:this.gid},fields:"title"}}]}}),this.title=e}getUrl(){return U({spreadsheetId:this.spreadsheet.spreadsheetId,gid:this.gid})}async applyL10nTheme(){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{repeatCell:{range:{sheetId:this.gid,startRowIndex:0},cell:{userEnteredFormat:{textFormat:{fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:0,endRowIndex:1},cell:{userEnteredFormat:{textFormat:{bold:!0,fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{frozenRowCount:1}},fields:"gridProperties.frozenRowCount"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:0,endIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:1,startColumnIndex:0},cell:{userEnteredFormat:{wrapStrategy:"WRAP"}},fields:"userEnteredFormat(wrapStrategy)"}}]}})}};function U(r){let t=[`https://docs.google.com/spreadsheets/d/${r.spreadsheetId}/edit`];return typeof r.gid=="number"&&t.push(`#gid=${r.gid}`),t.join("")}function k(r){if(!r.startsWith("https://docs.google.com/spreadsheets/d/"))return null;let e=r.split("/"),t=e[e.length-2],i=r.slice(r.indexOf("#")).match(/gid=(\d+)/),n=0;return i&&i[1]&&(n=parseInt(i[1])),{spreadsheetId:t,gid:n}}function P(r){let e=[];for(;r>=0;){let t=r%26;e.push(String.fromCharCode(t+65)),r=(r-t-1)/26}return e.reverse().join("")}function z(r){if(!r)return;if(!r.startsWith("https://drive.google.com/drive/folders/")){let s=r.trim();if(s.length===33&&/^[a-zA-Z0-9_-]+$/.test(s))return s}let e=r.trim().split("/");return e[e.length-1]||void 0}function W(r){let e=z(r);return e?`https://drive.google.com/drive/folders/${e}`:"https://drive.google.com/drive"}export{E as a,U as b,k as c,z as d,W as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,h as n,j as s}from"./chunk-NZHF733K.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as C,f as h}from"./chunk-ORXEMIQC.js";import{b as m,c as d,g as f,h as y,n as b,o as _,q as j,v as u,w as p}from"./chunk-EGEB6N4J.js";function S(){let t=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db;return m(o,"Projects",t,"Translations")}async function M(t){let o=S(),a=t?.tags?f(o,y("tags","array-contains-any",t.tags)):f(o),s=await _(a),e={};return s.forEach(r=>{let n=r.id;e[n]=r.data()}),e}async function k(t){let o=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,s=d(a,"Projects",o,"Translations",t);return(await b(s)).data()}async function H(t,o){let a=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,e=d(s,"Projects",a,"Translations",t),r={};for(let n in o){if(n==="tags"){r.tags=o.tags;continue}let c=I(n);c&&(r[c]=o[n])}console.log("updating translations: ",r),await j(e,r),h("translations.save",{metadata:{hash:t},throttle:5*C.minute,throttleId:t})}async function L(t,o){let a=o?.mode??"replace",s=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,r=500;for(let n=0;n<t.length;n+=r){let c=p(e);t.slice(n,n+r).forEach(({hash:l,tags:g})=>{let i=d(e,"Projects",s,"Translations",l);a==="union"?c.update(i,{tags:u(...g)}):c.update(i,{tags:g})}),await c.commit()}}async function A(t){return P(x(t))}async function P(t){let a=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-1",a);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")}function x(t){return String(t).trim().split(`
|
|
2
|
+
`).map(a=>E(a)).join(`
|
|
3
|
+
`)}function E(t){return String(t).trimEnd().replace(/ $/,"")}function I(t){let a=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];for(let s of a)if(String(s).toLowerCase()===t.toLowerCase())return s;return null}async function U(t,o){let a=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,e=500,r=await Promise.all(t.map(async n=>({hash:await A(n.source),locales:n.locales,source:n.source})));for(let n=0;n<r.length;n+=e){let c=p(s),w=r.slice(n,n+e);for(let l of w){let g=d(s,"Projects",a,"Translations",l.hash),i={source:l.source};for(let[O,R]of Object.entries(l.locales)){let T=I(O);T&&(i[T]=x(R))}o?.tags?.length&&(i.tags=u(...o.tags)),c.set(g,i,{merge:!0})}await c.commit()}h("translations.batch_save",{metadata:{count:t.length}})}export{S as a,M as b,k as c,H as d,L as e,A as f,x as g,U as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function a(t){if(!window.__ROOT_CTX.collections[t])throw new Error(`collection not found: ${t}`);let o=await window.fetch("/cms/api/collection.get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collectionId:t})});if(o.status!==200){let e=await o.text();throw new Error(e)}return(await o.json()).data}export{a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as k,d as z}from"./chunk-JZFTZ4X4.js";import{B as A,C as I,x as y}from"./chunk-AFWBSIPL.js";import{a as b}from"./chunk-HLMBCVRX.js";import{f as h}from"./chunk-5MV6XVGA.js";import{f as u}from"./chunk-AL3TN2KI.js";import{Ec as N,Ha as e,U as p,V as g,Vc as C,a as n,c as v,e as w,ea as S,j as V}from"./chunk-NZHF733K.js";import{d as _}from"./chunk-KUCVLANF.js";V();V();function P(o){let r=o.docId,[i,d]=n("idle"),[c,f]=n(""),[s,l]=n(""),m=w(!1);async function x(){d("loading");try{let t=await I(r,{beforeVersion:o.beforeVersion,afterVersion:o.afterVersion});f(t),d("success")}catch(t){console.error(t),l(t instanceof Error?t.message:"Unknown error"),d("error")}}function D(){m.current||(m.current=!0,x())}let a;return i==="idle"||i==="loading"?a=e("div",{className:"AiSummary__loading",children:e(g,{size:"md",color:"gray"})}):i==="error"?a=e(b,{className:"AiSummary__content",size:"body-sm",color:"gray",children:["Failed to load AI summary.",s&&e(_,{children:[e("br",{}),s]})]}):c?a=e(z,{className:"AiSummary__content",code:c}):a=e(b,{className:"AiSummary__content",size:"body-sm",color:"gray",children:"No AI summary available for this draft yet."}),e("div",{className:u(o.className,"AiSummary"),children:e(p,{iconPosition:"right",onChange:()=>D(),disableIconRotation:!0,children:e(p.Item,{label:"Summarize changes",icon:e(N,{stroke:"1.5"}),iconPosition:"left",children:a})})})}function se(o){let r=o.left,i=o.right,[d,c]=n(!1),[f,s]=n(null),[l,m]=n(null),D=(window.__ROOT_CTX?.experiments||{}).ai&&r.docId===i.docId&&o.showAiSummary!==!1,a=h(T(f?.fields||{})),t=h(T(l?.fields||{})),F=!d&&f&&l&&a===t,M=`/cms/compare?left=${B(r)}&right=${B(i)}`;async function $(){c(!0);let[j,E]=await Promise.all([y(r.docId,r.versionId),y(i.docId,i.versionId)]);s(j),m(E),c(!1)}return v(()=>{$()},[]),d?e("div",{className:"DocDiffViewer DocDiffViewer--loading",children:e(g,{size:"md",color:"gray"})}):e(_,{children:[D&&e(P,{className:"DocDiffViewer__aiSummary",docId:r.docId,beforeVersion:String(r.versionId),afterVersion:String(i.versionId)}),e("div",{className:u(o.className,"DocDiffViewer"),children:[o.showExpandButton&&e("div",{className:"DocDiffViewer__expand",children:e(S,{component:"a",variant:"default",size:"xs",compact:!0,href:M,target:"_blank",children:"Open in new tab"})}),e("div",{className:"DocDiffViewer__header",children:[e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.left.docId,"@",o.left.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:R(f)})]}),e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.right.docId,"@",o.right.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:R(l)})]})]}),e("div",{className:"DocDiffViewer__diff",children:F?e("div",{className:"DocDiffViewer__identical",children:[e(C,{size:20}),e("span",{children:"No changes. Both versions are identical."})]}):e(k,{oldCode:a,newCode:t})})]})]})}function R(o){if(!o?.sys?.modifiedAt)return"never";let r=o.sys.modifiedAt.toDate();return`${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)} by ${o.sys.modifiedBy}`}function T(o){return A(o,{removeArrayKey:!0})}function B(o){return encodeURIComponent(`${o.docId}@${o.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}export{P as a,se as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m}from"./chunk-SKEP5WYH.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";export{a as GCI_SUPPORTED_EXTS,d as GCI_URL_PREFIX,b as IMAGE_EXTS,c as VIDEO_EXTS,l as buildDownloadURL,g as checkFileExists,f as deleteFileFromGCS,h as getFileExt,m as shouldImageUseDarkBg,j as testIsGoogleCloudImageFile,i as testIsImageFile,k as testIsVideoFile,e as uploadFileToGCS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d,b as O,d as Z,i as ft,k as ut}from"./chunk-KUCVLANF.js";import"./chunk-PVAE643M.js";ut();ut();var Lt="diffed",pt="__c",G="__s",P="__c",bt="__k",et="__d",D="__s",ht=/[\s\n\\/='"\0<>]/,dt=/^(xlink|xmlns|xml)([A-Z])/,Tt=/^(?:accessK|auto[A-Z]|cell|ch|col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|src[A-Z]|tabI|useM|item[A-Z])/,Et=/^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/,Zt=new Set(["draggable","spellcheck"]);function xt(t){t.__g!==void 0?t.__g|=8:t[et]=!0}function jt(t){t.__g!==void 0?t.__g&=-9:t[et]=!1}function vt(t){return t.__g!==void 0?!!(8&t.__g):t[et]===!0}var Dt=/["&<]/;function R(t){if(t.length===0||Dt.test(t)===!1)return t;for(var n=0,e=0,o="",i="";e<t.length;e++){switch(t.charCodeAt(e)){case 34:i=""";break;case 38:i="&";break;case 60:i="<";break;default:continue}e!==n&&(o+=t.slice(n,e)),o+=i,n=e+1}return e!==n&&(o+=t.slice(n,e)),o}var yt={},Mt=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","fill-opacity","flex","flex-grow","flex-negative","flex-order","flex-positive","flex-shrink","flood-opacity","font-weight","grid-column","grid-row","line-clamp","line-height","opacity","order","orphans","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","widows","z-index","zoom"]),Pt=/[A-Z]/g;function Ut(t){var n="";for(var e in t){var o=t[e];if(o!=null&&o!==""){var i=e[0]=="-"?e:yt[e]||(yt[e]=e.replace(Pt,"-$&").toLowerCase()),r=";";typeof o!="number"||i.startsWith("--")||Mt.has(i)||(r="px;"),n=n+i+":"+o+r}}return n||void 0}function mt(){this.__d=!0}function $t(t,n){return{__v:t,context:n,props:t.props,setState:mt,forceUpdate:mt,__d:!0,__h:new Array(0)}}function b(t,n,e){if(!t.s){if(e instanceof nt){if(!e.s)return void(e.o=b.bind(null,t,n));1&n&&(n=e.s),e=e.v}if(e&&e.then)return void e.then(b.bind(null,t,n),b.bind(null,t,2));t.s=n,t.v=e;let o=t.o;o&&o(t)}}var nt=(function(){function t(){}return t.prototype.then=function(n,e){var o=new t,i=this.s;if(i){var r=1&i?n:e;if(r){try{b(o,1,r(this.v))}catch(a){b(o,2,a)}return o}return this}return this.o=function(a){try{var f=a.v;1&a.s?b(o,1,n?n(f):f):e?b(o,1,e(f)):b(o,2,f)}catch(u){b(o,2,u)}},o},t})();function j(t){return t instanceof nt&&1&t.s}function Ft(t,n,e){for(var o;;){var i=t();if(j(i)&&(i=i.v),!i)return r;if(i.then){o=0;break}var r=e();if(r&&r.then){if(!j(r)){o=1;break}r=r.s}if(n){var a=n();if(a&&a.then&&!j(a)){o=2;break}}}var f=new nt,u=b.bind(null,f,2);return(o===0?i.then(x):o===1?r.then(p):a.then(_)).then(void 0,u),f;function p(A){r=A;do{if(n&&(a=n())&&a.then&&!j(a))return void a.then(_).then(void 0,u);if(!(i=t())||j(i)&&!i.v)return void b(f,1,r);if(i.then)return void i.then(x).then(void 0,u);j(r=e())&&(r=r.v)}while(!r||!r.then);r.then(p).then(void 0,u)}function x(A){A?(r=e())&&r.then?r.then(p).then(void 0,u):p(r):b(f,1,r)}function _(){(i=t())?i.then?i.then(x).then(void 0,u):x(i):b(f,1,r)}}function Wt(t,n){try{var e=t()}catch(o){return n(!0,o)}return e&&e.then?e.then(n.bind(null,!1),n.bind(null,!0)):n(!1,e)}var I,L,W,F,wt=function(t,n){try{var e=d[G];d[G]=!0,I=d.__b,L=d[Lt],W=d.__r,F=d.unmount;var o=O(Z,null);return o[bt]=[t],Promise.resolve(Wt(function(){return Promise.resolve(k(t,n||rt,!1,void 0,o,!0,void 0)).then(function(i){var r,a=(function(){if(M(i)){var f=function(){var _=p.join(m);return r=1,_},u=0,p=i,x=Ft(function(){return!!p.some(function(_){return _&&typeof _.then=="function"})&&u++<25},void 0,function(){return Promise.resolve(Promise.all(p)).then(function(_){p=_.flat()})});return x&&x.then?x.then(f):f()}})();return a&&a.then?a.then(function(f){return r?f:i}):r?a:i})},function(i,r){if(d[pt]&&d[pt](t,gt),d[G]=e,gt.length=0,i)throw r;return r}))}catch(i){return Promise.reject(i)}},rt={},gt=[],M=Array.isArray,q=Object.assign,m="",Q="<!--$s-->",X="<!--/$s-->";function tt(t){return typeof t=="string"?Q+t+X:M(t)?(t.unshift(Q),t.push(X),t):t&&typeof t.then=="function"?t.then(tt):Q+t+X}function _t(t,n){var e,o=t.type,i=!0;return t[P]?(i=!1,(e=t[P]).state=e[D]):e=new o(t.props,n),t[P]=e,e.__v=t,e.props=t.props,e.context=n,xt(e),e.state==null&&(e.state=rt),e[D]==null&&(e[D]=e.state),o.getDerivedStateFromProps?e.state=q({},e.state,o.getDerivedStateFromProps(e.props,e.state)):i&&e.componentWillMount?(e.componentWillMount(),e.state=e[D]!==e.state?e[D]:e.state):!i&&e.componentWillUpdate&&e.componentWillUpdate(),W&&W(t),e.render(e.props,e.state,n)}function k(t,n,e,o,i,r,a){if(t==null||t===!0||t===!1||t===m)return m;var f=typeof t;if(f!="object")return f=="function"?m:f=="string"?R(t):t+m;if(M(t)){var u,p=m;i[bt]=t;for(var x=t.length,_=0;_<x;_++){var A=t[_];if(A!=null&&typeof A!="boolean"){var ot,U=k(A,n,e,o,i,r,a);typeof U=="string"?p+=U:(u||(u=new Array(x)),p&&u.push(p),p=m,M(U)?(ot=u).push.apply(ot,U):u.push(U))}}return u?(p&&u.push(p),u):p}if(t.constructor!==void 0)return m;t.__=i,I&&I(t);var h=t.type,v=t.props;if(typeof h=="function"){var V,c,y,H=n;if(h===Z){if("tpl"in v){for(var z=m,$=0;$<v.tpl.length;$++)if(z+=v.tpl[$],v.exprs&&$<v.exprs.length){var T=v.exprs[$];if(T==null)continue;typeof T!="object"||T.constructor!==void 0&&!M(T)?z+=T:z+=k(T,n,e,o,t,r,a)}return z}if("UNSTABLE_comment"in v)return"<!--"+R(v.UNSTABLE_comment)+"-->";c=v.children}else{if((V=h.contextType)!=null){var it=n[V.__c];H=it?it.props.value:V.__}var at=h.prototype&&typeof h.prototype.render=="function";if(at)c=_t(t,H),y=t[P];else{t[P]=y=$t(t,H);for(var St=0;vt(y)&&St++<25;){jt(y),W&&W(t);try{c=h.call(y,v,H)}catch(g){throw r&&g&&typeof g.then=="function"&&(t._suspended=!0),g}}xt(y)}if(y.getChildContext!=null&&(n=q({},n,y.getChildContext())),at&&d.errorBoundaries&&(h.getDerivedStateFromError||y.componentDidCatch)){c=c!=null&&c.type===Z&&c.key==null&&c.props.tpl==null?c.props.children:c;try{return k(c,n,e,o,t,r,!1)}catch(g){return h.getDerivedStateFromError&&(y[D]=h.getDerivedStateFromError(g)),y.componentDidCatch&&y.componentDidCatch(g,rt),vt(y)?(c=_t(t,n),(y=t[P]).getChildContext!=null&&(n=q({},n,y.getChildContext())),k(c=c!=null&&c.type===Z&&c.key==null&&c.props.tpl==null?c.props.children:c,n,e,o,t,r,a)):m}finally{L&&L(t),F&&F(t)}}}c=c!=null&&c.type===Z&&c.key==null&&c.props.tpl==null?c.props.children:c;try{var ct=k(c,n,e,o,t,r,a);return L&&L(t),d.unmount&&d.unmount(t),t._suspended?tt(ct):ct}catch(g){if(!r&&a&&a.onError){var lt=(function Y(B){return a.onError(B,t,function(E,At){try{return k(E,n,e,o,At,r,a)}catch(Ct){return Y(Ct)}})})(g);if(lt!==void 0)return lt;var st=d.__e;return st&&st(g,t),m}if(!r||!g||typeof g.then!="function")throw g;return g.then(function Y(){try{var B=k(c,n,e,o,t,r,a);return t._suspended?tt(B):B}catch(E){if(!E||typeof E.then!="function")throw E;return E.then(Y)}})}}var S,C="<"+h,w=m;for(var l in v){var s=v[l];if(typeof(s=zt(s)?s.value:s)!="function"||l==="class"||l==="className"){switch(l){case"children":S=s;continue;case"key":case"ref":case"__self":case"__source":continue;case"htmlFor":if("for"in v)continue;l="for";break;case"className":if("class"in v)continue;l="class";break;case"defaultChecked":l="checked";break;case"defaultSelected":l="selected";break;case"defaultValue":case"value":switch(l="value",h){case"textarea":S=s;continue;case"select":o=s;continue;case"option":o!=s||"selected"in v||(C+=" selected")}break;case"dangerouslySetInnerHTML":w=s&&s.__html;continue;case"style":typeof s=="object"&&(s=Ut(s));break;case"acceptCharset":l="accept-charset";break;case"httpEquiv":l="http-equiv";break;default:if(dt.test(l))l=l.replace(dt,"$1:$2").toLowerCase();else{if(ht.test(l))continue;l[4]!=="-"&&!Zt.has(l)||s==null?e?Et.test(l)&&(l=l==="panose1"?"panose-1":l.replace(/([A-Z])/g,"-$1").toLowerCase()):Tt.test(l)&&(l=l.toLowerCase()):s+=m}}s!=null&&s!==!1&&(C=s===!0||s===m?C+" "+l:C+" "+l+'="'+(typeof s=="string"?R(s):s+m)+'"')}}if(ht.test(h))throw new Error(h+" is not a valid HTML tag name in "+C+">");if(w||(typeof S=="string"?w=R(S):S!=null&&S!==!1&&S!==!0&&(w=k(S,n,h==="svg"||h!=="foreignObject"&&e,o,t,r,a))),L&&L(t),F&&F(t),!w&&Ht.has(h))return C+"/>";var J="</"+h+">",K=C+">";return M(w)?[K].concat(w,[J]):typeof w!="string"?[K,w,J]:K+w+J}var Ht=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]);function zt(t){return t!==null&&typeof t=="object"&&typeof t.peek=="function"&&"value"in t}var N,kt=d.vnode;d.vnode=t=>{kt&&kt(t),N&&N(t)};async function Bt(t,n){n=n||{};let e=n.props;typeof t=="function"?t=O(t,e):e&&(t=ft(t,e));let o=new Set;N=({type:i,props:r})=>{i==="a"&&r&&r.href&&(!r.target||r.target==="_self")&&o.add(r.href)};try{let i=await wt(t);return i+='<script type="isodata"><\/script>',{html:i,links:o}}finally{N=null}}function Jt(t){globalThis.location={};let n=new URL(t,"http://localhost");for(let e in n)try{globalThis.location[e]=/to[A-Z]/.test(e)?n[e].bind(n):String(n[e])}catch{}}export{Bt as default,Jt as locationStub};
|