import{C as e,S as t,u as n}from"./dist-rbQIUfXp.js";import{a as r,c as i,l as a,n as o,o as s,s as c,u as l}from"./app-module-BbhoykB5-Bxf5AUcc.js";import{n as u}from"./hooks-Vx4YtE1e-CANWwp8q.js";import{t as d}from"./components-tpme59UM.js";import{r as f}from"./connect-BSkeWkEI-BgLja9Zm.js";import{useCallback as p,useEffect as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";var v=`all-in-drive`,y=`all-in-reactor`,b=`allow-any`,x=()=>{let[t,f]=l(),x=t.state.global.name,S=t.state.global.status,C=t.state.global.isDragAndDropEnabled,w=t.state.global.allowedDocumentTypes,[T,E]=h(x),[D,O]=h(S===`CONFIRMED`),k=n(),A=e(),[j,M]=h(w??[]);u(T,p(e=>{e!==x&&(console.log(`onNameChange`,e),f(s({name:e})))},[x]),300);let N=()=>{f(c({status:`CONFIRMED`}))},P=e=>{e!==C&&f(a({enabled:e}))};m(()=>{S===`DRAFT`&&O(!1)},[S]);let F=D||S===`CONFIRMED`,I=()=>{T.trim()&&(O(!0),N())},L=e=>{!e||j.includes(e)||(M([...j,e]),f(o({documentType:e})))},R=e=>{M(j.filter(t=>t!==e)),f(r({documentType:e}))},z=()=>{let e=[...new Set([...j,...k??[]])];M(e),f(i({documentTypes:e}))},B=()=>{let e=[...new Set([...j,...A??[]])];M(e),f(i({documentTypes:e}))},V=()=>{M([]),f(i({documentTypes:[]}))},H=e=>{e===v?z():e===y?B():e===b?V():L(e)};return _(`div`,{className:`space-y-6 p-6`,children:[_(`div`,{className:`flex items-center justify-between`,children:[g(`h2`,{className:`text-lg font-medium text-gray-900`,children:`App Configuration`}),g(d,{status:S===`CONFIRMED`?`confirmed`:`draft`,label:S===`CONFIRMED`?`Confirmed`:`Draft`})]}),_(`div`,{children:[g(`label`,{htmlFor:`app-name`,className:`mb-2 block text-sm font-medium text-gray-700`,children:`App Name`}),g(`input`,{id:`app-name`,type:`text`,value:T,onChange:e=>E(e.target.value),disabled:F,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 ${F?`cursor-not-allowed bg-gray-100`:``}`,placeholder:`Enter app name`})]}),_(`div`,{children:[g(`label`,{htmlFor:`document-types`,className:`mb-2 block text-sm font-medium text-gray-700`,children:`Document Types`}),_(`div`,{className:`space-y-2`,children:[!F&&_(`select`,{onChange:e=>H(e.target.value),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`,children:[g(`option`,{children:`Select a document type to add`}),g(`option`,{children:`--- Vetra drive document types ---`}),g(`option`,{value:v,children:`Add all document types in Vetra drive`}),k?.filter(e=>!j.includes(e)).map(e=>g(`option`,{value:e,children:e},e)),g(`option`,{children:`--- Reactor document types ---`}),g(`option`,{value:y,children:`Add all document types in Reactor`}),A?.filter(e=>!j.includes(e)).map(e=>g(`option`,{value:e,children:e},e)),g(`option`,{children:`--- Allow any document type ---`}),g(`option`,{value:b,children:`Allow any document type`})]}),g(`div`,{className:`space-y-1`,children:j.length>0?j.map(e=>_(`div`,{className:`flex items-center py-1`,children:[g(`span`,{className:`text-sm text-gray-700`,children:e}),!F&&g(`button`,{onClick:()=>R(e),className:`ml-2 text-gray-400 hover:text-gray-600 focus:outline-none`,children:`×`})]},e)):g(`span`,{className:`text-sm text-gray-700`,children:`All documents (*)`})})]})]}),_(`div`,{children:[g(`h3`,{className:`text-md mb-4 font-medium text-gray-900`,children:`Drag and Drop Settings`}),g(`div`,{className:`mb-4`,children:_(`label`,{htmlFor:`drag-and-drop-enabled`,className:`flex items-center`,children:[g(`input`,{id:`drag-and-drop-enabled`,type:`checkbox`,checked:C,onChange:e=>P(e.target.checked),disabled:F,className:`mr-2 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 ${F?`cursor-not-allowed`:``}`}),g(`span`,{className:`text-sm font-medium text-gray-700`,children:`Enable drag and drop`})]})})]}),!F&&g(`div`,{children:g(`button`,{onClick:I,disabled:!T.trim(),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`})})]})},S={isExternalControlsEnabled:!1};function C(){return t(S),_(`div`,{className:`bg-gray-50 p-6`,children:[g(f,{}),g(x,{})]})}export{C as default};
//# sourceMappingURL=editor-9B-mf9yE-p79G9-a2.js.map