1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4810],{75152:function(e,t,n){let i,r,l,a,o,s;n.d(t,{Bh:function(){return ib},Cc:function(){return usePaneLayout},HZ:function(){return nJ},K4:function(){return dy},Ok:function(){return PaneItem},Oo:function(){return iW},P0:function(){return ds},PF:function(){return iK},Sg:function(){return DeskToolProvider},UA:function(){return nV},V$:function(){return n0},X6:function(){return ih},YL:function(){return cA},aL:function(){return nQ},aR:function(){return setActivePanes},cp:function(){return i$},ec:function(){return usePane},hL:function(){return PaneLayout},hX:function(){return iT},hb:function(){return nY},q5:function(){return cg},ud:function(){return nK},xu:function(){return useDeskTool},zc:function(){return SerializeError}});var d,c,u,p,h,m,f,g,x,b,v,_,y,j,w,k,C,I,S,z,P,E,D,T,M,R,A,O,L,B,N,$,Z,U,F,H,V,q,W,G,K,Y,X,Q,J,ee,et,en,ei,er,el,ea,eo,es,ed,ec,eu,ep,eh,em,ef,eg,ex,eb,ev,e_,ey,ej,ew,ek,eC,eI,eS,ez,eP,eE,eD,eT,eM,eR,eA,eO,eL,eB,eN,e$,eZ,eU,eF,eH,eV,eq,eW,eG,eK,eY,eX,eQ,eJ,e0,e1,e2,e5,e3,e6,e8,e4,e9,e7,te,tt,tn,ti,tr,tl,ta,to=n(43747),ts=n(67294),td=n(85893),tc=n(32932),tu=n(92212),tp=n(49688),th=n(68777),tm=n(22401),tf=n(6222),tg=n(1545),tx=n(32817),tb=n(29127),tv=n(34978),t_=n(52277),ty=n(43994),tj=n(69243),tw=n(79878),tk=n(23071),tC=n(40052),tI=n(19917),tS=n(83610),tz=n(65583),tP=n(30743),tE=n(74727),tD=n(9132),tT=n(37991),tM=n(82649),tR=n(42006),tA=n(92574),tO=n(98430),tL=n(53741),tB=n(68515),tN=n(93833),t$=n(46297),tZ=n(42965),tU=n(56542),tF=n(74855),tH=n.n(tF),tV=n(81763),tq=n.n(tV),tW=n(47037),tG=n.n(tW),tK=n(28440),tY=n(933),tX=n(57557),tQ=n.n(tX),tJ=n(64927),t0=n(45578),t1=n.n(t0),t2=n(94885),t5=n.n(t2),t3=n(25934),t6=n(34781),t8=n(60814),t4=n(42076),t9=n(18446),t7=n.n(t9),ne=n(53816),nt=n.n(ne),nn=n(55379),ni=n(42298);n(20745);var nr=n(23279),nl=n.n(nr),na=n(75472),no=n.n(na),ns=n(89734),nd=n.n(ns),nc=n(34167),nu=n(25274),np=n(30998),nh=n.n(np),nm=n(18029),nf=n.n(nm),ng=n(17423),nx=n(43495),nb=n(51526),nv=n(68929),n_=n.n(nv),ny=n(989),nj=n.n(ny),nw=n(44908),nk=n.n(nw),nC=n(21804),nI=n.n(nC),nS=n(38063),nz=n(13311),nP=n.n(nz),nE=n(73955),nD=n.n(nE),nT=n(5560),nM=n(30222),nR=n(67421),nA=n(18156),nO=n(34391),nL=n.n(nO),nB=n(70248),nN=n.n(nB),n$=n(38993),nZ=n.n(n$),nU=n(85092),nF=n(48764).lW,nH=n(34155);function Delay(e){let{children:t,ms:n=0}=e,[i,r]=(0,ts.useState)(n<=0);return((0,ts.useEffect)(()=>{if(n<=0)return;let e=setTimeout(()=>r(!0),n);return()=>{clearTimeout(e)}},[n]),i&&t)?"function"==typeof t?t():t:(0,td.jsx)(td.Fragment,{})}let nV="structure",nq=(0,tc.CVH)({locale:"en-US",namespace:nV,resources:()=>n.e(7972).then(n.bind(n,27972))});function DocTitle(e){let{document:t}=e,n=(0,tc.I_y)(),i=n.get(t._type),{t:r}=(0,tc.$G7)(nV),{error:l,value:a}=(0,tc._2T)({schemaType:i,value:t});return i?l?(0,td.jsx)(td.Fragment,{children:r("doc-title.error.text",{errorMessage:l.message})}):(0,td.jsx)(td.Fragment,{children:(null==a?void 0:a.title)||(0,td.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:r("doc-title.fallback.text")})}):(0,td.jsx)("code",{children:r("doc-title.unknown-schema-type.text",{schemaType:t._type})})}let RenderActionCollectionState=e=>{let{actions:t,children:n,actionProps:i,onActionComplete:r}=e;return(0,td.jsx)(tc.duV,{onReset:r,hooks:t,args:i,children:n})},RenderBadgeCollectionState=e=>{let{badges:t,children:n,badgeProps:i,...r}=e;return(0,td.jsx)(tc.duV,{...r,hooks:t,args:i,children:n})},getVisiblePoll$=()=>(i||(i=(0,tm.R)(document,"visibilitychange").pipe((0,tO.O)(null),(0,tb.U)(()=>"visible"===document.visibilityState),(0,tL.x)(),(0,tv.w)(e=>e?(0,tf.H)(0,5e3):tg.E),(0,tB.d)({refCount:!0,bufferSize:1}))),i),nW=(0,tc.ek8)(e=>{let[t,n]=e,i='{"references":'.concat("*[references($documentId)][0...100]{_id,_type}",',"totalCount":').concat("count(*[references($documentId)])","}");return n.listenQuery({fetch:i,listen:"*[references($documentId)]"},{documentId:t},{tag:"use-referring-documents",transitions:["appear","disappear"],throttleTime:5e3})}),nG=(0,tc.ek8)(e=>{let[t,n]=e;return getVisiblePoll$().pipe((0,tv.w)(()=>(function(e,t){let{versionedClient:n}=t;return getVisiblePoll$().pipe((0,tv.w)(()=>(function(e,t){let{versionedClient:n}=t,i=(0,tc.qyu)(e),r=(0,tc.vsM)(e),l={uri:n.getDataUrl("doc","".concat(i,",").concat(r)),json:!0,query:{excludeContent:"true"},tag:"use-referring-documents.document-existence"};return n.observable.request(l).pipe((0,tb.U)(e=>{let{omitted:t}=e,n=t.filter(e=>"existence"===e.reason);return 2===n.length?void 0:0===n.length?r:n.some(e=>e.id===i)?r:i}))})(e,t)),(0,tv.w)(e=>{if(!e)return(0,tx.of)({totalCount:0,references:[]});let t=n.config().dataset;return n.observable.request({url:"/data/references/".concat(t,"/documents/").concat(e,"/to?excludeInternalReferences=true&excludePaths=true"),tag:"use-referring-documents.external"}).pipe((0,tw.K)(e=>{if("object"==typeof e&&e&&"statusCode"in e&&"response"in e&&404===e.statusCode)return(0,tx.of)({totalCount:0,references:[]});throw e}))}))})(t,{versionedClient:n})))});function PublishedStatus(e){let{document:t}=e,n=t&&"_updatedAt"in t&&t._updatedAt,{t:i}=(0,tc.$G7)(nV);return(0,td.jsx)(tp.u,{portal:!0,content:(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{size:1,children:t?(0,td.jsx)(tc.vNl,{t:i,i18nKey:"pane-item.published-status.has-published.tooltip",components:{RelativeTime:()=>(0,td.jsx)(td.Fragment,{children:n&&(0,td.jsx)(tc.ijP,{time:n,useTemporalPhrase:!0})})}}):i("pane-item.published-status.no-published.tooltip")})}),children:(0,td.jsx)(tc.LPT,{tone:"positive",dimmed:!t,muted:!t,size:1,children:(0,td.jsx)(to.EI4,{"aria-label":t?"Published":"Not published"})})})}function DraftStatus(e){let{document:t}=e,n=t&&"_updatedAt"in t&&t._updatedAt,{t:i}=(0,tc.$G7)(nV);return(0,td.jsx)(tp.u,{portal:!0,content:(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{size:1,children:t?(0,td.jsx)(tc.vNl,{i18nKey:"pane-item.draft-status.has-draft.tooltip",t:i,components:{RelativeTime:()=>(0,td.jsx)(td.Fragment,{children:n&&(0,td.jsx)(tc.ijP,{time:n,useTemporalPhrase:!0})})}}):i("pane-item.draft-status.no-draft.tooltip")})}),children:(0,td.jsx)(tc.LPT,{tone:"caution",dimmed:!t,muted:!t,size:1,children:(0,td.jsx)(to.dY8,{})})})}function PaneItemPreview(e){let{icon:t,layout:n,presence:i,schemaType:r,value:l}=e,a=(0,tc.Uy$)(l.title)&&(0,ts.isValidElement)(l.title)||tG()(l.title)||tq(
1)(l.title)?l.title:null,{draft:o,published:s,isLoading:d}=(0,tK.m2)(()=>(0,tc.eLL)(e.documentPreviewStore,r,l._id,a),[e.documentPreviewStore,r,l._id,a]),c=d?null:(0,td.jsxs)(tp.gF,{space:4,children:[i&&i.length>0&&(0,td.jsx)(tc.mEJ,{presence:i}),(0,td.jsx)(PublishedStatus,{document:s}),(0,td.jsx)(DraftStatus,{document:o})]});return(0,td.jsx)(tc.ogX,{...(0,tc.L_b)({value:l,draft:o,published:s}),isPlaceholder:d,icon:t,layout:n,status:c})}function missingContext(){throw Error("Pane is missing router context")}let nK=(0,ts.createContext)({index:0,groupIndex:0,siblingIndex:0,payload:void 0,params:{},hasGroupSiblings:!1,groupLength:0,routerPanesState:[],BackLink:()=>missingContext(),ChildLink:()=>missingContext(),ReferenceChildLink:()=>missingContext(),handleEditReference:()=>missingContext(),ParameterizedLink:()=>missingContext(),replaceCurrent:()=>missingContext(),closeCurrentAndAfter:()=>missingContext(),closeCurrent:()=>missingContext(),duplicateCurrent:()=>missingContext(),setView:()=>missingContext(),setParams:()=>missingContext(),setPayload:()=>missingContext(),navigateIntent:()=>missingContext(),createPathWithParams:()=>missingContext()}),nY=(0,ts.forwardRef)(function(e,t){let{routerPanesState:n,groupIndex:i}=(0,ts.useContext)(nK),r=(0,ts.useMemo)(()=>n.slice(0,i),[i,n]),l=(0,ts.useMemo)(()=>({panes:r}),[r]);return(0,td.jsx)(tY.Px,{...e,ref:t,state:l})}),nX=(0,ts.createContext)(null);function usePaneLayout(){let e=(0,ts.useContext)(nX);if(!e)throw Error("PaneLayout: missing context value");return e}let nQ=(0,ts.forwardRef)(function(e,t){let{childId:n,childPayload:i,childParameters:r,...l}=e,{routerPanesState:a,groupIndex:o}=(0,ts.useContext)(nK);return(0,td.jsx)(tY.Px,{...l,ref:t,state:{panes:[...a.slice(0,o+1),[{id:n,params:r,payload:i}]]}})}),nJ=(0,ts.forwardRef)(function(e,t){let{documentId:n,documentType:i,parentRefPath:r,children:l,template:a,...o}=e;return(0,td.jsx)(nQ,{...o,ref:t,childId:n,childPayload:null==a?void 0:a.params,childParameters:{type:i,parentRefPath:(0,tJ.BB)(r),...a&&{template:null==a?void 0:a.id}},children:l})}),n0=(0,ts.forwardRef)(function(e,t){let{routerPanesState:n,groupIndex:i,siblingIndex:r}=(0,ts.useContext)(nK),{params:l,payload:a,...o}=e,s=(0,tc.BoV)(l),d=(0,tc.BoV)(a),c=(0,ts.useMemo)(()=>{let e=n[i],t=e[r],l={...t,params:null!=s?s:t.params,payload:null!=d?d:t.payload},a=[...e.slice(0,r),l,...e.slice(r+1)],o=[...n.slice(0,i),a,...n.slice(i+1)];return{panes:o}},[n,i,s,d,r]);return(0,td.jsx)(tY.Px,{ref:t,...o,state:c})});function usePaneRouter(){return(0,ts.useContext)(nK)}let n1=[];function ReferencePreviewLink(e){let{onClick:t,type:n,value:i}=e,r=(0,tc.vsM)(null==i?void 0:i._id),l=(0,tc.Dqo)(r),a=(0,tc.rq_)(),{ReferenceChildLink:o}=usePaneRouter(),s=(0,ts.useCallback)(function(e){return(0,td.jsx)(o,{documentId:null==i?void 0:i._id,documentType:null==n?void 0:n.name,parentRefPath:n1,...e})},[o,null==n?void 0:n.name,null==i?void 0:i._id]);return(0,td.jsx)(tc.oUE,{__unstable_focusRing:!0,as:s,"data-as":"a",onClick:t,padding:2,radius:2,children:(0,td.jsx)(PaneItemPreview,{documentPreviewStore:a,icon:null==n?void 0:n.icon,layout:"default",presence:(null==l?void 0:l.length)>0?l:n1,schemaType:n,value:i})})}var n2=Object.freeze,n5=Object.defineProperty,__template$I=(e,t)=>n2(n5(e,"raw",{value:n2(t||e.slice())}));let n3=(0,th.ZP)(tp.xu)(A||(A=__template$I(["\n margin-left: auto;\n"]))),n6=th.ZP.details(O||(O=__template$I(["\n flex: none;\n\n &[open] "," {\n transform: rotate(180deg);\n }\n"])),n3),n8=th.ZP.summary(L||(L=__template$I(["\n list-style: none;\n\n &::-webkit-details-marker {\n display: none;\n }\n"]))),n4=th.ZP.table(B||(B=__template$I(["\n width: 100%;\n text-align: left;\n padding: 0 ",";\n border-collapse: collapse;\n\n th {\n padding: ",";\n }\n\n td {\n padding: 0 ",";\n }\n\n tr > *:last-child {\n text-align: right;\n }\n"])),e=>{let{theme:t}=e;return(0,tp.hO)(t.sanity.space[2])},e=>{let{theme:t}=e;return(0,tp.hO)(t.sanity.space[1])},e=>{let{theme:t}=e;return(0,tp.hO)(t.sanity.space[1])}),n9=(0,th.ZP)(tp.kC)(N||(N=__template$I(["\n min-height: 35px;\n"]))),OtherReferenceCount=e=>{let{t}=(0,tc.$G7)(nV),n=e.totalCount-e.references.length;return n?(0,td.jsxs)(tp.gF,{space:2,children:[(0,td.jsx)(tp.xv,{size:1,muted:!0,children:t("confirm-delete-dialog.other-reference-count.title",{count:n})}),(0,td.jsx)(tp.u,{portal:!0,placement:"top",content:(0,td.jsx)(tp.W2,{width:0,children:(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{size:1,children:t("confirm-delete-dialog.other-reference-count.tooltip")})})}),children:(0,td.jsx)(tp.xv,{size:1,muted:!0,children:(0,td.jsx)(to.hQ6,{})})})]}):null};function ConfirmDeleteDialogBody(e){let{crossDatasetReferences:t,internalReferences:n,documentTitle:i,totalCount:r,action:l,datasetNames:a,hasUnknownDatasetN
1ames:o,onReferenceLinkClick:s}=e,d=(0,tc.I_y)(),c=(0,tp.pm)(),{t:u}=(0,tc.$G7)(nV),p=(0,ts.useCallback)(e=>{let t=d.get(e._type);return t?(0,td.jsx)(ReferencePreviewLink,{type:t,value:e,onClick:s}):(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tc.ogX,{icon:to.Tzq,title:u("confirm-delete-dialog.preview-item.preview-unavailable.title"),subtitle:u("confirm-delete-dialog.preview-item.preview-unavailable.subtitle",{documentId:e._id}),layout:"default"})})},[d,u,s]);if((null==n?void 0:n.totalCount)===0&&(null==t?void 0:t.totalCount)===0)return(0,td.jsx)(tp.xv,{as:"p",children:(0,td.jsx)(tc.vNl,{t:u,i18nKey:"confirm-delete-dialog.confirmation.text",context:l,components:{DocumentTitle:()=>(0,td.jsx)("strong",{children:i})}})});let h=[...a,...o?["unavailable"]:[]],m=u("confirm-delete-dialog.cdr-summary.subtitle",{count:h.length,datasets:h.join(", "),context:o&&h.length?"unavailable":""});return(0,td.jsxs)(tp.Zb,{children:[(0,td.jsx)(tp.Zb,{padding:3,radius:2,tone:"caution",marginBottom:4,flex:"none",children:(0,td.jsxs)(tp.kC,{children:[(0,td.jsx)(tp.xv,{"aria-hidden":"true",size:1,children:(0,td.jsx)(to.foC,{})}),(0,td.jsx)(tp.xu,{flex:1,marginLeft:3,children:(0,td.jsx)(tp.xv,{size:1,children:(0,td.jsx)(tc.vNl,{i18nKey:"confirm-delete-dialog.referring-document-count.text",components:{DocumentTitle:()=>i},t:u,values:{count:r}})})})]})}),(0,td.jsx)(tp.xu,{flex:"none",marginBottom:4,children:(0,td.jsx)(tp.xv,{children:(0,td.jsx)(tc.vNl,{i18nKey:"confirm-delete-dialog.referring-documents-descriptor.text",t:u,context:l,components:{DocumentTitle:()=>i}})})}),(0,td.jsx)(tp.Zb,{radius:2,shadow:1,marginBottom:4,flex:"auto",children:(0,td.jsxs)(tp.kC,{direction:"column",children:[n.totalCount>0&&(0,td.jsxs)(tp.Kq,{as:"ul",padding:2,space:3,"data-testid":"internal-references",children:[null==n?void 0:n.references.map(e=>(0,td.jsx)(tp.xu,{as:"li",children:p(e)},e._id)),n.totalCount>n.references.length&&(0,td.jsx)(tp.xu,{as:"li",padding:3,children:(0,td.jsx)(OtherReferenceCount,{...n})})]}),t.totalCount>0&&(0,td.jsxs)(n6,{"data-testid":"cross-dataset-references",style:{borderTop:n.totalCount>0?"1px solid var(--card-shadow-outline-color)":void 0},children:[(0,td.jsx)(n8,{children:(0,td.jsx)(tp.Zb,{as:"a",margin:2,radius:2,shadow:1,paddingY:1,children:(0,td.jsxs)(tp.kC,{align:"center",margin:2,children:[(0,td.jsx)(tp.xu,{marginLeft:3,marginRight:4,children:(0,td.jsx)(tp.xv,{size:3,children:(0,td.jsx)(to.TAM,{})})}),(0,td.jsxs)(tp.kC,{marginRight:4,direction:"column",children:[(0,td.jsx)(tp.xu,{marginBottom:2,children:(0,td.jsx)(tp.xv,{children:u("confirm-delete-dialog.cdr-summary.title",{count:h.length,documentCount:u("confirm-delete-dialog.cdr-summary.document-count",{count:t.totalCount})})})}),(0,td.jsx)(tp.xu,{children:(0,td.jsx)(tp.xv,{title:m,textOverflow:"ellipsis",size:1,muted:!0,children:m})})]}),(0,td.jsx)(n3,{children:(0,td.jsx)(tp.xv,{muted:!0,children:(0,td.jsx)(to.v4q,{})})})]})})}),(0,td.jsxs)(tp.xu,{overflow:"auto",paddingBottom:2,paddingX:2,children:[(0,td.jsxs)(n4,{children:[(0,td.jsx)("thead",{children:(0,td.jsxs)("tr",{children:[(0,td.jsx)("th",{children:(0,td.jsx)(tp.__,{muted:!0,size:0,style:{minWidth:"5rem"},children:u("confirm-delete-dialog.cdr-table.project-id.label")})}),(0,td.jsx)("th",{children:(0,td.jsx)(tp.__,{muted:!0,size:0,children:u("confirm-delete-dialog.cdr-table.dataset.label")})}),(0,td.jsx)("th",{children:(0,td.jsx)(tp.__,{muted:!0,size:0,children:u("confirm-delete-dialog.cdr-table.document-id.label")})})]})}),(0,td.jsx)("tbody",{children:t.references.filter(e=>"projectId"in e).map((e,t)=>{let{projectId:n,datasetName:i,documentId:r}=e;return(0,td.jsxs)("tr",{children:[(0,td.jsx)("td",{children:(0,td.jsx)(tp.xv,{size:1,children:n})}),(0,td.jsx)("td",{children:(0,td.jsx)(tp.xv,{size:1,children:i||"unavailable"})}),(0,td.jsx)("td",{children:(0,td.jsxs)(n9,{align:"center",gap:2,justify:"flex-end",children:[(0,td.jsx)(tp.xv,{textOverflow:"ellipsis",size:1,children:r||"unavailable"}),r&&(0,td.jsx)(tH(),{text:r,onCopy:()=>{c.push({title:u("confirm-delete-dialog.cdr-table.id-copied-toast.title"),status:"success"})},children:(0,td.jsx)(tp.zx,{title:u("confirm-delete-dialog.cdr-table.copy-id-button.tooltip"),mode:"bleed",icon:to.TIy,fontSize:0})})]})})]},"".concat(r,"-").concat(t))})})]}),(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(OtherReferenceCount,{...t})})]})]})]})}),(0,td.jsx)(tp.xu,{flex:"none",children:(0,td.jsx)(tp.xv,{children:(0,td.jsx)(tc.vNl,{i18nKey:"confirm-delete-dialog.referential-integrity-disclaimer.text",t:u,context:l,components:{DocumentTitle:()=>i}})})})]})}var n7=Object.freeze,ie=Object.defineProperty,__template$H=(e,t)=>n7(ie(e,"raw",{value:n7(t||e.slice())}));let it=(0,th.ZP)(tp.xu).attrs({padding:4})($||($=__template$H(["\n box-sizing: border-box;\n"]))),ii=(0,th.ZP)(tp.kC).attrs({align:"center",direction:"column",justify:"center"})(Z||(Z=__template$H(["\n height: 300px;\n"])));function ConfirmDeleteDialog(e){let{id:t,type:n,action:i="delete",onCancel:r,onConfirm:l}=e,{t:a}
1=(0,tc.$G7)(nV),o="deletion-confirmation-".concat((0,ts.useId)()),{internalReferences:s,crossDatasetReferences:d,isLoading:c,totalCount:u,projectIds:p,datasetNames:h,hasUnknownDatasetNames:m}=function(e){let t=(0,tc.m85)(tc.Dr7),n=(0,tc.H__)(),i=(0,tc.vsM)(e),[r,l]=nW((0,ts.useMemo)(()=>[i,n],[n,i])),[a,o]=nG((0,ts.useMemo)(()=>[i,t],[i,t])),s=(0,ts.useMemo)(()=>Array.from(new Set(null==a?void 0:a.references.map(e=>e.projectId).filter(Boolean))).sort(),[null==a?void 0:a.references]),d=(0,ts.useMemo)(()=>Array.from(new Set(null==a?void 0:a.references.map(e=>(null==e?void 0:e.datasetName)||"").filter(e=>!!e&&""!==e))).sort(),[null==a?void 0:a.references]),c=(0,ts.useMemo)(()=>!!(null==a?void 0:a.references.some(e=>"string"!=typeof e.datasetName)),[null==a?void 0:a.references]);return{totalCount:((null==r?void 0:r.totalCount)||0)+((null==a?void 0:a.totalCount)||0),projectIds:s,datasetNames:d,hasUnknownDatasetNames:c,internalReferences:r,crossDatasetReferences:a,isLoading:l||o}}(t),f=(0,td.jsx)(DocTitle,{document:(0,ts.useMemo)(()=>({_id:t,_type:n}),[t,n])}),g=!c;return(0,td.jsx)(tp.Vq,{width:1,id:o,header:a("confirm-delete-dialog.header.text",{context:i}),footer:(0,td.jsxs)(tp.rj,{columns:g?2:1,gap:2,paddingX:4,paddingY:3,children:[(0,td.jsx)(tp.zx,{mode:"ghost",onClick:r,text:a("confirm-delete-dialog.cancel-button.text")}),g&&(0,td.jsx)(tp.zx,{"data-testid":"confirm-delete-button",text:a(u>0?"confirm-delete-dialog.confirm-anyway-button.text":"confirm-delete-dialog.confirm-button.text",{context:i}),tone:"critical",onClick:l})]}),onClose:r,onClickOutside:r,children:(0,td.jsx)(it,{children:d&&s&&!c?(0,td.jsx)(ConfirmDeleteDialogBody,{crossDatasetReferences:d,internalReferences:s,documentTitle:f,isLoading:c,totalCount:u,action:i,projectIds:p,datasetNames:h,hasUnknownDatasetNames:m,onReferenceLinkClick:r}):(0,td.jsxs)(ii,{"data-testid":"loading-container",children:[(0,td.jsx)(tp.$j,{muted:!0}),(0,td.jsx)(tp.xu,{marginTop:3,children:(0,td.jsx)(tp.xv,{align:"center",muted:!0,size:1,children:a("confirm-delete-dialog.loading.text")})})]})})})}function ConfirmDeleteDialogContainer(e){let{t}=(0,tc.$G7)(nV),n=(0,ts.useId)(),[i,r]=(0,ts.useState)(null),l=(0,ts.useCallback)(()=>r(null),[]);return i?(0,td.jsx)(tp.Vq,{id:"dialog-error-".concat(n),"data-testid":"confirm-delete-error-dialog",header:t("confirm-delete-dialog.error.title.text"),footer:(0,td.jsx)(tp.kC,{paddingX:4,paddingY:3,direction:"column",children:(0,td.jsx)(tp.zx,{mode:"ghost",text:t("confirm-delete-dialog.error.retry-button.text"),onClick:l})}),onClose:e.onCancel,children:(0,td.jsx)(tp.xu,{padding:4,children:(0,td.jsx)(tp.xv,{children:t("confirm-delete-dialog.error.message.text")})})}):(0,td.jsx)(tp.SV,{onCatch:r,children:(0,td.jsx)(ConfirmDeleteDialog,{...e})})}let ir={constrainSize:!0,placement:"left-start",portal:!0};function PaneMenuButtonItem(e){let{disabled:t,isAfterGroup:n,node:i}=e,r=(0,tc.sr_)("i18n"in i?i:void 0);if("divider"===i.type)return(0,td.jsx)(tp.R,{});let{title:l}=r(i);return"group"===i.type?0===i.children.length?null:i.expanded?(0,td.jsxs)(td.Fragment,{children:[n&&(0,td.jsx)(tp.R,{}),l&&(0,td.jsx)(tp.xu,{padding:2,paddingBottom:1,children:(0,td.jsx)(tp.__,{muted:!0,size:0,children:l})}),i.children.map((e,n)=>{var r;return(0,td.jsx)(PaneMenuButtonItem,{disabled:t||!!i.disabled,isAfterGroup:(null==(r=i.children[n-1])?void 0:r.type)==="group",node:e},e.key)})]}):(0,td.jsxs)(td.Fragment,{children:[n&&(0,td.jsx)(tp.R,{}),(0,td.jsx)(tp.kS,{disabled:t,icon:i.icon,popover:ir,text:l,children:i.children.map((e,n)=>{var r;return(0,td.jsx)(PaneMenuButtonItem,{disabled:t||!!i.disabled,isAfterGroup:(null==(r=i.children[n-1])?void 0:r.type)==="group",node:e},e.key)})})]}):(0,td.jsxs)(td.Fragment,{children:[n&&(0,td.jsx)(tp.R,{}),(0,td.jsx)(PaneContextMenuItemResolver,{disabled:t,node:i})]})}function PaneContextMenuItemResolver(e){let{node:t}=e;return t.intent?(0,td.jsx)(PaneContextIntentMenuItem,{...e,intent:t.intent}):(0,td.jsx)(PaneContextMenuItem,{...e})}function PaneContextMenuItem(e){var t;let{disabled:n,node:i}=e,r="object"==typeof i.disabled&&(0,td.jsx)(tp.xv,{size:1,children:i.disabled.reason}),{title:l}=(0,tc.v0Z)(i);return(0,td.jsx)(tc.xMr,{content:r,placement:"left",children:(0,td.jsx)(tp.sN,{disabled:n||!!i.disabled,hotkeys:null==(t=i.hotkey)?void 0:t.split("+"),icon:i.icon,iconRight:i.iconRight||i.selected&&to.KML,onClick:i.onAction,pressed:i.selected,text:l,tone:i.tone})})}function PaneContextIntentMenuItem(e){var t;let{disabled:n,intent:i,node:r}=e,l="object"==typeof r.disabled&&(0,td.jsx)(tp.xv,{size:1,children:r.disabled.reason}),a=(0,tY.PM)({intent:i.type,params:i.params}),o=(0,ts.useCallback)(e=>{a.onClick(e),r.onAction()},[a,r]),{title:s}=(0,tc.v0Z)(r);return(0,td.jsx)(tc.xMr,{content:l,placement:"left",children:(0,td.jsx)(tp.sN,{as:"a",disabled:n||!!r.disabled,hotkeys:null==(t=r.hotkey)?void 0:t.split("+"),href:a.href,icon:r.icon,iconRight:r.selected?to.K
1ML:void 0,onClick:o,pressed:r.selected,text:s,tone:r.tone})})}let il={constrainSize:!0,placement:"bottom",portal:!0};function nodesHasTone(e,t){return e.some(e=>"item"===e.type&&e.tone===t||"group"===e.type&&nodesHasTone(e.children,t))}function PaneContextMenuButton(e){let{nodes:t}=e,n=(0,ts.useId)(),{t:i}=(0,tc.$G7)(nV),r=nodesHasTone(t,"critical"),l=nodesHasTone(t,"caution");return(0,td.jsx)(tp.j2,{button:(0,td.jsx)(tc.YG6,{icon:to.zGg,mode:"bleed",title:i("pane-header.context-menu-button.tooltip"),tone:r?"critical":l?"caution":void 0}),id:n,menu:(0,td.jsx)(tp.v2,{children:t.map((e,n)=>{var i;let r=(null==(i=t[n-1])?void 0:i.type)==="group";return(0,td.jsx)(PaneMenuButtonItem,{isAfterGroup:r,node:e},e.key)})}),popover:il})}let ia=(0,ts.createContext)(null);var io=Object.freeze,is=Object.defineProperty;let id=(0,th.ZP)(tp.mh)(U||(U=io(is(d=["\n position: relative;\n width: 1px;\n min-width: 1px;\n\n &:before {\n content: '';\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n width: 1px;\n background-color: var(--card-border-color);\n }\n\n &:not([data-disabled]) {\n cursor: ew-resize;\n width: 9px;\n min-width: 9px;\n margin: 0 -4px;\n\n &:before {\n left: 4px;\n }\n\n &:after {\n content: '';\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 9px;\n bottom: 0;\n background-color: var(--card-border-color);\n opacity: 0;\n transition: opacity 150ms;\n }\n\n &[data-dragging]:after,\n &:hover:after {\n opacity: 0.2;\n }\n }\n"],"raw",{value:io(d.slice())}))));function PaneDivider(e){let{disabled:t,element:n}=e,{resize:i}=usePaneLayout(),[r,l]=(0,ts.useState)(!1),a=(0,ts.useCallback)(e=>{if(!n)return;l(!0),e.preventDefault();let t=e.pageX;i("start",n,0);let handleMouseMove=e=>{e.preventDefault();let r=e.pageX-t;i("move",n,r)},handleMouseUp=e=>{e.preventDefault(),l(!1),window.removeEventListener("mousemove",handleMouseMove),window.removeEventListener("mouseup",handleMouseUp),i("end",n,0)};window.addEventListener("mousemove",handleMouseMove),window.addEventListener("mouseup",handleMouseUp)},[n,i]);return(0,td.jsx)(id,{"data-disabled":t?"":void 0,"data-dragging":r?"":void 0,onMouseDown:a})}var ic=Object.freeze,iu=Object.defineProperty;let ip=(0,th.ZP)(tp.Zb)(F||(F=ic(iu(c=["\n outline: none;\n\n // NOTE: This will render a border to the right side of each pane\n // without taking up physical space.\n box-shadow: 1px 0 0 var(--card-border-color);\n"],"raw",{value:ic(c.slice())})))),ih=(0,ts.forwardRef)(function(e,t){var n,i,r;let{children:l,currentMinWidth:a,currentMaxWidth:o,flex:s=1,id:d,minWidth:c,maxWidth:u,selected:p=!1,...h}=e,[m,f]=(0,ts.useState)(null),{collapse:g,collapsed:x,expand:b,expandedElement:v,mount:_,panes:y}=usePaneLayout(),j=y.find(e=>e.element===m),w=j&&y.indexOf(j),k="number"==typeof w?y[w+1]:void 0,C=w===y.length-1,I=!x&&((null==j?void 0:j.collapsed)||!1),S=(null==k?void 0:k.collapsed)||!1,z=(0,tp.ts)(t),P=null!=(n=null==j?void 0:j.flex)?n:s,E=null!=(i=null==j?void 0:j.currentMinWidth)?i:a,D=null!=(r=null==j?void 0:j.currentMaxWidth)?r:o,T=(0,ts.useCallback)(e=>{f(e),z.current=e},[z]);(0,ts.useEffect)(()=>{if(m)return _(m,{currentMinWidth:a,currentMaxWidth:o,flex:s,id:d,minWidth:c,maxWidth:u})},[a,o,s,d,c,u,_,m]);let M=(0,ts.useCallback)(()=>{m&&g(m)},[g,m]),R=(0,ts.useCallback)(()=>{m&&b(m)},[b,m]),A=(0,ts.useMemo)(()=>({collapse:M,collapsed:!x&&I,expand:R,index:w,isLast:C,rootElement:m}),[I,M,R,C,x,w,m]),O=(0,ts.useMemo)(()=>x?void 0:I?51:0===E||C?c||204:E||c||204,[I,E,C,x,c]),L=(0,ts.useMemo)(()=>I?51:x&&C?void 0:C?u?null!=D?D:u:void 0:null!=D?D:u,[I,D,C,x,u]),B=x&&!C,N=(0,ts.useMemo)(()=>!C&&!x&&(0,td.jsx)(tc.jr5,{zOffset:"paneResizer",children:(0,td.jsx)(PaneDivider,{disabled:I||S,element:m})}),[I,C,x,S,m]),$=(0,ts.useMemo)(()=>({flex:P,minWidth:O,maxWidth:L===1/0?void 0:L}),[P,O,L]);return(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)(tc.jr5,{zOffset:"pane",children:(0,td.jsx)(ia.Provider,{value:A,children:(0,td.jsxs)(ip,{"data-testid":"pane","data-ui":"Pane",tone
1:"inherit",hidden:B,id:d,overflow:x?void 0:"hidden",...h,"data-pane-collapsed":I?"":void 0,"data-pane-index":w,"data-pane-selected":p?"":void 0,ref:T,style:$,children:[!1,(0,td.jsx)(tp.NM,{element:m,children:!B&&(0,td.jsx)(tp.kC,{direction:"column",height:"fill",children:l})})]})})}),N]})});function usePane(){let e=(0,ts.useContext)(ia);if(!e)throw Error("Pane: missing context value");return e}var im=Object.freeze,ig=Object.defineProperty;let ix=(0,th.ZP)(tp.Zb)(H||(H=im(ig(u=["\n position: relative;\n outline: none;\n"],"raw",{value:im(u.slice())}))));ix.displayName="PaneContent__root";let ib=(0,ts.forwardRef)(function(e,t){let{as:n,children:i,overflow:r,padding:l,...a}=e,{collapsed:o}=usePane(),{collapsed:s}=usePaneLayout();return(0,td.jsx)(ix,{"data-testid":"pane-content",forwardedAs:n,...a,flex:1,hidden:o,overflow:s?void 0:r,padding:l,ref:t,tone:"inherit",children:i})});var iv=Object.freeze,i_=Object.defineProperty,__template$D=(e,t)=>iv(i_(e,"raw",{value:iv(t||e.slice())}));let iy=(0,th.ZP)(tp.mh)(V||(V=__template$D(["\n position: sticky;\n bottom: 0;\n\n &:before {\n content: '';\n display: block;\n position: absolute;\n left: 0;\n right: 0;\n top: -1px;\n border-bottom: 1px solid var(--card-shadow-outline-color);\n }\n"]))),ij=(0,th.ZP)(tp.Zb)(q||(q=__template$D(["\n padding-bottom: env(safe-area-inset-bottom);\n"]))),iw=(0,ts.forwardRef)(function(e,t){let{children:n,padding:i}=e,{collapsed:r}=usePane();return(0,td.jsx)(tc.jr5,{zOffset:"paneFooter",children:(0,td.jsx)(iy,{"data-testid":"pane-footer",hidden:r,ref:t,children:(0,td.jsx)(ij,{tone:"inherit",children:(0,td.jsx)(tp.xu,{padding:i,children:n})})})})});var ik=Object.freeze,iC=Object.defineProperty,__template$C=(e,t)=>ik(iC(e,"raw",{value:ik(t||e.slice())}));let iI=(0,th.ZP)(tp.mh)(W||(W=__template$C(["\n line-height: 0;\n position: sticky;\n top: 0;\n\n &:not([data-collapsed]):after {\n content: '';\n display: block;\n position: absolute;\n left: 0;\n right: 0;\n bottom: -1px;\n border-bottom: 1px solid var(--card-shadow-outline-color);\n }\n"]))),iS=(0,th.ZP)(tp.kC)(G||(G=__template$C(["\n transform-origin: calc(51px / 2);\n\n [data-collapsed] > div > & {\n transform: rotate(90deg);\n }\n"]))),iz=(0,th.ZP)(tp.Zb)(e=>{let{theme:t}=e,{fg:n,bg:i}=t.sanity.color.card.enabled;return(0,th.iv)(K||(K=__template$C(["\n background-color: ",";\n\n [data-ui='Text'] {\n color: ",";\n }\n "])),i,n)}),iP=(0,th.ZP)(tp.Qr)(Y||(Y=__template$C(["\n width: 66%;\n max-width: 175px;\n"]))),iE=(0,th.ZP)(tp.xv)(X||(X=__template$C(["\n cursor: default;\n outline: none;\n"]))),iD=(0,th.ZP)(tp.xu)(e=>{let{theme:t}=e,{color:n,space:i}=t.sanity;return(0,th.iv)(Q||(Q=__template$C(["\n overflow: hidden;\n overflow: clip;\n position: relative;\n\n & > div {\n white-space: nowrap;\n overflow: auto;\n /* Hide scrollbars */\n scrollbar-width: none;\n &::-webkit-scrollbar {\n width: 0;\n height: 0;\n }\n }\n\n /* right padding */\n & > div:after {\n content: '';\n display: inline-block;\n top: 0;\n right: 0;\n bottom: 0;\n width: ","px;\n height: 1px;\n }\n\n /* Gradient that makes it look like tabs disappear into nothing (looks nicer) */\n &:after {\n content: '';\n display: block;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n background: linear-gradient(to right, ",", var(--card-bg-color));\n width: ","px;\n pointer-events: none;\n }\n "])),i[3],(0,tp.m4)(n.base.bg,0),i[3])}),iT=(0,ts.forwardRef)(function(e,t){let{actions:n,backButton:i,contentAfter:r,loading:l,subActions:a,tabs:o,tabIndex:s,title:d}=e,{collapse:c,collapsed:u,expand:p,rootElement:h}=usePane(),m=(0,tp.XL)(h||null),f=(0,ts.useMemo)(()=>({width:u?(null==m?void 0:m.height)||window.innerHeight:void 0}),[u,m]),g=(0,ts.useCallback)(()=>{u||c()},[c,u]),x=(0,ts.useCallback)(()=>{u&&p()},[u,p]),b=!!(!u&&(o||a));return(0,td.jsx)(tp.li,{zOffset:100,children:(0,td.jsx)(iI,{"data-collapsed":u?"":void 0,"data-testid":"pane-header",ref:t,children:(0,td.jsx)(tc.jr5,{zOffset:"paneHeader",children:(0,td.jsxs)(tp.Zb,{"data-collapsed":u?"":void 0,tone:"inherit",children:[(0,td.jsxs)(iS,{onClick:x,padding:2,sizing:"border",style:f,children:[i&&(0,td.jsx)(tp.xu,{flex:"none",padding:1,children:i}),(0,td.jsxs)(iz,{__unstable_focusRing:!0,flex:1,forwardedAs:"button",marginRight:n?1:0,onClick:g,paddingLeft:i?1:3,paddingY:3,tabIndex:s,children:[l&&(0,td.jsx)(iP,{animated:!0,radius:1}),!l&&(0,td.jsx)(iE,{textOverflow:"ellipsis",weight:"semibold",children:d})]}),n&&(0,td.jsx)(tp.kC,{align:"center",hidden:u,children:(0,td.jsx)(tc.jr5,{zOffset:"paneHeader",children:n})})]}),b&&(0,td.jsxs)(tp.kC,{align:"center",hidden:u,overflow:"auto",paddingBottom:3,paddingX:3,paddingTop:1,children:[(0,td.jsx)(iD,{flex:1,marginRight:a?3:0,children:o}),a&&a]}),!u&&r&&r]})})})})});function PaneHeaderActionButton(e){let{node:t,padding:n}=e;return"item"===t.type?(0,td.jsx)(PaneHeaderMenuItemActionButton,{node:t,padding:n}):"group"===t.type?(0,td.jsx)(PaneHeaderMenuGroupActionButton,{node:t,padding:n}):(console.warn('unknown menu node (expected `type: "item" | "group"`):',t),null)}function PaneHeaderMenuItemActionButton(e){var t;let{node:n,padding:i}=e,{title:r}=(0,tc.v0Z)(n);if(n.intent)return(0,td.jsx)(PaneHeaderActionIntentButton,{...e,intent:n.intent});let l="object"==typeof n.disabled&&(0,td.jsx)(tp.xv,{size:1,children:n.disabled.reason});return(0,td.jsx)(tc.xMr,{content:l,placement:"bottom",children:(0,td.jsx)(tc.YG6,{disabled:!!n.disabled,hotkey:null==(t=n.hotkey)?void 0:t.split("+"),icon:n.icon,label:l?void 0:r,onClick:n.onAction,padding:i,selected:n.selected,tone:n.tone})})}function PaneHeaderActionIntentButton(e){var t;let{intent:n,node:i,padding:r}=e,l="object"==typeof i.disabled&&(0,td.jsx)(tp.xv,{size:1,children:i.disabled.reason}),a=(0,tY.PM)({intent:n.type,params:n.params}),o=(0,ts.useCallback)(e=>{a.onClick(e),i.onAction()},[a,i]);return(0,td.jsx)(tc.xMr,{content:l,placement:"bottom",children:(0,td.jsx)(tc.YG6,{as:"a",disabled:!!i.disabled,hotkey:null==(t=i.hotkey)?void 0:t.split("+"),href:a.href,icon:i.icon,label:l?void 0:i.title,onClick:o,padding:r,selected:i.selected,tone:i.tone})})}function PaneHeaderMenuGroupActionButton(e){var t;let{node:n,padding:i}=e,{title:r}=(0,tc.v0Z)(n);return(0,td.jsx)(tp.j2,{button:(0,td.jsx)(tc.YG6,{disabled:n.disabled,icon:null!=(t=n.icon)?t:to.Tzq,label:r,padding:i}),id:(0,ts.useId)(),menu:(0,td.jsx)(tp.v2,{children:n.children.map((e,t)=>{var i;return(0,td.jsx)(PaneMenuButtonItem,{disabled:!!n.disabled,isAfterGroup:(null==(i=n.children[t-1])?void 0:i.type)==="group",node:e},e.key)})})})}var iM=Object.freeze,iR=Object.defineProperty;let iA=(0,th.ZP)(tp.Zb)(J||(J=iM(iR(p=["\n transition: opacity 200ms;\n position: relative;\n z-index: 1;\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n opacity: 0;\n\n &:not([hidden]) {\n display: flex;\n }\n\n &:not([data-collapsed]) {\n overflow: auto;\n }\n\n &[data-mounted] {\n opacity: 1;\n }\n\n &[data-resizing] {\n pointer-events: none;\n }\n"],"raw",{value:iM(p.slice())})))),iO=[];
1function PaneLayout(e){let{children:t,minWidth:n,onCollapse:i,onExpand:r,...l}=e,a=(0,ts.useMemo)(()=>(function(){let e=[],t=[],n=new WeakMap,i=new Set,r={},l=null,a=0,o=null,s=new Map,d=!1;function expand(e){i.delete(e),o=e,_notifyObservers()}return{collapse:function(e){i.add(e),o===e&&(o=null),_notifyObservers()},expand,mount:function(e,i){return n.set(e,{...i,original:i}),t.push(e),l&&function(e,t){let n=new WeakMap;for(let i of t)n.set(i,function(e,t){let n=[],i=t;for(;i!==e;){let t=i.parentElement;if(!t)break;let r=Array.from(t.childNodes),l=r.indexOf(i);if(n.unshift(l),t===e)break;i=t}return n}(e,i));t.sort((e,t)=>{let i=n.get(e)||iO,r=n.get(t)||iO,l=Math.max(i.length,r.length);for(let e=0;e<l;e+=1){let t=i[e]||-1,n=r[e]||-1;if(t!==n)return t-n}return 0})}(l,t),expand(e),()=>{let i=t.indexOf(e);i>-1&&t.splice(i,1),n.delete(e),_notifyObservers()}},resize:function(e,i,l){var a,o,c,u;let p=t.indexOf(i),h=n.get(i);if(!h)return;let m=t[p+1],f=n.get(m);if(f){if("start"===e&&(d=!0,r.left={element:i,flex:h.flex||1,width:i.offsetWidth},r.right={element:m,flex:f.flex||1,width:m.offsetWidth},_notifyObservers()),"move"===e&&r.left&&r.right){s=new Map;let{leftW:e,rightW:t,leftFlex:n,rightFlex:a}=function(e,t,n,i){var r,l;let a={flex:e.left.flex+e.right.flex,width:e.left.width+e.right.width},o=null!=(r=t.minWidth)?r:204,s=null!=(l=n.minWidth)?l:204,d=Math.min(t.maxWidth||1/0,a.width-s),c=Math.min(n.maxWidth||1/0,a.width-o),u=o-e.left.width,p=e.right.width-c;u<p&&(u=p);let h=e.right.width-s,m=d-e.left.width;h>m&&(h=m);let f=Math.min(Math.max(i,u),h),g=e.left.width+f,x=e.right.width-f,b=g/a.width*a.flex,v=x/a.width*a.flex;return{leftFlex:b,leftW:g,rightFlex:v,rightW:x}}(r,h,f,l);s.set(i,{flex:n,width:e}),s.set(m,{flex:a,width:t}),_notifyObservers()}if("end"===e){d=!1;let e=s.get(i),t=s.get(m);n.set(i,{...h,currentMinWidth:0,currentMaxWidth:null!=(a=h.maxWidth)?a:1/0,flex:null!=(o=null==e?void 0:e.flex)?o:h.flex}),n.set(m,{...f,currentMinWidth:0,currentMaxWidth:null!=(c=h.maxWidth)?c:1/0,flex:null!=(u=null==t?void 0:t.flex)?u:f.flex}),s=new Map,delete r.left,delete r.right,_notifyObservers()}}},setRootElement:function(e){l=e},setRootWidth:function(e){a=e,_notifyObservers()},subscribe:function(t){return e.push(t),()=>{let n=e.push(t);n>-1&&e.splice(n,1)}}};function _notifyObservers(){var r,l,c,u;if(!a)return;let p=[];for(let e of t)e!==o&&p.unshift(e);o&&p.unshift(o);let h=new WeakMap,m=p.length,f=p[0],g=a-(m-1)*51;for(let e of p){let t=n.get(e);if(!t)continue;let a=t.currentMinWidth||t.minWidth||204,o=e===f,d=i.has(e),p=a>g,m=!o&&(d||p),x=s.get(e);h.set(e,{element:e,collapsed:m,currentMinWidth:null!=(r=null==x?void 0:x.width)?r:t.currentMinWidth,currentMaxWidth:null!=(l=null==x?void 0:x.width)?l:t.currentMaxWidth,flex:null!=(u=null!=(c=null==x?void 0:x.flex)?c:t.flex)?u:1}),m?g-=51:g-=a-51}let x=[];for(let e of t){let t=h.get(e);t&&x.push(t)}for(let n of e)n({expandedElement:o||t[t.length-1]||null,panes:x,resizing:d})}})(),[]),[o,s]=(0,ts.useState)(null),d=(0,tp.XL)(o),c=(null==d?void 0:d.width)||0,u=void 0!==c&&n?c<n:void 0,[p,h]=(0,ts.useState)({expandedElement:null,panes:[],resizing:!1});(0,ts.useEffect)(()=>a.setRootElement(o),[a,o]),(0,ts.useEffect)(()=>a.setRootWidth(c),[a,c]),(0,ts.useEffect)(()=>a.subscribe(h),[a]),(0,ts.useEffect)(()=>{void 0!==u&&(u&&i&&i(),!u&&r&&r())},[u,i,r]);let m=(0,ts.useMemo)(()=>({collapse:a.collapse,collapsed:u,expand:a.expand,expandedElement:p.expandedElement,mount:a.mount,panes:p.panes,resize:a.resize,resizing:p.resizing}),[u,a,p.expandedElement,p.panes,p.resizing]);return(0,td.jsx)(nX.Provider,{value:m,children:(0,td.jsx)(iA,{"data-ui":"PaneLayout",...l,"data-collapsed":u?"":void 0,"data-resizing":p.resizing?"":void 0,"data-mounted":c?"":void 0,ref:s,children:t})})}function isMenuNodeButton(e){return("item"===e.type||"group"===e.type)&&e.renderAsButton}let iL=t5()(isMenuNodeButton);function resolveMenuNodes(e){var t,n;let{fieldActions:i=[],menuItems:r,menuItemGroups:l}=e,a=[],o=0;for(let e=0;e<i.length;e+=1){let t=i[e];a.push(function mapFieldActionToPaneMenuNode(e,t){var n,i,r;return"divider"===e.type?{type:"divider",key:t}:"group"===e.type?{type:"group",key:t,children:e.children.map((e,n)=>mapFieldActionToPaneMenuNode(e,"".concat(t,"-").concat(n,"-").concat(e.type))),disabled:e.disabled,expanded:null==(n=e.expanded)||n,icon:e.icon,title:e.title,i18n:e.i18n,renderAsButton:null!=(i=e.renderAsButton)&&i}:{type:"item",key:t,intent:e.intent,disabled:e.disabled,icon:e.icon,iconRight:e.iconRight,onAction:e.onAction,renderAsButton:null!=(r=e.renderAsButton)&&r,selected:e.selected,title:e.title,i18n:e.i18n,tone:e.tone}}(t,"".concat(e,"-").concat(t.type)))}o+=a.length;let s=[];for(let e of l){let t=s.find(t=>t.key===e.id);t||s.push({type:"group",key:e.id,children:[],expanded:!0,renderAsButton:!1,title:e.title,i18n:e.i18n})}let d=[];for(let i=0;i<r.length;i+=1){let l=r[i],a=l.group&&s.find(e=>e.key===l.group);l.group&&!a&&(a={type:"group",key:l.group,expanded:!0,icon:l.icon,title:l.group,children:[],renderAsButton:!1},s.push(a)),a?a.children.push({type:"item",key:"".concat(o+i,"-item"),hotkey:l.shortcut,icon:l.icon,onAction:()=>e.actionHandler(l),renderAsButton:null!=(t=l.showAsAction)&&t,selected:l.selected,title:l.title,i18n:l.i18n,tone:l.tone}):d.push({type:"item",key:"".concat(o+i,"-item"),hotkey:l.shortcut,icon:l.icon,onAction:()=>e.actionHandler(l),renderAsButton:null!=(n=l.showAsAction)&&n,selected:l.selected,title:l.title,i18n:l.i18n,tone:l.tone})}return[...d,...s,...a]}let iB=(0,ts.forwardRef)(function(e,t){let{intent:n,...i}=e,r=(0,ts.useMemo)(()=>(0,ts.forwardRef)(function(e,t){return(0,td.jsx)(tY.nR,{...e,intent:n.type,params:n.params,ref:t})}),[n]);return e.disabled?(0,td.jsx)(tp.zx,{...i,as:"a",role:"link","aria-disabled":"true"}):(0,td.jsx)(tp.zx,{...i,as:r,"data-as":"a",ref:t})});function InsufficientPermissionsMessageTooltip(e){let{reveal:t,context:n,loading:i,children:r}=e,l=(0,tc.xJ)(),{t:a}=(0,tc.$G7)(nV);return t?(0,td.jsx)(tp.u,{content:i?(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{children:a("insufficient-permissions-message-tooltip.loading-text")})}):(0,td.jsx)(tc.FMn,{context:n,currentUser:l}),portal:!0,children:(0,td.jsx)("div",{children:r})}):(0,td.jsx)(td.Fragment,{children:r})}let iN={constrainSize:!0,placement:"bottom",portal:!0}
1,getIntent=(e,t,n)=>{var i;let r=null==(i=t.find(e=>e.id===n.templateId))?void 0:i.schemaType;if(!r)return null;let l={template:n.templateId,type:r,id:n.initialDocumentId};return{type:"create",params:n.parameters?[l,n.parameters]:l}};function PaneHeaderCreateButton(e){let{templateItems:t}=e,n=(0,tc.I_y)(),i=(0,tc.zEW)(),{t:r}=(0,tc.$G7)(nV),l=(0,tc.sr_)([...t,...i]),[a,o]=(0,tc.UMU)({templateItems:t}),s=(0,ts.useMemo)(()=>!o&&(null==a?void 0:a.every(e=>!e.granted)),[o,a]),d=(0,ts.useMemo)(()=>a?a.reduce((e,t)=>(e[t.id]=t,e),{}):{},[a]);if(s)return(0,td.jsx)(InsufficientPermissionsMessageTooltip,{context:"create-document-type",reveal:!0,loading:o,children:(0,td.jsx)(tp.zx,{"aria-label":r("pane-header.disabled-created-button.aria-label"),"data-testid":"action-intent-button",disabled:!0,icon:to.dtP,mode:"bleed"})});if(1===t.length){let e=t[0],r=d[e.id],a=!(null==r?void 0:r.granted),s=getIntent(n,i,e);return s?(0,td.jsx)(InsufficientPermissionsMessageTooltip,{reveal:a,loading:o,context:"create-document-type",children:(0,td.jsx)(iB,{title:l(e).title,icon:e.icon||to.dtP,intent:s,mode:"bleed",disabled:a,"data-testid":"action-intent-button"})}):null}return(0,td.jsx)(tp.j2,{button:(0,td.jsx)(tp.zx,{icon:to.dtP,mode:"bleed","data-testid":"multi-action-intent-button"}),id:"create-menu",menu:(0,td.jsxs)(tp.v2,{children:[(0,td.jsx)(tp.xu,{paddingX:3,paddingTop:3,paddingBottom:2,children:(0,td.jsx)(tp.__,{muted:!0,children:r("pane-header.create-menu.label")})}),t.map((e,t)=>{let a=d[e.id],s=!(null==a?void 0:a.granted),c=getIntent(n,i,e),u=i.find(t=>t.id===e.templateId);if(!u||!c)return null;let p=(0,ts.forwardRef)((e,t)=>s?(0,td.jsx)("button",{type:"button",disabled:!0,...e,ref:t}):(0,td.jsx)(tY.nR,{...e,intent:c.type,params:c.params,ref:t}));p.displayName="Link";let{title:h}=l({...e,title:e.title||l(u).title});return(0,td.jsx)(InsufficientPermissionsMessageTooltip,{context:"create-document-type",reveal:s,loading:o,children:(0,td.jsx)(tp.sN,{as:p,"data-as":s?"button":"a",text:h,"aria-label":s?r("pane-header.disabled-created-button.aria-label"):h,disabled:s,"data-testid":"action-intent-button-".concat(t)})},e.id)})]}),popover:iN})}function isNonNullable(e){return null!=e}let hashObject=e=>{let sortObject=e=>"object"==typeof e&&e?Array.isArray(e)?e.map(sortObject):Object.entries(e).sort((e,t)=>{let[n]=e,[i]=t;return n.localeCompare(i,"en")}):e;return JSON.stringify(sortObject(JSON.parse(JSON.stringify(e))))},i$=(0,ts.memo)(function(e){let{initialValueTemplateItems:t=tc.LZ8,menuItems:n=tc.LZ8,menuItemGroups:i=tc.LZ8,actionHandlers:r=tc.NuZ}=e,l=(0,tc.zEW)(),a=(0,ts.useCallback)(e=>{if("string"==typeof e.action&&!(e.action in r))return console.warn("No handler for action:",e.action),!1;let t="function"==typeof e.action?e.action:"string"==typeof e.action?r[e.action]:null;return!!t&&(t(e.params),!0)},[r]),o=(0,ts.useMemo)(()=>resolveMenuNodes({actionHandler:a,menuItemGroups:i,menuItems:n.filter(e=>{var t;return(null==(t=e.intent)?void 0:t.type)!=="create"})}),[a,i,n]),s=(0,ts.useMemo)(()=>o.filter(isMenuNodeButton),[o]),d=(0,ts.useMemo)(()=>o.filter(iL),[o]),c=(0,ts.useMemo)(()=>n.map((e,t)=>{var n;if((null==(n=e.intent)?void 0:n.type)!=="create")return null;let{params:i}=e.intent;if(!i)return null;let r=Array.isArray(i)?i[0]:i,a=Array.isArray(i)?i[1]:void 0,o=r.template||r.type;if(!o)return null;let s=l.find(e=>e.id===o);if(!s)return null;let d=r.id;return{item:e,template:s,templateParams:a,menuItemIndex:t,initialDocumentId:d}}).filter(isNonNullable).map(e=>{let{initialDocumentId:t,item:n,template:i,menuItemIndex:r,templateParams:l}=e,a={id:"menuItem".concat(r),initialDocumentId:t,templateId:i.id,type:"initialValueTemplateItem",title:n.title||i.title,i18n:n.i18n||i.i18n,icon:n.icon,description:i.description,parameters:l,schemaType:i.schemaType};return a}),[n,l]),u=(0,ts.useMemo)(()=>t1()([...c,...t],e=>hashObject([e.initialDocumentId,e.templateId,e.parameters])),[c,t]);return(0,td.jsxs)(tp.kC,{gap:1,children:[u.length>0&&(0,td.jsx)(PaneHeaderCreateButton,{templateItems:u}),s.map(e=>(0,td.jsx)(PaneHeaderActionButton,{node:e},e.key)),d.length>0&&(0,td.jsx)(PaneContextMenuButton,{nodes:d})]})});function MissingSchemaType(e){let{t}=(0,tc.$G7)(nV),{layout:n,value:i}=e;return(0,td.jsx)(tc.ogX,{title:(0,td.jsx)("em",{children:(0,td.jsx)(tc.vNl,{t,i18nKey:"pane-item.missing-schema-type.title",components:{Code:"code"},values:{documentType:i._type}})}),subtitle:(0,td.jsx)(tc.vNl,{t,i18nKey:"pane-item.missing-schema-type.subtitle",components:{Code:"code"},values:{documentId:i._id}}),media:()=>(0,td.jsx)(to.foC,{}),layout:n})}function getIconWithFallback(e,t,n){return!1!==e&&(e||t&&t.icon||n||!1)}function PaneItem(e){let{icon:t,id:n,layout:i="default",pressed:r,schemaType:l,selected:a,title:o,value:s,margin:d,marginBottom:c,marginTop:u}=e,p=(0,tc.I_y)(),h=(0,tc.rq_)(),{ChildLink:m}=usePaneRouter(),f=(0,tc.Dqo)(n),g=!!(l&&l.name&&p.get(l.name)),[x,b]=(0,ts.useState)(!1),v=(0,ts.useMemo)(()=>s&&(0,tu.Si)(s)?l&&g?(0,td.jsx)(PaneItemPreview,{documentPreviewStore:h,icon:getIconWithFallback(t,l,to.$lS),layout:i,schemaType:l,value:s,presence:f}):(0,td.jsx)(MissingSchemaType,{value:s}):(0,td.jsx)(tc.ogX,{status:(0,td.jsx)(tp.xv,{muted:!0,children:(0,td.jsx)(to.XCv,{})}),icon:getIconWithFallback(t,l,to.ROc),layout:i,title:o}),[h,g,t,i,l,o,s,f]),_=(0,ts.useMemo)(()=>function(e){return(0,td.jsx)(m,{...e,childId:n})},[m,n]),y=(0,ts.useCallback)(e=>{if(e.metaKey){b(!1);return}b(!0)},[]);return(0,ts.useEffect)(()=>b(!1),[a]),(0,td.jsx)(tc.oUE,{__unstable_focusRing:!0,as:_,"data-as":"a","data-ui":"PaneItem",margin:d,marginBottom:c,marginTop:u,onClick:y,padding:2,pressed:r,radius:2,selected:a||x,sizing:"border",tabIndex:-1,tone:"inherit",children:v})}let iZ=(0,ts.createContext)(null);function useDocumentPane(){let e=(0,ts.useContext)(iZ);if(!e)throw Error("DocumentPane: missing context value");return e}let iU={NOTHING_TO_DELETE:"action.delete.disabled.nothing-to-delete",NOT_READY:"action.delete.disabled.not-ready"},DeleteAction=e=>{let{id:t,type:n,draft:i,onComplete:r}=e,{setIsDeleting:l}=useDocumentPane(),{delete:a}=(0,tc.d9t)(t,n),[o,s]=(0,ts.useState)(!1),[d,c]=(0,ts.useState)(!1),{t:u}=(0,tc.$G7)(nV),p=(0,ts.useCallback)(()=>{c(!1),r()},[r]),h=(0,ts.useCallback)(()=>{s(!0),c(!1),l(!0),a.execute(),r()},[a,r,l]),m=(0,ts.useCallback)(()=>{c(!0)},[]),[f,g]=(0,tc.hHf)({id:t,type:n,permission:"delete"}),x=(0,tc.xJ)();return g||(null==f?void 0:f.granted)?{tone:"critical",icon:to.XHJ,disabled:o||!!a.disabled||g,title:a.disabled&&u(iU[a.disabled])||"",label:u(o?"action.delete.running.label":"action.delete.label"),shortcut:"Ctrl+Alt+D",onHandle:m,dialog:d&&{type:"custom",component:(0,td.jsx)(ConfirmDeleteDialogContainer,{action:"delete",id:(null==i?void 0:i._id)||t,type:n,onCancel:p,onConfirm:h})}}
1:{tone:"critical",icon:to.XHJ,disabled:!0,label:u("action.delete.label"),title:(0,td.jsx)(tc.FMn,{context:"delete-document",currentUser:x})}};DeleteAction.action="delete";let iF={NO_CHANGES:"action.discard-changes.disabled.no-changes",NOT_PUBLISHED:"action.discard-changes.disabled.not-published",NOT_READY:"action.discard-changes.disabled.not-ready"},DiscardChangesAction=e=>{let{id:t,type:n,published:i,liveEdit:r,onComplete:l}=e,{discardChanges:a}=(0,tc.d9t)(t,n),[o,s]=(0,ts.useState)(!1),[d,c]=(0,tc.hHf)({id:t,type:n,permission:"discardDraft"}),u=(0,tc.xJ)(),{t:p}=(0,tc.$G7)(nV),h=(0,ts.useCallback)(()=>{a.execute(),l()},[a,l]),m=(0,ts.useCallback)(()=>{s(!0)},[]),f=(0,ts.useMemo)(()=>o&&{type:"confirm",tone:"critical",onCancel:l,onConfirm:h,message:p("action.discard-changes.confirm-dialog.confirm-discard-changes")},[h,o,l,p]);return!i||r?null:c||(null==d?void 0:d.granted)?{tone:"critical",icon:to.X5P,disabled:!!a.disabled||c,title:a.disabled&&iF[a.disabled]||"",label:p("action.discard-changes.label"),onHandle:m,dialog:f}:{tone:"critical",icon:to.X5P,disabled:!0,label:p("action.discard-changes.label"),title:(0,td.jsx)(tc.FMn,{context:"discard-changes",currentUser:u})}};DiscardChangesAction.action="discardChanges";let iH={NOTHING_TO_DUPLICATE:"action.duplicate.disabled.nothing-to-duplicate",NOT_READY:"action.duplicate.disabled.not-ready"},DuplicateAction=e=>{let{id:t,type:n,onComplete:i}=e,{duplicate:r}=(0,tc.d9t)(t,n),{navigateIntent:l}=(0,tY.tv)(),[a,o]=(0,ts.useState)(!1),[s,d]=(0,tc.hHf)({id:t,type:n,permission:"duplicate"}),{t:c}=(0,tc.$G7)(nV),u=(0,tc.xJ)(),p=(0,ts.useCallback)(()=>{let e=(0,t3.Z)();o(!0),r.execute(e),l("edit",{id:e,type:n}),i()},[r,l,i,n]);return d||(null==s?void 0:s.granted)?{icon:to.TIy,disabled:a||!!r.disabled||d,label:c(a?"action.duplicate.running.label":"action.duplicate.label"),title:r.disabled?c(iH[r.disabled]):"",onHandle:p}:{icon:to.TIy,disabled:!0,label:c("action.duplicate.label"),title:(0,td.jsx)(tc.FMn,{context:"duplicate-document",currentUser:u})}};DuplicateAction.action="duplicate";let HistoryRestoreAction=e=>{let{id:t,type:n,revision:i,onComplete:r}=e,{restore:l}=(0,tc.d9t)(t,n),a=(0,tc.E6V)(t,n),{navigateIntent:o}=(0,tY.tv)(),s=(0,ts.useRef)(a),[d,c]=(0,ts.useState)(!1),{t:u}=(0,tc.$G7)(nV),p=(0,ts.useCallback)(()=>{l.execute(i),r()},[l,i,r]);(0,ts.useEffect)(()=>{a&&a!==s.current&&("success"===a.type&&"restore"===a.op&&o("edit",{id:t,type:n}),s.current=a)},[a,t,o,n]);let h=(0,ts.useCallback)(()=>{c(!0)},[]),m=(0,ts.useMemo)(()=>d?{type:"confirm",tone:"critical",onCancel:r,onConfirm:p,message:u("action.restore.confirm.message")}:null,[p,d,r,u]),f="@initial"===i,g=void 0===i;return g?null:{label:u("action.restore.label"),color:"primary",onHandle:h,title:u(f?"action.restore.disabled.cannot-restore-initial":"action.restore.tooltip"),icon:to.vaD,dialog:m,disabled:f}};HistoryRestoreAction.action="restore";let iV={LIVE_EDIT_ENABLED:"action.publish.live-edit.publish-disabled",ALREADY_PUBLISHED:"action.publish.already-published.no-time-ago.tooltip",NO_CHANGES:"action.publish.no-changes.tooltip",NOT_READY:"action.publish.disabled.not-ready"};function AlreadyPublished(e){let{publishedAt:t}=e,{t:n}=(0,tc.$G7)(nV),i=(0,tc.ofl)(t);return(0,td.jsx)("span",{children:n("action.publish.already-published.tooltip",{timeSincePublished:i})})}let PublishAction=e=>{var t,n,i;let{id:r,type:l,liveEdit:a,draft:o,published:s}=e,[d,c]=(0,ts.useState)(null),{publish:u}=(0,tc.d9t)(r,l),p=(0,tc.a3k)(r,l),h=(0,tc.nuD)(r,l),{changesOpen:m,onHistoryOpen:f,documentId:g,documentType:x}=useDocumentPane(),b=(0,tc.iav)(g,x),{t:v}=(0,tc.$G7)(nV),_=((null==b?void 0:b.draft)||(null==b?void 0:b.published)||{})._rev,y=p.validation.some(tu.YN),[j,w]=(0,ts.useState)(!1),k=h.isSyncing,C=p.isValidating,[I,S]=(0,tc.hHf)({id:r,type:l,permission:"publish"}),z=(0,tc.xJ)(),P=u.disabled?(n=u.disabled,i=(s||{})._updatedAt,("ALREADY_PUBLISHED"===n&&i?(0,td.jsx)(AlreadyPublished,{publishedAt:i}):v(iV[n]))||""):y?v("action.publish.validation-issues.tooltip"):"",E=!!o,D=(0,ts.useCallback)(()=>{u.execute(),c("publishing")},[u]);(0,ts.useEffect)(()=>{let e=!1===p.isValidating&&p.revision!==_;j&&!k&&e&&(y||D(),w(!1))},[k,D,y,j,p.revision,_,C,p.isValidating]),(0,ts.useEffect)(()=>{let e="publishing"===d&&!E;e&&m&&f();let t=e?"published":null,n=setTimeout(()=>{c(t)},e?200:4e3);return()=>clearTimeout(n)},[m,d,E,f]);let T=(0,ts.useCallback)(()=>{h.isSyncing||p.isValidating||p.revision!==_?w(!0):D()},[h.isSyncing,p.isValidating,p.revision,_,D]);if(a)return{tone:"positive",label:v("action.publish.live-edit.label"),title:v("action.publish.live-edit.tooltip"),disabled:!0};if(!S&&!(null==I?void 0:I.granted))return{tone:"positive",label:"Publish",t
1itle:(0,td.jsx)(tc.FMn,{context:"publish-document",currentUser:z}),disabled:!0};let M=!!(j||(null==(t=null==b?void 0:b.transactionSyncLock)?void 0:t.enabled)||"publishing"===d||"published"===d||y||u.disabled);return{disabled:M||S,tone:"positive",label:v("published"===d?"action.publish.published.label":j||"publishing"===d?"action.publish.running.label":"action.publish.draft.label"),icon:"published"===d?to.KML:to.EI4,title:j?v("action.publish.waiting"):"published"===d||"publishing"===d?null:P,shortcut:M||j?null:"Ctrl+Alt+P",onHandle:T}};PublishAction.action="publish";let iq={NOT_PUBLISHED:"action.unpublish.disabled.not-published",NOT_READY:"action.unpublish.disabled.not-ready",LIVE_EDIT_ENABLED:"action.unpublish.disabled.live-edit-enabled"},UnpublishAction=e=>{let{id:t,type:n,draft:i,onComplete:r,liveEdit:l}=e,{unpublish:a}=(0,tc.d9t)(t,n),[o,s]=(0,ts.useState)(!1),[d,c]=(0,tc.hHf)({id:t,type:n,permission:"unpublish"}),u=(0,tc.xJ)(),{t:p}=(0,tc.$G7)(nV),h=(0,ts.useCallback)(()=>{s(!1),r()},[r]),m=(0,ts.useCallback)(()=>{s(!1),a.execute(),r()},[r,a]),f=(0,ts.useMemo)(()=>o?{type:"dialog",onClose:r,content:(0,td.jsx)(ConfirmDeleteDialogContainer,{id:(null==i?void 0:i._id)||t,type:n,action:"unpublish",onCancel:h,onConfirm:m})}:null,[i,t,h,m,o,r,n]);return l?null:c||(null==d?void 0:d.granted)?{tone:"critical",icon:to.xEY,disabled:!!a.disabled||c,label:p("action.unpublish.label"),title:a.disabled?p(iq[a.disabled]):"",onHandle:()=>s(!0),dialog:f}:{tone:"critical",icon:to.xEY,label:"Unpublish",title:(0,td.jsx)(tc.FMn,{context:"unpublish-document",currentUser:u}),disabled:!0}};UnpublishAction.action="unpublish";let iW=!1,iG={},iK=Symbol("LOADING_PANE"),iY="documentPanelPortalElement",iX={activePanes:[]};function setActivePanes(e){iX.activePanes=e}function getIntentState(e,t,n,i){var r;let l=(null==n?void 0:n.panes)||[],a=iX.activePanes||[],o=t.id||(0,t3.Z)(),s="create"===e&&t.template;for(let n=a.length-1;n>=0;n--){let d=a[n];if("object"==typeof d&&((null==(r=d.canHandleIntent)?void 0:r.call(d,e,t,{pane:d,index:n}))||"documentList"===d.type&&d.schemaTypeName===t.type&&"_type == $type"===d.options.filter)){let e=s?{template:t.template}:iG;return{panes:l.slice(0,n).concat([[{id:o,params:e,payload:i}]])}}}return{intent:e,params:t,payload:i}}let iQ={},iJ=tY.BC.create("/",[tY.BC.intents("/intent"),tY.BC.create("/edit/:type/:editDocumentId",[tY.BC.create({path:"/:params",transform:{params:{toState:function(e){try{return JSON.parse(decodeURIComponent(e))}catch(e){return console.warn("Failed to parse JSON parameters"),{}}},toPath:function(e){return JSON.stringify(e)}}}})]),tY.BC.create({path:"/:panes",children:[tY.BC.create("/:action",tY.BC.create("/:legacyEditDocumentId"))],transform:{panes:{toState:function(e){var t;return -1!==(t=decodeURIComponent(e)).indexOf(",{")?function(e){let t=[],n=e;for(;n.length;){let[e,i,r]=n.match(i0)||[];if(!e){n=n.slice(1);continue}let l=r&&function(e){try{return JSON.parse(e)}catch(e){console.warn("Failed to parse parameters: ".concat(e.message));return}}(r);t.push({id:i,payload:l}),n=n.slice(e.length)}return[t]}(t):t.split(";").map(e=>{let[t,...n]=e.split("|").map(e=>{let[t,...n]=e.split(",");return function(e,t){let n={...t,params:iQ,payload:void 0};return e.reduce((e,t)=>{if(isParam(t)){let n=t.slice(0,t.indexOf("=")),i=t.slice(n.length+1);e.params={...e.params,[decodeURIComponent(n)]:decodeURIComponent(i)}}else isPayloadLike(t)?e.payload=function(e){try{return e?(0,tY.ZB)(e):void 0}catch(e){console.warn("Failed to parse parameters: ".concat(e.message));return}}(t):console.warn("Unknown pane segment: %s - skipping",t);return e},n)}(n,{id:t})});return[t,...n.map(e=>({...t,...e,id:e.id||t.id,params:{...tQ()(t.params,i1),...e.params},payload:e.payload||t.payload}))]}).filter(e=>e.length>0)},toPath:function(e){return(e||[]).map(e=>e.map(encodeChunks).join("|")).map(encodeURIComponent).join(";")}}}})]),i0=/^([.a-z0-9_-]+),?({.*?})?(?:(;|$))/i,isParam=e=>/^[a-z0-9]+=[^=]+/i.test(e),isPayloadLike=e=>/^[A-Za-z0-9\-_]+(?:={0,2})$/.test(e),i1=["view","since","rev","inspect","comment"],i2=Boolean;function encodeChunks(e,t,n){let{payload:i,params:r={},id:l}=e,[a]=n,o=e===a,s=0!==t&&l===a.id,d=void 0===i?void 0:(0,tY.B8)(i),c=Object.entries(r).filter(e=>{var t;let[n,i]=e;if(!i)return!1;if(o)return!0;let r=null==(t=a.params)?void 0:t[n];return!!(i!==r||i1.includes(n))}).map(e=>{let[t,n]=e;return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n))});return[s?"":l].concat([c.length>0&&c,d].filter(i2).flat()).join(",")||","}let i5={},i3="inspect:",i6=[{id:"inspectors"},{id:"links"}],i8="sanity/desk/history",i4="sanity/desk/comments";var i9=Object.freeze,i7=Object.defineProperty;let re=(0,th.ZP)(tp.qE)(ee||(ee=i9(i7(h=["\n svg > ellipse {\n stroke: transparent;\n }\n"],"raw",{value:i9(h.slice())})))),rt=/[^\p{Alpha}\p{White_Space}]/gu,rn=RegExp("\\p{White_Space}+","u");function CommentsAvatar(e){let{user:t,...n}=e,i=(0,ts.useMemo)(()=>(function(e){let t=e.replace(rt,"").split(rn);return 1===t.length?"".concat(t[0].charAt(0)).toUpperCase():"".concat(t[0].charAt(0)).concat(t[t.length-1].charAt(0))})((null==t?void 0:t.displayName)||""),[null==t?void 0:t.displayName]);return t?(0,td.jsx)(re,{initials:i,src:null==t?void 0:t.imageUrl,title:null==t?void 0:t.displayName,...n}):(0,td.jsx)(re,{...n})}let ri={minWidth:25};function SpacerAvatar(){return(0,td.jsx)("div",{style:ri})}var rr=Object.freeze,rl=Object.defineProperty,__template$z=(e,t)=>rr(rl(e,"raw",{value:rr(t||e.slice())}));let ra={open:500,close:0},ro=th.ZP.span(e=>{var t,n,i;let{theme:r}=e,{regular:l}=null==(t=r.sanity.fonts)?void 0:t.text.weights,{hovered:a}=null==(n=r.sanity.color)?void 0:n.card,{bg:o}=(null==(i=r.sanity.color.selectable)?void 0:i.caution.pressed)||{};return(0,th.iv)(et||(et=__template$z(["\n font-weight: ",";\n color: var(--card-link-fg-color);\n border-radius: 2px;\n background-color: ",";\n padding: 1px;\n box-sizing: border-box;\n\n &[data-active='true'] {\n background-color: ",";\n }\n "])),l,a.bg,o)});function MentionInlineBlock(e){let{selected:t,userId:n}=e,[i,r]=(0,tc.aFb)(n),l=(0,tc.xJ)();return!i||r?(0,td.jsx)(ro,{children:"@Loading"}):(0,td.jsx)(tp.u,{portal:!0,open:t,delay:ra,content:(0,td.jsxs)(tp.kC,{align:"center",padding:2,gap:2,children:[(0,td.jsx)(tp.kC,{children:(0,td.jsx)(CommentsAvatar,{user:i})}),(0,td.jsx)(tp.xv,{size:1,children:i.displayName})]}),children:(0,td.jsxs)(ro,{"data-selected":t,"data-active":(null==l?void 0:l.id)===n,children:["@",i.displayName]})})}
1var rs=Object.freeze,rd=Object.defineProperty;let rc=(0,th.ZP)(tp.xv)(en||(en=rs(rd(m=["\n word-break: break-word;\n"],"raw",{value:rs(m.slice())}))));function NormalBlock(e){let{children:t}=e;return(0,td.jsx)(rc,{size:1,children:t})}var ru=Object.freeze,rp=Object.defineProperty,__template$x=(e,t)=>ru(rp(e,"raw",{value:ru(t||e.slice())}));let rh=(0,th.ZP)(tp.Kq)(()=>(0,th.iv)(ei||(ei=__template$x(["\n & > [data-ui='Text']:not(:first-child) {\n margin-top: 1em; // todo: improve\n }\n\n & > [data-ui='Text']:has(> span:empty) {\n display: none;\n }\n "])))),rm=[],rf={block:{normal:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},h1:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},h2:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},h3:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},h4:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},h5:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},h6:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},blockquote:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},code:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})}},list:{bullet:e=>{let{children:t}=e;return t},number:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})},checkmarks:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})}},listItem:{bullet:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},number:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},checkmarks:e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})}},marks:{strong:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})},em:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})},code:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})},underline:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})},strikeThrough:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})},link:e=>{let{children:t}=e;return(0,td.jsx)(td.Fragment,{children:t})}},types:{mention:e=>{var t;return(0,td.jsx)(MentionInlineBlock,{userId:null==(t=null==e?void 0:e.value)?void 0:t.userId,selected:!1})}}};function CommentMessageSerializer(e){let{blocks:t}=e;return(0,td.jsx)(rh,{children:(0,td.jsx)(t6.YI,{value:t||rm,components:rf})})}let rg=(0,tu.Z2)({name:"mention",type:"object",fields:[{name:"userId",type:"string"}]}),rx=(0,tu.Z2)({type:"block",name:"block",of:[rg],marks:{annotations:[]},styles:[{title:"Normal",value:"normal"}],lists:[]}),rb=(0,tu.qu)({type:"array",name:"body",of:[rx]}),rv=t4.V.compile({name:"comments",types:[rb]}),r_=rv.get("body"),ry=(0,ts.forwardRef)(function(e,t){return(0,td.jsx)("svg",{"data-sanity-icon":"send",fill:"none",height:"1em",ref:t,viewBox:"0 0 25 25",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,td.jsx)("path",{clipRule:"evenodd",d:"M21.1602 12.5L7.16016 19.5V14.8765L13.6656 12.4989L7.16016 9.97149L7.16016 5.5L21.1602 12.5Z",stroke:"currentColor",strokeWidth:1.2,strokeLinejoin:"round"})})}),rj=(0,ts.forwardRef)(function(e,t){return(0,td.jsxs)("svg",{"data-sanity-icon":"mention",fill:"none",height:"1em",ref:t,viewBox:"0 0 25 25",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,td.jsx)("path",{d:"M16.6633 18.9383C15.539 19.6562 14.2034 20.0723 12.7705 20.0723C8.77022 20.0723 5.52734 16.8294 5.52734 12.8291C5.52734 8.82881 8.77022 5.58594 12.7705 5.58594C16.7708 5.58594 20.0137 8.82881 20.0137 12.8291C20.0137 13.6623 19.8249 14.7093 19.6141 15.2077C19.5578 15.3408 19.479 15.4845 19.3936 15.6238C19.0955 16.1106 18.5507 16.3721 17.9807 16.4018V16.4018C16.8271 16.462 15.8588 15.5428 15.8588 14.3877V9.27302",stroke:"currentColor",strokeWidth:1.2,strokeLinejoin:"round"}),(0,td.jsx)("circle",{cx:"12.5732",cy:"12.8291",r:"3.08691",stroke:"currentColor",strokeWidth:1.2})]})}),rw=(0,ts.forwardRef)(function(e,t){return(0,td.jsxs)("svg",{"data-sanity-icon":"add-comment",fill:"none",height:"1em",ref:t,viewBox:"0 0 25 25",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,td.jsx)("path",{d:"M12.3368 5.97917H6.89453C5.78996 5.97917 4.89453 6.8746 4.89453 7.97917V13.4881C4.89453 14.5926 5.78996 15.4881 6.89453 15.4881H8.69808V19.2916L12.5016 15.4881H16.207C17.3115 15.4881 18.207 14.5926 18.207 13.4881V11.7158",stroke:"currentColor",strokeWidth:1.2,strokeLinejoin:"round"}),(0,td.jsx)("path",{d:"M18.2081 2.08333V9.87058M14.3145 5.97695H22.1017",stroke:"currentColor",strokeWidth:1.2,strokeLinejoin:"round"})]})}),rk=(0,ts.forwardRef)(function(e,t){return(0,td.jsx)("svg",{"data-sanity-icon":"comment",width:"1em",height:"1em",ref:t,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,td.jsx)("path",{d:"M7.5 15.5H9.5V19.5L13.5 15.5H17.5C18.6046 15.5 19.5 14.6046 19.5 13.5V7.5C19.5 6.39543 18.6046 5.5 17.5 5.5H7.5C6.39543 5.5 5.5 6.39543 5.5 7.5V13.5C5.5 14.6046 6.39543 15.5 7.5 15.5Z",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"1.2"})})});function useCommentHasChanged(e){let t=(0,ts.useRef)(e);return(0,ts.useMemo)(()=>!t7()(t.current,e),[e])}function hasCommentMessageValue(e){return!!e&&(null==e?void 0:e.some(e=>{var t;return(0,tu.DG)(e)&&(null==(t=(null==e?void 0:e.children)||[])?void 0:t.some(e=>
1(0,tu.NG)(e)?e.text:e.userId))}))}let rC=ts.createContext(null);function CommentInputProvider(e){let{children:t,expandOnFocus:n=!1,focused:i,focusOnMount:r=!1,mentionOptions:l,onMentionMenuOpenChange:a,value:o,readOnly:s}=e,d=(0,t8._F)(),[c,u]=(0,ts.useState)(!1),[p,h]=(0,ts.useState)(""),[m,f]=(0,ts.useState)(null),g=(0,ts.useMemo)(()=>hasCommentMessageValue(o),[o]),x=useCommentHasChanged(o),b=(0,ts.useCallback)(()=>{s||t8.q$.focus(d)},[d,s]),v=(0,ts.useCallback)(()=>{u(!1),h(""),f(null)},[]),_=(0,ts.useCallback)(()=>{u(!0),h(""),u(!0),f(t8.q$.getSelection(d))},[d]),y=(0,ts.useCallback)(e=>{let t=t8.q$.getSelection(d),n=t?t.focus.offset:0,i=t8.q$.focusChild(d),r=(0,tu.NG)(i)&&i||void 0,l="insertText"===e.inputType,a="deleteContentBackward"===e.inputType,o=l&&"@"===e.data,s=(null==r?void 0:r.text.substring(0,n).lastIndexOf("@"))||0,c=(null==r?void 0:r.text.substring(n-1,n))===" ",u=l&&" "===e.data&&!p;if(o&&(n<1||c)){_();return}if(u||a&&((null==r?void 0:r.text.length)===1||s===((null==r?void 0:r.text.length)||0)-1)){v();return}if((0,tu.NG)(i)){let t=i.text.substring(s+1,n);l&&(t+=e.data),a&&(t=t.substring(0,t.length-1)),h(t)}},[v,d,p,_]),j=(0,ts.useCallback)(()=>{u(!0),t8.q$.focus(d),t8.q$.insertChild(d,d.schemaTypes.span,{text:"@"}),f(t8.q$.getSelection(d))},[d]);(0,tc.lRb)(c,()=>null==a?void 0:a(c));let w=(0,ts.useCallback)(e=>{var t;let n=d.schemaTypes.inlineObjects.find(e=>"mention"===e.name),[i,r]=m&&t8.q$.findByPath(d,m.focus.path)||[];if(i&&(0,tu.NG)(i)&&r&&n){t8.q$.focus(d);let l=null==(t=t8.q$.getSelection(d))?void 0:t.focus.offset;void 0!==l&&(t8.q$.delete(d,{anchor:{path:r,offset:i.text.lastIndexOf("@")},focus:{path:r,offset:l}},{mode:"selected"}),t8.q$.insertChild(d,n,{userId:e}),t8.q$.insertChild(d,d.schemaTypes.span,{text:" "}))}},[d,m]),k=(0,ts.useMemo)(()=>({canSubmit:g,closeMentions:v,editor:d,expandOnFocus:n,focused:i,focusEditor:b,focusOnMount:r,hasChanges:x,insertAtChar:j,insertMention:w,mentionOptions:l,mentionsMenuOpen:c,mentionsSearchTerm:p,onBeforeInput:y,openMentions:_,readOnly:!!s,value:o}),[g,v,d,n,i,b,r,x,j,w,l,c,p,y,_,s,o]);return(0,td.jsx)(rC.Provider,{value:k,children:t})}function useCommentInput(){let e=(0,ts.useContext)(rC);if(!e)throw Error("useCommentInputContext must be used within a CommentInputProvider");return e}var rI=Object.freeze,rS=Object.defineProperty;let rz=(0,th.ZP)(tp.kC)(er||(er=rI(rS(f=[""],"raw",{value:rI(f.slice())})))),rP={width:"50%"};function MentionsMenuItem(e){let{user:t,onSelect:n}=e,[i]=(0,tc.aFb)(t.id),r=(0,td.jsx)(CommentsAvatar,{user:i,status:t.canBeMentioned?void 0:"inactive"}),l=i?(0,td.jsx)(tp.xv,{size:1,textOverflow:"ellipsis",title:i.displayName,children:i.displayName}):(0,td.jsx)(tp.Qr,{size:1,style:rP}),a=(0,ts.useCallback)(()=>{n(t.id)},[n,t.id]);return(0,td.jsx)(tp.Zb,{as:"button",disabled:!t.canBeMentioned,onClick:a,padding:2,radius:2,children:(0,td.jsxs)(tp.kC,{align:"center",gap:3,children:[(0,td.jsxs)(rz,{align:"center",gap:2,flex:1,children:[r,(0,td.jsx)(tp.xu,{children:l})]}),!t.canBeMentioned&&(0,td.jsx)(tp.Ct,{fontSize:1,mode:"outline",children:"Unauthorized"})]})})}let rE=[],rD=(0,th.ZP)(tp.Kq)({maxWidth:"220px"}),rT=(0,th.ZP)(tp.kC)({maxHeight:315.5}),rM=ts.forwardRef(function(e,t){let{loading:n,onSelect:i,options:r=[],inputElement:l}=e,[a,o]=(0,ts.useState)(""),s=(0,ts.useRef)(null);(0,ts.useImperativeHandle)(t,()=>({setSearchTerm(e){o(e)}}),[]);let d=(0,ts.useCallback)(e=>(0,td.jsx)(MentionsMenuItem,{user:e,onSelect:i}),[i]),c=(0,ts.useCallback)(e=>{var t;return!(null==(t=null==r?void 0:r[e])?void 0:t.canBeMentioned)},[r]),u=(0,ts.useMemo)(()=>{var e;if(!a)return r||rE;let t=nt()(a).toLocaleLowerCase(),n=null==r?void 0:r.map(e=>({...e,displayName:nt()(e.displayName||"").toLocaleLowerCase()})),i=null==(e=null==n?void 0:n.filter(e=>{var n;return null==(n=null==e?void 0:e.displayName)?void 0:n.includes(t)}))?void 0:e.sort((e,n)=>{var i,r;let l=null==(i=e.displayName)?void 0:i.startsWith(t),a=null==(r=n.displayName)?void 0:r.startsWith(t);return l&&!a?-1:!l&&a?1:0});return i||rE},[r,a]);return n?(0,td.jsx)(rD,{children:(0,td.jsx)(tp.kC,{align:"center",justify:"center",padding:4,children:(0,td.jsx)(tp.$j,{muted:!0,size:1})})}):(0,td.jsxs)(tp.kC,{direction:"column",height:"fill","data-testid":"comments-mentions-menu",children:[0===u.length&&(0,td.jsx)(tp.xu,{padding:5,children:(0,td.jsx)(tp.xv,{align:"center",size:1,muted:!0,children:"No users found"})}),u.length>0&&(0,td.jsx)(rT,{direction:"column",flex:1,overflow:"hidden",children:(0,td.jsx)(tc.e8h,{activeItemDataAttr:"data-hovered",ariaLabel:"List of users to mention",fixedHeight:!0,getItemDisabled:c,inputElement:l||void 0,itemHeight:41,items:u,padding:1,ref:s,renderItem:d})})]})}),renderBlock=e=>{let{children:t}=e;return(0,td.jsx)(NormalBlock,{children:t})},renderChild=e=>{let{children:t,value:n,selected:i}=e,r="mention"===n._type&&n.userId;return r?(0,td.jsx)(MentionInlineBlock,{selected:i,userId:null==n?void 0:n.userId}):t},rR={passive:!0};var rA=Object.freeze,rO=Object.defineProperty,__template$v=(e,t)=>
1rA(rO(e,"raw",{value:rA(t||e.slice())}));let rL=["bottom","top"],rB={outline:"none"},rN=[],r$=th.ZP.span(()=>(0,th.iv)(el||(el=__template$v(["\n overflow: hidden;\n text-overflow: ellipsis;\n text-wrap: nowrap;\n display: block;\n "])))),rZ=(0,th.ZP)(tp.J2)(e=>{let{theme:t}=e,{space:n,radius:i}=t.sanity;return(0,th.iv)(ea||(ea=__template$v(["\n &[data-placement='bottom'] {\n transform: translateY(","px);\n }\n\n &[data-placement='top'] {\n transform: translateY(-","px);\n }\n\n [data-ui='Popover__wrapper'] {\n border-radius: ","px;\n display: flex;\n flex-direction: column;\n overflow: clip;\n overflow: hidden;\n position: relative;\n width: 300px; // todo: improve\n }\n "])),n[1],n[1],i[3])});function Editable(e){let{focusLock:t,placeholder:n="Create a new comment",onFocus:i,onBlur:r,onKeyDown:l,onSubmit:a}=e,[o,s]=(0,ts.useState)(null),d=(0,ts.useRef)(null),c=(0,ts.useRef)(null),u=(0,ts.useRef)(null),p=(0,t8.L9)(),{canSubmit:h,closeMentions:m,insertMention:f,mentionOptions:g,mentionsMenuOpen:x,mentionsSearchTerm:b,onBeforeInput:v,value:_}=useCommentInput(),y=function(e){let{disabled:t,rootElement:n}=e,[i,r]=(0,ts.useState)(null),l=(0,ts.useMemo)(()=>i?{getBoundingClientRect:()=>i}:null,[i]),a=(0,ts.useCallback)(()=>{if(t){r(null);return}let e=window.getSelection();if(!e||!e.isCollapsed||0===e.rangeCount)return;let i=e.getRangeAt(0),l=null==n?void 0:n.contains(i.commonAncestorContainer);if(!l){r(null);return}let a=null==i?void 0:i.getBoundingClientRect();a&&r(a)},[t,n]);return(0,ts.useEffect)(()=>(document.addEventListener("selectionchange",a,rR),()=>{document.removeEventListener("selectionchange",a)}),[a]),l}({disabled:!x,rootElement:d.current}),j=(0,ts.useCallback)(()=>(0,td.jsx)(r$,{children:n}),[n]),w=(0,ts.useCallback)(()=>{x&&m()},[m,x]);(0,tp.O8)(w,[o]);let k=(0,ts.useCallback)(e=>{switch(e.key){case"Enter":if(e.shiftKey)break;if(e.preventDefault(),e.stopPropagation(),x){m();break}a&&h&&a();break;case"Escape":case"ArrowLeft":case"ArrowRight":x&&(e.preventDefault(),e.stopPropagation(),m())}l&&l(e)},[h,m,x,l,a]),C=(0,ts.useMemo)(()=>{if(p)return;let e=(_||rN).slice(-1)[0],t=(0,tu.DG)(e)?e.children.slice(-1)[0]:void 0;if(!t)return;let n={path:[{_key:e._key},"children",{_key:t._key}],offset:(0,tu.NG)(t)?t.text.length:0};return{focus:n,anchor:n}},[_,p]);(0,ts.useEffect)(()=>{var e;null==(e=u.current)||e.setSearchTerm(b)},[b]),(0,ts.useEffect)(()=>{x&&p&&!t7()(p.anchor,p.focus)&&m()},[x,m,p]);let I=(0,td.jsx)(rM,{inputElement:c.current,loading:g.loading,onSelect:f,options:g.data||rN,ref:u});return(0,td.jsxs)("div",{ref:d,children:[(0,td.jsx)(rZ,{arrow:!1,constrainSize:!0,content:I,disabled:!x,fallbackPlacements:rL,open:x,placement:"bottom",ref:s,referenceElement:y}),(0,td.jsx)(t8.iV,{"data-testid":"comment-input-editable","data-ui":"EditableElement",onBeforeInput:v,onBlur:r,onFocus:i,onKeyDown:k,ref:c,renderBlock,renderChild,renderPlaceholder:j,selection:C,style:rB,tabIndex:t?0:void 0})]})}var rU=Object.freeze,rF=Object.defineProperty,__template$u=(e,t)=>rU(rF(e,"raw",{value:rU(t||e.slice())}));let rH=(0,th.ZP)(tp.xu)(eo||(eo=__template$u(["\n max-height: 20vh;\n overflow-y: auto;\n"]))),rV=(0,th.ZP)(tp.R)({height:20,width:1}),rq=(0,th.ZP)(tp.zx).attrs({fontSize:1,padding:2})(es||(es=__template$u(["\n /* border-radius: 50%; */\n"]))),rW=(0,th.ZP)(tp.Zb)(e=>{let{theme:t}=e,n=t.sanity.radius[2];return(0,th.iv)(ed||(ed=__template$u(["\n border-radius: ","px;\n\n &:not([data-expand-on-focus='false'], :focus-within) {\n background: transparent;\n box-shadow: unset;\n }\n\n &[data-focused='true']:focus-within {\n "," {\n min-height: 1em;\n }\n\n box-shadow:\n inset 0 0 0 1px var(--card-border-color),\n 0 0 0 1px var(--card-bg-color),\n 0 0 0 3px var(--card-focus-ring-color);\n }\n\n &:focus-within {\n "," {\n min-height: 1em;\n }\n }\n\n &[data-expand-on-focus='false'] {\n "," {\n min-height: 1em;\n }\n }\n\n &[data-expand-on-focus='true'] {\n [data-ui='CommentInputActions']:not([hidden]) {\n display: none;\n }\n\n &:focus-within {\n [data-ui='CommentInputActions'] {\n display: flex;\n }\n }\n }\n "])),n,rH,rH,rH)});function CommentInputInner(e){let{currentUser:t,focusLock:n,onBlur:i,onFocus:r,onKeyDown:l,onSubmit:a,placeholder:o,withAvatar:s}
1=e,[d]=(0,tc.aFb)(t.id),{canSubmit:c,expandOnFocus:u,focused:p,hasChanges:h,insertAtChar:m,openMentions:f,readOnly:g}=useCommentInput(),x=s?(0,td.jsx)(CommentsAvatar,{user:d}):null,b=(0,ts.useCallback)(e=>{e.stopPropagation(),m(),f()},[m,f]);return(0,td.jsxs)(tp.kC,{align:"flex-start",gap:2,children:[x,(0,td.jsx)(rW,{"data-expand-on-focus":u&&!c?"true":"false","data-focused":p?"true":"false",flex:1,shadow:1,sizing:"border",tone:g?"transparent":"default",children:(0,td.jsxs)(tp.Kq,{children:[(0,td.jsx)(rH,{paddingX:1,paddingY:2,sizing:"border",children:(0,td.jsx)(Editable,{focusLock:n,onBlur:i,onFocus:r,onKeyDown:l,onSubmit:a,placeholder:o})}),(0,td.jsxs)(tp.kC,{align:"center","data-ui":"CommentInputActions",gap:1,justify:"flex-end",padding:1,children:[(0,td.jsx)(rq,{"aria-label":"Mention user","data-testid":"comment-mention-button",disabled:g,icon:rj,mode:"bleed",onClick:b}),(0,td.jsx)(rV,{}),(0,td.jsx)(rq,{"aria-label":"Send comment",disabled:!c||!h||g,icon:ry,mode:h&&c?"default":"bleed",onClick:a,tone:h&&c?"primary":"default"})]})]})})]})}function CommentInputDiscardDialog(e){let{onClose:t,onConfirm:n}=e,i=(0,ts.useCallback)(e=>{e.stopPropagation(),t()},[t]),r=(0,ts.useCallback)(e=>{e.stopPropagation(),n()},[n]);return(0,td.jsx)(tp.eb,{tone:"default",children:(0,td.jsx)(tp.Tu,{zOffset:9999999,children:(0,td.jsx)(tp.Vq,{header:"Discard comment?",id:"discard-comment-dialog",onClose:t,width:0,onClickOutside:t,footer:(0,td.jsxs)(tp.rj,{columns:2,padding:2,gap:2,children:[(0,td.jsx)(tp.zx,{text:"Cancel",mode:"ghost",onClick:i}),(0,td.jsx)(tp.zx,{onClick:r,text:"Discard",tone:"critical"})]}),children:(0,td.jsx)(tp.Kq,{padding:4,children:(0,td.jsx)(tp.xv,{children:"Do you want to discard the comment?"})})})})})}let rG=[],rK={behavior:"smooth",block:"center",inline:"center"},rY=(0,ts.forwardRef)(function(e,t){let{currentUser:n,expandOnFocus:i,focusLock:r=!1,focusOnMount:l,mentionOptions:a,onBlur:o,onChange:s,onDiscardCancel:d,onDiscardConfirm:c,onFocus:u,onKeyDown:p,onMentionMenuOpenChange:h,onSubmit:m,placeholder:f,readOnly:g,value:x=rG,withAvatar:b=!0}=e,[v,_]=(0,ts.useState)(!1),y=(0,ts.useRef)(null),j=(0,ts.useRef)(null),[w,k]=(0,ts.useState)(!1),C=(0,ts.useRef)(null),I=(0,ts.useRef)(null),S=(0,ts.useRef)(null),[z,P]=(0,ts.useState)((0,t8.YH)()),E=(0,ts.useCallback)(()=>{requestAnimationFrame(()=>{y.current&&t8.q$.focus(y.current)})},[]),D=(0,ts.useCallback)(()=>{P((0,t8.YH)())},[]),T=(0,ts.useCallback)(e=>{if("ready"===e.type&&l&&E(),"focus"===e.type&&_(!0),"blur"===e.type&&_(!1),"patch"===e.type&&y.current){let e=t8.q$.getValue(y.current);s(e||rG)}},[l,s,E]),M=(0,ts.useCallback)(()=>{var e;null==(e=j.current)||e.scrollIntoView(rK)},[]),R=(0,ts.useCallback)(()=>{m(),D(),E(),M()},[m,E,D,M]),A=(0,ts.useCallback)(()=>{c(),D()},[c,D]),O=(0,ts.useMemo)(()=>({open:()=>{k(!0)},close:()=>{k(!1),E()}}),[E]);(0,ts.useImperativeHandle)(t,()=>({focus:E,blur(){y.current&&t8.q$.blur(y.current)},scrollTo:M,reset:D,discardDialogController:O}),[O,E,D,M]);let L=(0,ts.useCallback)(e=>{if(!r)return;let t=e.target,n=S.current;if(n&&t===C.current){(0,tp.bg)(n);return}n&&t===I.current&&(0,tp.fo)(n)},[r]);return(0,td.jsxs)(td.Fragment,{children:[w&&(0,td.jsx)(CommentInputDiscardDialog,{onClose:d,onConfirm:A}),(0,td.jsx)(tp.Kq,{ref:j,"data-testid":"comment-input",onFocus:L,children:(0,td.jsx)(t8.q$,{onChange:T,readOnly:g,ref:y,schemaType:r_,value:x||rG,children:(0,td.jsxs)(CommentInputProvider,{expandOnFocus:i,focused:v,focusOnMount:l,mentionOptions:a,onMentionMenuOpenChange:h,readOnly:g,value:x,children:[r&&(0,td.jsx)("div",{ref:C,tabIndex:0}),(0,td.jsx)(tp.Kq,{ref:S,children:(0,td.jsx)(CommentInputInner,{currentUser:n,focusLock:r,onBlur:o,onFocus:u,onKeyDown:p,onSubmit:R,placeholder:f,withAvatar:b})}),r&&(0,td.jsx)("div",{ref:I,tabIndex:0})]})},z)})]})});var rX=Object.freeze,rQ=Object.defineProperty;let rJ={open:500},r0=(0,th.ZP)(tp.xv)(ec||(ec=rX(rQ(g=["\n min-width: max-content;\n"],"raw",{value:rX(g.slice())}))));function TextTooltip(e){let{children:t,text:n}=e;return(0,td.jsx)(tp.u,{delay:rJ,portal:!0,placement:"top",content:(0,td.jsx)(r0,{size:1,children:n}),padding:2,children:(0,td.jsx)(tp.kC,{children:t})})}var r1=Object.freeze,r2=Object.defineProperty,__template$s=(e,t)=>r1(r2(e,"raw",{value:r1(t||e.slice())}));let r5={open:500},r3={placement:"bottom-end"},r6=(0,th.ZP)(tp.Zb)(e=>{let{theme:t}=e,{space:n}=t.sanity;return(0,th.iv)(eu||(eu=__template$s(["\n gap: ","px;\n padding: ","px;
1\n\n &:empty {\n display: none;\n }\n "])),n[1]/2,n[1]/2)});function CommentsListItemContextMenu(e){let{canDelete:t,canEdit:n,isParent:i,onCopyLink:r,onDeleteStart:l,onEditStart:a,onMenuClose:o,onMenuOpen:s,onStatusChange:d,readOnly:c,status:u}=e;return(0,td.jsx)(tp.uE,{delay:r5,children:(0,td.jsx)(tp.kC,{children:(0,td.jsxs)(r6,{display:"flex",shadow:2,padding:1,radius:2,sizing:"border",children:[i&&(0,td.jsx)(TextTooltip,{text:"open"===u?"Mark as resolved":"Re-open",children:(0,td.jsx)(tp.zx,{"aria-label":"Mark comment as resolved",disabled:c,fontSize:1,icon:"open"===u?to.nSX:to.UEU,mode:"bleed",onClick:d,padding:2})}),(0,td.jsx)(tp.j2,{id:"comment-actions-menu",button:(0,td.jsx)(tp.zx,{"aria-label":"Open comment actions menu",disabled:c,fontSize:1,hidden:!(r||l||a),icon:to.zGg,mode:"bleed",padding:2}),onOpen:s,onClose:o,menu:(0,td.jsxs)(tp.v2,{children:[(0,td.jsx)(tp.sN,{fontSize:1,hidden:!n,icon:to.dY8,onClick:a,text:"Edit comment"}),(0,td.jsx)(tp.sN,{fontSize:1,hidden:!t,icon:to.XHJ,onClick:l,text:"Delete comment",tone:"critical"}),(0,td.jsx)(tp.R,{hidden:!t&&!n}),(0,td.jsx)(tp.sN,{fontSize:1,hidden:!r,icon:to.xPt,onClick:r,text:"Copy link to comment"})]}),popover:r3})]})})})}var r8=Object.freeze,r4=Object.defineProperty,__template$r=(e,t)=>r8(r4(e,"raw",{value:r8(t||e.slice())}));let r9=(0,th.ZP)(tp.xu)(ep||(ep=__template$r([""])));function StopPropagationWrap(e){let{children:t,isParent:n}=e,i=(0,ts.useCallback)(e=>{e.stopPropagation()},[]);return(0,td.jsx)(r9,{"data-root-menu":n?"true":"false",onClick:i,children:t})}let r7={width:"50%"},le=(0,th.ZP)(tp.xv)(e=>{let{theme:t}=e,n=t.sanity.color.dark,i=nn.VG.gray[n?200:800].hex;return(0,th.iv)(eh||(eh=__template$r(["\n min-width: max-content;\n --card-fg-color: ",";\n color: var(--card-fg-color);\n "])),i)}),lt=(0,th.ZP)(tp.Kq)(em||(em=__template$r(["\n transition: opacity 200ms ease;\n\n &[data-muted='true'] {\n transition: unset;\n opacity: 0.5;\n }\n"]))),ln=(0,th.ZP)(tp.kC)(ef||(ef=__template$r(["\n min-height: ","px;\n"])),25),li=(0,th.ZP)(tp.Zb)(eg||(eg=__template$r(["\n // Add not on hover\n &:not(:hover) {\n background-color: transparent;\n }\n"]))),lr=(0,th.ZP)(tp.Kq)(e=>{let{theme:t}=e,{space:n}=t.sanity;return(0,th.iv)(ex||(ex=__template$r(["\n position: relative;\n\n // Only show the floating layer on hover when hover is supported.\n // Else, the layer is always visible.\n @media (hover: hover) {\n "," {\n opacity: 0;\n position: absolute;\n right: 0;\n top: 0;\n transform: translate(","px, -","px);\n }\n\n "," {\n &:focus-within {\n opacity: 1;\n }\n }\n\n &:hover {\n "," {\n opacity: 1;\n }\n }\n }\n\n &[data-menu-open='true'] {\n "," {\n opacity: 1;\n }\n }\n "])),r9,n[1],n[1],r9,r9,r9)}),ll={agoSuffix:!0};function CommentsListItemLayout(e){let{canDelete:t,canEdit:n,comment:i,currentUser:r,hasError:l,isParent:a,isRetrying:o,mentionOptions:s,onCopyLink:d,onCreateRetry:c,onDelete:u,onEdit:p,onInputKeyDown:h,onStatusChange:m,readOnly:f}=e,{_createdAt:g,authorId:x,message:b,_id:v,lastEditedAt:_}=i,[y]=(0,tc.aFb)(x),[j,w]=(0,ts.useState)(b),[k,C]=(0,ts.useState)(!1),[I,S]=(0,ts.useState)(null),z=(0,ts.useRef)(b),[P,E]=(0,ts.useState)(!1),D=useCommentHasChanged(j),T=(0,ts.useMemo)(()=>hasCommentMessageValue(j),[j]),M=(0,ts.useRef)(null),R=g?new Date(g):new Date,A=(0,tc.INm)(R,ll),O=(0,ni.Z)(R,"PPPPp"),L=_?(0,ni.Z)(new Date(_),"PPPPp"):null,B=l||o,N=(0,ts.useCallback)(()=>E(!0),[]),$=(0,ts.useCallback)(()=>E(!1),[]),Z=(0,ts.useCallback)(()=>null==d?void 0:d(v),[v,d]),U=(0,ts.useCallback)(e=>{e.stopPropagation(),null==c||c(v)},[v,c]),F=(0,ts.useCallback)(()=>u(v),[v,u]),H=(0,ts.useCallback)(()=>{C(!1),w(z.current)},[]),V=(0,ts.useCallback)(()=>{var e;if(!T||!D){H();return}null==(e=M.current)||e.discardDialogController.open()},[H,D,T]),q=(0,ts.useCallback)(e=>{!e.isDefaultPrevented()&&("Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),V()),h&&h(e))},[h,V]),W=(0,ts.useCallback)(()=>{var e;null==(e=M.current)||e.discardDialogController.close()},[]),G=(0,ts.useCallback)(()=>{var e;null==(e=M.current)||e.discardDialogController.close(),H()},[H]),K=(0,ts.useCallback)(()=>{p(v,{message:j}
1),C(!1)},[v,p,j]),Y=(0,ts.useCallback)(()=>{null==m||m(v,"open"===i.status?"resolved":"open")},[v,i.status,m]),X=(0,ts.useCallback)(()=>{C(e=>!e)},[]),Q=(0,ts.useCallback)(()=>E(!1),[]),J=(0,ts.useCallback)(()=>{D||H()},[H,D]),ee=(0,ts.useCallback)(e=>{"Escape"!==e.key||D||H()},[H,D]);(0,tc.lRb)(k,Q),(0,tp.O8)(J,[I]);let et=(null==y?void 0:y.displayName)?(0,td.jsx)(tp.xv,{size:1,weight:"semibold",textOverflow:"ellipsis",title:y.displayName,children:y.displayName}):(0,td.jsx)(tp.Qr,{size:1,style:r7});return(0,td.jsxs)(lr,{"data-menu-open":P?"true":"false",onKeyDown:ee,ref:S,space:4,children:[(0,td.jsxs)(lt,{space:1,"data-muted":B,children:[(0,td.jsxs)(tp.kC,{align:"center",gap:3,flex:1,children:[(0,td.jsx)(CommentsAvatar,{user:y}),(0,td.jsx)(tp.kC,{align:"center",paddingBottom:1,sizing:"border",flex:1,children:(0,td.jsxs)(tp.kC,{align:"flex-end",gap:2,children:[(0,td.jsx)(tp.xu,{flex:1,children:et}),!B&&(0,td.jsxs)(tp.kC,{align:"center",gap:1,children:[(0,td.jsx)(le,{muted:!0,size:0,title:O,children:A}),L&&(0,td.jsx)(le,{muted:!0,size:0,title:L,children:"(edited)"})]})]})}),!k&&!B&&(0,td.jsx)(StopPropagationWrap,{isParent:a,children:(0,td.jsx)(CommentsListItemContextMenu,{canDelete:t,canEdit:n,isParent:a,onCopyLink:Z,onDeleteStart:F,onEditStart:X,onMenuClose:$,onMenuOpen:N,onStatusChange:Y,readOnly:f,status:i.status})})]}),k&&(0,td.jsxs)(tp.kC,{align:"flex-start",gap:2,children:[(0,td.jsx)(SpacerAvatar,{}),(0,td.jsx)(tp.Kq,{flex:1,children:(0,td.jsx)(rY,{currentUser:r,focusOnMount:!0,mentionOptions:s,onChange:w,onDiscardCancel:W,onDiscardConfirm:G,onKeyDown:q,onSubmit:K,readOnly:f,ref:M,value:j,withAvatar:!1})})]}),!k&&(0,td.jsxs)(tp.kC,{gap:3,children:[(0,td.jsx)(SpacerAvatar,{}),(0,td.jsx)(CommentMessageSerializer,{blocks:b})]})]}),B&&(0,td.jsxs)(ln,{gap:3,children:[(0,td.jsx)(SpacerAvatar,{}),(0,td.jsxs)(tp.kC,{align:"center",gap:1,flex:1,children:[(0,td.jsxs)(tp.xv,{muted:!0,size:1,children:[l&&"Failed to send.",o&&"Posting..."]}),(0,td.jsx)(tp.kC,{hidden:o,children:(0,td.jsx)(li,{__unstable_focusRing:!0,display:"flex",forwardedAs:"button",onClick:U,padding:1,radius:2,tone:"primary",children:(0,td.jsx)(tp.xv,{size:1,muted:!0,children:"Retry"})})})]})]})]})}var la=Object.freeze,lo=Object.defineProperty;let ls=(0,th.ZP)(tp.Zb).attrs(e=>{let{tone:t}=e;return{padding:3,radius:3,sizing:"border",tone:t||"transparent"}})(eb||(eb=la(lo(x=["\n // ...\n"],"raw",{value:la(x.slice())}))));var ld=Object.freeze,lc=Object.defineProperty,__template$p=(e,t)=>ld(lc(e,"raw",{value:ld(t||e.slice())}));let lu=[],lp=(0,th.ZP)(ls)(e=>{let{theme:t}=e,{hovered:n}=t.sanity.color.button.bleed.default;return(0,th.iv)(ev||(ev=__template$p(["\n position: relative;\n\n &:has(> [data-ui='GhostButton']:focus:focus-visible) {\n box-shadow:\n inset 0 0 0 1px var(--card-border-color),\n 0 0 0 1px var(--card-bg-color),\n 0 0 0 3px var(--card-focus-ring-color);\n }\n\n // When the comment is not selected, we want to apply hover styles.\n // The hover styles is managed with the [data-hovered] attribute instead of the :hover pseudo class\n // since we want to show the hover styles when hovering over the menu items in the context menu as well.\n // The context menu is rendered using a portal, so the :hover pseudo class won't work when hovering over\n // the menu items.\n &:not([data-active='true']) {\n @media (hover: hover) {\n &[data-hovered='true'] {\n --card-bg-color: ",";\n\n [data-root-menu='true'] {\n opacity: 1;\n }\n }\n }\n }\n "])),n.bg2)}),lh=(0,th.ZP)(tp.zx)(e=>{let{theme:t}=e,{medium:n}=t.sanity.fonts.text.weights;return(0,th.iv)(e_||(e_=__template$p(["\n font-weight: ",";\n "])),n)}),lm=(0,th.ZP)(tp.zx)(ey||(ey=__template$p(["\n opacity: 0;\n position: absolute;\n right: 0;\n top: 0;\n bottom: 0;\n left: 0;\n"]))),lf=ts.memo(function(e){var t,n;let{canReply:i,currentUser:r,isSelected:l,mentionOptions:a,onCopyLink:o,onCreateRetry:s,onDelete:d,onEdit:c,onKeyDown:u,onPathSelect:p,onReply:h,onStatusChange:m,parentComment:f,readOnly:g,replies:x=lu}=e,[b,v]=(0,ts.useState)(lu),[_,y]=(0,ts.useState)(!0),j=(0,ts.useRef)(!1),w=(0,ts.useRef)(null),k=(0,ts.useMemo)(()=>hasCommentMessageValue(b),[b]),[C,I]=(0,ts.useState)(!1),S=(0,ts.useCallback)(()=>I(!0),[]),z=(0,ts.useCallback)(()=>I(!1),[]),P=(0,ts.useCallback)(()=>{let e={fieldPath:f.target.path.field,message:b,parentCommentId:f._id,status:(null==f?void 0:f.status)||"open",threadId:f.threadId};null==h||h(e),v(lu)},[h,f._id,null==f?void 0:f.status,f.target.path.field,f.threadId,b]),E=(0,ts.useCallback)(()=>{var e;if(!k){v(lu);return}null==(e=w.current)||e.discardDialogController.open()},[k]),D=(0,ts.useCallback)(e=>{e.isDefaultPrevented()||"Escape"!==e.key||(e.preventDefault(),e.stopPropagation(),E())},[E]),T=(0,ts.useCallback)(()=>{var e;null==(e=w.current)||e.discardDialogController.close()},[]),M=(0,ts.useCallback)(()=>{var e,t;v(lu),null==(e=w.current)||e.discardDialogController.close(),null==(t=w.current)||t.focu
1s()},[]),R=(0,ts.useCallback)(e=>{e.stopPropagation(),null==p||p({fieldPath:f.target.path.field,origin:"inspector",threadId:f.threadId})},[p,f.target.path.field,f.threadId]),A=(0,ts.useCallback)(e=>{e.stopPropagation(),y(!1),j.current=!0},[]),O=(0,ts.useMemo)(()=>_?null==x?void 0:x.slice(-5):x,[x,_]),L=(0,ts.useMemo)(()=>!!x&&x.length>5,[x]),B=(0,ts.useMemo)(()=>"".concat((null==x?void 0:x.length)-5," more ").concat((null==x?void 0:x.length)-5==1?"comment":"comments"),[null==x?void 0:x.length]);(0,ts.useEffect)(()=>{x.length>5&&!j.current&&y(!0)},[x]);let N=(0,ts.useMemo)(()=>O.map(e=>{var t,n;return(0,td.jsx)(tp.Kq,{as:"li","data-comment-id":e._id,children:(0,td.jsx)(CommentsListItemLayout,{canDelete:e.authorId===r.id,canEdit:e.authorId===r.id,comment:e,currentUser:r,hasError:(null==(t=e._state)?void 0:t.type)==="createError",isRetrying:(null==(n=e._state)?void 0:n.type)==="createRetrying",mentionOptions:a,onInputKeyDown:D,onCopyLink:o,onCreateRetry:s,onDelete:d,onEdit:c,readOnly:g})},e._id)}),[r,D,a,o,s,d,c,g,O]);return(0,td.jsx)(tp.Kq,{space:2,children:(0,td.jsxs)(lp,{"data-active":l?"true":"false","data-hovered":C?"true":"false",onClick:R,onMouseEnter:S,onMouseLeave:z,tone:l?"primary":void 0,children:[(0,td.jsx)(lm,{"data-ui":"GhostButton","aria-label":"Go to field"}),(0,td.jsxs)(tp.Kq,{as:"ul",paddingBottom:i?void 0:1,space:4,children:[(0,td.jsx)(tp.Kq,{as:"li","data-comment-id":f._id,children:(0,td.jsx)(CommentsListItemLayout,{canDelete:f.authorId===r.id,canEdit:f.authorId===r.id,comment:f,currentUser:r,hasError:(null==(t=f._state)?void 0:t.type)==="createError",isParent:!0,isRetrying:(null==(n=f._state)?void 0:n.type)==="createRetrying",mentionOptions:a,onCopyLink:o,onCreateRetry:s,onDelete:d,onEdit:c,onInputKeyDown:u,onStatusChange:m,readOnly:g})}),L&&!j.current&&(0,td.jsxs)(tp.kC,{gap:1,paddingY:1,sizing:"border",children:[(0,td.jsx)(SpacerAvatar,{}),(0,td.jsx)(lh,{fontSize:1,iconRight:to.v4q,mode:"bleed",onClick:A,padding:2,space:2,text:B})]}),N,i&&(0,td.jsx)(rY,{currentUser:r,expandOnFocus:!0,mentionOptions:a,onChange:v,onDiscardCancel:T,onDiscardConfirm:M,onKeyDown:D,onSubmit:P,placeholder:"Reply",readOnly:g,ref:w,value:b})]})]})})}),lg={close:0,open:500},lx=(0,td.jsx)(tp.xv,{muted:!0,children:(0,td.jsx)(to.XCv,{})}),renderItem=(e,t)=>(0,td.jsx)(tp.xu,{as:"li",children:(0,td.jsx)(tp.xv,{textOverflow:"ellipsis",size:1,weight:"semibold",children:e})},"".concat(e,"-").concat(t));function CommentBreadcrumbs(e){let{titlePath:t,maxLength:n}=e,i=(0,ts.useMemo)(()=>{let e=t.length,i=Math.ceil(n/2),r=Math.floor(n/2);return n&&e>n?[...t.slice(0,i-1),t.slice(i-1,e-r),...t.slice(e-r)]:t},[n,t]),r=(0,ts.useMemo)(()=>i.map((e,t)=>{let n="".concat(e,"-").concat(t),r=t<i.length-1;return Array.isArray(e)?(0,td.jsxs)(ts.Fragment,{children:[(0,td.jsx)(tp.u,{delay:lg,content:(0,td.jsx)(tp.Kq,{space:2,padding:2,children:e.map(renderItem)}),children:(0,td.jsx)(tp.xu,{children:renderItem("...",t)})}),r&&lx]},n):(0,td.jsxs)(ts.Fragment,{children:[renderItem(e,t),r&&lx]},n)}),[i]);return(0,td.jsx)(tp.kC,{align:"center",as:"ol",gap:2,children:r})}/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function zero$1(e){let t=e.length;for(;--t>=0;)e[t]=0}let lb=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),lv=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),l_=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ly=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lj=Array(576);zero$1(lj);let lw=Array(60);zero$1(lw);let lk=Array(512);zero$1(lk);let lC=Array(256);zero$1(lC);let lI=Array(29);zero$1(lI);let lS=Array(30);function StaticTreeDesc(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}function TreeDesc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}zero$1(lS);let d_code=e=>e<256?lk[e]:lk[256+(e>>>7)],put_short=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},send_bits=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,put_short(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},send_code=(e,t,n)=>{send_bits(e,n[2*t],n[2*t+1])},bi_reverse=(e,t)=>{let n=0;do n|=1&e,e>>>=1,n<<=1;while(--t>0);return n>>>1},bi_flush=e=>{16===e.bi_valid?(put_short(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)},gen_bitlen=(e,t)=>{let n,i,r,l,a,o;
1let s=t.dyn_tree,d=t.max_code,c=t.stat_desc.static_tree,u=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,m=t.stat_desc.max_length,f=0;for(l=0;l<=15;l++)e.bl_count[l]=0;for(s[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(l=s[2*s[2*(i=e.heap[n])+1]+1]+1)>m&&(l=m,f++),s[2*i+1]=l,!(i>d)&&(e.bl_count[l]++,a=0,i>=h&&(a=p[i-h]),o=s[2*i],e.opt_len+=o*(l+a),u&&(e.static_len+=o*(c[2*i+1]+a)));if(0!==f){do{for(l=m-1;0===e.bl_count[l];)l--;e.bl_count[l]--,e.bl_count[l+1]+=2,e.bl_count[m]--,f-=2}while(f>0);for(l=m;0!==l;l--)for(i=e.bl_count[l];0!==i;)!((r=e.heap[--n])>d)&&(s[2*r+1]!==l&&(e.opt_len+=(l-s[2*r+1])*s[2*r],s[2*r+1]=l),i--)}},gen_codes=(e,t,n)=>{let i,r;let l=Array(16),a=0;for(i=1;i<=15;i++)a=a+n[i-1]<<1,l[i]=a;for(r=0;r<=t;r++){let t=e[2*r+1];0!==t&&(e[2*r]=bi_reverse(l[t]++,t))}},tr_static_init=()=>{let e,t,n,i,o;let s=Array(16);for(i=0,n=0;i<28;i++)for(e=0,lI[i]=n;e<1<<lb[i];e++)lC[n++]=i;for(lC[n-1]=i,o=0,i=0;i<16;i++)for(e=0,lS[i]=o;e<1<<lv[i];e++)lk[o++]=i;for(o>>=7;i<30;i++)for(e=0,lS[i]=o<<7;e<1<<lv[i]-7;e++)lk[256+o++]=i;for(t=0;t<=15;t++)s[t]=0;for(e=0;e<=143;)lj[2*e+1]=8,e++,s[8]++;for(;e<=255;)lj[2*e+1]=9,e++,s[9]++;for(;e<=279;)lj[2*e+1]=7,e++,s[7]++;for(;e<=287;)lj[2*e+1]=8,e++,s[8]++;for(gen_codes(lj,287,s),e=0;e<30;e++)lw[2*e+1]=5,lw[2*e]=bi_reverse(e,5);r=new StaticTreeDesc(lj,lb,257,286,15),l=new StaticTreeDesc(lw,lv,0,30,15),a=new StaticTreeDesc([],l_,0,19,7)},init_block=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},bi_windup=e=>{e.bi_valid>8?put_short(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},smaller=(e,t,n,i)=>{let r=2*t,l=2*n;return e[r]<e[l]||e[r]===e[l]&&i[t]<=i[n]},pqdownheap=(e,t,n)=>{let i=e.heap[n],r=n<<1;for(;r<=e.heap_len&&(r<e.heap_len&&smaller(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!smaller(t,i,e.heap[r],e.depth));)e.heap[n]=e.heap[r],n=r,r<<=1;e.heap[n]=i},compress_block=(e,t,n)=>{let i,r,l,a;let o=0;
1if(0!==e.sym_next)do i=(255&e.pending_buf[e.sym_buf+o++])+((255&e.pending_buf[e.sym_buf+o++])<<8),r=e.pending_buf[e.sym_buf+o++],0===i?send_code(e,r,t):(send_code(e,(l=lC[r])+256+1,t),0!==(a=lb[l])&&send_bits(e,r-=lI[l],a),send_code(e,l=d_code(--i),n),0!==(a=lv[l])&&send_bits(e,i-=lS[l],a));while(o<e.sym_next);send_code(e,256,t)},build_tree=(e,t)=>{let n,i,r;let l=t.dyn_tree,a=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.elems,d=-1;for(n=0,e.heap_len=0,e.heap_max=573;n<s;n++)0!==l[2*n]?(e.heap[++e.heap_len]=d=n,e.depth[n]=0):l[2*n+1]=0;for(;e.heap_len<2;)l[2*(r=e.heap[++e.heap_len]=d<2?++d:0)]=1,e.depth[r]=0,e.opt_len--,o&&(e.static_len-=a[2*r+1]);for(t.max_code=d,n=e.heap_len>>1;n>=1;n--)pqdownheap(e,l,n);r=s;do n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pqdownheap(e,l,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,l[2*r]=l[2*n]+l[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,l[2*n+1]=l[2*i+1]=r,e.heap[1]=r++,pqdownheap(e,l,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],gen_bitlen(e,t),gen_codes(l,d,e.bl_count)},scan_tree=(e,t,n)=>{let i,r;let l=-1,a=t[1],o=0,s=7,d=4;for(0===a&&(s=138,d=3),t[(n+1)*2+1]=65535,i=0;i<=n;i++)r=a,a=t[(i+1)*2+1],++o<s&&r===a||(o<d?e.bl_tree[2*r]+=o:0!==r?(r!==l&&e.bl_tree[2*r]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,l=r,0===a?(s=138,d=3):r===a?(s=6,d=3):(s=7,d=4))},send_tree=(e,t,n)=>{let i,r;let l=-1,a=t[1],o=0,s=7,d=4;for(0===a&&(s=138,d=3),i=0;i<=n;i++)if(r=a,a=t[(i+1)*2+1],!(++o<s)||r!==a){if(o<d)do send_code(e,r,e.bl_tree);while(0!=--o);else 0!==r?(r!==l&&(send_code(e,r,e.bl_tree),o--),send_code(e,16,e.bl_tree),send_bits(e,o-3,2)):o<=10?(send_code(e,17,e.bl_tree),send_bits(e,o-3,3)):(send_code(e,18,e.bl_tree),send_bits(e,o-11,7));o=0,l=r,0===a?(s=138,d=3):r===a?(s=6,d=3):(s=7,d=4)}},build_bl_tree=e=>{let t;for(scan_tree(e,e.dyn_ltree,e.l_desc.max_code),scan_tree(e,e.dyn_dtree,e.d_desc.max_code),build_tree(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ly[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t},send_all_trees=(e,t,n,i)=>{let r;for(send_bits(e,t-257,5),send_bits(e,n-1,5),send_bits(e,i-4,4),r=0;r<i;r++)send_bits(e,e.bl_tree[2*ly[r]+1],3);send_tree(e,e.dyn_ltree,t-1),send_tree(e,e.dyn_dtree,n-1)},detect_data_type=e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0},lz=!1,_tr_stored_block$1=(e,t,n,i)=>{send_bits(e,0+(i?1:0),3),bi_windup(e),put_short(e,n),put_short(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var lP={_tr_init:e=>{lz||(tr_static_init(),lz=!0),e.l_desc=new TreeDesc(e.dyn_ltree,r),e.d_desc=new TreeDesc(e.dyn_dtree,l),e.bl_desc=new TreeDesc(e.bl_tree,a),e.bi_buf=0,e.bi_valid=0,init_block(e)},_tr_stored_block:_tr_stored_block$1,_tr_flush_block:(e,t,n,i)=>{let r,l;let a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=detect_data_type(e)),build_tree(e,e.l_desc),build_tree(e,e.d_desc),a=build_bl_tree(e),r=e.opt_len+3+7>>>3,(l=e.static_len+3+7>>>3)<=r&&(r=l)):r=l=n+5,n+4<=r&&-1!==t?_tr_stored_block$1(e,t,n,i):4===e.strategy||l===r?(send_bits(e,2+(i?1:0),3),compress_block(e,lj,lw)):(send_bits(e,4+(i?1:0),3),send_all_trees(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),compress_block(e,e.dyn_ltree,e.dyn_dtree)),init_block(e),i&&bi_windup(e)},_tr_tally:(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[(lC[n]+256+1)*2]++,e.dyn_dtree[2*d_code(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{send_bits(e,2,3),send_code(e,256,lj),bi_flush(e)}},adler32_1=(e,t,n,i)=>{let r=65535&e|0,l=e>>>16&65535|0,a=0;for(;0!==n;){a=n>2e3?2e3:n,n-=a;do l=l+(r=r+t[i++]|0)|0;while(--a);r%=65521,l%=65521}return r|l<<16|0};let lE=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var crc32_1=(e,t,n,i)=>{let r=i+n;e^=-1;for(let n=i;n<r;n++)e=e>>>8^lE[(e^t[n])&255];return -1^e},lD={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},lT={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ER
1ROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};let{_tr_init:lM,_tr_stored_block:lR,_tr_flush_block:lA,_tr_tally:lO,_tr_align:lL}=lP,{Z_NO_FLUSH:lB,Z_PARTIAL_FLUSH:lN,Z_FULL_FLUSH:l$,Z_FINISH:lZ,Z_BLOCK:lU,Z_OK:lF,Z_STREAM_END:lH,Z_STREAM_ERROR:lV,Z_DATA_ERROR:lq,Z_BUF_ERROR:lW,Z_DEFAULT_COMPRESSION:lG,Z_FILTERED:lK,Z_HUFFMAN_ONLY:lY,Z_RLE:lX,Z_FIXED:lQ,Z_DEFAULT_STRATEGY:lJ,Z_UNKNOWN:l0,Z_DEFLATED:l1}=lT,err=(e,t)=>(e.msg=lD[t],t),rank=e=>2*e-(e>4?9:0),zero=e=>{let t=e.length;for(;--t>=0;)e[t]=0},slide_hash=e=>{let t,n,i;let r=e.w_size;i=t=e.hash_size;do n=e.head[--i],e.head[i]=n>=r?n-r:0;while(--t);i=t=r;do n=e.prev[--i],e.prev[i]=n>=r?n-r:0;while(--t)},HASH=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,flush_pending=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},flush_block_only=(e,t)=>{lA(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,flush_pending(e.strm)},put_byte=(e,t)=>{e.pending_buf[e.pending++]=t},putShortMSB=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},read_buf=(e,t,n,i)=>{let r=e.avail_in;return(r>i&&(r=i),0===r)?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=adler32_1(e.adler,t,r,n):2===e.state.wrap&&(e.adler=crc32_1(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},longest_match=(e,t)=>{let n,i,r=e.max_chain_length,l=e.strstart,a=e.prev_length,o=e.nice_match,s=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,c=e.w_mask,u=e.prev,p=e.strstart+258,h=d[l+a-1],m=d[l+a];e.prev_length>=e.good_match&&(r>>=2),o>e.lookahead&&(o=e.lookahead);do{if(d[(n=t)+a]!==m||d[n+a-1]!==h||d[n]!==d[l]||d[++n]!==d[l+1])continue;l+=2,n++;do;while(d[++l]===d[++n]&&d[++l]===d[++n]&&d[++l]===d[++n]&&d[++l]===d[++n]&&d[++l]===d[++n]&&d[++l]===d[++n]&&d[++l]===d[++n]&&d[++l]===d[++n]&&l<p);if(i=258-(p-l),l=p-258,i>a){if(e.match_start=t,a=i,i>=o)break;h=d[l+a-1],m=d[l+a]}}while((t=u[t&c])>s&&0!=--r);return a<=e.lookahead?a:e.lookahead},fill_window=e=>{let t,n,i;let r=e.w_size;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=r+(r-262)&&(e.window.set(e.window.subarray(r,r+r-n),0),e.match_start-=r,e.strstart-=r,e.block_start-=r,e.insert>e.strstart&&(e.insert=e.strstart),slide_hash(e),n+=r),0===e.strm.avail_in)break;if(t=read_buf(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=t,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=HASH(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=HASH(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},deflate_stored=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i,r,l,a=0,o=e.strm.avail_in;do{if(i=65535,l=e.bi_valid+42>>3,e.strm.avail_out<l||(l=e.strm.avail_out-l,i>(r=e.strstart-e.block_start)+e.strm.avail_in&&(i=r+e.strm.avail_in),i>l&&(i=l),i<n&&(0===i&&t!==lZ||t===lB||i!==r+e.strm.avail_in)))break;a=t===lZ&&i===r+e.strm.avail_in?1:0,lR(e,0,0,a),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,flush_pending(e.strm),r&&(r>i&&(r=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,i-=r),i&&(read_buf(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===a);return((o-=e.strm.avail_in)&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),a)?4:t!==lB&&t!==lZ&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(l=e.window_size-e.strstart,e.strm.avail_in>l&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,l+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),l>e.strm.avail_in&&(l=e.strm.avail_in),l&&(read_buf(e.strm,e.window,e.strstart,l),e.strstart+=l,e.insert+=l>e.w_size-e.insert?e.w_size-e.insert:l),e.high_water<e.strstart&&(e.high_water=e.strstart),l=e.bi_valid+42>>3,n=(l=e.pending_buf_size-l>65535?65535:e.pending_buf_size-l)>
1e.w_size?e.w_size:l,((r=e.strstart-e.block_start)>=n||(r||t===lZ)&&t!==lB&&0===e.strm.avail_in&&r<=l)&&(i=r>l?l:r,a=t===lZ&&0===e.strm.avail_in&&i===r?1:0,lR(e,e.block_start,i,a),e.block_start+=i,flush_pending(e.strm)),a?3:1)},deflate_fast=(e,t)=>{let n,i;for(;;){if(e.lookahead<262){if(fill_window(e),e.lookahead<262&&t===lB)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-262&&(e.match_length=longest_match(e,n)),e.match_length>=3){if(i=lO(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+1])}else i=lO(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}return(e.insert=e.strstart<2?e.strstart:2,t===lZ)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2},deflate_slow=(e,t)=>{let n,i,r;for(;;){if(e.lookahead<262){if(fill_window(e),e.lookahead<262&&t===lB)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-262&&(e.match_length=longest_match(e,n),e.match_length<=5&&(e.strategy===lK||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,i=lO(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((i=lO(e,0,e.window[e.strstart-1]))&&flush_block_only(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return(e.match_available&&(i=lO(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===lZ)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2},deflate_rle=(e,t)=>{let n,i,r,l;let a=e.window;for(;;){if(e.lookahead<=258){if(fill_window(e),e.lookahead<=258&&t===lB)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=a[r=e.strstart-1])===a[++r]&&i===a[++r]&&i===a[++r]){l=e.strstart+258;do;while(i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&r<l);e.match_length=258-(l-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=lO(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=lO(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===lZ)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2},deflate_huff=(e,t)=>{let n;for(;;){if(0===e.lookahead&&(fill_window(e),0===e.lookahead)){if(t===lB)return 1;break}if(e.match_length=0,n=lO(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===lZ)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2};function Config(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}let l2=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)],lm_init=e=>{e.window_size=2*e.w_size,zero(e.head),e.max_lazy_match=l2[e.level].max_lazy,e.good_match=l2[e.level].good_length,e.nice_match=l2[e.level].nice_length,e.max_chain_length=l2[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0};function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=l1,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),zero(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}let deflateStateCheck=e=>{if(!e)return 1;let t=e.state;return t&&t.strm===e&&(42===t.status||57===t.status||69===t.status||73===t.status||91===t.status||103===t.status||113===t.status||666===t.status)?0:1},deflateResetKeep=e=>{if(deflateStateCheck(e))return err(e,lV);e.total_in=e.total_out=0,e.data_type=l0;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=-2,lM(t),lF},deflateReset=e=>{let t=deflateResetKeep(e);return t===lF&&lm_init(e.state),t},deflateInit2=(e,t,n,i,r,l)=>{if(!e)return lV;let a=1;if(t===lG&&(t=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),r<1||r>9||n!==l1||i<8||i>15||t<0||t>9||l<0||l>lQ||8===i&&1!==a)return err(e,lV);8===i&&(i=9);let o=new DeflateState;return e.state=o,o.strm=e,o.status=42,o.wrap=a,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=(o.lit_bufsize-1)*3,o.level=t,o.strategy=l,o.method=n,deflateReset(e)};var l5={deflateInit:(e,t)=>
1deflateInit2(e,t,l1,15,8,lJ),deflateInit2:deflateInit2,deflateReset:deflateReset,deflateResetKeep:deflateResetKeep,deflateSetHeader:(e,t)=>deflateStateCheck(e)||2!==e.state.wrap?lV:(e.state.gzhead=t,lF),deflate:(e,t)=>{if(deflateStateCheck(e)||t>lU||t<0)return e?err(e,lV):lV;let n=e.state;if(!e.output||0!==e.avail_in&&!e.input||666===n.status&&t!==lZ)return err(e,0===e.avail_out?lW:lV);let i=n.last_flush;if(n.last_flush=t,0!==n.pending){if(flush_pending(e),0===e.avail_out)return n.last_flush=-1,lF}else if(0===e.avail_in&&rank(t)<=rank(i)&&t!==lZ)return err(e,lW);if(666===n.status&&0!==e.avail_in)return err(e,lW);if(42===n.status&&0===n.wrap&&(n.status=113),42===n.status){let t=l1+(n.w_bits-8<<4)<<8;if(t|=(n.strategy>=lY||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(t|=32),putShortMSB(n,t+=31-t%31),0!==n.strstart&&(putShortMSB(n,e.adler>>>16),putShortMSB(n,65535&e.adler)),e.adler=1,n.status=113,flush_pending(e),0!==n.pending)return n.last_flush=-1,lF}if(57===n.status){if(e.adler=0,put_byte(n,31),put_byte(n,139),put_byte(n,8),n.gzhead)put_byte(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),put_byte(n,255&n.gzhead.time),put_byte(n,n.gzhead.time>>8&255),put_byte(n,n.gzhead.time>>16&255),put_byte(n,n.gzhead.time>>24&255),put_byte(n,9===n.level?2:n.strategy>=lY||n.level<2?4:0),put_byte(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(put_byte(n,255&n.gzhead.extra.length),put_byte(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=crc32_1(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,9===n.level?2:n.strategy>=lY||n.level<2?4:0),put_byte(n,3),n.status=113,flush_pending(e),0!==n.pending)return n.last_flush=-1,lF}if(69===n.status){if(n.gzhead.extra){let t=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=crc32_1(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=r,flush_pending(e),0!==n.pending)return n.last_flush=-1,lF;t=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>t&&(e.adler=crc32_1(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32_1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),0!==n.pending)return n.last_flush=-1,lF;i=0}t=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,put_byte(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32_1(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32_1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),0!==n.pending)return n.last_flush=-1,lF;i=0}t=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,put_byte(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32_1(e.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(flush_pending(e),0!==n.pending))return n.last_flush=-1,lF;put_byte(n,255&e.adler),put_byte(n,e.adler>>8&255),e.adler=0}if(n.status=113,flush_pending(e),0!==n.pending)return n.last_flush=-1,lF}if(0!==e.avail_in||0!==n.lookahead||t!==lB&&666!==n.status){let i=0===n.level?deflate_stored(n,t):n.strategy===lY?deflate_huff(n,t):n.strategy===lX?deflate_rle(n,t):l2[n.level].func(n,t);if((3===i||4===i)&&(n.status=666),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),lF;if(2===i&&(t===lN?lL(n):t!==lU&&(lR(n,0,0,!1),t===l$&&(zero(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),flush_pending(e),0===e.avail_out))return n.last_flush=-1,lF}return t!==lZ?lF:n.wrap<=0?lH:(2===n.wrap?(put_byte(n,255&e.adler),put_byte(n,e.adler>>8&255),put_byte(n,e.adler>>16&255),put_byte(n,e.adler>>24&255),put_byte(n,255&e.total_in),put_byte(n,e.total_in>>8&255),put_byte(n,e.total_in>>16&255),put_byte(n,e.total_in>>24&255)):(putShortMSB(n,e.adler>>>16),putShortMSB(n,65535&e.adler)),flush_pending(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?lF:lH)},deflateEnd:e=>{if(deflateStateCheck(e))return lV;let t=e.state.status;return e.state=null,113===t?err(e,lq):lF},deflateSetDictionary:(e,t)=>{let n=t.length;if(deflateStateCheck(e))return lV;let i=e.state,r=i.wrap;if(2===r||1===r&&42!==i.status||i.lookahead)return lV;if(1===r&&(e.adler=adler32_1(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(zero(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}let l=e.avail_in,a=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,fill_window(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do i.ins_h=HASH(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++;while(--t);i.strstart=e,i.lookahead=2,fill_window(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=a,e.input=o,e.avail_in=l,i.wrap=r,lF},deflateInfo:"pako deflate (from Nodeca project)"};let _has=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var l3={assign:function(e){let t=Array.prototype.slice.call(arguments,1
1);for(;t.length;){let n=t.shift();if(n){if("object"!=typeof n)throw TypeError(n+"must be non-object");for(let t in n)_has(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,i=e.length;n<i;n++)t+=e[n].length;let n=new Uint8Array(t);for(let t=0,i=0,r=e.length;t<r;t++){let r=e[t];n.set(r,i),i+=r.length}return n}};let l6=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){l6=!1}let l8=new Uint8Array(256);for(let e=0;e<256;e++)l8[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;l8[254]=l8[254]=1;let buf2binstring=(e,t)=>{if(t<65534&&e.subarray&&l6)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n};var l4={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,i,r,l,a=e.length,o=0;for(r=0;r<a;r++)(64512&(n=e.charCodeAt(r)))==55296&&r+1<a&&(64512&(i=e.charCodeAt(r+1)))==56320&&(n=65536+(n-55296<<10)+(i-56320),r++),o+=n<128?1:n<2048?2:n<65536?3:4;for(l=0,t=new Uint8Array(o),r=0;l<o;r++)(64512&(n=e.charCodeAt(r)))==55296&&r+1<a&&(64512&(i=e.charCodeAt(r+1)))==56320&&(n=65536+(n-55296<<10)+(i-56320),r++),n<128?t[l++]=n:(n<2048?t[l++]=192|n>>>6:(n<65536?t[l++]=224|n>>>12:(t[l++]=240|n>>>18,t[l++]=128|n>>>12&63),t[l++]=128|n>>>6&63),t[l++]=128|63&n);return t},buf2string:(e,t)=>{let n,i;let r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let l=Array(2*r);for(i=0,n=0;n<r;){let t=e[n++];if(t<128){l[i++]=t;continue}let a=l8[t];if(a>4){l[i++]=65533,n+=a-1;continue}for(t&=2===a?31:3===a?15:7;a>1&&n<r;)t=t<<6|63&e[n++],a--;if(a>1){l[i++]=65533;continue}t<65536?l[i++]=t:(t-=65536,l[i++]=55296|t>>10&1023,l[i++]=56320|1023&t)}return buf2binstring(l,i)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(192&e[n])==128;)n--;return n<0||0===n?t:n+l8[e[n]]>t?n:t}},zstream=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};let l9=Object.prototype.toString,{Z_NO_FLUSH:l7,Z_SYNC_FLUSH:ae,Z_FULL_FLUSH:at,Z_FINISH:an,Z_OK:ai,Z_STREAM_END:ar,Z_DEFAULT_COMPRESSION:al,Z_DEFAULT_STRATEGY:aa,Z_DEFLATED:ao}=lT;function Deflate$1(e){this.options=l3.assign({level:al,method:ao,chunkSize:16384,windowBits:15,memLevel:8,strategy:aa},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zstream,this.strm.avail_out=0;let n=l5.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ai)throw Error(lD[n]);if(t.header&&l5.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?l4.string2buf(t.dictionary):"[object ArrayBuffer]"===l9.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(n=l5.deflateSetDictionary(this.strm,e))!==ai)throw Error(lD[n]);this._dict_set=!0}}function deflate$1(e,t){let n=new Deflate$1(t);if(n.push(e,!0),n.err)throw n.msg||lD[n.err];return n.result}Deflate$1.prototype.push=function(e,t){let n,i;let r=this.strm,l=this.options.chunkSize;if(this.ended)return!1;for(i=t===~~t?t:!0===t?an:l7,"string"==typeof e?r.input=l4.string2buf(e):"[object ArrayBuffer]"===l9.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(0===r.avail_out&&(r.output=new Uint8Array(l),r.next_out=0,r.avail_out=l),(i===ae||i===at)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if((n=l5.deflate(r,i))===ar)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=l5.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===ai;if(0===r.avail_out){this.onData(r.output);continue}if(i>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(0===r.avail_in)break}return!0},Deflate$1.prototype.onData=function(e){this.chunks.push(e)},Deflate$1.prototype.onEnd=function(e){e===ai&&(this.result=l3.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var inffast=function(e,t){let n,i,r,l,a,o,s,d,c,u,p,h,m,f,g,x,b,v,_,y,j,w,k,C;let I=e.state;n=e.next_in,k=e.input,i=n+(e.avail_in-5),r=e.next_out,C=e.output,l=r-(t-e.avail_out),a=r+(e.avail_out-257),o=I.dmax,s=I.wsize,d=I.whave,c=I.wnext,u=I.window,p=I.hold,h=I.bits,m=I.lencode,f=I.distcode,g=(1<<I.lenbits)-1,x=(1<<I.distbits)-1;e:do for(h<15&&(p+=k[n++]<<h,h+=8,p+=k[n++]<<h,h+=8),b=m[p&g];;){if(p>>>=v=b>>>24,h-=v,0==(v=b>>>16&255))C[r++]=65535&b;else if(16&v)for(_=65535&b,(v&=15)&&(h<v&&(p+=k[n++]<<h,h+=8),_+=p&(1<<v)-1,p>>>=v,h-=v),h<15&&(p+=k[n++]<<h,h+=8,p+=k[n++]<<h,h+=8),b=f[p&x];;){if(p>>>=v=b>>>24,h-=v,16&(v=b>>>16&255)){if(y=65535&b,h<(v&=15)&&(p+=k[n++]<<h,(h+=8)<v&&(p+=k[n++]<<h,h+=8)),(y+=p&(1<<v)-1)>o){e.msg="invalid distance too far back",I.mode=16209;break e}if(p>>>=v,h-=v,y>(v=r-l)){if((v=y-v)>d&&I.sane){e.msg="invalid distance too far back",I.mode=16209;break e}if(j=0,w=u,0===c){if(j+=s-v,v<_){_-=v;do C[r++]=u[j++];while(--v);j=r-y,w=C}}else if(c<v){if(j+=s+c-v,(v-=c)<_){_-=v;do C[r++]=u[j++];while(--v);if(j=0,c<_){_-=v=c;do C[r++]=u[j++];while(--v);j=r-y,w=C}}}else if(j+=c-v,v<_){_-=v;do C[r++]=u[j++];while(--v);j=r-y,w=C}for(;_>2;)C[r++]=w[j++],C[r++]=w[j++],C[r++]=w[j++],_-=3;_&&(C[r++]=w[j++],_>1&&(C[r++]=w[j++]))}else{j=r-y;do C[r++]=C[j++],C[r++]=C[j++],C[r++]=C[j++],_-=3;while(_>2);_&&(C[r++]=C[j++],_>1&&(C[r++]=C[j++]))}}else if((64&v)==0){b=f[(65535&b)+(p&(1<<v)-1)];continue}else{e.msg="invalid distance code",I.mode=16209;break e}break}else if((64&v)==0){b=m[(65535&b)+(p&(1<<v)-1)];continue}else if(32&v){I.mode=16191;break e}else{e.msg="invalid literal/length code",I.mode=16209;break e}break}while(n<i&&r<a);n-=_=h>>3,h-=_<<3,p&=(1<<h)-1,e.next_in=n,e.next_out=r,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=r<a?257+(a-r):257-(r-a),I.hold=p,I.bits=h};let as=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ad=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ac=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),au=new
1Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var inftrees=(e,t,n,i,r,l,a,o)=>{let s,d,c,u,p,h,m,f,g;let x=o.bits,b=0,v=0,_=0,y=0,j=0,w=0,k=0,C=0,I=0,S=0,z=null,P=new Uint16Array(16),E=new Uint16Array(16),D=null;for(b=0;b<=15;b++)P[b]=0;for(v=0;v<i;v++)P[t[n+v]]++;for(y=15,j=x;y>=1&&0===P[y];y--);if(j>y&&(j=y),0===y)return r[l++]=20971520,r[l++]=20971520,o.bits=1,0;for(_=1;_<y&&0===P[_];_++);for(j<_&&(j=_),C=1,b=1;b<=15;b++)if(C<<=1,(C-=P[b])<0)return -1;if(C>0&&(0===e||1!==y))return -1;for(b=1,E[1]=0;b<15;b++)E[b+1]=E[b]+P[b];for(v=0;v<i;v++)0!==t[n+v]&&(a[E[t[n+v]]++]=v);if(0===e?(z=D=a,h=20):1===e?(z=as,D=ad,h=257):(z=ac,D=au,h=0),S=0,v=0,b=_,p=l,w=j,k=0,c=-1,u=(I=1<<j)-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){m=b-k,a[v]+1<h?(f=0,g=a[v]):a[v]>=h?(f=D[a[v]-h],g=z[a[v]-h]):(f=96,g=0),s=1<<b-k,_=d=1<<w;do r[p+(S>>k)+(d-=s)]=m<<24|f<<16|g|0;while(0!==d);for(s=1<<b-1;S&s;)s>>=1;if(0!==s?(S&=s-1,S+=s):S=0,v++,0==--P[b]){if(b===y)break;b=t[n+a[v]]}if(b>j&&(S&u)!==c){for(0===k&&(k=j),p+=_,C=1<<(w=b-k);w+k<y&&!((C-=P[w+k])<=0);)w++,C<<=1;if(I+=1<<w,1===e&&I>852||2===e&&I>592)return 1;r[c=S&u]=j<<24|w<<16|p-l|0}}return 0!==S&&(r[p+S]=b-k<<24|4194304),o.bits=j,0};let{Z_FINISH:ap,Z_BLOCK:ah,Z_TREES:am,Z_OK:af,Z_STREAM_END:ag,Z_NEED_DICT:ax,Z_STREAM_ERROR:ab,Z_DATA_ERROR:av,Z_MEM_ERROR:a_,Z_BUF_ERROR:ay,Z_DEFLATED:aj}=lT,zswap32=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function InflateState(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}let inflateStateCheck=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<16180||t.mode>16211?1:0},inflateResetKeep=e=>{if(inflateStateCheck(e))return ab;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=16180,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,af},inflateReset=e=>{if(inflateStateCheck(e))return ab;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,inflateResetKeep(e)},inflateReset2=(e,t)=>{let n;if(inflateStateCheck(e))return ab;let i=e.state;return(t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15))?ab:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,inflateReset(e))},inflateInit2=(e,t)=>{if(!e)return ab;let n=new InflateState;e.state=n,n.strm=e,n.window=null,n.mode=16180;let i=inflateReset2(e,t);return i!==af&&(e.state=null),i},aw=!0,fixedtables=e=>{if(aw){o=new Int32Array(512),s=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(inftrees(1,e.lens,0,288,o,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inftrees(2,e.lens,0,32,s,0,e.work,{bits:5}),aw=!1}e.lencode=o,e.lenbits=9,e.distcode=s,e.distbits=5},updatewindow=(e,t,n,i)=>{let r;let l=e.state;return null===l.window&&(l.wsize=1<<l.wbits,l.wnext=0,l.whave=0,l.window=new Uint8Array(l.wsize)),i>=l.wsize?(l.window.set(t.subarray(n-l.wsize,n),0),l.wnext=0,l.whave=l.wsize):((r=l.wsize-l.wnext)>i&&(r=i),l.window.set(t.subarray(n-i,n-i+r),l.wnext),(i-=r)?(l.window.set(t.subarray(n-i,n),0),l.wnext=i,l.whave=l.wsize):(l.wnext+=r,l.wnext===l.wsize&&(l.wnext=0),l.whave<l.wsize&&(l.whave+=r))),0};var ak={inflateReset:inflateReset,inflateReset2:inflateReset2,inflateResetKeep:inflateResetKeep,inflateInit:e=>inflateInit2(e,15),inflateInit2:inflateInit2,inflate:(e,t)=>{let n,i,r,l,a,o,s,d,c,u,p,h,m,f,g,x,b,v,_,y,j,w,k,C;let I=0,S=new Uint8Array(4),z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(inflateStateCheck(e)||!e.output||!e.input&&0!==e.avail_in)return ab;16191===(n=e.state).mode&&(n.mode=16192),a=e.next_out,r=e.output,s=e.avail_out,l=e.next_in,i=e.input,o=e.avail_in,d=n.hold,c=n.bits,u=o,p=s,w=af;t:for(;;)switch(n.mode){case 16180:if(0===n.wrap){n.mode=16192;break}for(;c<16;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(2&n.wrap&&35615===d){0===n.wbits&&(n.wbits=15),n.check=0,S[0]=255&d,S[1]=d>>>8&255,n.check=crc32_1(n.check,S,2,0),d=0,c=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",n.mode=16209;break}if((15&d)!==aj){e.msg="unknown compression method",n.mode=16209;break}if(d>>>=4,c-=4,j=(15&d)+8,0===n.wbits&&(n.wbits=j),j>15||j>n.wbits){e.msg="invalid window size",n.mode=16209;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=512&d?16189:16191,d=0,c=0;break;case 16181:for(;c<16;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(n.flags=d,(255&n.flags)!==aj){e.msg="unknown compression method",n.mode=16209;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=16209;break}n.head&&(n.head.text=d>>8&1),512&n.flags&&4&n.wrap&&(S[0]=255&d,S[1]=d>>>8&255,n.check=crc32_1(n.check,S,2,0)),d=0,c=0,n.mode=16182;case 16182:for(;c<32;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}n.head&&(n.head.time=d),512&n.flags&&4&n.wrap&&(S[0]=255&d,S[1]=d>>>8&255,S[2]=d>>>16&255,S[3]=d>>>24&255,n.check=crc32_1(n.check,S,4,0)),d=0,c=0,n.mode=16183;case 16183:for(;c<16;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}n.head&&(n.head.xflags=255&d,n.head.os=d>>8),512&n.flags&&4&n.wrap&&(S[0]=255&d,S[1]=d>>>8&255,n.check=crc32_1(n.check,S,2,0)),d=0,c=0,n.mode=16184;case 16184:if(1024&n.flags){for(;c<16;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}n.length=d,n.head&&(n.head.extra_len=d),512&n.flags&&4&n.wrap&&(S[0]=255&d,S[1]=d>>>8&255,n.check=crc32_1(n.check,S,2,0)),d=0,c=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&((h=n.length)>o&&(h=o),h&&(n.head&&(j=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(l,l+h),j)),512&n.flags&&4&n.wrap&&(n.check=crc32_1(n.check,i,h,l)),o-=
1h,l+=h,n.length-=h),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break t;h=0;do j=i[l+h++],n.head&&j&&n.length<65536&&(n.head.name+=String.fromCharCode(j));while(j&&h<o);if(512&n.flags&&4&n.wrap&&(n.check=crc32_1(n.check,i,h,l)),o-=h,l+=h,j)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===o)break t;h=0;do j=i[l+h++],n.head&&j&&n.length<65536&&(n.head.comment+=String.fromCharCode(j));while(j&&h<o);if(512&n.flags&&4&n.wrap&&(n.check=crc32_1(n.check,i,h,l)),o-=h,l+=h,j)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;c<16;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(4&n.wrap&&d!==(65535&n.check)){e.msg="header crc mismatch",n.mode=16209;break}d=0,c=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=16191;break;case 16189:for(;c<32;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}e.adler=n.check=zswap32(d),d=0,c=0,n.mode=16190;case 16190:if(0===n.havedict)return e.next_out=a,e.avail_out=s,e.next_in=l,e.avail_in=o,n.hold=d,n.bits=c,ax;e.adler=n.check=1,n.mode=16191;case 16191:if(t===ah||t===am)break t;case 16192:if(n.last){d>>>=7&c,c-=7&c,n.mode=16206;break}for(;c<3;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}switch(n.last=1&d,c-=1,3&(d>>>=1)){case 0:n.mode=16193;break;case 1:if(fixedtables(n),n.mode=16199,t===am){d>>>=2,c-=2;break t}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=16209}d>>>=2,c-=2;break;case 16193:for(d>>>=7&c,c-=7&c;c<32;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",n.mode=16209;break}if(n.length=65535&d,d=0,c=0,n.mode=16194,t===am)break t;case 16194:n.mode=16195;case 16195:if(h=n.length){if(h>o&&(h=o),h>s&&(h=s),0===h)break t;r.set(i.subarray(l,l+h),a),o-=h,l+=h,s-=h,a+=h,n.length-=h;break}n.mode=16191;break;case 16196:for(;c<14;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(n.nlen=(31&d)+257,d>>>=5,c-=5,n.ndist=(31&d)+1,d>>>=5,c-=5,n.ncode=(15&d)+4,d>>>=4,c-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=16209;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;c<3;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}n.lens[z[n.have++]]=7&d,d>>>=3,c-=3}for(;n.have<19;)n.lens[z[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,k={bits:n.lenbits},w=inftrees(0,n.lens,0,19,n.lencode,0,n.work,k),n.lenbits=k.bits,w){e.msg="invalid code lengths set",n.mode=16209;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;g=(I=n.lencode[d&(1<<n.lenbits)-1])>>>24,x=I>>>16&255,b=65535&I,!(g<=c);){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(b<16)d>>>=g,c-=g,n.lens[n.have++]=b;else{if(16===b){for(C=g+2;c<C;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(d>>>=g,c-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=16209;break}j=n.lens[n.have-1],h=3+(3&d),d>>>=2,c-=2}else if(17===b){for(C=g+3;c<C;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}d>>>=g,c-=g,j=0,h=3+(7&d),d>>>=3,c-=3}else{for(C=g+7;c<C;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}d>>>=g,c-=g,j=0,h=11+(127&d),d>>>=7,c-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=16209;break}for(;h--;)n.lens[n.have++]=j}}if(16209===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=16209;break}if(n.lenbits=9,k={bits:n.lenbits},w=inftrees(1,n.lens,0,n.nlen,n.lencode,0,n.work,k),n.lenbits=k.bits,w){e.msg="invalid literal/lengths set",n.mode=16209;break}if(n.distbits=6,n.distcode=n.distdyn,k={bits:n.distbits},w=inftrees(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,k),n.distbits=k.bits,w){e.msg="invalid distances set",n.mode=16209;break}if(n.mode=16199,t===am)break t;case 16199:n.mode=16200;case 16200:if(o>=6&&s>=258){e.next_out=a,e.avail_out=s,e.next_in=l,e.avail_in=o,n.hold=d,n.bits=c,inffast(e,p),a=e.next_out,r=e.output,s=e.avail_out,l=e.next_in,i=e.input,o=e.avail_in,d=n.hold,c=n.bits,16191===n.mode&&(n.back=-1);break}for(n.back=0;g=(I=n.lencode[d&(1<<n.lenbits)-1])>>>24,x=I>>>16&255,b=65535&I,!(g<=c);){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(x&&(240&x)==0){for(v=g,_=x,y=b;g=(I=n.lencode[y+((d&(1<<v+_)-1)>>v)])>>>24,x=I>>>16&255,b=65535&I,!(v+g<=c);){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}d>>>=v,c-=v,n.back+=v}if(d>>>=g,c-=g,n.back+=g,n.length=b,0===x){n.mode=16205;break}if(32&x){n.back=-1,n.mode=16191;break}if(64&x){e.msg="invalid literal/length code",n.mode=16209;break}n.extra=15&x,n.mode=16201;case 16201:if(n.extra){for(C=n.extra;c<C;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}n.length+=d&(1<<n.extra)-1,d>>>=n.extra,c-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;g=(I=n.distcode[d&(1<<n.distbits)-1])>>>24,x=I>>>16&255,b=65535&I,!(g<=c);){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if((240&x)==0){for(v=g,_=x,y=b;g=(I=n.distcode[y+((d&(1<<v+_)-1)>>v)])>>>24,x=I>>>16&255,b=65535&I,!(v+g<=c);){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}d>>>=v,c-=v,n.back+=v}if(d>>>=g,c-=g,n.back+=g,64&x){e.msg="invalid distance code",n.mode=16209;break}n.offset=b,n.extra=15&x,n.mode=16203;case 16203:if(n.extra){for(C=n.extra;c<C;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}n.offset+=d&(1<<n.extra)-1,d>>>=n.extra,c-=n.extra,n.back+=n.extra}if(n.offset>
1n.dmax){e.msg="invalid distance too far back",n.mode=16209;break}n.mode=16204;case 16204:if(0===s)break t;if(h=p-s,n.offset>h){if((h=n.offset-h)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=16209;break}h>n.wnext?(h-=n.wnext,m=n.wsize-h):m=n.wnext-h,h>n.length&&(h=n.length),f=n.window}else f=r,m=a-n.offset,h=n.length;h>s&&(h=s),s-=h,n.length-=h;do r[a++]=f[m++];while(--h);0===n.length&&(n.mode=16200);break;case 16205:if(0===s)break t;r[a++]=n.length,s--,n.mode=16200;break;case 16206:if(n.wrap){for(;c<32;){if(0===o)break t;o--,d|=i[l++]<<c,c+=8}if(p-=s,e.total_out+=p,n.total+=p,4&n.wrap&&p&&(e.adler=n.check=n.flags?crc32_1(n.check,r,p,a-p):adler32_1(n.check,r,p,a-p)),p=s,4&n.wrap&&(n.flags?d:zswap32(d))!==n.check){e.msg="incorrect data check",n.mode=16209;break}d=0,c=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;c<32;){if(0===o)break t;o--,d+=i[l++]<<c,c+=8}if(4&n.wrap&&d!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=16209;break}d=0,c=0}n.mode=16208;case 16208:w=ag;break t;case 16209:w=av;break t;case 16210:return a_;default:return ab}return e.next_out=a,e.avail_out=s,e.next_in=l,e.avail_in=o,n.hold=d,n.bits=c,(n.wsize||p!==e.avail_out&&n.mode<16209&&(n.mode<16206||t!==ap))&&updatewindow(e,e.output,e.next_out,p-e.avail_out),u-=e.avail_in,p-=e.avail_out,e.total_in+=u,e.total_out+=p,n.total+=p,4&n.wrap&&p&&(e.adler=n.check=n.flags?crc32_1(n.check,r,p,e.next_out-p):adler32_1(n.check,r,p,e.next_out-p)),e.data_type=n.bits+(n.last?64:0)+(16191===n.mode?128:0)+(16199===n.mode||16194===n.mode?256:0),(0===u&&0===p||t===ap)&&w===af&&(w=ay),w},inflateEnd:e=>{if(inflateStateCheck(e))return ab;let t=e.state;return t.window&&(t.window=null),e.state=null,af},inflateGetHeader:(e,t)=>{if(inflateStateCheck(e))return ab;let n=e.state;return(2&n.wrap)==0?ab:(n.head=t,t.done=!1,af)},inflateSetDictionary:(e,t)=>{let n;let i=t.length;return inflateStateCheck(e)||0!==(n=e.state).wrap&&16190!==n.mode?ab:16190===n.mode&&adler32_1(1,t,i,0)!==n.check?av:updatewindow(e,t,i,i)?(n.mode=16210,a_):(n.havedict=1,af)},inflateInfo:"pako inflate (from Nodeca project)"},gzheader=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};let aC=Object.prototype.toString,{Z_NO_FLUSH:aI,Z_FINISH:aS,Z_OK:az,Z_STREAM_END:aP,Z_NEED_DICT:aE,Z_STREAM_ERROR:aD,Z_DATA_ERROR:aT,Z_MEM_ERROR:aM}=lT;function Inflate$1(e){this.options=l3.assign({chunkSize:65536,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits)==0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zstream,this.strm.avail_out=0;let n=ak.inflateInit2(this.strm,t.windowBits);if(n!==az||(this.header=new gzheader,ak.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=l4.string2buf(t.dictionary):"[object ArrayBuffer]"===aC.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ak.inflateSetDictionary(this.strm,t.dictionary))!==az)))throw Error(lD[n])}function inflate$1(e,t){let n=new Inflate$1(t);if(n.push(e),n.err)throw n.msg||lD[n.err];return n.result}Inflate$1.prototype.push=function(e,t){let n,i,r;let l=this.strm,a=this.options.chunkSize,o=this.options.dictionary;if(this.ended)return!1;for(i=t===~~t?t:!0===t?aS:aI,"[object ArrayBuffer]"===aC.call(e)?l.input=new Uint8Array(e):l.input=e,l.next_in=0,l.avail_in=l.input.length;;){for(0===l.avail_out&&(l.output=new Uint8Array(a),l.next_out=0,l.avail_out=a),(n=ak.inflate(l,i))===aE&&o&&((n=ak.inflateSetDictionary(l,o))===az?n=ak.inflate(l,i):n===aT&&(n=aE));l.avail_in>0&&n===aP&&l.state.wrap>0&&0!==e[l.next_in];)ak.inflateReset(l),n=ak.inflate(l,i);switch(n){case aD:case aT:case aE:case aM:return this.onEnd(n),this.ended=!0,!1}if(r=l.avail_out,l.next_out&&(0===l.avail_out||n===aP)){if("string"===this.options.to){let e=l4.utf8border(l.output,l.next_out),t=l.next_out-e,n=l4.buf2string(l.output,e);l.next_out=t,l.avail_out=a-t,t&&l.output.set(l.output.subarray(e,e+t),0),this.onData(n)}else this.onData(l.output.length===l.next_out?l.output:l.output.subarray(0,l.next_out))}if(n!==az||0!==r){if(n===aP)return n=ak.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===l.avail_in)break}}return!0},Inflate$1.prototype.onData=function(e){this.chunks.push(e)},Inflate$1.prototype.onEnd=function(e){e===az&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=l3.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};let{Deflate:aR,deflate:aA,deflateRaw:aO,gzip:aL}={Deflate:Deflate$1,deflate:deflate$1,deflateRaw:function(e,t){return(t=t||{}).raw=!0,deflate$1(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,deflate$1(e,t)},constants:lT},{Inflate:aB,inflate:aN,inflateRaw:a$,ungzip:aZ}={Inflate:Inflate$1,inflate:inflate$1,inflateRaw:function(e,t){return(t=t||{}).raw=!0,inflate$1(e,t)},ungzip:inflate$1,constants:lT};var aU={Deflate:aR,deflate:aA,deflateRaw:aO,gzip:aL,Inflate:aB,inflate:aN,inflateRaw:a$,ungzip:aZ,constants:lT};function _getProperty(e,t){return _isArray(e)?e[Number(t)]:e[t]}function _isArray(e){return Array.isArray(e)}function _isRecord(e){return e&&"object"==typeof e}function _setProperty(e,t,n){if(_isArray(e)){e[Number(t)]=n;return}if(_isRecord(e)){e[t]=n;return}throw Error("shallowClone: target must be an object or an array")}function _shallowClone(e){if(_isArray(e))return e.slice(0);if(_isRecord(e))return function(e,t){var n;for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}({},e);throw Error("shallowClone: source must be an object or an array")}let aF=[],aH={},aV=[{name:"auto",title:"Full",rect:{width:"auto"}},{name:"768",title:"768px",rect:{width:768}},{name:"375",title:"375px",rect:{width:375,height:667}},{name:"320",title:"320px",rect:{width:320,height:568}}],aq=[{value:.5,title:"50%"},{value:.75,title:"75%"},{value:1,title:"100%"},{value:1.5,title:"150%"}
1,{value:2,title:"200%"},{value:3,title:"300%"}];function createPubsub(){let e=new Set;return{publish(t){for(let n of e)n(t)},subscribe:t=>(e.add(t),()=>{e.delete(t)})}}let aW={parse(e){let t=new URLSearchParams("?"+e),n={};return t.forEach((e,t)=>{n[t]=e}),n},stringify:e=>Object.entries(e).map(e=>{let[t,n]=e;return"".concat(t,"=").concat(n)}).join("&")};function buildFrameUrl(e){let{baseUrl:t="/frame/",path:n,payload:i,scheme:r,viewport:l,zoom:a}=e;return[t,"?path=".concat(encodeURIComponent(n)),"&scheme=".concat(r),"&viewport=".concat(l),"&zoom=".concat(a),...Object.entries(i).map(e=>{let[t,n]=e;return"&".concat(t,"=").concat(n)})].join("")}let aG=(0,ts.createContext)(null);function useProps(){let e=(0,ts.useContext)(aG);if(!e)throw Error("Props: missing context value");return e}let aK=(0,ts.memo)(function(e){let{schema:t,value:n}=e,{setPropValue:i}=useProps();return(0,td.jsxs)(tp.kC,{as:"label",padding:3,children:[(0,td.jsx)(tp.xu,{marginRight:2,style:{lineHeight:0},children:(0,td.jsx)(tp.XZ,{checked:n||!1,onChange:e=>i(t.name,e.currentTarget.checked)})}),(0,td.jsx)(tp.xu,{paddingY:1,children:(0,td.jsx)(tp.xv,{size:1,weight:"semibold",children:t.name})})]})}),aY=(0,ts.memo)(function(e){let{schema:t,value:n=""}=e,{setPropValue:i}=useProps();return(0,td.jsxs)(tp.xu,{padding:3,children:[(0,td.jsx)(tp.xv,{size:1,weight:"semibold",children:t.name}),(0,td.jsx)(tp.xu,{marginTop:2,children:(0,td.jsx)(tp.oi,{fontSize:[2,2,1],onChange:e=>i(t.name,Number(e.currentTarget.value)),padding:2,value:n})})]})}),aX=(0,ts.memo)(function(e){let{schema:t,value:n}=e,{setPropValue:i}=useProps(),r=(0,ts.useMemo)(()=>{let e=Object.entries(t.options);for(let[t,i]of e)if(i===n)return t;return""},[t,n]);return(0,td.jsxs)(tp.xu,{padding:3,children:[(0,td.jsx)(tp.xv,{size:1,weight:"semibold",children:t.name}),(0,td.jsx)(tp.xu,{marginTop:2,children:(0,td.jsx)(tp.Ph,{fontSize:[2,2,1],onChange:e=>{let n=e.currentTarget.value,r=t.options[n];i(t.name,r)},padding:2,radius:2,value:String(r||""),children:Object.entries(t.options).map(e=>{let[t]=e;return(0,td.jsx)("option",{value:t,children:t},t)})})})]})}),aQ=(0,ts.memo)(function(e){let{schema:t,value:n}=e,{setPropValue:i}=useProps();return(0,td.jsxs)(tp.xu,{padding:3,children:[(0,td.jsx)(tp.xv,{size:1,weight:"semibold",children:t.name}),(0,td.jsx)(tp.xu,{marginTop:2,children:(0,td.jsx)(tp.oi,{fontSize:[2,2,1],onChange:e=>i(t.name,e.currentTarget.value),padding:2,value:n||""})})]})}),aJ=(0,ts.memo)(function(e){let{schema:t,value:n}=e,{setPropValue:i}=useProps();return(0,td.jsxs)(tp.xu,{padding:3,children:[(0,td.jsx)(tp.xv,{size:1,weight:"semibold",children:t.name}),(0,td.jsx)(tp.xu,{marginTop:2,children:(0,td.jsx)(tp.Kx,{fontSize:[2,2,1],onChange:e=>i(t.name,e.currentTarget.value),rows:4,value:n||""})})]})});function Prop(e){let{schema:t,value:n}=e;return"boolean"===t.type?(0,td.jsx)(aK,{schema:t,value:n}):"number"===t.type?(0,td.jsx)(aY,{schema:t,value:n}):"select"===t.type?(0,td.jsx)(aX,{schema:t,value:n}):"string"===t.type?(0,td.jsx)(aQ,{schema:t,value:n}):"text"===t.type?(0,td.jsx)(aJ,{schema:t,value:n}):(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsxs)(tp.xv,{size:1,weight:"semibold",children:["Unknown Prop type:"," ",(0,td.jsxs)("code",{children:[t.name,": ",t.type]})]})})}let a0=(0,ts.memo)(function(){let{schemas:e,value:t}=useProps();return(0,td.jsxs)(tp.xu,{padding:2,children:[0===e.length&&(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{muted:!0,size:[2,2,1],children:"No properties"})}),e.length>0&&e.map((e,n)=>(0,td.jsx)(Prop,{schema:e,value:void 0===t[e.name]?e.defaultValue:t[e.name]},n))]})}),a1=t7(),a2=(0,ts.createContext)(null);function useWorkshop(){let e=(0,ts.useContext)(a2);if(!e)throw Error("Workshop: missing context value");return e}let a5="undefined"==typeof window?e=>nF.from(e,"binary").toString("base64"):window.btoa,a3="undefined"==typeof window?e=>nF.from(e,"base64").toString("binary"):window.atob;function decodeValue(e){try{return JSON.parse(function(e){if(0===e.length)return"";let t=function(e){let t=a3(e),n=t.length,i=new Uint8Array(n);for(let e=0;e<n;e++)i[e]=t.charCodeAt(e);return i}(e);
1return aU.inflate(t,{to:"string"})}(e))}catch(e){return{}}}let a6=(0,ts.memo)(function(e){let{children:t}=e,{channel:n,broadcast:i,payload:r}=useWorkshop(),l=r.value,a=(0,ts.useRef)(l),[{schemas:o,value:s},d]=(0,ts.useState)({schemas:[],value:decodeValue(String(l))||{}}),c=(0,ts.useCallback)(e=>{i({type:"workshop/props/registerProp",schema:e})},[i]),u=(0,ts.useCallback)(e=>{i({type:"workshop/props/unregisterProp",name:e})},[i]),p=(0,ts.useCallback)((e,t)=>{i({type:"workshop/props/setPropValue",name:e,value:t})},[i]),h=(0,ts.useMemo)(()=>({registerProp:c,schemas:o,setPropValue:p,unregisterProp:u,value:s}),[c,o,p,u,s]);return(0,ts.useEffect)(()=>n.subscribe(e=>{d(t=>{let n=function(e,t){if("workshop/props/setValue"===t.type)return{...e,value:t.value};if("workshop/props/registerProp"===t.type)return{...e,schemas:e.schemas.concat([t.schema])};if("workshop/props/unregisterProp"===t.type){let n={...e.value};return delete n[t.name],{...e,schemas:e.schemas.filter(e=>e.name!==t.name),value:n}}return"workshop/props/setPropValue"===t.type?{...e,value:{...e.value,[t.name]:t.value}}:e}(t,e);return a1(t,n)?t:n})}),[n]),(0,ts.useEffect)(()=>{let e=function(e){if(0===e.length)return"";let t=aU.deflate(e);return function(e){let t="";for(let n=0,{length:i}=e;n<i;n++)t+=String.fromCharCode(e[n]);return a5(t)}(t)}(JSON.stringify(s));a.current!==e&&(a.current=e,i({type:"workshop/setPayloadValue",key:"value",value:e}))},[i,s]),(0,ts.useEffect)(()=>{a.current!==l&&(a.current=l,d(e=>({...e,value:decodeValue(String(l))||{}})))},[l]),(0,td.jsx)(aG.Provider,{value:h,children:t})}),a8=(0,ts.memo)(function(e){let{broadcast:t,children:n,channel:i,config:r,frameReady:l,origin:a,path:o,payload:s,scheme:d,viewport:c="auto",zoom:u=1}=e,{plugins:p=aF,collections:h=aF,frameUrl:m="/frame/",scopes:f,title:g="Workshop"}=r;if(!s)throw Error("missing `payload` property");let x=(0,ts.useMemo)(()=>[{name:"props",title:"Properties",inspector:a0,provider:a6},...p],[p]),{scope:b,story:v}=(0,ts.useMemo)(()=>(function(e,t){let n=t.split("/").slice(1).filter(Boolean),i=n.join("/");if(0===n.length)return{scope:null,story:null};for(let t of e)for(let e of t.stories){let n=[t.name,e.name].filter(Boolean).join("/");if(i===n)return{scope:t,story:e}}return{scope:null,story:null}})(f,o),[o,f]),_=(0,ts.useMemo)(()=>({plugins:x,broadcast:t,channel:i,collections:h,frameReady:l,frameUrl:m,origin:a,path:o,payload:s,scheme:d,scope:b,scopes:f,story:v,title:g,viewport:c,zoom:u}),[x,t,i,h,l,m,a,o,s,d,b,f,v,g,c,u]),y=n;for(let e of x)e.provider&&(y=(0,ts.createElement)(e.provider,{options:e.options||aH},y));return(0,td.jsx)(a2.Provider,{value:_,children:y})});function workshopReducer(e,t){if("workshop/frameReady"===t.type)return{...e,frameReady:!0};if("workshop/setState"===t.type)return a1(e,t.value)?e:t.value;if("workshop/setZoom"===t.type)return e.zoom===t.value?e:{...e,zoom:t.value};if("workshop/setViewport"===t.type)return e.viewport===t.value?e:{...e,viewport:t.value};if("workshop/toggleScheme"===t.type)return{...e,scheme:"light"===e.scheme?"dark":"light"};if("workshop/setScheme"===t.type)return e.scheme===t.value?e:{...e,scheme:t.value};if("workshop/setPath"===t.type)return e.path===t.value?e:{...e,path:t.value};if("workshop/setPayload"===t.type)return a1(e.payload,t.value)?e:{...e,payload:t.value};if("workshop/setPayloadValue"===t.type){let n={...e.payload,[t.key]:t.value};return a1(e.payload,n)?e:{...e,payload:n}}return e}let a4=(()=>{try{return nH.env.ROOT_PATH}catch(e){return}})(),a9=/http:\/\/([^:/\s]+)(:[0-9]+)?/g,a7=/\/@fs\//g,oe=/\?([a-z]{1})=([0-9]+)/g;function formatStack(e){let t=decodeURIComponent(e);return(t=e.replace(a9,"").replace(a7,"/").replace(oe,""),a4)?function(e,t){let n=RegExp(t.replace(/\//g,"\\/"),"g");return e.replace(n,"")}(t,a4+"/"):t}let ot=(0,ts.memo)(function(){let{story:e}=useWorkshop(),[t,n]=(0,ts.useState)({error:null,errorInfo:null}),i=(0,ts.useCallback)(e=>{let{error:t,info:i}=e;n({error:t,errorInfo:i})},[]),r=(0,ts.useCallback)(()=>{n({error:null,errorInfo:null})},[]);return e?t.error?(0,td.jsx)(tp.Zb,{as:"main",height:"fill",overflow:"auto",tone:"critical",children:(0,td.jsx)(oi,{error:t.error,errorInfo:t.errorInfo,onRetry:r})}):(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)("h1",{hidden:!0,children:e.title}),(0,td.jsx)(ts.Suspense,{fallback:(0,td.jsx)(on,{story:e}),children:(0,td.jsx)(tp.Zb,{as:"main",height:"fill",children:(0,td.jsx)(tp.SV,{onCatch:i,children:(0,ts.createElement)(e.component)})})})]}):(0,td.jsx)(td.Fragment,{})}),on=(0,ts.memo)(function(e){let{story:t}=e;return(0,td.jsxs)(td.Fragment,{children:[(0,td.jsxs)("h1",{hidden:!0,children:["Loading ",(0,td.jsx)("em",{children:t.title}),"â¦"]}),(0,td.jsx)(tp.kC,{align:"center",as:"main",height:"fill",justify:"center",children:(0,td.jsx)(tp.$j,{muted:!0}
1)})]})}),oi=(0,ts.memo)(function(e){let{error:t,errorInfo:n,onRetry:i}=e;return(0,td.jsx)(tp.xu,{padding:4,children:(0,td.jsxs)(tp.Kq,{space:4,children:[(0,td.jsx)(tp.X6,{as:"h1",size:[1,1,2],children:t.message}),(0,td.jsx)(tp.xu,{children:(0,td.jsx)(tp.zx,{onClick:i,text:"Retry"})}),t.stack&&(0,td.jsx)(tp.EK,{size:1,children:formatStack(t.stack)}),n&&(0,td.jsx)(tp.EK,{size:1,children:"Component stack:"+formatStack(n.componentStack)})]})})});function isArray(e){return Array.isArray(e)}function isRecord(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}(0,ts.memo)(function(e){let{config:t,setScheme:n}=e,i=(0,ts.useMemo)(()=>(function(){let e=new Set,t=[],n=null;function _handleMessage(t){let n=t.data;if(isArray(n)){for(let t of n)if(isRecord(t)&&"string"==typeof t.type&&t.type.startsWith("workshop/"))for(let n of e)n(t)}}return{message:{publish(e){t.push(e),n&&clearInterval(n),n=setTimeout(()=>{window.parent.postMessage(t),t=[],n=null},0)},subscribe:t=>(e.add(t),1===e.size&&window.addEventListener("message",_handleMessage,!1),()=>{e.delete(t),0===e.size&&window.removeEventListener("message",_handleMessage,!1)})}}})(),[]),r=(0,ts.useMemo)(()=>createPubsub(),[]),[l,a]=(0,ts.useState)(null),[o,s]=(0,ts.useState)(null),d=(0,ts.useCallback)(e=>{r.publish(e),i.message.publish(e)},[r,i]),[{frameReady:c,path:u,payload:p,scheme:h,viewport:m,zoom:f},g]=(0,ts.useState)(()=>(function(){let e="undefined"==typeof window?{}:aW.parse(window.location.search.slice(1)),{path:t="/",scheme:n,viewport:i,zoom:r,...l}=e;return{frameReady:!1,path:t,payload:l,scheme:"string"==typeof n?n:"light",viewport:"string"==typeof i?i:"auto",zoom:"string"==typeof r?Number(r):1}})());return(0,ts.useEffect)(()=>r.subscribe(e=>g(t=>workshopReducer(t,e))),[r]),(0,ts.useEffect)(()=>i.message.subscribe(r.publish),[r,i]),(0,ts.useEffect)(()=>n(h),[n,h]),(0,ts.useEffect)(()=>d({type:"workshop/frameReady"}),[d]),(0,td.jsx)(tp.VW,{children:(0,td.jsx)(tp.NM,{element:l,children:(0,td.jsx)(tp.Xp,{element:o,children:(0,td.jsx)(a8,{broadcast:d,config:t,channel:r,frameReady:c,origin:"frame",path:u,payload:p,scheme:h,viewport:m,zoom:f,children:(0,td.jsxs)(tp.Zb,{height:"fill",ref:a,children:[(0,td.jsx)(ot,{}),(0,td.jsx)("div",{"data-portal":"",ref:s})]})})})})})});var or=Object.freeze,ol=Object.defineProperty;(0,th.vJ)(ej||(ej=or(ol(b=["\n body {\n background-color: ",";\n }\n"],"raw",{value:or(b.slice())}))),e=>{let{theme:t}=e;return t.sanity.color.base.bg});var oa=Object.freeze,oo=Object.defineProperty;let os=(0,ts.memo)(tp.OK),od=(0,th.ZP)(tp.Zb)(ew||(ew=oa(oo(v=["\n line-height: 0;\n\n @media screen and (max-width: ","px) {\n text-align: center;\n }\n"],"raw",{value:oa(v.slice())}))),e=>{let{theme:t}=e;return t.sanity.media[1]-1}),oc=(0,ts.memo)(function(e){let{currentTabId:t,onTabChange:n,tabs:i}=e,r=(0,ts.useMemo)(()=>({flex:"none",position:"sticky",top:0}),[]),l=(0,ts.useMemo)(()=>i.map(e=>(0,td.jsx)(InspectorTabView,{onTabChange:n,selected:e.id===t,tab:e},e.id)),[t,n,i]);return(0,td.jsx)(tp.mh,{style:r,children:(0,td.jsx)(od,{padding:2,shadow:1,children:(0,td.jsx)(tp.td,{space:1,children:l})})})});function InspectorTabView(e){let{onTabChange:t,selected:n,tab:i}=e,r=(0,ts.useCallback)(()=>{t(i.id)},[t,i]);return(0,td.jsx)(os,{"aria-controls":"".concat(i.id,"-panel"),fontSize:[2,2,1],id:i.id,label:i.label,onClick:r,selected:n,tone:i.tone})}var ou=Object.freeze,op=Object.defineProperty;let oh=(0,th.ZP)(tp.Zb)(ek||(ek=ou(op(_=["\n overflow: hidden;\n\n @media screen and (min-width: ","px) {\n border-left: 1px solid var(--card-border-color);\n min-width: 180px;\n max-width: 300px;\n overflow: auto;\n }\n"],"raw",{value:ou(_.slice())}))),e=>{let{theme:t}=e;return t.sanity.media[1]}),om=(0,ts.memo)(function(e){return(0,ts.createElement)(e.component,{options:e.options})}),of=(0,ts.memo)(function(e){let{expanded:t}=e,{plugins:n}=useWorkshop(),i=(0,ts.useMemo)(()=>n.filter(e=>e.inspector).map(e=>({id:e.name,label:e.title,tone:void 0,plugin:e})),[n]),[r,l]=(0,ts.useState)(i.length>0?i[0].id:null),a=i.find(e=>e.id===r),o=i.length>1,s=(0,ts.useMemo)(()=>t?["block"]:["none","none","block"],[t]);return(0,td.jsx)(oh,{display:s,flex:1,children:(0,td.jsxs)(tp.kC,{direction:"column",height:"fill",children:[o&&(0,td.jsx)(oc,{currentTabId:r,onTabChange:l,tabs:i}),o&&i.map(e=>(0,td.jsx)(tp.x4,{"aria-labelledby":"".concat(e.id,"-tab"),flex:1,hidden:e.id!==r,id:"".concat(e.id,"-panel"),overflow:"auto",children:e.plugin.inspector&&(0,td.jsx)(om,{component:e.plugin.inspector,options:e.plugin.options||aH})},e.id)),!o&&(null==a?void 0:a.plugin.inspector)&&(0,td.jsx)(tp.xu,{flex:1,overflow:"auto",children:(0,td.jsx)(om,{component:a.plugin.inspector,options:a.plugin.options||aH})})]})})}),og=nl();function NavbarBreadcrumbs(){let{broadcast:e,scope:t,story:n,title:i}=useWorkshop(),r=(0,ts.useCallback)(t=>{t.preventDefault(),e({type:"workshop/setPath",value:"/"})},[e]);return(0,td.jsx)(ox,{onHomeClick:r,scopeTitle:null==t?void 0:t.t
1itle,storyTitle:null==n?void 0:n.title,title:i})}let ox=(0,ts.memo)(function(e){let{onHomeClick:t,scopeTitle:n,storyTitle:i,title:r}=e;return(0,td.jsxs)(tp.Oo,{separator:(0,td.jsx)(tp.xv,{muted:!0,size:[2,2,1],children:"/"}),space:2,children:[(0,td.jsx)(tp.xv,{size:[2,2,1],weight:"bold",children:(0,td.jsx)("a",{href:"/",onClick:t,style:{color:"inherit"},children:r})}),n&&(0,td.jsx)(tp.xv,{align:"center",size:[2,2,1],children:n}),i&&(0,td.jsx)(tp.xv,{size:[2,2,1],children:i})]})}),ob=(0,ts.memo)(function(){let{frameUrl:e,path:t,payload:n,scheme:i,zoom:r,viewport:l}=useWorkshop(),a=(0,ts.useMemo)(()=>"/"===t?void 0:buildFrameUrl({baseUrl:e,path:t,payload:n,scheme:i,zoom:r,viewport:l}),[e,t,n,i,r,l]);return(0,td.jsx)(tp.zx,{as:a?"a":"button",disabled:!a,fontSize:1,href:a,iconRight:to.buG,mode:"ghost",padding:2,rel:"noopener noreferrer",target:"_blank",text:"Open story"})});function SchemeMenu(){let{broadcast:e,scheme:t}=useWorkshop(),n=(0,ts.useCallback)(()=>{e({type:"workshop/toggleScheme"})},[e]);return(0,td.jsx)(ov,{dark:"dark"===t,onToggleScheme:n})}let ov=(0,ts.memo)(function(e){let{dark:t,onToggleScheme:n}=e;return(0,td.jsx)(tp.zx,{fontSize:1,icon:t?to.kLh:to.NWY,mode:"bleed",onClick:n,padding:2})}),o_=(0,ts.memo)(function(){let{broadcast:e,story:t,viewport:n}=useWorkshop(),i=(0,ts.useCallback)(t=>{e({type:"workshop/setViewport",value:t})},[e]);return(0,td.jsx)(oj,{disabled:!t,setViewport:i,viewport:n})}),oy={constrainSize:!0,matchReferenceWidth:!0,placement:"bottom",portal:!0},oj=(0,ts.memo)(function(e){var t;let{disabled:n,setViewport:i,viewport:r}=e;return(0,td.jsx)(tp.j2,{button:(0,td.jsx)(tp.zx,{disabled:n,fontSize:1,iconRight:to.GVG,mode:"ghost",padding:2,style:{minWidth:80},text:null==(t=aV.find(e=>e.name===r))?void 0:t.title}),id:"viewport-menu",menu:(0,td.jsx)(tp.v2,{children:aV.map(e=>(0,td.jsx)(tp.sN,{fontSize:1,onClick:()=>i(e.name),padding:2,selected:e.name===r,text:e.title},e.name))}),popover:oy})});function ZoomMenu(){let{broadcast:e,story:t,zoom:n}=useWorkshop(),i=(0,ts.useCallback)(t=>e({type:"workshop/setZoom",value:t}),[e]);return(0,td.jsx)(ok,{disabled:!t,setZoom:i,zoom:n})}let ow={constrainSize:!0,matchReferenceWidth:!0,placement:"bottom",portal:!0},ok=(0,ts.memo)(function(e){var t;let{disabled:n,setZoom:i,zoom:r}=e;return(0,td.jsx)(tp.j2,{button:(0,td.jsx)(tp.zx,{disabled:n,fontSize:1,iconRight:to.GVG,mode:"ghost",padding:2,style:{minWidth:80},text:null==(t=aq.find(e=>e.value===r))?void 0:t.title}),id:"zoom-menu",menu:(0,td.jsx)(tp.v2,{children:aq.map(e=>(0,td.jsx)(tp.sN,{fontSize:1,onClick:()=>i(e.value),padding:2,selected:e.value===r,text:e.title},e.value))}),popover:ow})}),oC=(0,ts.memo)(function(e){let{inspectorExpanded:t,navigatorExpanded:n,onInspectorToggle:i,onNavigatorToggle:r}=e,l=(0,tp.d2)(),{story:a,title:o}=useWorkshop();return(0,td.jsx)(tp.Zb,{borderBottom:!0,flex:"none",padding:2,style:{lineHeight:0},children:(0,td.jsxs)(tp.kC,{gap:1,children:[(0,td.jsx)(tp.xu,{display:["block","block","none"],flex:"none",children:(0,td.jsx)(tp.zx,{"aria-label":"Open navigator",fontSize:[2,2,1],icon:to.Oqj,mode:"bleed",onClick:r,padding:2,selected:n})}),(0,td.jsxs)(tp.kC,{flex:1,justify:["center","center","flex-start"],padding:2,sizing:"border",style:{minWidth:250},children:[l<2&&(0,td.jsx)(tp.xv,{weight:"bold",children:(null==a?void 0:a.title)||o}),l>=2&&(0,td.jsx)(NavbarBreadcrumbs,{})]}),(0,td.jsx)(tp.xu,{display:["block","block","none"],flex:"none",children:(0,td.jsx)(tp.zx,{"aria-label":"Open inspector",fontSize:[2,2,1],icon:to.d$S,mode:"bleed",onClick:i,padding:2,selected:t})}),(0,td.jsx)(tp.xu,{display:["none","none","block"],flex:"none",children:(0,td.jsxs)(tp.gF,{space:1,children:[(0,td.jsx)(ob,{}),(0,td.jsx)(o_,{}),(0,td.jsx)(ZoomMenu,{}),(0,td.jsx)(SchemeMenu,{})]})})]})})}),oI=(0,ts.memo)(function(e){let{matches:t,onStoryClick:n}=e;return(0,td.jsx)(tp.Kq,{space:1,children:t.map(e=>{let{scope:t,story:i}=e;return(0,td.jsx)(tp.Zb,{as:"a","data-path":"/".concat(t.name,"/").concat(i.name),href:"/".concat(t.name,"/").concat(i.name),onClick:n,padding:2,radius:2,children:(0,td.jsx)(tp.xv,{size:1,textOverflow:"ellipsis",children:[t.title||"",i.title].filter(
1Boolean).join(" / ")})},"".concat(t.name,"/").concat(i.name))})})}),oS=(0,ts.memo)(function(e){let{items:t}=e;return(0,td.jsx)(tp.mp,{space:1,children:(0,td.jsx)(oz,{items:t})})}),oz=(0,ts.memo)(function(e){let{basePath:t="",items:n}=e,{broadcast:i,path:r,scope:l,story:a}=useWorkshop(),o=(0,ts.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=t.getAttribute("data-path");n&&i({type:"workshop/setPath",value:n})},[i]);return(0,ts.useMemo)(()=>0===n.length?null:(0,td.jsx)(td.Fragment,{children:n.map((e,n)=>{if("list"===e.type){let i="".concat(t,"/").concat(e.name);return(0,td.jsx)(oP,{expanded:r.startsWith(i+"/"),item:e,path:i},e.name||n)}return"story"===e.type?(0,td.jsx)(tp.kf,{"data-path":"/".concat(e.name||""),fontSize:[2,2,1],href:"/".concat(e.name||""),onClick:o,padding:2,selected:(null==a?void 0:a.component)===e.component,text:e.title},e.name):"scope"===e.type?(0,td.jsx)(oE,{currentStory:a,expanded:e.scope===l,item:e,onStoryClick:o},e.name):(0,td.jsx)(tp.kf,{text:"unknown"},n)})}),[t,l,a,o,n,r])}),oP=(0,ts.memo)(function(e){let{expanded:t,item:n,path:i}=e,r=(0,ts.useMemo)(()=>(0,td.jsx)(oz,{basePath:i,items:n.items}),[n,i]);return(0,td.jsx)(tp.kf,{expanded:t,fontSize:[2,2,1],padding:2,text:n.title,weight:"semibold",children:r})}),oE=(0,ts.memo)(function(e){let{currentStory:t,expanded:n,item:i,onStoryClick:r}=e,l=(0,ts.useMemo)(()=>i.scope.stories.map(e=>(0,td.jsx)(tp.kf,{"data-path":"/".concat(i.scope.name,"/").concat(e.name),fontSize:[2,2,1],href:"/".concat(i.scope.name,"/").concat(e.name),onClick:r,padding:2,selected:t===e,text:e.title},e.name)),[t,i,r]);return(0,td.jsx)(tp.kf,{expanded:n,fontSize:[2,2,1],padding:2,text:i.title,weight:"semibold",children:l})});var oD=Object.freeze,oT=Object.defineProperty;let oM=(0,th.ZP)(tp.Zb)(eC||(eC=oD(oT(y=["\n overflow: hidden;\n\n @media screen and (min-width: ","px) {\n border-right: 1px solid var(--card-border-color);\n min-width: 180px;\n max-width: 300px;\n overflow: auto;\n }\n"],"raw",{value:oD(y.slice())}))),e=>{let{theme:t}=e;return t.sanity.media[1]}),oR={flex:"none"},oA={lineHeight:0},oO=[2,2,1],oL=(0,ts.memo)(function(e){let{collections:t=[],expanded:n}=e,{broadcast:i,scopes:r}=useWorkshop(),l=(0,ts.useMemo)(()=>(function(e,t){let n={};for(let e of t){let t=e.name||"@@root@@",i=n[t]||{name:t,title:e.title,stories:[]},r={...i,name:t,stories:i.stories.concat(e.stories)};n[t]=r}let i={};for(let e of Object.values(n))i=function(e,t,n){if(!t){if(_isArray(n)||_isRecord(n))return n;throw Error("set: cannot replace value with a non-record value")}if((t?function _getByPath(e,t){if(e){var n=_getProperty(e,t.shift());return t.length&&(_isArray(n)||_isRecord(n))?_getByPath(n,t):n}}(e,t.split("/")):e)===n)return e;for(var i=_shallowClone(e),r=t.split("/"),l=e,a=i;r.length;){var o=r.shift();if(r.length){var s=_getProperty(l,o);if(void 0===s&&_setProperty(l,o,s={}),!_isArray(s)&&!_isRecord(s))throw Error('set: path is not targeting an object nor an array: "'+t+'"');var d=_shallowClone(l=s);_setProperty(a,o,d),a=d}else _setProperty(a,o,n)}return i}(i,e.name||"@@root@@",{__scope__:e});let r={type:"list",name:"@@root@@",items:[]};for(let[t,n]of Object.entries(i))r.items.push(...function parseMenuNode(e,t,n){if(t.__scope__){let e=t.__scope__;return"@@root@@"===e.name?e.stories.map(e=>({type:"story",...e})):[{type:"scope",name:e.name||"@@root@@",title:e.title||"(root)",scope:e}]}let i=e.find(e=>e.name===n),r=Object.entries(t).filter(e=>{let[t]=e;return"__scope__"!==t}),l=r.flatMap(e=>{let[t,n]=e;return parseMenuNode((null==i?void 0:i.children)||[],n,t)});return[{type:"list",name:n,title:(null==i?void 0:i.title)||n,items:l}]}(e,n,t));return r})(t,r),[t,r]),[a,o]=(0,ts.useState)(""),s=(0,ts.useMemo)(()=>{var e;if(!a)return aF;let t=a.toLowerCase(),n=[];for(let i of r)for(let r of i.stories)((null==(e=i.title)?void 0:e.toLowerCase().includes(t))||r.title.toLowerCase().includes(t))&&n.push({scope:i,story:r});return n},[a,r]),d=(0,ts.useCallback)(e=>o(e.currentTarget.value),[]),c=(0,ts.useCallback)(()=>o(""),[]),u=(0,ts.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=t.getAttribute("data-path");
1n&&(i({type:"workshop/setPath",value:n}),o(""))},[i]);return(0,td.jsx)(oB,{expanded:n,matches:s,menu:l,onSearchQueryChange:d,onSearchQueryClear:c,onStoryClick:u,query:a})}),oB=(0,ts.memo)(function(e){let{expanded:t,matches:n,menu:i,onSearchQueryChange:r,onSearchQueryClear:l,onStoryClick:a,query:o}=e,s=(0,ts.useMemo)(()=>t?["block"]:["none","none","block"],[t]);return(0,td.jsx)(oM,{display:s,flex:1,children:(0,td.jsxs)(tp.kC,{direction:"column",height:"fill",children:[(0,td.jsx)(tp.mh,{style:oR,children:(0,td.jsx)(tp.Zb,{padding:2,shadow:1,style:oA,children:(0,td.jsx)(tp.oi,{border:!1,clearButton:!!o,fontSize:oO,icon:to.W1M,onChange:r,onClear:l,padding:2,placeholder:"Stories",radius:2,space:2,value:o})})}),(0,td.jsxs)(tp.Zb,{flex:1,overflow:"auto",children:[o&&n.length>0&&(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(oI,{matches:n,onStoryClick:a})}),!o&&"list"===i.type&&(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(oS,{items:i.items})})]})]})})});var oN=Object.freeze,o$=Object.defineProperty;let oZ=th.ZP.iframe(eI||(eI=oN(o$(j=["\n display: block;\n border: 0;\n height: 100%;\n width: 100%;\n"],"raw",{value:oN(j.slice())})))),oU=(0,ts.memo)(function(e){let{frameRef:t,hidden:n}=e,{frameReady:i,frameUrl:r,path:l,payload:a,scheme:o,title:s,viewport:d,zoom:c}=useWorkshop(),u=aV.find(e=>e.name===d)||aV[0],p=null==u?void 0:u.rect.width,h=null==u?void 0:u.rect.height,[m]=(0,ts.useState)(()=>buildFrameUrl({baseUrl:r,path:l,payload:a,scheme:o,viewport:d,zoom:c})),f=(0,ts.useMemo)(()=>({maxWidth:"auto"===p?void 0:"".concat((p||1)*c,"px"),maxHeight:h?"".concat((h||1)*c,"px"):void 0}),[p,h,c]),g=(0,ts.useMemo)(()=>n?"none":"block",[n]),x=(0,ts.useMemo)(()=>({transform:"scale(".concat(c,")"),transformOrigin:"0 0",width:"".concat(100/c,"%"),height:"".concat(100/c,"%")}),[c]);return(0,td.jsx)(tp.Zb,{display:g,flex:1,overflow:"hidden",tone:"transparent",children:(0,td.jsxs)(tp.kC,{align:"center",height:"fill",justify:"center",sizing:"border",children:["/"===l&&(0,td.jsx)(tp.W2,{width:0,children:(0,td.jsxs)(tp.Kq,{padding:4,space:4,children:[(0,td.jsx)(tp.X6,{align:"center",children:s}),(0,td.jsx)(tp.xv,{align:"center",muted:!0,children:"Browse workshop stories in the navigator to the left."})]})}),!i&&"/"!==l&&(0,td.jsx)(tp.$j,{muted:!0}),(0,td.jsx)(tp.W2,{height:"fill",hidden:!i||"/"===l,style:f,width:"auto",children:(0,td.jsx)(tp.Zb,{height:"fill",shadow:1,children:(0,td.jsx)(oZ,{ref:t,src:m,style:x})})})]})})});function getStateFromLocation(e,t,n){let i=e.path,r=e.query||{},{scheme:l,viewport:a,zoom:o,...s}=r;return{frameReady:n||!1,path:i,payload:s,scheme:t||("string"==typeof l?l:"light"),viewport:"string"==typeof a?a:"auto",zoom:"number"==typeof o?o:1}}function getQueryFromState(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],{payload:n,scheme:i,viewport:r,zoom:l}=e,a={scheme:i};if(r&&"auto"!==r&&(a.viewport=r),l&&1!==l&&(a.zoom=l),t)for(let[e,t]of Object.entries(n))["schema","viewport","zoom"].includes(e)?console.warn('Workshop: the payload cannot contain a property named "'.concat(e,'" (protected name)')):a[e]=t;return a}function CreateNewThreadInput(e){let{currentUser:t,fieldName:n,mentionOptions:i,onBlur:r,onFocus:l,onKeyDown:a,onNewThreadCreate:o,readOnly:s}=e,[d,c]=(0,ts.useState)(aF),u=(0,ts.useRef)(null),p=(0,ts.useCallback)(()=>{null==o||o(d),c(aF)},[o,d]),h=(0,ts.useMemo)(()=>hasCommentMessageValue(d),[d]),m=(0,ts.useCallback)(()=>{var e;h&&(null==(e=u.current)||e.discardDialogController.open())},[h]),f=(0,ts.useCallback)(e=>{!e.isDefaultPrevented()&&("Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),m()),a&&a(e))},[a,m]),g=(0,ts.useCallback)(()=>{var e,t;c(aF),null==(e=u.current)||e.discardDialogController.close(),null==(t=u.current)||t.focus()},[]),x=(0,ts.useCallback)(()=>{var e;null==(e=u.current)||e.discardDialogController.close()},[]),b=(0,td.jsxs)(td.Fragment,{children:["Add comment to ",(0,td.jsx)("b",{children:n})]});return(0,td.jsx)(rY,{currentUser:t,expandOnFocus:!0,mentionOptions:i,onBlur:r,onChange:c,onDiscardCancel:x,onDiscardConfirm:g,onKeyDown:f,onFocus:l,onSubmit:p,placeholder:b,readOnly:s,ref:u,value:d})}(0,ts.memo)(function(e){var t,n;let{config:i,locationStore:r,onSchemeChange:l,scheme:a}=e,o=null==(n=null==(t=i.features)?void 0:t.navbar)||n,s=(0,ts.useMemo)(()=>createPubsub(),[]),d=(0,ts.useMemo)(()=>(function(){let e=new Set,t=null,n=[],i=null;function _handleMessage(t){let n=t.data;if(isArray(n)){for(let t of n)if(isRecord(t)&&"string"==typeof t.type&&t.type.startsWith("workshop/"))for(let n of e)n(t)}}return{message:{publish(e){n.push(e),i&&clearInterval(i),i=setTimeout(()=>{var e;null==(e=null==t?void 0:t.contentWindow)||e.postMessage(n,window.location.origin),n=[],i=null},0)},subscribe:t=>(e.add(t),()=>{e.delete(t)})},setElement(e){let n=t;(t=e,e)?(null==t?void 0:t.contentWindow)&&window.addEventListener("message",_handleMessage):n&&(null==n?void 0:n.contentWindow)&&window.removeEventListener("message",_handleMessage)}}})(),[]),[c,u]=(0,ts.useState)(null),[p,h]=(0,ts.useState)(null),[{frameReady:m,path:f,payload:g,scheme:x,viewport:b,zoom:v},_]=(0,ts.useState)(()=>getStateFromLocation(r.get(),a)),y=(0,tp.d2)(),[j,w]=(0,ts.useState)(!1),[k,C]=(0,ts.useState)(!1),I=(0,ts.useRef)(m),S=(0,ts.useRef)(x),z=(0,ts.useRef)(f),P=(0,ts.useRef)({scheme:x,viewport:b,zoom:v,...g}),E=(0,ts.useCallback)(e=>{s.publish(e),d.message.publish(e)},[s,d]),D=(0,ts.useMemo)(()=>
1og(e=>r.push(e),150),[r]),T=(0,ts.useMemo)(()=>og(e=>r.replace(e),150),[r]),M=(0,ts.useCallback)(()=>{w(e=>!e),C(!1)},[]),R=(0,ts.useCallback)(()=>{w(!1),C(e=>!e)},[]),A=(0,ts.useRef)(y);return((0,ts.useEffect)(()=>{let e=A.current;e<2&&y>=2&&(w(!1),C(!1)),A.current=y},[y]),(0,ts.useEffect)(()=>{w(!1)},[f]),(0,ts.useEffect)(()=>()=>D.cancel(),[D]),(0,ts.useEffect)(()=>()=>T.cancel(),[T]),(0,ts.useEffect)(()=>s.subscribe(e=>{_(t=>{let n=workshopReducer(t,e),i=!a1(t,n);if(i){if("workshop/setPath"===e.type){if(z.current!==n.path){z.current=n.path;let e=getQueryFromState(n,!1);D({path:n.path,query:e})}}else if("workshop/setState"!==e.type){let e=getQueryFromState(n);a1(P.current,e)||(P.current=e,T({path:n.path,query:e}))}}return i?n:t})}),[D,T,s,r]),(0,ts.useEffect)(()=>d.message.subscribe(s.publish),[s,d]),(0,ts.useEffect)(()=>{I.current=m},[m]),(0,ts.useEffect)(()=>r.subscribe(e=>{let t=getStateFromLocation(e,void 0,m);E({type:"workshop/setState",value:t})}),[E,m,r]),(0,ts.useEffect)(()=>{S.current=x,l(x)},[l,x]),(0,ts.useEffect)(()=>{a&&S.current!==a&&(S.current=a,E({type:"workshop/setScheme",value:a}))},[E,a]),i.scopes)?(0,td.jsx)(a8,{config:i,broadcast:E,channel:s,frameReady:m,origin:"main",path:f,payload:g,scheme:x,viewport:b,zoom:v,children:(0,td.jsx)(tp.VW,{children:(0,td.jsx)(tp.NM,{element:c,children:(0,td.jsx)(tp.Xp,{element:p,children:(0,td.jsxs)(tp.kC,{"data-boundary":"",direction:"column",height:"fill",ref:u,style:{minWidth:320},children:[o&&(0,td.jsx)(oC,{inspectorExpanded:k,navigatorExpanded:j,onInspectorToggle:R,onNavigatorToggle:M}),(0,td.jsxs)(tp.kC,{flex:1,children:[(0,td.jsx)(oL,{collections:i.collections,expanded:j}),(0,td.jsx)(oU,{frameRef:d.setElement,hidden:j||k}),(0,td.jsx)(of,{expanded:k})]}),(0,td.jsx)("div",{"data-portal":"",ref:h})]})})})})}):(0,td.jsx)(td.Fragment,{children:"No scopes"})});var oF=Object.freeze,oH=Object.defineProperty,__template$n=(e,t)=>oF(oH(e,"raw",{value:oF(t||e.slice())}));let oV=(0,th.ZP)(tp.kC)(eS||(eS=__template$n(["\n min-height: 25px;\n"]))),oq=(0,th.ZP)(tp.zx)(e=>{let{theme:t}=e,n=t.sanity.color.base.fg;return(0,th.iv)(ez||(ez=__template$n(["\n --card-fg-color: ",";\n\n // The width is needed to make the text ellipsis work\n // in the breadcrumbs component\n max-width: 100%;\n "])),n)});function CommentThreadLayout(e){let{breadcrumbs:t,canCreateNewThread:n,children:i,currentUser:r,fieldPath:l,isSelected:a,mentionOptions:o,onNewThreadCreate:s,onPathSelect:d,readOnly:c}=e,u=(0,ts.useCallback)(e=>{let t={fieldPath:l,message:e,parentCommentId:void 0,status:"open",threadId:(0,t3.Z)()};null==s||s(t)},[s,l]),p=(0,ts.useCallback)(e=>{e.stopPropagation(),null==d||d({fieldPath:l,origin:"inspector",threadId:null})},[l,d]),h=(0,ts.useCallback)(e=>{e.stopPropagation(),0!==e.detail&&(null==d||d({fieldPath:l,origin:"inspector",threadId:null}))},[l,d]),m=(0,ts.useMemo)(()=>(null==t?void 0:t.map(e=>e.title))||[],[t]),f=m[m.length-1];return(0,td.jsxs)(tp.Kq,{space:2,children:[(0,td.jsx)(oV,{align:"center",gap:2,paddingRight:1,sizing:"border",children:(0,td.jsx)(tp.Kq,{flex:1,children:(0,td.jsx)(tp.kC,{align:"center",children:(0,td.jsx)(oq,{"aria-label":"Go to ".concat(f," field"),mode:"bleed",onClick:p,padding:2,children:(0,td.jsx)(CommentBreadcrumbs,{maxLength:3,titlePath:m})})})})}),n&&(0,td.jsx)(ls,{onClick:h,tone:a?"primary":void 0,children:(0,td.jsx)(CreateNewThreadInput,{currentUser:r,fieldName:f,mentionOptions:o,onNewThreadCreate:u,readOnly:c})}),(0,td.jsx)(tp.Kq,{space:2,children:i})]})}let oW={open:{title:"No open comments yet",message:(0,td.jsxs)("span",{children:["Open comments on this document ",(0,td.jsx)("br",{}),"will be shown here."]})},resolved:{title:"No resolved comments yet",message:(0,td.jsxs)(td.Fragment,{children:["Resolved comments on this document ",(0,td.jsx)("br",{}),"will be shown here."]})}};function CommentsListStatus(e){let{status:t,error:n,loading:i,hasNoComments:r}=e;return n?(0,td.jsx)(tp.kC,{align:"center",justify:"center",flex:1,padding:4,children:(0,td.jsx)(tp.kC,{align:"center",children:(0,td.jsx)(tp.xv,{size:1,muted:!0,children:"Something went wrong"})})}):i?(0,td.jsx)(tp.kC,{align:"center",justify:"center",flex:1,padding:4,children:(0,td.jsxs)(tp.kC,{align:"center",gap:2,children:[(0,td.jsx)(tp.$j,{muted:!0,size:1}),(0,td.jsx)(tp.xv,{size:1,muted:!0,children:"Loading comments..."})]})}):r?(0,td.jsx)(tp.kC,{align:"center",justify:"center",flex:1,sizing:"border",children:(0,td.jsx)(tp.W2,{width:0,padding:4,children:(0,td.jsxs)(tp.Kq,{space:3,children:[(0,td.jsx)(tp.xv,{align:"center",size:1,muted:!0,weight:"semibold",children:oW[t].title}),(0,td.jsx)(tp.xv,{align:"center",size:1,muted:!0,children:oW[t].message})]})})}):null}let oG={behavior:"smooth",block:"start",inline:"nearest"}
1,oK=(0,ts.forwardRef)(function(e,t){let{comments:n,currentUser:i,error:r,loading:l,mentionOptions:a,onCopyLink:o,onCreateRetry:s,onDelete:d,onEdit:c,onNewThreadCreate:u,onPathSelect:p,onReply:h,onStatusChange:m,readOnly:f,selectedPath:g,status:x}=e,[b,v]=(0,ts.useState)(null),_=(0,ts.useCallback)(e=>{let t=null==document?void 0:document.querySelector('[data-comment-id="'.concat(e,'"]'));t&&t.scrollIntoView(oG)},[]);(0,ts.useImperativeHandle)(t,()=>({scrollToComment:_}),[_]);let y=(0,ts.useMemo)(()=>Object.entries(n.reduce((e,t)=>{let n=t.fieldPath;return e[n]||(e[n]=[]),e[n].push(t),e},{})),[n]),j=!l&&!r&&y.length>0;return(0,td.jsxs)(tp.kC,{direction:"column",flex:1,height:"fill",overflow:"hidden",ref:v,sizing:"border",children:[(0,td.jsx)(CommentsListStatus,{error:r,hasNoComments:0===y.length,loading:l,status:x}),j&&(0,td.jsx)(tp.Kq,{as:"ul",flex:1,overflow:"auto",padding:3,paddingTop:1,paddingBottom:6,sizing:"border",space:1,children:(0,td.jsx)(tp.NM,{element:b,children:null==y?void 0:y.map(e=>{let[t,n]=e,r=n[0].breadcrumbs,l=n[0].threadId,b=(null==g?void 0:g.fieldPath)===t&&!g.threadId;return(0,td.jsx)(tp.Kq,{as:"li","data-group-id":l,paddingTop:3,children:(0,td.jsx)(CommentThreadLayout,{breadcrumbs:r,canCreateNewThread:"open"===x,currentUser:i,fieldPath:t,isSelected:b,mentionOptions:a,onNewThreadCreate:u,onPathSelect:p,readOnly:f,children:n.map(e=>{var t,n;let r=e.replies.slice().reverse(),l="open"===x&&(null==(t=e.parentComment._state)?void 0:t.type)!=="createError"&&(null==(n=e.parentComment._state)?void 0:n.type)!=="createRetrying",u=(null==g?void 0:g.threadId)===e.parentComment.threadId&&(null==g?void 0:g.fieldPath)===e.parentComment.target.path.field;return(0,td.jsx)(lf,{canReply:l,currentUser:i,isSelected:u,mentionOptions:a,onCopyLink:o,onCreateRetry:s,onDelete:d,onEdit:c,onPathSelect:p,onReply:h,onStatusChange:m,parentComment:e.parentComment,readOnly:f,replies:r},e.parentComment._id)})},t)},t)})})})]})}),oY=ts.memo(oK),oX={thread:{title:"Delete this comment thread?",body:"This comment and its replies will be deleted, and once deleted cannot be recovered.",confirmButtonText:"Delete thread"},comment:{title:"Delete this comment?",body:"Once deleted, a comment cannot be recovered.",confirmButtonText:"Delete comment"}};function CommentDeleteDialog(e){let{isParent:t,onClose:n,commentId:i,onConfirm:r,loading:l,error:a}=e,{title:o,body:s,confirmButtonText:d}=oX[t?"thread":"comment"],c=(0,ts.useCallback)(()=>{r(i)},[i,r]);return(0,td.jsx)(tp.Vq,{header:o,id:"delete-comment-dialog",onClose:n,width:0,footer:(0,td.jsxs)(tp.rj,{columns:2,padding:2,gap:2,children:[(0,td.jsx)(tp.zx,{text:"Cancel",mode:"ghost",onClick:n}),(0,td.jsx)(tp.zx,{loading:l,onClick:c,text:d,tone:"critical"})]}),children:(0,td.jsxs)(tp.Kq,{padding:4,space:4,children:[(0,td.jsx)(tp.xv,{children:s}),a&&(0,td.jsx)(tc.LPT,{tone:"critical",children:"An error occurred while deleting the comment. Please try again."})]})})}var oQ=Object.freeze,oJ=Object.defineProperty,__template$m=(e,t)=>oQ(oJ(e,"raw",{value:oQ(t||e.slice())}));let o0=(0,th.ZP)(tp.xu)(eP||(eP=__template$m(["\n max-width: 280px;\n"]))),o1=(0,th.F4)(eE||(eE=__template$m(["\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n"]))),o2=(0,th.ZP)(tp.J2)(eD||(eD=__template$m(["\n opacity: 0;\n // Fade in the popover after 500ms\n animation: "," 200ms 500ms forwards;\n"])),o1);function CommentsOnboardingPopover(e){let{onDismiss:t}=e;return(0,td.jsx)(o2,{content:(0,td.jsx)(o0,{padding:4,children:(0,td.jsxs)(tp.Kq,{space:3,children:[(0,td.jsx)(tp.xv,{weight:"semibold",size:1,children:"Document fields now have comments"}),(0,td.jsx)(tp.xv,{size:1,children:"You can add comments to any field in a document. They'll show up here, grouped by field."}),(0,td.jsx)(tp.kC,{justify:"flex-end",marginTop:2,children:(0,td.jsx)(tp.zx,{fontSize:1,padding:2,text:"Got it",tone:"primary",onClick:t})})]})}),open:!0,portal:!0,...e})}let o5=(0,ts.createContext)(null),o3=new Map;async function matchesFilter(e,t,n){o3.has(t)||o3.set(t,(0,nc.Qc)("*[".concat(t,"]")));let i=o3.get(t),r=function(e){let t={};return null!==e&&(t.identity=e.id),t}(e),{identity:l}=r,a={...r},o=await (await (0,nu.m)(i,{dataset:[n],identity:l,params:a})).get();return(null==o?void 0:o.length)===1}async function grantsPermissionOn(e,t,n,i){if(!i)return{granted:!0,reason:"Null document, nothing to check"};
1if(!t.length)return{granted:!1,reason:"No document grants"};let r=[];for(let n of t)await matchesFilter(e,n.filter,i)&&r.push(n);let l=r.some(e=>e.permissions.some(e=>e===n));return{granted:l,reason:l?"Matching grant":"No matching grants found"}}let o6={data:[],error:null,loading:!0},o8=null;function useComments(){let e=(0,ts.useContext)(o5);if(!e)throw Error("useComments must be used within a CommentsProvider");return e}let o4=(0,ts.createContext)(null),o9=ts.memo(function(e){let{children:t,documentId:n,documentType:i}=e,r=function(e,t){let{enabled:n,isLoading:i}=(0,tc.nhK)("studioComments"),{enabled:r}=(0,tc.Lky)().document.unstable_comments,l=(0,ts.useMemo)(()=>r({documentType:t,documentId:(0,tc.vsM)(e)}),[e,t,r]);return!i&&n&&l}(n,i);return(0,td.jsx)(o4.Provider,{value:r,children:t})});function useCommentsEnabled(){let e=(0,ts.useContext)(o4);if(null===e)throw Error("useCommentsEnabled: missing context value");return e}let o7=(0,ts.createContext)(null),se="sanityStudio:comments:inspector:onboarding:dismissed:v".concat(1),setLocalStorage=e=>{try{window.localStorage.setItem(se,JSON.stringify(e))}catch(e){}},getLocalStorage=()=>{try{let e=window.localStorage.getItem(se);return!!e&&JSON.parse(e)}catch(e){return!1}};function CommentsOnboardingProvider(e){let{children:t}=e,[n,i]=(0,ts.useState)(getLocalStorage()),r=(0,ts.useCallback)(()=>{i(!0),setLocalStorage(!0)},[i]),l=(0,ts.useMemo)(()=>({setDismissed:r,isDismissed:n}),[r,n]);return(0,td.jsx)(o7.Provider,{value:l,children:t})}function useCommentsSelectedPath(){let e=(0,ts.useContext)(sc);if(!e)throw Error("useCommentsSelectedPath: missing context value");return e}function commentsReducer(e,t){switch(t.type){case"COMMENTS_SET":{let n=function(e){let t=e.reduce((e,t)=>({...e,[t._id]:t}),{});return t}(t.comments);return{...e,comments:n}}case"COMMENT_ADDED":{let n=t.payload,i={[n._id]:{...e.comments[n._id],...n,_state:n._state||void 0,_createdAt:n._createdAt||new Date().toISOString()}},r=e.comments&&e.comments[n._id];if(r)return{...e,comments:{...e.comments,...i}};let l={...e.comments||{},...i};return{...e,comments:l}}case"COMMENT_RECEIVED":{let n=t.payload;return{...e,comments:{...e.comments,[n._id]:n}}}case"COMMENT_DELETED":{let{[t.id]:n,...i}=e.comments;
1return Object.keys(i).forEach(e=>{i[e].parentCommentId===t.id&&delete i[e]}),{...e,comments:i}}case"COMMENT_UPDATED":{let n=t.payload,i=n._id;return{...e,comments:{...e.comments,[i]:{...e.comments[i],...n}}}}default:return e}}let st={comments:{}},sn={events:["welcome","mutation","reconnect"],includeResult:!0,visibility:"query"},si="order(".concat("_createdAt"," ").concat("desc",")"),sr="*[".concat('_type == "comment" && target.document._ref == $documentId',"] ").concat("{\n _createdAt,\n _id,\n authorId,\n lastEditedAt,\n message,\n parentCommentId,\n status,\n target,\n threadId,\n}"," | ").concat(si),sl=[],sa={open:sl,resolved:sl},so=(0,ts.memo)(function(e){let{children:t,documentId:n,documentType:i,isCommentsOpen:r,onCommentsOpen:l}=e,[a,o]=(0,ts.useState)("open"),{client:s,runSetup:d,isRunningSetup:c}=function(){let e=(0,ts.useContext)(ss);if(!e)throw Error("useCommentsSetup: missing context value");return e}(),u=(0,tc.vsM)(n),p=(0,tc.iav)(u,i,"low"),h=(0,ts.useMemo)(()=>p.draft||p.published,[p.draft,p.published]),{dispatch:m,data:f=sl,error:g,loading:x}=function(e){let{client:t,documentId:n}=e,[i,r]=(0,ts.useReducer)(commentsReducer,st),[l,a]=(0,ts.useState)(null!==t),[o,s]=(0,ts.useState)(null),d=(0,ts.useMemo)(()=>({documentId:(0,tc.vsM)(n)}),[n]),c=(0,ts.useCallback)(async()=>{if(!t){a(!1);return}try{let e=await t.fetch(sr,d);r({type:"COMMENTS_SET",comments:e}),a(!1)}catch(e){s(e)}},[t,d]),u=(0,ts.useCallback)(async e=>{if("welcome"===e.type&&(a(!0),await c(),a(!1)),"reconnect"===e.type&&a(!0),"mutation"===e.type){if("appear"===e.transition){let t=e.result;t&&r({type:"COMMENT_RECEIVED",payload:t})}if("disappear"===e.transition&&r({type:"COMMENT_DELETED",id:e.documentId}),"update"===e.transition){let t=e.result;t&&r({type:"COMMENT_UPDATED",payload:t})}}},[c]),p=(0,ts.useMemo)(()=>{if(!t)return(0,tx.of)();let e=t.observable.listen(sr,d,sn).pipe((0,tw.K)(e=>(s(e),(0,tx.of)(e))));return e},[t,d]);(0,ts.useEffect)(()=>{let e=p.subscribe(u);return()=>{null==e||e.unsubscribe()}},[u,p]);let h=(0,ts.useMemo)(()=>Object.values(i.comments),[i.comments]);return{data:h,dispatch:r,error:o,loading:l}}({documentId:u,client:s}),b=function(e){let{documentValue:t}=e,n=(0,tc.iZE)(),i=(0,tc.LMB)(),r=(0,tc.m85)(tc.Dr7),[l,a]=(0,ts.useState)(o6),o=(0,ts.useMemo)(()=>{let e=n.get().pipe((0,tb.U)(e=>{var t;return null==(t=e.members)?void 0:t.filter(e=>!e.isRobot)})),l=e.pipe((0,tv.w)(async e=>{let t=e.map(e=>{let{id:t}=e;return t}),n=await i.getUsers(t);return n}),(0,tb.U)(e=>e.map(e=>({displayName:e.displayName,id:e.id,canBeMentioned:!1})))),a=o8,o=a?(0,tx.of)(a):r.observable.fetch('*[_type == "system.group"]'),s=(0,t_.D)([l,o]).pipe((0,ty.z)(async e=>{let[n,i]=e;a||(o8=i);let r=null==n?void 0:n.map(async e=>{let n=i.map(t=>t.members.includes(e.id)?t.grants:[]),r=[...n].flat(),{granted:l}=await grantsPermissionOn(e,r,"read",t);return{...e,canBeMentioned:l}}),l=await Promise.all(r||[]);return l})),d=s.pipe((0,tb.U)(e=>({error:null,loading:!1,data:nd()(e,"displayName")})));return d},[r.observable,t,n,i]);return(0,ts.useEffect)(()=>{let e=(0,tx.of)(o6),t=(0,tj.z)(e,o),n=t.subscribe(a);return()=>{n.unsubscribe()}},[o]),l}((0,ts.useMemo)(()=>({documentValue:h}),[h])),v=(0,tc.I_y)().get(i),_=(0,tc.xJ)(),{name:y,dataset:j,projectId:w}=(0,tc.cFj)(),k=(0,ts.useMemo)(()=>{if(!v||!_)return sa;let e=no()(f,["_createdAt"],["desc"]),t=function(e){let{comments:t,currentUser:n,documentValue:i,schemaType:r}=e,l=null==t?void 0:t.filter(e=>!e.parentCommentId),a=l.map(e=>{let l=function(e){let{currentUser:t,schemaType:n,fieldPath:i,documentValue:r}=e,l=tJ.mL(i),a=[],o=null;return l.forEach((e,i)=>{var s,d,c,u,p;let h=l.slice(0,i+1),m=l.slice(0,i),f=function getSchemaField(e,t){var n;let i=tJ.mL(t),r=i[0];if(r&&(0,tu.m$)(e)){let t=null==(n=null==e?void 0:e.fields)?void 0:n.find(e=>e.name===r);if(t){let e=tJ.BB(i.slice(1));return e?getSchemaField(t.type,e):t}}}(n,tJ.BB(h)),g=e.hasOwnProperty("_key"),x=(0,tc.PtK)(r,m),b=(0,tc.PtK)(r,h),v={document:r,currentUser:t,parent:x,value:b};if(g&&Array.isArray(x)){let t=function(e,t){if("number"==typeof t)return t;let n=nh()(e,t);return -1!==n&&n}(x,e);a.push({invalid:!1===t,isArrayItem:!0,title:"number"==typeof t?"#".concat(Number(t)+1):"Unknown array item"});return}if(null==f?void 0:f.type){let e=(0,tc.ZCh)(f.type.hidden,v);a.push({invalid:e,isArrayItem:!1,title:(0,tc.EZo)(f.type)}),o=f.type;return}if((0,tu.jB)(o)){let t=(0,tc.PtK)(r,m),n=null==t?void 0:t._type,i=null==(s=null==o?void 0:o.of)?void 0:s.find(e=>e.name===n),l=null==(d=null==i?void 0:i.fields)?void 0:d.find(t=>t.name===e);if(!n&&b){let t=null==(c=null==o?void 0:o.of)?void 0:c.map(e=>
1null==e?void 0:e.fields).filter(Boolean).flat(),n=null==t?void 0:t.find(t=>(null==t?void 0:t.name)===e),i=(0,tc.ZCh)(null==(u=null==n?void 0:n.type)?void 0:u.hidden,v);n&&(a.push({invalid:i,isArrayItem:!1,title:(0,tc.EZo)(null==n?void 0:n.type)}),o=null==n?void 0:n.type);return}if(!l){a.push({invalid:!0,isArrayItem:!1,title:"Unknown field"});return}let h=(0,tc.EZo)(null==l?void 0:l.type),f=(0,tc.ZCh)(null==(p=null==i?void 0:i.type)?void 0:p.hidden,v),g=(0,tc.ZCh)(null==l?void 0:l.type.hidden,v);a.push({invalid:f||g,isArrayItem:!1,title:h}),o=null==l?void 0:l.type;return}a.push({invalid:!0,isArrayItem:!1,title:"Unknown field"})}),a}({currentUser:n,documentValue:i,fieldPath:e.target.path.field,schemaType:r}),a=l.some(e=>e.invalid);if(a)return;let o=null==t?void 0:t.filter(t=>t.parentCommentId===e._id),s=[e,...o].length;return{breadcrumbs:l,commentsCount:s,fieldPath:e.target.path.field,parentComment:e,replies:o,threadId:e.threadId}}).filter(Boolean);return a}({comments:e,schemaType:v,currentUser:_,documentValue:h});return{open:t.filter(e=>"open"===e.parentComment.status),resolved:t.filter(e=>"resolved"===e.parentComment.status)}},[_,f,h,v]),C=(0,ts.useCallback)(e=>k.open.filter(t=>t.threadId===e).length,[k.open]),I=(0,ts.useCallback)(e=>null==f?void 0:f.find(t=>t._id===e),[f]),S=(0,ts.useCallback)(async e=>{var t,n;let i=(null==(n=null==(t=null==f?void 0:f.find(t=>t._id===e._id))?void 0:t._state)?void 0:n.type)==="createError";m({type:"COMMENT_ADDED",payload:{...e,_state:i?{type:"createRetrying"}:void 0}})},[f,m]),z=(0,ts.useCallback)((e,t)=>{m({type:"COMMENT_UPDATED",payload:{_id:e,...t}})},[m]),P=(0,ts.useCallback)((e,t)=>{m({type:"COMMENT_UPDATED",payload:{_id:e,...t}})},[m]),E=(0,ts.useCallback)((e,t)=>{m({type:"COMMENT_UPDATED",payload:{_id:e,_state:{error:t,type:"createError"}}})},[m]),{operation:D}=function(e){let{client:t,currentUser:n,dataset:i,documentId:r,documentType:l,getThreadLength:a,onCreate:o,onCreateError:s,onEdit:d,onRemove:c,onUpdate:u,projectId:p,runSetup:h,workspace:m}=e,f=null==n?void 0:n.id,g=(0,tY.z)((0,ts.useCallback)(e=>"string"==typeof e.tool?e.tool:void 0,[])),{tools:x}=(0,tc.cFj)(),b=(0,ts.useMemo)(()=>x.find(e=>e.name===g),[g,x]),{getNotificationValue:v}=function(e){let{documentId:t,documentType:n}=e||{},i=(0,tc.I_y)().get(n),{title:r}=(0,tc.cFj)(),{createPathWithParams:l,params:a}=usePaneRouter(),o=(0,tc.rq_)(),s=(0,tK.m2)(()=>t&&i?(0,tc.eLL)(o,i,t,""):(0,tx.of)(null),[t,o,i]),{published:d,draft:c}=s||{},u=(null==c?void 0:c.title)||(null==d?void 0:d.title)||"Sanity document",p=(0,ts.useCallback)(e=>{let{commentId:t}=e,n=l({...a,comment:t,inspect:i4}),i="".concat(window.location.origin).concat(n);return{documentTitle:u,url:i,workspaceTitle:r}},[l,u,a,r]);return{getNotificationValue:p}}({documentId:r,documentType:l}),_=(0,ts.useCallback)(async e=>{let n=(null==e?void 0:e.id)||(0,t3.Z)(),d=((null==a?void 0:a(e.threadId))||0)+1,{documentTitle:c="",url:u="",workspaceTitle:g=""}=v({commentId:n})||{},x={_id:n,_type:"comment",authorId:f||"",lastEditedAt:void 0,message:e.message,parentCommentId:e.parentCommentId,status:e.status,threadId:e.threadId,context:{payload:{workspace:m},notification:{currentThreadLength:d,documentTitle:c,url:u,workspaceTitle:g},tool:(null==b?void 0:b.name)||""},target:{path:{field:e.fieldPath},document:{_dataset:i,_projectId:p,_ref:r,_type:"crossDatasetReference",_weak:!0},documentType:l}};if(null==o||o(x),!t){try{await h(x)}catch(e){throw null==s||s(x._id,e),e}return}try{await t.create(x)}catch(e){throw null==s||s(x._id,e),e}},[null==b?void 0:b.name,f,t,i,r,l,v,a,o,s,p,h,m]),y=(0,ts.useCallback)(async e=>{t&&(null==c||c(e),await Promise.all([t.delete({query:'*[_type == "comment" && parentCommentId == "'.concat(e,'"]')}),t.delete(e)]))},[t,c]),j=(0,ts.useCallback)(async(e,n)=>{if(!t)return;let i={message:n.message,lastEditedAt:new Date().toISOString()};null==d||d(e,i),await t.patch(e).set(i).commit()},[t,d]),w=(0,ts.useCallback)(async(e,n)=>{if(t){if(null==u||u(e,n),n.status){await Promise.all([t.patch({query:'*[_type == "comment" && parentCommentId == "'.concat(e,'"]')}).set({status:n.status}).commit(),t.patch(e).set(n).commit()]);return}await (null==t?void 0:t.patch(e).set(n).commit())}},[t,u]),k=(0,ts.useMemo)(()=>({create:_,edit:j,remove:y,update:w}),[_,y,j,w]);return{operation:k}}((0,ts.useMemo)(()=>({client:s,currentUser:_,dataset:j,documentId:u,documentType:i,projectId:w,schemaType:v,workspace:y,getThreadLength:C,runSetup:d,onCreate:S,onCreateError:E,onEdit:P,onUpdate:z}),[s,_,j,u,i,w,v,y,C,d,S,E,P,z])),T=(0,ts.useMemo)(()=>({isRunningSetup:c,status:a,setStatus:o,getComment:I,isCommentsOpen:r,onCommentsOpen:l,comments:{data:k,error:g,loading:x||c},create:{execute:D.create},remove:{execute:D.remove},edit:{execute:D.edit},update:{execute:D.update},mentionOptions:b}),[g,I,r,c,x,b,l,D.create,D.edit,D.remove,D.update,a,k]);return(0,td.jsx)(o5.Provider,{value:T,children:t})}),ss=(0,ts.createContext)(null),sd="v2023-11-13";function CommentsSetupProvider(e){let{children:t}=e,{dataset:n,projectId:i}=(0,tc.cFj)(),r=(0,tc.m85)(tc.Dr7),[l,a]=(0,ts.useState)(null),[o,s]=(0,ts.useState)(!1),d=(0,ts.useCallback)(async()=>{var e;let t=await r.withConfig({apiVersion:sd}).request({uri:"/projects/".concat(i,"/datasets?datasetProfile=comments&addonFor=").concat(n),tag:"sanity.studio"});return null==(e=null==t?void 0:t[0])?void 0:e.name},[n,r,i]),c=(0,ts.useCallback)(e=>{let t=r.withConfig({apiVersion:sd,dataset:e,projectId:i,requestTagPrefix:"sanity.studio",useCdn:!1,withCredentials:!0});return t},[r,i]),u=(0,ts.useCallback)(async e=>{s(!0);try{let t=await d();if(t){let n=c(t);a(n),await n.create(e),s(!1);return}}catch(e){}try{let t=await r.withConfig({apiVersion:sd}).request({uri:"/comments/".concat(n,"/setup"),method:"POST"}),i=null==t?void 0:t.datasetName;if(!i){s(!1);return}let l=c(i);a(l),await l.create(e)}catch(e){throw e}finally{s(!1)}},[n,d,c,r]);(0,ts.useEffect)(()=>{d().then(e=>{if(!e)return;let t=c(e);a(t)})},[d,c]);let p=(0,ts.useMemo)(()=>({client:l,runSetup:u,isRunningSetup:o}),[l,u,o]);return(0,td.jsx)(ss.Provider,{value:p,children:t})}let sc=(0,ts.createContext)(null),su=ts.memo(function(e){let{children:t}=e,[n,i]=(0,ts.useState)(null),r=(0,ts.useCallback)(e=>{i(e)},[]),l=(0,ts.useMemo)(()=>({selectedPath:n,setSelectedPath:r}),[n,r]);return(0,td.jsx)(sc.Provider,{value:l,children:t})}),sp=(0,th.ZP)(tp.Zb)({position:"relative",zIndex:1,lineHeight:0,"&:after":{content:'""',dis
1play:"block",position:"absolute",left:0,bottom:-1,right:0,borderBottom:"1px solid var(--card-border-color)",opacity:.5}}),sh=(0,ts.forwardRef)(function(e,t){let{onClose:n,onViewChange:i,view:r}=e,l=(0,ts.useCallback)(()=>i("open"),[i]),a=(0,ts.useCallback)(()=>i("resolved"),[i]);return(0,td.jsx)(sp,{ref:t,children:(0,td.jsxs)(tp.kC,{padding:2,children:[(0,td.jsxs)(tp.kC,{align:"center",flex:1,gap:2,paddingY:2,padding:3,children:[(0,td.jsx)(tp.xv,{as:"h1",size:1,weight:"semibold",children:"Comments"}),(0,td.jsx)(tc.vwM,{})]}),(0,td.jsxs)(tp.kC,{flex:"none",padding:1,gap:2,children:[(0,td.jsx)(tp.j2,{id:"comment-status-menu-button",button:(0,td.jsx)(tp.zx,{text:nf()(r),fontSize:1,padding:2,mode:"bleed",iconRight:to.v4q,space:2}),menu:(0,td.jsxs)(tp.v2,{style:{width:"180px"},children:[(0,td.jsx)(tp.sN,{fontSize:1,iconRight:"open"===r?to.KML:void 0,onClick:l,text:"Open comments"}),(0,td.jsx)(tp.sN,{fontSize:1,iconRight:"resolved"===r?to.KML:void 0,onClick:a,text:"Resolved comments"})]}),popover:{placement:"bottom-end"}}),(0,td.jsx)(tp.zx,{"aria-label":"Close comments",fontSize:1,icon:to.hZl,mode:"bleed",onClick:n,padding:2})]})]})})});var sm=Object.freeze,sf=Object.defineProperty,__template$l=(e,t)=>sm(sf(e,"raw",{value:sm(t||e.slice())}));let sg=th.ZP.span(eT||(eT=__template$l(["\n margin-right: 0.2em;\n"]))),sx=th.ZP.a(eM||(eM=__template$l(["\n white-space: nowrap;\n"]))),sb=(0,th.ZP)(tp.Zb)({position:"relative",zIndex:1,"&:after":{content:'""',display:"block",position:"absolute",left:0,top:-1,right:0,borderBottom:"1px solid var(--card-border-color)",opacity:.5}});function CommentsInspectorFeedbackFooter(){return(0,td.jsx)(sb,{padding:3,children:(0,td.jsxs)(tp.xv,{muted:!0,size:1,children:["Help improve comments."," ",(0,td.jsxs)(sx,{href:"https://snty.link/comments-beta-feedback",target:"_blank",rel:"noreferrer",children:[(0,td.jsx)(sg,{children:"Share your feedback "})," ",(0,td.jsx)(to.buG,{})]})]})})}var sv=Object.freeze,s_=Object.defineProperty;let sy=(0,th.ZP)(tp.mh)(eR||(eR=sv(s_(w=["\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n"],"raw",{value:sv(w.slice())}))));function CommentsInspectorInner(e){let{onClose:t}=e,[n,i]=(0,ts.useState)(!1),[r,l]=(0,ts.useState)(null),[a,o]=(0,ts.useState)(!1),[s,d]=(0,ts.useState)(null),c=(0,ts.useRef)(null),u=(0,ts.useRef)(null),p=(0,tc.xJ)(),{params:h,createPathWithParams:m,setParams:f}=usePaneRouter(),g=(0,tc.BoV)(h)||iG,x=(0,ts.useRef)(null==g?void 0:g.comment),b=(0,ts.useRef)(!1),v=(0,tp.pm)().push,{onPathOpen:_,ready:y}=useDocumentPane(),{isDismissed:j,setDismissed:w}=function(){let e=(0,ts.useContext)(o7);if(!e)throw Error("useCommentsOnboarding: missing context value");return e}(),{comments:k,create:C,edit:I,getComment:S,isRunningSetup:z,mentionOptions:P,remove:E,setStatus:D,status:T,update:M}=useComments(),{isTopLayer:R}=(0,tp.sJ)(),A=(0,ts.useMemo)(()=>k.data[T],[k,T]),O=(0,ts.useMemo)(()=>k.loading||!y,[k.loading,y]),{selectedPath:L,setSelectedPath:B}=useCommentsSelectedPath(),N=(0,ts.useCallback)(e=>{D(e),B(null)},[B,D]),$=(0,ts.useCallback)(()=>{t(),B(null)},[t,B]),Z=(0,ts.useCallback)(e=>{let t=m({...h,comment:e}),n="".concat(window.location.origin).concat(t);navigator.clipboard.writeText(n).then(()=>{v({closable:!0,status:"info",title:"Copied link to clipboard"})}).catch(()=>{v({closable:!0,status:"error",title:"Unable to copy link to clipboard"})})},[m,h,v]),U=(0,ts.useCallback)(e=>{let t=S(e);t&&C.execute({fieldPath:t.target.path.field,id:t._id,message:t.message,parentCommentId:t.parentCommentId,status:t.status,threadId:t.threadId})},[C,S]),F=(0,ts.useCallback)(()=>{a||(i(!1),l(null))},[a]),H=(0,ts.useCallback)(e=>{if(B(e),null==e?void 0:e.fieldPath){let t=tJ.mL(e.fieldPath);_(t)}},[_,B]),V=(0,ts.useCallback)(e=>{C.execute(e),B({fieldPath:e.fieldPath,origin:"inspector",threadId:e.threadId})},[C,B]),q=(0,ts.useCallback)(e=>{C.execute(e)},[C]),W=(0,ts.useCallback)((e,t)=>{I.execute(e,t)},[I]),G=(0,ts.useCallback)(e=>{var t;let n=A.find(t=>{var n;return(null==(n=t.parentComment)?void 0:n._id)===e}),r=!!(n&&(null==(t=null==n?void 0:n.replies)?void 0:t.length)>0);i(!0),l({commentId:e,isParent:r})},[A]),K=(0,ts.useCallback)(async e=>{try{o(!0),await E.execute(e),F()}catch(e){d(e)}finally{o(!1)}},[F,E]),Y=(0,ts.useCallback)((e,t)=>{let n=S(e);n&&(B({fieldPath:n.target.path.field||null,origin:t||"inspector",threadId:n.threadId||null}),setTimeout(()=>{var t;null==(t=c.current)||t.scrollToComment(e)}))},[S,B]),X=(0,ts.useCallback)((e,t)=>{M.execute(e,{status:t}),"open"===t&&(D("open"),Y(e))},[Y,D,M]),Q=(0,ts.useCallback)(()=>{L&&R&&B(null)},[R,L,B]);return(0,tp.O8)(Q,[u.current]),(0,ts.useEffect)(()=>{let e=S(x.current||"");!O&&e&&!1===b.current&&(D(e.status||"open"),Y(e._id,"url"),b.current=!0,x.current=void 0,f({...h,comment:void 0}))},[S,Y,O,h,f,D]),(0,td.jsxs)(ts.Fragment,{children:[r&&n&&(0,td.jsx)(CommentDeleteDialog,{...r,error:s,loading:a,onClose:F,onConfirm:K}),(0,td.jsxs)(tp.kC,{direction:"column",flex:1,height:"fill",onClick:Q,overflow:"hidden",ref:u,children:[(0,td.jsx)(CommentsOnboardingPopover,{onDismiss:w,open:!j,placement:"left-start",children:(0,td.jsx)(sh,{onClose:$,onViewChange:N,view:T})}),p&&(0,td.jsx)(oY,{comments:A,currentUser:p,error:k.error,loading:O,mentionOptions:P,onCopyLink:Z,onCreateRetry:U,onDelete:G,onEdit:W,onNewThreadCreate:V,onPathSelect:H,onReply:q,onStatusChange:X,readOnly:z,ref:c,selectedPath:L,status:T}),(0,td.jsx)(CommentsInspectorFeedbackFooter,{})]})]})}let sj=(0,tc.mbX)({name:i4,component:function(e){let t=useCommentsEnabled();return t?(0,td.jsx)(sy,{children:(0,td.jsx)(CommentsInspectorInner,{...e})}):null},useMenuItem:function(){let e=useCommentsEnabled();return{hidden:!e,icon:to.qtd,showAsAction:!0,title:"Comments"}}});var sw=Object.freeze,sk=Object.defineProperty,__template$j=(e,t)=>sw(sk(e,"raw",{value:sw(t||e.slice())}));let sC={open:500},sI=(0,th.ZP)(tp.xv)(eA||(eA=__template$j(["\n width: max-content;\n"]))),sS=(0,th.ZP)(tp.Kq)(eO||(eO=__template$j(["\n width: 320px;\n"])));
1function CommentsFieldButton(e){let{count:t,currentUser:n,fieldTitle:i,isRunningSetup:r,mentionOptions:l,onChange:a,onClick:o,onCommentAdd:s,onDiscard:d,onInputKeyDown:c,open:u,setOpen:p,value:h}=e,[m,f]=(0,ts.useState)(null),[g,x]=(0,ts.useState)(null),b=(0,ts.useRef)(null),v=(0,ts.useCallback)(()=>{u&&(p(!1),null==g||g.focus())},[g,u,p]),_=(0,ts.useCallback)(()=>{s(),v()},[v,s]),y=(0,ts.useMemo)(()=>hasCommentMessageValue(h),[h]),j=(0,ts.useCallback)(()=>{var e;if(!y){v();return}null==(e=b.current)||e.discardDialogController.open()},[v,y]),w=(0,ts.useCallback)(e=>{!e.isDefaultPrevented()&&c&&c(e)},[c]),k=(0,ts.useCallback)(()=>{var e;null==(e=b.current)||e.discardDialogController.close()},[]),C=(0,ts.useCallback)(()=>{var e;null==(e=b.current)||e.discardDialogController.close(),v(),d()},[v,d]),I=(0,ts.useCallback)(e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),j())},[j]),S=(0,ts.useCallback)(()=>{u&&j()},[u,j]);if((0,tp.O8)(S,[m]),!(t>0)){let e=(0,td.jsxs)(td.Fragment,{children:["Add comment to ",(0,td.jsx)("b",{children:i})]}),t=(0,td.jsx)(sS,{padding:2,space:4,children:(0,td.jsx)(rY,{currentUser:n,focusLock:!0,focusOnMount:!0,mentionOptions:l,onChange:a,onDiscardCancel:k,onDiscardConfirm:C,onKeyDown:w,onSubmit:_,placeholder:e,readOnly:r,ref:b,value:h})});return(0,td.jsx)(tp.J2,{constrainSize:!0,content:t,fallbackPlacements:["bottom-end"],open:u,placement:"right-start",portal:!0,ref:f,onKeyDown:I,children:(0,td.jsx)("div",{children:(0,td.jsx)(tp.u,{delay:sC,disabled:u,portal:!0,placement:"top",content:(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{size:1,children:"Add comment"})}),children:(0,td.jsx)(tp.zx,{"aria-label":"Add comment",disabled:r,fontSize:1,icon:rw,mode:"bleed",onClick:o,padding:2,ref:x,selected:u})})})})}return(0,td.jsx)(tp.u,{portal:!0,placement:"top",content:(0,td.jsx)(tp.xu,{padding:2,sizing:"border",children:(0,td.jsxs)(sI,{size:1,children:["View comment",t>1?"s":""]})}),delay:sC,fallbackPlacements:["bottom"],children:(0,td.jsx)(tp.zx,{"aria-label":"Open comments",mode:"bleed",onClick:o,padding:2,children:(0,td.jsxs)(tp.kC,{align:"center",gap:2,children:[(0,td.jsx)(tp.xv,{size:1,children:(0,td.jsx)(rk,{})}),(0,td.jsx)(tp.xv,{size:0,children:t>9?"9+":t})]})})})}var sz=Object.freeze,sP=Object.defineProperty,__template$i=(e,t)=>sz(sP(e,"raw",{value:sz(t||e.slice())}));let sE={initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0}},sD={behavior:"smooth",block:"start"},sT=(0,th.ZP)(nx.E.div)(e=>{let{theme:t}=e,{radius:n,space:i,color:r}=t.sanity,l=nn.VG.blue[r.dark?900:50].hex;return(0,th.iv)(eL||(eL=__template$i(["\n mix-blend-mode: ",";\n border-radius: ","px;\n top: -","px;\n left: -","px;\n bottom: -","px;\n right: -","px;\n pointer-events: none;\n position: absolute;\n z-index: 1;\n width: calc(100% + ","px);\n height: calc(100% + ","px);\n background-color: ",";\n "])),r.dark?"screen":"multiply",n[3],i[2],i[2],i[2],i[2],2*i[2],2*i[2],l)}),sM=(0,th.ZP)(tp.Kq)(eB||(eB=__template$i(["\n position: relative;\n"])));function CommentFieldInner(e){let[t,n]=(0,ts.useState)(!1),[i,r]=(0,ts.useState)(null),l=(0,ts.useRef)(null),{element:a}=(0,tp.sz)(),o=(0,tc.xJ)(),{comments:s,create:d,isCommentsOpen:c,isRunningSetup:u,mentionOptions:p,onCommentsOpen:h,setStatus:m,status:f}=useComments(),{selectedPath:g,setSelectedPath:x}=useCommentsSelectedPath(),b=(0,ts.useMemo)(()=>(0,tc.EZo)(e.schemaType),[e.schemaType]),[v,_]=(0,ts.useState)(null),y=(0,ts.useMemo)(()=>!!c&&(null==g?void 0:g.origin)!=="form"&&(null==g?void 0:g.origin)!=="url"&&(null==g?void 0:g.fieldPath)===tJ.BB(e.path),[c,e.path,null==g?void 0:g.fieldPath,null==g?void 0:g.origin]),j=(0,ts.useMemo)(()=>{let t=tJ.BB(e.path),n=s.data.open.map(e=>e.fieldPath===t?e.commentsCount:0).reduce((e,t)=>e+t,0);return n||0},[s.data.open,e.path]),w=j>0,k=(0,ts.useCallback)(t=>{x({threadId:t,origin:"form",fieldPath:tJ.BB(e.path)}),_(t)},[e.path,x]),C=(0,ts.useCallback)(()=>{var t;if(w){"resolved"===f&&m("open"),n(!1),null==h||h();let i=null==(t=s.data.open.find(t=>t.fieldPath===tJ.BB(e.path)))?void 0:t.threadId;i&&k(i);return}n(e=>!e)},[w,f,h,s.data.open,m,e.path,k]),I=(0,ts.useCallback)(()=>{if(i){let t=(0,t3.Z)(),n={fieldPath:tJ.BB(e.path),message:i,parentCommentId:void 0,status:"open",threadId:t};d.execute(n),null==h||h(),"resolved"===f&&m("open"),r(null),k(t)}},[d,k,h,e.path,m,f,i]),S=(0,ts.useCallback)(()=>r(null),[]),z=(0,ts.useMemo)(()=>({...sD,boundary:a,scrollMode:"if-needed",block:"start"}),[a]);(0,ts.useEffect)(()=>{y&&l.current&&c&&(0,ng.Z)(l.current,z)},[a,c,y,e.path,z]),(0,ts.useEffect)(()=>{if(c&&v){let e=document.querySelector('[data-group-id="'.concat(v,'"]'));e&&(e.scrollIntoView(sD),_(null))}},[c,v]);let P=(0,ts.useMemo)(()=>({button:o&&(0,td.jsx)(CommentsFieldButton,{count:Number(j),currentUser:o,fieldTitle:b,isRunningSetup:u,mentionOptions:p,onChange:r,onClick:C,onCommentAdd:I,onDiscard:S,open:t,setOpen:n,value:i}),hasComments:w,isAddingComment:t}),[o,j,b,p,C,I,S,t,i,u,w]);return(0,td.jsxs)(sM,{ref:l,children:[e.renderDefault({...e,__internal_comments:P}),(0,td.jsx)(nb.M,{children:y&&(0,td.jsx)(sT,{animate:"animate",exit:"exit",initial:"initial",variants:sE})})]})}function CommentsDocumentLayoutInner(e){let{documentId:t,documentType:n}=e,i=useCommentsEnabled(),{openInspector:r,inspector:l}=useDocumentPane(),a=(0,ts.useCallback)(()=>{(null==l?void 0:l.name)!==i4&&r(i4)},[null==l?void 0:l.name,r]);return i?(0,td.jsx)(so,{documentId:t,documentType:n,isCommentsOpen:(null==l?void 0:l.name)===i4,onCommentsOpen:a,children:(0,td.jsx)(su,{children:e.renderDefault(e)})}):e.renderDefault(e)}let sR=(0,tc.Cw0)({name:"sanity/desk/comments",document:{inspectors:[sj],components:{unstable_layout:function(e){let{documentId:t,documentType:n}=e;return(0,td.jsx)(o9,{documentId:t,documentType:n,children:(0,td.jsx)(CommentsDocumentLayoutInner,{...e})})}}},form:{components:{field:function(e){let t=useCommentsEnabled();return t?(0,td.jsx)(CommentFieldInner,{...e}):e.renderDefault(e)}}},studio:{components:{layout:function(e){return(0,td.jsx)(CommentsSetupProvider,{children:(0,td.jsx)(CommentsOnboardingProvider,{children:e.renderDefault(e)})})}}}}),sA="sanityStudio:desk:renameDismissed",sO=(()=>{if("undefined"==typeof localStorage)return!1;let e="lsCheck";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}})(),sL=(0,nS.h)("desk-is-now-structure");function DeskRenameToolMenuButtonPopover(e){let{children:t}=e,[n,i]=(0,ts.useState)(void 0),{showOnboarding:r,dismissOnboarding:l}=function(){let[e,t]=(0,ts.useState)(()=>!function(){if(!sO)return!0;let e=localStorage.getItem(sA);return"1"===e}());(0,ts.useEffect)(()=>
1{if("undefined"==typeof window||!sO)return()=>{};function onStorageEvent(e){e.newValue!==e.oldValue&&e.key===sA&&t("1"!==e.newValue)}return window.addEventListener("storage",onStorageEvent),()=>{window.removeEventListener("storage",onStorageEvent)}},[]);let n=(0,ts.useCallback)(()=>{t(!1),sO&&localStorage.setItem(sA,"1")},[]);return{showOnboarding:e,dismissOnboarding:n}}(),a=(0,ts.useCallback)(e=>{let t=null==e?void 0:e.closest("[data-hidden]");i((null==t?void 0:t.getAttribute("data-hidden"))!=="true")},[]);return(0,td.jsx)("div",{ref:a,children:(0,td.jsx)(tp.J2,{content:(0,td.jsx)(DeskRenamedCard,{onDismiss:l}),fallbackPlacements:["top","bottom"],open:r&&n,placement:"bottom",portal:!0,tone:"default",width:0,children:(0,td.jsx)("span",{children:t})})})}function DeskRenamedCard(e){let t=(0,ts.useCallback)(e=>{e.stopPropagation()},[]);return(0,td.jsxs)(tp.Kq,{as:"section",padding:3,space:3,onClick:t,children:[(0,td.jsxs)(tp.Kq,{padding:2,space:4,children:[(0,td.jsx)(tp.kC,{gap:2,align:"center",children:(0,td.jsxs)(tp.xv,{as:"h1",size:1,weight:"semibold",children:[(0,td.jsx)("strong",{children:"Desk"})," is now ",(0,td.jsx)("strong",{children:"Structure"})]})}),(0,td.jsx)(tp.Kq,{space:3,children:(0,td.jsx)(tp.xv,{as:"p",muted:!0,size:1,children:"We've renamed this tool to better reflect its purpose alongside the new Presentation tool."})})]}),(0,td.jsxs)(tp.rj,{columns:2,gap:3,children:[(0,td.jsx)(tp.zx,{as:"a","data-as":"a",href:sL,icon:to.buG,target:"_blank",rel:"noreferrer",fontSize:1,padding:3,text:"Learn more",mode:"ghost"}),(0,td.jsx)(tp.zx,{fontSize:1,icon:to.KML,onClick:e.onDismiss,padding:3,text:"Got it",tone:"primary"})]})]})}let sB=(0,ts.createContext)(null);function useDeskTool(){let e=(0,ts.useContext)(sB);if(!e)throw Error("DeskTool: missing context value");return e}let sN={create:to.agZ,delete:to.XHJ,discardDraft:to.Two,initial:to.agZ,editDraft:to.dY8,editLive:to.dY8,publish:to.EI4,unpublish:to.xEY};function UserAvatarStack(e){let{maxLength:t,userIds:n}=e;return(0,td.jsx)(tp.Jh,{maxLength:t,children:n.map(e=>(0,td.jsx)(tc.YtX,{user:e,withTooltip:!0},e))})}var s$=Object.freeze,sZ=Object.defineProperty,__template$h=(e,t)=>s$(sZ(e,"raw",{value:s$(t||e.slice())}));let sU=(0,th.ZP)(tp.kC)(e=>{var t;let{theme:n}=e,i=null==(t=n.sanity.color.base.skeleton)?void 0:t.from;return(0,th.iv)(eN||(eN=__template$h(["\n --timeline-hairline-width: 1px;\n position: relative;\n z-index: 2;\n margin: 0;\n padding: 0;\n\n &::before {\n position: absolute;\n content: '';\n height: 100%;\n width: var(--timeline-hairline-width);\n background: ",";\n top: 0;\n left: calc((100% - var(--timeline-hairline-width)) / 2);\n z-index: 1;\n }\n "])),i)}),sF=(0,th.ZP)(tp.zx)(e=>{let{$selected:t,$disabled:n}=e;return(0,th.iv)(eU||(eU=__template$h(["\n position: relative;\n width: 100%;\n\n /* Line styling */\n &[data-first] ","::before {\n height: 50%;\n top: unset;\n bottom: 0;\n }\n\n &[data-last] ","::before {\n height: 50%;\n }\n\n ","\n\n ","\n "])),sU,sU,t&&(0,th.iv)(e$||(e$=__template$h(["\n ","::before {\n background: transparent;\n }\n "])),sU),n&&(0,th.iv)(eZ||(eZ=__template$h(["\n cursor: not-allowed;\n "]))))}),sH=(0,th.ZP)(tp.xu)(eF||(eF=__template$h(["\n background: var(--card-bg-color);\n border-radius: 50px;\n position: relative;\n z-index: 2;\n"]))),sV=(0,th.ZP)(tp.xu)(eH||(eH=__template$h(["\n min-width: 1rem;\n margin-left: ",";\n"])),e=>{let{theme:t}=e;return"-".concat((0,tp.hO)(t.sanity.space[1]))}),sq={initial:"timeline.operation.created-initial",create:"timeline.operation.created",publish:"timeline.operation.published",editLive:"timeline.operation.edited-live",editDraft:"timeline.operation.edited-draft",unpublish:"timeline.operation.unpublished",discardDraft:"timeline.operation.draft-discarded",delete:"timeline.operation.deleted"},sW={initial:"primary",create:"primary",publish:"positive",editLive:"caution",editDraft:"caution",unpublish:"critical",discardDraft:"critical",delete:"critical",withinSelection:"primary"};function TimelineItem(e){let{chunk:t,isFirst:n,isLast:i,isLatest:r,isSelected:l,onSelect:a,timestamp:o,type:s}=e,{t:d}=(0,tc.$G7)("studio"),c=sN[s],u=Array.from(t.authors),p="delete"!==s,h=(0,tc.P9l)({dateStyle:"medium",timeStyle:"short"}),m=(0,ts.useMemo)(()=>{let e=new Date(o),t=h.format(e);return t},[o,h]),f=(0,ts.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),p&&a(t)},[a,t,p]);return(0,td.jsx)(sF,{$selected:l,$disabled:!p,"data-chunk-id":t.id,"data-first":!!n||void 0,"data-last":!!i||void 0,"data-ui":"timelineItem",mode:l?"default":"bleed",onClick:f,padding:0,radius:2,tone:l?"primary":sW[t.type],children:(0,td.jsx)(tp.xu,{paddingX:2,children:(0,td.jsxs)(tp.kC,{align:"stretch",children:[(0,td.jsx)(sU,{align:"center",children:(0,td.jsx)(sH,{padding:2,children:(0,td.jsx)(tp.xv,{size:2,children:c&&(0,ts.createElement)(c)})})}),(0,td.jsxs)(tp.Kq,{space:2,margin:2,children:[r&&(0,td.jsx)(tp.kC,{children:(0,td.jsx)(tp.Zb,{padding:1,radius:2,shadow:1,tone:l?"primary":sW[t.type],children:(0,td.jsx)(tp.__,{muted:!0,size:0,children:d("timeline.latest")})})}),(0,td.jsx)(tp.xu,{children:(0,td.jsx)(tp.xv,{size:1,weight:"medium",children:d(sq[s])||(0,td.jsx)("code",{children:s})})}),(0,td.jsx)(sV,{paddingX:1,children:(0,td.jsx)(tp.xv,{as:"time",size:0,muted:!0,dateTime:o,children:m})})]}),(0,td.jsx)(tp.kC,{flex:1,justify:"flex-end",align:"center",children:(0,td.jsx)(UserAvatarStack,{maxLength:3,userIds:u})})]})})})}var sG=Object.freeze,sK=Object.defineProperty,__template$g=(e,t)=>sG(sK(e,"raw",{value:sG(t||e.slice())}));let sY=(0,th.ZP)(tp.Kq)(eV||(eV=__template$g(["\n max-width: 200px;\n"]))),sX=(0,th.ZP)(tp.kC)(eq||(eq=__template$g(["\n max-height: calc(100vh - 198px);\n min-width: 244px;\n"]))),sQ=(0,th.ZP)(tp.xu)(e=>{let{$visible:t}=e;return(0,th.iv)(eG||(eG=__template$g(["\n opacity: 0;\n pointer-events: none;\n\n ","\n "])),t&&(0,th.iv)(eW||(eW=__template$g(["\n opacity: 1;\n pointer-events: auto;\n "]))))}),Timeline=e=>{let{chunks:t,disabledBeforeFirstChunk:n,hasMoreChunks:i,lastChunk:r,onLoadMore:l,onSelect:a,firstChunk:o}
1=e,[s,d]=(0,ts.useState)(!1),{t:c}=(0,tc.$G7)("studio"),u=(0,ts.useMemo)(()=>t.filter(e=>!n||!o||e.index<o.index),[t,n,o]),p=(0,ts.useMemo)(()=>(null==r?void 0:r.id)?u.findIndex(e=>e.id===r.id):-1,[null==r?void 0:r.id,u]),h=(0,ts.useCallback)((e,t)=>{let{activeIndex:r}=t,l=0===r,o=u&&r===u.length-1||!1;return(0,td.jsxs)(tp.xu,{paddingBottom:o?1:0,paddingTop:l?1:0,paddingX:1,children:[(0,td.jsx)(TimelineItem,{chunk:e,isFirst:l,isLast:o,isLatest:0===r&&!n,isSelected:r===p,onSelect:a,timestamp:e.endTimestamp,type:e.type}),r===u.length-1&&i&&(0,td.jsx)(tp.kC,{align:"center",justify:"center",padding:4,children:(0,td.jsx)(tp.$j,{muted:!0})})]})},[n,u,i,a,p]);return(0,ts.useEffect)(()=>d(!0),[]),(0,td.jsxs)(sQ,{$visible:!p||s,"data-ui":"timeline",children:[0===u.length&&(0,td.jsxs)(sY,{padding:3,space:3,children:[(0,td.jsx)(tp.xv,{size:1,weight:"semibold",children:c("timeline.error.no-document-history-title")}),(0,td.jsx)(tp.xv,{muted:!0,size:1,children:c("timeline.error.no-document-history-description")})]}),u.length>0&&(0,td.jsx)(sX,{direction:"column",children:(0,td.jsx)(tc.e8h,{activeItemDataAttr:"data-hovered",ariaLabel:c("timeline.list.aria-label"),autoFocus:"list",initialIndex:p,initialScrollAlign:"center",itemHeight:40,items:u,onEndReached:l,onEndReachedIndexOffset:20,overscan:5,renderItem:h,wrapAround:!1})})]})};function TimelineError(){let{t:e}=(0,tc.$G7)("studio");return(0,td.jsxs)(tp.kC,{align:"flex-start",gap:3,padding:4,children:[(0,td.jsx)(tc.LPT,{tone:"critical",children:(0,td.jsx)(to.uIy,{})}),(0,td.jsxs)(tp.Kq,{space:4,children:[(0,td.jsx)(tc.LPT,{size:1,tone:"critical",weight:"semibold",children:e("timeline.error.load-document-changes-title")}),(0,td.jsx)(tc.LPT,{size:1,tone:"critical",children:e("timeline.error.load-document-changes-description")})]})]})}Timeline.displayName="Timeline";var sJ=Object.freeze,s0=Object.defineProperty;let s1=(0,th.ZP)(tp.J2)(eK||(eK=sJ(s0(k=["\n overflow: hidden;\n overflow: clip;\n"],"raw",{value:sJ(k.slice())}))));function TimelineMenu(e){let{chunk:t,mode:n,placement:i}=e,{setTimelineRange:r,setTimelineMode:l,timelineError:a,ready:o,timelineStore:s}=useDocumentPane(),[d,c]=(0,ts.useState)(!1),[u,p]=(0,ts.useState)(null),[h,m]=(0,ts.useState)(null),f=(0,tp.pm)(),g=(0,tc.P08)(s,e=>e.chunks),x=(0,tc.P08)(s,e=>e.isLoading),b=(0,tc.P08)(s,e=>e.hasMoreChunks),v=(0,tc.P08)(s,e=>e.realRevChunk),_=(0,tc.P08)(s,e=>e.sinceTime),{t:y}=(0,tc.$G7)("studio"),j=(0,ts.useCallback)(()=>{l(n),c(!0)},[n,l]),w=(0,ts.useCallback)(()=>{l("closed"),c(!1)},[l]),k=(0,ts.useCallback)(()=>{d&&w()},[w,d]),C=(0,ts.useCallback)(e=>{d&&("Escape"===e.key||"Tab"===e.key)&&(w(),null==u||u.focus())},[u,w,d]);(0,tp.O8)(k,[u,h]),(0,tp.qh)(C);let I=(0,ts.useCallback)(e=>{try{let[t,n]=s.findRangeForRev(e);l("closed"),r(t,n)}catch(e){f.push({closable:!0,description:e.message,status:"error",title:y("timeline.error.unable-to-load-revision")})}},[l,r,y,s,f]),S=(0,ts.useCallback)(e=>{try{let[t,n]=s.findRangeForSince(e);l("closed"),r(t,n)}catch(e){f.push({closable:!0,description:e.message,status:"error",title:y("timeline.error.unable-to-load-revision")})}},[l,r,y,s,f]),z=(0,ts.useCallback)(()=>{x||s.loadMore()},[x,s]),P=a?(0,td.jsx)(TimelineError,{}):(0,td.jsxs)(td.Fragment,{children:["rev"===n&&(0,td.jsx)(Timeline,{chunks:g,firstChunk:v,hasMoreChunks:b,lastChunk:v,onLoadMore:z,onSelect:I}),"since"===n&&(0,td.jsx)(Timeline,{chunks:g,disabledBeforeFirstChunk:!0,firstChunk:v,hasMoreChunks:b,lastChunk:_,onLoadMore:z,onSelect:S})]}),E={timestamp:{dateStyle:"medium",timeStyle:"short"}},D=t?y(sq[t.type],{context:"timestamp",timestamp:new Date(null==t?void 0:t.endTimestamp),formatParams:E}):y("timeline.latest-version"),T=t?y("timeline.since",{timestamp:new Date(null==t?void 0:t.endTimestamp),formatParams:E}):y("timeline.since-version-missing"),M="rev"===n?D:T;return(0,td.jsx)(s1,{constrainSize:!0,content:d&&P,"data-ui":"versionMenu",open:d,placement:i,portal:!0,ref:m,children:(0,td.jsx)(tp.zx,{disabled:!o,mode:"bleed",fontSize:1,padding:2,iconRight:to.GVG,onClick:d?w:j,ref:p,selected:d,style:{maxWidth:"100%"},text:o?M:y("timeline.loading-history")})})}let s2=(0,th.ZP)(tp.Zb)({position:"relative",zIndex:1,lineHeight:0,"&:after":{content:'""',dis
1play:"block",position:"absolute",left:0,bottom:-1,right:0,borderBottom:"1px solid var(--card-border-color)",opacity:.5}});function DocumentInspectorHeader(e){let{as:t,children:n,closeButtonLabel:i,onClose:r,title:l,...a}=e;return(0,td.jsxs)(s2,{...a,as:t,children:[(0,td.jsxs)(tp.kC,{padding:2,children:[(0,td.jsx)(tp.xu,{flex:1,padding:3,children:(0,td.jsx)(tp.xv,{as:"h1",size:1,weight:"semibold",children:l})}),(0,td.jsx)(tp.xu,{flex:"none",padding:1,children:(0,td.jsx)(tp.zx,{"aria-label":i,fontSize:1,icon:to.Two,mode:"bleed",onClick:r,padding:2})})]}),n]})}var s5=Object.freeze,s3=Object.defineProperty;let s6=th.ZP.div(eY||(eY=s5(s3(C=["\n position: absolute;\n top: 0;\n left: -4px;\n bottom: 0;\n width: 9px;\n z-index: 201;\n cursor: ew-resize;\n\n /* Border */\n & > span:nth-child(1) {\n display: block;\n border-left: 1px solid var(--card-border-color);\n position: absolute;\n top: 0;\n left: 4px;\n bottom: 0;\n transition: opacity 200ms;\n opacity: 0.5;\n }\n\n /* Hover effect */\n & > span:nth-child(2) {\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 9px;\n bottom: 0;\n background-color: var(--card-border-color);\n opacity: 0;\n transition: opacity 150ms;\n }\n\n @media (hover: hover) {\n &:hover > span:nth-child(2) {\n opacity: 0.2;\n }\n }\n"],"raw",{value:s5(C.slice())}))));function Resizer(e){let{onResize:t,onResizeStart:n}=e,i=(0,ts.useRef)(0),r=(0,ts.useCallback)(e=>{e.preventDefault(),i.current=e.pageX,n();let handleMouseMove=e=>{e.preventDefault(),t(e.pageX-i.current)},handleMouseUp=()=>{window.removeEventListener("mousemove",handleMouseMove),window.removeEventListener("mouseup",handleMouseUp)};window.addEventListener("mousemove",handleMouseMove),window.addEventListener("mouseup",handleMouseUp)},[t,n]);return(0,td.jsxs)(s6,{onMouseDown:r,children:[(0,td.jsx)("span",{}),(0,td.jsx)("span",{})]})}var s8=Object.freeze,s4=Object.defineProperty;let s9=(0,th.ZP)(tp.xu)(eX||(eX=s8(s4(I=["\n position: relative;\n flex: 1;\n padding-left: 1px;\n"],"raw",{value:s8(I.slice())}))));function Resizable(e){let{as:t,children:n,minWidth:i,maxWidth:r,...l}=e,[a,o]=(0,ts.useState)(null),s=(0,ts.useRef)(),[d,c]=(0,ts.useState)(),u=(0,ts.useCallback)(()=>{s.current=null==a?void 0:a.offsetWidth},[a]),p=(0,ts.useCallback)(e=>{let t=s.current;t&&c(Math.min(Math.max(t-e,i),r))},[i,r]),h=(0,ts.useMemo)(()=>d?{flex:"none",width:d}:{minWidth:i,maxWidth:r},[i,r,d]);return(0,td.jsxs)(s9,{as:t,...l,ref:o,style:h,children:[n,(0,td.jsx)(Resizer,{onResize:p,onResizeStart:u})]})}function DocumentInspectorPanel(e){let{documentId:t,documentType:n,flex:i}=e,{collapsed:r}=usePane(),{closeInspector:l,inspector:a}=useDocumentPane(),{features:o}=useDeskTool(),s=(0,ts.useCallback)(()=>{a&&l(a.name)},[l,a]);if(r||!a)return null;let d=(0,ts.createElement)(a.component,{onClose:s,documentId:t,documentType:n});return o.resizablePanes?(0,td.jsx)(Resizable,{as:"aside","data-ui":"DocumentInspectorPanel",flex:i,maxWidth:540,minWidth:320,children:d}):(0,td.jsx)(tp.xu,{as:"aside","data-ui":"DocumentInspectorPanel",flex:i,children:d})}function LoadingContent(){let{t:e}=(0,tc.$G7)("studio");return(0,td.jsx)(Delay,{ms:300,children:(0,td.jsxs)(tp.kC,{align:"center",direction:"column",height:"fill",justify:"center",paddingTop:3,children:[(0,td.jsx)(tp.$j,{muted:!0}),(0,td.jsx)(tp.xu,{marginTop:3,children:(0,td.jsx)(tp.xv,{align:"center",muted:!0,size:1,children:e("changes.loading-changes")})})]})})}var s7=Object.freeze,de=Object.defineProperty;let dt=(0,th.ZP)(tc.l$t)(eQ||(eQ=s7(de(S=["\n height: 100%;\n overflow: auto;\n position: relative;\n scroll-behavior: smooth;\n"],"raw",{value:s7(S.slice())}))));function Content$1(e){let{error:t,diff:n,documentContext:i,loading:r,schemaType:l}=e;return t?(0,td.jsx)(tc.kwM,{}):r?(0,td.jsx)(LoadingContent,{}):n?(0,td.jsx)(tc.H7Z.Provider,{value:i,children:(0,td.jsx)(tc.EyJ,{diff:n,schemaType:l})}):(0,td.jsx)(tc.kwM,{})}let dn={error:to.uIy,warning:to.foC,info:to.hQ6},di={error:"critical",warning:"caution",info:"primary"};function ValidationCard(e){let{marker:t,onOpen:n,schemaType:i,value:r}=e,l=(0,ts.useCallback)(()=>n(t.path),[t,n]),[a,o]=(0,ts.useState)(null);return(0,td.jsxs)(tp.SV,{onCatch:o,children:[a&&(0,td.jsx)(tp.Zb,{padding:3,radius:2,tone:"critical",children:(0,td.jsx)(tp.xv,{size:1,children:a.error.message})}),!a&&(0,td.jsx)(tp.Zb,{__unstable_focusRing:!0,as:"button",onClick:l,padding:3,radius:2,tone:di[t.level],children:(0,td.jsxs)(tp.kC,{align:"flex-start",ga
1p:3,children:[(0,td.jsx)(tp.xu,{flex:"none",children:(0,td.jsx)(tp.xv,{size:1,children:(0,ts.createElement)(dn[t.level])})}),(0,td.jsxs)(tp.Kq,{flex:1,space:2,children:[(0,td.jsx)(DocumentNodePathBreadcrumbs,{path:t.path,schemaType:i,value:r}),(0,td.jsx)(tp.xv,{muted:!0,size:1,children:t.item.message})]})]})})]})}function DocumentNodePathBreadcrumbs(e){let{path:t,schemaType:n,value:i}=e,r=(0,ts.useMemo)(()=>(function(e){let{path:t,schemaType:n,value:i}=e,r=[],l=n,a=i;for(let e of t){if("string"==typeof e){if(!(0,tc.Uy$)(a)&&void 0!==a)throw Error("Parent value is not an object, cannot get path segment: .".concat(e));if("object"!==l.jsonType)throw Error("Parent type is not an object schema type, cannot get path segment: .".concat(e));a=null==a?void 0:a[e];let t=l.fields.find(t=>t.name===e);if(!t)throw Error("Field type not found: .".concat(e));l=t.type,r.push(l);continue}if("number"==typeof e){if(!(0,tc.kJL)(a)&&void 0!==a)throw Error("Parent value is not an array, cannot get path segment: [".concat(e,"]"));if("array"!==l.jsonType)throw Error("Parent type is not an array schema type, cannot get path segment: [".concat(e,"]"));a=null==a?void 0:a[e];let t=l.of.find(e=>"string"==typeof a?"string"===e.jsonType:"number"==typeof a?"number"===e.jsonType:"boolean"==typeof a?"boolean"===e.jsonType:!!(0,tc.Uy$)(a)&&e.name===(null==a?void 0:a._type));if(!t)throw Error("Item type not found: [".concat(e,"]"));l=t,r.push(l);continue}if((0,tc.Uy$)(e)&&e._key){if(!(0,tc.kJL)(a))throw Error("Parent value is not an array, cannot get path segment: [_key == ".concat(e,"]"));if("array"!==l.jsonType)throw Error("Parent type is not an array schema type, cannot get path segment: .".concat(e));let t=null!=a?a:[];if(a=t.find(t=>(0,tc.Uy$)(t)&&t._key===e._key),!(0,tc.Uy$)(a))throw Error("Array item not found: [_key == ".concat(e._key,"]"));let n=l.of.find(e=>(0,tc.Uy$)(a)&&e.name===(null==a?void 0:a._type));if(!n)throw Error("Array item type not found: .".concat(null==a?void 0:a._type));l=n,r.push(l);continue}throw Error("Invalid path segment: ".concat(JSON.stringify(e)))}return r})({path:t,schemaType:n,value:i}),[t,n,i]);return(0,td.jsx)(tp.xv,{size:1,children:r.map((e,t)=>(0,td.jsxs)(ts.Fragment,{children:[t>0&&(0,td.jsx)("span",{style:{color:"var(--card-muted-fg-color)",opacity:.5},children:" / "}),(0,td.jsx)("span",{style:{fontWeight:500},children:e.title||e.name})]},t))})}let dr=[PublishAction,UnpublishAction,DiscardChangesAction,DuplicateAction,DeleteAction,HistoryRestoreAction],dl=[e=>{let{liveEdit:t}=e;return t?{label:"Live",color:"danger"}:null}],da=[{name:"sanity/desk/validation",component:function(e){let{onClose:t}=e,{onFocus:n,onPathOpen:i,schemaType:r,validation:l,value:a}=useDocumentPane(),{t:o}=(0,tc.$G7)("validation"),s=(0,ts.useCallback)(e=>{i(e),n(e)},[n,i]);return(0,td.jsxs)(tp.kC,{direction:"column",height:"fill",overflow:"hidden",children:[(0,td.jsx)(DocumentInspectorHeader,{as:"header",closeButtonLabel:o("panel.close-button-aria-label"),flex:"none",onClose:t,title:o("panel.title")}),(0,td.jsxs)(tp.Zb,{flex:1,overflow:"auto",padding:3,children:[0===l.length&&(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{muted:!0,size:1,children:o("panel.no-errors-message")})}),l.length>0&&(0,td.jsx)(tp.Kq,{space:2,children:l.map((e,t)=>(0,td.jsx)(ValidationCard,{marker:e,onOpen:s,schemaType:r,value:a},t))})]})]})},useMenuItem:function(e){let{documentId:t,documentType:n}=e,{t:i}=(0,tc.$G7)("validation"),{validation:r}=(0,tc.a3k)(t,n),l=(0,ts.useMemo)(()=>r.map(e=>({level:e.level,message:e.item.message,path:e.path})),[r]),a=l.some(tu.z1),o=l.some(tu.AY),s=(0,ts.useMemo)(()=>a?to.uIy:o?to.foC:to.nSX,[a,o]),d=(0,ts.useMemo)(()=>a?"critical":o?"caution":"positive",[a,o]);return{hidden:0===l.length,icon:s,title:i("panel.title"),tone:d,showAsAction:!0}}},{name:i8,useMenuItem:()=>{let{features:e}=useDeskTool(),{t}=(0,tc.$G7)();return{hidden:!e.reviewChanges,icon:to.vaD,title:t("changes.title")}},component:function(e){let{onClose:t}=e,{documentId:n,schemaType:i,timelineError:r,timelineStore:l,value:a}=useDocumentPane(),o=(0,ts.useRef)(null),s=(0,tc.P08)(l,e=>e.diff),d=(0,tc.P08)(l,e=>e.onOlderRevision),c=(0,tc.P08)(l,e=>e.selectionState),u=(0,tc.P08)(l,e=>e.sinceTime),p=!d,{t:h}=(0,tc.$G7)("studio"),m=ts.useMemo(()=>({documentId:n,schemaType:i,FieldWrapper:tc.MUX,rootDiff:s,isComparingCurrent:p,value:a}),[n,s,p,i,a]),f=ts.useMemo(()=>s?function(e){let t=new Map;return(0,tc.Z7x)(e,e=>{if("unchanged"===e.action||!("annotation"in e)||!e.annotation)return!0;let{author:n,timestamp:i}=e.annotation,r=t.get(n);return(!r||r.timestamp<i)&&t.set(n,e.annotation),!0}),Array.from(t.values()).sort((e,t)=>
1e.timestamp<t.timestamp?1:-1)}(s):[],[s]);return(0,td.jsxs)(tp.kC,{"data-testid":"review-changes-pane",direction:"column",height:"fill",overflow:"hidden",children:[(0,td.jsx)(DocumentInspectorHeader,{as:"header",closeButtonLabel:h("changes.action.close-label"),flex:"none",onClose:t,title:h("changes.title"),children:(0,td.jsxs)(tp.kC,{gap:1,padding:3,paddingTop:0,paddingBottom:2,children:[(0,td.jsx)(tp.xu,{flex:1,children:(0,td.jsx)(TimelineMenu,{mode:"since",chunk:u,placement:"bottom-start"})}),(0,td.jsx)(tp.xu,{flex:"none",children:(0,td.jsx)(tc.IIC,{annotations:f,description:h("changes.changes-by-author"),portal:!0,children:(0,td.jsx)(tp.Jh,{maxLength:4,"aria-label":h("changes.changes-by-author"),children:f.map(e=>{let{author:t}=e;return(0,td.jsx)(tc.YtX,{user:t},t)})})})})]})}),(0,td.jsx)(tp.Zb,{flex:1,children:(0,td.jsx)(tp.NM,{element:o.current,children:(0,td.jsx)(dt,{"data-ui":"Scroller",ref:o,children:(0,td.jsx)(tp.xu,{flex:1,padding:4,children:(0,td.jsx)(Content$1,{diff:s,documentContext:m,error:r,loading:"loading"===c,schemaType:i})})})})})]})},onClose:e=>{let{params:t}=e;return{params:{...t,since:void 0}}},onOpen:e=>{let{params:t}=e;return{params:{...t,since:"@lastPublished"}}}}],ds=(0,tc.Cw0)(e=>{let t=!!e&&"string"==typeof e.name,i=(null==e?void 0:e.icon)||to.kLv;return{name:"@sanity/desk-tool",document:{actions:e=>Array.from(new Set([...e,...dr])),badges:e=>Array.from(new Set([...e,...dl])),inspectors:e=>Array.from(new Set([...e,...da]))},plugins:[sR()],tools:[{name:(null==e?void 0:e.name)||"structure",title:(null==e?void 0:e.title)||"Structure",icon:i,component:(0,ts.lazy)(()=>n.e(1869).then(n.bind(n,1869))),canHandleIntent:(e,t)=>{var n;return"create"===e?"type"in t&&(!("template"in t)||{template:!0}):"edit"===e&&"id"in(n=t)&&(!("mode"in n)||{mode:"structure"===n.mode})},getIntentState,controlsDocumentTitle:!0,options:{...e,__internal_toolMenuButtonWrapper:t?void 0:DeskRenameToolMenuButtonPopover},router:iJ}],i18n:{bundles:[nq]}}});let SerializeError=class SerializeError extends Error{constructor(e,t,n,i){super(e);let r=void 0===n?"<unknown>":"".concat(n);this.path=(t||[]).concat(i?"".concat(r," (").concat(i,")"):r)}withHelpUrl(e){return this.helpId=e,this}};var dd=((z=dd||{}).ID_REQUIRED="structure-node-id-required",z.TITLE_REQUIRED="structure-title-required",z.FILTER_REQUIRED="structure-filter-required",z.INVALID_LIST_ITEM="structure-invalid-list-item",z.COMPONENT_REQUIRED="structure-view-component-required",z.DOCUMENT_ID_REQUIRED="structure-document-id-required",z.DOCUMENT_TYPE_REQUIRED="structure-document-type-required",z.SCHEMA_TYPE_REQUIRED="structure-schema-type-required",z.SCHEMA_TYPE_NOT_FOUND="structure-schema-type-not-found",z.LIST_ITEMS_MUST_BE_ARRAY="structure-list-items-must-be-array",z.QUERY_PROVIDED_FOR_FILTER="structure-query-provided-for-filter",z.ACTION_OR_INTENT_REQUIRED="structure-action-or-intent-required",z.LIST_ITEM_IDS_MUST_BE_UNIQUE="structure-list-item-ids-must-be-unique",z.ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE="structure-action-and-intent-mutually-exclusive",z.API_VERSION_REQUIRED_FOR_CUSTOM_FILTER="structure-api-version-required-for-custom-filter",z);let dc=["_id","_type","_createdAt","_updatedAt","_rev"],du={title:"Last edited",i18n:{title:{key:"menu-items.sort-by.last-edited",ns:nV}},name:"lastEditedDesc",by:[{field:"_updatedAt",direction:"desc"}]},dp=[du,{title:"Created",i18n:{title:{key:"menu-items.sort-by.created",ns:nV}},name:"lastCreatedDesc",by:[{field:"_createdAt",direction:"desc"}]}];function maybeSerializeMenuItem(e,t,n){return e instanceof MenuItemBuilder?e.serialize({path:n,index:t}):e}let MenuItemBuilder=class MenuItemBuilder{constructor(e,t){this._context=e,this.spec=t||{}}action(e){return this.clone({action:e})}getAction(){return this.spec.action}intent(e){return this.clone({intent:e})}getIntent(){return this.spec.intent}title(e){return this.clone({title:e})}getTitle(){return this.spec.title}i18n(e){return this.clone({i18n:e})}getI18n(){return this.spec.i18n}group(e){return this.clone({group:e})}getGroup(){return this.spec.group}icon(e){return this.clone({icon:e})}getIcon(){return this.spec.icon}params(e){return this.clone({params:e})}getParams(){return this.spec.params}showAsAction(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return this.clone({showAsAction:!!e})}getShowAsAction(){return this.spec.showAsAction}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},{title:t,action:n,intent:i}=this.spec;if(!t){let t="string"==typeof n?'action: "'.concat(n,'"'):void 0;throw new SerializeError("`title` is required for menu item",e.path,e.index,t).withHelpUrl(dd.TITLE_REQUIRED)}if(!n&&!i)throw new SerializeError("`action` or `intent` required for menu item with title ".concat(this.spec.title),e.path,e.index,'"'.concat(t,'"')).withHelpUrl(dd.ACTION_OR_INTENT_REQUIRED);if(i&&n)throw new SerializeError("cannot set both `action` AND `intent`",e.path,e.index,'"'.concat(t,'"')).withHelpUrl(dd.ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE);return{...this.spec,title:t}}clone(e){let t=new MenuItemBuilder(this._context);return t.spec={...this.spec,...e||{}},t}};function getOrderingMenuItem(e,t,n){let{by:i,title:r,i18n:l}=t,a=new MenuItemBuilder(e).group("sorting").title(e.i18n.t("default-menu-item.fallback-title",{ns:"studio",replace:{title:r}}
1)).icon(to.fzI).action("setSortOrder").params({by:i,extendedProjection:n});return l&&(a=a.i18n(l)),a}function getOrderingMenuItemsForSchemaType(e,t){let{schema:n}=e,i="string"==typeof t?n.get(t):t;return i&&"orderings"in i?(i.orderings?i.orderings.concat(dp):dp).map(t=>getOrderingMenuItem(e,t,t.by.map(e=>(function joinReferences(e,t){let[n,...i]=t;if(!("fields"in e))return"";let r=e.fields.find(e=>e.name===n);if(!r)return dc.includes(n)||console.warn('The current ordering config targeted the nonexistent field "%s" on schema type "%s". It should be one of %o',n,e.name,e.fields.map(e=>e.name)),"";if("to"in r.type&&"reference"===r.type.name){let e=r.type.to;return"".concat(n,"->{").concat(e.map(e=>joinReferences(e,i)).join(","),"}")}let l=i.length>0&&joinReferences(r.type,i),a=l?"{".concat(l,"}"):"";return i.length>0?"".concat(n).concat(a):n})(i,e.field.split("."))).join(", "))):[]}function maybeSerializeMenuItemGroup(e,t,n){return e instanceof MenuItemGroupBuilder?e.serialize({path:n,index:t}):e}let MenuItemGroupBuilder=class MenuItemGroupBuilder{constructor(e,t){this._context=e,this._id=t?t.id:"",this._title=t?t.title:"",this._i18n=t?t.i18n:void 0}id(e){return new MenuItemGroupBuilder(this._context,{id:e,title:this._title,i18n:this._i18n})}getId(){return this._id}title(e){return new MenuItemGroupBuilder(this._context,{title:e,id:this._id,i18n:this._i18n})}getTitle(){return this._title}i18n(e){return new MenuItemGroupBuilder(this._context,{i18n:e,id:this._id,title:this._title})}getI18n(){return this._i18n}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},{_id:t,_title:n,_i18n:i}=this;if(!t)throw new SerializeError("`id` is required for a menu item group",e.path,e.index,n).withHelpUrl(dd.ID_REQUIRED);if(!n)throw new SerializeError("`title` is required for a menu item group",e.path,t).withHelpUrl(dd.TITLE_REQUIRED);return{id:t,title:n,i18n:i}}};let dh=/([^A-Za-z0-9-_.])/;function validateId(e,t,n){if("string"!=typeof e)throw new SerializeError("Structure node id must be of type string, got ".concat(typeof e),t,n);let[i]=e.match(dh)||[];if(i)throw new SerializeError('Structure node id cannot contain character "'.concat(i,'"'),t,n);if(e.startsWith("__edit__"))throw new SerializeError("Structure node id cannot start with __edit__",t,n);return e}function getStructureNodeId(e,t){if(t)return t;let n=n_()(e);return dh.test(n)?n_()(nj()(e)):n}let ComponentBuilder=class ComponentBuilder{constructor(e){this.spec={options:{},...e||{}}}id(e){return this.clone({id:e})}getId(){return this.spec.id}title(e){return this.clone({title:e,id:getStructureNodeId(e,this.spec.id)})}getTitle(){return this.spec.title}i18n(e){return this.clone({i18n:e})}getI18n(){return this.spec.i18n}child(e){return this.clone({child:e})}getChild(){return this.spec.child}component(e){return this.clone({component:e})}getComponent(){return this.spec.component}options(e){return this.clone({options:e})}getOptions(){return this.spec.options||{}}menuItems(e){return this.clone({menuItems:e})}getMenuItems(){return this.spec.menuItems}menuItemGroups(e){return this.clone({menuItemGroups:e})}getMenuItemGroups(){return this.spec.menuItemGroups}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},{id:t,title:n,child:i,options:r,component:l}=this.spec;if(!t)throw new SerializeError("`id` is required for `component` structure item",e.path,e.index).withHelpUrl(dd.ID_REQUIRED);if(!l)throw new SerializeError("`component` is required for `component` structure item",e.path,e.index).withHelpUrl(dd.ID_REQUIRED);
1return{id:validateId(t,e.path,e.index),title:n,type:"component",child:i,component:l,options:r||{},menuItems:(this.spec.menuItems||[]).map((t,n)=>maybeSerializeMenuItem(t,n,e.path)),menuItemGroups:(this.spec.menuItemGroups||[]).map((t,n)=>maybeSerializeMenuItemGroup(t,n,e.path))}}clone(e){let t=new ComponentBuilder;return t.spec={...this.spec,...e||{}},t}};async function resolveTypeForDocument(e,t){let n=(0,tc.vsM)(t),i=(0,tc.qyu)(t),r=await e(tc.Dr7).fetch("*[_id in [$documentId, $draftId]]._type",{documentId:n,draftId:i},{tag:"structure.resolve-type"});return r[0]}let GenericViewBuilder=class GenericViewBuilder{constructor(){this.spec={}}id(e){return this.clone({id:e})}getId(){return this.spec.id}title(e){return this.clone({title:e,id:this.spec.id||nI()(e)})}getTitle(){return this.spec.title}icon(e){return this.clone({icon:e})}getIcon(){return this.spec.icon}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},{id:t,title:n,icon:i}=this.spec;if(!t)throw new SerializeError("`id` is required for view item",e.path,e.index).withHelpUrl(dd.ID_REQUIRED);if(!n)throw new SerializeError("`title` is required for view item",e.path,e.index).withHelpUrl(dd.TITLE_REQUIRED);
1return{id:validateId(t,e.path,e.index),title:n,icon:i}}};function maybeSerializeView(e,t,n){return"function"==typeof e.serialize?e.serialize({path:n,index:t}):e}let isComponentSpec=e=>(0,tc.Uy$)(e)&&"component"===e.type;let ComponentViewBuilder=class ComponentViewBuilder extends GenericViewBuilder{constructor(e){let t=isComponentSpec(e)?{...e}:{options:{}};super(),this.spec=t;let n="function"==typeof e?e:this.spec.component;n&&(this.spec=this.component(n).spec)}component(e){return this.clone({component:e})}getComponent(){return this.spec.component}options(e){return this.clone({options:e})}getOptions(){return this.spec.options||{}}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},t=super.serialize(e),n=this.spec.component;if("function"!=typeof n)throw new SerializeError("`component` is required and must be a function for `component()` view item",e.path,e.index).withHelpUrl(dd.COMPONENT_REQUIRED);return{...t,component:n,options:this.spec.options||{},type:"component"}}clone(e){let t=new ComponentViewBuilder;return t.spec={...this.spec,...e||{}},t}};let FormViewBuilder=class FormViewBuilder extends GenericViewBuilder{constructor(e){super(),this.spec={id:"editor",title:"Editor",...e||{}}}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]};return{...super.serialize(e),type:"form"}}clone(e){let t=new FormViewBuilder;return t.spec={...this.spec,...e||{}},t}};let form=e=>new FormViewBuilder(e);var dm=Object.freeze({__proto__:null,ComponentViewBuilder:ComponentViewBuilder,FormViewBuilder:FormViewBuilder,GenericViewBuilder:GenericViewBuilder,component:e=>
1new ComponentViewBuilder(e),form:form,maybeSerializeView:maybeSerializeView});let createDocumentChildResolver=e=>{let{resolveDocumentNode:t,getClient:n}=e;return async(e,i)=>{let{params:r,path:l}=i,a=r.type,o=l.slice(0,l.length-1),s=l[l.length-1];if(a||(a=await resolveTypeForDocument(n,e)),!a)throw new SerializeError("Failed to resolve document, and no type provided in parameters.",o,s);return t({documentId:e,schemaType:a})}};let DocumentBuilder=class DocumentBuilder{constructor(e,t){this._context=e,this.spec=t||{}}id(e){return this.clone({id:e})}getId(){return this.spec.id}title(e){return this.clone({title:e,id:getStructureNodeId(e,this.spec.id)})}getTitle(){return this.spec.title}i18n(e){return this.clone({i18n:e})}getI18n(){return this.spec.i18n}child(e){return this.clone({child:e})}getChild(){return this.spec.child}documentId(e){let t=this.spec.id||e;return this.clone({id:t,options:{...this.spec.options||{},id:e}})}getDocumentId(){var e;return null==(e=this.spec.options)?void 0:e.id}schemaType(e){return this.clone({options:{...this.spec.options||{},type:"string"==typeof e?e:e.name}})}getSchemaType(){var e;return null==(e=this.spec.options)?void 0:e.type}initialValueTemplate(e,t){return this.clone({options:{...this.spec.options||{},template:e,templateParameters:t}})}getInitialValueTemplate(){var e;return null==(e=this.spec.options)?void 0:e.template}getInitialValueTemplateParameters(){var e;return null==(e=this.spec.options)?void 0:e.templateParameters}views(e){return this.clone({views:e})}getViews(){return this.spec.views||[]}serialize(){let{path:e=[],index:t,hint:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},i=e[t||e.length-1],r=this.spec.id||i&&"".concat(i)||"",l={id:r,type:void 0,template:void 0,templateParameters:void 0,...this.spec.options};if("string"!=typeof r||!r)throw new SerializeError("`id` is required for document nodes",e,t,n).withHelpUrl(dd.ID_REQUIRED);if(!l||!l.id)throw new SerializeError("document id (`id`) is required for document nodes",e,r,n).withHelpUrl(dd.DOCUMENT_ID_REQUIRED);if(!l||!l.type)throw new SerializeError("document type (`schemaType`) is required for document nodes",e,r,n);let a=(this.spec.views&&this.spec.views.length>0?this.spec.views:[form()]).map((t,n)=>maybeSerializeView(t,n,e)),o=a.map(e=>e.id),s=nk()(o.filter((e,t)=>o.includes(e,t+1)));if(s.length>0)throw new SerializeError("document node has views with duplicate IDs: ".concat(s.join(", ")),e,r,n);return{...this.spec,child:this.spec.child||createDocumentChildResolver(this._context),id:validateId(r,e,t),type:"document",options:function(e){let t={id:e.id||"",type:e.type||"*"};return e.template&&(t.template=e.template),e.templateParameters&&(t.templateParameters=e.templateParameters),t}(l),views:a}}clone(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new DocumentBuilder(this._context),n={...this.spec.options||{},...e.options||{}};return t.spec={...this.spec,...e,options:n},t}};let df=["default","card","media","detail","block"],dg=Symbol("Document type list canHandleIntent"),defaultIntentChecker=(e,t,n)=>{var i,r;let{pane:l}=n,a="create"===e,o=(null==(i=l.options)?void 0:i.filter)||"",s=(null==(r=l.options)?void 0:r.params)||{},d=l.schemaTypeName?[l.schemaTypeName]:getTypeNamesFromFilter(o,s),c=l.initialValueTemplates||[];return a&&t.template?c.some(e=>e.templateId===t.template):"edit"===e&&t.id&&d.includes(t.type)||a&&d.includes(t.type)};defaultIntentChecker.identity=dg;let InitialValueTemplateItemBuilder=class InitialValueTemplateItemBuilder{constructor(e,t){this._context=e,this.spec=t||{}}id(e){return this.clone({id:e})}getId(){return this.spec.id}title(e){return this.clone({title:e})}getTitle(){return this.spec.title}description(e){return this.clone({description:e})}getDescription(){return this.spec.description}templateId(e){let t=this.spec.id||e;return this.clone({id:t,templateId:e})}getTemplateId(){return this.spec.templateId}parameters(e){return this.clone({parameters:e})}getParameters(){return this.spec.parameters}serialize(){let{path:e=[],index:t,hint:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]}
1,{spec:i,_context:r}=this,{templates:l}=r;if("string"!=typeof i.id||!i.id)throw new SerializeError("`id` is required for initial value template item nodes",e,t,n).withHelpUrl(dd.ID_REQUIRED);if(!i.templateId)throw new SerializeError("template id (`templateId`) is required for initial value template item nodes",e,i.id,n).withHelpUrl(dd.ID_REQUIRED);let a=l.find(e=>e.id===i.templateId);if(!a)throw new SerializeError("template id (`templateId`) is required for initial value template item nodes",e,i.id,n).withHelpUrl(dd.ID_REQUIRED);return{id:i.id,templateId:i.id,schemaType:a.schemaType,type:"initialValueTemplateItem",description:i.description||a.description,title:i.title||a.title,subtitle:i.subtitle,icon:i.icon||a.icon,initialDocumentId:i.initialDocumentId,parameters:i.parameters}}clone(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new InitialValueTemplateItemBuilder(this._context);return t.spec={...this.spec,...e},t}};function noChildResolver(){}let shallowIntentChecker=(e,t,n)=>{let{pane:i,index:r}=n;return r<=1&&defaultIntentChecker(e,t,{pane:i,index:r})};let GenericListBuilder=class GenericListBuilder{constructor(){this.initialValueTemplatesSpecified=!1,this.spec={}}id(e){return this.clone({id:e})}getId(){return this.spec.id}title(e){return this.clone({title:e,id:getStructureNodeId(e,this.spec.id)})}getTitle(){return this.spec.title}i18n(e){return this.clone({i18n:e})}getI18n(){return this.spec.i18n}defaultLayout(e){return this.clone({defaultLayout:e})}getDefaultLayout(){return this.spec.defaultLayout}menuItems(e){return this.clone({menuItems:e})}getMenuItems(){return this.spec.menuItems}menuItemGroups(e){return this.clone({menuItemGroups:e})}getMenuItemGroups(){return this.spec.menuItemGroups}child(e){return this.clone({child:e})}getChild(){return this.spec.child}canHandleIntent(e){return this.clone({canHandleIntent:e})}getCanHandleIntent(){return this.spec.canHandleIntent}showIcons(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return this.clone({displayOptions:{...this.spec.displayOptions||{},showIcons:e}})}getShowIcons(){return this.spec.displayOptions?this.spec.displayOptions.showIcons:void 0}initialValueTemplates(e){return this.initialValueTemplatesSpecified=!0,this.clone({initialValueTemplates:Array.isArray(e)?e:[e]})}getInitialValueTemplates(){return this.spec.initialValueTemplates}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},t=this.spec.id||"",n=e.path,i=this.spec.defaultLayout;if(i&&!df.includes(i))throw new SerializeError("`layout` must be one of ".concat(df.map(e=>'"'.concat(e,'"')).join(", ")),n,t||e.index,this.spec.title);let r=(this.spec.initialValueTemplates||[]).map((e,t)=>e instanceof InitialValueTemplateItemBuilder?e.serialize({path:n,index:t}):e);
1return{id:validateId(t,e.path,t||e.index),title:this.spec.title,i18n:this.spec.i18n,type:"genericList",defaultLayout:i,child:this.spec.child||noChildResolver,canHandleIntent:this.spec.canHandleIntent||shallowIntentChecker,displayOptions:this.spec.displayOptions,initialValueTemplates:r,menuItems:(this.spec.menuItems||[]).map((e,t)=>maybeSerializeMenuItem(e,t,n)),menuItemGroups:(this.spec.menuItemGroups||[]).map((e,t)=>maybeSerializeMenuItemGroup(e,t,n))}}};let validateFilter=(e,t)=>{var n;let i=(null==(n=e.options)?void 0:n.filter.trim())||"";if(["*","{"].includes(i[0]))throw new SerializeError("`filter` cannot start with `".concat(i[0],"` - looks like you are providing a query, not a filter"),t.path,e.id,e.title).withHelpUrl(dd.QUERY_PROVIDED_FOR_FILTER);return i},createDocumentChildResolverForItem=e=>(t,n)=>{var i;let r=n.parent,l=(null==(i=n.params)?void 0:i.template)?e.templates.find(e=>e.id===n.params.template):void 0,a=l?l.schemaType:r.schemaTypeName||resolveTypeForDocument(e.getClient,t);return Promise.resolve(a).then(n=>n?e.resolveDocumentNode({schemaType:n,documentId:t}):new DocumentBuilder(e).id("editor").documentId(t).schemaType(""))};let DocumentListBuilder=class DocumentListBuilder extends GenericListBuilder{constructor(e,t){super(),this._context=e,this.spec=t||{},this.initialValueTemplatesSpecified=!!(null==t?void 0:t.initialValueTemplates)}apiVersion(e){return this.clone({options:{...this.spec.options||{filter:""},apiVersion:e}})}getApiVersion(){var e;return null==(e=this.spec.options)?void 0:e.apiVersion}filter(e){return this.clone({options:{...this.spec.options||{},filter:e}})}getFilter(){var e;return null==(e=this.spec.options)?void 0:e.filter}schemaType(e){let t="string"==typeof e?e:e.name;return this.clone({schemaTypeName:t})}getSchemaType(){return this.spec.schemaTypeName}params(e){return this.clone({options:{...this.spec.options||{filter:""},params:e}})}getParams(){var e;return null==(e=this.spec.options)?void 0:e.params}defaultOrdering(e){if(!Array.isArray(e))throw Error("`defaultOrdering` must be an array of order clauses");return this.clone({options:{...this.spec.options||{filter:""},defaultOrdering:e}})}getDefaultOrdering(){var e;return null==(e=this.spec.options)?void 0:e.defaultOrdering}serialize(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]};if("string"!=typeof this.spec.id||!this.spec.id)throw new SerializeError("`id` is required for document lists",t.path,t.index,this.spec.title).withHelpUrl(dd.ID_REQUIRED);if(!this.spec.options||!this.spec.options.filter)throw new SerializeError("`filter` is required for document lists",t.path,this.spec.id,this.spec.title).withHelpUrl(dd.FILTER_REQUIRED);let n=(null==(e=this.spec.options)?void 0:e.filter)==="_type == $type";return n||!this.spec.options.filter||this.spec.options.apiVersion||console.warn("No apiVersion specified for document type list with custom filter: `".concat(this.spec.options.filter,"`. This will be required in the future. See %s for more info."),(0,nS.h)(dd.API_VERSION_REQUIRED_FOR_CUSTOM_FILTER)),{...super.serialize(t),type:"documentList",schemaTypeName:this.spec.schemaTypeName,child:this.spec.child||createDocumentChildResolverForItem(this._context),options:{...this.spec.options,apiVersion:this.spec.options.apiVersion||tc.Dr7.apiVersion,filter:validateFilter(this.spec,t)}}}clone(e){let t=new DocumentListBuilder(this._context);return t.spec={...this.spec,...e||{}},this.initialValueTemplatesSpecified||(t.spec.initialValueTemplates=function(e,t){let{document:n}=e,{schemaTypeName:i,options:r}=t,{filter:l,params:a}=r||{filter:"",params:{}},o=i?[i]:Array.from(new Set(getTypeNamesFromFilter(l,a)));if(0!==o.length)return o.flatMap(e=>n.resolveNewDocumentOptions({type:"structure",schemaType:e})).map(e=>({...e,icon:to.dtP}))}(this._context,t.spec)),t.spec.schemaTypeName||(t.spec.schemaTypeName=function(e){let{options:t}=e,{filter:n,params:i}=t||{filter:"",params:{}},r=getTypeNamesFromFilter(n,i);return 1===r.length?r[0]:void 0}(t.spec)),t}getSpec(){return this.spec}};function getTypeNamesFromFilter(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=function(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=/\b_type\s*==\s*(['"].*?['"]|\$.*?(?:\s|$))|\B(['"].*?['"]|\$.*?(?:\s|$))\s*==\s*_type/g,r=[];for(;null!==(t=i.exec(e));)r.push(t[1]||t[2]);return r.map(e=>{let t="$"===e[0]?n[e.slice(1)]:e,i=(t||"").trim().replace(/^["']|["']$/g,"");return i}
1).filter(Boolean)}(e,t);return 0===n.length&&(n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.match(/\b_type\s+in\s+\[(.*?)\]/);return n?n[1].split(/,\s*/).map(e=>e.trim().replace(/^["']+|["']+$/g,"")).map(e=>"$"===e[0]?t[e.slice(1)]:e).filter(Boolean):[]}(e,t)),n}let getArgType=e=>e instanceof ListBuilder?"ListBuilder":(0,tc.Uy$)(e)&&"function"==typeof e.then?"Promise":Array.isArray(e)?"array":typeof e,isListItem=e=>"listItem"===e.type,defaultCanHandleIntent=(e,t,n)=>{let i=n.pane,r=i.items||[];return r.filter(isDocumentListItem).some(e=>e.schemaType.name===t.type&&e._id===t.id)||shallowIntentChecker(e,t,n)},resolveChildForItem=(e,t)=>{let n=t.parent,i=n.items.filter(isListItem),r=(i.find(t=>t.id===e)||{child:void 0}).child;return r&&"function"==typeof r&&"function"==typeof r?r(e,t):r};let ListBuilder=class ListBuilder extends GenericListBuilder{constructor(e,t){super(),this._context=e,this.spec=t||{},this.initialValueTemplatesSpecified=!!(t&&t.initialValueTemplates)}items(e){return this.clone({items:e})}getItems(){return this.spec.items}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},t=this.spec.id;if("string"!=typeof t||!t)throw new SerializeError("`id` is required for lists",e.path,e.index).withHelpUrl(dd.ID_REQUIRED);let n=void 0===this.spec.items?[]:this.spec.items;if(!Array.isArray(n))throw new SerializeError("`items` must be an array of items",e.path,e.index).withHelpUrl(dd.LIST_ITEMS_MUST_BE_ARRAY);let i=(e.path||[]).concat(t),r=n.map((e,t)=>(function(e,t,n){if(e instanceof ListItemBuilder)return e.serialize({path:n,index:t});if(e&&"divider"===e.type)return e;if(!e||"listItem"!==e.type){let i=e&&e.type||getArgType(e);throw new SerializeError('List items must be of type "listItem", got "'.concat(i,'"').concat("array"===i?" - did you forget to spread (...moreItems)?":""),n,t).withHelpUrl(dd.INVALID_LIST_ITEM)}return e})(e,t,i)),l=r.filter((e,t)=>nP()(r,{id:e.id},t+1));if(l.length>0){let t=l.map(e=>e.id).slice(0,5),n=l.length>5?"".concat(t.join(", "),"..."):t.join(", ");throw new SerializeError("List items with same ID found (".concat(n,")"),e.path,e.index).withHelpUrl(dd.LIST_ITEM_IDS_MUST_BE_UNIQUE)}return{...super.serialize(e),type:"list",canHandleIntent:this.spec.canHandleIntent||defaultCanHandleIntent,child:this.spec.child||resolveChildForItem,items:r}}clone(e){let t=new ListBuilder(this._context);return t.spec={...this.spec,...e||{}},t}};let ListItemBuilder=class ListItemBuilder{constructor(e,t){this._context=e,this.spec=t||{}}id(e){return this.clone({id:e})}getId(){return this.spec.id}title(e){return this.clone({title:e,id:getStructureNodeId(e,this.spec.id)})}getTitle(){return this.spec.title}i18n(e){return this.clone({i18n:e})}getI18n(){return this.spec.i18n}icon(e){return this.clone({icon:e})}showIcon(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return this.clone({displayOptions:{...this.spec.displayOptions||{},showIcon:e}})}getShowIcon(){return this.spec.displayOptions?this.spec.displayOptions.showIcon:void 0}getIcon(){return this.spec.icon}child(e){return this.clone({child:e})}getChild(){return this.spec.child}schemaType(e){return this.clone({schemaType:e})}getSchemaType(){let e=this.spec.schemaType;return"string"==typeof e?this._context.schema.get(e):this.spec.schemaType}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},{id:t,title:n,child:i}=this.spec;if("string"!=typeof t||!t)throw new SerializeError("`id` is required for list items",e.path,e.index).withHelpUrl(dd.ID_REQUIRED);if(!e.titleIsOptional&&("string"!=typeof n||!n))throw new SerializeError("`title` is required for list items",e.path,t).withHelpUrl(dd.TITLE_REQUIRED);let r=this.spec.schemaType;if("string"==typeof r){let n=this._context.schema.get(r);if(!n)throw new SerializeError('Could not find type "'.concat(r,'" in schema'),e.path,t).withHelpUrl(dd.SCHEMA_TYPE_NOT_FOUND);r=n}let l={path:e.path.concat(t),hint:"child"},a=i instanceof ComponentBuilder||i instanceof DocumentListBuilder||i instanceof DocumentBuilder||i instanceof ListBuilder?i.serialize(l):i;if("function"==typeof a){let e=a;a=(t,n)=>e(t,{...n,serializeOptions:l})}return{...this.spec,id:validateId(t,e.path,e.index),schemaType:r,child:a,title:n,type:"listItem"}}clone(e){let t=new ListItemBuilder(this._context);return t.spec={...this.spec,...e||{}},t}};let createDefaultChildResolver=(e,t)=>n=>{let i=t.schemaType&&("string"==typeof t.schemaType?t.schemaType:t.schemaType.n
1ame);return i?e.resolveDocumentNode({schemaType:i,documentId:n}):new DocumentBuilder(e).id("documentEditor").documentId(n)};let DocumentListItemBuilder=class DocumentListItemBuilder extends ListItemBuilder{constructor(e,t){super(e,t),this._context=e,this.spec=t||{}}serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:[]},t=super.serialize({...e,titleIsOptional:!0});if(!t.schemaType)throw new SerializeError("`schemaType` is required for document list items",e.path,e.index).withHelpUrl(dd.SCHEMA_TYPE_REQUIRED);let n=t.child||createDefaultChildResolver(this._context,t);return{...t,child:n,schemaType:t.schemaType,_id:t.id}}clone(e){let t=new DocumentListItemBuilder(this._context);return t.spec={...this.spec,...e||{}},t}};function isDocumentListItem(e){return(0,tc.Uy$)(e)&&void 0!==e.schemaType&&"string"==typeof e._id}let DocumentTypeListBuilder=class DocumentTypeListBuilder extends DocumentListBuilder{constructor(e,t){super(e),this._context=e,this.spec=t||{}}child(e){return this.cloneWithoutDefaultIntentHandler({child:e})}clone(e){let t=super.clone(e),n=new DocumentTypeListBuilder(this._context);return n.spec={...this.spec,...t.getSpec(),...e||{}},n}cloneWithoutDefaultIntentHandler(e){let t=super.clone(e),n=new DocumentTypeListBuilder(this._context),i=this.spec.canHandleIntent,r=i&&i.identity===dg;return n.spec={...t.getSpec(),...this.spec,...e||{},...r?{canHandleIntent:void 0}:{}},n}};let dx=["sanity.imageAsset","sanity.fileAsset"];function getDocumentTypeListItems(e){let t=function(e){let{schema:t}=e;return t.getTypeNames().filter(e=>{var n;let i=t.get(e);return i&&(null==(n=i.type)?void 0:n.name)==="document"}).filter(e=>!dx.includes(e))}(e);return t.map(t=>getDocumentTypeListItem(e,t))}function getDocumentTypeListItem(e,t){let{schema:n}=e,i=n.get(t);if(!i)throw Error('Schema type with name "'.concat(t,'" not found'));let r=i.title||nf()(t);return new ListItemBuilder(e).id(t).title(r).schemaType(i).child((n,i)=>{let r=i.parent,l="list"===r.type?r.items.find(e=>e.id===n):null,a=getDocumentTypeList(e,t);return l&&l.title&&(a=a.title(l.title)),a})}function getDocumentTypeList(e,t){let{schema:n,resolveDocumentNode:i}=e,r="string"==typeof t?t:t.schemaType,l="string"==typeof r?r:r.name,a="string"==typeof t?{schemaType:r}:t,o=n.get(l);if(!o)throw Error('Schema type with name "'.concat(l,'" not found'));let s=o.title||nf()(l),d=function(e){let t=e.preview;return!!(t&&(t.prepare||t.select&&t.select.media))}(o);return new DocumentTypeListBuilder(e).id(a.id||l).title(a.title||s).filter("_type == $type").params({type:l}).schemaType(o).showIcons(d).defaultOrdering(du.by).menuItemGroups(a.menuItemGroups||[{id:"sorting",title:"Sort",i18n:{title:{key:"menu-item-groups.actions-group",ns:nV}}},{id:"layout",title:"Layout",i18n:{title:{key:"menu-item-groups.layout-group",ns:nV}}},{id:"actions",title:"Actions",i18n:{title:{key:"menu-item-groups.sorting-group",ns:nV}}}]).child(a.child||(e=>i({schemaType:l,documentId:e}))).canHandleIntent(a.canHandleIntent||defaultIntentChecker).menuItems(a.menuItems||[...getOrderingMenuItemsForSchemaType(e,o),new MenuItemBuilder(e).group("layout").i18n({title:{key:"menu-items.layout.compact-view",ns:nV}}).title("Compact view").icon(to.reJ).action("setLayout").params({layout:"default"}),new MenuItemBuilder(e).group("layout").i18n({title:{key:"menu-items.layout.detailed-view",ns:nV}}).title("Detailed view").icon(to.cMY).action("setLayout").params({layout:"detail"})])}function DeskToolProvider(e){let{defaultDocumentNode:t,structure:n,children:i}=e,[r,l]=(0,ts.useState)(!1),a=(0,tc.Lky)(),o=(0,tc.Q3k)(a),s=(0,tc.H__)(),d=(0,ts.useMemo)(()=>(function(e){let{defaultDocumentNode:t,source:n}=e,i=(0,tc.nqf)(n),r={...n,getStructureBuilder:()=>l,resolveDocumentNode:e=>{let n=(null==t?void 0:t(l,{...e,...i}))||new DocumentBuilder(r);return n.getId()||(n=n.id("documentEditor")),e.documentId&&(n=n.documentId((0,tc.vsM)(e.documentId))),n.schemaType(e.schemaType)}},l={defaults:()=>(function(e){let t=getDocumentTypeListItems(e);return new ListBuilder(e).id("__root__").title("Content").i18n({title:{key:"default-definition.content-title",ns:nV}}).items(t).showIcons(t.some(e=>{var t;return!!(t=e.getSchemaType())&&"string"!=typeof t&&!!t.icon}))})(r),documentTypeList:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return getDocumentTypeList(r,...t)},documentTypeListItem:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return getDocumentTypeListItem(r,...t)},documentTypeListItems:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return getDocumentTypeListItems(r,...t)},document:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new DocumentBuilder(r,...t)},documentWithInitialValueTemplate:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e,t,n){let{resolveDocumentNode:i,templates:r}=e,l=r.find(e=>e.id===t);if(!l)throw Error('Template with ID "'.concat(t,'" not defined'));return i({schemaType:l.schemaType}).initialValueTemplate(t,n)}(r,...t)},defaultDocument:r.resolveDocumentNode,list:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new ListBuilder(r,...t)},listItem:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new ListItemBuilder(r,...t)},menuItem:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new MenuItemBuilder(r,...t)},menuItemGroup:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new MenuItemGroupBuilder(r,...t)},menuItemsFromInitialValueTemplateItems:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e,t){let{schema:n,templates:i}=e;return t.map(t=>{let r=i.find(e=>e.id===t.templateId),l=t.title||(null==r?void 0:r.title)||"Create new",a={};r&&r.schemaType&&(a.type=r.schemaType),t.templateId&&(a.template=t.templateId);let o=t.parameters?[a,t.parameters]:a,s=r&&n.get(r.schemaType),d=t.i18n||(null==r?void 0:r.i18n),c=new Me
1nuItemBuilder(e).title(l).icon(r&&r.icon||(null==s?void 0:s.icon)||to.dtP).intent({type:"create",params:o});return d&&(c=c.i18n(d)),c.serialize()})}(r,...t)},documentList:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new DocumentListBuilder(r,...t)},documentListItem:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new DocumentListItemBuilder(r,...t)},orderingMenuItem:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return getOrderingMenuItem(r,...t)},orderingMenuItemsForType:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return getOrderingMenuItemsForSchemaType(r,...t)},editor:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e,t){let n=(null==t?void 0:t.type)?e.resolveDocumentNode({schemaType:t.type}):new DocumentBuilder(e);if(!t)return n;let{id:i,type:r,template:l,templateParameters:a}=t.options;return n=n.id(t.id).documentId(i),r&&(n=n.schemaType(r)),l&&(n=n.initialValueTemplate(l,a)),t.child&&(n=n.child(t.child)),n}(r,...t)},defaultInitialValueTemplateItems:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){let{schema:t,getStructureBuilder:n,templates:i}=e,r=t.getTypeNames(),l=i.filter(e=>{var t;return!(null==(t=e.parameters)?void 0:t.length)}).sort((e,t)=>r.indexOf(e.schemaType)-r.indexOf(t.schemaType));return l.map(e=>n().initialValueTemplateItem(e.id))}(r,...t)},initialValueTemplateItem:(e,t)=>new InitialValueTemplateItemBuilder(r,{id:e,parameters:t,templateId:e}),component:e=>(0,nT.isValidElementType)(e)?new ComponentBuilder().component(e):new ComponentBuilder(e),divider:()=>({id:nD()("__divider__"),type:"divider"}),view:dm,context:r};return l})({defaultDocumentNode:t,source:a}),[t,a]),c=(0,ts.useMemo)(()=>n?n(d,{...o,documentStore:s}):d.defaults(),[d,n,o,s]),u=(0,ts.useMemo)(()=>({backButton:r,resizablePanes:!r,reviewChanges:!r,splitPanes:!r,splitViews:!r}),[r]),p=(0,ts.useMemo)(()=>({features:u,layoutCollapsed:r,setLayoutCollapsed:l,rootPaneNode:c,structureContext:d.context}),[u,r,c,d.context]);return(0,td.jsx)(sB.Provider,{value:p,children:i})}function ErrorPane(e){let{children:t,currentMinWidth:n,flex:i,minWidth:r,paneKey:l,title:a="Error",tone:o="critical"}=e;return(0,td.jsxs)(ih,{currentMinWidth:n,flex:i,id:l,minWidth:r,tone:o,children:[(0,td.jsx)(iT,{title:a}),(0,td.jsx)(ib,{overflow:"auto",children:(0,td.jsx)(tp.xu,{paddingX:4,paddingY:5,children:t})})]})}function getWaitMessages(e){let t=[{ms:300,messageKey:"panes.resolving.default-message"},{ms:5e3,messageKey:"panes.resolving.slow-resolve-message"}];if(tc.r8Q){let n=["Check console for errors?","Is your observable/promise resolving?",e.length>0?"Structure path: ".concat(e.join(" â ")):""];t.push({ms:1e4,message:n.join("\n")})}let n=(0,tx.of)(null);return(0,tk.T)(...t.map(e=>n.pipe((0,tN.h)("messageKey"in e?{messageKey:e.messageKey}:{message:e.message}),(0,t$.g)(e.ms))))}var db=Object.freeze,dv=Object.defineProperty;let d_=(0,th.ZP)(tp.kC)(eJ||(eJ=db(dv(P=["\n opacity: 0;\n transition: opacity 200ms;\n\n &[data-mounted] {\n opacity: 1;\n }\n"],"raw",{value:db(P.slice())})))),dy=(0,ts.memo)(e=>{let{delay:t=300,flex:n,message:i=getWaitMessages,minWidth:r,paneKey:l,path:a,selected:o,title:s,tone:d}=e,{t:c}=(0,tc.$G7)(nV),u=(0,ts.useMemo)(()=>"function"==typeof i?i(a?a.split(";"):[]):i,[i,a]),[p,h]=(0,ts.useState)(()=>"string"==typeof u?u:"panes.resolving.default-message");(0,ts.useEffect)(()=>{if("object"!=typeof u||"function"==typeof u.subscribe)return;let e=u.subscribe(e=>{h("messageKey"in e?c(e.messageKey):e.message)});return()=>e.unsubscribe()},[u,c]);let[m,f]=(0,ts.useState)(null),[g,x]=(0,ts.useState)(!1);(0,ts.useEffect)(()=>{if(m)return(0,tp.RE)(()=>x(!0))},[m]);let b=(0,td.jsxs)(d_,{align:"center","data-mounted":g?"":void 0,direction:"column",height:"fill",justify:"center",ref:f,children:[(0,td.jsx)(tp.$j,{muted:!0}),(s||p)&&(0,td.jsx)(tp.xu,{marginTop:3,children:(0,td.jsx)(tp.xv,{align:"center",muted:!0,size:1,children:s||p})})]});return(0,td.jsx)(ih,{flex:n,id:l,minWidth:r,selected:o,tone:d,children:(0,td.jsx)(ib,{children:b})})});dy.displayName="LoadingPane";let isSanityDocument=e=>(0,tc.Uy$)(e)&&"string"==typeof e._id&&"string"==typeof e._type;function usePreviewUrl(e){let[t,n]=(0,ts.useState)(void 0),[i,r]=(0,ts.useState)(null),{resolveProductionUrl:l}=(0,tc.Lky)().document,a=(0,tK.l)(e);if(i)throw i;return(0,ts.useEffect)(()=>{a.pipe((0,tZ.b)(500),(0,tv.w)(e=>isSanityDocument(e)?(0,tC.D)(l({document:e})):(0,tx.of)(void 0)),(0,tw.K)(e=>{let t=(0,tc.Uy$)(e)&&"string"==typeof e.message?e.message:"Unknown error";throw Error("An error was thrown while trying to get your preview url: ".concat(t))})).subscribe({next:n,error:r})},[l,a]),t}let dj=(0,ts.memo)(e=>{let{children:t,index:n,pane:i,paneKey:r,onFocusPath:l}=e,a=(0,tc.I_y)(),o=(0,tc.zEW)(),{actions:s,badges:d,unstable_fieldActions:c,unstable_languageFilter:u,inspectors:p}=(0,tc.Lky)().document,h=(0,tc.ap5)(),m=usePaneRouter(),f=m.setParams,{features:g}=useDeskTool(),{push:x}=(0,tp.pm)(),{options:b,menuItemGroups:v=i6,title:_=null,views:y=[]}=i,j=(0,tc.BoV)(b),w=j.id,k=(0,tc.vsM)(w),C=b.type,I=(0,tc.BoV)(m.params)||i5,S=(0,tc.BoV)(m.payload),{templateName:z,templateParams:P}=(0,ts.useMemo)(()=>(function(e,t){let n=t.panePayload||{},i=t.templateName;t.urlTemplate&&i&&i!==t.urlTemplate&&console.warn('Conflicting templates: URL says "'.concat(t.urlTemplate,'", structure node says "').concat(i,'". Using "').concat(i,'".'));let r=i||t.urlTemplate,l=e.filter(e=>e.schemaType===t.documentType),a={...t.templateParams,..."object"==typeof n&&n||{}},o=r;return r||1!==l.length||(o=l[0].id),{templateName:o,templateParams:a}})(o,{documentType:C,templateName:j.template,templateParams:j.templateParameters,panePayload:S,urlTemplate:I.template}),[C,j,I,S,o]),E=(0,tc.t2O)({documentId:k,documentType:C,templateName:z,templateParams:P}),D=(0,tc.BoV)(E),{patch:T}=(0,tc.d9t)(k,C),M=(0,tc.iav)(k,C),{validation:R}
1=(0,tc.a3k)(k,C),A=(0,tc.z1O)(k,C),O=a.get(C),L=(null==M?void 0:M.draft)||(null==M?void 0:M.published)||D.value,[B,N]=(0,ts.useState)(!1),$=(0,ts.useMemo)(()=>s({schemaType:C,documentId:k}),[s,k,C]),Z=(0,ts.useMemo)(()=>d({schemaType:C,documentId:k}),[d,k,C]),U=(0,ts.useMemo)(()=>u({schemaType:C,documentId:k}),[k,C,u]),F=(0,tc.BoV)(R),H=(0,tc.BoV)(y),[V,q]=(0,ts.useState)(()=>I.path?(0,tJ.mL)(I.path):tc.LZ8),W=(0,ts.useRef)(V),G=I.view||H[0]&&H[0].id||null,[K,Y]=(0,ts.useState)("closed"),[X,Q]=(0,ts.useState)(null),J=(0,tc.Dab)({documentId:k,documentType:C,onError:Q,rev:I.rev,since:I.since}),ee=(0,tc.P08)(J,e=>e.onOlderRevision),et=(0,tc.P08)(J,e=>e.revTime),en=(0,tc.P08)(J,e=>e.sinceAttributes),ei=(0,tc.P08)(J,e=>e.timelineDisplayed),er=(0,tc.P08)(J,e=>e.timelineReady),el=(0,tc.P08)(J,e=>e.isPristine),ea=(0,ts.useMemo)(()=>!!er&&!!(!(null==M?void 0:M.draft)&&!(null==M?void 0:M.published))&&!el,[null==M?void 0:M.draft,null==M?void 0:M.published,el,er]),eo=usePreviewUrl(L),[es,ed]=(0,ts.useState)([]);(0,ts.useEffect)(()=>{let e=h.documentPresence(k).subscribe(e=>{ed(e)});return()=>{e.unsubscribe()}},[k,h]);let ec=(0,ts.useMemo)(()=>p({documentId:k,documentType:C}),[k,C,p]),[eu,ep]=(0,ts.useState)(()=>I.inspect||null),eh=(0,ts.useRef)(I.inspect);(0,ts.useEffect)(()=>{eh.current!==I.inspect&&(eh.current=I.inspect,ep(I.inspect||null))},[I.inspect]);let em=null==ec?void 0:ec.find(e=>e.name===eu),ef=ec.find(e=>e.name===i8),eg=(null==em?void 0:em.name)===i8,{t:ex}=(0,tc.$G7)(nV),eb="on"===I.inspect,ev=eg?en:(null==M?void 0:M.published)||null,e_=(0,ts.useMemo)(()=>O?c({documentId:k,documentType:C,schemaType:O}):[],[k,C,c,O]),ey="connected"===A&&M.ready&&(er||!!X),ej=(0,ts.useMemo)(()=>ee?ei||{_id:L._id,_type:L._type}:L,[ee,ei,L]),ew=(0,ts.useCallback)((e,t)=>{f({...I,since:e,rev:t||void 0})},[I,f]),ek=(0,ts.useCallback)(e=>{q(e),W.current!==e&&(W.current=e,null==l||l(e)),h.setLocation([{type:"document",documentId:k,path:e,lastActiveAt:new Date().toISOString()}])},[k,l,h,q]),eC=(0,ts.useCallback)(e=>{e6.current||(q(tc.LZ8),W.current!==tc.LZ8&&(W.current=tc.LZ8,null==l||l(tc.LZ8)))},[l,q]),eI=(0,ts.useRef)(()=>{throw Error("Nope")});eI.current=e=>{T.execute((0,tc.GWp)(e.patches),D.value)};let eS=(0,ts.useCallback)(e=>eI.current(e),[]),ez=(0,ts.useCallback)(e=>{var t,n,i,r;let l=e&&ec.find(t=>t.name===e);if(e&&!l){console.warn('No inspector named "'.concat(e,'"'));return}if(em){if(l){let e=null!=(n=null==(t=l.onClose)?void 0:t.call(l,{params:I}))?n:{params:I};ep(null),eh.current=void 0,f({...e.params,inspect:void 0});return}if(em){let e=null!=(r=null==(i=em.onClose)?void 0:i.call(em,{params:I}))?r:{params:I};ep(null),eh.current=void 0,f({...e.params,inspect:void 0})}}},[em,ec,I,f]),eP=(0,ts.useCallback)((e,t)=>{var n,i,r,l;let a=ec.find(t=>t.name===e);if(!a){console.warn('No inspector named "'.concat(e,'"'));return}if((null==em?void 0:em.name)===a.name){f({...I,...t,inspect:a.name});return}let o=I;if(em){let e=null!=(i=null==(n=a.onClose)?void 0:n.call(a,{params:o}))?i:{params:o};o=e.params}let s=null!=(l=null==(r=a.onOpen)?void 0:r.call(a,{params:o}))?l:{params:o};ep(a.name),eh.current=a.name,f({...s.params,...t,inspect:a.name})},[em,ec,I,f]),eE=(0,ts.useCallback)(()=>{ef&&ez(ef.name)},[ez,ef]),eD=(0,ts.useCallback)(()=>{g.reviewChanges&&ef&&eP(ef.name)},[g.reviewChanges,eP,ef]),eT=(0,ts.useCallback)(()=>m.closeCurrent(),[m]),eM=(0,ts.useCallback)(()=>m.duplicateCurrent(),[m]),eR=(0,ts.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!eb;e?f({...I,inspect:"on"}):f(tQ()(I,"inspect"))},[eb,I,f]),eA=(0,ts.useCallback)(e=>{if("production-preview"===e.action&&eo)return window.open(eo),!0;if("inspect"===e.action)return eR(!0),!0;if("reviewChanges"===e.action)return eD(),!0;if("string"==typeof e.action&&e.action.startsWith(i3)){let t=e.action.slice(i3.length),n=ec.find(e=>e.name===t);if(n)return n.name===eu?ez(n.name):eP(n.name),!0}return!1},[ez,eD,eu,ec,eP,eo,eR]),eO=(0,ts.useCallback)(()=>eR(!1),[eR]),[eL,eB]=(0,ts.useState)([]),[eN,e$]=(0,ts.useState)(),[eZ,eU]=(0,ts.useState)(),[eF,eH]=(0,ts.useState)(),eV=(0,ts.useCallback)((e,t)=>{eU(n=>(0,tc.pt$)(n,e,t))},[]),eq=(0,ts.useCallback)((e,t)=>{eH(n=>(0,tc.pt$)(n,e,t))},[]),eW=(0,ts.useCallback)((e,t)=>e$(n=>(0,tc.pt$)(n,e,t)),[]),eG=L._createdAt?"update":"create",eK=!!(null==O?void 0:O.liveEdit),eY=L._id?L._id:"dummy-id",eX=(0,ts.useMemo)(()=>({...L,_id:eK?(0,tc.vsM)(eY):(0,tc.qyu)(eY)}),[eK,L,eY]),[eQ,eJ]=(0,tc.vSY)({document:eX,permission:eG}),e0=!(null==L?void 0:L._id),e1=(0,ts.useMemo)(()=>{var e;let t=!eJ&&!(null==eQ?void 0:eQ.granted),n=!(0,nM.jA)(O,"update"),i=e0&&!(0,nM.jA)(O,"create"),r="reconnecting"===A,l=null==(e=M.transactionSyncLock)?void 0:e.enabled;return!ey||null!==et||t||n||i||r||l||B||ea},[A,M.transactionSyncLock,e0,ea,B,eJ,null==eQ?void 0:eQ.granted,ey,et,O]),e2=(0,tc.clL)(O,{value:ej,readOnly:e1,comparisonValue:ev,focusPath:V,openPath:e
1L,collapsedPaths:eZ,presence:es,validation:F,collapsedFieldSets:eF,fieldGroupState:eN,changesOpen:eg}),e5=(0,ts.useRef)(e2);e5.current=e2;let e3=(0,ts.useCallback)(e=>{let t=(0,tc.C8M)(e5.current,e);t.forEach(e=>{"expandPath"===e.type&&eU(t=>(0,tc.pt$)(t,e.path,!1)),"expandFieldSet"===e.type&&eH(t=>(0,tc.pt$)(t,e.path,!1)),"setSelectedGroup"===e.type&&e$(t=>(0,tc.pt$)(t,e.path,e.groupName))}),eB(e)},[e5]);(0,ts.useEffect)(()=>{"reconnecting"===A&&x({id:"sanity/desk/reconnecting",status:"warning",title:ex("panes.document-pane-provider.reconnecting.title")})},[A,x,ex]);let e6=(0,ts.useRef)(!1);return(0,ts.useEffect)(()=>{var e;if(ey&&I.path){let{path:t,...n}=I,i=(0,tJ.vW)(null==(e=e5.current)?void 0:e.value,(0,tJ.mL)(t));e6.current=!0,q(i),e3(i),W.current!==i&&(W.current=i,null==l||l(i));let r=setTimeout(()=>{e6.current=!1},0);return m.setParams(n),()=>clearTimeout(r)}},[I,k,l,e3,ey,m]),(0,td.jsx)(iZ.Provider,{value:{actions:$,activeViewId:G,badges:Z,changesOpen:eg,closeInspector:ez,collapsedFieldSets:eF,collapsedPaths:eZ,compareValue:ev,connectionState:A,displayed:ej,documentId:k,documentIdRaw:w,documentType:C,editState:M,fieldActions:e_,focusPath:V,inspector:em||null,inspectors:ec,onBlur:eC,onChange:eS,onFocus:ek,onPathOpen:e3,onHistoryClose:eE,onHistoryOpen:eD,onInspectClose:eO,onMenuAction:eA,onPaneClose:eT,onPaneSplit:eM,onSetActiveFieldGroup:eW,onSetCollapsedPath:eV,onSetCollapsedFieldSet:eq,openInspector:eP,index:n,inspectOpen:eb,validation:F,menuItemGroups:v||[],paneKey:r,previewUrl:eo,ready:ey,schemaType:O,isPermissionsLoading:eJ,permissions:eQ,setTimelineMode:Y,setTimelineRange:ew,setIsDeleting:N,isDeleting:B,isDeleted:ea,timelineError:X,timelineMode:K,timelineStore:J,title:_,value:L,views:H,formState:e2,unstable_languageFilter:U},children:t})});dj.displayName="DocumentPaneProvider";let dw=["patch","commit"],dk=(0,ts.memo)(function(){let{push:e}=(0,tp.pm)(),{documentId:t,documentType:n}=useDocumentPane(),i=(0,tc.E6V)(t,n),r=(0,ts.useRef)(i),l=usePaneRouter(),{t:a}=(0,tc.$G7)(nV);return(0,ts.useEffect)(()=>{let t;if(i&&i!==r.current)return"error"===i.type&&e({closable:!0,duration:3e4,status:"error",title:a("panes.document-operation-results.operation-error",{context:i.op}),description:(0,td.jsxs)("details",{children:[(0,td.jsx)("summary",{children:a("panes.document-operation-results.error.summary.title")}),i.error.message]})}),"success"!==i.type||dw.includes(i.op)||e({closable:!0,status:"success",title:a("panes.document-operation-results.operation-success",{context:i.op})}),"success"===i.type&&"delete"===i.op&&(t=setTimeout(()=>l.closeCurrentAndAfter(),0)),r.current=i,()=>clearTimeout(t)},[i,l,e,a]),null});function useDeskToolSetting(e,t,n){let i=(0,tc.F2f)(),[r,l]=(0,ts.useState)(n),a=(0,ts.useMemo)(()=>i.forNamespace("desk-tool"),[i]),o=(0,ts.useMemo)(()=>e?a.forNamespace(e).forKey(t):a.forKey(t),[a,e,t]);(0,ts.useEffect)(()=>{let e=o.listen(n).subscribe({next:l});return()=>null==e?void 0:e.unsubscribe()},[n,t,e,o]);let s=(0,ts.useCallback)(e=>{l(e),o.set(e)},[o]);return(0,ts.useMemo)(()=>[r,s],[s,r])}let dC={id:"parsed",title:"document-inspector.view-mode.parsed"},dI={id:"raw",title:"document-inspector.view-mode.raw-json"},dS=[dC,dI],dz=nN()(1e3);function toggleExpanded(e){let{path:t}=e,n=dz.get(t);void 0!==n&&dz.set(t,!n)}function selectElement(e){let t=window.getSelection();if(t){let n=document.createRange();t.removeAllRanges(),n.selectNodeContents(e),t.addRange(n)}}function select(e){selectElement(e.currentTarget)}function maybeSelectAll(e){let t=65===e.keyCode&&(e.metaKey||e.ctrlKey);t&&(e.preventDefault(),selectElement(e.currentTarget))}var dP=Object.freeze,dE=Object.defineProperty,__template$a=(e,t)=>dP(dE(e,"raw",{value:dP(t||e.slice())}));let dD=th.ZP.div(e=>{let{theme:t}=e,{color:n,fonts:i,space:r}=t.sanity;return(0,th.iv)(e0||(e0=__template$a(["\n & .json-inspector,\n & .json-inspector .json-inspector__selection {\n font-family: ",";\n font-size: ","px;\n line-height: ","px;\n color: var(--card-code-fg-color);\n }\n\n & .json-inspector .json-inspector__leaf {\n padding-left: ",";\n }\n\n & .json-inspector .json-inspector__leaf.json-inspector__leaf_root {\n padding-top: ",";\n padding-left: 0;\n }\n\n & .json-inspector > .json-inspector__leaf_root > .json-inspector__line > .json-inspector__key {\n display: none;\n }\n\n & .json-inspector .json-inspector__line {\n display: block;\n position: relative;\n cursor: default;\n }\n\n & .json-inspector .json-inspector__line::after {\n content: '';\n position: absolute;\n top: 0;\n left: -200px;\n right: -50px;\n bottom: 0;\n z-index: -1;\n pointer-events: none;\n }\n\n & .json-inspector .json-inspector__line:hover::after {\n background: var(--card-code-bg-color);\n }\n\n & .json-inspector .json-inspector__leaf_composite > .json-inspector__line {\n cursor: pointer;\n }\n\n & .json-inspector .json-inspector__leaf_composite > .json-inspector__line::before {\n content: '⸠';\n margin-left: calc(0 - "," + 3px);\n font-size: ","px;\n line-height: ","px;\n }\n\n &\n .json-inspector\n .json-inspector__leaf_expanded.json-inspector__leaf_composite\n > .json-inspector__line::before {\n content: 'â¾ ';\n font-size: ","px;\n line-height: ","px;\n }\n\n & .json-inspector .json-inspector__radio,\n & .json-inspector .json-inspector__flatpath {\n display: none;\n }\n\n & .json-inspector .json-inspector__value {\n margin-left: ",";\n }\n\n &\n .json-inspector\n > .json-inspector__leaf_root\n > .json-inspector__line\n > .json-inspector__key\n + .json-inspector__value {\n margin: 0;\n }\n\n & .json-inspector .json-inspector__key {\n color: ",";\n }\n\n & .json-inspector .json-inspector__value_helper,\n & .json-inspector .json-inspector__value_null {\n color: ",";\n }\n\n & .json-inspector .json-inspector__not-found {\n padding-top: ",";\n }\n\n & .json-inspector .json-inspector__value_string {\n color: ",";\n }\n\n & .json-inspector .json-inspector__value_boolean {\n color: ",";\n }\n\n & .json-inspector .json-inspector__value_number {\n color: ",";\n }\n\n & .json-inspector .json-inspector__show-original {\n display: inline-block;\n padding: 0 6px;\n cursor: pointer;\n }\n\n & .json-inspector .json-inspector__show-original:hover {\n color: inherit;\n }\n\n & .json-inspector .json-inspector__show-original::before {\n content: 'â';\n }\n\n & .json-inspector .json-inspector__show-original:hover::after {\n content: ' expand';\n }\n "])),i.code.family,i.code.sizes[2].fontSize,i.code.sizes[2].lineHeight,(0,tp.hO)(r[4]),(0,tp.hO)(r[3]),(0,tp.hO)(r[4]),i.code.sizes[2].fontSize,i.code.sizes[2].lineHeight,i.code.sizes[2].fontSize,i.code.sizes[2].lineHeight,(0,tp.hO)(r[4]/2),n.syntax.property,n.syntax.constant,(0,tp.hO)(r[3]),n.syntax.string,n.syntax.boolean,n.syntax.number)});function Search(e){let{onChange:t,query:n}=e,i=(0,ts.useCallback)(e=>t(e.target.value),[t]),{t:r}=(0,tc.$G7)(nV);return(0,td.jsx)(tp.oi,{icon:to.W1M,onChange:i,placeholder:r("document-inspector.search.placeholder"),radius:2,value:n||""})}function InspectDialog(e){let{value:t}=e,{onInspectClose:n,paneKey:i}=useDocumentPane(),r="".concat(i,"_inspect_"),[l,a]=useDeskToolSetting("desk-tool","inspect-view-preferred-view-mode-".concat(i),"parsed"),o=dS.find(e=>e.id===l),s=(0,ts.useCallback)(()=>
1{a(dC.id)},[a]),d=(0,ts.useCallback)(()=>{a(dI.id)},[a]),{t:c}=(0,tc.$G7)(nV);return(0,td.jsx)(tp.Vq,{id:"".concat(r,"dialog"),header:(0,tc.Uy$)(t)&&(0,tc.HD0)(t._id)&&(0,tc.HD0)(t._type)?(0,td.jsx)(tc.vNl,{t:c,i18nKey:"document-inspector.dialog.title",components:{DocumentTitle:()=>(0,td.jsx)("em",{children:(0,td.jsx)(DocTitle,{document:t})})}}):(0,td.jsx)("em",{children:c("document-inspector.dialog.title-no-value")}),onClose:n,onClickOutside:n,width:3,children:(0,td.jsxs)(tp.kC,{direction:"column",height:"fill",children:[(0,td.jsx)(tp.Zb,{padding:3,shadow:1,style:{position:"sticky",bottom:0,zIndex:3},children:(0,td.jsxs)(tp.td,{space:1,children:[(0,td.jsx)(tp.OK,{"aria-controls":"".concat(r,"tabpanel"),fontSize:1,id:"".concat(r,"tab-").concat(dC.id),label:c(dC.title),onClick:s,selected:o===dC}),(0,td.jsx)(tp.OK,{"aria-controls":"".concat(r,"tabpanel"),fontSize:1,id:"".concat(r,"tab-").concat(dI.id),label:c(dI.title),onClick:d,selected:o===dI})]})}),(0,td.jsxs)(tp.x4,{"aria-labelledby":"".concat(r,"tab-").concat(l),flex:1,id:"".concat(r,"tabpanel"),overflow:"auto",padding:4,style:{outline:"none"},children:[o===dC&&(0,td.jsx)(dD,{children:(0,td.jsx)(nL(),{data:t,isExpanded:function isExpanded(e,t){let n=dz.get(e);return void 0===n?(dz.set(e,Array.isArray(t)||(0,tc.Uy$)(t)),isExpanded(e,t)):n},onClick:toggleExpanded,search:Search})}),o===dI&&(0,td.jsx)(tp.EK,{language:"json",tabIndex:0,onKeyDown:maybeSelectAll,onDoubleClick:select,onFocus:select,children:JSON.stringify(t,null,2)})]})]})})}var dT=Object.freeze,dM=Object.defineProperty;let dR=(0,th.ZP)(tp.Zb)(e1||(e1=dT(dM(E=["\n position: relative;\n z-index: 50;\n"],"raw",{value:dT(E.slice())}))));function DeletedDocumentBanner(e){let{revisionId:t}=e,{documentId:n,documentType:i}=useDocumentPane(),{restore:r}=(0,tc.d9t)(n,i),{navigateIntent:l}=(0,tY.tv)(),a=(0,ts.useCallback)(()=>{t&&(r.execute(t),l("edit",{id:n,type:i}))},[n,i,l,r,t]),{t:o}=(0,tc.$G7)(nV);return(0,td.jsx)(dR,{"data-testid":"deleted-document-banner",shadow:1,tone:"transparent",children:(0,td.jsx)(tp.W2,{paddingX:4,paddingY:t?2:3,sizing:"border",width:1,children:(0,td.jsxs)(tp.kC,{align:"center",children:[(0,td.jsx)(tp.xv,{size:1,children:(0,td.jsx)(to.CPA,{})}),(0,td.jsxs)(tp.kC,{align:"center",gap:2,flex:1,marginLeft:3,children:[(0,td.jsx)(tp.xv,{size:1,children:o("banners.deleted-document-banner.text")}),t&&(0,td.jsx)(tp.zx,{fontSize:1,padding:2,mode:"bleed",tone:"primary",onClick:a,text:o("banners.deleted-document-banner.restore-button.text")})]})]})})})}var dA=Object.freeze,dO=Object.defineProperty,__template$8=(e,t)=>dA(dO(e,"raw",{value:dA(t||e.slice())}));let dL=(0,th.ZP)(tp.Zb)(e2||(e2=__template$8(["\n position: relative;\n z-index: 50;\n"]))),dB=(0,th.ZP)(tp.xv)(e5||(e5=__template$8(["\n & > * {\n overflow: hidden;\n overflow: clip;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n"]))),dN=(0,ts.memo)(()=>{var e,t,n,i,r,l;let a=(0,tc.rq_)(),{params:o,groupIndex:s,routerPanesState:d,replaceCurrent:c,BackLink:u}=usePaneRouter(),p=null==(e=d[s])?void 0:e[0].id,h=d[s-1],m=null==h?void 0:h[0],f=null==m?void 0:m.id,g=!!(null==(t=null==m?void 0:m.params)?void 0:t.rev),x=(0,ts.useMemo)(()=>(null==o?void 0:o.parentRefPath)&&(0,tJ.mL)(o.parentRefPath)||null,[null==o?void 0:o.parentRefPath]),{t:b}=(0,tc.$G7)(nV),v=(0,tK.m2)(()=>{let e=null==x?void 0:x[0];if(!f||!e||!x)return(0,tx.of)({loading:!1});let t=(0,tc.vsM)(f),n=(0,tJ.mL)(e),i=n.findIndex(e=>"object"==typeof e&&"_key"in e);return(0,tj.z)((0,tx.of)({loading:!0}),a.unstable_observePathsDocumentPair(t,-1===i?n:n.slice(0,i)).pipe((0,tZ.b)(750),(0,tb.U)(e=>{var t;let{draft:n,published:i}=e;return{loading:!1,result:{availability:{draft:n.availability,published:i.availability},refValue:null==(t=(0,tJ.U2)(n.snapshot||i.snapshot,x))?void 0:t._ref}}})))},[a,f,x],{loading:!0}),_=(0,ts.useCallback)(()=>{var e;!v.loading&&(null==(e=v.result)?void 0:e.refValue)&&c({id:v.result.refValue,params:o})},[v.loading,v.result,c,o]),y=!f||!x||g||v.loading||!(null==(n=v.result)?void 0:n.availability.draft.available)&&!(null==(i=v.result)?void 0:i.availability.published.available)||(null==(r=v.result)?void 0:r.refValue)===p;return y?null:(0,td.jsx)(dL,{shadow:1,tone:"caution","data-testid":"reference-changed-banner",children:(0,td.jsx)(tp.W2,{paddingX:4,paddingY:2,sizing:"border",width:1,children:(0,td.jsxs)(tp.kC,{align:"center",children:[(0,td.jsx)(tp.xv,{size:1,children:(0,td.jsx)(to.foC,{})}),(null==(l=v.result)?void 0:l.refValue)?(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)(tp.xu,{flex:1,marginLeft:3,children:(0,td.jsx)(dB,{title:b("banners.reference-changed-banner.reason-changed.text"),size:1,children:b("banners.reference-changed-banner.reason-changed.text")})}),(0,td.jsx)(tp.xu,{marginLeft:3,children:(0,td.jsx)(tp.zx,{onClick:_,icon:to.bnu,fontSize:1,mode:"ghost",padding:2,space:2,text:b("banners.reference-changed-banner.reason-changed.reload-button.text")})})]}):(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)(tp.xu,{flex:1,marginLeft:3,children:(0,td.jsx)(dB,{title:b("banners.reference-changed-banner.reason-removed.text"),size:1,children:b("banners.reference-changed-banner.reason-removed.text")})}),(0,td.jsx)(tp.xu,{marginLeft:3,children:(0,td.jsx)(tp.zx,{as:u,icon:to.Two,fontSize:1,mode:"ghost",padding:2,space:2,text:b("banners.reference-changed-banner.reason-removed.close-button.text")})})]})]})})})});dN.displayName="ReferenceChangedBanner";var d$=Object.freeze,dZ=Object.defineProperty;let dU=(0,th.ZP)(tp.Zb)(e3||(e3=d$(dZ(D=["\n position: relative;\n z-index: 50;\n"],"raw",{value:d$(D.slice())}))));function PermissionCheckBanner(e){let{granted:t,requiredPermission:n}=e,i=(0,tc.xJ)(),r=(0,tc.WEl)({style:"short"}),{t:l}=(0,tc.$G7)(nV);if(t)return null;let a=((null==i?void 0:i.roles)||[]).map(e=>e.title),o=r.formatToParts(a).map(e=>"element"===e.type?(0,td.jsx)("code",{children:e.value},e.value):e.value);return(0,td.jsx)(dU,{"data-testid":"permission-check-banner",shadow:1,tone:"transparent",children:(0,td.jsx)(tp.W2,{paddingX:4,paddingY:3,sizing:"border",width:1,children:(0,td.jsxs)(tp.kC,{align:"flex-start",children:[(0,td.jsx)(tp.xv,{size:1,children:(0,td.jsx)(to.CPA,{})}),(0,td.jsx)(tp.xu,{flex:1,marginLeft:3,children:(0,td.jsx)(tp.xv,{size:1,children:(0,td.jsx)(tc.vNl,{t:l,i18nKey:"banners.permission-check-banner.missing-permission",components:{Roles:()=>(0,td.jsx)(td.Fragment,{children:o})},values:{count:o.length,roles:a},context:n})})})]})})})}let preventDefault=e=>e.preventDefault(),dF=(0,ts.forwardRef)(function(e,t){var n;let{hidden:i,margins:r}
1=e,{collapsedFieldSets:l,collapsedPaths:a,displayed:o,editState:s,documentId:d,documentType:c,fieldActions:u,onChange:p,validation:h,ready:m,formState:f,onFocus:g,onBlur:x,onSetCollapsedPath:b,onPathOpen:v,onSetCollapsedFieldSet:_,onSetActiveFieldGroup:y}=useDocumentPane(),j=(0,tc.H__)(),w=(0,tc.Dqo)(d),k=(0,ts.useMemo)(()=>(0,tc.fm0)(),[]),C=null==(n=null==s?void 0:s.transactionSyncLock)?void 0:n.enabled,{t:I}=(0,tc.$G7)(nV);!function(e){let t=(0,tp.pm)(),n=function(e){let t=(0,ts.useRef)();return(0,ts.useEffect)(()=>{t.current=e},[e]),t.current}(e.enabled);(0,ts.useEffect)(()=>{!n&&e.enabled&&t.push({...e,duration:20736e5}),n&&!e.enabled&&t.push({...e,duration:.01})},[e,t,n])}({id:"sync-lock-".concat(d),status:"warning",enabled:C,title:I("document-view.form-view.sync-lock-toast.title"),description:I("document-view.form-view.sync-lock-toast.description")}),(0,ts.useEffect)(()=>{let e=j.pair.documentEvents(d,c).pipe((0,tR.b)(e=>{"mutation"===e.type&&k.publish(function(e){let t=e.mutations.map(e=>e.patch).filter(Boolean);return{type:"mutation",snapshot:e.document,patches:(0,tc.Sis)(e.origin,t)}}(e)),"rebase"===e.type&&k.publish(function(e){let t=e.remoteMutations.map(e=>e.patch).filter(Boolean),n=e.localMutations.map(e=>e.patch).filter(Boolean);return{type:"rebase",snapshot:e.document,patches:(0,tc.Sis)("remote",t).concat((0,tc.Sis)("local",n))}}(e))})).subscribe();return()=>{e.unsubscribe()}},[d,j,c,k]);let S=!!(null==o?void 0:o._rev);(0,ts.useEffect)(()=>{S&&k.publish({type:"mutation",patches:[],snapshot:o})},[S]);let[z,P]=(0,ts.useState)(null);(0,ts.useEffect)(()=>{m&&!(null==f?void 0:f.focusPath.length)&&z&&(0,tp.fo)(z)},[m]);let E=(0,ts.useCallback)(e=>{P(e),"function"==typeof t?t(e):t&&(t.current=e)},[t]);return(0,td.jsx)(tp.W2,{hidden:i,paddingX:4,paddingTop:5,paddingBottom:9,sizing:"border",width:1,children:(0,td.jsx)(tc.$rW,{margins:r,children:(0,td.jsx)(tp.xu,{as:"form",onSubmit:preventDefault,ref:E,children:m?null===f||i?(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{children:I("document-view.form-view.form-hidden")})}):(0,td.jsx)(tc.quP,{__internal_fieldActions:u,__internal_patchChannel:k,collapsedFieldSets:l,collapsedPaths:a,focusPath:f.focusPath,changed:f.changed,focused:f.focused,groups:f.groups,id:"root",members:f.members,onChange:p,onFieldGroupSelect:y,onPathBlur:x,onPathFocus:g,onPathOpen:v,onSetFieldSetCollapsed:_,onSetPathCollapsed:b,presence:w,readOnly:f.readOnly,schemaType:f.schemaType,validation:h,value:f.value}):(0,td.jsx)(Delay,{ms:300,children:(0,td.jsxs)(tp.kC,{align:"center",direction:"column",height:"fill",justify:"center",children:[(0,td.jsx)(tp.$j,{muted:!0}),(0,td.jsx)(tp.xu,{marginTop:3,children:(0,td.jsx)(tp.xv,{align:"center",muted:!0,size:1,children:I("document-view.form-view.loading")})})]})})})})})});var dH=Object.freeze,dV=Object.defineProperty,__template$6=(e,t)=>dH(dV(e,"raw",{value:dH(t||e.slice())}));let dq=(0,th.ZP)(tp.xu)({position:"relative"}),dW=(0,th.ZP)(tc.l$t)(e=>{let{$disabled:t}=e;return t?{height:"100%"}:(0,th.iv)(e6||(e6=__template$6(["\n height: 100%;\n overflow: auto;\n position: relative;\n scroll-behavior: smooth;\n outline: none;\n "])))}),DocumentPanel=function(e){let{footerHeight:t,headerHeight:n,isInspectOpen:i,rootElement:r,setDocumentPanelPortalElement:l}=e,{activeViewId:a,displayed:o,documentId:s,editState:d,inspector:c,value:u,views:p,ready:h,schemaType:m,permissions:f,isPermissionsLoading:g,isDeleting:x,isDeleted:b,timelineStore:v}=useDocumentPane(),{collapsed:_}=usePaneLayout(),{collapsed:y}=usePane(),j=(0,tp.vI)(),{features:w}=useDeskTool(),k=(0,ts.useRef)(null),[C,I]=(0,ts.useState)(null),S=(0,ts.useRef)(null),z=u._createdAt?"update":"create",P=(0,ts.useMemo)(()=>p.find(e=>e.id===a)||p[0]||{type:"form"},[a,p]),E=w.splitPanes&&k.current||j.element,D=(0,ts.useMemo)(()=>_?[n||0,0,t?t+2:2,0]:[0,0,2,0],[_,t,n]),T="form"!==P.type,M=(0,ts.useMemo)(()=>"component"===P.type&&P.component&&(0,ts.createElement)(P.component,{document:{draft:(null==d?void 0:d.draft)||null,displayed:o||u,historical:o,published:(null==d?void 0:d.published)||null},documentId:s,options:P.options,schemaType:m}),[P,o,s,null==d?void 0:d.draft,null==d?void 0:d.published,m,u]),R=(0,tc.P08)(v,e=>e.lastNonDeletedRevId);(0,ts.useEffect)(()=>{(null==C?void 0:C.scrollTo)&&C.scrollTo(0,0)},[s,C]),(0,ts.useEffect)(()=>{E&&l(E)},[E,l]);let A=(0,ts.useMemo)(()=>i?(0,td.jsx)(InspectDialog,{value:o||u}
1):null,[i,o,u]),O=!!(!y&&c);return(0,td.jsx)(ib,{children:(0,td.jsxs)(tp.kC,{height:"fill",children:[(w.resizablePanes||!O)&&(0,td.jsx)(dq,{flex:2,overflow:"hidden",children:(0,td.jsx)(tp.Xp,{element:E,__unstable_elements:{documentScrollElement:C},children:(0,td.jsx)(tp.NM,{element:C,children:(0,td.jsxs)(tc.Ahg,{scrollElement:C,containerElement:S,children:["form"===P.type&&!g&&h&&(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)(PermissionCheckBanner,{granted:!!(null==f?void 0:f.granted),requiredPermission:z}),!x&&b&&(0,td.jsx)(DeletedDocumentBanner,{revisionId:R}),(0,td.jsx)(dN,{})]}),(0,td.jsxs)(dW,{$disabled:_||!1,"data-testid":"document-panel-scroller",ref:I,children:[(0,td.jsx)(dF,{hidden:T,margins:D,ref:S},s+(h?"_ready":"_pending")),M]}),A,(0,td.jsx)("div",{"data-testid":"document-panel-portal",ref:k})]})})})}),O&&(0,td.jsx)(tp.NM,{element:r,children:(0,td.jsx)(DocumentInspectorPanel,{documentId:s,documentType:m.name,flex:1})})]})})},dG=["left","bottom"],dK={small:0,medium:1,large:2,full:"auto"};function ConfirmDialog(e){let{dialog:t,referenceElement:n}=e;return(0,td.jsx)(tp.J2,{content:(0,td.jsx)(ConfirmDialogContent,{dialog:t}),fallbackPlacements:dG,open:!0,placement:"top",portal:!0,preventOverflow:!0,referenceElement:n})}function ConfirmDialogContent(e){let{dialog:t}=e,{cancelButtonIcon:n,cancelButtonText:i,confirmButtonIcon:r,confirmButtonText:l,message:a,onCancel:o,onConfirm:s,tone:d}=t,{t:c}=(0,tc.$G7)(nV),{isTopLayer:u}=(0,tp.sJ)(),[p,h]=(0,ts.useState)(null),m=(0,ts.useCallback)(()=>{u&&o()},[u,o]),f=(0,ts.useCallback)(e=>{"Escape"===e.key&&u&&o()},[u,o]);return(0,tp.O8)(m,[p]),(0,tp.qh)(f),(0,td.jsxs)(tp.kC,{direction:"column",ref:h,style:{minWidth:304,maxWidth:400},children:[(0,td.jsx)(tp.xu,{flex:1,overflow:"auto",padding:4,children:(0,td.jsx)(tp.xv,{children:a})}),(0,td.jsx)(tp.xu,{paddingX:4,paddingY:3,style:{borderTop:"1px solid var(--card-border-color)"},children:(0,td.jsxs)(tp.rj,{columns:2,gap:2,children:[(0,td.jsx)(tp.zx,{icon:n,onClick:o,mode:"ghost",text:i||c("confirm-dialog.cancel-button.fallback-text")}),(0,td.jsx)(tp.zx,{icon:r,onClick:s,text:l||c("confirm-dialog.confirm-button.fallback-text"),tone:d})]})})]})}function ModalDialog(e){let{dialog:t}=e,n=(0,ts.useId)(),i=t.footer&&(0,td.jsx)(tp.xu,{paddingX:4,paddingY:3,children:t.footer});return(0,td.jsx)(tc.jr5,{zOffset:"fullscreen",children:(0,td.jsx)(tp.Vq,{__unstable_hideCloseButton:!1===t.showCloseButton,footer:i,header:t.header,id:n,onClose:t.onClose,onClickOutside:t.onClose,width:void 0===t.width?1:dK[t.width],children:(0,td.jsx)(tp.xu,{padding:4,children:t.content})})})}function PopoverDialog(e){let{dialog:t,referenceElement:n}=e;return(0,td.jsx)(tp.J2,{content:(0,td.jsx)(PopoverDialogContent,{dialog:t}),fallbackPlacements:dG,open:!0,placement:"top",portal:!0,preventOverflow:!0,referenceElement:n})}function PopoverDialogContent(e){let{dialog:t}=e,{content:n,onClose:i}=t,{isTopLayer:r}=(0,tp.sJ)(),[l,a]=(0,ts.useState)(null),o=(0,ts.useCallback)(()=>{r&&i()},[r,i]),s=(0,ts.useCallback)(e=>{"Escape"===e.key&&r&&i()},[r,i]);return(0,tp.O8)(o,[l]),(0,tp.qh)(s),(0,td.jsx)("div",{ref:a,children:n})}function DocumentActionPortalProvider(e){let{children:t}=e,{element:n,elements:i}=(0,tp.vI)(),r=(null==i?void 0:i[iY])||n;return(0,td.jsx)(tp.Xp,{element:r,children:t})}function ActionStateDialog(e){let{dialog:t,referenceElement:n=null}=e,i=(0,ts.useId)();return"confirm"===t.type?(0,td.jsx)(ConfirmDialog,{dialog:t,referenceElement:n}):"popover"===t.type?(0,td.jsx)(PopoverDialog,{dialog:t,referenceElement:n}):"dialog"!==t.type&&t.type?"custom"===t.type?(0,td.jsx)(DocumentActionPortalProvider,{children:null==t?void 0:t.component}):(console.warn("Unsupported modal type ".concat(t.type)),(0,td.jsx)(tp.Vq,{id:i,onClose:t.onClose,onClickOutside:t.onClose,width:2,children:(0,td.jsx)(tp.xu,{padding:4,children:t.content||(0,td.jsxs)(td.Fragment,{children:["Unexpected modal type (",(0,td.jsx)("code",{children:t.type}),")"]})})})):(0,td.jsx)(DocumentActionPortalProvider,{children:(0,td.jsx)(ModalDialog,{dialog:t})})}function ActionMenuButton(e){let{actionStates:t,disabled:n}=e,i=(0,ts.useId)(),r=(0,ts.useRef)(null),[l,a]=(0,ts.useState)(-1),[o,s]=(0,ts.useState)(null),d=(0,ts.useCallback)(e=>{a(e)},[]),c=(0,ts.useMemo)(()=>({placement:"top-end",portal:!0,preventOverflow:!0}),[]),u=t[l],{t:p}=(0,tc.$G7)(nV);return(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)(tp.j2,{id:"".concat(i,"-action-menu"),button:(0,td.jsx)(tp.zx,{"data-testid":"action-menu-button","aria-label":p("buttons.action-menu-button.aria-label"),disabled:n,icon:to.v4q,mode:"ghost",ref:r}),menu:(0,td.jsx)(tp.v2,{padding:1,children:t.map((e,t)=>(0,td.jsx)(ActionMenuListItem,{actionState:e,disabled:n,index:t,onAction:d},t))}),popover:c,ref:s}),u&&u.dialog&&(0,td.jsx)(tc.jr5,{zOffset:"paneFooter",children:(0,td.jsx)(ActionStateDialog,{dialog:u.dialog,referenceElement:o})})]})}function ActionMenuListItem(e){let{actionState:t,disabled:n,index:i,onAction:r}=e,{onHandle:l}=t,a=(0,ts.useCallback)(()=>{r(i),l&&l()},[i,r,l]),o=t.title&&(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{size:1,children:t.title})});return(0,td.jsx)(tp.sN,{"data-testid":"action-".concat(t.label.replace(" ","")),disabled:n||!!t.disabled,onClick:a,padding:0,tone:t.tone,children:(0,td.jsx)(tp.u,{content:o,disabled:!o,fallbackPlacements:["left","bottom"],placement:"top",portal:!0,children:(0,td.jsxs)(tp.kC,{align:"center",paddingX:3,children:[(0,td.jsxs)(tp.kC,{flex:1,paddingY:3,children:[t.icon&&(0,td.jsx)(tp.xu,{marginRight:3,children:(0,td.jsxs)(tp.xv,{children:[(0,ts.isValidElement)(t.icon)&&t.icon,(0,nT.isValidElementType)(t.icon)&&(0,ts.createElement)(t.icon)]})}),(0,td.jsx)(tp.xv,{children:t.label})]}),t.shortcut&&(0,td.jsx)(tp.xu,{marginLeft:3,children:(0,td.jsx)(tc.SV0,{keys:String(t.shortcut).split("+").map(e=>e.slice(0,1).toUpperCase()+e.slice(1))})})]})})})}function DocumentStatusBarActionsInner(e){let{disabled:t,showMenu:n,states:i}=e,[r,...l]=i,[a,o]=(0,ts.useState)(null),s=(0,ts.useMemo)(()=>r&&(r.title||r.shortcut)?(0,td.jsxs)(tp.kC,{padding:2,style:{maxWidth:300},align:"center",children:[(0,td.jsx)(tp.xv,{size:1,children:r.title}),r.shortcut&&(0,td.jsx)(tp.xu,{marginLeft:r.title?2:0,children:(0,td.jsx)(tc.SV0,{keys:String(r.shortcut).split("+").map(e=>e.slice(0,1).toUpperCase()+e.slice(1).toLowerCase())})})]}):null,[r]);return(0,td.jsxs)(tp.kC,{children:[r&&(0,td.jsx)(tp.li,{zOffset:200,children:(0,td.jsx)(tp.u,{disabled:!s,content:s,portal:!0,placement:"top",children:(0,td.jsx)(tp.Kq,{flex:1,children:(0,td.jsx)(tp.zx,{"data-testid":"action-".concat(r.label),disabled:t||!!r.disabled,icon:r.icon,onClick:r.onHandle,ref:o,text:r.label,tone:r.tone||"primary"})})})}),n&&l.length>0&&(0,td.jsx)(tp.xu,{marginLeft:1,children:(0,td.jsx)(ActionMenuButton,{actionStates:l,disabled:t})}),r&&r.dialog&&(0,td.jsx)(ActionStateDialog,{dialog:r.dialog,referenceElement:a})]})}let dY=(0,ts.memo)(function(){let{actions:e,connectionState:t,documentId:n,editState:i}=useDocumentPane();return e&&i?(0,td.jsx)(RenderActionCollectionState,{actions:e,actionProps:i,children:i=>{let{states:r}=i;return(0,td.jsx)(DocumentStatusBarActionsInner,{disabled:"connected"!==t,showMenu:e.length>1,states:r},n)}}):null}),dX=(0,ts.memo)(function(){let{connectionState:e,editState:t,timelineStore:n}=useDocumentPane(),i=(0,tc.P08)(n,e=>e.revTime),r=(null==i?void 0:i.id)||"",l=((null==t?void 0:t.draft)||(null==t?void 0:t.published)||{})._rev===r,a=(0,ts.useMemo)(()=>({...t||{},revision:r}),[t,r]),o=(0,ts.useMemo)(()=>[HistoryRestoreAction],[]);return(0,td.jsx)(RenderActionCollectionState,{actions:o,actionProps:a,children:t=>{let{states:n}=t;return(0,td.jsx)(DocumentStatusBarActionsInner,{disabled:"connected"!==e||!!l,showMenu:!1,states:n})}})}),dQ={primary:"primary",success:"positive",warning:"caution",danger:"critical"};function DocumentBadgesInner(e){let{states:t}=e;return(0,td.jsx)(tp.gF,{space:1,children:t.map((e,t)=>(0,td.jsx)(tp.u,{content:e.title&&(0,td.jsx)(tp.xu,{padding:2,children:(0,td.jsx)(tp.xv,{size:1,children:e.title})}),disabled:!e.title,placement:"top",portal:!0,children:(0,td.jsx)(tp.Ct,{fontSize:1,mode:"outline",paddingX:2,paddingY:1,radius:4,tone:e.color?dQ[e.color]:void 0,style:{whiteSpace:"nowrap"},children:e.label})},String(t)))})}function DocumentBadges(){let{badges:e,editState:t}=useDocumentPane();return t&&e?(0,td.jsx)(RenderBadgeCollectionState,{badges:e,badgeProps:t,children:e=>{let{states:t}=e;return(0,td.jsx)(DocumentBadgesInner,{states:t})}}):null}var dJ=Object.freeze,d0=Object.defineProperty;let d1=(0,th.ZP)(tp.kC)(e8||(e8=dJ(d0(T=["\n cursor: default;\n"],"raw",{value:dJ(T.slice())}))));
1function PublishStatus(e){let{collapsed:t,disabled:n,lastPublished:i,lastUpdated:r,liveEdit:l}=e,{t:a}=(0,tc.$G7)(nV),o=(0,tc.ofl)(i||"",{minimal:!0,useTemporalPhrase:!0}),s=(0,tc.ofl)(i||"",{minimal:!0}),d=(0,tc.ofl)(r||"",{minimal:!0,useTemporalPhrase:!0}),c=(0,tc.ofl)(r||"",{minimal:!0}),u=(0,tc.ofl)(r||"",{minimal:!1,useTemporalPhrase:!0}),p=(0,tc.ofl)(i||"",{minimal:!1,useTemporalPhrase:!0}),h=l?a("status-bar.publish-status-button.last-updated-time.aria-label",{relativeTime:u}):a("status-bar.publish-status-button.last-published-time.aria-label",{relativeTime:p});return(0,td.jsx)(d1,{align:"center","data-ui":"PublishStatus",sizing:"border",children:(0,td.jsx)(tp.u,{placement:"top",portal:!0,content:(0,td.jsx)(tp.Kq,{padding:3,space:3,children:(0,td.jsx)(tp.xv,{size:1,children:l?(0,td.jsx)(tc.vNl,{t:a,i18nKey:"status-bar.publish-status-button.last-updated-time.tooltip",components:{RelativeTime:()=>(0,td.jsx)("time",{dateTime:r,"aria-label":r?u:p,children:r?d:o})}}):(0,td.jsx)(tc.vNl,{t:a,i18nKey:"status-bar.publish-status-button.last-published-time.tooltip",components:{RelativeTime:()=>(0,td.jsx)("time",{dateTime:i,"aria-label":p,children:o})}})})}),children:(0,td.jsx)(tp.zx,{mode:"bleed",tone:l?"critical":"positive",tabIndex:-1,disabled:n,"aria-label":h,children:(0,td.jsxs)(tp.kC,{align:"center",children:[(0,td.jsx)(tp.xu,{marginRight:t?0:3,children:(0,td.jsx)(tp.xv,{size:2,"aria-hidden":"true",children:l?(0,td.jsx)(to.o1U,{}):(0,td.jsx)(to.EI4,{})})}),!t&&(0,td.jsx)(tp.xv,{size:1,weight:"medium",children:l?(0,td.jsx)("time",{dateTime:r||i,"aria-label":h,children:r?c:s}):(0,td.jsx)("time",{dateTime:i,"aria-label":h,children:s})})]})})})})}var d2=Object.freeze,d5=Object.defineProperty,__template$4=(e,t)=>d2(d5(e,"raw",{value:d2(t||e.slice())}));let d3=(0,th.ZP)(nx.E.path)(e4||(e4=__template$4(["\n transform-origin: center;
1\n"]))),Circle=e=>(0,td.jsx)(nx.E.circle,{fill:"none",r:"8",cx:"12.5",cy:"12.5",strokeWidth:"1.2",...e}),Arrows=e=>(0,td.jsx)(d3,{fill:"none",d:"M14 17.5619L11.5 20.5L14.5 23.0619M11 7.43811L13.5 4.50001L10.5 1.93811",...e}),Checkmark=e=>(0,td.jsx)(nx.E.path,{d:"M9.5 12.1316L11.7414 14.5L16 10",...e}),Edit=e=>(0,td.jsx)(nx.E.path,{d:"M15 7L18 10M6 19L7 15L17 5L20 8L10 18L6 19Z",...e}),d6=(0,th.F4)(e9||(e9=__template$4(["\n 0% {\n transform: rotate(0);\n }\n 100% {\n transform: rotate(360deg);\n }\n"]))),d8=th.ZP.g(e7||(e7=__template$4(["\n transform-origin: center;\n\n &[data-rotate] {\n animation: "," 1s ease-in-out infinite;\n }\n"])),d6),d4={syncing:{scale:1,transition:{duration:0}},saved:{scale:[1,.8,1.2,.9,1.1,.95,1.05,.99,1],transition:{duration:.5,delay:.2}},changes:{transition:{duration:0}}},d9={syncing:{strokeDasharray:"0, 0, 23, 3, 23, 3",strokeDashoffset:10,opacity:1,transition:{duration:0}},saved:{strokeDasharray:"0, 0, 23, 0, 23, 0",strokeDashoffset:10,opacity:1,transition:{duration:.2}},changes:{strokeDasharray:"0, 60, 23, 0, 23, 0",strokeDashoffset:0,opacity:0,transition:{duration:.5}}},d7={syncing:{opacity:1,transition:{duration:0}},saved:{opacity:0,transition:{duration:.2}},changes:{opacity:0}},ce={syncing:{pathLength:0,transition:{duration:0}},saved:{pathLength:1,transition:{delay:.4,duration:.3}},changes:{pathLength:0,transition:{duration:.2}}},ct={syncing:{pathLength:0,transition:{duration:0}},saved:{pathLength:0,transition:{duration:0}},changes:{pathLength:1,transition:{duration:.4,delay:.5}}};function AnimatedStatusIcon(e){let{status:t}=e;return t?(0,td.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",stroke:"currentColor",strokeWidth:"1.2","data-sanity-icon":"",children:(0,td.jsxs)(nx.E.g,{variants:d4,initial:t,animate:t,children:[(0,td.jsxs)(d8,{"data-rotate":"changes"===t?void 0:"",children:[(0,td.jsx)(Arrows,{variants:d7,initial:t,animate:t}),(0,td.jsx)(Circle,{variants:d9,initial:t,animate:t})]}),(0,td.jsx)(Checkmark,{variants:ce,initial:t,animate:t}),(0,td.jsx)(Edit,{variants:ct,initial:t,animate:t})]})}):null}let cn=ts.forwardRef(function(e,t){let{collapsed:n,status:i,lastUpdated:r,...l}=e,a=(0,tc.ofl)(r||"",{minimal:!0}),o=(0,tc.ofl)(r||"",{minimal:!0,useTemporalPhrase:!0}),s=(0,tc.ofl)(r||"",{minimal:!1,useTemporalPhrase:!0}),{t:d}=(0,tc.$G7)(nV),c=(0,ts.useMemo)(()=>"syncing"===i?{text:d("status-bar.review-changes-button.status.syncing.text"),tone:void 0}:"changes"===i?{text:a,tone:"caution"}:"saved"===i?{text:d("status-bar.review-changes-button.status.saved.text"),tone:"positive"}:{},[i,a,d]);return i?(0,td.jsx)(tp.u,{placement:"top",portal:!0,disabled:"changes"!==i,content:(0,td.jsxs)(tp.Kq,{padding:3,space:3,children:[(0,td.jsx)(tp.xv,{size:1,weight:"semibold",children:d("status-bar.review-changes-button.tooltip.text")}),(0,td.jsxs)(tp.xv,{size:1,muted:!0,children:[d("status-bar.review-changes-button.tooltip.changes-saved")," ",(0,td.jsx)("abbr",{"aria-label":s,children:o})]})]}),children:(0,td.jsx)(tp.zx,{mode:"bleed",justify:"flex-start",tone:null==c?void 0:c.tone,...l,"data-testid":"review-changes-button",ref:t,"aria-label":d("status-bar.review-changes-button.aria-label"),children:(0,td.jsxs)(tp.kC,{align:"center",children:[(0,td.jsx)(tp.xu,{marginRight:n?0:3,"aria-hidden":"true",children:(0,td.jsx)(tp.xv,{children:(0,td.jsx)(AnimatedStatusIcon,{status:i})})}),!n&&(0,td.jsx)(tp.xv,{size:1,weight:"medium",children:null==c?void 0:c.text})]})})}):null}),ci=ts.memo(cn),cr=(0,ts.memo)(function(){var e;let{changesOpen:t,documentId:n,documentType:i,editState:r,onHistoryClose:l,onHistoryOpen:a,timelineStore:o,value:s}=useDocumentPane(),d=(0,tc.nuD)(n,i),c=null==s?void 0:s._updatedAt,u=null==(e=null==r?void 0:r.published)?void 0:e._updatedAt,p=!!(null==r?void 0:r.liveEdit),h=!!(null==r?void 0:r.published),m=!!(null==r?void 0:r.draft),[f,g]=(0,ts.useState)(null),x=(0,tp.XL)(f),b=!x||(null==x?void 0:x.width)<300,[v,_]=(0,ts.useState)(null),y=(0,tc.P08)(o,e=>e.onOlderRevision);(0,ts.useEffect)(()=>{if("syncing"===v&&!d.isSyncing){let e=setTimeout(()=>_("saved"),1e3);return()=>clearTimeout(e)}if("saved"===v){let e=setTimeout(()=>_(null),3e3);return()=>clearTimeout(e)}},[v,c,d.isSyncing]),(0,ts.useLayoutEffect)(()=>{_(null)},[n]),(0,ts.useLayoutEffect)(()=>{d.isSyncing&&_("syncing")},[d.isSyncing,c]);let j=(0,ts.useMemo)(()=>(0,td.jsx)(ci,{lastUpdated:c,status:v||(m?"changes":void 0),onClick:t?l:a,disabled:y,selected:t,collapsed:b}),[m,t,l,a,c,y,v,b]),w=(0,ts.useMemo)(()=>(p||h)&&(0,td.jsx)(tp.xu,{marginRight:1,children:(0,td.jsx)(PublishStatus,{disabled:y,lastPublished:u,lastUpdated:c,liveEdit:p,collapsed:b})}),[b,u,c,p,h,y]);return(0,td.jsxs)(tp.kC,{align:"center","data-ui":"DocumentSparkline",ref:g,children:[w,(0,td.jsxs)(tp.kC,{align:"center",flex:1,children:[j,!b&&(0,td.jsx)(tp.xu,{marginLeft:3,children:(0,td.jsx)(DocumentBadges,{})})]})]})});var cl=Object.freeze,ca=Object.defineProperty;let co=(0,th.ZP)(tp.xu)(te||(te=cl(ca(M=["\n min-width: 10em;\n max-width: 16em;\n"],"raw",{value:cl(M.slice())}))));function DocumentStatusBar(e){let{actionsBoxRef:t}=e,{badges:n,timelineStore:i}=useDocumentPane(),r=(0,tc.P08)(i,e=>e.onOlderRevision);return(0,ts.useMemo)(()=>(0,td.jsx)(tp.xu,{paddingLeft:2,paddingRight:[2,3],paddingY:2,children:(0,td.jsxs)(tp.kC,{align:"center",children:[(0,td.jsx)(tp.xu,{flex:[1,2],children:n&&(0,td.jsx)(cr,{})}),(0,td.jsx)(co,{flex:1,marginLeft:[1,3],ref:t,children:r?(0,td.jsx)(dX,{}):(0,td.jsx)(dY,{})})]})}),[t,n,r])}function KeyboardShortcutResponder(e){let{actionsBoxElement:t,activeIndex:n,as:i="div",children:r,id:l,onActionStart:a,onKeyDown:o,rootRef:s,states:d,...c}=e,u=d[n],p=(0,ts.useCallback)(e=>{let t=d.filter(t=>t.shortcut&&(0,nA.ZP)(t.shortcut,e)),n=t[0];if(t.length>1&&console.warn('Keyboard shortcut conflict: More than one document action matches the shortcut "'.concat(n.shortcut,'"')),n&&!n.disabled&&n.onHandle){e.preventDefault(),n.onHandle(),a(d.indexOf(n));return}o&&o(e)},[a,o,d]);return(0,ts.createElement)(i,{id:l,onKeyDown:p,tabIndex:-1,...c,ref:s},[r,u&&u.dialog&&(0,td.jsx)(tc.jr5,{zOffset:"paneFooter",children:(0,td.jsx)(ActionStateDialog,{dialog:u.dialog,referenceElement:t})})])}let cs=ts.memo(e=>{let{actionsBoxElement:t,as:n="div",children:i,...r}=e,{actions:l,editState:a}=useDocumentPane(),[o,s]=(0,ts.useState)(-1),d=(0,ts.useCallback)(e=>{s(e)},[]),c=(0,ts.useMemo)(()=>a&&{...a,onComplete:()=>void 0,revision:void 0},[a]);return c&&l?(0,td.jsx)(RenderActionCollectionState,{actionProps:c,actions:l,children:e=>{let{states:l}=e;return(0,td.jsx)(KeyboardShortcutResponder,{...r,activeIndex:o,actionsBoxElement:t,as:n,onActionStart:d,states:l,children:i})}}):null});function DocumentHeaderTabs(){let{activeViewId:e,paneKey:t,views:n}=useDocumentPane(),i="".concat(t,"tabpanel");return(0,td.jsx)(tp.td,{space:1,children:n.map((n,r)=>{var l;return(0,td.jsx)(DocumentHeaderTab,{icon:n.icon,id:"".concat(t,"tab-").concat(n.id),isActive:e===n.id,label:(0,td.jsx)(td.Fragment,{children:n.title}),tabPanelId:i,viewId:0===r?null:null!=(l=n.id)?l:null},n.id)})})}function DocumentHeaderTab(e){let{isActive:t,tabPanelId:n,viewId:i,...r}=e,{ready:l}=useDocumentPane(),{setView:a}=usePaneRouter(),o=(0,ts.useCallback)(()=>a(i),[a,i]);return(0,td.jsx)(tp.OK,{...r,"aria-controls":n,disabled:!l,fontSize:1,selected:t,onClick:o})}function DocumentHeaderTitle(){let{connectionState:e,schemaType:t,title:n,value:i}=useDocumentPane(),{error:r,value:l}=(0,tc._2T)({enabled:!!i&&"connected"===e,schemaType:t,value:i}),{t:a}=(0,tc.$G7)(nV);return"connected"!==e?(0,td.jsx)(td.Fragment,{}):n?(0,td.jsx)(td.Fragment,{children:n}):i?r?(0,td.jsx)(td.Fragment,{children:a("panes.document-header-title.error.text",{error:r.message})}):(0,td.jsx)(td.Fragment,{children:(null==l?void 0:l.title)||(0,td.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:a("panes.document-header-title.untitled.text")})}):(0,td.jsx)(td.Fragment,{children:a("panes.document-header-title.new.text",{schemaType:(null==t?void 0:t.t
1itle)||(null==t?void 0:t.name)})})}cs.displayName="DocumentActionShortcuts";let cd=(0,ts.memo)((0,ts.forwardRef)(function(e,t){let{menuItems:n}=e,{onMenuAction:i,onPaneClose:r,onPaneSplit:l,menuItemGroups:a,schemaType:o,timelineStore:s,ready:d,views:c,unstable_languageFilter:u}=useDocumentPane(),{features:p}=useDeskTool(),{index:h,BackLink:m,hasGroupSiblings:f}=usePaneRouter(),{actions:g}=(0,tc.qGk)(),x=(0,ts.useMemo)(()=>resolveMenuNodes({actionHandler:i,fieldActions:g,menuItems:n,menuItemGroups:a}),[i,g,a,n]),b=(0,ts.useMemo)(()=>x.filter(isMenuNodeButton),[x]),v=(0,ts.useMemo)(()=>x.filter(iL),[x]),_=c.length>1,y=(0,tc.P08)(s,e=>e.revTime),{collapsed:j,isLast:w}=usePane(),k=w&&!j?-1:0,C=p.splitViews&&l&&c.length>1,I=C&&f,S=!I&&!p.backButton,{t:z}=(0,tc.$G7)(nV);return(0,td.jsx)(iT,{ref:t,loading:!d,title:(0,td.jsx)(DocumentHeaderTitle,{}),tabs:_&&(0,td.jsx)(DocumentHeaderTabs,{}),tabIndex:k,backButton:p.backButton&&h>0&&(0,td.jsx)(tp.zx,{as:m,"data-as":"a",icon:to.Y4O,mode:"bleed",padding:2}),subActions:(0,td.jsx)(TimelineMenu,{chunk:y,mode:"rev",placement:"bottom-end"}),actions:(0,td.jsxs)(tp.kC,{align:"center",gap:1,children:[u.length>0&&(0,td.jsx)(td.Fragment,{children:u.map((e,t)=>(0,ts.createElement)(e,{key:"language-filter-".concat(t),schemaType:o}))}),b.map(e=>(0,td.jsx)(PaneHeaderActionButton,{node:e},e.key)),(0,td.jsx)(PaneContextMenuButton,{nodes:v},"context-menu"),C&&(0,td.jsx)(tp.u,{content:(0,td.jsx)(tp.xv,{size:1,style:{whiteSpace:"nowrap"},children:z("buttons.split-pane-button.tooltip")}),padding:2,placement:"bottom",portal:!0,children:(0,td.jsx)(tp.zx,{"aria-label":z("buttons.split-pane-button.aria-label"),icon:to.iro,mode:"bleed",onClick:l},"split-pane-button")}),I&&(0,td.jsx)(tp.zx,{icon:to.Two,mode:"bleed",onClick:r,title:z("buttons.split-pane-close-button.title")},"close-view-button"),S&&(0,td.jsx)(tp.zx,{icon:to.Two,mode:"bleed",title:z("buttons.split-pane-close-group-button.title"),as:m},"close-view-button")]})})})),cc=(0,ts.memo)(function(e){let{documentId:t,documentType:n,index:i,setMenuItem:r,useMenuItem:l}=e,a=(0,tc.BoV)(l({documentId:t,documentType:n}));return(0,ts.useEffect)(()=>{r(i,a)},[i,a,r]),(0,td.jsx)(td.Fragment,{})});function DocumentInspectorMenuItemsResolver(e){let{documentId:t,documentType:n,inspectors:i,onMenuItems:r}=e,l=i.length,a=(0,ts.useRef)(l),[o,s]=(0,ts.useState)(()=>Array.from(Array(l))),d=(0,ts.useRef)(o);(0,ts.useEffect)(()=>{if(a.current!==l){let e=Array.from(Array(l));for(let t=0;t<l;t++)e[t]=d.current[t];a.current=l,s(()=>(d.current=e,e))}},[l]);let c=(0,ts.useCallback)((e,t)=>{s(n=>{let i=[...n];return i[e]=t,d.current=i,i})},[]);return(0,ts.useEffect)(()=>{r(o.filter(Boolean))},[o,r]),(0,td.jsx)(td.Fragment,{children:i.map((e,i)=>e.useMenuItem&&(0,td.jsx)(cc,{documentId:t,documentType:n,index:i,setMenuItem:c,useMenuItem:e.useMenuItem},e.name))})}function DocumentLayoutError(e){let{documentType:t,value:n,currentMinWidth:i,paneKey:r,minWidth:l}=e,{t:a}=(0,tc.$G7)();return(0,td.jsx)(ErrorPane,{currentMinWidth:i,flex:2.5,minWidth:l,paneKey:r,title:(0,td.jsx)(tc.vNl,{t:a,i18nKey:"panes.document-pane.document-unknown-type.title",values:{documentType:t}}),tone:"caution",children:(0,td.jsxs)(tp.Kq,{space:4,children:[t&&(0,td.jsx)(tp.xv,{as:"p",children:(0,td.jsx)(tc.vNl,{t:a,i18nKey:"panes.document-pane.document-unknown-type.text",values:{documentType:t}})}),!t&&(0,td.jsx)(tp.xv,{as:"p",children:a("panes.document-pane.document-unknown-type.without-schema.text")}),tc.r8Q&&n&&(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)(tp.xv,{as:"p",children:"Here is the JSON representation of the document:"}),(0,td.jsx)(tp.Zb,{padding:3,overflow:"auto",radius:2,shadow:1,tone:"inherit",children:(0,td.jsx)(tp.EK,{language:"json",size:[1,1,2],children:JSON.stringify(n,null,2)})})]})]})})}var cu=Object.freeze,cp=Object.defineProperty;let ch=[],cm=["fixed","fixed","absolute"],cf=(0,th.ZP)(tc.jbM)(tt||(tt=cu(cp(R=["\n flex: 1;\n display: flex;\n flex-direction: column;\n min-height: 0;\n min-width: 0;\n"],"raw",{value:cu(R.slice())}))));function DocumentLayout(){let{changesOpen:e,documentId:t,documentType:n,fieldActions:i,inspectOpen:r,inspector:l,inspectors:a,onFocus:o,onHistoryOpen:s,onMenuAction:d,onPathOpen:c,paneKey:u,schemaType:p,value:h}
1=useDocumentPane(),{features:m}=useDeskTool(),{t:f}=(0,nR.$G)(nV),{collapsed:g}=usePaneLayout(),x=(0,tc.Cnp)(),b=usePreviewUrl(h),[v,_]=(0,ts.useState)(null),[y,j]=(0,ts.useState)(null),[w,k]=(0,ts.useState)(null),[C,I]=(0,ts.useState)(null),[S,z]=(0,ts.useState)(null),[P,E]=(0,ts.useState)([]),[D,T]=(0,ts.useState)([]),M=(0,tp.XL)(y),R=(0,tp.XL)(w),A=null==M?void 0:M.height,O=null==R?void 0:R.height,L=600+(l?320:0),B=320+(l?320:0),N=(0,ts.useMemo)(()=>null==a?void 0:a.find(e=>e.name===(null==l?void 0:l.name)),[a,null==l?void 0:l.name]),$=!!h,Z=(0,ts.useMemo)(()=>(function(e){let t=function(e){let{currentInspector:t,hasValue:n,inspectors:i,inspectorMenuItems:r}=e;return i.map((e,i)=>{var l;let a=r[i];return!a||a.hidden?null:{action:"".concat(i3).concat(e.name),group:a.showAsAction?void 0:"inspectors",icon:a.icon,isDisabled:!n,selected:(null==t?void 0:t.name)===e.name,shortcut:null==(l=a.hotkeys)?void 0:l.join("+"),showAsAction:a.showAsAction,title:a.title,tone:a.tone}}).filter(Boolean)}(e),n=[function(e){let{previewUrl:t,t:n}=e;return t?{action:"production-preview",group:"links",title:n("production-preview.menu-item.title"),icon:to.YE8,shortcut:"Ctrl+Alt+O"}:null}(e)].filter(Boolean);return[...t,function(e){let{hasValue:t,t:n}=e;return{action:"inspect",group:"inspectors",title:n("document-inspector.menu-item.title"),icon:to.bg6,isDisabled:!t,shortcut:"Ctrl+Alt+I"}}(e),...n]})({currentInspector:N,features:m,hasValue:$,inspectorMenuItems:P,inspectors:a,previewUrl:b,t:f}),[N,m,$,P,a,b,f]),U=(0,ts.useCallback)(e=>{for(let t of Z)if(t.shortcut&&(0,nA.ZP)(t.shortcut,e)){e.preventDefault(),e.stopPropagation(),d(t);return}},[d,Z]),F=(0,ts.useCallback)(e=>{c(e),o(e)},[c,o]);return p?(0,td.jsxs)(td.Fragment,{children:[a.length>0&&(0,td.jsx)(DocumentInspectorMenuItemsResolver,{documentId:t,documentType:n,inspectors:a,onMenuItems:E}),i.length>0&&p&&(0,td.jsx)(tc.QMc,{actions:i,documentId:t,documentType:n,onActions:T,path:ch,schemaType:p}),(0,td.jsx)(tc.kNp,{actions:D,path:ch,children:(0,td.jsxs)(cs,{actionsBoxElement:C,as:ih,currentMinWidth:L,"data-testid":"document-pane",flex:2.5,id:u,minWidth:B,onKeyUp:U,rootRef:_,children:[(0,td.jsx)(cd,{ref:k,menuItems:Z}),(0,td.jsx)(tp.Tu,{position:cm,zOffset:x.portal,children:(0,td.jsx)(tp.kC,{direction:"column",flex:1,height:g?void 0:"fill",children:(0,td.jsx)(cf,{"data-testid":"change-connector-root",isReviewChangesOpen:e,onOpenReviewChanges:s,onSetFocus:F,children:(0,td.jsx)(DocumentPanel,{footerHeight:A||null,headerHeight:O||null,isInspectOpen:r,rootElement:v,setDocumentPanelPortalElement:z})})})}),(0,td.jsx)(tp.Xp,{__unstable_elements:{[iY]:S},children:(0,td.jsx)(tp.Tu,{position:cm,zOffset:x.portal,children:(0,td.jsx)(iw,{ref:j,children:(0,td.jsx)(DocumentStatusBar,{actionsBoxRef:I})})})}),(0,td.jsx)(dk,{})]})})]}):(0,td.jsx)(DocumentLayoutError,{currentMinWidth:L,documentType:n,minWidth:B,paneKey:u,value:h})}function pick(e){var t,n;return null==(n=null==(t=e.document)?void 0:t.components)?void 0:n.unstable_layout}let cg=(0,ts.memo)(function(e){let{name:t}=(0,tc.Lky)();return(0,td.jsx)(tc.cWh,{name:e.pane.source||t,children:(0,td.jsx)(DocumentPaneInner,{...e})})});function DocumentPaneInner(e){var t;let{pane:n,paneKey:i}=e,{resolveNewDocumentOptions:r}=(0,tc.Lky)().document,l=usePaneRouter(),a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=(0,tc.zEW)();return(0,ts.useMemo)(()=>{if(e.type&&"*"!==e.type)return e;let i=e.template||t.template,r=i?n.find(e=>e.id===i):void 0,l=null==r?void 0:r.schemaType;return l?{...e,type:l}:e},[e,t.template,n])}(n.options,l.params),{documentType:o,isLoaded:s}=(0,tc.Hdz)(a.id,a.type),d=(0,tc.uwK)({pick,defaultComponent:DocumentLayout}),c=(0,ts.useMemo)(()=>r({type:"document",documentId:a.id,schemaType:a.type}),[a.id,a.type,r]),[u,p]=(0,tc.UMU)({templateItems:c}),h=s&&!p,m=(0,ts.useMemo)(()=>h&&o&&a.type!==o?{...e,pane:{...e.pane,options:{...a,type:o}}}:e,[e,o,h,a]),{ReferenceChildLink:f,handleEditReference:g,groupIndex:x,routerPanesState:b}=l,v=(null==(t=b[x+1])?void 0:t[0].params)||{},_=b.length,{parentRefPath:y}=v,j=(0,ts.useMemo)(()=>y?{path:(0,tJ.mL)(y),state:x>=_-1?"none":x>=_-2?"selected":"pressed"}:{path:[],state:"none"},[y,x,_]),{t:w}=(0,tc.$G7)(nV);return"*"!==a.type||h?o?(0,td.jsx)(dj,{...m,children:(0,td.jsx)(tc.euX,{EditReferenceLinkComponent:f,onEditReference:g,initialValueTemplateItems:u,activePath:j,children:(0,td.jsx)(d,{documentId:a.id,documentType:a.type})})},"".concat(o,"-").concat(a.id)):(0,td.jsx)(ErrorPane,{flex:2.5,minWidth:320,paneKey:i,title:w("panes.document-pane.document-not-found.title"),children:(0,td.jsx)(tp.Kq,{space:4,children:(0,td.jsx)(tp.xv,{as:"p",children:(0,td.jsx)(tc.vNl,{t:w,i18nKey:"panes.document-pane.document-not-found.text",values:{id:a.id}})})})}):(0,td.jsx)(dy,{flex:2.5,minWidth:320,paneKey:i,title:w("panes.document-pane.document-not-found.loading")})}let cx={by:[{field:"_updatedAt",direction:"desc"}]},cb={},cv=/\b_type\s*==\s*(['"].*?['"]|\$.*?(?:\s|$))|\B(['"].*?['"]|\$.*?(?:\s|$))\s*==\s*_type\b/;function getTypeNameFromSingleTypeFilter(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.match(cv);if(!n)return null;let i=(n[1]||n[2]).trim().replace(/^["']|["']$/g,"");if("$"===i[0]){let e=i.slice(1),n=t[e];return"string"==typeof n?n:null}return i}var c_=Object.freeze,cy=Object.defineProperty,__template$1=(e,t)=>c_(cy(e,"raw",{value:c_(t||e.slice())}));let cj=(0,th.ZP)(tp.xu)(tn||(tn=__template$1(["\n position: relative;\n"]))),cw=(0,th.ZP)(tp.xu)(ti||(ti=__template$1(["\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n"]))),ck=[...Array(30).keys()];function LoadingView(e){let{layout:t}=e;return(0,td.jsx)(tp.Kq,{padding:2,space:1,children:ck.map(e=>(0,td.jsx)(tp.Zb,{padding:2,children:(0,td.jsx)(tc.ogX,{isPlaceholder:!0,layout:t})},e))})}function DocumentListPaneContent(e){let{childItemId:t,error:n,filterIsSimpleTypeConstraint:i,hasMaxItems:r,hasSearchQuery:l,isActive:a,isLazyLoading:o,isLoading:s,items:d,layout:c,loadingVariant:u,onListChange:p,onRetry:h,paneTitle:m,searchInputElement:f,showIcons:g}=e,x=(0,tc.I_y)(),{collapsed:b}=usePaneLayout(),{collapsed:v,index:_}=usePane(),[y,j]=(0,ts.useState)(!1),{t:w}=(0,tc.$G7)(nV),k=(0,ts.useCallback)(()=>{s||o||!y||p()},[o,s,p,y]);(0,ts.useEffect)(()=>
1{if(v)return;let e=setTimeout(()=>{j(!0)},0);return()=>{clearTimeout(e)}},[v,d]);let C=(0,ts.useCallback)((e,n)=>{let{activeIndex:i}=n,l=(0,tc.vsM)(e._id),s=t===l,u=!a&&s,p=a&&s,h=i===d.length-1,m=h&&o,f=h&&r;return(0,td.jsxs)(td.Fragment,{children:[(0,td.jsx)(PaneItem,{icon:!1!==g&&void 0,id:l,layout:c,marginBottom:1,pressed:u,schemaType:x.get(e._type),selected:p,value:e}),m&&(0,td.jsx)(tp.kC,{align:"center",justify:"center",padding:4,children:(0,td.jsx)(tp.$j,{muted:!0})}),f&&(0,td.jsx)(tp.xu,{marginY:1,paddingX:3,paddingY:4,children:(0,td.jsx)(tp.xv,{align:"center",muted:!0,size:1,children:w("panes.document-list-pane.max-items.text",{limit:2e3})})})]})},[t,a,d.length,c,x,g,r,o,w]),I=(0,ts.useMemo)(()=>l?(0,td.jsx)(tp.kC,{align:"center",direction:"column",height:"fill",justify:"center",children:(0,td.jsx)(tp.W2,{width:1,children:(0,td.jsx)(tp.xu,{paddingX:4,paddingY:5,children:(0,td.jsx)(tp.xv,{align:"center",muted:!0,children:w("panes.document-list-pane.no-documents.text")})})})}):(0,td.jsx)(tp.kC,{align:"center",direction:"column",height:"fill",justify:"center",children:(0,td.jsx)(tp.W2,{width:1,children:(0,td.jsx)(tp.xu,{paddingX:4,paddingY:5,children:(0,td.jsx)(tp.xv,{align:"center",muted:!0,children:i?w("panes.document-list-pane.no-documents-of-type.text"):w("panes.document-list-pane.no-matching-documents.text")})})})}),[i,l,w]),S=(0,ts.useMemo)(()=>{if(!y)return null;if(n)return(0,td.jsx)(tp.kC,{align:"center",direction:"column",height:"fill",justify:"center",children:(0,td.jsx)(tp.W2,{width:1,children:(0,td.jsxs)(tp.Kq,{paddingX:4,paddingY:5,space:4,children:[(0,td.jsx)(tp.X6,{as:"h3",children:w("panes.document-list-pane.error.title")}),(0,td.jsx)(tp.xv,{as:"p",children:(0,td.jsx)(tc.vNl,{t:w,i18nKey:"panes.document-list-pane.error.text",values:{error:n.message}})}),h&&(0,td.jsx)(tp.xu,{children:(0,td.jsx)(tp.zx,{icon:to.bnu,onClick:h,text:w("panes.document-list-pane.error.retry-button.text"),tone:"primary"})})]})})});if(!s&&0===d.length)return I;if("initial"===u&&s)return(0,td.jsx)(Delay,{ms:300,children:(0,td.jsx)(LoadingView,{layout:c})});if("spinner"===u&&s)return null;let e="".concat(_,"-").concat(v);return(0,td.jsx)(cj,{overflow:"hidden",height:"fill",children:(0,td.jsx)(cw,{children:(0,td.jsx)(tc.e8h,{activeItemDataAttr:"data-hovered",ariaLabel:m,canReceiveFocus:!0,focusRingOffset:-3,inputElement:f,itemHeight:51,items:d,onEndReached:k,onlyShowSelectionWhenActive:!0,overscan:10,padding:2,paddingBottom:1,renderItem:C,wrapAround:!1},e)})})},[v,n,k,_,s,d,c,u,h,C,f,y]);return(0,td.jsx)(ib,{overflow:b||"initial"===u?"hidden":"auto",children:S})}let cC=(0,ts.memo)(e=>{let{contentAfter:t,index:n,initialValueTemplates:i=[],menuItemGroups:r=[],menuItems:l=[],setLayout:a,setSortOrder:o,title:s}=e,{features:d}=useDeskTool(),{collapsed:c,isLast:u}=usePane(),p=u&&!c?-1:0,h=(0,ts.useMemo)(()=>({setLayout:e=>{let{layout:t}=e;a(t)},setSortOrder:e=>{o(e)}}),[a,o]);return(0,td.jsx)(iT,{actions:(0,td.jsx)(i$,{initialValueTemplateItems:i,actionHandlers:h,menuItemGroups:r,menuItems:l}),backButton:d.backButton&&n>0&&(0,td.jsx)(tp.zx,{as:nY,"data-as":"a",icon:to.Y4O,mode:"bleed"}),contentAfter:t,tabIndex:p,title:s})});cC.displayName="DocumentListPaneHeader";let cI=[],cS={error:null,onRetry:void 0,result:null},cz={result:null,error:null};var cP=Object.freeze,cE=Object.defineProperty,__template=(e,t)=>
1cP(cE(e,"raw",{value:cP(t||e.slice())}));let cD=[],cT=(0,th.F4)(tr||(tr=__template(["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"]))),cM=(0,th.ZP)(to.L4p)(tl||(tl=__template(["\n animation: "," 500ms linear infinite;\n"])),cT),cR=(0,th.ZP)(tp.Zb)(ta||(ta=__template(["\n [data-ui='TextInput'] {\n border-radius: inherit;\n }\n"]))),addSelectedStateToMenuItems=e=>{let{menuItems:t,sortOrderRaw:n,layout:i}=e;return null==t?void 0:t.map(e=>{var t,r,l,a;return(null==(t=e.params)?void 0:t.layout)?{...e,selected:i===(null==(r=e.params)?void 0:r.layout)}:(null==(l=null==e?void 0:e.params)?void 0:l.by)?{...e,selected:t7()(null==n?void 0:n.by,(null==(a=null==e?void 0:e.params)?void 0:a.by)||cD)}:{...e,selected:!1}})},cA=(0,ts.memo)(function(e){let{childItemId:t,index:n,isActive:i,isSelected:r,pane:l,paneKey:a}=e,o=(0,tc.I_y)(),{name:s}=(0,tc.Lky)(),{defaultLayout:d="default",displayOptions:c,initialValueTemplates:u=cD,menuItemGroups:p,menuItems:h,options:m}=l,{apiVersion:f,defaultOrdering:g=cD,filter:x}=m,b=function(e){let t=(0,ts.useRef)(e);return nZ()(t.current,e)||(t.current=e),t.current}(m.params||cb),v=l.source,_=(0,ts.useMemo)(()=>getTypeNameFromSingleTypeFilter(x,b),[x,b]),y=(null==c?void 0:c.showIcons)!==!1,[j,w]=useDeskToolSetting(_,"layout",d),{t:k}=(0,tc.$G7)(nV),{title:C}=(0,tc.v0Z)(l),[I,S]=(0,ts.useState)(""),[z,P]=(0,ts.useState)(""),[E,D]=(0,ts.useState)(null),T=(0,ts.useRef)(!1),M=(0,ts.useMemo)(()=>(null==g?void 0:g.length)>0?{by:g}:cx,[g]),[R,A]=useDeskToolSetting(_,"sortOrder",M),O=_&&R?function(e,t){let n=e.by.map(e=>{if(e.mapWith)return e;let n=function(e,t){let n=tJ.mL(t),i=e;for(let e of n){if(!i)return;if("string"==typeof e){i=function(e,t){if(!("fields"in e))return;let n=e.fields.find(e=>e.name===t);return n?n.type:void 0}(i,e);continue}let t=(0,tu.Fd)(e)||(0,tu.dw)(e);if(!t||"array"!==i.jsonType)return;let[n,r]=i.of||[];if(r||!n)return;if(!(0,tu.dD)(n)){i=n;continue}let[l,a]=n.to||[];if(a||!l)return;i=l}return i}(t,e.field);return n?!function(e,t){let n=e.type;for(;n;){if(n.name===t||!n.type&&n.jsonType===t)return!0;n=n.type}return!1}(n,"datetime")?"string"===n.jsonType?{...e,mapWith:"lower"}:e:{...e,mapWith:"dateTime"}:e});return n.every((t,n)=>t===e.by[n])?e:{...e,by:n}}(R,o.get(_)):R,L=(0,tc.BoV)(O),B=/^_type\s*==\s*['"$]\w+['"]?\s*$/.test(x.trim()),{error:N,hasMaxItems:$,isLazyLoading:Z,isLoading:U,isSearchReady:F,items:H,onListChange:V,onRetry:q}=function(e){let{filter:t,params:n,sortOrder:i,searchQuery:r,apiVersion:l}=e,a=(0,tc.m85)({...tc.Dr7,apiVersion:l||tc.Dr7.apiVersion}),o=(0,tc.I_y)(),[s,d]=(0,ts.useState)(cS),{onRetry:c,error:u,result:p}=s,h=null==p?void 0:p.documents,m=(0,ts.useMemo)(()=>h?(0,tc.RgL)(h).map(e=>{let t=e.draft||e.published;return{...t,hasPublished:!!e.published,hasDraft:!!e.draft}}):cI,[h]),[f,g]=(0,ts.useState)(!1),[x,b]=(0,ts.useState)(!1),[v,_]=(0,ts.useState)(!1),y=(0,ts.useMemo)(()=>getTypeNameFromSingleTypeFilter(t,n),[t,n]),j=null===p&&!u,w=(null==h?void 0:h.length)===2e3,k=(0,ts.useCallback)(()=>{j||x||v||_(!0)},[j,x,v]),C=(0,ts.useCallback)(e=>{var t,n;if(e.error){d(e);return}let i=(null==(n=null==(t=e.result)?void 0:t.documents)?void 0:n.length)||0,r=!e.error&&(null==e?void 0:e.result)===null&&v;if(r){g(!0);return}if(i<100&&0!==i&&!v&&b(!0),(null==e?void 0:e.result)===null){d(t=>({...t.error?e:t}));return}g(!1),d(e)},[v]),I=(0,ts.useMemo)(()=>{let e=new tM.x,_onRetry=()=>e.next(),l=v?2e3:100,s=i||cx;return(function(e){let{client:t,schema:n,sort:i,limit:r,params:l,filter:a,searchQuery:o,staticTypeNames:s}=e,d=i.by,c=null==i?void 0:i.extendedProjection,u=(0,tI.P)(()=>t.listen("*[".concat(a,"]"),l,{events:["welcome","mutation","reconnect"],includeResult:!1,visibility:"query"})).pipe((0,ty.z)((e,t)=>0===t&&"welcome"!==e.type?(0,tS._)(()=>Error("reconnect"===e.type?"Could not establish EventSource connection":'Received unexpected type of first event "'.concat(e.type,'"'))):(0,tx.of)(e)),(0,tz.B)()),[p,h]=(0,tP.u)(u,e=>"welcome"===e.type);return(0,tk.T)(p.pipe((0,tE.q)(1)),h.pipe((0,tD.p)(1e3,tT.z,{leading:!0,trailing:!0}))).pipe((0,nU.q)(e=>{let i=s?(0,tx.of)(s):t.observable.fetch("array::unique(*[".concat(a,"][]._type)"),l);return i.pipe((0,ty.z)(i=>{let s=i.flatMap(e=>n.get(e)||[]),{query:u,params:p}=(0,tc.kqP)({filter:a,query:o||"",types:s},{__unstable_extendedProjection:c,comments:["findability-source: ".concat(o?"list-query":"list")],limit:r,params:l,sort:d}),doFetch=()=>t.observable.fetch(u,p);return"mutation"===e.type&&"query"!==e.visibility?(0,tf.H)(1200).pipe((0,ty.z)(doFetch)):doFetch()}))}))})({client:a,filter:t,limit:l,params:n,schema:o,searchQuery:r||"",sort:s,staticTypeNames:y?[y]:void 0}).pipe((0,tb.U)(e=>({result:{documents:e},error:null})),(0,tO.O)(cz),(0,tw.K)(e=>e instanceof ProgressEvent?(0,tS._)(()=>Error("Request error")):(0,tS._)(()=>e)),(0,tw.K)((t,n)=>(0,tj.z)((0,tx.of)({result:null,error:t}),(0,tk.T)((0,tm.R)(window,"online"),e).pipe((0,tE.q)(1),(0,ty.z)(()=>n)))),(0,tU.R)((e,t)=>({...e,...t,onRetry:_onRetry})))},[a,t,n,o,r,v,i,y]);(0,ts.useEffect)(()=>{let e=I.subscribe(C);return()=>{e.unsubscribe()}},[C,I]);let S=(0,ts.useCallback)(()=>{b(!1),g(!1),d(cS),_(!1)},[]);return(0,ts.useEffect)(()=>{S()},[S,t,n,i,r]),{error:u,hasMaxItems:w,isLazyLoading:f,isLoading:j,isSearchReady:!u,items:m,onListChange:k,onRetry:c}}({apiVersion:f,filter:x,params:b,searchQuery:null==I?void 0:I.trim(),sortOrder:L}),W=(0,ts.useMemo)(()=>addSelectedStateToMenuItems({menuItems:h,sortOrderRaw:R,layout:j}),[j,h,R]),G=(0,tK.W2)(e=>e.pipe((0,tb.U)(e=>e.target.value),(0,tR.b)(P),(0,tA.D)(e=>""===e?(0,tx.of)(""):(0,tf.H)(300)),(0,tR.b)(S)),[]),K=(0,ts.useCallback)(()=>{S(""),P("")},[]),Y=(0,ts.useCallback)(e=>{"Escape"===e.key&&K()},[K]);(0,ts.useEffect)(()=>(!1!==T.current||U||(T.current=!0),()=>{T.current=!1}),[U]),(0,ts.useEffect)(()=>{K(),T.current=!1},[a,K]);let X=(0,ts.useMemo)(()=>{let e=U&&0===H.length&&T.current;return e?"spinner":"initial"},[U,H.length]),Q=(0,td.jsx)(tp.xu,{paddingX:2,paddingBottom:2,children:(0,td.jsx)(cR,{radius:4,tone:"transparent",children:(0,td.jsx)(tp.oi,{"aria-label":k("panes.document-list-pane.search-input.aria-label"),autoComplete:"off",border:!1,clearButton:!!I,disabled:!F,fontSize:[2,2,1],icon:"spinner"===X?cM:to.W1M,onChange:G,onClear:K,onKeyDown:Y,placeholder:k("panes.document-list-pane.search-input.placeholder"),radius:2,ref:D,spellCheck:!1,value:z})})});return(0,td.jsx)(tc.cWh,{name:v||s,children:(0,td.jsxs)(ih,{currentMaxWidth:350,"data-ui":"DocumentListPane",id:a,maxWidth:640,minWidth:320,selected:r,children:[iW,(0,td.jsx)(cC,{contentAfter:Q,index:n,initialValueTemplates:u,menuItemGroups:p,menuItems:W,setLayout:w,setSortOrder:A,title:C}),(0,td.jsx)(DocumentListPaneContent,{childItemId:t,error:N,filterIsSimpleTypeConstraint:B,hasMaxItems:$,hasSearchQuery:!!I,isActive:i,isLazyLoading:Z,isLoading:U,items:H,layout:j,loadingVariant:X,onListChange:V,onRetry:q,paneTitle:C,searchInputElement:E,showIcons:y},a)]})})})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.