@plank-cms/plank 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ ${n}`}}),s}function SW(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants
|
|
|
197
197
|
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/)?.index;return t===void 0?-1:t},tokenize:(e,t,n)=>{let r=e.split(`
|
|
198
198
|
`),[i,a]=QJ(r);if(i.length===0)return;let o=$J(i,0,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,items:o,raw:r.slice(0,a).join(`
|
|
199
199
|
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(tY,this.editor.getAttributes(nY)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=lW({find:rY,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=lW({find:rY,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(nY)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),aY=/^\s*(\[([( |x])?\])\s$/,oY=CW.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,xH(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>xW(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=SH(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[lW({find:aY,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),sY=CW.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,xH(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
200
|
-
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=bW(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=bW(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});WU.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(FJ.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(IJ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qJ.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(iY.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(oY.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(sY.configure(this.options.taskList)),e}});var cY=` `,lY=`\xA0`,uY=CW.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,xH(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===cY||n[0].text===cY||n[0].raw===lY||n[0].text===lY)&&r.length===1&&r[0].type===`text`&&(r[0].text===cY||r[0].text===lY)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?cY:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),dY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,fY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,pY=FU.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,xH(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[oW({find:dY,type:this.type})]},addPasteRules(){return[wW({find:fY,type:this.type})]}}),mY=CW.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),hY=FU.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,xH(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function gY(e={}){return new mF({view(t){return new _Y(t,e)}})}var _Y=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=TP(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},vY=class e extends KP{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):KP.near(r)}content(){return Z.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new yY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!xY(e)||!SY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!QP.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};vY.prototype.visible=!1,vY.findFrom=vY.findGapCursorFrom,KP.jsonID(`gapcursor`,vY);var yY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return vY.valid(t)?new vY(t):KP.near(t)}};function bY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function xY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||bY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function SY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||bY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function CY(){return new mF({props:{decorations:OY,createSelectionBetween(e,t,n){return t.pos==n.pos&&vY.valid(n)?new vY(n):null},handleClick:EY,handleKeyDown:wY,handleDOMEvents:{beforeinput:DY}}})}var wY=WB({ArrowLeft:TY(`horiz`,-1),ArrowRight:TY(`horiz`,1),ArrowUp:TY(`vert`,-1),ArrowDown:TY(`vert`,1)});function TY(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof XP){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=vY.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new vY(c))),!0):!1}}function EY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!vY.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&QP.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new vY(r))),!0)}function DY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof vY))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=X.empty;for(let e=r.length-1;e>=0;e--)i=X.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Z(i,0,0));return a.setSelection(XP.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function OY(e){if(!(e.selection instanceof vY))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,Uz.create(e.doc,[Bz.widget(e.selection.head,t,{key:`gapcursor`})])}var kY=200,AY=function(){};AY.prototype.append=function(e){return e.length?(e=AY.from(e),!this.length&&e||e.length<kY&&this.leafAppend(e)||this.length<kY&&e.leafPrepend(this)||this.appendInner(e)):this},AY.prototype.prepend=function(e){return e.length?AY.from(e).append(this):this},AY.prototype.appendInner=function(e){return new MY(this,e)},AY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?AY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},AY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},AY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},AY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},AY.from=function(e){return e instanceof AY?e:e&&e.length?new jY(e):AY.empty};var jY=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=kY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=kY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(AY);AY.empty=new jY([]);var MY=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(AY),NY=500,PY=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new IY(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new IY(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new IY(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>RY&&(s=FY(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new UN;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new IY(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new IY(i,o,l))}else r.push(new IY(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new IY(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>NY&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new IY(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(AY.from(i.reverse()),a)}};PY.empty=new PY(AY.empty,0);function FY(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var IY=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},LY=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},RY=20;function zY(e,t,n,r){let i=n.getMeta(qY),a;if(i)return i.historyState;n.getMeta(JY)&&(e=new LY(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(qY))return o.getMeta(qY).redo?new LY(e.done.addTransform(n,void 0,r,KY(t)),e.undone,VY(n.mapping.maps),e.prevTime,e.prevComposition):new LY(e.done,e.undone.addTransform(n,void 0,r,KY(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!BY(n,e.prevRanges)),s=o?HY(e.prevRanges,n.mapping):VY(n.mapping.maps);return new LY(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,KY(t)),PY.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new LY(e.done.rebased(n,a),e.undone.rebased(n,a),HY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new LY(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),HY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function BY(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function VY(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function HY(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function UY(e,t,n){let r=KY(t),i=qY.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new LY(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(qY,{redo:n,historyState:c})}var WY=!1,GY=null;function KY(e){let t=e.plugins;if(GY!=t){WY=!1,GY=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){WY=!0;break}}return WY}var qY=new _F(`history`),JY=new _F(`closeHistory`);function YY(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new mF({key:qY,state:{init(){return new LY(PY.empty,PY.empty,null,0,-1)},apply(t,n,r){return zY(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?ZY:n==`historyRedo`?QY:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function XY(e,t){return(n,r)=>{let i=qY.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=UY(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var ZY=XY(!1,!0),QY=XY(!0,!0);WU.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new mF({key:new _F(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var $Y=WU.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[gY(this.options)]}});WU.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new mF({key:new _F(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return Uz.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(Bz.node(t,t+e.nodeSize,{class:this.options.className}))}),Uz.create(e,a)}}})]}});var eX=WU.create({name:`gapCursor`,addProseMirrorPlugins(){return[CY()]},extendNodeSchema(e){return{allowGapCursor:hH(Q(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),tX=`placeholder`;function nX(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}WU.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:tX,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${nX(this.options.dataAttribute)}`:`data-${tX}`;return[new mF({key:new _F(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&XH(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=Bz.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),Uz.create(t,a)}}})]}}),WU.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new mF({key:new _F(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||ZH(n.selection)||e.view.dragging?null:Uz.create(n.doc,[Bz.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function rX({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var iX=WU.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new _F(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new mF({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!rX({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!rX({node:r,types:n})}}})]}}),aX=WU.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>ZY(e,t),redo:()=>({state:e,dispatch:t})=>QY(e,t)}},addProseMirrorPlugins(){return[YY(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),oX=WU.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(QG.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(qG.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(FJ.configure(this.options.bulletList)),this.options.code!==!1&&e.push(tK.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(aK.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(oK.configure(this.options.document)),this.options.dropcursor!==!1&&e.push($Y.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(eX.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(sK.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(cK.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(aX.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(lK.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(mK.configure(this.options.italic)),this.options.listItem!==!1&&e.push(IJ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qJ.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(kJ.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(iY.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(uY.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(pY.configure(this.options.strike)),this.options.text!==!1&&e.push(mY.configure(this.options.text)),this.options.underline!==!1&&e.push(hY.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(iX.configure(this.options?.trailingNode)),e}}),sX=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cX=CW.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,xH(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new dW({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[sW({find:sX,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function lX({onClick:e,active:t,disabled:n,title:r,children:i}){return(0,H.jsx)(`button`,{type:`button`,title:r,disabled:n,onMouseDown:t=>{t.preventDefault(),e()},className:K(`flex size-7 items-center justify-center rounded transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`,n&&`pointer-events-none opacity-40`),children:i})}function uX(){return(0,H.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`})}function dX({value:e,onChange:t,placeholder:n,onInsertImage:r}){let[i,a]=(0,v.useState)(!e),o=LG({extensions:[oX.configure({link:{openOnClick:!1,HTMLAttributes:{class:`text-primary underline`}}}),cX.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null}}}}).configure({HTMLAttributes:{class:`max-w-full rounded`}})],content:(()=>{if(!e)return``;try{return JSON.parse(e)}catch{return e}})(),editorProps:{attributes:{class:`h-128 px-3 py-2.5 focus:outline-none`}},onUpdate({editor:e}){a(e.isEmpty),t(JSON.stringify(e.getJSON()))}});(0,v.useEffect)(()=>{if(!o)return;let t=e?(()=>{try{return JSON.parse(e)}catch{return e}})():``;JSON.stringify(o.getJSON())!==e&&o.commands.setContent(t,{emitUpdate:!1}),a(o.isEmpty)},[e]);async function s(){if(!o||!r)return;let e=await r();e&&o.chain().focus().setImage({src:e.src,alt:e.alt??void 0,width:e.width??void 0,height:e.height??void 0}).run()}function c(){if(!o)return;let e=o.getAttributes(`link`).href,t=window.prompt(`URL`,e??`https://`);if(t!==null){if(!t){o.chain().focus().unsetLink().run();return}o.chain().focus().setLink({href:t}).run()}}return o?(0,H.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-input bg-background focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50`,children:[(0,H.jsxs)(`div`,{className:`sticky top-0 z-10 flex flex-wrap items-center gap-0.5 border-b border-border bg-background px-2 py-1.5`,children:[(0,H.jsx)(lX,{title:`Bold`,active:o.isActive(`bold`),onClick:()=>o.chain().focus().toggleBold().run(),children:(0,H.jsx)(Ta,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Italic`,active:o.isActive(`italic`),onClick:()=>o.chain().focus().toggleItalic().run(),children:(0,H.jsx)(oo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Underline`,active:o.isActive(`underline`),onClick:()=>o.chain().focus().toggleUnderline().run(),children:(0,H.jsx)(No,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Strikethrough`,active:o.isActive(`strike`),onClick:()=>o.chain().focus().toggleStrike().run(),children:(0,H.jsx)(Do,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Heading 1`,active:o.isActive(`heading`,{level:1}),onClick:()=>o.chain().focus().toggleHeading({level:1}).run(),children:(0,H.jsx)(to,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Heading 2`,active:o.isActive(`heading`,{level:2}),onClick:()=>o.chain().focus().toggleHeading({level:2}).run(),children:(0,H.jsx)(no,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Heading 3`,active:o.isActive(`heading`,{level:3}),onClick:()=>o.chain().focus().toggleHeading({level:3}).run(),children:(0,H.jsx)(ro,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Bullet list`,active:o.isActive(`bulletList`),onClick:()=>o.chain().focus().toggleBulletList().run(),children:(0,H.jsx)(mo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Ordered list`,active:o.isActive(`orderedList`),onClick:()=>o.chain().focus().toggleOrderedList().run(),children:(0,H.jsx)(po,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Blockquote`,active:o.isActive(`blockquote`),onClick:()=>o.chain().focus().toggleBlockquote().run(),children:(0,H.jsx)(yo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Inline code`,active:o.isActive(`code`),onClick:()=>o.chain().focus().toggleCode().run(),children:(0,H.jsx)(Ra,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Code block`,active:o.isActive(`codeBlock`),onClick:()=>o.chain().focus().toggleCodeBlock().run(),children:(0,H.jsx)(To,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Add link`,active:o.isActive(`link`),onClick:c,children:(0,H.jsx)(fo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Remove link`,disabled:!o.isActive(`link`),onClick:()=>o.chain().focus().unsetLink().run(),children:(0,H.jsx)(Po,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),r&&(0,H.jsx)(lX,{title:`Insert image`,onClick:s,children:(0,H.jsx)(ao,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Hard break (Shift + Enter)`,onClick:()=>o.chain().focus().setHardBreak().run(),children:(0,H.jsx)(ko,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`relative overflow-y-auto`,children:[i&&n&&(0,H.jsx)(`p`,{className:`pointer-events-none absolute left-3 top-2.5 text-muted-foreground select-none`,children:n}),(0,H.jsx)(kG,{editor:o})]})]}):null}function fX(e){let t=localStorage.getItem(`plank_token`);return{...t?{Authorization:`Bearer ${t}`}:{},...e}}function pX(e){return e.type.startsWith(`image/`)?new Promise(t=>{let n=new Image,r=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(r),t({width:n.naturalWidth,height:n.naturalHeight})},n.onerror=()=>{URL.revokeObjectURL(r),t(null)},n.src=r}):Promise.resolve(null)}async function mX(e,t){let n=await pX(e),r=await fetch(`/cms/admin/media/presign`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type,folderId:t?.folderId??null})});if(!r.ok)throw Error(`Upload failed.`);let i=await r.json();if(i.mode===`presigned`){if(!(await fetch(i.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let r=await fetch(`/cms/admin/media/confirm`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({key:i.key,filename:e.name,mimeType:e.type,size:e.size,folderId:t?.folderId??null,width:n?.width??null,height:n?.height??null})});if(!r.ok)throw Error(`Upload failed.`);return r.json()}let a=new FormData;a.append(`files`,e,e.name),t?.folderId&&a.append(`folder_id`,t.folderId),n?.width&&a.append(`width`,String(n.width)),n?.height&&a.append(`height`,String(n.height));let o=await fetch(`/cms/admin/media`,{method:`POST`,headers:fX(),body:a});if(!o.ok)throw Error(`Upload failed.`);return o.json()}async function hX(e){let t=await fetch(`/cms/admin/users/me/avatar/presign`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type})});if(!t.ok)throw Error(`Upload failed.`);let n=await t.json();if(n.mode===`presigned`){if(!(await fetch(n.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let t=await fetch(`/cms/admin/users/me/avatar/confirm`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({key:n.key})});if(!t.ok)throw Error(`Upload failed.`);return(await t.json()).avatarUrl}let r=new FormData;r.append(`file`,e);let i=await fetch(`/cms/admin/users/me/avatar`,{method:`POST`,headers:fX(),body:r});if(!i.ok)throw Error(`Upload failed.`);return(await i.json()).avatarUrl}var gX=1,_X=.9,vX=.8,yX=.17,bX=.1,xX=.999,SX=.9999,CX=.99,wX=/[\\\/_+.#"@\[\(\{&]/,TX=/[\\\/_+.#"@\[\(\{&]/g,EX=/[\s-]/,DX=/[\s-]/g;function OX(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?gX:CX;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=OX(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=gX:wX.test(e.charAt(l-1))?(d*=vX,p=e.slice(i,l-1).match(TX),p&&i>0&&(d*=xX**+p.length)):EX.test(e.charAt(l-1))?(d*=_X,m=e.slice(i,l-1).match(DX),m&&i>0&&(d*=xX**+m.length)):(d*=yX,i>0&&(d*=xX**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=SX)),(d<bX&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=OX(e,t,n,r,l+1,a+2,o),f*bX>d&&(d=f*bX)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function kX(e){return e.toLowerCase().replace(DX,` `)}function AX(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,OX(e,t,kX(e),kX(t),0,0,{})}var jX=`[cmdk-group=""]`,MX=`[cmdk-group-items=""]`,NX=`[cmdk-group-heading=""]`,PX=`[cmdk-item=""]`,FX=`${PX}:not([aria-disabled="true"])`,IX=`cmdk-item-select`,LX=`data-value`,RX=(e,t,n)=>AX(e,t,n),zX=v.createContext(void 0),BX=()=>v.useContext(zX),VX=v.createContext(void 0),HX=()=>v.useContext(VX),UX=v.createContext(void 0),WX=v.forwardRef((e,t)=>{let n=iZ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=iZ(()=>new Set),i=iZ(()=>new Map),a=iZ(()=>new Map),o=iZ(()=>new Set),s=nZ(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,y=du(),b=du(),x=du(),S=v.useRef(null),C=sZ();rZ(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),rZ(()=>{C(6,A)},[]);let w=v.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(y))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=v.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:y,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??RX;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(MX);t?t.appendChild(e.parentElement===t?e:e.closest(`${MX} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${MX} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${jX}[${LX}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(LX);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(jX)?.querySelector(NX))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${PX}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(FX)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(LX))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(LX))}function F(e){let t=j()?.closest(jX),n;for(;t&&!n;)t=e>0?eZ(t,jX):tZ(t,jX),n=t?.querySelector(FX);n?w.setState(`value`,n.getAttribute(LX)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return v.createElement(Rc.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(IX);t.dispatchEvent(e)}}}}},v.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:uZ},c),lZ(e,e=>v.createElement(VX.Provider,{value:w},v.createElement(zX.Provider,{value:T},e))))}),GX=v.forwardRef((e,t)=>{let n=du(),r=v.useRef(null),i=v.useContext(UX),a=BX(),o=nZ(e),s=o.current?.forceMount??i?.forceMount;rZ(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=oZ(n,r,[e.value,e.children,r],e.keywords),l=HX(),u=aZ(e=>e.value&&e.value===c.current),d=aZ(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);v.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(IX,f),()=>t.removeEventListener(IX,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:y,...b}=e;return v.createElement(Rc.div,{ref:Wo(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),KX=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=du(),s=v.useRef(null),c=v.useRef(null),l=du(),u=BX(),d=aZ(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);rZ(()=>u.group(o),[]),oZ(o,s,[e.value,e.heading,c]);let f=v.useMemo(()=>({id:o,forceMount:i}),[i]);return v.createElement(Rc.div,{ref:Wo(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&v.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),lZ(e,e=>v.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},v.createElement(UX.Provider,{value:f},e))))}),qX=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=v.useRef(null),a=aZ(e=>!e.search);return!n&&!a?null:v.createElement(Rc.div,{ref:Wo(i,t),...r,"cmdk-separator":``,role:`separator`})}),JX=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=HX(),o=aZ(e=>e.search),s=aZ(e=>e.selectedItemId),c=BX();return v.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),v.createElement(Rc.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),YX=v.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=v.useRef(null),o=v.useRef(null),s=aZ(e=>e.selectedItemId),c=BX();return v.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),v.createElement(Rc.div,{ref:Wo(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},lZ(e,e=>v.createElement(`div`,{ref:Wo(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),XX=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return v.createElement(Py,{open:n,onOpenChange:r},v.createElement(Fy,{container:o},v.createElement(Iy,{"cmdk-overlay":``,className:i}),v.createElement(Ly,{"aria-label":e.label,"cmdk-dialog":``,className:a},v.createElement(WX,{ref:t,...s}))))}),ZX=v.forwardRef((e,t)=>aZ(e=>e.filtered.count===0)?v.createElement(Rc.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),QX=v.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return v.createElement(Rc.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},lZ(e,e=>v.createElement(`div`,{"aria-hidden":!0},e)))}),$X=Object.assign(WX,{List:YX,Item:GX,Input:JX,Group:KX,Separator:qX,Dialog:XX,Empty:ZX,Loading:QX});function eZ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tZ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function nZ(e){let t=v.useRef(e);return rZ(()=>{t.current=e}),t}var rZ=typeof window>`u`?v.useEffect:v.useLayoutEffect;function iZ(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function aZ(e){let t=HX(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function oZ(e,t,n,r=[]){let i=v.useRef(),a=BX();return rZ(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(LX,s),i.current=s}),i}var sZ=()=>{let[e,t]=v.useState(),n=iZ(()=>new Map);return rZ(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function cZ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function lZ({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(cZ(t),{ref:t.ref},n(t.props.children)):n(t)}var uZ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},dZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X,{ref:n,className:K(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t}));dZ.displayName=$X.displayName;var fZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsxs)(`div`,{className:`flex items-center border-b px-3`,"cmdk-input-wrapper":``,children:[(0,H.jsx)(So,{className:`mr-2 h-4 w-4 shrink-0 opacity-50`}),(0,H.jsx)($X.Input,{ref:n,className:K(`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}));fZ.displayName=$X.Input.displayName;var pZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.List,{ref:n,className:K(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));pZ.displayName=$X.List.displayName;var mZ=v.forwardRef((e,t)=>(0,H.jsx)($X.Empty,{ref:t,className:`py-6 text-center text-sm`,...e}));mZ.displayName=$X.Empty.displayName;var hZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.Group,{ref:n,className:K(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t}));hZ.displayName=$X.Group.displayName;var gZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.Separator,{ref:n,className:K(`-mx-1 h-px bg-border`,e),...t}));gZ.displayName=$X.Separator.displayName;var _Z=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.Item,{ref:n,className:K(`relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,e),...t}));_Z.displayName=$X.Item.displayName;var vZ=({className:e,...t})=>(0,H.jsx)(`span`,{className:K(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t});vZ.displayName=`CommandShortcut`;var yZ={image:`image/*`,video:`video/*`,audio:`audio/*`,document:`.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv`};function bZ(e){return!e||e.length===0?`*/*`:e.map(e=>yZ[e]).join(`,`)}function xZ(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function SZ(e){return e?.startsWith(`image/`)??!1}async function CZ(e,t){return mX(e,{folderId:t})}function wZ(e,t){if(!t||t.length===0)return!0;let n=e??``;return t.some(e=>e===`image`?n.startsWith(`image/`):e===`video`?n.startsWith(`video/`):e===`audio`?n.startsWith(`audio/`):e===`document`?n.startsWith(`application/`)||n.startsWith(`text/`):!1)}function TZ({open:e,onOpenChange:t,allowedTypes:n,onSelect:r}){let[i,a]=(0,v.useState)([{id:null,name:`Media`}]),o=i[i.length-1].id,[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;f(!0);let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=o??``;Promise.all([fetch(`/cms/admin/folders?parent_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{folders:[]}).then(e=>e.folders),fetch(`/cms/admin/media?folder_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{items:[]}).then(e=>e.items)]).then(([e,t])=>{c(e),u(t)}).catch(()=>{c([]),u([])}).finally(()=>f(!1))},[e,o]),(0,v.useEffect)(()=>{e||a([{id:null,name:`Media`}])},[e]);function p(e){a(t=>[...t,{id:e.id,name:e.name}])}function m(e){a(t=>t.slice(0,e+1))}let h=l.filter(e=>wZ(e.mime_type,n)),g=s.length===0&&h.length===0;return(0,H.jsx)(US,{open:e,onOpenChange:t,children:(0,H.jsxs)(qS,{className:`max-w-3xl`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Media Library`})}),i.length>1&&(0,H.jsx)(`div`,{className:`flex items-center gap-1 text-sm -mt-1`,children:i.map((e,t)=>(0,H.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[t>0&&(0,H.jsx)(`span`,{children:`/`}),t===i.length-1?(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name}):(0,H.jsx)(`button`,{onClick:()=>m(t),className:`hover:text-foreground transition-colors`,children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name})]},t))}),d?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,H.jsx)(Mv,{className:`size-5`})}):g?(0,H.jsx)(`p`,{className:`py-16 text-center text-sm text-muted-foreground`,children:l.length===0&&s.length===0?`No media found.`:`No matching files in this folder.`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 max-h-[60vh] overflow-y-auto pr-1`,children:[s.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2`,children:s.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`flex items-center gap-2.5 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-muted/50 hover:border-primary`,children:[(0,H.jsx)(Qa,{className:`size-7 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`p`,{className:`truncate text-xs font-bold leading-tight`,title:e.name,children:e.name}),(0,H.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]})]},e.id))}),h.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-5`,children:h.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{r(e),t(!1)},className:`group relative overflow-hidden rounded-md border bg-card text-left transition-colors hover:border-primary`,children:[(0,H.jsx)(`div`,{className:`aspect-square bg-muted`,children:SZ(e.mime_type)?(0,H.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,H.jsx)(Ja,{className:`size-6 text-muted-foreground`})})}),(0,H.jsxs)(`div`,{className:`p-1.5`,children:[(0,H.jsx)(`p`,{className:`truncate text-[11px] font-medium leading-tight`,title:e.filename,children:e.filename}),(0,H.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:xZ(e.size)})]}),(0,H.jsx)(`div`,{className:`absolute inset-0 rounded-md ring-2 ring-primary ring-offset-1 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`})]},e.id))})]})]})})}function EZ({value:e,onChange:t,allowedTypes:n,disabled:r=!1}){let i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(!1),p=typeof e==`string`&&e.startsWith(`http`);(0,v.useEffect)(()=>{if(!e){u(null);return}if(p){u(e);return}let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(e=>u(e?.url??null)).catch(()=>u(null))},[e,p]);async function m(e){o(!0),c(null);try{let n=await CZ(e);u(n.url),t(n.id)}catch(e){c(e instanceof Error?e.message:`Upload failed.`)}finally{o(!1),i.current&&(i.current.value=``)}}let h=l&&/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i.test(l);return e?(0,H.jsxs)(`div`,{className:`relative w-full rounded-md border bg-muted/30 overflow-hidden`,children:[l?h?(0,H.jsx)(`img`,{src:l,alt:`Media`,className:`max-h-72 w-full object-contain`}):(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,H.jsx)(ao,{className:`size-4 text-muted-foreground shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l})]}):(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-muted-foreground`,children:[(0,H.jsx)(ao,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs`,children:`Loading…`})]}),(0,H.jsx)(q,{type:`button`,size:`icon`,variant:`secondary`,className:`absolute top-1.5 right-1.5 size-6`,onClick:()=>{t(null),u(null)},disabled:r,children:(0,H.jsx)(zo,{className:`size-3.5`})})]}):(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`input`,{ref:i,type:`file`,accept:bZ(n),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&m(t)}}),(0,H.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(r)return;e.preventDefault();let t=e.dataTransfer.files[0];t&&m(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>i.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Fo,{className:`size-4`}),a?`Uploading…`:`Upload`]}),(0,H.jsx)(`div`,{className:`w-px bg-border`}),(0,H.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>f(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Xa,{className:`size-4`}),`Library`]})]}),s&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:s}),(0,H.jsx)(TZ,{open:d,onOpenChange:f,allowedTypes:n,onSelect:e=>{u(e.url),t(e.id)}})]})}function DZ({id:e,previewUrl:t,filename:n,onRemove:r,disabled:i=!1}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=BE({id:e});return(0,H.jsxs)(`div`,{ref:s,style:{transform:$C.Transform.toString(c),transition:l,opacity:u?.4:1},className:`relative aspect-square overflow-hidden rounded-md border bg-muted`,children:[t?(0,H.jsx)(`img`,{src:t,alt:n,className:`h-full w-full object-cover`}):(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,H.jsx)(ao,{className:`size-5 text-muted-foreground`})}),n&&(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 bg-background/75 backdrop-blur-sm px-1.5 py-1 pointer-events-none`,children:(0,H.jsx)(`p`,{className:`truncate text-[10px] leading-none text-foreground`,children:n})}),(0,H.jsx)(`button`,{type:`button`,onClick:r,disabled:i,className:`absolute right-1 top-1 flex size-5 items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm hover:bg-background`,children:(0,H.jsx)(zo,{className:`size-3`})}),!i&&(0,H.jsx)(`button`,{type:`button`,className:`absolute bottom-6 left-1 flex size-5 cursor-grab items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm active:cursor-grabbing`,...o,...a,children:(0,H.jsx)($a,{className:`size-3`})})]})}function OZ({value:e,onChange:t,disabled:n=!1}){let r=Array.isArray(e)?e:[],[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),m=(0,v.useRef)(null),h=hw(mw(hT,{activationConstraint:{distance:5}}));(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in i));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);Promise.all(e.map(e=>fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(t=>t?[e,t.url]:null).catch(()=>null))).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);Object.keys(t).length>0&&a(e=>({...e,...t}))})},[r.join(`,`)]),(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in o));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():{items:[]}).then(t=>{let n={};for(let r of t.items)e.includes(r.id)&&(n[r.id]=r.filename);Object.keys(n).length>0&&s(e=>({...e,...n}))}).catch(()=>{})},[r.join(`,`)]);function g(e){return e.startsWith(`http`)?e:i[e]??null}function _(e){return o[e]??``}function y(e){if(n)return;let{active:i,over:a}=e;!a||i.id===a.id||t(xE(r,r.indexOf(i.id),r.indexOf(a.id)))}async function b(e){if(e.length===0)return;l(!0),d(null);let n=r;try{for(let r of e){let e=await CZ(r);a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:r.name})),n=[...n,e.id],t(n)}}catch(e){d(e instanceof Error?e.message:`Upload failed.`)}finally{l(!1),m.current&&(m.current.value=``)}}return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`input`,{ref:m,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:e=>{b(Array.from(e.target.files??[]))}}),r.length>0&&(0,H.jsx)(fE,{sensors:h,collisionDetection:Sw,onDragEnd:y,children:(0,H.jsx)(ME,{items:r,strategy:EE,children:(0,H.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4`,children:r.map(e=>(0,H.jsx)(DZ,{id:e,previewUrl:g(e),filename:_(e),onRemove:()=>t(r.filter(t=>t!==e)),disabled:n},e))})})}),(0,H.jsxs)(`div`,{className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>m.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Fo,{className:`size-4`}),c?`Uploading…`:`Upload`]}),(0,H.jsx)(`div`,{className:`w-px bg-border`}),(0,H.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>p(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Xa,{className:`size-4`}),`Library`]})]}),u&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:u}),(0,H.jsx)(TZ,{open:f,onOpenChange:p,allowedTypes:[`image`],onSelect:e=>{r.includes(e.id)||(a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:e.filename})),t([...r,e.id]))}})]})}function kZ({value:e,onChange:t,disabled:n=!1}){let[r,i]=(0,v.useState)(()=>e!=null&&e!==``?String(e):``);(0,v.useEffect)(()=>{if(e==null||e===``){i(``);return}let t=typeof e==`number`?e:parseFloat(String(e));!isNaN(t)&&t!==parseFloat(r)&&i(String(t))},[e]);function a(e){let n=e.target.value.replace(`,`,`.`);if(i(n),n===``||n===`-`){t(null);return}let r=parseFloat(n);isNaN(r)||t(r)}return(0,H.jsx)(Tv,{type:`text`,inputMode:`decimal`,className:K(`w-full`,`text-base!`),value:r,placeholder:`0.00`,onChange:a,disabled:n})}function AZ({value:e,onChange:t,timezone:n,disabled:r=!1}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(`00:00`);(0,v.useEffect)(()=>{if(!e){s(void 0),l(`00:00`);return}let t=new Date(e);isNaN(t.getTime())||(s(t),l(Lv(e,n)))},[e,n]);function u(e){s(e),a(!1),e&&t(Rv(e,c,n))}function d(e){l(e),o&&t(Rv(o,e,n))}return(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(oM,{open:i&&!r,onOpenChange:a,children:[(0,H.jsx)(sM,{asChild:!0,children:(0,H.jsxs)(q,{variant:`outline`,className:`w-40 justify-between font-normal text-base`,disabled:r,children:[o?uk(o,`MMM d, yyyy`):`Select date`,(0,H.jsx)(Aa,{className:`size-4 opacity-50`})]})}),(0,H.jsx)(cM,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,H.jsx)(iM,{mode:`single`,selected:o,captionLayout:`dropdown`,defaultMonth:o??new Date,onSelect:u})})]}),(0,H.jsx)(Tv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none text-base!`,value:c,onChange:e=>d(e.target.value),disabled:r}),e&&(0,H.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground hover:text-foreground`,onClick:()=>{s(void 0),l(`00:00`),t(null)},disabled:r,children:(0,H.jsx)(zo,{className:`size-3.5`})})]})}function jZ(e){return e.find(e=>e.type===`uid`)?.name??e.find(e=>e.type===`string`)?.name??null}var MZ={data:null,promise:null};function NZ(e){return MZ.data?Promise.resolve(MZ.data):(MZ.promise||=fetch(`/cms/admin/content-types`,{headers:e}).then(e=>e.ok?e.json():[]).then(e=>(MZ.data=e,e)).catch(()=>[]),MZ.promise)}function PZ(e,t){return e.find(e=>e.tableName===t)??null}function FZ(e,t){return fetch(`/cms/admin/content-types/${e}/entries?limit=200`,{headers:t}).then(e=>e.ok?e.json():{data:[]}).catch(()=>({data:[]}))}function IZ(e){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e)return;i(!0);let t=localStorage.getItem(`plank_token`),r=t?{Authorization:`Bearer ${t}`}:{};NZ(r).then(t=>{let n=PZ(t,e);return n?FZ(n.slug,r).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:t})=>{let r=e?jZ(e.fields??[]):null;n(t.data.map(e=>({id:String(e.id),label:String(r?e[r]??e.id:e.id)})))}).catch(()=>n([])).finally(()=>i(!1))},[e]),{entries:t,loading:r}}function LZ(e,t,n){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e||!n){i([]);return}o(!0);let r=localStorage.getItem(`plank_token`),a=r?{Authorization:`Bearer ${r}`}:{};NZ(a).then(t=>{let n=PZ(t,e);return n?FZ(n.slug,a).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:r})=>{let a=e?jZ(e.fields??[]):null;i(r.data.filter(e=>String(e[t]??``)===n).map(e=>({id:String(e.id),label:String(a?e[a]??e.id:e.id)})))}).catch(()=>i([])).finally(()=>o(!1))},[e,t,n]),{entries:r,loading:a}}function RZ({relatedTable:e,relatedField:t,currentId:n}){let{entries:r,loading:i}=LZ(e,t,n);return n?i?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,H.jsx)(Mv,{className:`size-3.5`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading…`})]}):r.length===0?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No linked entries.`}):(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,H.jsx)(`span`,{className:`inline-flex items-center rounded-md border bg-muted px-2 py-0.5 text-xs`,children:e.label},e.id))}):(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save this entry first to see linked items.`})}function zZ({relationType:e,relatedTable:t,relatedField:n,currentEntryId:r,value:i,onChange:a,disabled:o=!1}){let s=e===`many-to-many`,[c,l]=(0,v.useState)(!1),{entries:u,loading:d}=IZ(t);if(e===`one-to-many`)return(0,H.jsx)(RZ,{relatedTable:t,relatedField:n,currentId:r});let f=s?Array.isArray(i)?i:[]:i&&!Array.isArray(i)?[i]:[];function p(e){return u.find(t=>t.id===e)?.label??e}function m(e){if(s){let t=f.includes(e)?f.filter(t=>t!==e):[...f,e];a(t.length>0?t:null)}else a(f[0]===e?null:e),l(!1)}function h(e){if(s){let t=f.filter(t=>t!==e);a(t.length>0?t:null)}else a(null)}let g=s?f.length>0?`${f.length} selected`:`Select entries…`:f.length>0?p(f[0]):`Select entry…`;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(oM,{open:c&&!o,onOpenChange:l,children:[(0,H.jsx)(sM,{asChild:!0,children:(0,H.jsxs)(q,{variant:`outline`,role:`combobox`,"aria-expanded":c,className:`w-full justify-between font-normal text-base`,disabled:o,children:[(0,H.jsx)(`span`,{className:`truncate text-left`,children:g}),(0,H.jsx)(Pa,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,H.jsx)(cM,{className:`w-(--radix-popover-trigger-width) p-0`,align:`start`,children:(0,H.jsxs)(dZ,{children:[(0,H.jsx)(fZ,{placeholder:`Search…`}),(0,H.jsx)(pZ,{children:d?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,H.jsx)(Mv,{className:`size-4`})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(mZ,{children:`No entries found.`}),(0,H.jsx)(hZ,{children:u.map(e=>{let t=f.includes(e.id);return(0,H.jsxs)(_Z,{value:e.label,onSelect:()=>{o||m(e.id)},children:[(0,H.jsx)(ka,{className:`mr-2 size-4 ${t?`opacity-100`:`opacity-0`}`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.label}),(0,H.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground opacity-60 shrink-0`,children:e.id.slice(0,8)})]},e.id)})})]})})]})})]}),f.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border bg-muted px-2 py-0.5 text-xs`,children:[p(e),(0,H.jsx)(`button`,{type:`button`,onClick:()=>h(e),disabled:o,className:`text-muted-foreground hover:text-foreground`,children:(0,H.jsx)(zo,{className:`size-3`})})]},e))})]})}var BZ={full:`col-span-6`,"two-thirds":`col-span-4`,half:`col-span-3`,third:`col-span-2`};function VZ({field:e,value:t,onChange:n,disabled:r=!1}){let i=Array.isArray(t)?t:[],a=e.arrayFields??[];function o(){return Object.fromEntries(a.map(e=>[e.name,e.type===`boolean`?!1:null]))}function s(){n([...i,o()])}function c(e){n(i.filter((t,n)=>n!==e))}function l(e,t,r){n(i.map((n,i)=>i===e?{...n,[t]:r}:n))}return a.length===0?(0,H.jsx)(`div`,{className:`flex w-full items-center justify-center rounded-md border border-dashed p-4 text-xs text-muted-foreground`,children:`No sub-fields defined for this array.`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[`Item `,t+1]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>c(t),disabled:r,className:`flex size-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,H.jsx)(jo,{className:`size-3.5`})})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:a.map(n=>(0,H.jsxs)(`div`,{className:BZ[n.width??`full`]??`col-span-6`,children:[(0,H.jsx)(`div`,{className:`mb-1 flex items-center gap-1`,children:(0,H.jsxs)(Y,{className:`text-xs font-medium`,children:[n.name,n.required&&(0,H.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]})}),(0,H.jsx)(WZ,{field:{...n,type:n.type},value:e[n.name]??null,onChange:e=>l(t,n.name,e),allValues:e,disabled:r})]},n.name))})]},t)),(0,H.jsxs)(`button`,{type:`button`,onClick:s,disabled:r,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:border-primary hover:text-primary`,children:[(0,H.jsx)(vo,{className:`size-3.5`}),`Add item`]})]})}function HZ(e){return e.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/^-+|-+$/g,``)}function UZ({value:e,onChange:t,disabled:n=!1}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null);function p(){return o(!0),new Promise(e=>{i.current=e})}function m(e){i.current?.(e),i.current=null}function h(e){e||m(null),o(e)}async function g(e){u(!0),f(null);try{let t=await mX(e);m({src:t.url,alt:t.alt,width:t.width,height:t.height}),o(!1)}catch(e){f(e instanceof Error?e.message:`Upload failed.`)}finally{u(!1),r.current&&(r.current.value=``)}}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:n?`pointer-events-none opacity-70`:``,children:(0,H.jsx)(dX,{value:String(e??``),onChange:t,placeholder:`Type or add your content here...`,onInsertImage:p})}),(0,H.jsx)(US,{open:a,onOpenChange:h,children:(0,H.jsxs)(qS,{className:`max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Insert Image`})}),(0,H.jsx)(`input`,{ref:r,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&g(t)}}),(0,H.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault();let t=e.dataTransfer.files[0];t&&g(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>r.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Fo,{className:`size-4`}),l?`Uploading…`:`Upload`]}),(0,H.jsx)(`div`,{className:`w-px bg-border`}),(0,H.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>c(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Xa,{className:`size-4`}),`Library`]})]}),d&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:d})]})}),(0,H.jsx)(TZ,{open:s,onOpenChange:e=>{!e&&!a&&m(null),c(e)},allowedTypes:[`image`],onSelect:e=>{m({src:e.url,alt:e.alt,width:e.width,height:e.height}),c(!1),o(!1)}})]})}function WZ({field:e,value:t,onChange:n,allValues:r,disabled:i}){let a=(0,v.useRef)(!1),{timezone:o}=la();(0,v.useEffect)(()=>{if(e.type!==`uid`||!e.targetField||a.current)return;let t=r,i=e.targetField,o=!!t.__localizationEnabled,s=r[i];if(s!=null&&String(s).trim()!==``){n(HZ(String(s)));return}let c=r.localized&&typeof r.localized==`object`?r.localized:{};if(o){let e=r.__defaultLocale;e&&c[e]&&c[e][i]!==void 0&&String(c[e][i]).trim()!==``&&n(HZ(String(c[e][i])));return}let l=Object.keys(c).filter(e=>!e.startsWith(`_`));for(let e of l)if(c[e]&&c[e][i]!==void 0&&String(c[e][i]).trim()!==``){n(HZ(String(c[e][i])));return}},[e.type,e.targetField,r[e.targetField??``],JSON.stringify(r.localized??{}),r.__localizationEnabled]);let s=`w-full`;return e.type===`boolean`?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,H.jsx)(XE,{id:`field-${e.name}`,checked:!!t,onCheckedChange:e=>n(!!e),disabled:!!i}),(0,H.jsx)(Y,{htmlFor:`field-${e.name}`,className:`cursor-pointer font-normal text-base`,children:t?`Yes`:`No`})]}):e.type===`richtext`?(0,H.jsx)(UZ,{value:t,onChange:n,disabled:!!i}):e.type===`text`?(0,H.jsx)(lM,{className:K(s,`text-base`),value:String(t??``),placeholder:e.name,onChange:e=>n(e.target.value),disabled:!!i}):e.type===`number`?e.subtype===`float`?(0,H.jsx)(kZ,{value:t,onChange:n,disabled:!!i}):(0,H.jsx)(Tv,{type:`number`,className:K(s,`text-base!`),value:t==null?``:String(t),step:`1`,placeholder:`0`,onChange:e=>{let t=e.target.value;if(t===``){n(null);return}n(parseInt(t,10))},disabled:!!i}):e.type===`datetime`?(0,H.jsx)(AZ,{value:t,onChange:n,timezone:o,disabled:!!i}):e.type===`uid`?(0,H.jsx)(Tv,{className:K(s,`text-base md:text-base`),value:String(t??``),placeholder:`auto-generated`,onChange:e=>{let t=e.target.value;a.current=!!(t&&t!==``),n(e.target.value)},disabled:!!i}):e.type===`media`?(0,H.jsx)(EZ,{value:t,onChange:n,allowedTypes:e.allowedTypes,disabled:!!i}):e.type===`media-gallery`?(0,H.jsx)(OZ,{value:t,onChange:n,disabled:!!i}):e.type===`relation`?(0,H.jsx)(zZ,{relationType:e.relationType??`many-to-one`,relatedTable:e.relatedTable??``,relatedField:e.relatedField??``,currentEntryId:String(r.id??``),value:t,onChange:n,disabled:!!i}):e.type===`array`?(0,H.jsx)(VZ,{field:e,value:t,onChange:n,disabled:!!i}):(0,H.jsx)(Tv,{className:K(s,`text-base md:text-base`),value:String(t??``),placeholder:e.name,onChange:e=>n(e.target.value),disabled:!!i})}function GZ(){let{slug:e,id:t}=rr(),n=$n(),r=!t,{timezone:i,locales:a,defaultLocale:o}=la(),{user:s}=oa(),{data:c,loading:l}=ma(e?`/cms/admin/content-types/${e}`:null),{data:u,loading:d}=ma(e&&t?`/cms/admin/entries/${e}/${t}`:null),{loading:f,request:p}=wv(),{loading:m,request:h}=wv(),{loading:g,request:_}=wv(),[y,b]=(0,v.useState)({}),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(`draft`),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(),[ne,z]=(0,v.useState)(`09:00`),B=(0,v.useRef)(`{}`),re=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(r){let e={};c?.fields.forEach(t=>{e[t.name]=t.type===`boolean`?!1:``}),e.localized={};let t=a&&a.length>0?a:[`en`];S(t),w(o??t[0]),E(!1),b(e),O(`draft`),A(``),M(!1),B.current=JSON.stringify(e);return}if(!u||!c)return;let e={};c.fields.forEach(t=>{e[t.name]=u[t.name]??(t.type===`boolean`?!1:``)});let t=u.localized,n=t&&typeof t==`object`?t:{};e.localized=n;let s=Object.keys(n).filter(e=>!e.startsWith(`_`)),l=n._meta||{},d=l.enabled??s.length>0;if(l.primary??s[0],s.length>0)S(s),w(s[0]);else{let e=a&&a.length>0?a:[`en`];S(e),w(o??e[0])}if(E(!!d),b(e),O(u.status??`draft`),B.current=JSON.stringify(e),u.scheduled_for?(A(u.scheduled_for),te(new Date(u.scheduled_for)),z(Lv(u.scheduled_for,i))):A(``),u.status===`published`&&u.published_data){let t=(e,t)=>{if(t===`datetime`&&e&&typeof e==`string`){let t=/Z|[+-]\d{2}:\d{2}$/.test(e)?e:e+`Z`,n=new Date(t);return isNaN(n.getTime())?e:n.toISOString()}return e},n={},r={};c.fields.forEach(i=>{i.name in u.published_data&&(n[i.name]=t(u.published_data[i.name]??(i.type===`boolean`?!1:``),i.type),r[i.name]=t(e[i.name],i.type))}),M(JSON.stringify(r)!==JSON.stringify(n))}else M(!1)},[u,c,r]);let V=JSON.stringify(y)!==B.current,ie=Cr((0,v.useCallback)(()=>re.current?!1:V,[V]));function ae(e,t){b(n=>({...n,[e]:t}))}function oe(e,t,n){b(r=>{let i={...r||{}};return(!i.localized||typeof i.localized!=`object`)&&(i.localized={}),i.localized[e]={...i.localized[e]||{}},i.localized[e][t]=n,i})}function se(e){E(e),b(t=>{let n={...t||{}};if((!n.localized||typeof n.localized!=`object`)&&(n.localized={}),n.localized._meta||(n.localized._meta={}),e&&o)n.localized[o]||(n.localized[o]={},c&&c.fields&&c.fields.forEach(e=>{if([`string`,`text`,`richtext`].includes(e.type)){let t=n[e.name];t!=null&&t!==``&&(n.localized[o][e.name]=t)}})),n.localized._meta.primary=o;else if(!e&&o){let e=n.localized&&n.localized[o]?n.localized[o]:null;e&&c&&c.fields&&c.fields.forEach(t=>{if([`string`,`text`,`richtext`,`uid`].includes(t.type)){let r=e[t.name];r!==void 0&&(n[t.name]=r)}})}return n.localized._meta.enabled=e,n})}function ce(){if(k)te(new Date(k)),z(Lv(k,i));else{let e=new Date;e.setDate(e.getDate()+1),te(e),z(`09:00`)}I(!0)}async function le(){if(!e||!c)return null;let n={},i=T&&y.localized&&typeof y.localized==`object`&&y.localized[o]?y.localized[o]:null;c.fields.forEach(e=>{let t=y[e.name];(t==null||t===``)&&i&&i[e.name]!==void 0&&(t=i[e.name]),e.type===`media`&&t===null?n[e.name]=null:t!==``&&t!=null&&(n[e.name]=t)}),y.localized&&Object.keys(y.localized).length>0&&(y.localized._meta||(y.localized._meta={}),y.localized._meta.enabled=T,y.localized._meta.primary=o,n.localized=y.localized);try{let i=await p(r?`/cms/admin/content-types/${e}/entries`:`/cms/admin/entries/${e}/${t}`,r?`POST`:`PUT`,n);return B.current=JSON.stringify(y),i}catch{return null}}async function ue(){let i=await le();if(i){if(D===`scheduled`){let n=r?i.id:t;try{await h(`/cms/admin/entries/${e}/${n}/status`,`PATCH`,{status:`draft`}),O(`draft`),A(``),I(!1)}catch{}}else D===`published`&&M(!0);r&&(re.current=!0,n(`/content/${e}/${i.id}`,{replace:!0}))}}async function de(){if(!e)return;let i=t;if(V||r){let e=await le();if(!e)return;i=r?e.id:t,r&&(re.current=!0)}try{await h(`/cms/admin/entries/${e}/${i}/status`,`PATCH`,{status:`published`}),O(`published`),A(``),M(!1),I(!1),r&&n(`/content/${e}/${i}`,{replace:!0})}catch{r&&i&&n(`/content/${e}/${i}`,{replace:!0})}}async function fe(){if(!e||!ee||!ne)return;let a=Rv(ee,ne,i);if(new Date(a)<=new Date)return;let o=t;if(V||r){let e=await le();if(!e)return;o=r?e.id:t,r&&(re.current=!0)}try{await h(`/cms/admin/entries/${e}/${o}/status`,`PATCH`,{status:`scheduled`,scheduled_for:a}),O(`scheduled`),A(a),I(!1),r&&n(`/content/${e}/${o}`,{replace:!0})}catch{r&&o&&n(`/content/${e}/${o}`,{replace:!0})}}async function pe(){if(!(!e||!t))try{await h(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`draft`}),O(`draft`),A(``),M(!1)}catch{}}async function me(){if(!(!e||!t))try{await _(`/cms/admin/entries/${e}/${t}`,`DELETE`),re.current=!0,n(`/content/${e}`,{replace:!0})}catch{}}let he=l||!r&&d,ge=f||m,_e=s?.permissions??[],ve=_e.includes(`*`)||_e.includes(`entries:write`),ye=_e.includes(`*`)||_e.includes(`entries:delete`),be=s?.role?.toLowerCase()===`user`&&c?.kind===`single`,xe=!ve||be,Se=V||D===`draft`||D===`scheduled`||j,Ce=!!(ee&&ne);if(UE(`mod+s`,ue,{enabled:!xe&&!ge&&(D===`scheduled`?!0:V),label:`Save draft`}),UE(`mod+shift+p`,de,{enabled:Se&&!ge&&!xe,label:`Publish`}),he)return(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,H.jsx)(Mv,{className:`size-4`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]});if(!c)return null;let we;return we=D===`scheduled`?(0,H.jsxs)(HS,{variant:`outline`,className:`border-blue-500 text-blue-600`,children:[(0,H.jsx)(Ea,{className:`size-3 mr-1`}),k?`Scheduled · ${Iv(k,i)}`:`Scheduled`]}):D===`published`?(0,H.jsx)(HS,{variant:j?`secondary`:`default`,children:j?`Published (pending changes)`:`Published`}):(0,H.jsx)(HS,{variant:`secondary`,children:`Draft`}),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:r?`New entry`:`Edit entry`}),we]}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs mt-1`,children:c.name})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!r&&ye&&!be&&(0,H.jsx)(q,{variant:`ghost`,size:`icon`,className:`text-muted-foreground hover:text-destructive`,onClick:()=>P(!0),disabled:g,children:(0,H.jsx)(jo,{className:`size-4`})}),!r&&D===`published`&&!xe&&(0,H.jsxs)(q,{variant:`outline`,onClick:pe,disabled:ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,`Revert to draft`]}),!r&&D===`scheduled`&&!xe&&(0,H.jsxs)(q,{variant:`outline`,onClick:pe,disabled:ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,`Cancel schedule`]}),(0,H.jsxs)(q,{variant:`outline`,onClick:ue,disabled:xe||(D===`scheduled`?ge:!V||ge),children:[f?(0,H.jsx)(Mv,{className:`size-4`}):null,D===`scheduled`?`Save draft (cancel schedule)`:`Save draft`]}),D!==`scheduled`&&(0,H.jsxs)(q,{variant:`outline`,onClick:ce,disabled:xe||ge,children:[(0,H.jsx)(Ea,{className:`size-4`}),`Schedule`]}),(0,H.jsxs)(q,{onClick:de,disabled:xe||!Se||ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,D===`scheduled`?`Publish now`:D===`published`&&!j?`Republish`:`Publish`]})]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[F&&!xe&&(0,H.jsxs)(`div`,{className:`mb-6 flex items-end gap-2 rounded-lg border p-4 bg-muted/30`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{children:`Date`}),(0,H.jsxs)(oM,{open:L,onOpenChange:R,children:[(0,H.jsx)(sM,{asChild:!0,children:(0,H.jsxs)(q,{variant:`outline`,className:`w-40 justify-between font-normal`,children:[ee?uk(ee,`MMM d, yyyy`):`Select date`,(0,H.jsx)(Aa,{className:`size-4 opacity-50`})]})}),(0,H.jsx)(cM,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,H.jsx)(iM,{mode:`single`,selected:ee,captionLayout:`dropdown`,defaultMonth:ee??new Date,disabled:{before:new Date},onSelect:e=>{te(e),R(!1)}})})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(Y,{children:[`Time `,(0,H.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(24h)`})]}),(0,H.jsx)(Tv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none`,value:ne,onChange:e=>z(e.target.value)})]}),(0,H.jsxs)(q,{onClick:fe,disabled:!Ce||ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,`Confirm`]}),(0,H.jsx)(q,{variant:`ghost`,onClick:()=>I(!1),children:`Cancel`})]}),(0,H.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Tk,{checked:T,onCheckedChange:se,disabled:xe}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Localization`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable per-entry localization`})]})]}),(0,H.jsx)(`div`,{})]}),(0,H.jsx)(`div`,{children:T&&(0,H.jsx)(xk,{value:C,onValueChange:e=>w(e),children:(0,H.jsx)(Sk,{children:x.map(e=>(0,H.jsx)(Ck,{value:e,disabled:xe,children:e.toUpperCase()},e))})})})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-6 gap-4`,children:c.fields.map(e=>{let n=[`string`,`text`,`richtext`].includes(e.type),r=y.localized&&y.localized[C]?y.localized[C][e.name]:void 0,i=n&&T?r:y[e.name],a=e.type===`uid`&&e.targetField&&T&&[`string`,`text`,`richtext`].includes(c.fields.find(t=>t.name===e.targetField)?.type??``);return(0,H.jsx)(`div`,{className:GE[e.width??`full`],children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(Y,{htmlFor:`entry-${e.name}`,className:`capitalize`,children:[e.name.replace(/_/g,` `),e.required&&(0,H.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,H.jsx)(WZ,{field:e,value:i,onChange:t=>{n&&T?oe(C,e.name,t):ae(e.name,t)},allValues:{...y,id:t,__activeLocale:C,__localizationEnabled:T,__defaultLocale:o},disabled:!!a||xe})]})},e.name)})}),(0,H.jsx)(US,{open:N,onOpenChange:P,children:(0,H.jsxs)(qS,{className:`max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete this entry?`})}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>P(!1),children:`Cancel`}),(0,H.jsxs)(q,{variant:`destructive`,onClick:me,disabled:g,children:[g?(0,H.jsx)(Mv,{className:`size-4`}):null,`Delete`]})]})]})}),(0,H.jsx)(US,{open:ie.state===`blocked`,onOpenChange:()=>ie.reset?.(),children:(0,H.jsxs)(qS,{className:`max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Unsaved changes`})}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Leave without saving?`}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>ie.reset?.(),children:`Stay`}),(0,H.jsx)(q,{variant:`destructive`,onClick:()=>ie.proceed?.(),children:`Leave`})]})]})})]})]})}function KZ({...e}){return(0,H.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,...e})}function qZ({className:e,...t}){return(0,H.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:K(`flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5`,e),...t})}function JZ({className:e,...t}){return(0,H.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:K(`inline-flex items-center gap-1.5`,e),...t})}function YZ({asChild:e,className:t,...n}){return(0,H.jsx)(e?vl:`a`,{"data-slot":`breadcrumb-link`,className:K(`transition-colors hover:text-foreground`,t),...n})}function XZ({className:e,...t}){return(0,H.jsx)(`span`,{"data-slot":`breadcrumb-page`,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:K(`font-normal text-foreground`,e),...t})}function ZZ({children:e,className:t,...n}){return(0,H.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:K(`[&>svg]:size-3.5`,t),...n,children:e??(0,H.jsx)(Ma,{})})}function QZ(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function $Z(e){return!!e?.startsWith(`image/`)}function eQ(e){return!!e?.startsWith(`video/`)}function tQ(e){return!!e?.startsWith(`audio/`)}function nQ(e){return e===`application/pdf`}function rQ(e,t){return e.split(`?`)[0].endsWith(`.m3u8`)||t===`application/x-mpegurl`||t===`application/vnd.apple.mpegurl`}async function iQ(e){if(e.isFile)return new Promise(t=>{e.file(n=>t([{file:n,relativePath:e.fullPath.replace(/^\//,``)}]))});if(e.isDirectory){let t=e.createReader(),n=[];return await new Promise(e=>{let r=()=>{t.readEntries(async t=>{if(t.length===0){e();return}let i=await Promise.all(t.map(iQ));n.push(...i.flat()),r()})};r()}),n}return[]}function aQ({url:e}){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let n=t.current;if(!n)return;if(n.canPlayType(`application/vnd.apple.mpegurl`)){n.src=e;return}let r=null;return w(async()=>{let{default:e}=await import(`./hls-0EiSYoTw.js`);return{default:e}},[]).then(({default:t})=>{if(!t.isSupported())return;let i=new t;r=i,i.loadSource(e),i.attachMedia(n)}),()=>{r?.destroy()}},[e]),(0,H.jsx)(`video`,{ref:t,controls:!0,className:`max-h-[70vh] w-full rounded-md bg-black`})}function oQ({item:e}){let t=e.mime_type?.toLowerCase()??null;return $Z(t)?(0,H.jsx)(`img`,{src:e.url,alt:e.filename,className:`max-h-full max-w-full rounded-md object-contain`}):rQ(e.url,t)?(0,H.jsx)(aQ,{url:e.url}):eQ(t)?(0,H.jsx)(`video`,{src:e.url,controls:!0,preload:`none`,className:`max-h-[70vh] w-full rounded-md bg-black`}):tQ(t)?(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6`,children:[(0,H.jsx)(Ga,{className:`size-14 text-muted-foreground`}),(0,H.jsx)(`audio`,{src:e.url,controls:!0,className:`w-full`})]}):nQ(t)?(0,H.jsx)(`iframe`,{src:e.url,title:e.filename,className:`h-[70vh] w-full rounded-md border`}):(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8 text-center`,children:[(0,H.jsx)(qa,{className:`size-14 text-muted-foreground`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.mime_type??`Unknown type`}),(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,download:e.filename,children:(0,H.jsxs)(q,{variant:`outline`,size:`sm`,children:[(0,H.jsx)(Va,{className:`size-4`}),`Download`]})})]})}function sQ({folder:e,onOpen:t,onDelete:n,onRename:r,canDelete:i,canRename:a,selected:o,onToggle:s}){return(0,H.jsxs)(`div`,{className:`group relative flex items-center gap-3 rounded-lg border bg-card px-3 py-2.5 transition-colors cursor-pointer hover:bg-muted/50 ${o?`ring-2 ring-primary`:``}`,onClick:()=>{o||t(e)},children:[(0,H.jsxs)(`div`,{className:`relative shrink-0 size-7 flex items-center justify-center`,children:[(0,H.jsx)(Qa,{className:`size-7 text-muted-foreground transition-opacity ${o?`opacity-0`:`group-hover:opacity-0`}`}),(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center transition-opacity ${o?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(XE,{checked:o,onCheckedChange:()=>s(`folder:${e.id}`),"aria-label":`Select folder`})})]}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-bold truncate`,title:e.name,children:e.name}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]}),!o&&(a||i)&&(0,H.jsxs)(__,{children:[(0,H.jsx)(v_,{asChild:!0,children:(0,H.jsx)(`button`,{className:`shrink-0 opacity-0 group-hover:opacity-100 transition-opacity flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(Ha,{className:`size-4`})})}),(0,H.jsxs)(x_,{align:`end`,onClick:e=>e.stopPropagation(),children:[a&&(0,H.jsxs)(S_,{onSelect:()=>r(e),children:[(0,H.jsx)(_o,{className:`size-4`}),`Rename`]}),i&&(0,H.jsxs)(S_,{onSelect:()=>n(e),className:`text-destructive focus:text-destructive`,children:[(0,H.jsx)(jo,{className:`size-4`}),`Delete`]})]})]})]})}function cQ({item:e,onDelete:t,onPreview:n,canDelete:r,selected:i,onToggle:a}){let o=e.mime_type?.toLowerCase()??null;return(0,H.jsxs)(`div`,{className:`group relative rounded-lg border bg-card overflow-hidden transition-colors ${i?`ring-2 ring-primary`:``}`,children:[(0,H.jsx)(`div`,{className:`aspect-square bg-muted flex items-center justify-center cursor-pointer`,onClick:()=>{i||n(e)},children:$Z(o)?(0,H.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):eQ(o)||rQ(e.url,o)?(0,H.jsx)(Ka,{className:`size-10 text-muted-foreground`}):tQ(o)?(0,H.jsx)(Ga,{className:`size-10 text-muted-foreground`}):nQ(o)?(0,H.jsx)(qa,{className:`size-10 text-muted-foreground`}):(0,H.jsx)(Ja,{className:`size-10 text-muted-foreground`})}),(0,H.jsx)(`div`,{className:`absolute top-1.5 left-1.5 transition-opacity ${i?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,children:(0,H.jsx)(XE,{checked:i,onCheckedChange:()=>a(e.id),"aria-label":`Select file`,className:`bg-background/80 backdrop-blur-sm`})}),!i&&r&&(0,H.jsx)(`button`,{onClick:()=>t(e),className:`absolute top-1.5 right-1.5 flex size-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground opacity-0 backdrop-blur-sm transition-opacity hover:text-destructive group-hover:opacity-100`,children:(0,H.jsx)(jo,{className:`size-3.5`})}),(0,H.jsxs)(`div`,{className:`p-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium truncate`,title:e.filename,children:e.filename}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:QZ(e.size)})]})]})}function lQ(){let e=(0,v.useRef)(null),{user:t}=oa(),n=t?.permissions??[],r=n.includes(`*`)||n.includes(`media:write`),i=n.includes(`*`)||n.includes(`media:delete`),[a,o]=(0,v.useState)([{id:null,name:`Media`}]),s=a[a.length-1].id,{data:c,loading:l,refetch:u}=ma(`/cms/admin/folders?parent_id=${s??``}`),{data:d,loading:f,refetch:p}=ma(`/cms/admin/media?folder_id=${s??``}`),m=(0,v.useCallback)(()=>{u(),p()},[u,p]),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(new Set),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(null),[I,L]=(0,v.useState)(null),[R,ee]=(0,v.useState)(``),[te,ne]=(0,v.useState)(!1),[z,B]=(0,v.useState)(``),[re,V]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(!1),{loading:oe,error:se,request:ce}=wv(),{loading:le,error:ue,request:de}=wv();async function fe(e){if(e.some(({relativePath:e})=>e.endsWith(`.m3u8`))){let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=new FormData;for(let{file:t,relativePath:n}of e)r.append(`files`,t,n);s&&r.append(`folder_id`,s),r.append(`bundle`,`true`);let i=await fetch(`/cms/admin/media`,{method:`POST`,headers:n,body:r});if(!i.ok){let e=await i.text(),t=`Upload failed.`;try{t=JSON.parse(e).error??t}catch{}throw Error(t)}}else await Promise.all(e.map(({file:e})=>mX(e,{folderId:s})))}async function pe(t){if(r&&!(!t||t.length===0)){g(!0),y(null);try{await fe(Array.from(t).map(e=>({file:e,relativePath:e.webkitRelativePath||e.name}))),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1),e.current&&(e.current.value=``)}}}async function me(e){if(!r)return;e.preventDefault();let t=Array.from(e.dataTransfer.items);if(!t.some(e=>typeof e.webkitGetAsEntry==`function`)){pe(e.dataTransfer.files);return}g(!0),y(null);try{let e=t.map(e=>e.webkitGetAsEntry()).filter(e=>e!==null);await fe((await Promise.all(e.map(iQ))).flat()),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1)}}function he(e){o(t=>[...t,{id:e.id,name:e.name}]),x(new Set)}function ge(e){o(t=>t.slice(0,e+1)),x(new Set)}async function _e(){if(r&&z.trim())try{await de(`/cms/admin/folders`,`POST`,{name:z.trim(),parent_id:s}),ne(!1),B(``),u()}catch{}}async function ve(){if(r&&!(!I||!R.trim()))try{await de(`/cms/admin/folders/${I.id}`,`PATCH`,{name:R.trim()}),L(null),u()}catch{}}async function ye(){if(i&&P)try{await ce(`/cms/admin/folders/${P.id}`,`DELETE`),F(null),u()}catch{}}async function be(){if(i&&M)try{await ce(`/cms/admin/media/${M.id}`,`DELETE`),N(null),p()}catch{}}function xe(e){x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let Se=c?.folders??[],Ce=d?.items??[],we=[...Se.map(e=>`folder:${e.id}`),...Ce.map(e=>e.id)],Te=we.length>0&&we.every(e=>b.has(e)),Ee=!Te&&we.some(e=>b.has(e));async function De(){if(!i||ie)return;ae(!0);let e=localStorage.getItem(`plank_token`),t=e?{Authorization:`Bearer ${e}`}:{};try{await Promise.all([...[...b].filter(e=>e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/folders/${e.slice(7)}`,{method:`DELETE`,headers:t})),...[...b].filter(e=>!e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/media/${e}`,{method:`DELETE`,headers:t}))]),V(!1),x(new Set),m()}finally{ae(!1)}}let Oe=l||f,ke=Se.length===0&&Ce.length===0;return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Media Library`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:d?`${d.total} file${d.total===1?``:`s`}`:``})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(q,{variant:`outline`,onClick:()=>{B(``),ne(!0)},disabled:!r,children:[(0,H.jsx)(Za,{className:`size-4`}),`New folder`]}),(0,H.jsxs)(q,{onClick:()=>e.current?.click(),disabled:h||!r,children:[h?(0,H.jsx)(Mv,{className:`size-4`}):(0,H.jsx)(Fo,{className:`size-4`}),h?`Uploading…`:`Upload`]})]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[a.length>1&&(0,H.jsx)(KZ,{className:`mb-4`,children:(0,H.jsx)(qZ,{children:a.map((e,t)=>(0,H.jsxs)(v.Fragment,{children:[t>0&&(0,H.jsx)(ZZ,{}),(0,H.jsx)(JZ,{children:t===a.length-1?(0,H.jsx)(XZ,{children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name}):(0,H.jsx)(YZ,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:()=>ge(t),children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name})})})]},t))})}),!ke&&!Oe&&(0,H.jsxs)(`div`,{className:`mb-4 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-4 py-2.5`,children:[(0,H.jsx)(XE,{checked:Te?!0:Ee?`indeterminate`:!1,onCheckedChange:()=>{x(Te?new Set:new Set(we))},"aria-label":`Select all`}),b.size>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`text-sm font-medium`,children:[b.size,` selected`]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>x(new Set),children:`Clear`}),i&&(0,H.jsxs)(q,{variant:`destructive`,size:`sm`,disabled:ie,onClick:()=>V(!0),children:[(0,H.jsx)(jo,{className:`size-3.5`}),`Delete`]})]})]}):(0,H.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Select all`})]}),(0,H.jsx)(`input`,{ref:e,type:`file`,multiple:!0,className:`hidden`,onChange:e=>pe(e.target.files)}),_&&(0,H.jsx)(`p`,{className:`mb-4 text-sm text-destructive`,children:_}),Oe?(0,H.jsx)(`div`,{className:`flex items-center gap-2 py-16 justify-center text-muted-foreground`,children:(0,H.jsx)(Mv,{className:`size-5`})}):ke?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-lg border border-dashed py-20 text-center cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>r&&e.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:me,children:[(0,H.jsx)(Fo,{className:`size-8 text-muted-foreground mb-3`}),(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop files or folders here, or click to upload`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Images, videos, audio, documents and more`})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,onDragOver:e=>e.preventDefault(),onDrop:me,children:[Se.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,children:Se.map(e=>(0,H.jsx)(sQ,{folder:e,onOpen:he,onDelete:F,onRename:e=>{L(e),ee(e.name)},canDelete:i,canRename:r,selected:b.has(`folder:${e.id}`),onToggle:xe},e.id))}),Ce.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6`,children:Ce.map(e=>(0,H.jsx)(cQ,{item:e,onDelete:N,onPreview:e=>{C(e),T(e.filename),D(e.alt??``),j(null)},canDelete:i,selected:b.has(e.id),onToggle:xe},e.id))})]}),(0,H.jsx)(US,{open:!!S,onOpenChange:e=>{e||(C(null),j(null))},children:(0,H.jsxs)(qS,{className:`sm:max-w-4xl h-[80vh] flex flex-col`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{className:`truncate pr-6`,title:S?.filename,children:S?.filename})}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center overflow-hidden`,children:S&&(0,H.jsx)(oQ,{item:S})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:S?.mime_type??`—`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[S?.width&&S?.height&&(0,H.jsxs)(`span`,{children:[S.width,` × `,S.height]}),(0,H.jsx)(`span`,{children:QZ(S?.size??null)}),(0,H.jsx)(`a`,{href:S?.url,target:`_blank`,rel:`noreferrer`,download:S?.filename,children:(0,H.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,children:(0,H.jsx)(Va,{className:`size-3.5`})})})]})]}),S&&$Z(S.mime_type)&&(0,H.jsxs)(`form`,{className:`flex flex-col gap-3 border-t pt-3`,onSubmit:async e=>{e.preventDefault(),k(!0),j(null);let t=localStorage.getItem(`plank_token`);try{let e=await fetch(`/cms/admin/media/${S.id}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({filename:w||S.filename,alt:E||null})});if(!e.ok)throw Error(`Save failed.`);C(await e.json()),p()}catch(e){j(e instanceof Error?e.message:`Save failed.`)}finally{k(!1)}},children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{className:`text-xs`,children:`Filename`}),(0,H.jsx)(Tv,{value:w,onChange:e=>T(e.target.value),placeholder:S.filename,className:`h-8 text-sm`,disabled:!r})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{className:`text-xs`,children:`Alt text`}),(0,H.jsx)(Tv,{value:E,onChange:e=>D(e.target.value),placeholder:`Describe the image…`,className:`h-8 text-sm`,disabled:!r})]})]}),A&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:A}),(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(q,{type:`submit`,size:`sm`,disabled:O||!r,children:O?`Saving…`:`Save`})})]})]})}),(0,H.jsx)(US,{open:te,onOpenChange:e=>{e||ne(!1)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`New folder`})}),(0,H.jsx)(Tv,{placeholder:`Folder name`,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_e()},autoFocus:!0}),ue&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:ue}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>ne(!1),children:`Cancel`}),(0,H.jsx)(q,{onClick:_e,disabled:le||!z.trim()||!r,children:le?`Creating…`:`Create`})]})]})}),(0,H.jsx)(US,{open:!!I,onOpenChange:e=>{e||L(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Rename folder`})}),(0,H.jsx)(Tv,{value:R,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ve()},autoFocus:!0}),ue&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:ue}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>L(null),children:`Cancel`}),(0,H.jsx)(q,{onClick:ve,disabled:le||!R.trim()||!r,children:le?`Saving…`:`Save`})]})]})}),(0,H.jsx)(US,{open:!!M,onOpenChange:e=>{e||N(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete file`})}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:M?.filename}),`? This action cannot be undone.`]}),se&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:se}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>N(null),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:be,disabled:oe||!i,children:oe?`Deleting…`:`Delete`})]})]})}),(0,H.jsx)(US,{open:!!P,onOpenChange:e=>{e||F(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete folder`})}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:P?.name}),`? The folder must be empty.`]}),se&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:se}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>F(null),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:ye,disabled:oe||!i,children:oe?`Deleting…`:`Delete`})]})]})}),(0,H.jsx)(US,{open:re,onOpenChange:e=>{e||V(!1)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsxs)(XS,{children:[`Delete `,b.size,` `,b.size===1?`item`:`items`,`?`]})}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone. Non-empty folders will be skipped.`}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>V(!1),children:`Cancel`}),(0,H.jsxs)(q,{variant:`destructive`,onClick:De,disabled:ie,children:[ie?(0,H.jsx)(Mv,{className:`size-4`}):null,`Delete`]})]})]})})]})]})}function uQ({items:e}){let{pathname:t}=Xn();function n(e){return t===e||t.startsWith(e+`/`)}return(0,H.jsx)(`nav`,{className:`flex flex-col gap-0.5 p-2`,children:e.map(({label:e,to:t,icon:r})=>(0,H.jsxs)(Fi,{to:t,className:[`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,n(t)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:[r&&(0,H.jsx)(r,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e})]},t))})}function dQ(e,t){return e?.permissions.includes(`*`)||e?.permissions.includes(t)||!1}function fQ(){let{user:e}=oa(),t=[{label:`Overview`,to:`/settings/overview`,icon:Co,permission:`settings:overview:read`},{label:`Users`,to:`/settings/users`,icon:Lo,permission:`settings:users:read`},{label:`Roles`,to:`/settings/roles`,icon:wo,permission:`settings:roles:read`},{label:`API Tokens`,to:`/settings/api-tokens`,icon:so,permission:`settings:api-tokens:read`},{label:`Webhooks`,to:`/settings/webhooks`,icon:Ro,permission:`settings:webhooks:read`}].filter(({permission:t})=>dQ(e,t));return(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`div`,{className:`border-b border-sidebar-border px-4 py-3`,children:(0,H.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Settings`})}),(0,H.jsx)(uQ,{items:t})]})}function pQ(){return _C((0,H.jsx)(fQ,{})),(0,H.jsx)(Br,{})}var mQ=`••••••••`;function hQ({values:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`local-uploads-dir`,children:`Upload directory`}),(0,H.jsx)(Tv,{id:`local-uploads-dir`,placeholder:`public/uploads`,value:e[`local.uploads_dir`]??``,onChange:e=>t(`local.uploads_dir`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Path on disk where files are stored. Relative to the server working directory.`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`local-public-url`,children:`Public URL`}),(0,H.jsx)(Tv,{id:`local-public-url`,placeholder:`http://localhost:1337`,value:e[`local.public_url`]??``,onChange:e=>t(`local.public_url`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Base URL used to build file URLs. Should match the server's public address.`})]})]})}function gQ({id:e,label:t,fieldKey:n,values:r,onChange:i,placeholder:a,disabled:o=!1}){let[s,c]=(0,v.useState)(!1),l=r[n]===mQ,u=r[n]??``;return(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:e,children:t}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(Tv,{id:e,type:s?`text`:`password`,placeholder:l?`Leave blank to keep current value`:a,value:l?``:u,onChange:e=>i(n,e.target.value),className:`pr-9`,disabled:o}),(0,H.jsx)(`button`,{type:`button`,className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>c(e=>!e),tabIndex:-1,disabled:o,children:s?(0,H.jsx)(Ua,{className:`size-4`}):(0,H.jsx)(Wa,{className:`size-4`})})]}),l&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A value is already saved. Enter a new one to replace it.`})]})}function _Q({values:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-access-key`,children:`Access key ID`}),(0,H.jsx)(Tv,{id:`s3-access-key`,placeholder:`AKIAIOSFODNN7EXAMPLE`,value:e[`s3.access_key_id`]??``,onChange:e=>t(`s3.access_key_id`,e.target.value),disabled:n})]}),(0,H.jsx)(gQ,{id:`s3-secret-key`,label:`Secret access key`,fieldKey:`s3.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-region`,children:`Region`}),(0,H.jsx)(Tv,{id:`s3-region`,placeholder:`us-east-1`,value:e[`s3.region`]??``,onChange:e=>t(`s3.region`,e.target.value),disabled:n})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-bucket`,children:`Bucket`}),(0,H.jsx)(Tv,{id:`s3-bucket`,placeholder:`my-bucket`,value:e[`s3.bucket`]??``,onChange:e=>t(`s3.bucket`,e.target.value),disabled:n})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-path-prefix`,children:`Path prefix`}),(0,H.jsx)(Tv,{id:`s3-path-prefix`,placeholder:`cms/media`,value:e[`s3.path_prefix`]??``,onChange:e=>t(`s3.path_prefix`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-public-url`,children:`Public URL`}),(0,H.jsx)(Tv,{id:`s3-public-url`,placeholder:`https://cdn.example.com`,value:e[`s3.public_url`]??``,onChange:e=>t(`s3.public_url`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Leave blank to use the default S3 URL.`})]})]})}function vQ({values:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-access-key`,children:`Access key ID`}),(0,H.jsx)(Tv,{id:`r2-access-key`,placeholder:`R2 access key ID`,value:e[`r2.access_key_id`]??``,onChange:e=>t(`r2.access_key_id`,e.target.value),disabled:n})]}),(0,H.jsx)(gQ,{id:`r2-secret-key`,label:`Secret access key`,fieldKey:`r2.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-bucket`,children:`Bucket`}),(0,H.jsx)(Tv,{id:`r2-bucket`,placeholder:`my-bucket`,value:e[`r2.bucket`]??``,onChange:e=>t(`r2.bucket`,e.target.value),disabled:n})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-path-prefix`,children:`Path prefix`}),(0,H.jsx)(Tv,{id:`r2-path-prefix`,placeholder:`cms/media`,value:e[`r2.path_prefix`]??``,onChange:e=>t(`r2.path_prefix`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(Y,{htmlFor:`r2-public-url`,children:[`Public URL `,(0,H.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,H.jsx)(Tv,{id:`r2-public-url`,placeholder:`https://assets.example.com`,value:e[`r2.public_url`]??``,onChange:e=>t(`r2.public_url`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Required. R2 does not generate public URLs automatically.`})]})]})}function yQ(){let{user:e}=oa(),{data:t,loading:n}=ma(`/cms/admin/settings/media`),{loading:r,error:i,request:a}=wv(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),u=o??t??{provider:`local`},d=u.provider||`local`,f=e?.permissions??[],p=f.includes(`*`)||f.includes(`settings:overview:write`);function m(e,t){s({...u,[e]:t})}function h(e){s({...u,provider:e})}async function g(e){e.preventDefault();try{await a(`/cms/admin/settings/media`,`PUT`,u),l(!0),setTimeout(()=>l(!1),2500)}catch{}}return n?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-8 text-muted-foreground`,children:[(0,H.jsx)(Mv,{className:`size-4`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Loading settings…`})]}):(0,H.jsxs)(`form`,{onSubmit:g,className:`space-y-8`,children:[(0,H.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Storage`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure where uploaded files are stored.`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`provider`,children:`Storage provider`}),(0,H.jsxs)(QS,{value:d,onValueChange:e=>h(e),children:[(0,H.jsx)(tC,{id:`provider`,disabled:!p,children:(0,H.jsx)(eC,{})}),(0,H.jsxs)(iC,{children:[(0,H.jsx)(oC,{value:`local`,children:`Local`}),(0,H.jsx)(oC,{value:`s3`,children:`Amazon S3`}),(0,H.jsx)(oC,{value:`r2`,children:`Cloudflare R2`})]})]})]}),d===`r2`&&(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-account-id`,children:`Account ID`}),(0,H.jsx)(Tv,{id:`r2-account-id`,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:u[`r2.account_id`]??``,onChange:e=>m(`r2.account_id`,e.target.value),disabled:!p}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Found in the Cloudflare dashboard under R2 > Overview.`})]})]}),(0,H.jsxs)(`div`,{className:`border-t pt-6`,children:[d===`local`&&(0,H.jsx)(hQ,{values:u,onChange:m,disabled:!p}),d===`s3`&&(0,H.jsx)(_Q,{values:u,onChange:m,disabled:!p}),d===`r2`&&(0,H.jsx)(vQ,{values:u,onChange:m,disabled:!p})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(q,{type:`submit`,disabled:r||!p,children:r?`Saving…`:`Save`}),c&&(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Changes saved.`}),i&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:i})]})]})}function bQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card`,className:K(`flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm`,e),...t})}function xQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-header`,className:K(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function SQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-title`,className:K(`leading-none font-semibold`,e),...t})}function CQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-action`,className:K(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function wQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-content`,className:K(`px-6`,e),...t})}var TQ={name:`@plank-cms/admin`,version:`0.12.0`,type:`module`,scripts:{build:`vite build`,dev:`vite`,lint:`eslint src/`},dependencies:{"@dnd-kit/core":`6.3.1`,"@dnd-kit/sortable":`10.0.0`,"@dnd-kit/utilities":`3.2.2`,"@radix-ui/react-avatar":`1.1.11`,"@radix-ui/react-checkbox":`1.3.3`,"@radix-ui/react-dialog":`1.1.15`,"@radix-ui/react-dropdown-menu":`2.1.16`,"@radix-ui/react-label":`2.1.8`,"@radix-ui/react-popover":`1.1.15`,"@radix-ui/react-select":`2.2.6`,"@radix-ui/react-separator":`1.1.8`,"@radix-ui/react-slot":`1.2.4`,"@radix-ui/react-switch":`1.2.6`,"@radix-ui/react-tabs":`1.1.13`,"@radix-ui/react-tooltip":`1.2.8`,"@tanstack/react-table":`8.21.3`,"@tiptap/extension-image":`3.22.4`,"@tiptap/pm":`3.22.4`,"@tiptap/react":`3.22.4`,"@tiptap/starter-kit":`3.22.4`,"class-variance-authority":`0.7.1`,clsx:`2.1.1`,cmdk:`1.1.1`,"date-fns":`4.1.0`,"hls.js":`1.6.16`,"lucide-react":`1.8.0`,"radix-ui":`1.4.3`,react:`19.2.5`,"react-day-picker":`9.14.0`,"react-dom":`19.2.5`,"react-router-dom":`7.14.1`,"tailwind-merge":`3.5.0`},devDependencies:{"@tailwindcss/vite":`4.2.3`,"@types/react":`19.2.14`,"@types/react-dom":`19.2.3`,"@types/react-router-dom":`5.3.3`,"@vitejs/plugin-react":`6.0.1`,tailwindcss:`4.2.3`,vite:`8.0.9`}},EQ=[{value:`UTC`,label:`UTC — Coordinated Universal Time`},{value:`America/New_York`,label:`America/New_York — Eastern Time (UTC-5/4)`},{value:`America/Chicago`,label:`America/Chicago — Central Time (UTC-6/5)`},{value:`America/Denver`,label:`America/Denver — Mountain Time (UTC-7/6)`},{value:`America/Los_Angeles`,label:`America/Los_Angeles — Pacific Time (UTC-8/7)`},{value:`America/Anchorage`,label:`America/Anchorage — Alaska Time (UTC-9/8)`},{value:`America/Honolulu`,label:`America/Honolulu — Hawaii Time (UTC-10)`},{value:`America/Mexico_City`,label:`America/Mexico_City — Mexico City (UTC-6/5)`},{value:`America/El_Salvador`,label:`America/El_Salvador — El Salvador (UTC-6)`},{value:`America/Bogota`,label:`America/Bogota — Colombia Time (UTC-5)`},{value:`America/Lima`,label:`America/Lima — Peru Time (UTC-5)`},{value:`America/Santiago`,label:`America/Santiago — Chile Time (UTC-4/3)`},{value:`America/Argentina/Buenos_Aires`,label:`America/Buenos_Aires — Argentina (UTC-3)`},{value:`America/Sao_Paulo`,label:`America/Sao_Paulo — Brasília Time (UTC-3/2)`},{value:`Atlantic/Reykjavik`,label:`Atlantic/Reykjavik — Iceland (UTC+0)`},{value:`Europe/London`,label:`Europe/London — GMT/BST (UTC+0/1)`},{value:`Europe/Paris`,label:`Europe/Paris — Central European Time (UTC+1/2)`},{value:`Europe/Berlin`,label:`Europe/Berlin — Central European Time (UTC+1/2)`},{value:`Europe/Madrid`,label:`Europe/Madrid — Central European Time (UTC+1/2)`},{value:`Europe/Rome`,label:`Europe/Rome — Central European Time (UTC+1/2)`},{value:`Europe/Helsinki`,label:`Europe/Helsinki — Eastern European Time (UTC+2/3)`},{value:`Europe/Istanbul`,label:`Europe/Istanbul — Turkey Time (UTC+3)`},{value:`Europe/Moscow`,label:`Europe/Moscow — Moscow Standard Time (UTC+3)`},{value:`Asia/Dubai`,label:`Asia/Dubai — Gulf Standard Time (UTC+4)`},{value:`Asia/Karachi`,label:`Asia/Karachi — Pakistan Standard Time (UTC+5)`},{value:`Asia/Kolkata`,label:`Asia/Kolkata — India Standard Time (UTC+5:30)`},{value:`Asia/Dhaka`,label:`Asia/Dhaka — Bangladesh Standard Time (UTC+6)`},{value:`Asia/Bangkok`,label:`Asia/Bangkok — Indochina Time (UTC+7)`},{value:`Asia/Singapore`,label:`Asia/Singapore — Singapore Time (UTC+8)`},{value:`Asia/Shanghai`,label:`Asia/Shanghai — China Standard Time (UTC+8)`},{value:`Asia/Tokyo`,label:`Asia/Tokyo — Japan Standard Time (UTC+9)`},{value:`Asia/Seoul`,label:`Asia/Seoul — Korea Standard Time (UTC+9)`},{value:`Australia/Sydney`,label:`Australia/Sydney — AEST/AEDT (UTC+10/11)`},{value:`Australia/Melbourne`,label:`Australia/Melbourne — AEST/AEDT (UTC+10/11)`},{value:`Pacific/Auckland`,label:`Pacific/Auckland — New Zealand (UTC+12/13)`}];function DQ(){let{user:e}=oa(),{data:t,loading:n}=ma(`/cms/admin/settings/general`),{request:r,loading:i}=wv(),{refreshSettings:a}=la(),[o,s]=(0,v.useState)(`UTC`),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(`en`),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),g=e?.permissions??[],_=g.includes(`*`)||g.includes(`settings:overview:write`);(0,v.useEffect)(()=>{if(t?.timezone&&s(t.timezone),t?.locales)try{let e=JSON.parse(t.locales);Array.isArray(e)&&l(e)}catch{l((t.locales||``).split(`,`).map(e=>e.trim()).filter(Boolean))}t?.default_locale&&d(t.default_locale)},[t]);async function y(){let e={timezone:o};c.length&&(e.locales=JSON.stringify(c)),u&&(e.default_locale=u),await r(`/cms/admin/settings/general`,`PUT`,e),a(),h(!0),setTimeout(()=>h(!1),2e3)}return n?(0,H.jsx)(Mv,{}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(bQ,{children:(0,H.jsxs)(wQ,{className:`flex items-center gap-4 py-2`,children:[(0,H.jsx)(`img`,{src:`/admin/plank-logo-w.svg`,alt:`Plank CMS`,className:`h-10 w-auto`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-bold`,children:`Plank CMS by AM25`}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,TQ.version]})]})]})}),(0,H.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Commons`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`General settings that apply across the CMS.`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`timezone`,children:`Timezone`}),(0,H.jsxs)(QS,{value:o,onValueChange:s,children:[(0,H.jsx)(tC,{id:`timezone`,className:`w-1/2`,disabled:!_,children:(0,H.jsx)(eC,{})}),(0,H.jsx)(iC,{className:`max-h-72`,children:EQ.map(e=>(0,H.jsx)(oC,{value:e.value,children:e.label},e.value))})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Used to display dates and times across the admin panel.`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{children:`Locales`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Tv,{placeholder:`E.g. "en"`,value:f,onChange:e=>p(e.target.value),className:`w-1/4`,disabled:!_}),(0,H.jsx)(q,{variant:`outline`,disabled:!_,onClick:()=>{let e=f.trim().toLowerCase();e&&(c.includes(e)||l(t=>[...t,e]),p(``))},children:`Add`})]}),(0,H.jsx)(`div`,{className:`flex gap-2 mt-2`,children:c.map(e=>(0,H.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>l(t=>t.filter(t=>t!==e)),disabled:!_,children:e.toUpperCase()},e))}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(Y,{htmlFor:`default-locale`,children:`Default locale`}),(0,H.jsxs)(QS,{value:u,onValueChange:d,children:[(0,H.jsx)(tC,{id:`default-locale`,className:`w-1/2`,disabled:!_,children:(0,H.jsx)(eC,{})}),(0,H.jsx)(iC,{className:`max-h-72`,children:c.length===0?(0,H.jsx)(oC,{value:u,children:u}):c.map(e=>(0,H.jsx)(oC,{value:e,children:e.toUpperCase()},e))})]})]})]}),(0,H.jsx)(q,{onClick:y,disabled:i||!_,children:m?`Saved`:i?`Saving…`:`Save`})]})}function OQ(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(jv,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Overview`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`General configuration for your CMS instance.`})]}),(0,H.jsxs)(xk,{defaultValue:`general`,className:`mt-24`,children:[(0,H.jsxs)(Sk,{className:`mb-6`,children:[(0,H.jsx)(Ck,{value:`general`,children:`General`}),(0,H.jsx)(Ck,{value:`media`,children:`Media Library`})]}),(0,H.jsx)(wk,{value:`general`,children:(0,H.jsx)(DQ,{})}),(0,H.jsx)(wk,{value:`media`,children:(0,H.jsx)(yQ,{})})]})]})}function kQ(e,t){return typeof e==`function`?e(t):e}function AQ(e,t){return n=>{t.setState(t=>({...t,[e]:kQ(n,t[e])}))}}function jQ(e){return e instanceof Function}function MQ(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function NQ(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function PQ(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
200
|
+
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=bW(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=bW(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});WU.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(FJ.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(IJ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qJ.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(iY.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(oY.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(sY.configure(this.options.taskList)),e}});var cY=` `,lY=`\xA0`,uY=CW.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,xH(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===cY||n[0].text===cY||n[0].raw===lY||n[0].text===lY)&&r.length===1&&r[0].type===`text`&&(r[0].text===cY||r[0].text===lY)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?cY:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),dY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,fY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,pY=FU.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,xH(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[oW({find:dY,type:this.type})]},addPasteRules(){return[wW({find:fY,type:this.type})]}}),mY=CW.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),hY=FU.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,xH(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function gY(e={}){return new mF({view(t){return new _Y(t,e)}})}var _Y=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=TP(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},vY=class e extends KP{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):KP.near(r)}content(){return Z.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new yY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!xY(e)||!SY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!QP.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};vY.prototype.visible=!1,vY.findFrom=vY.findGapCursorFrom,KP.jsonID(`gapcursor`,vY);var yY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return vY.valid(t)?new vY(t):KP.near(t)}};function bY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function xY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||bY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function SY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||bY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function CY(){return new mF({props:{decorations:OY,createSelectionBetween(e,t,n){return t.pos==n.pos&&vY.valid(n)?new vY(n):null},handleClick:EY,handleKeyDown:wY,handleDOMEvents:{beforeinput:DY}}})}var wY=WB({ArrowLeft:TY(`horiz`,-1),ArrowRight:TY(`horiz`,1),ArrowUp:TY(`vert`,-1),ArrowDown:TY(`vert`,1)});function TY(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof XP){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=vY.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new vY(c))),!0):!1}}function EY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!vY.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&QP.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new vY(r))),!0)}function DY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof vY))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=X.empty;for(let e=r.length-1;e>=0;e--)i=X.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Z(i,0,0));return a.setSelection(XP.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function OY(e){if(!(e.selection instanceof vY))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,Uz.create(e.doc,[Bz.widget(e.selection.head,t,{key:`gapcursor`})])}var kY=200,AY=function(){};AY.prototype.append=function(e){return e.length?(e=AY.from(e),!this.length&&e||e.length<kY&&this.leafAppend(e)||this.length<kY&&e.leafPrepend(this)||this.appendInner(e)):this},AY.prototype.prepend=function(e){return e.length?AY.from(e).append(this):this},AY.prototype.appendInner=function(e){return new MY(this,e)},AY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?AY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},AY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},AY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},AY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},AY.from=function(e){return e instanceof AY?e:e&&e.length?new jY(e):AY.empty};var jY=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=kY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=kY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(AY);AY.empty=new jY([]);var MY=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(AY),NY=500,PY=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new IY(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new IY(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new IY(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>RY&&(s=FY(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new UN;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new IY(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new IY(i,o,l))}else r.push(new IY(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new IY(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>NY&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new IY(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(AY.from(i.reverse()),a)}};PY.empty=new PY(AY.empty,0);function FY(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var IY=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},LY=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},RY=20;function zY(e,t,n,r){let i=n.getMeta(qY),a;if(i)return i.historyState;n.getMeta(JY)&&(e=new LY(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(qY))return o.getMeta(qY).redo?new LY(e.done.addTransform(n,void 0,r,KY(t)),e.undone,VY(n.mapping.maps),e.prevTime,e.prevComposition):new LY(e.done,e.undone.addTransform(n,void 0,r,KY(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!BY(n,e.prevRanges)),s=o?HY(e.prevRanges,n.mapping):VY(n.mapping.maps);return new LY(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,KY(t)),PY.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new LY(e.done.rebased(n,a),e.undone.rebased(n,a),HY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new LY(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),HY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function BY(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function VY(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function HY(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function UY(e,t,n){let r=KY(t),i=qY.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new LY(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(qY,{redo:n,historyState:c})}var WY=!1,GY=null;function KY(e){let t=e.plugins;if(GY!=t){WY=!1,GY=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){WY=!0;break}}return WY}var qY=new _F(`history`),JY=new _F(`closeHistory`);function YY(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new mF({key:qY,state:{init(){return new LY(PY.empty,PY.empty,null,0,-1)},apply(t,n,r){return zY(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?ZY:n==`historyRedo`?QY:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function XY(e,t){return(n,r)=>{let i=qY.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=UY(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var ZY=XY(!1,!0),QY=XY(!0,!0);WU.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new mF({key:new _F(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var $Y=WU.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[gY(this.options)]}});WU.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new mF({key:new _F(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return Uz.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(Bz.node(t,t+e.nodeSize,{class:this.options.className}))}),Uz.create(e,a)}}})]}});var eX=WU.create({name:`gapCursor`,addProseMirrorPlugins(){return[CY()]},extendNodeSchema(e){return{allowGapCursor:hH(Q(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),tX=`placeholder`;function nX(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}WU.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:tX,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${nX(this.options.dataAttribute)}`:`data-${tX}`;return[new mF({key:new _F(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&XH(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=Bz.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),Uz.create(t,a)}}})]}}),WU.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new mF({key:new _F(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||ZH(n.selection)||e.view.dragging?null:Uz.create(n.doc,[Bz.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function rX({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var iX=WU.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new _F(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new mF({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!rX({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!rX({node:r,types:n})}}})]}}),aX=WU.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>ZY(e,t),redo:()=>({state:e,dispatch:t})=>QY(e,t)}},addProseMirrorPlugins(){return[YY(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),oX=WU.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(QG.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(qG.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(FJ.configure(this.options.bulletList)),this.options.code!==!1&&e.push(tK.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(aK.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(oK.configure(this.options.document)),this.options.dropcursor!==!1&&e.push($Y.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(eX.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(sK.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(cK.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(aX.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(lK.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(mK.configure(this.options.italic)),this.options.listItem!==!1&&e.push(IJ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qJ.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(kJ.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(iY.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(uY.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(pY.configure(this.options.strike)),this.options.text!==!1&&e.push(mY.configure(this.options.text)),this.options.underline!==!1&&e.push(hY.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(iX.configure(this.options?.trailingNode)),e}}),sX=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cX=CW.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,xH(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new dW({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[sW({find:sX,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function lX({onClick:e,active:t,disabled:n,title:r,children:i}){return(0,H.jsx)(`button`,{type:`button`,title:r,disabled:n,onMouseDown:t=>{t.preventDefault(),e()},className:K(`flex size-7 items-center justify-center rounded transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`,n&&`pointer-events-none opacity-40`),children:i})}function uX(){return(0,H.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`})}function dX({value:e,onChange:t,placeholder:n,onInsertImage:r}){let[i,a]=(0,v.useState)(!e),o=LG({extensions:[oX.configure({link:{openOnClick:!1,HTMLAttributes:{class:`text-primary underline`}}}),cX.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null}}}}).configure({HTMLAttributes:{class:`max-w-full rounded`}})],content:(()=>{if(!e)return``;try{return JSON.parse(e)}catch{return e}})(),editorProps:{attributes:{class:`h-128 px-3 py-2.5 focus:outline-none`}},onUpdate({editor:e}){a(e.isEmpty),t(JSON.stringify(e.getJSON()))}});(0,v.useEffect)(()=>{if(!o)return;let t=e?(()=>{try{return JSON.parse(e)}catch{return e}})():``;JSON.stringify(o.getJSON())!==e&&o.commands.setContent(t,{emitUpdate:!1}),a(o.isEmpty)},[e]);async function s(){if(!o||!r)return;let e=await r();e&&o.chain().focus().setImage({src:e.src,alt:e.alt??void 0,width:e.width??void 0,height:e.height??void 0}).run()}function c(){if(!o)return;let e=o.getAttributes(`link`).href,t=window.prompt(`URL`,e??`https://`);if(t!==null){if(!t){o.chain().focus().unsetLink().run();return}o.chain().focus().setLink({href:t}).run()}}return o?(0,H.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-input bg-background focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50`,children:[(0,H.jsxs)(`div`,{className:`sticky top-0 z-10 flex flex-wrap items-center gap-0.5 border-b border-border bg-background px-2 py-1.5`,children:[(0,H.jsx)(lX,{title:`Bold`,active:o.isActive(`bold`),onClick:()=>o.chain().focus().toggleBold().run(),children:(0,H.jsx)(Ta,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Italic`,active:o.isActive(`italic`),onClick:()=>o.chain().focus().toggleItalic().run(),children:(0,H.jsx)(oo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Underline`,active:o.isActive(`underline`),onClick:()=>o.chain().focus().toggleUnderline().run(),children:(0,H.jsx)(No,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Strikethrough`,active:o.isActive(`strike`),onClick:()=>o.chain().focus().toggleStrike().run(),children:(0,H.jsx)(Do,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Heading 1`,active:o.isActive(`heading`,{level:1}),onClick:()=>o.chain().focus().toggleHeading({level:1}).run(),children:(0,H.jsx)(to,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Heading 2`,active:o.isActive(`heading`,{level:2}),onClick:()=>o.chain().focus().toggleHeading({level:2}).run(),children:(0,H.jsx)(no,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Heading 3`,active:o.isActive(`heading`,{level:3}),onClick:()=>o.chain().focus().toggleHeading({level:3}).run(),children:(0,H.jsx)(ro,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Bullet list`,active:o.isActive(`bulletList`),onClick:()=>o.chain().focus().toggleBulletList().run(),children:(0,H.jsx)(mo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Ordered list`,active:o.isActive(`orderedList`),onClick:()=>o.chain().focus().toggleOrderedList().run(),children:(0,H.jsx)(po,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Blockquote`,active:o.isActive(`blockquote`),onClick:()=>o.chain().focus().toggleBlockquote().run(),children:(0,H.jsx)(yo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Inline code`,active:o.isActive(`code`),onClick:()=>o.chain().focus().toggleCode().run(),children:(0,H.jsx)(Ra,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Code block`,active:o.isActive(`codeBlock`),onClick:()=>o.chain().focus().toggleCodeBlock().run(),children:(0,H.jsx)(To,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),(0,H.jsx)(lX,{title:`Add link`,active:o.isActive(`link`),onClick:c,children:(0,H.jsx)(fo,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Remove link`,disabled:!o.isActive(`link`),onClick:()=>o.chain().focus().unsetLink().run(),children:(0,H.jsx)(Po,{className:`size-3.5`})}),(0,H.jsx)(uX,{}),r&&(0,H.jsx)(lX,{title:`Insert image`,onClick:s,children:(0,H.jsx)(ao,{className:`size-3.5`})}),(0,H.jsx)(lX,{title:`Hard break (Shift + Enter)`,onClick:()=>o.chain().focus().setHardBreak().run(),children:(0,H.jsx)(ko,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`relative overflow-y-auto`,children:[i&&n&&(0,H.jsx)(`p`,{className:`pointer-events-none absolute left-3 top-2.5 text-muted-foreground select-none`,children:n}),(0,H.jsx)(kG,{editor:o})]})]}):null}function fX(e){let t=localStorage.getItem(`plank_token`);return{...t?{Authorization:`Bearer ${t}`}:{},...e}}function pX(e){return e.type.startsWith(`image/`)?new Promise(t=>{let n=new Image,r=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(r),t({width:n.naturalWidth,height:n.naturalHeight})},n.onerror=()=>{URL.revokeObjectURL(r),t(null)},n.src=r}):Promise.resolve(null)}async function mX(e,t){let n=await pX(e),r=await fetch(`/cms/admin/media/presign`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type,folderId:t?.folderId??null})});if(!r.ok)throw Error(`Upload failed.`);let i=await r.json();if(i.mode===`presigned`){if(!(await fetch(i.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let r=await fetch(`/cms/admin/media/confirm`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({key:i.key,filename:e.name,mimeType:e.type,size:e.size,folderId:t?.folderId??null,width:n?.width??null,height:n?.height??null})});if(!r.ok)throw Error(`Upload failed.`);return r.json()}let a=new FormData;a.append(`files`,e,e.name),t?.folderId&&a.append(`folder_id`,t.folderId),n?.width&&a.append(`width`,String(n.width)),n?.height&&a.append(`height`,String(n.height));let o=await fetch(`/cms/admin/media`,{method:`POST`,headers:fX(),body:a});if(!o.ok)throw Error(`Upload failed.`);return o.json()}async function hX(e){let t=await fetch(`/cms/admin/users/me/avatar/presign`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type})});if(!t.ok)throw Error(`Upload failed.`);let n=await t.json();if(n.mode===`presigned`){if(!(await fetch(n.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let t=await fetch(`/cms/admin/users/me/avatar/confirm`,{method:`POST`,headers:fX({"Content-Type":`application/json`}),body:JSON.stringify({key:n.key})});if(!t.ok)throw Error(`Upload failed.`);return(await t.json()).avatarUrl}let r=new FormData;r.append(`file`,e);let i=await fetch(`/cms/admin/users/me/avatar`,{method:`POST`,headers:fX(),body:r});if(!i.ok)throw Error(`Upload failed.`);return(await i.json()).avatarUrl}var gX=1,_X=.9,vX=.8,yX=.17,bX=.1,xX=.999,SX=.9999,CX=.99,wX=/[\\\/_+.#"@\[\(\{&]/,TX=/[\\\/_+.#"@\[\(\{&]/g,EX=/[\s-]/,DX=/[\s-]/g;function OX(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?gX:CX;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=OX(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=gX:wX.test(e.charAt(l-1))?(d*=vX,p=e.slice(i,l-1).match(TX),p&&i>0&&(d*=xX**+p.length)):EX.test(e.charAt(l-1))?(d*=_X,m=e.slice(i,l-1).match(DX),m&&i>0&&(d*=xX**+m.length)):(d*=yX,i>0&&(d*=xX**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=SX)),(d<bX&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=OX(e,t,n,r,l+1,a+2,o),f*bX>d&&(d=f*bX)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function kX(e){return e.toLowerCase().replace(DX,` `)}function AX(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,OX(e,t,kX(e),kX(t),0,0,{})}var jX=`[cmdk-group=""]`,MX=`[cmdk-group-items=""]`,NX=`[cmdk-group-heading=""]`,PX=`[cmdk-item=""]`,FX=`${PX}:not([aria-disabled="true"])`,IX=`cmdk-item-select`,LX=`data-value`,RX=(e,t,n)=>AX(e,t,n),zX=v.createContext(void 0),BX=()=>v.useContext(zX),VX=v.createContext(void 0),HX=()=>v.useContext(VX),UX=v.createContext(void 0),WX=v.forwardRef((e,t)=>{let n=iZ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=iZ(()=>new Set),i=iZ(()=>new Map),a=iZ(()=>new Map),o=iZ(()=>new Set),s=nZ(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,y=du(),b=du(),x=du(),S=v.useRef(null),C=sZ();rZ(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),rZ(()=>{C(6,A)},[]);let w=v.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(y))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=v.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:y,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??RX;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(MX);t?t.appendChild(e.parentElement===t?e:e.closest(`${MX} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${MX} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${jX}[${LX}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(LX);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(jX)?.querySelector(NX))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${PX}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(FX)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(LX))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(LX))}function F(e){let t=j()?.closest(jX),n;for(;t&&!n;)t=e>0?eZ(t,jX):tZ(t,jX),n=t?.querySelector(FX);n?w.setState(`value`,n.getAttribute(LX)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return v.createElement(Rc.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(IX);t.dispatchEvent(e)}}}}},v.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:uZ},c),lZ(e,e=>v.createElement(VX.Provider,{value:w},v.createElement(zX.Provider,{value:T},e))))}),GX=v.forwardRef((e,t)=>{let n=du(),r=v.useRef(null),i=v.useContext(UX),a=BX(),o=nZ(e),s=o.current?.forceMount??i?.forceMount;rZ(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=oZ(n,r,[e.value,e.children,r],e.keywords),l=HX(),u=aZ(e=>e.value&&e.value===c.current),d=aZ(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);v.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(IX,f),()=>t.removeEventListener(IX,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:y,...b}=e;return v.createElement(Rc.div,{ref:Wo(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),KX=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=du(),s=v.useRef(null),c=v.useRef(null),l=du(),u=BX(),d=aZ(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);rZ(()=>u.group(o),[]),oZ(o,s,[e.value,e.heading,c]);let f=v.useMemo(()=>({id:o,forceMount:i}),[i]);return v.createElement(Rc.div,{ref:Wo(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&v.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),lZ(e,e=>v.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},v.createElement(UX.Provider,{value:f},e))))}),qX=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=v.useRef(null),a=aZ(e=>!e.search);return!n&&!a?null:v.createElement(Rc.div,{ref:Wo(i,t),...r,"cmdk-separator":``,role:`separator`})}),JX=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=HX(),o=aZ(e=>e.search),s=aZ(e=>e.selectedItemId),c=BX();return v.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),v.createElement(Rc.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),YX=v.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=v.useRef(null),o=v.useRef(null),s=aZ(e=>e.selectedItemId),c=BX();return v.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),v.createElement(Rc.div,{ref:Wo(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},lZ(e,e=>v.createElement(`div`,{ref:Wo(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),XX=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return v.createElement(Py,{open:n,onOpenChange:r},v.createElement(Fy,{container:o},v.createElement(Iy,{"cmdk-overlay":``,className:i}),v.createElement(Ly,{"aria-label":e.label,"cmdk-dialog":``,className:a},v.createElement(WX,{ref:t,...s}))))}),ZX=v.forwardRef((e,t)=>aZ(e=>e.filtered.count===0)?v.createElement(Rc.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),QX=v.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return v.createElement(Rc.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},lZ(e,e=>v.createElement(`div`,{"aria-hidden":!0},e)))}),$X=Object.assign(WX,{List:YX,Item:GX,Input:JX,Group:KX,Separator:qX,Dialog:XX,Empty:ZX,Loading:QX});function eZ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tZ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function nZ(e){let t=v.useRef(e);return rZ(()=>{t.current=e}),t}var rZ=typeof window>`u`?v.useEffect:v.useLayoutEffect;function iZ(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function aZ(e){let t=HX(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function oZ(e,t,n,r=[]){let i=v.useRef(),a=BX();return rZ(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(LX,s),i.current=s}),i}var sZ=()=>{let[e,t]=v.useState(),n=iZ(()=>new Map);return rZ(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function cZ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function lZ({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(cZ(t),{ref:t.ref},n(t.props.children)):n(t)}var uZ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},dZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X,{ref:n,className:K(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t}));dZ.displayName=$X.displayName;var fZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsxs)(`div`,{className:`flex items-center border-b px-3`,"cmdk-input-wrapper":``,children:[(0,H.jsx)(So,{className:`mr-2 h-4 w-4 shrink-0 opacity-50`}),(0,H.jsx)($X.Input,{ref:n,className:K(`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}));fZ.displayName=$X.Input.displayName;var pZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.List,{ref:n,className:K(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));pZ.displayName=$X.List.displayName;var mZ=v.forwardRef((e,t)=>(0,H.jsx)($X.Empty,{ref:t,className:`py-6 text-center text-sm`,...e}));mZ.displayName=$X.Empty.displayName;var hZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.Group,{ref:n,className:K(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t}));hZ.displayName=$X.Group.displayName;var gZ=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.Separator,{ref:n,className:K(`-mx-1 h-px bg-border`,e),...t}));gZ.displayName=$X.Separator.displayName;var _Z=v.forwardRef(({className:e,...t},n)=>(0,H.jsx)($X.Item,{ref:n,className:K(`relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,e),...t}));_Z.displayName=$X.Item.displayName;var vZ=({className:e,...t})=>(0,H.jsx)(`span`,{className:K(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t});vZ.displayName=`CommandShortcut`;var yZ={image:`image/*`,video:`video/*`,audio:`audio/*`,document:`.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv`};function bZ(e){return!e||e.length===0?`*/*`:e.map(e=>yZ[e]).join(`,`)}function xZ(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function SZ(e){return e?.startsWith(`image/`)??!1}async function CZ(e,t){return mX(e,{folderId:t})}function wZ(e,t){if(!t||t.length===0)return!0;let n=e??``;return t.some(e=>e===`image`?n.startsWith(`image/`):e===`video`?n.startsWith(`video/`):e===`audio`?n.startsWith(`audio/`):e===`document`?n.startsWith(`application/`)||n.startsWith(`text/`):!1)}function TZ({open:e,onOpenChange:t,allowedTypes:n,onSelect:r}){let[i,a]=(0,v.useState)([{id:null,name:`Media`}]),o=i[i.length-1].id,[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;f(!0);let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=o??``;Promise.all([fetch(`/cms/admin/folders?parent_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{folders:[]}).then(e=>e.folders),fetch(`/cms/admin/media?folder_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{items:[]}).then(e=>e.items)]).then(([e,t])=>{c(e),u(t)}).catch(()=>{c([]),u([])}).finally(()=>f(!1))},[e,o]),(0,v.useEffect)(()=>{e||a([{id:null,name:`Media`}])},[e]);function p(e){a(t=>[...t,{id:e.id,name:e.name}])}function m(e){a(t=>t.slice(0,e+1))}let h=l.filter(e=>wZ(e.mime_type,n)),g=s.length===0&&h.length===0;return(0,H.jsx)(US,{open:e,onOpenChange:t,children:(0,H.jsxs)(qS,{className:`max-w-3xl`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Media Library`})}),i.length>1&&(0,H.jsx)(`div`,{className:`flex items-center gap-1 text-sm -mt-1`,children:i.map((e,t)=>(0,H.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[t>0&&(0,H.jsx)(`span`,{children:`/`}),t===i.length-1?(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name}):(0,H.jsx)(`button`,{onClick:()=>m(t),className:`hover:text-foreground transition-colors`,children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name})]},t))}),d?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,H.jsx)(Mv,{className:`size-5`})}):g?(0,H.jsx)(`p`,{className:`py-16 text-center text-sm text-muted-foreground`,children:l.length===0&&s.length===0?`No media found.`:`No matching files in this folder.`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 max-h-[60vh] overflow-y-auto pr-1`,children:[s.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2`,children:s.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`flex items-center gap-2.5 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-muted/50 hover:border-primary`,children:[(0,H.jsx)(Qa,{className:`size-7 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`p`,{className:`truncate text-xs font-bold leading-tight`,title:e.name,children:e.name}),(0,H.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]})]},e.id))}),h.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-5`,children:h.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{r(e),t(!1)},className:`group relative overflow-hidden rounded-md border bg-card text-left transition-colors hover:border-primary`,children:[(0,H.jsx)(`div`,{className:`aspect-square bg-muted`,children:SZ(e.mime_type)?(0,H.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,H.jsx)(Ja,{className:`size-6 text-muted-foreground`})})}),(0,H.jsxs)(`div`,{className:`p-1.5`,children:[(0,H.jsx)(`p`,{className:`truncate text-[11px] font-medium leading-tight`,title:e.filename,children:e.filename}),(0,H.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:xZ(e.size)})]}),(0,H.jsx)(`div`,{className:`absolute inset-0 rounded-md ring-2 ring-primary ring-offset-1 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`})]},e.id))})]})]})})}function EZ({value:e,onChange:t,allowedTypes:n,disabled:r=!1}){let i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(!1),p=typeof e==`string`&&e.startsWith(`http`);(0,v.useEffect)(()=>{if(!e){u(null);return}if(p){u(e);return}let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(e=>u(e?.url??null)).catch(()=>u(null))},[e,p]);async function m(e){o(!0),c(null);try{let n=await CZ(e);u(n.url),t(n.id)}catch(e){c(e instanceof Error?e.message:`Upload failed.`)}finally{o(!1),i.current&&(i.current.value=``)}}let h=l&&/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i.test(l);return e?(0,H.jsxs)(`div`,{className:`relative w-full rounded-md border bg-muted/30 overflow-hidden`,children:[l?h?(0,H.jsx)(`img`,{src:l,alt:`Media`,className:`max-h-72 w-full object-contain`}):(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,H.jsx)(ao,{className:`size-4 text-muted-foreground shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l})]}):(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-muted-foreground`,children:[(0,H.jsx)(ao,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs`,children:`Loading…`})]}),(0,H.jsx)(q,{type:`button`,size:`icon`,variant:`secondary`,className:`absolute top-1.5 right-1.5 size-6`,onClick:()=>{t(null),u(null)},disabled:r,children:(0,H.jsx)(zo,{className:`size-3.5`})})]}):(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`input`,{ref:i,type:`file`,accept:bZ(n),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&m(t)}}),(0,H.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(r)return;e.preventDefault();let t=e.dataTransfer.files[0];t&&m(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>i.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Fo,{className:`size-4`}),a?`Uploading…`:`Upload`]}),(0,H.jsx)(`div`,{className:`w-px bg-border`}),(0,H.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>f(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Xa,{className:`size-4`}),`Library`]})]}),s&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:s}),(0,H.jsx)(TZ,{open:d,onOpenChange:f,allowedTypes:n,onSelect:e=>{u(e.url),t(e.id)}})]})}function DZ({id:e,previewUrl:t,filename:n,onRemove:r,disabled:i=!1}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=BE({id:e});return(0,H.jsxs)(`div`,{ref:s,style:{transform:$C.Transform.toString(c),transition:l,opacity:u?.4:1},className:`relative aspect-square overflow-hidden rounded-md border bg-muted`,children:[t?(0,H.jsx)(`img`,{src:t,alt:n,className:`h-full w-full object-cover`}):(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,H.jsx)(ao,{className:`size-5 text-muted-foreground`})}),n&&(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 bg-background/75 backdrop-blur-sm px-1.5 py-1 pointer-events-none`,children:(0,H.jsx)(`p`,{className:`truncate text-[10px] leading-none text-foreground`,children:n})}),(0,H.jsx)(`button`,{type:`button`,onClick:r,disabled:i,className:`absolute right-1 top-1 flex size-5 items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm hover:bg-background`,children:(0,H.jsx)(zo,{className:`size-3`})}),!i&&(0,H.jsx)(`button`,{type:`button`,className:`absolute bottom-6 left-1 flex size-5 cursor-grab items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm active:cursor-grabbing`,...o,...a,children:(0,H.jsx)($a,{className:`size-3`})})]})}function OZ({value:e,onChange:t,disabled:n=!1}){let r=Array.isArray(e)?e:[],[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),m=(0,v.useRef)(null),h=hw(mw(hT,{activationConstraint:{distance:5}}));(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in i));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);Promise.all(e.map(e=>fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(t=>t?[e,t.url]:null).catch(()=>null))).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);Object.keys(t).length>0&&a(e=>({...e,...t}))})},[r.join(`,`)]),(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in o));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():{items:[]}).then(t=>{let n={};for(let r of t.items)e.includes(r.id)&&(n[r.id]=r.filename);Object.keys(n).length>0&&s(e=>({...e,...n}))}).catch(()=>{})},[r.join(`,`)]);function g(e){return e.startsWith(`http`)?e:i[e]??null}function _(e){return o[e]??``}function y(e){if(n)return;let{active:i,over:a}=e;!a||i.id===a.id||t(xE(r,r.indexOf(i.id),r.indexOf(a.id)))}async function b(e){if(e.length===0)return;l(!0),d(null);let n=r;try{for(let r of e){let e=await CZ(r);a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:r.name})),n=[...n,e.id],t(n)}}catch(e){d(e instanceof Error?e.message:`Upload failed.`)}finally{l(!1),m.current&&(m.current.value=``)}}return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`input`,{ref:m,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:e=>{b(Array.from(e.target.files??[]))}}),r.length>0&&(0,H.jsx)(fE,{sensors:h,collisionDetection:Sw,onDragEnd:y,children:(0,H.jsx)(ME,{items:r,strategy:EE,children:(0,H.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4`,children:r.map(e=>(0,H.jsx)(DZ,{id:e,previewUrl:g(e),filename:_(e),onRemove:()=>t(r.filter(t=>t!==e)),disabled:n},e))})})}),(0,H.jsxs)(`div`,{className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>m.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Fo,{className:`size-4`}),c?`Uploading…`:`Upload`]}),(0,H.jsx)(`div`,{className:`w-px bg-border`}),(0,H.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>p(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Xa,{className:`size-4`}),`Library`]})]}),u&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:u}),(0,H.jsx)(TZ,{open:f,onOpenChange:p,allowedTypes:[`image`],onSelect:e=>{r.includes(e.id)||(a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:e.filename})),t([...r,e.id]))}})]})}function kZ({value:e,onChange:t,disabled:n=!1}){let[r,i]=(0,v.useState)(()=>e!=null&&e!==``?String(e):``);(0,v.useEffect)(()=>{if(e==null||e===``){i(``);return}let t=typeof e==`number`?e:parseFloat(String(e));!isNaN(t)&&t!==parseFloat(r)&&i(String(t))},[e]);function a(e){let n=e.target.value.replace(`,`,`.`);if(i(n),n===``||n===`-`){t(null);return}let r=parseFloat(n);isNaN(r)||t(r)}return(0,H.jsx)(Tv,{type:`text`,inputMode:`decimal`,className:K(`w-full`,`text-base!`),value:r,placeholder:`0.00`,onChange:a,disabled:n})}function AZ({value:e,onChange:t,timezone:n,disabled:r=!1}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(`00:00`);(0,v.useEffect)(()=>{if(!e){s(void 0),l(`00:00`);return}let t=new Date(e);isNaN(t.getTime())||(s(t),l(Lv(e,n)))},[e,n]);function u(e){s(e),a(!1),e&&t(Rv(e,c,n))}function d(e){l(e),o&&t(Rv(o,e,n))}return(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(oM,{open:i&&!r,onOpenChange:a,children:[(0,H.jsx)(sM,{asChild:!0,children:(0,H.jsxs)(q,{variant:`outline`,className:`w-40 justify-between font-normal text-base`,disabled:r,children:[o?uk(o,`MMM d, yyyy`):`Select date`,(0,H.jsx)(Aa,{className:`size-4 opacity-50`})]})}),(0,H.jsx)(cM,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,H.jsx)(iM,{mode:`single`,selected:o,captionLayout:`dropdown`,defaultMonth:o??new Date,onSelect:u})})]}),(0,H.jsx)(Tv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none text-base!`,value:c,onChange:e=>d(e.target.value),disabled:r}),e&&(0,H.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground hover:text-foreground`,onClick:()=>{s(void 0),l(`00:00`),t(null)},disabled:r,children:(0,H.jsx)(zo,{className:`size-3.5`})})]})}function jZ(e){return e.find(e=>e.type===`uid`)?.name??e.find(e=>e.type===`string`)?.name??null}var MZ={data:null,promise:null};function NZ(e){return MZ.data?Promise.resolve(MZ.data):(MZ.promise||=fetch(`/cms/admin/content-types`,{headers:e}).then(e=>e.ok?e.json():[]).then(e=>(MZ.data=e,e)).catch(()=>[]),MZ.promise)}function PZ(e,t){return e.find(e=>e.tableName===t)??null}function FZ(e,t){return fetch(`/cms/admin/content-types/${e}/entries?limit=200`,{headers:t}).then(e=>e.ok?e.json():{data:[]}).catch(()=>({data:[]}))}function IZ(e){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e)return;i(!0);let t=localStorage.getItem(`plank_token`),r=t?{Authorization:`Bearer ${t}`}:{};NZ(r).then(t=>{let n=PZ(t,e);return n?FZ(n.slug,r).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:t})=>{let r=e?jZ(e.fields??[]):null;n(t.data.map(e=>({id:String(e.id),label:String(r?e[r]??e.id:e.id)})))}).catch(()=>n([])).finally(()=>i(!1))},[e]),{entries:t,loading:r}}function LZ(e,t,n){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e||!n){i([]);return}o(!0);let r=localStorage.getItem(`plank_token`),a=r?{Authorization:`Bearer ${r}`}:{};NZ(a).then(t=>{let n=PZ(t,e);return n?FZ(n.slug,a).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:r})=>{let a=e?jZ(e.fields??[]):null;i(r.data.filter(e=>String(e[t]??``)===n).map(e=>({id:String(e.id),label:String(a?e[a]??e.id:e.id)})))}).catch(()=>i([])).finally(()=>o(!1))},[e,t,n]),{entries:r,loading:a}}function RZ({relatedTable:e,relatedField:t,currentId:n}){let{entries:r,loading:i}=LZ(e,t,n);return n?i?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,H.jsx)(Mv,{className:`size-3.5`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading…`})]}):r.length===0?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No linked entries.`}):(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,H.jsx)(`span`,{className:`inline-flex items-center rounded-md border bg-muted px-2 py-0.5 text-xs`,children:e.label},e.id))}):(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save this entry first to see linked items.`})}function zZ({relationType:e,relatedTable:t,relatedField:n,currentEntryId:r,value:i,onChange:a,disabled:o=!1}){let s=e===`many-to-many`,[c,l]=(0,v.useState)(!1),{entries:u,loading:d}=IZ(t);if(e===`one-to-many`)return(0,H.jsx)(RZ,{relatedTable:t,relatedField:n,currentId:r});let f=s?Array.isArray(i)?i:[]:i&&!Array.isArray(i)?[i]:[];function p(e){return u.find(t=>t.id===e)?.label??e}function m(e){if(s){let t=f.includes(e)?f.filter(t=>t!==e):[...f,e];a(t.length>0?t:null)}else a(f[0]===e?null:e),l(!1)}function h(e){if(s){let t=f.filter(t=>t!==e);a(t.length>0?t:null)}else a(null)}let g=s?f.length>0?`${f.length} selected`:`Select entries…`:f.length>0?p(f[0]):`Select entry…`;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(oM,{open:c&&!o,onOpenChange:l,children:[(0,H.jsx)(sM,{asChild:!0,children:(0,H.jsxs)(q,{variant:`outline`,role:`combobox`,"aria-expanded":c,className:`w-full justify-between font-normal text-base`,disabled:o,children:[(0,H.jsx)(`span`,{className:`truncate text-left`,children:g}),(0,H.jsx)(Pa,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,H.jsx)(cM,{className:`w-(--radix-popover-trigger-width) p-0`,align:`start`,children:(0,H.jsxs)(dZ,{children:[(0,H.jsx)(fZ,{placeholder:`Search…`}),(0,H.jsx)(pZ,{children:d?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,H.jsx)(Mv,{className:`size-4`})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(mZ,{children:`No entries found.`}),(0,H.jsx)(hZ,{children:u.map(e=>{let t=f.includes(e.id);return(0,H.jsxs)(_Z,{value:e.label,onSelect:()=>{o||m(e.id)},children:[(0,H.jsx)(ka,{className:`mr-2 size-4 ${t?`opacity-100`:`opacity-0`}`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.label}),(0,H.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground opacity-60 shrink-0`,children:e.id.slice(0,8)})]},e.id)})})]})})]})})]}),f.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border bg-muted px-2 py-0.5 text-xs`,children:[p(e),(0,H.jsx)(`button`,{type:`button`,onClick:()=>h(e),disabled:o,className:`text-muted-foreground hover:text-foreground`,children:(0,H.jsx)(zo,{className:`size-3`})})]},e))})]})}var BZ={full:`col-span-6`,"two-thirds":`col-span-4`,half:`col-span-3`,third:`col-span-2`};function VZ({field:e,value:t,onChange:n,disabled:r=!1}){let i=Array.isArray(t)?t:[],a=e.arrayFields??[];function o(){return Object.fromEntries(a.map(e=>[e.name,e.type===`boolean`?!1:null]))}function s(){n([...i,o()])}function c(e){n(i.filter((t,n)=>n!==e))}function l(e,t,r){n(i.map((n,i)=>i===e?{...n,[t]:r}:n))}return a.length===0?(0,H.jsx)(`div`,{className:`flex w-full items-center justify-center rounded-md border border-dashed p-4 text-xs text-muted-foreground`,children:`No sub-fields defined for this array.`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[`Item `,t+1]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>c(t),disabled:r,className:`flex size-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,H.jsx)(jo,{className:`size-3.5`})})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:a.map(n=>(0,H.jsxs)(`div`,{className:BZ[n.width??`full`]??`col-span-6`,children:[(0,H.jsx)(`div`,{className:`mb-1 flex items-center gap-1`,children:(0,H.jsxs)(Y,{className:`text-xs font-medium`,children:[n.name,n.required&&(0,H.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]})}),(0,H.jsx)(WZ,{field:{...n,type:n.type},value:e[n.name]??null,onChange:e=>l(t,n.name,e),allValues:e,disabled:r})]},n.name))})]},t)),(0,H.jsxs)(`button`,{type:`button`,onClick:s,disabled:r,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:border-primary hover:text-primary`,children:[(0,H.jsx)(vo,{className:`size-3.5`}),`Add item`]})]})}function HZ(e){return e.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/^-+|-+$/g,``)}function UZ({value:e,onChange:t,disabled:n=!1}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null);function p(){return o(!0),new Promise(e=>{i.current=e})}function m(e){i.current?.(e),i.current=null}function h(e){e||m(null),o(e)}async function g(e){u(!0),f(null);try{let t=await mX(e);m({src:t.url,alt:t.alt,width:t.width,height:t.height}),o(!1)}catch(e){f(e instanceof Error?e.message:`Upload failed.`)}finally{u(!1),r.current&&(r.current.value=``)}}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:n?`pointer-events-none opacity-70`:``,children:(0,H.jsx)(dX,{value:String(e??``),onChange:t,placeholder:`Type or add your content here...`,onInsertImage:p})}),(0,H.jsx)(US,{open:a,onOpenChange:h,children:(0,H.jsxs)(qS,{className:`max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Insert Image`})}),(0,H.jsx)(`input`,{ref:r,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&g(t)}}),(0,H.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault();let t=e.dataTransfer.files[0];t&&g(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>r.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Fo,{className:`size-4`}),l?`Uploading…`:`Upload`]}),(0,H.jsx)(`div`,{className:`w-px bg-border`}),(0,H.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>c(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,H.jsx)(Xa,{className:`size-4`}),`Library`]})]}),d&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:d})]})}),(0,H.jsx)(TZ,{open:s,onOpenChange:e=>{!e&&!a&&m(null),c(e)},allowedTypes:[`image`],onSelect:e=>{m({src:e.url,alt:e.alt,width:e.width,height:e.height}),c(!1),o(!1)}})]})}function WZ({field:e,value:t,onChange:n,allValues:r,disabled:i}){let a=(0,v.useRef)(!1),{timezone:o}=la();(0,v.useEffect)(()=>{if(e.type!==`uid`||!e.targetField||a.current)return;let t=r,i=e.targetField,o=!!t.__localizationEnabled,s=r[i];if(s!=null&&String(s).trim()!==``){n(HZ(String(s)));return}let c=r.localized&&typeof r.localized==`object`?r.localized:{};if(o){let e=r.__defaultLocale;e&&c[e]&&c[e][i]!==void 0&&String(c[e][i]).trim()!==``&&n(HZ(String(c[e][i])));return}let l=Object.keys(c).filter(e=>!e.startsWith(`_`));for(let e of l)if(c[e]&&c[e][i]!==void 0&&String(c[e][i]).trim()!==``){n(HZ(String(c[e][i])));return}},[e.type,e.targetField,r[e.targetField??``],JSON.stringify(r.localized??{}),r.__localizationEnabled]);let s=`w-full`;return e.type===`boolean`?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,H.jsx)(XE,{id:`field-${e.name}`,checked:!!t,onCheckedChange:e=>n(!!e),disabled:!!i}),(0,H.jsx)(Y,{htmlFor:`field-${e.name}`,className:`cursor-pointer font-normal text-base`,children:t?`Yes`:`No`})]}):e.type===`richtext`?(0,H.jsx)(UZ,{value:t,onChange:n,disabled:!!i}):e.type===`text`?(0,H.jsx)(lM,{className:K(s,`text-base`),value:String(t??``),placeholder:e.name,onChange:e=>n(e.target.value),disabled:!!i}):e.type===`number`?e.subtype===`float`?(0,H.jsx)(kZ,{value:t,onChange:n,disabled:!!i}):(0,H.jsx)(Tv,{type:`number`,className:K(s,`text-base!`),value:t==null?``:String(t),step:`1`,placeholder:`0`,onChange:e=>{let t=e.target.value;if(t===``){n(null);return}n(parseInt(t,10))},disabled:!!i}):e.type===`datetime`?(0,H.jsx)(AZ,{value:t,onChange:n,timezone:o,disabled:!!i}):e.type===`uid`?(0,H.jsx)(Tv,{className:K(s,`text-base md:text-base`),value:String(t??``),placeholder:`auto-generated`,onChange:e=>{let t=e.target.value;a.current=!!(t&&t!==``),n(e.target.value)},disabled:!!i}):e.type===`media`?(0,H.jsx)(EZ,{value:t,onChange:n,allowedTypes:e.allowedTypes,disabled:!!i}):e.type===`media-gallery`?(0,H.jsx)(OZ,{value:t,onChange:n,disabled:!!i}):e.type===`relation`?(0,H.jsx)(zZ,{relationType:e.relationType??`many-to-one`,relatedTable:e.relatedTable??``,relatedField:e.relatedField??``,currentEntryId:String(r.id??``),value:t,onChange:n,disabled:!!i}):e.type===`array`?(0,H.jsx)(VZ,{field:e,value:t,onChange:n,disabled:!!i}):(0,H.jsx)(Tv,{className:K(s,`text-base md:text-base`),value:String(t??``),placeholder:e.name,onChange:e=>n(e.target.value),disabled:!!i})}function GZ(){let{slug:e,id:t}=rr(),n=$n(),r=!t,{timezone:i,locales:a,defaultLocale:o}=la(),{user:s}=oa(),{data:c,loading:l}=ma(e?`/cms/admin/content-types/${e}`:null),{data:u,loading:d}=ma(e&&t?`/cms/admin/entries/${e}/${t}`:null),{loading:f,request:p}=wv(),{loading:m,request:h}=wv(),{loading:g,request:_}=wv(),[y,b]=(0,v.useState)({}),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(`draft`),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(),[ne,z]=(0,v.useState)(`09:00`),B=(0,v.useRef)(`{}`),re=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(r){let e={};c?.fields.forEach(t=>{e[t.name]=t.type===`boolean`?!1:``}),e.localized={};let t=a&&a.length>0?a:[`en`];S(t),w(o??t[0]),E(!1),b(e),O(`draft`),A(``),M(!1),B.current=JSON.stringify(e);return}if(!u||!c)return;let e={};c.fields.forEach(t=>{e[t.name]=u[t.name]??(t.type===`boolean`?!1:``)});let t=u.localized,n=t&&typeof t==`object`?t:{};e.localized=n;let s=Object.keys(n).filter(e=>!e.startsWith(`_`)),l=n._meta||{},d=l.enabled??s.length>0;if(l.primary??s[0],s.length>0)S(s),w(s[0]);else{let e=a&&a.length>0?a:[`en`];S(e),w(o??e[0])}if(E(!!d),b(e),O(u.status??`draft`),B.current=JSON.stringify(e),u.scheduled_for?(A(u.scheduled_for),te(new Date(u.scheduled_for)),z(Lv(u.scheduled_for,i))):A(``),u.status===`published`&&u.published_data){let t=(e,t)=>{if(t===`datetime`&&e&&typeof e==`string`){let t=/Z|[+-]\d{2}:\d{2}$/.test(e)?e:e+`Z`,n=new Date(t);return isNaN(n.getTime())?e:n.toISOString()}return e},n={},r={};c.fields.forEach(i=>{i.name in u.published_data&&(n[i.name]=t(u.published_data[i.name]??(i.type===`boolean`?!1:``),i.type),r[i.name]=t(e[i.name],i.type))}),M(JSON.stringify(r)!==JSON.stringify(n))}else M(!1)},[u,c,r]);let V=JSON.stringify(y)!==B.current,ie=Cr((0,v.useCallback)(()=>re.current?!1:V,[V]));function ae(e,t){b(n=>({...n,[e]:t}))}function oe(e,t,n){b(r=>{let i={...r||{}};return(!i.localized||typeof i.localized!=`object`)&&(i.localized={}),i.localized[e]={...i.localized[e]||{}},i.localized[e][t]=n,i})}function se(e){E(e),b(t=>{let n={...t||{}};if((!n.localized||typeof n.localized!=`object`)&&(n.localized={}),n.localized._meta||(n.localized._meta={}),e&&o)n.localized[o]||(n.localized[o]={},c&&c.fields&&c.fields.forEach(e=>{if([`string`,`text`,`richtext`].includes(e.type)){let t=n[e.name];t!=null&&t!==``&&(n.localized[o][e.name]=t)}})),n.localized._meta.primary=o;else if(!e&&o){let e=n.localized&&n.localized[o]?n.localized[o]:null;e&&c&&c.fields&&c.fields.forEach(t=>{if([`string`,`text`,`richtext`,`uid`].includes(t.type)){let r=e[t.name];r!==void 0&&(n[t.name]=r)}})}return n.localized._meta.enabled=e,n})}function ce(){if(k)te(new Date(k)),z(Lv(k,i));else{let e=new Date;e.setDate(e.getDate()+1),te(e),z(`09:00`)}I(!0)}async function le(){if(!e||!c)return null;let n={},i=T&&y.localized&&typeof y.localized==`object`&&y.localized[o]?y.localized[o]:null;c.fields.forEach(e=>{let t=y[e.name];(t==null||t===``)&&i&&i[e.name]!==void 0&&(t=i[e.name]),e.type===`media`&&t===null?n[e.name]=null:t!==``&&t!=null&&(n[e.name]=t)}),y.localized&&Object.keys(y.localized).length>0&&(y.localized._meta||(y.localized._meta={}),y.localized._meta.enabled=T,y.localized._meta.primary=o,n.localized=y.localized);try{let i=await p(r?`/cms/admin/content-types/${e}/entries`:`/cms/admin/entries/${e}/${t}`,r?`POST`:`PUT`,n);return B.current=JSON.stringify(y),i}catch{return null}}async function ue(){let i=await le();if(i){if(D===`scheduled`){let n=r?i.id:t;try{await h(`/cms/admin/entries/${e}/${n}/status`,`PATCH`,{status:`draft`}),O(`draft`),A(``),I(!1)}catch{}}else D===`published`&&M(!0);r&&(re.current=!0,n(`/content/${e}/${i.id}`,{replace:!0}))}}async function de(){if(!e)return;let i=t;if(V||r){let e=await le();if(!e)return;i=r?e.id:t,r&&(re.current=!0)}try{await h(`/cms/admin/entries/${e}/${i}/status`,`PATCH`,{status:`published`}),O(`published`),A(``),M(!1),I(!1),r&&n(`/content/${e}/${i}`,{replace:!0})}catch{r&&i&&n(`/content/${e}/${i}`,{replace:!0})}}async function fe(){if(!e||!ee||!ne)return;let a=Rv(ee,ne,i);if(new Date(a)<=new Date)return;let o=t;if(V||r){let e=await le();if(!e)return;o=r?e.id:t,r&&(re.current=!0)}try{await h(`/cms/admin/entries/${e}/${o}/status`,`PATCH`,{status:`scheduled`,scheduled_for:a}),O(`scheduled`),A(a),I(!1),r&&n(`/content/${e}/${o}`,{replace:!0})}catch{r&&o&&n(`/content/${e}/${o}`,{replace:!0})}}async function pe(){if(!(!e||!t))try{await h(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`draft`}),O(`draft`),A(``),M(!1)}catch{}}async function me(){if(!(!e||!t))try{await _(`/cms/admin/entries/${e}/${t}`,`DELETE`),re.current=!0,n(`/content/${e}`,{replace:!0})}catch{}}let he=l||!r&&d,ge=f||m,_e=s?.permissions??[],ve=_e.includes(`*`)||_e.includes(`entries:write`),ye=_e.includes(`*`)||_e.includes(`entries:delete`),be=s?.role?.toLowerCase()===`user`&&c?.kind===`single`,xe=!ve||be,Se=V||D===`draft`||D===`scheduled`||j,Ce=!!(ee&&ne);if(UE(`mod+s`,ue,{enabled:!xe&&!ge&&(D===`scheduled`?!0:V),label:`Save draft`}),UE(`mod+shift+p`,de,{enabled:Se&&!ge&&!xe,label:`Publish`}),he)return(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,H.jsx)(Mv,{className:`size-4`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]});if(!c)return null;let we;return we=D===`scheduled`?(0,H.jsxs)(HS,{variant:`outline`,className:`border-blue-500 text-blue-600`,children:[(0,H.jsx)(Ea,{className:`size-3 mr-1`}),k?`Scheduled · ${Iv(k,i)}`:`Scheduled`]}):D===`published`?(0,H.jsx)(HS,{variant:j?`secondary`:`default`,children:j?`Published (pending changes)`:`Published`}):(0,H.jsx)(HS,{variant:`secondary`,children:`Draft`}),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:r?`New entry`:`Edit entry`}),we]}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs mt-1`,children:c.name})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!r&&ye&&!be&&(0,H.jsx)(q,{variant:`ghost`,size:`icon`,className:`text-muted-foreground hover:text-destructive`,onClick:()=>P(!0),disabled:g,children:(0,H.jsx)(jo,{className:`size-4`})}),!r&&D===`published`&&!xe&&(0,H.jsxs)(q,{variant:`outline`,onClick:pe,disabled:ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,`Revert to draft`]}),!r&&D===`scheduled`&&!xe&&(0,H.jsxs)(q,{variant:`outline`,onClick:pe,disabled:ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,`Cancel schedule`]}),(0,H.jsxs)(q,{variant:`outline`,onClick:ue,disabled:xe||(D===`scheduled`?ge:!V||ge),children:[f?(0,H.jsx)(Mv,{className:`size-4`}):null,D===`scheduled`?`Save draft (cancel schedule)`:`Save draft`]}),D!==`scheduled`&&(0,H.jsxs)(q,{variant:`outline`,onClick:ce,disabled:xe||ge,children:[(0,H.jsx)(Ea,{className:`size-4`}),`Schedule`]}),(0,H.jsxs)(q,{onClick:de,disabled:xe||!Se||ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,D===`scheduled`?`Publish now`:D===`published`&&!j?`Republish`:`Publish`]})]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[F&&!xe&&(0,H.jsxs)(`div`,{className:`mb-6 flex items-end gap-2 rounded-lg border p-4 bg-muted/30`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{children:`Date`}),(0,H.jsxs)(oM,{open:L,onOpenChange:R,children:[(0,H.jsx)(sM,{asChild:!0,children:(0,H.jsxs)(q,{variant:`outline`,className:`w-40 justify-between font-normal`,children:[ee?uk(ee,`MMM d, yyyy`):`Select date`,(0,H.jsx)(Aa,{className:`size-4 opacity-50`})]})}),(0,H.jsx)(cM,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,H.jsx)(iM,{mode:`single`,selected:ee,captionLayout:`dropdown`,defaultMonth:ee??new Date,disabled:{before:new Date},onSelect:e=>{te(e),R(!1)}})})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(Y,{children:[`Time `,(0,H.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(24h)`})]}),(0,H.jsx)(Tv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none`,value:ne,onChange:e=>z(e.target.value)})]}),(0,H.jsxs)(q,{onClick:fe,disabled:!Ce||ge,children:[m?(0,H.jsx)(Mv,{className:`size-4`}):null,`Confirm`]}),(0,H.jsx)(q,{variant:`ghost`,onClick:()=>I(!1),children:`Cancel`})]}),(0,H.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Tk,{checked:T,onCheckedChange:se,disabled:xe}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Localization`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable per-entry localization`})]})]}),(0,H.jsx)(`div`,{})]}),(0,H.jsx)(`div`,{children:T&&(0,H.jsx)(xk,{value:C,onValueChange:e=>w(e),children:(0,H.jsx)(Sk,{children:x.map(e=>(0,H.jsx)(Ck,{value:e,disabled:xe,children:e.toUpperCase()},e))})})})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-6 gap-4`,children:c.fields.map(e=>{let n=[`string`,`text`,`richtext`].includes(e.type),r=y.localized&&y.localized[C]?y.localized[C][e.name]:void 0,i=n&&T?r:y[e.name],a=e.type===`uid`&&e.targetField&&T&&[`string`,`text`,`richtext`].includes(c.fields.find(t=>t.name===e.targetField)?.type??``);return(0,H.jsx)(`div`,{className:GE[e.width??`full`],children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(Y,{htmlFor:`entry-${e.name}`,className:`capitalize`,children:[e.name.replace(/_/g,` `),e.required&&(0,H.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,H.jsx)(WZ,{field:e,value:i,onChange:t=>{n&&T?oe(C,e.name,t):ae(e.name,t)},allValues:{...y,id:t,__activeLocale:C,__localizationEnabled:T,__defaultLocale:o},disabled:!!a||xe})]})},e.name)})}),(0,H.jsx)(US,{open:N,onOpenChange:P,children:(0,H.jsxs)(qS,{className:`max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete this entry?`})}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>P(!1),children:`Cancel`}),(0,H.jsxs)(q,{variant:`destructive`,onClick:me,disabled:g,children:[g?(0,H.jsx)(Mv,{className:`size-4`}):null,`Delete`]})]})]})}),(0,H.jsx)(US,{open:ie.state===`blocked`,onOpenChange:()=>ie.reset?.(),children:(0,H.jsxs)(qS,{className:`max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Unsaved changes`})}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Leave without saving?`}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>ie.reset?.(),children:`Stay`}),(0,H.jsx)(q,{variant:`destructive`,onClick:()=>ie.proceed?.(),children:`Leave`})]})]})})]})]})}function KZ({...e}){return(0,H.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,...e})}function qZ({className:e,...t}){return(0,H.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:K(`flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5`,e),...t})}function JZ({className:e,...t}){return(0,H.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:K(`inline-flex items-center gap-1.5`,e),...t})}function YZ({asChild:e,className:t,...n}){return(0,H.jsx)(e?vl:`a`,{"data-slot":`breadcrumb-link`,className:K(`transition-colors hover:text-foreground`,t),...n})}function XZ({className:e,...t}){return(0,H.jsx)(`span`,{"data-slot":`breadcrumb-page`,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:K(`font-normal text-foreground`,e),...t})}function ZZ({children:e,className:t,...n}){return(0,H.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:K(`[&>svg]:size-3.5`,t),...n,children:e??(0,H.jsx)(Ma,{})})}function QZ(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function $Z(e){return!!e?.startsWith(`image/`)}function eQ(e){return!!e?.startsWith(`video/`)}function tQ(e){return!!e?.startsWith(`audio/`)}function nQ(e){return e===`application/pdf`}function rQ(e,t){return e.split(`?`)[0].endsWith(`.m3u8`)||t===`application/x-mpegurl`||t===`application/vnd.apple.mpegurl`}async function iQ(e){if(e.isFile)return new Promise(t=>{e.file(n=>t([{file:n,relativePath:e.fullPath.replace(/^\//,``)}]))});if(e.isDirectory){let t=e.createReader(),n=[];return await new Promise(e=>{let r=()=>{t.readEntries(async t=>{if(t.length===0){e();return}let i=await Promise.all(t.map(iQ));n.push(...i.flat()),r()})};r()}),n}return[]}function aQ({url:e}){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let n=t.current;if(!n)return;if(n.canPlayType(`application/vnd.apple.mpegurl`)){n.src=e;return}let r=null;return w(async()=>{let{default:e}=await import(`./hls-0EiSYoTw.js`);return{default:e}},[]).then(({default:t})=>{if(!t.isSupported())return;let i=new t;r=i,i.loadSource(e),i.attachMedia(n)}),()=>{r?.destroy()}},[e]),(0,H.jsx)(`video`,{ref:t,controls:!0,className:`max-h-[70vh] w-full rounded-md bg-black`})}function oQ({item:e}){let t=e.mime_type?.toLowerCase()??null;return $Z(t)?(0,H.jsx)(`img`,{src:e.url,alt:e.filename,className:`max-h-full max-w-full rounded-md object-contain`}):rQ(e.url,t)?(0,H.jsx)(aQ,{url:e.url}):eQ(t)?(0,H.jsx)(`video`,{src:e.url,controls:!0,preload:`none`,className:`max-h-[70vh] w-full rounded-md bg-black`}):tQ(t)?(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6`,children:[(0,H.jsx)(Ga,{className:`size-14 text-muted-foreground`}),(0,H.jsx)(`audio`,{src:e.url,controls:!0,className:`w-full`})]}):nQ(t)?(0,H.jsx)(`iframe`,{src:e.url,title:e.filename,className:`h-[70vh] w-full rounded-md border`}):(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8 text-center`,children:[(0,H.jsx)(qa,{className:`size-14 text-muted-foreground`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.mime_type??`Unknown type`}),(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,download:e.filename,children:(0,H.jsxs)(q,{variant:`outline`,size:`sm`,children:[(0,H.jsx)(Va,{className:`size-4`}),`Download`]})})]})}function sQ({folder:e,onOpen:t,onDelete:n,onRename:r,canDelete:i,canRename:a,selected:o,onToggle:s}){return(0,H.jsxs)(`div`,{className:`group relative flex items-center gap-3 rounded-lg border bg-card px-3 py-2.5 transition-colors cursor-pointer hover:bg-muted/50 ${o?`ring-2 ring-primary`:``}`,onClick:()=>{o||t(e)},children:[(0,H.jsxs)(`div`,{className:`relative shrink-0 size-7 flex items-center justify-center`,children:[(0,H.jsx)(Qa,{className:`size-7 text-muted-foreground transition-opacity ${o?`opacity-0`:`group-hover:opacity-0`}`}),(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center transition-opacity ${o?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(XE,{checked:o,onCheckedChange:()=>s(`folder:${e.id}`),"aria-label":`Select folder`})})]}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-bold truncate`,title:e.name,children:e.name}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]}),!o&&(a||i)&&(0,H.jsxs)(__,{children:[(0,H.jsx)(v_,{asChild:!0,children:(0,H.jsx)(`button`,{className:`shrink-0 opacity-0 group-hover:opacity-100 transition-opacity flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(Ha,{className:`size-4`})})}),(0,H.jsxs)(x_,{align:`end`,onClick:e=>e.stopPropagation(),children:[a&&(0,H.jsxs)(S_,{onSelect:()=>r(e),children:[(0,H.jsx)(_o,{className:`size-4`}),`Rename`]}),i&&(0,H.jsxs)(S_,{onSelect:()=>n(e),className:`text-destructive focus:text-destructive`,children:[(0,H.jsx)(jo,{className:`size-4`}),`Delete`]})]})]})]})}function cQ({item:e,onDelete:t,onPreview:n,canDelete:r,selected:i,onToggle:a}){let o=e.mime_type?.toLowerCase()??null;return(0,H.jsxs)(`div`,{className:`group relative rounded-lg border bg-card overflow-hidden transition-colors ${i?`ring-2 ring-primary`:``}`,children:[(0,H.jsx)(`div`,{className:`aspect-square bg-muted flex items-center justify-center cursor-pointer`,onClick:()=>{i||n(e)},children:$Z(o)?(0,H.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):eQ(o)||rQ(e.url,o)?(0,H.jsx)(Ka,{className:`size-10 text-muted-foreground`}):tQ(o)?(0,H.jsx)(Ga,{className:`size-10 text-muted-foreground`}):nQ(o)?(0,H.jsx)(qa,{className:`size-10 text-muted-foreground`}):(0,H.jsx)(Ja,{className:`size-10 text-muted-foreground`})}),(0,H.jsx)(`div`,{className:`absolute top-1.5 left-1.5 transition-opacity ${i?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,children:(0,H.jsx)(XE,{checked:i,onCheckedChange:()=>a(e.id),"aria-label":`Select file`,className:`bg-background/80 backdrop-blur-sm`})}),!i&&r&&(0,H.jsx)(`button`,{onClick:()=>t(e),className:`absolute top-1.5 right-1.5 flex size-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground opacity-0 backdrop-blur-sm transition-opacity hover:text-destructive group-hover:opacity-100`,children:(0,H.jsx)(jo,{className:`size-3.5`})}),(0,H.jsxs)(`div`,{className:`p-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium truncate`,title:e.filename,children:e.filename}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:QZ(e.size)})]})]})}function lQ(){let e=(0,v.useRef)(null),{user:t}=oa(),n=t?.permissions??[],r=n.includes(`*`)||n.includes(`media:write`),i=n.includes(`*`)||n.includes(`media:delete`),[a,o]=(0,v.useState)([{id:null,name:`Media`}]),s=a[a.length-1].id,{data:c,loading:l,refetch:u}=ma(`/cms/admin/folders?parent_id=${s??``}`),{data:d,loading:f,refetch:p}=ma(`/cms/admin/media?folder_id=${s??``}`),m=(0,v.useCallback)(()=>{u(),p()},[u,p]),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(new Set),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(null),[I,L]=(0,v.useState)(null),[R,ee]=(0,v.useState)(``),[te,ne]=(0,v.useState)(!1),[z,B]=(0,v.useState)(``),[re,V]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(!1),{loading:oe,error:se,request:ce}=wv(),{loading:le,error:ue,request:de}=wv();async function fe(e){if(e.some(({relativePath:e})=>e.endsWith(`.m3u8`))){let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=new FormData;for(let{file:t,relativePath:n}of e)r.append(`files`,t,n);s&&r.append(`folder_id`,s),r.append(`bundle`,`true`);let i=await fetch(`/cms/admin/media`,{method:`POST`,headers:n,body:r});if(!i.ok){let e=await i.text(),t=`Upload failed.`;try{t=JSON.parse(e).error??t}catch{}throw Error(t)}}else await Promise.all(e.map(({file:e})=>mX(e,{folderId:s})))}async function pe(t){if(r&&!(!t||t.length===0)){g(!0),y(null);try{await fe(Array.from(t).map(e=>({file:e,relativePath:e.webkitRelativePath||e.name}))),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1),e.current&&(e.current.value=``)}}}async function me(e){if(!r)return;e.preventDefault();let t=Array.from(e.dataTransfer.items);if(!t.some(e=>typeof e.webkitGetAsEntry==`function`)){pe(e.dataTransfer.files);return}g(!0),y(null);try{let e=t.map(e=>e.webkitGetAsEntry()).filter(e=>e!==null);await fe((await Promise.all(e.map(iQ))).flat()),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1)}}function he(e){o(t=>[...t,{id:e.id,name:e.name}]),x(new Set)}function ge(e){o(t=>t.slice(0,e+1)),x(new Set)}async function _e(){if(r&&z.trim())try{await de(`/cms/admin/folders`,`POST`,{name:z.trim(),parent_id:s}),ne(!1),B(``),u()}catch{}}async function ve(){if(r&&!(!I||!R.trim()))try{await de(`/cms/admin/folders/${I.id}`,`PATCH`,{name:R.trim()}),L(null),u()}catch{}}async function ye(){if(i&&P)try{await ce(`/cms/admin/folders/${P.id}`,`DELETE`),F(null),u()}catch{}}async function be(){if(i&&M)try{await ce(`/cms/admin/media/${M.id}`,`DELETE`),N(null),p()}catch{}}function xe(e){x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let Se=c?.folders??[],Ce=d?.items??[],we=[...Se.map(e=>`folder:${e.id}`),...Ce.map(e=>e.id)],Te=we.length>0&&we.every(e=>b.has(e)),Ee=!Te&&we.some(e=>b.has(e));async function De(){if(!i||ie)return;ae(!0);let e=localStorage.getItem(`plank_token`),t=e?{Authorization:`Bearer ${e}`}:{};try{await Promise.all([...[...b].filter(e=>e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/folders/${e.slice(7)}`,{method:`DELETE`,headers:t})),...[...b].filter(e=>!e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/media/${e}`,{method:`DELETE`,headers:t}))]),V(!1),x(new Set),m()}finally{ae(!1)}}let Oe=l||f,ke=Se.length===0&&Ce.length===0;return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Media Library`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:d?`${d.total} file${d.total===1?``:`s`}`:``})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(q,{variant:`outline`,onClick:()=>{B(``),ne(!0)},disabled:!r,children:[(0,H.jsx)(Za,{className:`size-4`}),`New folder`]}),(0,H.jsxs)(q,{onClick:()=>e.current?.click(),disabled:h||!r,children:[h?(0,H.jsx)(Mv,{className:`size-4`}):(0,H.jsx)(Fo,{className:`size-4`}),h?`Uploading…`:`Upload`]})]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[a.length>1&&(0,H.jsx)(KZ,{className:`mb-4`,children:(0,H.jsx)(qZ,{children:a.map((e,t)=>(0,H.jsxs)(v.Fragment,{children:[t>0&&(0,H.jsx)(ZZ,{}),(0,H.jsx)(JZ,{children:t===a.length-1?(0,H.jsx)(XZ,{children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name}):(0,H.jsx)(YZ,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:()=>ge(t),children:t===0?(0,H.jsx)(io,{className:`size-3.5`}):e.name})})})]},t))})}),!ke&&!Oe&&(0,H.jsxs)(`div`,{className:`mb-4 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-4 py-2.5`,children:[(0,H.jsx)(XE,{checked:Te?!0:Ee?`indeterminate`:!1,onCheckedChange:()=>{x(Te?new Set:new Set(we))},"aria-label":`Select all`}),b.size>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`text-sm font-medium`,children:[b.size,` selected`]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>x(new Set),children:`Clear`}),i&&(0,H.jsxs)(q,{variant:`destructive`,size:`sm`,disabled:ie,onClick:()=>V(!0),children:[(0,H.jsx)(jo,{className:`size-3.5`}),`Delete`]})]})]}):(0,H.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Select all`})]}),(0,H.jsx)(`input`,{ref:e,type:`file`,multiple:!0,className:`hidden`,onChange:e=>pe(e.target.files)}),_&&(0,H.jsx)(`p`,{className:`mb-4 text-sm text-destructive`,children:_}),Oe?(0,H.jsx)(`div`,{className:`flex items-center gap-2 py-16 justify-center text-muted-foreground`,children:(0,H.jsx)(Mv,{className:`size-5`})}):ke?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-lg border border-dashed py-20 text-center cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>r&&e.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:me,children:[(0,H.jsx)(Fo,{className:`size-8 text-muted-foreground mb-3`}),(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop files or folders here, or click to upload`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Images, videos, audio, documents and more`})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,onDragOver:e=>e.preventDefault(),onDrop:me,children:[Se.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,children:Se.map(e=>(0,H.jsx)(sQ,{folder:e,onOpen:he,onDelete:F,onRename:e=>{L(e),ee(e.name)},canDelete:i,canRename:r,selected:b.has(`folder:${e.id}`),onToggle:xe},e.id))}),Ce.length>0&&(0,H.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6`,children:Ce.map(e=>(0,H.jsx)(cQ,{item:e,onDelete:N,onPreview:e=>{C(e),T(e.filename),D(e.alt??``),j(null)},canDelete:i,selected:b.has(e.id),onToggle:xe},e.id))})]}),(0,H.jsx)(US,{open:!!S,onOpenChange:e=>{e||(C(null),j(null))},children:(0,H.jsxs)(qS,{className:`sm:max-w-4xl h-[80vh] flex flex-col`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{className:`truncate pr-6`,title:S?.filename,children:S?.filename})}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center overflow-hidden`,children:S&&(0,H.jsx)(oQ,{item:S})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:S?.mime_type??`—`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[S?.width&&S?.height&&(0,H.jsxs)(`span`,{children:[S.width,` × `,S.height]}),(0,H.jsx)(`span`,{children:QZ(S?.size??null)}),(0,H.jsx)(`a`,{href:S?.url,target:`_blank`,rel:`noreferrer`,download:S?.filename,children:(0,H.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,children:(0,H.jsx)(Va,{className:`size-3.5`})})})]})]}),S&&$Z(S.mime_type)&&(0,H.jsxs)(`form`,{className:`flex flex-col gap-3 border-t pt-3`,onSubmit:async e=>{e.preventDefault(),k(!0),j(null);let t=localStorage.getItem(`plank_token`);try{let e=await fetch(`/cms/admin/media/${S.id}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({filename:w||S.filename,alt:E||null})});if(!e.ok)throw Error(`Save failed.`);C(await e.json()),p()}catch(e){j(e instanceof Error?e.message:`Save failed.`)}finally{k(!1)}},children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{className:`text-xs`,children:`Filename`}),(0,H.jsx)(Tv,{value:w,onChange:e=>T(e.target.value),placeholder:S.filename,className:`h-8 text-sm`,disabled:!r})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{className:`text-xs`,children:`Alt text`}),(0,H.jsx)(Tv,{value:E,onChange:e=>D(e.target.value),placeholder:`Describe the image…`,className:`h-8 text-sm`,disabled:!r})]})]}),A&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:A}),(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(q,{type:`submit`,size:`sm`,disabled:O||!r,children:O?`Saving…`:`Save`})})]})]})}),(0,H.jsx)(US,{open:te,onOpenChange:e=>{e||ne(!1)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`New folder`})}),(0,H.jsx)(Tv,{placeholder:`Folder name`,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_e()},autoFocus:!0}),ue&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:ue}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>ne(!1),children:`Cancel`}),(0,H.jsx)(q,{onClick:_e,disabled:le||!z.trim()||!r,children:le?`Creating…`:`Create`})]})]})}),(0,H.jsx)(US,{open:!!I,onOpenChange:e=>{e||L(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Rename folder`})}),(0,H.jsx)(Tv,{value:R,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ve()},autoFocus:!0}),ue&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:ue}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>L(null),children:`Cancel`}),(0,H.jsx)(q,{onClick:ve,disabled:le||!R.trim()||!r,children:le?`Saving…`:`Save`})]})]})}),(0,H.jsx)(US,{open:!!M,onOpenChange:e=>{e||N(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete file`})}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:M?.filename}),`? This action cannot be undone.`]}),se&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:se}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>N(null),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:be,disabled:oe||!i,children:oe?`Deleting…`:`Delete`})]})]})}),(0,H.jsx)(US,{open:!!P,onOpenChange:e=>{e||F(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete folder`})}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:P?.name}),`? The folder must be empty.`]}),se&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:se}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>F(null),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:ye,disabled:oe||!i,children:oe?`Deleting…`:`Delete`})]})]})}),(0,H.jsx)(US,{open:re,onOpenChange:e=>{e||V(!1)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsxs)(XS,{children:[`Delete `,b.size,` `,b.size===1?`item`:`items`,`?`]})}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone. Non-empty folders will be skipped.`}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>V(!1),children:`Cancel`}),(0,H.jsxs)(q,{variant:`destructive`,onClick:De,disabled:ie,children:[ie?(0,H.jsx)(Mv,{className:`size-4`}):null,`Delete`]})]})]})})]})]})}function uQ({items:e}){let{pathname:t}=Xn();function n(e){return t===e||t.startsWith(e+`/`)}return(0,H.jsx)(`nav`,{className:`flex flex-col gap-0.5 p-2`,children:e.map(({label:e,to:t,icon:r})=>(0,H.jsxs)(Fi,{to:t,className:[`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,n(t)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:[r&&(0,H.jsx)(r,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e})]},t))})}function dQ(e,t){return e?.permissions.includes(`*`)||e?.permissions.includes(t)||!1}function fQ(){let{user:e}=oa(),t=[{label:`Overview`,to:`/settings/overview`,icon:Co,permission:`settings:overview:read`},{label:`Users`,to:`/settings/users`,icon:Lo,permission:`settings:users:read`},{label:`Roles`,to:`/settings/roles`,icon:wo,permission:`settings:roles:read`},{label:`API Tokens`,to:`/settings/api-tokens`,icon:so,permission:`settings:api-tokens:read`},{label:`Webhooks`,to:`/settings/webhooks`,icon:Ro,permission:`settings:webhooks:read`}].filter(({permission:t})=>dQ(e,t));return(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`div`,{className:`border-b border-sidebar-border px-4 py-3`,children:(0,H.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Settings`})}),(0,H.jsx)(uQ,{items:t})]})}function pQ(){return _C((0,H.jsx)(fQ,{})),(0,H.jsx)(Br,{})}var mQ=`••••••••`;function hQ({values:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`local-uploads-dir`,children:`Upload directory`}),(0,H.jsx)(Tv,{id:`local-uploads-dir`,placeholder:`public/uploads`,value:e[`local.uploads_dir`]??``,onChange:e=>t(`local.uploads_dir`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Path on disk where files are stored. Relative to the server working directory.`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`local-public-url`,children:`Public URL`}),(0,H.jsx)(Tv,{id:`local-public-url`,placeholder:`http://localhost:1337`,value:e[`local.public_url`]??``,onChange:e=>t(`local.public_url`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Base URL used to build file URLs. Should match the server's public address.`})]})]})}function gQ({id:e,label:t,fieldKey:n,values:r,onChange:i,placeholder:a,disabled:o=!1}){let[s,c]=(0,v.useState)(!1),l=r[n]===mQ,u=r[n]??``;return(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:e,children:t}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(Tv,{id:e,type:s?`text`:`password`,placeholder:l?`Leave blank to keep current value`:a,value:l?``:u,onChange:e=>i(n,e.target.value),className:`pr-9`,disabled:o}),(0,H.jsx)(`button`,{type:`button`,className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>c(e=>!e),tabIndex:-1,disabled:o,children:s?(0,H.jsx)(Ua,{className:`size-4`}):(0,H.jsx)(Wa,{className:`size-4`})})]}),l&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A value is already saved. Enter a new one to replace it.`})]})}function _Q({values:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-access-key`,children:`Access key ID`}),(0,H.jsx)(Tv,{id:`s3-access-key`,placeholder:`AKIAIOSFODNN7EXAMPLE`,value:e[`s3.access_key_id`]??``,onChange:e=>t(`s3.access_key_id`,e.target.value),disabled:n})]}),(0,H.jsx)(gQ,{id:`s3-secret-key`,label:`Secret access key`,fieldKey:`s3.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-region`,children:`Region`}),(0,H.jsx)(Tv,{id:`s3-region`,placeholder:`us-east-1`,value:e[`s3.region`]??``,onChange:e=>t(`s3.region`,e.target.value),disabled:n})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-bucket`,children:`Bucket`}),(0,H.jsx)(Tv,{id:`s3-bucket`,placeholder:`my-bucket`,value:e[`s3.bucket`]??``,onChange:e=>t(`s3.bucket`,e.target.value),disabled:n})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-path-prefix`,children:`Path prefix`}),(0,H.jsx)(Tv,{id:`s3-path-prefix`,placeholder:`cms/media`,value:e[`s3.path_prefix`]??``,onChange:e=>t(`s3.path_prefix`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`s3-public-url`,children:`Public URL`}),(0,H.jsx)(Tv,{id:`s3-public-url`,placeholder:`https://cdn.example.com`,value:e[`s3.public_url`]??``,onChange:e=>t(`s3.public_url`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Leave blank to use the default S3 URL.`})]})]})}function vQ({values:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-access-key`,children:`Access key ID`}),(0,H.jsx)(Tv,{id:`r2-access-key`,placeholder:`R2 access key ID`,value:e[`r2.access_key_id`]??``,onChange:e=>t(`r2.access_key_id`,e.target.value),disabled:n})]}),(0,H.jsx)(gQ,{id:`r2-secret-key`,label:`Secret access key`,fieldKey:`r2.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-bucket`,children:`Bucket`}),(0,H.jsx)(Tv,{id:`r2-bucket`,placeholder:`my-bucket`,value:e[`r2.bucket`]??``,onChange:e=>t(`r2.bucket`,e.target.value),disabled:n})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-path-prefix`,children:`Path prefix`}),(0,H.jsx)(Tv,{id:`r2-path-prefix`,placeholder:`cms/media`,value:e[`r2.path_prefix`]??``,onChange:e=>t(`r2.path_prefix`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(Y,{htmlFor:`r2-public-url`,children:[`Public URL `,(0,H.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,H.jsx)(Tv,{id:`r2-public-url`,placeholder:`https://assets.example.com`,value:e[`r2.public_url`]??``,onChange:e=>t(`r2.public_url`,e.target.value),disabled:n}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Required. R2 does not generate public URLs automatically.`})]})]})}function yQ(){let{user:e}=oa(),{data:t,loading:n}=ma(`/cms/admin/settings/media`),{loading:r,error:i,request:a}=wv(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),u=o??t??{provider:`local`},d=u.provider||`local`,f=e?.permissions??[],p=f.includes(`*`)||f.includes(`settings:overview:write`);function m(e,t){s({...u,[e]:t})}function h(e){s({...u,provider:e})}async function g(e){e.preventDefault();try{await a(`/cms/admin/settings/media`,`PUT`,u),l(!0),setTimeout(()=>l(!1),2500)}catch{}}return n?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-8 text-muted-foreground`,children:[(0,H.jsx)(Mv,{className:`size-4`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Loading settings…`})]}):(0,H.jsxs)(`form`,{onSubmit:g,className:`space-y-8`,children:[(0,H.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Storage`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure where uploaded files are stored.`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`provider`,children:`Storage provider`}),(0,H.jsxs)(QS,{value:d,onValueChange:e=>h(e),children:[(0,H.jsx)(tC,{id:`provider`,disabled:!p,children:(0,H.jsx)(eC,{})}),(0,H.jsxs)(iC,{children:[(0,H.jsx)(oC,{value:`local`,children:`Local`}),(0,H.jsx)(oC,{value:`s3`,children:`Amazon S3`}),(0,H.jsx)(oC,{value:`r2`,children:`Cloudflare R2`})]})]})]}),d===`r2`&&(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`r2-account-id`,children:`Account ID`}),(0,H.jsx)(Tv,{id:`r2-account-id`,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:u[`r2.account_id`]??``,onChange:e=>m(`r2.account_id`,e.target.value),disabled:!p}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Found in the Cloudflare dashboard under R2 > Overview.`})]})]}),(0,H.jsxs)(`div`,{className:`border-t pt-6`,children:[d===`local`&&(0,H.jsx)(hQ,{values:u,onChange:m,disabled:!p}),d===`s3`&&(0,H.jsx)(_Q,{values:u,onChange:m,disabled:!p}),d===`r2`&&(0,H.jsx)(vQ,{values:u,onChange:m,disabled:!p})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(q,{type:`submit`,disabled:r||!p,children:r?`Saving…`:`Save`}),c&&(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Changes saved.`}),i&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:i})]})]})}function bQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card`,className:K(`flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm`,e),...t})}function xQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-header`,className:K(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function SQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-title`,className:K(`leading-none font-semibold`,e),...t})}function CQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-action`,className:K(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function wQ({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`card-content`,className:K(`px-6`,e),...t})}var TQ={name:`@plank-cms/admin`,version:`0.12.1`,type:`module`,scripts:{build:`vite build`,dev:`vite`,lint:`eslint src/`},dependencies:{"@dnd-kit/core":`6.3.1`,"@dnd-kit/sortable":`10.0.0`,"@dnd-kit/utilities":`3.2.2`,"@radix-ui/react-avatar":`1.1.11`,"@radix-ui/react-checkbox":`1.3.3`,"@radix-ui/react-dialog":`1.1.15`,"@radix-ui/react-dropdown-menu":`2.1.16`,"@radix-ui/react-label":`2.1.8`,"@radix-ui/react-popover":`1.1.15`,"@radix-ui/react-select":`2.2.6`,"@radix-ui/react-separator":`1.1.8`,"@radix-ui/react-slot":`1.2.4`,"@radix-ui/react-switch":`1.2.6`,"@radix-ui/react-tabs":`1.1.13`,"@radix-ui/react-tooltip":`1.2.8`,"@tanstack/react-table":`8.21.3`,"@tiptap/extension-image":`3.22.4`,"@tiptap/pm":`3.22.4`,"@tiptap/react":`3.22.4`,"@tiptap/starter-kit":`3.22.4`,"class-variance-authority":`0.7.1`,clsx:`2.1.1`,cmdk:`1.1.1`,"date-fns":`4.1.0`,"hls.js":`1.6.16`,"lucide-react":`1.8.0`,"radix-ui":`1.4.3`,react:`19.2.5`,"react-day-picker":`9.14.0`,"react-dom":`19.2.5`,"react-router-dom":`7.14.1`,"tailwind-merge":`3.5.0`},devDependencies:{"@tailwindcss/vite":`4.2.3`,"@types/react":`19.2.14`,"@types/react-dom":`19.2.3`,"@types/react-router-dom":`5.3.3`,"@vitejs/plugin-react":`6.0.1`,tailwindcss:`4.2.3`,vite:`8.0.9`}},EQ=[{value:`UTC`,label:`UTC — Coordinated Universal Time`},{value:`America/New_York`,label:`America/New_York — Eastern Time (UTC-5/4)`},{value:`America/Chicago`,label:`America/Chicago — Central Time (UTC-6/5)`},{value:`America/Denver`,label:`America/Denver — Mountain Time (UTC-7/6)`},{value:`America/Los_Angeles`,label:`America/Los_Angeles — Pacific Time (UTC-8/7)`},{value:`America/Anchorage`,label:`America/Anchorage — Alaska Time (UTC-9/8)`},{value:`America/Honolulu`,label:`America/Honolulu — Hawaii Time (UTC-10)`},{value:`America/Mexico_City`,label:`America/Mexico_City — Mexico City (UTC-6/5)`},{value:`America/El_Salvador`,label:`America/El_Salvador — El Salvador (UTC-6)`},{value:`America/Bogota`,label:`America/Bogota — Colombia Time (UTC-5)`},{value:`America/Lima`,label:`America/Lima — Peru Time (UTC-5)`},{value:`America/Santiago`,label:`America/Santiago — Chile Time (UTC-4/3)`},{value:`America/Argentina/Buenos_Aires`,label:`America/Buenos_Aires — Argentina (UTC-3)`},{value:`America/Sao_Paulo`,label:`America/Sao_Paulo — Brasília Time (UTC-3/2)`},{value:`Atlantic/Reykjavik`,label:`Atlantic/Reykjavik — Iceland (UTC+0)`},{value:`Europe/London`,label:`Europe/London — GMT/BST (UTC+0/1)`},{value:`Europe/Paris`,label:`Europe/Paris — Central European Time (UTC+1/2)`},{value:`Europe/Berlin`,label:`Europe/Berlin — Central European Time (UTC+1/2)`},{value:`Europe/Madrid`,label:`Europe/Madrid — Central European Time (UTC+1/2)`},{value:`Europe/Rome`,label:`Europe/Rome — Central European Time (UTC+1/2)`},{value:`Europe/Helsinki`,label:`Europe/Helsinki — Eastern European Time (UTC+2/3)`},{value:`Europe/Istanbul`,label:`Europe/Istanbul — Turkey Time (UTC+3)`},{value:`Europe/Moscow`,label:`Europe/Moscow — Moscow Standard Time (UTC+3)`},{value:`Asia/Dubai`,label:`Asia/Dubai — Gulf Standard Time (UTC+4)`},{value:`Asia/Karachi`,label:`Asia/Karachi — Pakistan Standard Time (UTC+5)`},{value:`Asia/Kolkata`,label:`Asia/Kolkata — India Standard Time (UTC+5:30)`},{value:`Asia/Dhaka`,label:`Asia/Dhaka — Bangladesh Standard Time (UTC+6)`},{value:`Asia/Bangkok`,label:`Asia/Bangkok — Indochina Time (UTC+7)`},{value:`Asia/Singapore`,label:`Asia/Singapore — Singapore Time (UTC+8)`},{value:`Asia/Shanghai`,label:`Asia/Shanghai — China Standard Time (UTC+8)`},{value:`Asia/Tokyo`,label:`Asia/Tokyo — Japan Standard Time (UTC+9)`},{value:`Asia/Seoul`,label:`Asia/Seoul — Korea Standard Time (UTC+9)`},{value:`Australia/Sydney`,label:`Australia/Sydney — AEST/AEDT (UTC+10/11)`},{value:`Australia/Melbourne`,label:`Australia/Melbourne — AEST/AEDT (UTC+10/11)`},{value:`Pacific/Auckland`,label:`Pacific/Auckland — New Zealand (UTC+12/13)`}];function DQ(){let{user:e}=oa(),{data:t,loading:n}=ma(`/cms/admin/settings/general`),{request:r,loading:i}=wv(),{refreshSettings:a}=la(),[o,s]=(0,v.useState)(`UTC`),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(`en`),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),g=e?.permissions??[],_=g.includes(`*`)||g.includes(`settings:overview:write`);(0,v.useEffect)(()=>{if(t?.timezone&&s(t.timezone),t?.locales)try{let e=JSON.parse(t.locales);Array.isArray(e)&&l(e)}catch{l((t.locales||``).split(`,`).map(e=>e.trim()).filter(Boolean))}t?.default_locale&&d(t.default_locale)},[t]);async function y(){let e={timezone:o};c.length&&(e.locales=JSON.stringify(c)),u&&(e.default_locale=u),await r(`/cms/admin/settings/general`,`PUT`,e),a(),h(!0),setTimeout(()=>h(!1),2e3)}return n?(0,H.jsx)(Mv,{}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(bQ,{children:(0,H.jsxs)(wQ,{className:`flex items-center gap-4 py-2`,children:[(0,H.jsx)(`img`,{src:`/admin/plank-logo-w.svg`,alt:`Plank CMS`,className:`h-10 w-auto`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-bold`,children:`Plank CMS by AM25`}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,TQ.version]})]})]})}),(0,H.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Commons`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`General settings that apply across the CMS.`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`timezone`,children:`Timezone`}),(0,H.jsxs)(QS,{value:o,onValueChange:s,children:[(0,H.jsx)(tC,{id:`timezone`,className:`w-1/2`,disabled:!_,children:(0,H.jsx)(eC,{})}),(0,H.jsx)(iC,{className:`max-h-72`,children:EQ.map(e=>(0,H.jsx)(oC,{value:e.value,children:e.label},e.value))})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Used to display dates and times across the admin panel.`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{children:`Locales`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Tv,{placeholder:`E.g. "en"`,value:f,onChange:e=>p(e.target.value),className:`w-1/4`,disabled:!_}),(0,H.jsx)(q,{variant:`outline`,disabled:!_,onClick:()=>{let e=f.trim().toLowerCase();e&&(c.includes(e)||l(t=>[...t,e]),p(``))},children:`Add`})]}),(0,H.jsx)(`div`,{className:`flex gap-2 mt-2`,children:c.map(e=>(0,H.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>l(t=>t.filter(t=>t!==e)),disabled:!_,children:e.toUpperCase()},e))}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(Y,{htmlFor:`default-locale`,children:`Default locale`}),(0,H.jsxs)(QS,{value:u,onValueChange:d,children:[(0,H.jsx)(tC,{id:`default-locale`,className:`w-1/2`,disabled:!_,children:(0,H.jsx)(eC,{})}),(0,H.jsx)(iC,{className:`max-h-72`,children:c.length===0?(0,H.jsx)(oC,{value:u,children:u}):c.map(e=>(0,H.jsx)(oC,{value:e,children:e.toUpperCase()},e))})]})]})]}),(0,H.jsx)(q,{onClick:y,disabled:i||!_,children:m?`Saved`:i?`Saving…`:`Save`})]})}function OQ(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(jv,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Overview`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`General configuration for your CMS instance.`})]}),(0,H.jsxs)(xk,{defaultValue:`general`,className:`mt-24`,children:[(0,H.jsxs)(Sk,{className:`mb-6`,children:[(0,H.jsx)(Ck,{value:`general`,children:`General`}),(0,H.jsx)(Ck,{value:`media`,children:`Media Library`})]}),(0,H.jsx)(wk,{value:`general`,children:(0,H.jsx)(DQ,{})}),(0,H.jsx)(wk,{value:`media`,children:(0,H.jsx)(yQ,{})})]})]})}function kQ(e,t){return typeof e==`function`?e(t):e}function AQ(e,t){return n=>{t.setState(t=>({...t,[e]:kQ(n,t[e])}))}}function jQ(e){return e instanceof Function}function MQ(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function NQ(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function PQ(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
201
201
|
font-size: .6rem;
|
|
202
202
|
font-weight: bold;
|
|
203
203
|
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function FQ(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function IQ(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:PQ(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),FQ(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function LQ(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:PQ(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],FQ(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:PQ(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},FQ(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var RQ=`debugHeaders`;function zQ(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var BQ={createTable:e=>{e.getHeaderGroups=PQ(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return VQ(t,[...a,...s,...o],e)},FQ(e.options,RQ,`getHeaderGroups`)),e.getCenterHeaderGroups=PQ(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),VQ(t,n,e,`center`)),FQ(e.options,RQ,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=PQ(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>VQ(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),FQ(e.options,RQ,`getLeftHeaderGroups`)),e.getRightHeaderGroups=PQ(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>VQ(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),FQ(e.options,RQ,`getRightHeaderGroups`)),e.getFooterGroups=PQ(()=>[e.getHeaderGroups()],e=>[...e].reverse(),FQ(e.options,RQ,`getFooterGroups`)),e.getLeftFooterGroups=PQ(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),FQ(e.options,RQ,`getLeftFooterGroups`)),e.getCenterFooterGroups=PQ(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),FQ(e.options,RQ,`getCenterFooterGroups`)),e.getRightFooterGroups=PQ(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),FQ(e.options,RQ,`getRightFooterGroups`)),e.getFlatHeaders=PQ(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),FQ(e.options,RQ,`getFlatHeaders`)),e.getLeftFlatHeaders=PQ(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),FQ(e.options,RQ,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=PQ(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),FQ(e.options,RQ,`getCenterFlatHeaders`)),e.getRightFlatHeaders=PQ(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),FQ(e.options,RQ,`getRightFlatHeaders`)),e.getCenterLeafHeaders=PQ(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),FQ(e.options,RQ,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=PQ(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),FQ(e.options,RQ,`getLeftLeafHeaders`)),e.getRightLeafHeaders=PQ(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),FQ(e.options,RQ,`getRightLeafHeaders`)),e.getLeafHeaders=PQ(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),FQ(e.options,RQ,`getLeafHeaders`))}};function VQ(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=zQ(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>zQ(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var HQ=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>NQ(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:PQ(()=>[e.getAllLeafColumns()],t=>t.map(t=>IQ(e,s,t,t.id)),FQ(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:PQ(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),FQ(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},UQ={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},WQ=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};WQ.autoRemove=e=>e$(e);var GQ=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};GQ.autoRemove=e=>e$(e);var KQ=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};KQ.autoRemove=e=>e$(e);var qQ=(e,t,n)=>e.getValue(t)?.includes(n);qQ.autoRemove=e=>e$(e);var JQ=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});JQ.autoRemove=e=>e$(e)||!(e!=null&&e.length);var YQ=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));YQ.autoRemove=e=>e$(e)||!(e!=null&&e.length);var XQ=(e,t,n)=>e.getValue(t)===n;XQ.autoRemove=e=>e$(e);var ZQ=(e,t,n)=>e.getValue(t)==n;ZQ.autoRemove=e=>e$(e);var QQ=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};QQ.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},QQ.autoRemove=e=>e$(e)||e$(e[0])&&e$(e[1]);var $Q={includesString:WQ,includesStringSensitive:GQ,equalsString:KQ,arrIncludes:qQ,arrIncludesAll:JQ,arrIncludesSome:YQ,equals:XQ,weakEquals:ZQ,inNumberRange:QQ};function e$(e){return e==null||e===``}var t$={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:AQ(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?$Q.includesString:typeof n==`number`?$Q.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?$Q.equals:Array.isArray(n)?$Q.arrIncludes:$Q.weakEquals},e.getFilterFn=()=>jQ(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??$Q[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=kQ(n,i?i.value:void 0);if(n$(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>kQ(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&n$(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function n$(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var r$={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!MQ(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},i$={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:AQ(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return r$.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return r$.extent},e.getAggregationFn=()=>{if(!e)throw Error();return jQ(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??r$[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function a$(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var o$={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:AQ(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=PQ(e=>[_$(t,e)],t=>t.findIndex(t=>t.id===e.id),FQ(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>_$(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=_$(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=PQ(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return a$(i,t,n)},FQ(e.options,`debugTable`,`_getOrderColumnsFn`))}},s$=()=>({left:[],right:[]}),c$={getInitialState:e=>({columnPinning:s$(),...e}),getDefaultOptions:e=>({onColumnPinningChange:AQ(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=PQ(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},FQ(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=PQ(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),FQ(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=PQ(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),FQ(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?s$():e.initialState?.columnPinning??s$()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=PQ(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),FQ(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=PQ(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),FQ(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=PQ(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},FQ(e.options,`debugColumns`,`getCenterLeafColumns`))}};function l$(e){return e||(typeof document<`u`?document:null)}var u$={size:150,minSize:20,maxSize:2**53-1},d$=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),f$={getDefaultColumnDef:()=>u$,getInitialState:e=>({columnSizing:{},columnSizingInfo:d$(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:AQ(`columnSizing`,e),onColumnSizingInfoChange:AQ(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??u$.minSize,n??e.columnDef.size??u$.size),e.columnDef.maxSize??u$.maxSize)},e.getStart=PQ(e=>[e,_$(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),FQ(t.options,`debugColumns`,`getStart`)),e.getAfter=PQ(e=>[e,_$(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),FQ(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),h$(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=h$(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=l$(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=m$()?{passive:!1}:!1;h$(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?d$():e.initialState.columnSizingInfo??d$())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},p$=null;function m$(){if(typeof p$==`boolean`)return p$;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return p$=e,p$}function h$(e){return e.type===`touchstart`}var g$={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:AQ(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=PQ(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),FQ(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=PQ(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],FQ(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>PQ(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),FQ(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function _$(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var v$={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},y$={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:AQ(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>$Q.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return jQ(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??$Q[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},b$={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:AQ(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0?!0:!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},x$=0,S$=10,C$=()=>({pageIndex:x$,pageSize:S$}),w$={getInitialState:e=>({...e,pagination:{...C$(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:AQ(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>kQ(t,e)),e.resetPagination=t=>{e.setPagination(t?C$():e.initialState.pagination??C$())},e.setPageIndex=t=>{e.setPagination(n=>{let r=kQ(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?x$:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??x$)},e.resetPageSize=t=>{var n;e.setPageSize(t?S$:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??S$)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,kQ(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=kQ(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=PQ(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},FQ(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1?!0:n===0?!1:t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},T$=()=>({top:[],bottom:[]}),E$={getInitialState:e=>({rowPinning:T$(),...e}),getDefaultOptions:e=>({onRowPinningChange:AQ(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?T$():e.initialState?.rowPinning??T$()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=PQ(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),FQ(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=PQ(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),FQ(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=PQ(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},FQ(e.options,`debugRows`,`getCenterRows`))}},D$={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:AQ(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{O$(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=PQ(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?k$(e,n):{rows:[],flatRows:[],rowsById:{}},FQ(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=PQ(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?k$(e,n):{rows:[],flatRows:[],rowsById:{}},FQ(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=PQ(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?k$(e,n):{rows:[],flatRows:[],rowsById:{}},FQ(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return O$(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return A$(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return j$(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return j$(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},O$=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>O$(e,t.id,n,r,i))};function k$(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=A$(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function A$(e,t){return t[e.id]??!1}function j$(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(A$(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=j$(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var M$=/([0-9]+)/gm,N$=(e,t,n)=>V$(B$(e.getValue(n)).toLowerCase(),B$(t.getValue(n)).toLowerCase()),P$=(e,t,n)=>V$(B$(e.getValue(n)),B$(t.getValue(n))),F$=(e,t,n)=>z$(B$(e.getValue(n)).toLowerCase(),B$(t.getValue(n)).toLowerCase()),I$=(e,t,n)=>z$(B$(e.getValue(n)),B$(t.getValue(n))),L$=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},R$=(e,t,n)=>z$(e.getValue(n),t.getValue(n));function z$(e,t){return e===t?0:e>t?1:-1}function B$(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function V$(e,t){let n=e.split(M$).filter(Boolean),r=t.split(M$).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var H$={alphanumeric:N$,alphanumericCaseSensitive:P$,text:F$,textCaseSensitive:I$,datetime:L$,basic:R$},U$=[BQ,g$,o$,c$,UQ,t$,v$,y$,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:AQ(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return H$.datetime;if(typeof n==`string`&&(r=!0,n.split(M$).length>1))return H$.alphanumeric}return r?H$.text:H$.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return jQ(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??H$[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},i$,b$,w$,E$,D$,f$];function W$(e){let t=[...U$,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{n.options=i(kQ(e,n.options))},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:PQ(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),FQ(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:PQ(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=LQ(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},FQ(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:PQ(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),FQ(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:PQ(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),FQ(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:PQ(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),FQ(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function G$(){return e=>PQ(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=HQ(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},FQ(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function K$(e,t){return e?q$(e)?v.createElement(e,t):e:null}function q$(e){return J$(e)||typeof e==`function`||Y$(e)}function J$(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Y$(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function X$(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=v.useState(()=>({current:W$(t)})),[r,i]=v.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}var Z$={"super admin":`default`,admin:`secondary`,user:`outline`};function Q$({roleId:e,roleName:t,roles:n}){let r=n.find(t=>t.id===e),i=t??r?.name??e;return(0,H.jsx)(HS,{variant:Z$[i.toLowerCase()]??`secondary`,children:i})}function $$({user:e,currentUserId:t,currentUserRole:n,onEdit:r,onDelete:i}){let a=e.id===t,o=(e.role_name??``).toLowerCase()===`super admin`,s=n.toLowerCase()===`super admin`;return(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,H.jsx)(q,{size:`icon`,variant:`ghost`,className:`flex size-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,disabled:o&&!a&&!s,onClick:()=>r(e),children:(0,H.jsx)(_o,{className:`size-3.5`})}),(0,H.jsx)(q,{size:`icon`,variant:`ghost`,className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,disabled:a||o,onClick:()=>i(e),children:(0,H.jsx)(jo,{className:`size-3.5`})})]})}var e1={email:``,password:``,roleId:``};function t1(){let{user:e,updateUser:t}=oa(),{data:n,loading:r,refetch:i}=ma(`/cms/admin/users`),{data:a,loading:o}=ma(`/cms/admin/roles`),s=r||o,{request:c,loading:l,error:u}=wv(),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(e1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)({email:``,roleId:``,firstName:``,lastName:``}),[b,x]=(0,v.useState)(null),S=a??[],C=e?.role?.toLowerCase()===`super admin`?S:S.filter(e=>e.name.toLowerCase()!==`super admin`),w=(0,v.useMemo)(()=>[{id:`name`,header:`Name`,cell:({row:e})=>{let{first_name:t,last_name:n}=e.original;return!t&&!n?(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,H.jsx)(`span`,{className:`font-bold`,children:[t,n].filter(Boolean).join(` `)})}},{accessorKey:`email`,header:`Email`},{accessorKey:`role_id`,header:`Role`,cell:({row:e,getValue:t})=>(0,H.jsx)(Q$,{roleId:t(),roleName:e.original.role_name,roles:S})},{id:`actions`,header:``,cell:({row:t})=>(0,H.jsx)($$,{user:t.original,currentUserId:e?.id??``,currentUserRole:e?.role??``,onEdit:e=>{g(e),y({email:e.email,roleId:e.role_id,firstName:e.first_name??``,lastName:e.last_name??``})},onDelete:x})}],[S,e?.id,e?.role]),T=X$({data:(0,v.useMemo)(()=>[...n??[]].sort((e,t)=>{let n=[e.first_name,e.last_name].filter(Boolean).join(` `)||e.email,r=[t.first_name,t.last_name].filter(Boolean).join(` `)||t.email;return n.localeCompare(r)}),[n]),columns:w,getCoreRowModel:G$()});async function E(e){e.preventDefault();try{await c(`/cms/admin/users`,`POST`,p),f(!1),m(e1),i()}catch{}}async function D(n){n.preventDefault();try{await c(`/cms/admin/users/${h.id}`,`PUT`,_),h.id===e?.id&&t({email:_.email,firstName:_.firstName||null,lastName:_.lastName||null}),g(null),i()}catch{}}async function O(){try{await c(`/cms/admin/users/${b.id}`,`DELETE`),x(null),i()}catch{}}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Users`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage who has access to the admin panel.`})]}),(0,H.jsxs)(q,{onClick:()=>f(!0),children:[(0,H.jsx)(vo,{className:`size-4`}),`New user`]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[(0,H.jsx)(`div`,{className:`rounded-md border`,children:(0,H.jsxs)(cC,{children:[(0,H.jsx)(lC,{className:`font-bold uppercase`,children:T.getHeaderGroups().map(e=>(0,H.jsx)(dC,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,H.jsx)(fC,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:K$(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,H.jsx)(uC,{children:s?(0,H.jsx)(dC,{children:(0,H.jsx)(pC,{colSpan:w.length,className:`h-24`,children:(0,H.jsx)(Mv,{className:`mx-auto size-5`})})}):T.getRowModel().rows.length===0?(0,H.jsx)(dC,{children:(0,H.jsx)(pC,{colSpan:w.length,className:`h-24 text-center text-muted-foreground`,children:`No users found.`})}):T.getRowModel().rows.map(e=>(0,H.jsx)(dC,{children:e.getVisibleCells().map(e=>(0,H.jsx)(pC,{className:`px-4 py-3`,children:K$(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,H.jsx)(US,{open:d,onOpenChange:f,children:(0,H.jsxs)(qS,{className:`sm:max-w-md`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`New user`})}),(0,H.jsxs)(`form`,{id:`create-user-form`,onSubmit:E,className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`c-email`,children:`Email`}),(0,H.jsx)(Tv,{id:`c-email`,type:`email`,placeholder:`user@example.com`,value:p.email,onChange:e=>m(t=>({...t,email:e.target.value})),required:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`c-password`,children:`Password`}),(0,H.jsx)(Tv,{id:`c-password`,type:`password`,placeholder:`Min. 8 characters`,value:p.password,onChange:e=>m(t=>({...t,password:e.target.value})),required:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`c-role`,children:`Role`}),(0,H.jsxs)(QS,{value:p.roleId,onValueChange:e=>m(t=>({...t,roleId:e})),children:[(0,H.jsx)(tC,{id:`c-role`,children:(0,H.jsx)(eC,{placeholder:`Select a role`})}),(0,H.jsx)(iC,{children:C.map(e=>(0,H.jsx)(oC,{value:e.id,children:e.name.charAt(0).toUpperCase()+e.name.slice(1)},e.id))})]})]}),u&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:u})]}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,type:`button`,onClick:()=>f(!1),children:`Cancel`}),(0,H.jsx)(q,{type:`submit`,form:`create-user-form`,disabled:l,children:l?`Creating…`:`Create user`})]})]})}),(0,H.jsx)(US,{open:!!h,onOpenChange:e=>{e||g(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-md`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Edit user`})}),(0,H.jsxs)(`form`,{id:`edit-user-form`,onSubmit:D,className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`e-email`,children:`Email`}),(0,H.jsx)(Tv,{id:`e-email`,type:`email`,value:_.email,onChange:e=>y(t=>({...t,email:e.target.value})),required:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`e-fname`,children:`First name`}),(0,H.jsx)(Tv,{id:`e-fname`,value:_.firstName,onChange:e=>y(t=>({...t,firstName:e.target.value}))})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`e-lname`,children:`Last name`}),(0,H.jsx)(Tv,{id:`e-lname`,value:_.lastName,onChange:e=>y(t=>({...t,lastName:e.target.value}))})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`e-role`,children:`Role`}),(0,H.jsxs)(QS,{value:_.roleId,onValueChange:e=>y(t=>({...t,roleId:e})),children:[(0,H.jsx)(tC,{id:`e-role`,children:(0,H.jsx)(eC,{placeholder:`Select a role`})}),(0,H.jsx)(iC,{children:C.map(e=>(0,H.jsx)(oC,{value:e.id,children:e.name.charAt(0).toUpperCase()+e.name.slice(1)},e.id))})]})]}),u&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:u})]}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,type:`button`,onClick:()=>g(null),children:`Cancel`}),(0,H.jsx)(q,{type:`submit`,form:`edit-user-form`,disabled:l,children:l?`Saving…`:`Save changes`})]})]})}),(0,H.jsx)(US,{open:!!b,onOpenChange:e=>{e||x(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete user`})}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:b?.email}),`? This action cannot be undone.`]}),u&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:u}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>x(null),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:O,disabled:l,children:l?`Deleting…`:`Delete`})]})]})})]})]})}var n1=[{key:`content-types`,label:`Content Types`,actions:[`read`,`write`,`delete`]},{key:`entries`,label:`Entries`,actions:[`read`,`write`,`delete`]},{key:`media`,label:`Media`,actions:[`read`,`write`,`delete`]},{key:`settings:overview`,label:`Settings / Overview`,actions:[`read`,`write`]},{key:`settings:users`,label:`Settings / Users`,actions:[`read`,`write`,`delete`]},{key:`settings:roles`,label:`Settings / Roles`,actions:[`read`,`write`]},{key:`settings:api-tokens`,label:`Settings / API Tokens`,actions:[`read`,`write`,`delete`]},{key:`settings:webhooks`,label:`Settings / Webhooks`,actions:[`read`,`write`,`delete`]}],r1=[{key:`read`,label:`R`},{key:`write`,label:`W`},{key:`delete`,label:`D`}];function i1(e){return Object.fromEntries(e.map(e=>[e.id,new Set(e.permissions)]))}function a1(e,t){return e.includes(t)}function o1(){let{user:e}=oa(),{data:t,loading:n,refetch:r}=ma(`/cms/admin/roles`),{request:i,loading:a}=wv(),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(new Set),[u,d]=(0,v.useState)(!1);(0,v.useEffect)(()=>{t&&s(i1(t))},[t]);function f(e,t){s(n=>{let r=new Set(n[e]);return r.has(t)?r.delete(t):r.add(t),{...n,[e]:r}}),l(t=>new Set(t).add(e))}async function p(e){await i(`/cms/admin/roles/${e.id}`,`PUT`,{permissions:Array.from(o[e.id]??[])}),l(t=>{let n=new Set(t);return n.delete(e.id),n})}async function m(){await i(`/cms/admin/roles/reset`,`POST`),d(!1),l(new Set),r()}let h=e?.role===`Super Admin`,g=(t??[]).filter(e=>e.name!==`Super Admin`),_=(t??[]).find(e=>e.name===`Super Admin`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Roles`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Configure what each role can do across the CMS.`})]}),h&&(0,H.jsxs)(q,{variant:`outline`,onClick:()=>d(!0),children:[(0,H.jsx)(bo,{className:`size-4`}),`Reset defaults`]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[(0,H.jsx)(`div`,{className:`rounded-md border`,children:(0,H.jsxs)(cC,{children:[(0,H.jsxs)(lC,{children:[(0,H.jsxs)(dC,{className:`hover:bg-transparent`,children:[(0,H.jsx)(fC,{className:`w-40`,rowSpan:2}),_&&(0,H.jsx)(fC,{colSpan:3,className:`border-l text-center`,children:_.name}),g.map(e=>(0,H.jsx)(fC,{colSpan:3,className:`border-l`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{children:e.name}),(0,H.jsxs)(q,{size:`sm`,variant:c.has(e.id)?`default`:`ghost`,className:`h-6 px-2 text-xs`,disabled:!c.has(e.id)||a,onClick:()=>p(e),children:[(0,H.jsx)(xo,{className:`size-3`}),`Save`]})]})},e.id))]}),(0,H.jsxs)(dC,{className:`hover:bg-transparent`,children:[_&&r1.map((e,t)=>(0,H.jsx)(fC,{className:`w-12 text-center font-normal ${t===0?`border-l`:``}`,children:e.label},e.key)),g.map(e=>r1.map((t,n)=>(0,H.jsx)(fC,{className:`w-12 text-center font-normal ${n===0?`border-l`:``}`,children:t.label},`${e.id}-${t.key}`)))]})]}),(0,H.jsx)(uC,{children:n?(0,H.jsx)(dC,{children:(0,H.jsx)(pC,{colSpan:99,className:`h-24`,children:(0,H.jsx)(Mv,{className:`mx-auto size-5`})})}):n1.map(({key:e,label:t,actions:n})=>(0,H.jsxs)(dC,{children:[(0,H.jsx)(pC,{className:`font-medium`,children:t}),_&&r1.map((e,t)=>(0,H.jsx)(pC,{className:`text-center ${t===0?`border-l`:``}`,children:a1(n,e.key)?(0,H.jsx)(XE,{checked:!0,disabled:!0}):(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})},e.key)),g.map(t=>r1.map((r,i)=>{let a=a1(n,r.key),s=`${e}:${r.key}`;return(0,H.jsx)(pC,{className:`text-center ${i===0?`border-l`:``}`,children:a?(0,H.jsx)(XE,{checked:o[t.id]?.has(s)??!1,onCheckedChange:()=>f(t.id,s)}):(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})},`${t.id}-${r.key}`)}))]},e))})]})}),(0,H.jsx)(US,{open:u,onOpenChange:d,children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Reset to defaults`})}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This will restore all role permissions to their original configuration. Any custom changes will be lost.`}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>d(!1),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:m,disabled:a,children:a?`Resetting…`:`Reset`})]})]})})]})]})}var s1={"full-access":`default`,"read-only":`secondary`},c1={"full-access":`Full access`,"read-only":`Read only`};function l1({value:e}){let[t,n]=(0,v.useState)(!1);function r(){navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}return(0,H.jsx)(q,{type:`button`,size:`icon`,variant:`outline`,className:`shrink-0`,onClick:r,children:t?(0,H.jsx)(ka,{className:`size-4 text-green-500`}):(0,H.jsx)(Ba,{className:`size-4`})})}var u1={name:``,accessType:``};function d1(){let{user:e}=oa(),{data:t,loading:n,refetch:r}=ma(`/cms/admin/api-tokens`),{request:i,loading:a,error:o}=wv(),s=e?.permissions??[],c=s.includes(`*`)||s.includes(`settings:api-tokens:write`),l=s.includes(`*`)||s.includes(`settings:api-tokens:delete`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(u1),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),y=[{accessorKey:`name`,header:`Name`},{accessorKey:`access_type`,header:`Access`,cell:({getValue:e})=>{let t=e();return(0,H.jsx)(HS,{variant:s1[t]??`secondary`,children:c1[t]??t})}},{accessorKey:`created_at`,header:`Created`,cell:({getValue:e})=>new Date(e()).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})},{id:`actions`,header:``,cell:({row:e})=>l?(0,H.jsx)(q,{size:`icon`,variant:`ghost`,className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,onClick:()=>_(e.original),children:(0,H.jsx)(jo,{className:`size-3.5`})}):null}],b=X$({data:t??[],columns:y,getCoreRowModel:G$()});async function x(e){e.preventDefault();try{h(await i(`/cms/admin/api-tokens`,`POST`,{name:f.name,accessType:f.accessType})),r()}catch{}}function S(){d(!1),h(null),p(u1)}async function C(){try{await i(`/cms/admin/api-tokens/${g.id}`,`DELETE`),_(null),r()}catch{}}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`API Tokens`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage tokens for consuming the public API.`})]}),(0,H.jsxs)(q,{onClick:()=>d(!0),disabled:!c,children:[(0,H.jsx)(vo,{className:`size-4`}),`New token`]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[(0,H.jsx)(`div`,{className:`rounded-md border`,children:(0,H.jsxs)(cC,{children:[(0,H.jsx)(lC,{className:`font-bold uppercase`,children:b.getHeaderGroups().map(e=>(0,H.jsx)(dC,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,H.jsx)(fC,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:K$(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,H.jsx)(uC,{children:n?(0,H.jsx)(dC,{children:(0,H.jsx)(pC,{colSpan:y.length,className:`h-24`,children:(0,H.jsx)(Mv,{className:`mx-auto size-5`})})}):b.getRowModel().rows.length===0?(0,H.jsx)(dC,{children:(0,H.jsx)(pC,{colSpan:y.length,className:`h-24 text-center text-muted-foreground`,children:`No tokens yet.`})}):b.getRowModel().rows.map(e=>(0,H.jsx)(dC,{children:e.getVisibleCells().map(e=>(0,H.jsx)(pC,{className:`px-4 py-3`,children:K$(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,H.jsx)(US,{open:u,onOpenChange:e=>{e||S()},children:(0,H.jsx)(qS,{className:`sm:max-w-md`,children:m?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Token generated`})}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`div`,{className:`rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200`,children:`Make sure to copy your token now. You won't be able to see it again.`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{children:`Token`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(Tv,{readOnly:!0,value:m.token,className:`font-mono text-xs`}),(0,H.jsx)(l1,{value:m.token})]})]})]}),(0,H.jsx)(YS,{children:(0,H.jsx)(q,{onClick:S,children:`Done`})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`New API token`})}),(0,H.jsxs)(`form`,{id:`create-token-form`,onSubmit:x,className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`token-name`,children:`Name`}),(0,H.jsx)(Tv,{id:`token-name`,placeholder:`e.g. Production frontend`,value:f.name,onChange:e=>p(t=>({...t,name:e.target.value})),required:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`token-access`,children:`Access type`}),(0,H.jsxs)(QS,{value:f.accessType,onValueChange:e=>p(t=>({...t,accessType:e})),children:[(0,H.jsx)(tC,{id:`token-access`,children:(0,H.jsx)(eC,{placeholder:`Select access type`})}),(0,H.jsxs)(iC,{children:[(0,H.jsx)(oC,{value:`read-only`,children:`Read only`}),(0,H.jsx)(oC,{value:`full-access`,children:`Full access`})]})]})]}),o&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:o})]}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,type:`button`,onClick:S,children:`Cancel`}),(0,H.jsx)(q,{type:`submit`,form:`create-token-form`,disabled:a||!f.accessType||!c,children:a?`Generating…`:`Generate token`})]})]})})}),(0,H.jsx)(US,{open:!!g,onOpenChange:e=>{e||_(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Revoke token`})}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to revoke`,` `,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:g?.name}),`? Any frontend using it will immediately lose access.`]}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>_(null),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:C,disabled:a||!l,children:a?`Revoking…`:`Revoke`})]})]})})]})]})}var f1=[{value:`entry.published`,label:`Entry published`},{value:`entry.unpublished`,label:`Entry unpublished`},{value:`entry.created`,label:`Entry created`},{value:`entry.updated`,label:`Entry updated`},{value:`entry.deleted`,label:`Entry deleted`}],p1={name:``,url:``,events:[]};function m1(){let{user:e}=oa(),{data:t,loading:n,refetch:r}=ma(`/cms/admin/webhooks`),{request:i,loading:a,error:o}=wv(),s=e?.permissions??[],c=s.includes(`*`)||s.includes(`settings:webhooks:write`),l=s.includes(`*`)||s.includes(`settings:webhooks:delete`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(p1),[m,h]=(0,v.useState)(null),g=[{accessorKey:`name`,header:`Name`},{accessorKey:`url`,header:`URL`,cell:({getValue:e})=>(0,H.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground truncate max-w-xs block`,children:e()})},{accessorKey:`events`,header:`Events`,cell:({getValue:e})=>(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e().map(e=>(0,H.jsx)(HS,{variant:`secondary`,className:`text-xs font-mono`,children:e},e))})},{accessorKey:`created_at`,header:`Created`,cell:({getValue:e})=>new Date(e()).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})},{id:`actions`,header:``,cell:({row:e})=>l?(0,H.jsx)(q,{size:`icon`,variant:`ghost`,className:`size-8 text-destructive hover:text-destructive`,onClick:()=>h(e.original),children:(0,H.jsx)(jo,{className:`size-3.5`})}):null}],_=X$({data:t??[],columns:g,getCoreRowModel:G$()});function y(e){p(t=>({...t,events:t.events.includes(e)?t.events.filter(t=>t!==e):[...t.events,e]}))}async function b(e){e.preventDefault();try{await i(`/cms/admin/webhooks`,`POST`,f),d(!1),p(p1),r()}catch{}}async function x(){try{await i(`/cms/admin/webhooks/${m.id}`,`DELETE`),h(null),r()}catch{}}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jv,{children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Webhooks`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Notify external services when content events occur.`})]}),(0,H.jsxs)(q,{onClick:()=>d(!0),disabled:!c,children:[(0,H.jsx)(vo,{className:`size-4`}),`New webhook`]})]})}),(0,H.jsxs)(`section`,{className:`mt-24`,children:[(0,H.jsx)(`div`,{className:`rounded-md border`,children:(0,H.jsxs)(cC,{children:[(0,H.jsx)(lC,{className:`font-bold uppercase`,children:_.getHeaderGroups().map(e=>(0,H.jsx)(dC,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,H.jsx)(fC,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:K$(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,H.jsx)(uC,{children:n?(0,H.jsx)(dC,{children:(0,H.jsx)(pC,{colSpan:g.length,className:`h-24`,children:(0,H.jsx)(Mv,{className:`mx-auto size-5`})})}):_.getRowModel().rows.length===0?(0,H.jsx)(dC,{children:(0,H.jsx)(pC,{colSpan:g.length,className:`h-24 text-center text-muted-foreground`,children:`No webhooks yet.`})}):_.getRowModel().rows.map(e=>(0,H.jsx)(dC,{children:e.getVisibleCells().map(e=>(0,H.jsx)(pC,{className:`px-4 py-3`,children:K$(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,H.jsx)(US,{open:u,onOpenChange:e=>{e||(d(!1),p(p1))},children:(0,H.jsxs)(qS,{className:`sm:max-w-md`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`New webhook`})}),(0,H.jsxs)(`form`,{id:`create-webhook-form`,onSubmit:b,className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`webhook-name`,children:`Name`}),(0,H.jsx)(Tv,{id:`webhook-name`,placeholder:`e.g. Dokploy deploy`,value:f.name,onChange:e=>p(t=>({...t,name:e.target.value})),required:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`webhook-url`,children:`URL`}),(0,H.jsx)(Tv,{id:`webhook-url`,type:`url`,placeholder:`https://...`,value:f.url,onChange:e=>p(t=>({...t,url:e.target.value})),required:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(Y,{children:`Events`}),f1.map(({value:e,label:t})=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(XE,{id:`event-${e}`,checked:f.events.includes(e),onCheckedChange:()=>y(e)}),(0,H.jsxs)(`label`,{htmlFor:`event-${e}`,className:`text-sm cursor-pointer`,children:[t,(0,H.jsx)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:e})]})]},e))]}),o&&(0,H.jsx)(`p`,{className:`text-sm text-destructive`,children:o})]}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,type:`button`,onClick:()=>{d(!1),p(p1)},children:`Cancel`}),(0,H.jsx)(q,{type:`submit`,form:`create-webhook-form`,disabled:a||f.events.length===0||!c,children:a?`Creating…`:`Create webhook`})]})]})}),(0,H.jsx)(US,{open:!!m,onOpenChange:e=>{e||h(null)},children:(0,H.jsxs)(qS,{className:`sm:max-w-sm`,children:[(0,H.jsx)(JS,{children:(0,H.jsx)(XS,{children:`Delete webhook`})}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:m?.name}),`? It will stop receiving events immediately.`]}),(0,H.jsxs)(YS,{children:[(0,H.jsx)(q,{variant:`outline`,onClick:()=>h(null),children:`Cancel`}),(0,H.jsx)(q,{variant:`destructive`,onClick:x,disabled:a||!l,children:a?`Deleting…`:`Delete`})]})]})})]})]})}function h1({...e}){return(0,H.jsx)($v,{"data-slot":`collapsible`,...e})}function g1({...e}){return(0,H.jsx)(Xv,{"data-slot":`collapsible-content`,...e})}function _1(){let{user:e,updateUser:t}=oa(),{loading:n,error:r,request:i}=wv(),{request:a}=wv(),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(e?.firstName??``),[_,y]=(0,v.useState)(e?.lastName??``),[b,x]=(0,v.useState)(e?.jobTitle??``),[S,C]=(0,v.useState)(e?.organization??``),[w,T]=(0,v.useState)(e?.country??``);function E(){p&&(g(e?.firstName??``),y(e?.lastName??``),x(e?.jobTitle??``),C(e?.organization??``),T(e?.country??``)),m(!p)}async function D(e){let n=e.target.files?.[0];if(n){c(!0),f(null);try{t({avatarUrl:await hX(n)})}catch(e){f(e instanceof Error?e.message:`Upload failed.`)}finally{c(!1),o.current&&(o.current.value=``)}}}async function O(){u(!0),f(null);try{await a(`/cms/admin/users/me/avatar`,`DELETE`),t({avatarUrl:null})}catch(e){f(e instanceof Error?e.message:`Delete failed.`)}finally{u(!1)}}async function k(e){e.preventDefault();try{let e=await i(`/cms/admin/users/me`,`PATCH`,{firstName:h,lastName:_,jobTitle:b,organization:S,country:w});t({firstName:e.first_name,lastName:e.last_name,jobTitle:e.job_title,organization:e.organization,country:e.country}),m(!1)}catch{}}return(0,H.jsx)(h1,{open:p,onOpenChange:m,children:(0,H.jsxs)(bQ,{children:[(0,H.jsxs)(xQ,{children:[(0,H.jsx)(SQ,{className:`uppercase`,children:`Account`}),(0,H.jsx)(CQ,{children:(0,H.jsx)(q,{variant:`ghost`,size:`icon`,onClick:E,children:p?(0,H.jsx)(zo,{className:`size-4`}):(0,H.jsx)(_o,{className:`size-4`})})})]}),(0,H.jsxs)(wQ,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4 -mt-4`,children:[(0,H.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`block`,onClick:()=>o.current?.click(),disabled:s||l,title:`Change avatar`,children:[(0,H.jsx)(ll,{avatarUrl:e?.avatarUrl,firstName:e?.firstName,lastName:e?.lastName,email:e?.email,className:`size-20`,fallbackClassName:`text-xl`}),(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 transition-opacity group-hover:opacity-100`,children:s||l?(0,H.jsx)(`div`,{className:`size-4 animate-spin rounded-full border-2 border-white border-t-transparent`}):(0,H.jsx)(Oa,{className:`size-5 text-white`})})]}),e?.avatarUrl&&!s&&!l&&(0,H.jsx)(`button`,{type:`button`,onClick:O,title:`Remove avatar`,className:`absolute -top-1 -right-1 flex size-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground opacity-0 transition-opacity group-hover:opacity-100`,children:(0,H.jsx)(jo,{className:`size-3`})})]}),(0,H.jsx)(`input`,{ref:o,type:`file`,accept:`image/*`,className:`hidden`,onChange:D}),(0,H.jsxs)(`div`,{children:[d&&(0,H.jsx)(`p`,{className:`text-xs text-destructive mb-1`,children:d}),(0,H.jsx)(`p`,{className:`font-bold text-xl`,children:e?.firstName||e?.lastName?`${e.firstName??``} ${e.lastName??``}`.trim():e?.email}),(e?.jobTitle||e?.organization)&&(0,H.jsx)(`p`,{className:`text-sm`,children:[e.jobTitle,e.organization].filter(Boolean).join(` · `)}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e?.email}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2 mt-2`,children:[(0,H.jsx)(HS,{className:`capitalize`,children:e?.role}),e?.country&&(0,H.jsx)(HS,{variant:`outline`,children:e.country})]})]})]}),(0,H.jsx)(g1,{children:(0,H.jsxs)(`form`,{onSubmit:k,className:`space-y-4 mt-8`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`firstName`,children:`First name`}),(0,H.jsx)(Tv,{id:`firstName`,value:h,onChange:e=>g(e.target.value)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`lastName`,children:`Last name`}),(0,H.jsx)(Tv,{id:`lastName`,value:_,onChange:e=>y(e.target.value)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`jobTitle`,children:`Job title`}),(0,H.jsx)(Tv,{id:`jobTitle`,value:b,onChange:e=>x(e.target.value)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`organization`,children:`Organization`}),(0,H.jsx)(Tv,{id:`organization`,value:S,onChange:e=>C(e.target.value)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`country`,children:`Country`}),(0,H.jsx)(Tv,{id:`country`,value:w,onChange:e=>T(e.target.value)})]})]}),r&&(0,H.jsx)(`p`,{className:`text-destructive text-sm`,children:r}),(0,H.jsx)(q,{type:`submit`,disabled:n,children:n?`Saving…`:`Save changes`})]})})]})]})})}function v1(){let{loading:e,error:t,request:n}=wv(),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(null);function p(){i(!1),o(``),c(``),u(``),f(null)}async function m(e){if(e.preventDefault(),f(null),s!==l){f(`New passwords do not match`);return}try{await n(`/cms/admin/users/me/password`,`PATCH`,{currentPassword:a,newPassword:s}),p()}catch{}}return(0,H.jsx)(h1,{open:r,onOpenChange:i,children:(0,H.jsxs)(bQ,{children:[(0,H.jsxs)(xQ,{children:[(0,H.jsx)(SQ,{className:`uppercase`,children:`Security`}),(0,H.jsx)(CQ,{children:r&&(0,H.jsx)(q,{variant:`ghost`,size:`icon`,onClick:p,children:(0,H.jsx)(zo,{className:`size-4`})})})]}),(0,H.jsxs)(wQ,{children:[!r&&(0,H.jsxs)(`div`,{className:`flex gap-4`,children:[(0,H.jsx)(q,{variant:`secondary`,onClick:()=>i(!0),children:`Change password`}),(0,H.jsx)(q,{variant:`secondary`,disabled:!0,children:`Enable 2FA`})]}),(0,H.jsx)(g1,{children:(0,H.jsxs)(`form`,{onSubmit:m,className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`current`,children:`Current password`}),(0,H.jsx)(Tv,{id:`current`,type:`password`,value:a,onChange:e=>o(e.target.value),required:!0})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`new`,children:`New password`}),(0,H.jsx)(Tv,{id:`new`,type:`password`,value:s,onChange:e=>c(e.target.value),required:!0,minLength:8})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Y,{htmlFor:`confirm`,children:`Confirm new password`}),(0,H.jsx)(Tv,{id:`confirm`,type:`password`,value:l,onChange:e=>u(e.target.value),required:!0})]}),(d??t)&&(0,H.jsx)(`p`,{className:`text-destructive text-sm`,children:d??t}),(0,H.jsx)(q,{type:`submit`,disabled:e,children:e?`Saving…`:`Update password`})]})})]})]})})}function y1(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jv,{children:(0,H.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Profile`})}),(0,H.jsx)(`section`,{className:`mt-18`,children:(0,H.jsx)(`div`,{className:`grid grid-cols-2 gap-4 items-start`,children:(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(_1,{}),(0,H.jsx)(v1,{})]})})})]})}var b1=ki([{path:`/login`,element:(0,H.jsx)(Av,{})},{element:(0,H.jsx)(pa,{children:(0,H.jsx)(Cv,{})}),children:[{index:!0,element:(0,H.jsx)(gC,{})},{path:`content`,element:(0,H.jsx)(fD,{}),children:[{index:!0,element:(0,H.jsx)(pD,{})},{path:`:slug`,element:(0,H.jsx)(VD,{})},{path:`:slug/new`,element:(0,H.jsx)(GZ,{})},{path:`:slug/:id`,element:(0,H.jsx)(GZ,{})}]},{path:`media`,element:(0,H.jsx)(lQ,{})},{path:`content-types`,element:(0,H.jsx)(pa,{permission:`content-types:write`,children:(0,H.jsx)(yC,{})}),children:[{index:!0,element:(0,H.jsx)(DC,{})},{path:`new`,element:(0,H.jsx)(uD,{})},{path:`:slug`,element:(0,H.jsx)(uD,{})}]},{path:`settings`,element:(0,H.jsx)(pa,{permission:`settings:overview:read`,children:(0,H.jsx)(pQ,{})}),children:[{index:!0,element:(0,H.jsx)(zr,{to:`overview`,replace:!0})},{path:`overview`,element:(0,H.jsx)(pa,{permission:`settings:overview:read`,children:(0,H.jsx)(OQ,{})})},{path:`users`,element:(0,H.jsx)(pa,{permission:`settings:users:read`,children:(0,H.jsx)(t1,{})})},{path:`roles`,element:(0,H.jsx)(pa,{permission:`settings:roles:read`,children:(0,H.jsx)(o1,{})})},{path:`api-tokens`,element:(0,H.jsx)(pa,{permission:`settings:api-tokens:read`,children:(0,H.jsx)(d1,{})})},{path:`webhooks`,element:(0,H.jsx)(pa,{permission:`settings:webhooks:read`,children:(0,H.jsx)(m1,{})})}]},{path:`profile`,element:(0,H.jsx)(y1,{})}]},{path:`*`,element:(0,H.jsx)(zr,{to:`/`,replace:!0})}],{basename:`/admin/`.replace(/\/$/,``)||`/`});function x1(){return(0,H.jsx)(aa,{children:(0,H.jsx)(ca,{children:(0,H.jsx)(da,{children:(0,H.jsx)($i,{router:b1})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(v.StrictMode,{children:(0,H.jsx)(x1,{})}));
|
package/dist/admin/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
href="https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap"
|
|
13
13
|
rel="stylesheet"
|
|
14
14
|
/>
|
|
15
|
-
<script type="module" crossorigin src="/admin/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/admin/assets/index-Mg2IXN8V.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/admin/assets/index-BCd-a4uR.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { randomBytes } from "crypto";
|
|
|
7
7
|
import { resolve, join } from "path";
|
|
8
8
|
import fs from "fs-extra";
|
|
9
9
|
import { execa } from "execa";
|
|
10
|
-
var PACKAGE_VERSION = "0.12.
|
|
10
|
+
var PACKAGE_VERSION = "0.12.1";
|
|
11
11
|
function generateSecret() {
|
|
12
12
|
return randomBytes(32).toString("hex");
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plank-cms/plank",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Self-hosted headless CMS. Deploy in minutes on your own infrastructure.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/fs-extra": "^11.0.4",
|
|
57
57
|
"tsup": "^8.5.0",
|
|
58
|
-
"@plank-cms/
|
|
59
|
-
"@plank-cms/
|
|
60
|
-
"@plank-cms/schema": "0.12.
|
|
58
|
+
"@plank-cms/core": "0.12.1",
|
|
59
|
+
"@plank-cms/db": "0.12.1",
|
|
60
|
+
"@plank-cms/schema": "0.12.1"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsup",
|