import{S as e}from"./dist-rbQIUfXp.js";import{a as t,c as n,n as r,o as i,s as a}from"./document-editor-CHM7Pu4m-CAewHPNC.js";import{n as o,t as s}from"./hooks-Vx4YtE1e-CANWwp8q.js";import{t as c}from"./components-tpme59UM.js";import{r as l}from"./connect-BSkeWkEI-BgLja9Zm.js";import{Suspense as u,useCallback as d,useEffect as f,useState as p}from"react";import{jsx as m,jsxs as h}from"react/jsx-runtime";function g(e){return h(`select`,{id:`supported-document-types`,className:`w-full rounded-md border border-gray-300 px-3 py-2 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500`,...e,children:[m(`option`,{value:``,children:`Select a document type`}),e.children]})}function _({documentTypes:e,setDocumentTypes:t,onAddDocumentType:n,onRemoveDocumentType:r}){let i=s(!0),[a,o]=p(``);return m(g,{value:a,onChange:i=>{let a=i.target.value;if(a){let i=e?.at(0);i&&r?.({id:i.id});let o={id:Date.now().toString(),documentType:a};t([{id:o.id,documentType:o.documentType}]),n?.(o)}o(``)},children:i.map(e=>m(`option`,{value:e,children:e},e))})}var v=({editorName:e=``,documentTypes:t=[],status:n=`DRAFT`,onEditorNameChange:r,onAddDocumentType:i,onRemoveDocumentType:a,onConfirm:s})=>{let[l,d]=p(e),[v,y]=p(t),[b,x]=p(!1);o(l,r,300),f(()=>{d(e)},[e]),f(()=>{y(t)},[t]),f(()=>{n===`DRAFT`&&x(!1)},[n]);let S=b||n===`CONFIRMED`;return h(`div`,{className:`space-y-6 p-6`,children:[h(`div`,{className:`flex items-center justify-between`,children:[m(`h2`,{className:`text-lg font-medium text-gray-900`,children:`Editor Configuration`}),m(c,{status:n===`CONFIRMED`?`confirmed`:`draft`,label:n===`CONFIRMED`?`Confirmed`:`Draft`})]}),h(`div`,{children:[m(`label`,{htmlFor:`editor-name`,className:`mb-2 block text-sm font-medium text-gray-700`,children:`Editor Name`}),m(`input`,{id:`editor-name`,type:`text`,value:l,onChange:e=>d(e.target.value),disabled:S,className:`w-full rounded-md border border-gray-300 px-3 py-2 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500 ${S?`cursor-not-allowed bg-gray-100`:``}`})]}),h(`div`,{children:[m(`label`,{htmlFor:`supported-document-types`,className:`mb-2 block text-sm font-medium text-gray-700`,children:`Supported Document Types`}),h(`div`,{className:`space-y-2`,children:[!S&&m(u,{fallback:m(g,{}),children:m(_,{documentTypes:v,setDocumentTypes:y,onAddDocumentType:i,onRemoveDocumentType:a})}),m(`div`,{className:`space-y-1`,children:v.map(e=>h(`div`,{className:`flex items-center py-1`,children:[m(`span`,{className:`text-sm text-gray-700`,children:e.documentType}),!S&&m(`button`,{onClick:()=>{y([]),a?.({id:e.id})},className:`ml-2 text-gray-400 hover:text-gray-600 focus:outline-none`,children:`×`})]},e.id))})]})]}),!S&&m(`div`,{children:m(`button`,{onClick:()=>{l.trim()&&v.length>0&&(x(!0),s?.())},disabled:!l.trim()||v.length===0,className:`rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:bg-gray-300`,children:`Confirm`})})]})},y={isExternalControlsEnabled:!1};function b(){e(y);let[o,s]=n(),c=d(e=>{!o.state.global.name&&!e||e!==o.state.global.name&&s(i({name:e}))},[o.state.global.name,s]),u=d(e=>{s(r(e))},[s]),f=d(e=>{s(t(e))},[s]),p=d(()=>{s(a({status:`CONFIRMED`}))},[s]);return h(`div`,{className:`bg-gray-50 p-6`,children:[m(l,{}),m(v,{status:o.state.global.status,editorName:o.state.global.name??``,documentTypes:o.state.global.documentTypes,onEditorNameChange:c,onAddDocumentType:u,onRemoveDocumentType:f,onConfirm:p})]})}export{b as default};
//# sourceMappingURL=editor-CQwD5q6a-6-KwVgxx.js.map