@objectstack/console 11.9.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.objectui-sha +1 -1
- package/dist/assets/{AdapterProvider-DVX_k0gB.js → AdapterProvider-BIB-F0Qa.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-La6Ze-fz.js → AiPendingActionsPage-CMVG4Uuj.js} +1 -1
- package/dist/assets/ApiConsolePage-BpBKlVk6.js +1 -0
- package/dist/assets/{AppDocsIndex-B04zB99i.js → AppDocsIndex-35urFMpk.js} +1 -1
- package/dist/assets/{AppManagementPage-DJchVHa5.js → AppManagementPage-Q8hLq3cQ.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-Cjd1esAG.js +1 -0
- package/dist/assets/AuditLogPage-C2lQmF3X.js +1 -0
- package/dist/assets/{ComponentNavView-DbfuUNGc.js → ComponentNavView-BuEXrmXR.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-BAW-WlIf.js → ConsoleFloatingChatbot-XMVIlmjf.js} +1 -1
- package/dist/assets/{DashboardView-Djw0MggX.js → DashboardView-cKnnhVZW.js} +1 -1
- package/dist/assets/DashboardWidgetInspector-DQzulo-e.js +1 -0
- package/dist/assets/{DeveloperHubPage-DlfRVfB3.js → DeveloperHubPage-DO4z3Sj9.js} +1 -1
- package/dist/assets/{ExpressionProvider-DGF3MugJ.js → ExpressionProvider-BI-jCA0B.js} +1 -1
- package/dist/assets/FlowRunsPage-DVvg_WMt.js +1 -0
- package/dist/assets/{IntegrationsPage-sLCzz4vL.js → IntegrationsPage-kF55v0ix.js} +2 -2
- package/dist/assets/InterfaceListPage-CH9wtpOt.js +1 -0
- package/dist/assets/{ManagedByBadge-CDDSvYHn.js → ManagedByBadge-DtZfR2w_.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-D_tpevwJ.js → MarketplaceAccessDenied-JR0ElPYV.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-CkUEaBR9.js → MarketplaceInstalledPage-c1qqM0m9.js} +1 -1
- package/dist/assets/MarketplacePackagePage-CT5bU1QW.js +4 -0
- package/dist/assets/MarketplacePage-BkOByUub.js +1 -0
- package/dist/assets/{MetadataInspector-Cgk4Y1A7.js → MetadataInspector-FQJn-0mY.js} +1 -1
- package/dist/assets/{MetadataProvider-Cu56xdi9.js → MetadataProvider-DlGQbrYS.js} +1 -1
- package/dist/assets/PageView-BR-dytGp.js +1 -0
- package/dist/assets/ProfilePage-BfNhQTic.js +1 -0
- package/dist/assets/PublicFormsPage-D5HXZ9gs.js +1 -0
- package/dist/assets/RecordDetailView-BUBX12o3.js +9 -0
- package/dist/assets/RecordFormPage-dOx4tkq3.js +1 -0
- package/dist/assets/ReportDefaultInspector-DQlvnczB.js +11 -0
- package/dist/assets/{ReportView-DqC6GJsU.js → ReportView-BoYtuwGU.js} +1 -1
- package/dist/assets/{SearchResultsPage-DoTdiqLP.js → SearchResultsPage-Dn6Lg7cm.js} +1 -1
- package/dist/assets/{SettingsHub-BMclJbZT.js → SettingsHub-BIUh_NaE.js} +1 -1
- package/dist/assets/{SettingsView-BriYkHIM.js → SettingsView-iFSFGurq.js} +1 -1
- package/dist/assets/{SystemHubPage-u4cJwRz3.js → SystemHubPage-BbYZjpSv.js} +1 -1
- package/dist/assets/data-adapter-BJMUjXWO.js +7 -0
- package/dist/assets/{framework-WZr4krBC.js → framework-Bn8ShCi0.js} +5 -5
- package/dist/assets/{highlighted-body-OFNGDK62-De1Z23h7.js → highlighted-body-OFNGDK62-CLYrkLJN.js} +1 -1
- package/dist/assets/index-BecTd5hZ.js +2 -0
- package/dist/assets/index-Ci5dbUDe.css +2 -0
- package/dist/assets/mermaid-GHXKKRXX-B7A4_dsH.js +1 -0
- package/dist/assets/metadata-admin-CwGCDJE1.js +22 -0
- package/dist/assets/plugin-calendar-DJ1vxgSA.js +1 -0
- package/dist/assets/plugin-charts-vp7sTLa2.js +7 -0
- package/dist/assets/plugin-chatbot-DCC-44Dt.js +120 -0
- package/dist/assets/plugin-dashboard-z2hSPvkm.js +6 -0
- package/dist/assets/plugin-form-BUDPowXG.js +1 -0
- package/dist/assets/plugin-gantt-BJIjCj1A.js +93 -0
- package/dist/assets/plugin-grid-ieKf1CBn.js +8 -0
- package/dist/assets/plugin-kanban-DhARoJCa.js +1 -0
- package/dist/assets/plugin-map-C2xGbkMv.js +1 -0
- package/dist/assets/{plugin-markdown-DN5tgnpR.js → plugin-markdown-DXEq1goV.js} +1 -1
- package/dist/assets/plugin-report-Cho-TzT3.js +59 -0
- package/dist/assets/plugin-timeline-6gVRcvzs.js +1 -0
- package/dist/assets/plugin-tree-_9p0xC9K.js +1 -0
- package/dist/assets/plugin-view-vYQlhE3F.js +1 -0
- package/dist/assets/plugins-views-ycDq-ZXC.js +4 -0
- package/dist/assets/{skeletons-DQtGqEIo.js → skeletons-C2aQsjPE.js} +1 -1
- package/dist/assets/{src-Dt23JboC.js → src-B4OzWw0f.js} +1 -1
- package/dist/assets/src-CbqgiuxM.js +15 -0
- package/dist/assets/{types-C_3ZSSQo.js → types-B0Soeu38.js} +1 -1
- package/dist/assets/ui-components-DlauVk27.js +42 -0
- package/dist/assets/ui-layout-DnHby9xU.js +1 -0
- package/dist/assets/{useOpenRecordList-CiUIxuVn.js → useOpenRecordList-DWDU_kYn.js} +1 -1
- package/dist/assets/useReconcileOnError-B9komLeJ.js +1 -0
- package/dist/assets/useRecordApprovals-B_jxSZvZ.js +1 -0
- package/dist/assets/utils-Bixzg6Bz.js +1 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ApiConsolePage-CBAIJWJ_.js +0 -1
- package/dist/assets/ApprovalsInboxPage-Ddy3SDqP.js +0 -1
- package/dist/assets/AuditLogPage-r6ifzD0U.js +0 -1
- package/dist/assets/DashboardWidgetInspector-BVvGLv7b.js +0 -1
- package/dist/assets/FlowRunsPage-C4_71jyO.js +0 -1
- package/dist/assets/InterfaceListPage-CxfEqY2Z.js +0 -1
- package/dist/assets/MarketplacePackagePage-CKZ9QH3r.js +0 -4
- package/dist/assets/MarketplacePage-BdxwjGoT.js +0 -1
- package/dist/assets/PageView-C1patuLx.js +0 -1
- package/dist/assets/ProfilePage-Bd6u25mD.js +0 -1
- package/dist/assets/PublicFormsPage-DMSTg6WT.js +0 -1
- package/dist/assets/RecordDetailView-CXltbudR.js +0 -9
- package/dist/assets/RecordFormPage-C3okBT1R.js +0 -1
- package/dist/assets/ReportDefaultInspector-CssrqnGI.js +0 -11
- package/dist/assets/data-adapter-D0RtPrPs.js +0 -7
- package/dist/assets/index-CN2ZOfrA.css +0 -2
- package/dist/assets/index-DoXSjQ3z.js +0 -2
- package/dist/assets/mermaid-GHXKKRXX-aGLnXuPV.js +0 -1
- package/dist/assets/metadata-admin-G3YkfiAa.js +0 -22
- package/dist/assets/plugin-calendar-_Py45vU-.js +0 -1
- package/dist/assets/plugin-charts-Bchg0hAC.js +0 -7
- package/dist/assets/plugin-chatbot-DoDgOZ1X.js +0 -120
- package/dist/assets/plugin-dashboard-CqUaEqJ2.js +0 -6
- package/dist/assets/plugin-form-CUnJuXVB.js +0 -1
- package/dist/assets/plugin-gantt-nPjFN--f.js +0 -93
- package/dist/assets/plugin-grid-Ber_5UtY.js +0 -8
- package/dist/assets/plugin-kanban-Cng34wUx.js +0 -1
- package/dist/assets/plugin-map-DMseuRbE.js +0 -1
- package/dist/assets/plugin-report-BzdS88ls.js +0 -59
- package/dist/assets/plugin-timeline-CFOn7Ntr.js +0 -1
- package/dist/assets/plugin-tree-DRaXkomQ.js +0 -1
- package/dist/assets/plugin-view-B0FdLoWA.js +0 -1
- package/dist/assets/plugins-views-BKj7GUfw.js +0 -4
- package/dist/assets/src-hN5UFV3j.js +0 -12
- package/dist/assets/ui-components-BTSIX9CP.js +0 -42
- package/dist/assets/ui-layout-B6R0dB1y.js +0 -1
- package/dist/assets/useActionModal-B60Ph5_U.js +0 -1
- package/dist/assets/useReconcileOnError-BUw6x-9Q.js +0 -1
- package/dist/assets/utils-CFXe_XCU.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-slxo-5GC.js";import{d as c,f as l,m as u,n as d}from"./infrastructure-BySW-NB0.js";import{H as f,I as p,M as m,a as h,g,j as _}from"./framework-WZr4krBC.js";import{Cr as v,G as y,K as b,Lc as x,Lo as S,V as C,Y as w,_r as T,br as E,gr as D,ia as O,mr as k,vr as A,xr as j,yr as M}from"./ui-components-BTSIX9CP.js";import{r as N}from"./vendor-ui-utils-C1OpMExs.js";import"./MetadataProvider-Cu56xdi9.js";import{r as P}from"./ExpressionProvider-DGF3MugJ.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-CXltbudR.js";import{n as F,r as I,t as L}from"./MetadataInspector-Cgk4Y1A7.js";import{t as R}from"./InterfaceListPage-CxfEqY2Z.js";var z=e(n(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(v,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(k,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(T,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(E,{children:[(0,B.jsx)(j,{children:r?.title}),(0,B.jsx)(A,{children:r?.message})]}),(0,B.jsxs)(M,{children:[(0,B.jsx)(D,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:c}=l(),{systemPermissions:f}=d(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=x(),y=(0,z.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),b=r||y?.name,S=(0,z.useCallback)(()=>{i?.()},[i]),C=g({dataSource:t,onUndo:()=>{S(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=re(e,{objectName:r||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),s=r||y?.name;D({open:!0,params:o.map(e=>({...e,label:h(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(s,t?.name,e.name,n.value,n.label)})):e.options})),title:t?.label||t?.title,description:v(s,t?.name,t?.description),resolve:i})}),[r,y,n,p,m,h,_]),V=o?{id:o.id,name:o.name,avatar:o.image,isPlatformAdmin:o?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),W=(0,z.useMemo)(()=>u(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&S(),{success:!0,data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||b,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&S(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,b,W,c,S,G]),q=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)a=e[0]?.id;else if(e.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||b,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&S(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,b,S]),J=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)o=e[0]?.[a];else if(e.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&S(),{success:!0}}let i=e.objectName||b||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&S();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,b,S]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...r?{objectName:r}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[r,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),S()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=Q(t);return(0,B.jsxs)(p,{...n.actionProviderProps,children:[e,n.dialogs]})}var $=t({PageView:()=>ue});function ue(){let{t:e}=h(),{pageName:t}=r(),[n]=a(),{showDebug:o}=F(),l=s(),u=i(),d=c(),{pages:p,objects:g,getTypeStatus:v}=m(),{app:x}=P(),T=_(),[E,D]=(0,z.useState)(0),k=I(p,t,x?._packageId);if(!k){let n=v?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(C,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(y,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(S,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(w,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(b,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(n.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:T,objects:g,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,B.jsx)(O,{className:`h-3.5 w-3.5`})}),k.interfaceConfig?.source?(0,B.jsx)(R,{page:k,reserveEditAffordance:M},E):(0,B.jsx)(f,{schema:{...k,type:k.type||`page`,context:{...k.context,params:A,refreshKey:E}}},E)]}),(0,B.jsx)(L,{open:o,sections:[{title:`Page Configuration`,data:k}]})]})})}export{q as a,K as i,Q as n,G as r,$ as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{f as r,o as i}from"./infrastructure-BySW-NB0.js";import{Ar as a,Ba as o,Cr as s,Hr as c,Is as l,Ns as u,T as d,Va as f,ar as p,cr as m,dr as h,fr as g,ir as _,ln as v,lr as y,nr as b,pn as x,rr as S,sr as C,tr as w,ur as T,zr as E}from"./ui-components-BTSIX9CP.js";var D=e(t(),1),O=n();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:o,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=d(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(w,{children:(0,O.jsxs)(b,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(m,{className:`h-16 w-16`,children:[(0,O.jsx)(T,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(y,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(C,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{await t({image:(await M(n)).url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(f,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(c,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(a,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(h,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(g,{children:H})]})]})}),(0,O.jsxs)(w,{children:[(0,O.jsxs)(_,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(E,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(p,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(S,{children:`Update your name and view account details`})]}),(0,O.jsx)(b,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(h,{variant:`destructive`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(g,{children:L})]}),F&&(0,O.jsxs)(h,{children:[(0,O.jsx)(u,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(g,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(v,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(v,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{children:`Role`}),(0,O.jsx)(v,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(s,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:o,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[a,c]=(0,D.useState)(null),[d,f]=(0,D.useState)(``),[m,y]=(0,D.useState)(``),[C,T]=(0,D.useState)(``),[E,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||c(t)}).catch(()=>{e||c(!1)}),()=>{e=!0}},[n]);let P=()=>{f(``),y(``),T(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),m.length<8){j(`Password must be at least 8 characters`);return}if(m!==C){j(`Passwords do not match`);return}k(!0);try{if(a){if(!d){j(`Enter your current password`),k(!1);return}await e(d,m),N(`Password changed.`)}else await t(m),N(`Local password set. You can now sign in with email and password on this environment.`),c(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=a===null;return(0,O.jsxs)(w,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(_,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(p,{className:`text-base sm:text-lg`,children:a?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(S,{children:a?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(b,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[a&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(v,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:d,onChange:e=>f(e.target.value),disabled:E||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`new-password`,children:a?`New password`:`Password`}),(0,O.jsx)(v,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:m,onChange:e=>y(e.target.value),disabled:E||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(v,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:C,onChange:e=>T(e.target.value),disabled:E||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(h,{variant:`destructive`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(g,{children:A})]}),M&&(0,O.jsxs)(h,{children:[(0,O.jsx)(u,{className:`h-4 w-4`}),(0,O.jsx)(g,{children:M})]}),(0,O.jsx)(s,{type:`submit`,disabled:E||I,className:`w-full sm:w-auto`,children:E?`Saving…`:a?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{j as r}from"./framework-WZr4krBC.js";import{Cr as i,Gn as a,Ja as o,Jn as s,Ki as ee,Kn as c,Oi as te,Ui as ne,Xn as l,Xo as re,Yn as u,Zi as ie,_t as ae,ar as oe,gt as d,ht as f,ir as se,ln as p,mt as ce,nr as m,pn as h,ps as le,pt as ue,qn as g,rr as de,sr as fe,tr as pe,us as me,vt as _}from"./ui-components-BTSIX9CP.js";import{r as v}from"./vendor-ui-utils-C1OpMExs.js";import"./src-hN5UFV3j.js";var y=e(t(),1),b=n();function he(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function S(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[S,ge]=(0,y.useState)([]),[C,w]=(0,y.useState)(!0),[T,E]=(0,y.useState)(null),[_e,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(!1),[ve,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(``),[z,B]=(0,y.useState)(`thank-you`),[V,H]=(0,y.useState)(``),[U,W]=(0,y.useState)(``),[G,K]=(0,y.useState)(``),[q,J]=(0,y.useState)(!1),Y=async()=>{if(!e?.meta?.getItems){E(`meta.getItems is not available on this client`),w(!1);return}w(!0),E(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=he(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),ge(a)}catch(e){E(e?.message??String(e))}finally{w(!1)}};(0,y.useEffect)(()=>{Y()},[]);let ye=typeof window<`u`?window.location.origin:``,X=e=>`${ye}/console/f/${e}`,Z=e=>`<iframe src="${X(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${X(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),v.success(`Copied ${e}`)}catch{v.error(`Clipboard unavailable`)}},xe=async()=>{if(!O||!A)return;let t=S.find(e=>e.name===O);if(!t)return;let n=x(A);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};N(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),D(!1),k(``),j(``),await Y()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{N(!1)}},Se=e=>{I(e),R(e.slug);let t=e.spec?.submitBehavior;B(t?.kind??`thank-you`),H(t?.title??``),W(t?.message??``),K(t?.url??``),P(!0)},Ce=async()=>{if(!F)return;let t=x(L);if(!t){v.error(`Invalid slug`);return}let n;switch(z){case`thank-you`:n={kind:`thank-you`},V&&(n.title=V),U&&(n.message=U);break;case`redirect`:if(!G){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:G};break;case`continue`:case`next-record`:n={kind:z};break}let r={...F.spec,sharing:{...F.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};J(!0);try{await e.meta.saveItem(`view`,F.name,r),v.success(`Saved ${F.name}`),P(!1),I(null),await Y()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{J(!1)}},$=t.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,b.jsxs)(pe,{children:[(0,b.jsxs)(se,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(oe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(ee,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(de,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(i,{variant:`default`,size:`sm`,onClick:()=>D(!0),disabled:S.length===0,title:S.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(ie,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(i,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(ne,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(m,{children:[T&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:T}),!C&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(ue,{children:[(0,b.jsx)(ae,{children:(0,b.jsxs)(_,{children:[(0,b.jsx)(d,{children:`Name`}),(0,b.jsx)(d,{children:`Object`}),(0,b.jsx)(d,{children:`Slug`}),(0,b.jsx)(d,{children:`Public URL`}),(0,b.jsx)(d,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(ce,{children:t.map(e=>{let t=X(e.slug);return(0,b.jsxs)(_,{children:[(0,b.jsx)(f,{children:(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,b.jsx)(f,{children:e.object?(0,b.jsx)(fe,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(f,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(f,{children:(0,b.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,b.jsx)(re,{className:`h-3 w-3`})]})}),(0,b.jsx)(f,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(i,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(i,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,Z(e.slug)),children:(0,b.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(i,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(me,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(i,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(te,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(a,{open:_e,onOpenChange:D,children:(0,b.jsxs)(c,{className:`sm:max-w-md`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(l,{children:`Publish a FormView`}),(0,b.jsxs)(g,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,b.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,b.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:O,onChange:e=>k(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),S.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(p,{id:`publish-slug`,placeholder:`contact-us`,value:A,onChange:e=>j(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(s,{children:[(0,b.jsx)(i,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(i,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(a,{open:ve,onOpenChange:P,children:(0,b.jsxs)(c,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(l,{children:F?`Edit ${F.label??F.name}`:`Edit form`}),(0,b.jsx)(g,{children:`Configure the public URL and what happens after submit.`})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(p,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:z,onChange:e=>B(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),z===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(p,{id:`edit-tytitle`,placeholder:`Thanks!`,value:V,onChange:e=>H(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(p,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:U,onChange:e=>W(e.target.value)})]})]}),z===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(p,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(s,{children:[(0,b.jsx)(i,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(i,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t,t as n}from"./rolldown-runtime-DAXXjFlN.js";import{_ as r,f as i,l as a,r as o,t as s,u as c}from"./vendor-react-slxo-5GC.js";import{f as l,m as u}from"./infrastructure-BySW-NB0.js";import{H as d,I as f,S as p,T as m,a as h,g,jt as _,m as v,tt as y,w as b}from"./framework-WZr4krBC.js";import{Cr as x,E as S,G as C,Gn as w,Gs as T,Ic as E,Jn as D,Jo as O,Jt as k,K as ee,Kn as A,Lc as te,Us as ne,Xn as j,Xt as re,Y as ie,Yn as ae,Yo as oe,Yt as se,Zt as ce,_r as le,br as ue,ct as de,er as fe,gr as pe,hr as me,is as he,jc as ge,ln as _e,mr as ve,pn as ye,qn as be,qt as xe,us as Se,vr as M,xr as N,yr as Ce}from"./ui-components-BTSIX9CP.js";import{r as P}from"./vendor-ui-utils-C1OpMExs.js";import{t as we}from"./plugin-form-CUnJuXVB.js";import{i as Te,n as Ee,o as De,t as Oe}from"./useActionModal-B60Ph5_U.js";import{n as ke}from"./utils-CFXe_XCU.js";import{n as Ae,t as je}from"./MetadataInspector-Cgk4Y1A7.js";import{c as Me,i as Ne,n as Pe,r as Fe,s as Ie}from"./plugins-views-BKj7GUfw.js";import{t as Le}from"./ManagedByBadge-CDDSvYHn.js";import{t as Re}from"./skeletons-DQtGqEIo.js";var F=e(r(),1),I=s(),L=(0,F.createContext)(void 0);function ze({children:e}){let[t,n]=(0,F.useState)(`home`),[r,i]=(0,F.useState)(),[a,o]=(0,F.useState)(),s=(0,F.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,I.jsx)(L.Provider,{value:s,children:e})}function R(){return(0,F.useContext)(L)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function Be(e){let{setRecordTitle:t}=R();(0,F.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}var Ve=n(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),z=n((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),B=n((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),He=n(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ue=n(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),We=n((e=>{var t=z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),V=n((e=>{var t=z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Ge=n((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),H=n((e=>{var t=B(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),U=n((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Ke=n((e=>{var t=U();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),W=n(((e,t)=>{var n=Ke();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),qe=n((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Je=n((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
2
|
-
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),G=n((e=>{var t=qe(),n=Je();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),K=n((e=>{var t=z(),n=H(),r=B(),i=G(),a=qe(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Ye=n((e=>{var t=z(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Xe=n(((e,t)=>{var n=G();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),q=n(((e,t)=>{var n=G(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),J=n(((e,t)=>{var n=G();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Ze=n(((e,t)=>{var n=G(),r=z();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
3
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Qe=n(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),$e=n((e=>{var t=G(),n=Xe(),r=q(),i=J(),a=Ze(),o=Je(),s=z(),c=Qe();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
4
|
-
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),et=n((e=>{var t=z(),n=B(),r=He(),i=Ue(),a=We(),o=V(),s=Ge(),c=H(),l=W(),u=K(),d=Ye(),f=G(),p=$e();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
5
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
-
Minimum version required to store current data is: `+c+`.
|
|
7
|
-
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),tt=n((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),nt=n((e=>{var t=tt();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),rt=n((e=>{var t=tt();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
8
|
-
`;return typeof a==`function`&&a(null,p),p}})),it=n((e=>{var t=Ve(),n=et(),r=nt(),i=rt();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}));function at(e){let{url:t,channel:n,autoReconnect:r=!0,reconnectInterval:i=1e3,maxReconnectAttempts:a=10,authToken:o}=e,[s,c]=(0,F.useState)(`disconnected`),[l,u]=(0,F.useState)(null),[d,f]=(0,F.useState)([]),[p,m]=(0,F.useState)(null),h=(0,F.useRef)(null),g=(0,F.useRef)(0),_=(0,F.useRef)(null),v=(0,F.useRef)(new Map),y=(0,F.useRef)([]),b=(0,F.useRef)(!0),x=(0,F.useRef)(!1),S=(0,F.useCallback)(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),C=(0,F.useCallback)(e=>{for(;y.current.length>0;){let t=y.current.shift(),r={type:t.type,channel:n,data:t.data,timestamp:new Date().toISOString()};e.send(JSON.stringify(r))}},[n]),w=(0,F.useCallback)(()=>{if(typeof WebSocket>`u`){m(Error(`WebSocket is not available in this environment`)),c(`error`);return}if(!t){m(Error(`WebSocket URL is required`)),c(`error`);return}try{let e=new URL(t);if(e.protocol!==`ws:`&&e.protocol!==`wss:`){m(Error(`WebSocket URL must use ws: or wss: protocol`)),c(`error`);return}}catch{m(Error(`Invalid WebSocket URL`)),c(`error`);return}h.current&&=(x.current=!0,h.current.close(),null),x.current=!1,c(`connecting`),m(null);let e=o?`${t}?token=${encodeURIComponent(o)}&channel=${encodeURIComponent(n)}`:`${t}?channel=${encodeURIComponent(n)}`,s;try{s=new WebSocket(e)}catch(e){if(!b.current)return;m(e instanceof Error?e:Error(`Failed to create WebSocket connection`)),c(`error`);return}h.current=s,s.onopen=()=>{b.current&&(c(`connected`),m(null),g.current=0,C(s))},s.onmessage=e=>{if(b.current)try{let t=JSON.parse(String(e.data));if(t.channel!==n)return;u(t),f(e=>[...e,t]);let r=v.current.get(t.type);r&&r.forEach(e=>e(t.data))}catch{}},s.onerror=()=>{b.current&&(m(Error(`WebSocket connection error`)),c(`error`))},s.onclose=()=>{if(b.current){if(h.current=null,x.current){c(`disconnected`);return}if(r&&g.current<a){c(`reconnecting`);let e=Math.min(i*2**g.current,3e4);g.current+=1,_.current=setTimeout(()=>{b.current&&w()},e)}else c(`disconnected`)}}},[t,n,o,r,i,a,C]),T=(0,F.useCallback)(()=>{S(),x.current=!0,g.current=0,h.current&&=(h.current.close(),null),c(`disconnected`)},[S]),E=(0,F.useCallback)(()=>{S(),g.current=0,w()},[w,S]),D=(0,F.useCallback)((e,t)=>{let r=h.current;if(r&&r.readyState===WebSocket.OPEN){let i={type:e,channel:n,data:t,timestamp:new Date().toISOString()};r.send(JSON.stringify(i))}else y.current.push({type:e,data:t})},[n]),O=(0,F.useCallback)((e,t)=>(v.current.has(e)||v.current.set(e,new Set),v.current.get(e).add(t),()=>{let n=v.current.get(e);n&&(n.delete(t),n.size===0&&v.current.delete(e))}),[]);return(0,F.useEffect)(()=>(b.current=!0,t&&w(),()=>{b.current=!1,S(),x.current=!0,h.current&&=(h.current.close(),null)}),[t,n,o]),{connectionState:s,isConnected:s===`connected`,lastMessage:l,messages:d,send:D,subscribe:O,disconnect:T,reconnect:E,error:p}}var ot=0;function st(){return ot+=1,`conflict-${Date.now()}-${ot}`}var ct=0;function lt(){return ct+=1,`ver-${Date.now()}-${ct}`}function ut(e,t,n){let[r,i]=(0,F.useState)([]),[a,o]=(0,F.useState)([]);return{versions:r,currentVersion:(0,F.useMemo)(()=>r.length===0?0:r[r.length-1].version,[r]),conflicts:a,hasConflicts:a.length>0,recordVersion:(0,F.useCallback)((n,r)=>{i(i=>{let a=i.length===0?1:i[i.length-1].version+1,o={id:lt(),version:a,timestamp:new Date().toISOString(),userId:e,userName:t,changes:n,message:r};return[...i,o]})},[e,t]),resolveConflict:(0,F.useCallback)((n,r,a)=>{o(o=>{let s=o.find(e=>e.id===n);if(!s)return o;let c;switch(r){case`local`:c=s.localValue;break;case`remote`:c=s.remoteValue;break;case`merge`:c=a??s.localValue;break}return i(n=>{let i=n.length===0?1:n[n.length-1].version+1,a={id:lt(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:{[s.field]:{before:s.baseValue,after:c}},message:`Resolved conflict on "${s.field}" using ${r} strategy`};return[...n,a]}),o.filter(e=>e.id!==n)})},[e,t]),resolveAllConflicts:(0,F.useCallback)(n=>{o(r=>{if(r.length===0)return r;let a={};for(let e of r)a[e.field]={before:e.baseValue,after:n===`local`?e.localValue:e.remoteValue};return i(r=>{let i=r.length===0?1:r[r.length-1].version+1,o={id:lt(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:a,message:`Resolved all conflicts using ${n} strategy`};return[...r,o]}),[]})},[e,t]),revertToVersion:(0,F.useCallback)(n=>{let a=r.findIndex(e=>e.id===n);if(a===-1)return null;let o={};for(let e=0;e<=a;e++){let t=r[e];for(let[e,n]of Object.entries(t.changes))o[e]=n.after}let s={},c={};for(let e of r)for(let[t,n]of Object.entries(e.changes))c[t]=n.after;for(let[e,t]of Object.entries(o))c[e]!==t&&(s[e]={before:c[e],after:t});return Object.keys(s).length>0&&i(n=>{let i=n.length===0?1:n[n.length-1].version+1,o={id:lt(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:s,message:`Reverted to version ${r[a].version}`};return[...n,o]}),o},[r,e,t]),compareVersions:(0,F.useCallback)((e,t)=>{let n=r.findIndex(t=>t.id===e),i=r.findIndex(e=>e.id===t);if(n===-1||i===-1)return null;let[a,o]=n<i?[n,i]:[i,n],s=e=>{let t={};for(let n=0;n<=e;n++)for(let[e,i]of Object.entries(r[n].changes))t[e]=i.after;return t},c=s(a),l=s(o),u=new Set([...Object.keys(c),...Object.keys(l)]),d={};for(let e of u){let t=c[e],n=l[e];t!==n&&(d[e]={before:t,after:n})}return d},[r]),addConflict:(0,F.useCallback)(e=>{let t={...e,id:st()};o(e=>[...e,t])},[]),clearHistory:(0,F.useCallback)(()=>{i([]),o([])},[])}}var dt={sm:24,md:32,lg:40},ft={active:`#22c55e`,idle:`#f59e0b`,away:`#94a3b8`};function pt(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function mt({users:e,maxVisible:t=5,size:n=`md`,showStatus:r=!0,className:i}){let a=dt[n],o=Math.round(a*.3),s=Math.round(a*.35),c=Math.max(8,Math.round(a*.28)),l=(0,F.useMemo)(()=>e.slice(0,t),[e,t]),u=Math.max(0,e.length-t),d={display:`inline-flex`,alignItems:`center`,flexDirection:`row-reverse`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`},f={width:`${a}px`,height:`${a}px`,borderRadius:`50%`,border:`2px solid #fff`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`${s}px`,fontWeight:600,color:`#fff`,position:`relative`,flexShrink:0,overflow:`hidden`,boxSizing:`border-box`},p={...f,backgroundColor:`#e2e8f0`,color:`#475569`,marginLeft:`-${o}px`},m={position:`absolute`,bottom:`-1px`,right:`-1px`,width:`${c}px`,height:`${c}px`,borderRadius:`50%`,border:`2px solid #fff`,boxSizing:`border-box`},h=(0,F.useMemo)(()=>[...l].reverse(),[l]);return F.createElement(`div`,{style:d,className:i,role:`group`,"aria-label":`${e.length} user${e.length===1?``:`s`} present`},u>0&&F.createElement(`div`,{key:`overflow`,style:p,title:`${u} more user${u===1?``:`s`}`},`+${u}`),h.map((e,t)=>F.createElement(`div`,{key:e.userId,style:{...f,backgroundColor:e.color,marginLeft:t>0||u>0?`-${o}px`:`0`},title:`${e.userName} (${e.status})`},e.avatar?F.createElement(`img`,{src:e.avatar,alt:e.userName,style:{width:`100%`,height:`100%`,objectFit:`cover`}}):pt(e.userName),r&&F.createElement(`span`,{style:{...m,backgroundColor:ft[e.status]}}))))}var ht=F.createContext({});function Y(){let e=F.useContext(ht),[t,n]=F.useState([]);return F.useEffect(()=>{if(!e.subscribeTenant){n([]);return}return e.subscribeTenant(e=>{n(Array.isArray(e)?e:[])})},[e]),t}function gt(e,t){let n=F.useContext(ht),[r,i]=F.useState([]);return F.useEffect(()=>{if(!n.subscribeRecord||!e||!t){i([]);return}return n.subscribeRecord({objectName:e,recordId:t},e=>{i(Array.isArray(e)?e:[])})},[n,e,t]),r}var _t={platform:{create:!0,import:!0,edit:!0,delete:!0,exportCsv:!0},config:{create:!0,import:!1,edit:!0,delete:!0,exportCsv:!0},system:{create:!1,import:!1,edit:!1,delete:!1,exportCsv:!0},"append-only":{create:!1,import:!1,edit:!1,delete:!1,exportCsv:!0},"better-auth":{create:!1,import:!1,edit:!1,delete:!1,exportCsv:!0}};function vt(e){let t=_t[e?.managedBy??`platform`]??_t.platform,n=e?.userActions??{};return{create:n.create??t.create,import:n.import??t.import,edit:n.edit??t.edit,delete:n.delete??t.delete,exportCsv:n.exportCsv??t.exportCsv}}var yt=new Set([`record:discussion`,`record:chatter`]);function bt(e){let t=new WeakSet,n=e=>{if(!e||typeof e!=`object`||t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.some(n);let r=e?.type;return typeof r==`string`&&yt.has(r)?!0:[e.children,e.items,e.body,e.components,e.properties?.children,e.properties?.items,e.regions].some(n)};return n(e)}function xt({state:e,onOpenChange:t}){let{t:n}=h(),r=()=>{e.resolve?.(!0),t(!1)},i=()=>{e.resolve?.(!1),t(!1)};return(0,I.jsx)(ve,{open:e.open,onOpenChange:e=>{e||i()},children:(0,I.jsxs)(le,{children:[(0,I.jsxs)(ue,{children:[(0,I.jsx)(N,{children:e.options?.title||n(`actionConfirm.title`)}),(0,I.jsx)(M,{children:e.message})]}),(0,I.jsxs)(Ce,{children:[(0,I.jsx)(pe,{onClick:i,children:e.options?.cancelText||n(`actionConfirm.cancel`)}),(0,I.jsx)(me,{onClick:r,children:e.options?.confirmText||n(`actionConfirm.confirm`)})]})]})})}function St({state:e,onOpenChange:t}){let{t:n,language:r}=h(),[i,a]=(0,F.useState)({}),[o,s]=(0,F.useState)({});(0,F.useEffect)(()=>{if(e.open){let t={};for(let n of e.params)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);a(t),s({})}},[e.open,e.params]);let c=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:!1,l=()=>{let n={};for(let t of e.params)t.required&&c(i[t.name])&&(n[t.name]=!0);if(Object.keys(n).length>0){s(n);return}e.resolve?.(i),t(!1)},u=()=>{e.resolve?.(null),t(!1)},d=(e,t)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:!1}))};return(0,I.jsx)(w,{open:e.open,onOpenChange:e=>{e||u()},children:(0,I.jsxs)(A,{children:[(0,I.jsxs)(ae,{children:[(0,I.jsx)(j,{children:e.title||n(`actionDialog.title`)}),(0,I.jsx)(be,{children:e.description||n(`actionDialog.description`)})]}),(0,I.jsx)(`div`,{className:`grid gap-4 py-4`,children:e.params.map(e=>{let t={...e,label:E(e.label,r),helpText:e.helpText==null?e.helpText:E(e.helpText,r),options:e.options?.map(e=>({...e,label:E(e.label,r)}))};if(t.type===`boolean`||t.type===`checkbox`){let e=i[t.name]===!0;return(0,I.jsxs)(`div`,{className:`grid gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(fe,{id:t.name,checked:e,onCheckedChange:e=>d(t.name,e===!0),className:`mt-0.5`}),(0,I.jsxs)(ye,{htmlFor:t.name,className:`font-normal cursor-pointer`,children:[t.label,t.required&&(0,I.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]})]}),o[t.name]&&(0,I.jsx)(`p`,{className:`text-xs text-destructive ml-6`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground ml-6`,children:t.helpText})]},t.name)}let a=t.type===`lookup`||t.type===`reference`;return(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsxs)(ye,{htmlFor:t.name,children:[t.label,t.required&&(0,I.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]}),t.type===`select`&&t.options?(0,I.jsxs)(xe,{value:i[t.name]??``,onValueChange:e=>d(t.name,e),children:[(0,I.jsx)(re,{id:t.name,className:o[t.name]?`border-destructive`:``,children:(0,I.jsx)(ce,{placeholder:t.placeholder||n(`actionDialog.selectPlaceholder`,{label:t.label})})}),(0,I.jsx)(k,{children:t.options.map(e=>(0,I.jsx)(se,{value:e.value,children:e.label},e.value))})]}):a&&t.referenceTo?(0,I.jsx)(S,{value:i[t.name]??null,onChange:e=>d(t.name,e),field:{name:t.name,type:`lookup`,reference_to:t.referenceTo,display_field:t.displayField,id_field:t.idField,description_field:t.descriptionField,multiple:t.multiple,title_format:t.titleFormat,lookup_columns:t.lookupColumns,lookup_filters:t.lookupFilters,lookup_page_size:t.lookupPageSize,depends_on:t.dependsOn,placeholder:t.placeholder}}):t.type===`textarea`?(0,I.jsx)(de,{id:t.name,value:i[t.name]??``,onChange:e=>d(t.name,e.target.value),placeholder:t.placeholder,className:o[t.name]?`border-destructive`:``}):t.type===`number`?(0,I.jsx)(_e,{id:t.name,type:`number`,value:i[t.name]??``,onChange:e=>d(t.name,e.target.value===``?void 0:e.target.valueAsNumber),placeholder:t.placeholder,className:o[t.name]?`border-destructive`:``}):(0,I.jsx)(_e,{id:t.name,type:[`email`,`url`,`date`,`datetime-local`,`time`,`password`].includes(t.type)?t.type:`text`,value:i[t.name]??``,onChange:e=>d(t.name,e.target.value),placeholder:t.placeholder||(a?n(`actionDialog.lookupPlaceholder`,{label:t.label}):void 0),className:o[t.name]?`border-destructive`:``}),o[t.name]&&(0,I.jsx)(`p`,{className:`text-xs text-destructive`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.helpText}),a&&!t.helpText&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`actionDialog.lookupHelpText`)})]},t.name)})}),(0,I.jsxs)(D,{children:[(0,I.jsx)(x,{variant:`outline`,onClick:u,children:n(`actionDialog.cancel`)}),(0,I.jsx)(x,{onClick:l,children:n(`actionDialog.confirm`)})]})]})})}var Ct=it();function X(e,t){if(e!=null)return t.split(`.`).reduce((e,t)=>{if(e!=null)return e[t]},e)}function wt({state:e,onAcknowledge:t}){let{t:n}=h(),{spec:r,data:i}=e,a=(0,F.useMemo)(()=>r?.fields&&r.fields.length>0?r.fields:[{path:``,label:void 0,format:r?.format??`json`}],[r]);return(0,I.jsx)(w,{open:e.open,onOpenChange:e=>{},children:(0,I.jsxs)(A,{onPointerDownOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),className:`max-w-lg`,children:[(0,I.jsxs)(ae,{children:[(0,I.jsx)(j,{children:r?.title||n(`actions.resultDialog.defaultTitle`)||`Save this value now`}),r?.description?(0,I.jsx)(be,{children:r.description}):null]}),(0,I.jsx)(`div`,{className:`space-y-4 py-2`,children:a.map((e,t)=>(0,I.jsx)(Tt,{field:e,value:e.path===``?i:X(i,e.path),defaultFormat:r?.format},`${e.path}-${t}`))}),(0,I.jsx)(D,{children:(0,I.jsx)(x,{onClick:t,children:r?.acknowledge||n(`actions.resultDialog.acknowledge`)||`I have saved this`})})]})})}function Tt({field:e,value:t,defaultFormat:n}){let r=e.format??n??`json`,i=e.label,a=r===`qrcode`&&typeof t!=`string`||r===`code-list`&&!Array.isArray(t)||(r===`secret`||r===`text`)&&typeof t!=`string`?`json`:r;return(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[i?(0,I.jsx)(`div`,{className:`text-sm font-medium text-foreground/80`,children:i}):null,a===`qrcode`?(0,I.jsx)(Dt,{value:t}):null,a===`code-list`?(0,I.jsx)(Q,{value:t}):null,a===`secret`?(0,I.jsx)(Ot,{value:t}):null,a===`text`?(0,I.jsx)(kt,{value:t}):null,a===`json`?(0,I.jsx)(At,{value:t}):null]})}function Et(e){let[t,n]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{if(!t)return;let e=setTimeout(()=>n(!1),1500);return()=>clearTimeout(e)},[t]),{copy:async()=>{if(e!=null)try{await navigator.clipboard.writeText(e),n(!0)}catch{}},copied:t}}function Z({value:e,label:t}){let{copy:n,copied:r}=Et(e);return(0,I.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,onClick:n,children:[r?(0,I.jsx)(T,{className:`w-4 h-4`}):(0,I.jsx)(Se,{className:`w-4 h-4`}),t?(0,I.jsx)(`span`,{className:`ml-2`,children:t}):null]})}function Dt({value:e}){let[t,n]=(0,F.useState)(null);return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`div`,{className:`flex justify-center rounded-md border bg-white p-3`,children:t?(0,I.jsx)(`span`,{className:`text-sm text-destructive`,children:t}):(0,I.jsx)(`canvas`,{ref:t=>{!t||!e||(0,Ct.toCanvas)(t,e,{width:200,margin:1},e=>{e&&n(e.message)})}})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1 text-xs font-mono`,children:e}),(0,I.jsx)(Z,{value:e})]})]})}function Q({value:e}){let t=e.join(`
|
|
9
|
-
`);return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`div`,{className:`rounded-md border bg-muted/40 p-2`,children:(0,I.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 rounded bg-background px-2 py-1 text-sm font-mono`,children:e}),(0,I.jsx)(Z,{value:e})]},`${t}-${e}`))})}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(Z,{value:t,label:`Copy all`})})]})}function Ot({value:e}){let[t,n]=(0,F.useState)(!1);return(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 rounded bg-muted px-2 py-1 text-sm font-mono break-all`,children:t?e:e.replace(/./g,`•`)}),(0,I.jsx)(x,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(e=>!e),children:t?(0,I.jsx)(oe,{className:`w-4 h-4`}):(0,I.jsx)(O,{className:`w-4 h-4`})}),(0,I.jsx)(Z,{value:e})]})}function kt({value:e}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 rounded bg-muted px-2 py-1 text-sm font-mono break-all`,children:e}),(0,I.jsx)(Z,{value:e})]})}function At({value:e}){let t=(0,F.useMemo)(()=>{try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]);return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-md border bg-muted/40 p-3 text-xs font-mono`,children:t}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(Z,{value:t})})]})}function $(e){return e.kind===`object-form`&&!!e.objectName}function jt(e){let t={};for(let n of e.fields)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function Mt({screen:e,values:t,onValueChange:n,dataSource:r,objects:i,objectForm:a,className:o}){if($(e)){let t=Array.isArray(i)?i.find(t=>t?.name===e.objectName):void 0,n=t?t.form?.subforms??t.formViews?.default?.subforms:void 0;return(0,I.jsx)(`div`,{className:ge(`py-2`,o),children:r?(0,I.jsx)(we,{schema:{type:`object-form`,formType:`simple`,objectName:e.objectName,mode:e.mode===`edit`?`edit`:`create`,recordId:e.mode===`edit`?e.recordId:void 0,...e.defaults?{initialValues:e.defaults}:{},layout:`vertical`,subforms:n,onSuccess:a?.onSuccess,onCancel:a?.onCancel,showSubmit:a?.showSubmit??!0,showCancel:a?.showCancel??!0,submitText:a?.submitText??`Save & Continue`,cancelText:a?.cancelText??`Cancel`},dataSource:r},e.nodeId):(0,I.jsx)(`div`,{className:`text-sm text-destructive py-4`,children:a?.noDataSourceMessage??`This step renders an object form but no data source is available.`})})}return(0,I.jsx)(`div`,{className:ge(`space-y-4 py-2`,o),children:e.fields.map(e=>(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsxs)(ye,{htmlFor:`ff-${e.name}`,className:`text-sm`,children:[e.label||e.name,e.required&&(0,I.jsx)(`span`,{className:`text-destructive`,children:` *`})]}),(0,I.jsx)(Nt,{field:e,value:t[e.name],onChange:t=>n(e.name,t)})]},e.name))})}function Nt({field:e,value:t,onChange:n}){let r=`ff-${e.name}`,i=(e.type||`text`).toLowerCase();if(Array.isArray(e.options)&&e.options.length>0)return(0,I.jsxs)(xe,{value:t==null?void 0:String(t),onValueChange:e=>n(e),children:[(0,I.jsx)(re,{id:r,children:(0,I.jsx)(ce,{placeholder:e.placeholder||`Select…`})}),(0,I.jsx)(k,{children:e.options.map((e,t)=>(0,I.jsx)(se,{value:String(e.value),children:e.label},t))})]});if(i===`boolean`||i===`checkbox`)return(0,I.jsx)(fe,{id:r,checked:t===!0,onCheckedChange:e=>n(e===!0)});if(i===`textarea`||i===`markdown`)return(0,I.jsx)(de,{id:r,value:t??``,placeholder:e.placeholder,onChange:e=>n(e.target.value)});let a=i===`number`||i===`currency`?`number`:i===`email`?`email`:i===`date`?`date`:`text`;return(0,I.jsx)(_e,{id:r,type:a,value:t??``,placeholder:e.placeholder,onChange:e=>n(a===`number`?e.target.value===``?void 0:Number(e.target.value):e.target.value)})}function Pt({state:e,authFetch:t,baseUrl:n,onClose:r,onComplete:i,dataSource:a,objects:o}){let[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(``),[p,m]=(0,F.useState)({}),[h,g]=(0,F.useState)(!1);if((0,F.useEffect)(()=>{e&&(c(e.screen),u(e.runId),f(e.flowName),m(jt(e.screen)))},[e]),!e||!s)return null;let _=(e,t)=>m(n=>({...n,[e]:t})),v=async e=>{let a=await t(`${n}/api/v1/automation/${encodeURIComponent(d)}/runs/${encodeURIComponent(l)}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({inputs:e})}),o=await a.json().catch(()=>null);if(!a.ok||o?.success===!1){P.error(o?.error||`Resume failed (HTTP ${a.status})`);return}let s=o?.data??{};if(s.success===!1||s.status===`failed`){P.error(s.errorMessage||s.error||`The flow failed to complete.`),r();return}s.status===`paused`&&s.screen?(c(s.screen),u(s.runId||l),m(jt(s.screen)),P.success(`Saved — next step`)):(P.success(s.successMessage||`Done`),i())},y=async()=>{let e=s.fields.filter(e=>e.required&&(p[e.name]===void 0||p[e.name]===``||p[e.name]===null));if(e.length){P.error(`Please fill: ${e.map(e=>e.label||e.name).join(`, `)}`);return}g(!0);try{await v(p)}catch(e){P.error(e.message)}finally{g(!1)}},b=async e=>{let t=e?.id??e?.data?.id??e?.record?.id,n=s.idVariable&&t!=null?{[s.idVariable]:t}:{};g(!0);try{await v(n)}catch(e){P.error(e.message)}finally{g(!1)}},S=$(s);return(0,I.jsx)(w,{open:!0,onOpenChange:e=>{!e&&!h&&r()},children:(0,I.jsxs)(A,{className:S?`sm:max-w-3xl max-h-[90vh] overflow-y-auto`:`sm:max-w-md`,children:[(0,I.jsxs)(ae,{children:[(0,I.jsx)(j,{children:s.title||`Input`}),s.description&&(0,I.jsx)(be,{children:s.description})]}),(0,I.jsx)(Mt,{screen:s,values:p,onValueChange:_,dataSource:a,objects:o,objectForm:{onSuccess:b,onCancel:r,showSubmit:!0,showCancel:!0,submitText:`Save & Continue`,cancelText:`Cancel`}}),!S&&(0,I.jsxs)(D,{children:[(0,I.jsx)(x,{variant:`outline`,onClick:r,disabled:h,children:`Cancel`}),(0,I.jsx)(x,{onClick:y,disabled:h,children:h?`Submitting…`:`Submit`})]})]})})}function Ft(e,t,n,r){if(!(!Array.isArray(e)||e.length===0))return e.map(e=>{let i=typeof e==`string`?{label:e,value:e}:e;return{label:r?r(t,n,i.value,i.label):i.label,value:i.value}})}function It(e,t){let n=e.field??e.name,r=e.defaultFromRow&&t.row&&n!=null&&Object.prototype.hasOwnProperty.call(t.row,n)?t.row[n]:void 0;if(!e.field)return{name:e.name??``,label:e.label??e.name??``,type:e.type??`text`,required:e.required??!1,options:e.options,placeholder:e.placeholder,helpText:e.helpText,defaultValue:r??e.defaultValue};let i=e.objectOverride??t.objectName,a=t.objects.find(e=>e?.name===i)?.fields?.[e.field];if(!a)return{name:e.name??e.field,label:e.label??t.fieldLabel(i,e.field,e.field),type:e.type??`text`,required:e.required??!1,options:e.options,placeholder:e.placeholder,helpText:e.helpText,defaultValue:r??e.defaultValue};let o=e.type??a.type??`text`,s=e.options??Ft(a.options,i,e.field,t.fieldOptionLabel),c=e.label??t.fieldLabel(i,e.field,a.label??e.field),l=o===`lookup`||o===`reference`?{referenceTo:a.reference_to??a.reference,displayField:a.display_field??a.reference_field,idField:a.id_field,descriptionField:a.description_field,multiple:a.multiple,titleFormat:a.title_format,lookupColumns:a.lookup_columns,lookupFilters:a.lookup_filters,lookupPageSize:a.lookup_page_size,dependsOn:a.depends_on}:{};return{name:e.name??e.field,label:c,type:o,required:e.required??a.required??!1,options:s,placeholder:e.placeholder??a.placeholder,helpText:e.helpText??a.help??a.description,defaultValue:r??e.defaultValue??a.defaultValue,...l}}function Lt(e,t){return Array.isArray(e)?e.map(e=>It(e,t)):[]}var Rt=t({RecordDetailView:()=>Gt}),zt={id:`current-user`,name:`Demo User`},Bt=new Set([`created_at`,`created_by`,`updated_at`,`updated_by`]),Vt=new Set([`organization_id`,`tenant_id`,`is_deleted`,`deleted_at`]),Ht=[`description`,`notes`,`note`,`remark`,`remarks`,`comments`],Ut=new Set([`textarea`,`markdown`,`html`,`rich-text`,`json`,`code`]);function Wt(e,t){if(Ut.has(t?.type))return!0;let n=e.toLowerCase();return Ht.some(e=>n===e||n.endsWith(`_${e}`))}function Gt({dataSource:e,objects:t,onEdit:n,objectNameOverride:r,recordIdOverride:s,embedded:x}){let S=i(),w=S.appName,T=r??S.objectName,E=s??S.recordId,{showDebug:D}=Ae(),{user:O}=l(),k=c(),A=a().state?.from,{t:j}=h(),{objectLabel:re,viewLabel:ae,sectionLabel:oe,actionLabel:se,actionConfirm:ce,actionSuccess:le,actionParamText:ue,actionParamOptionLabel:de,actionDescription:fe,fieldLabel:pe,fieldOptionLabel:me}=te(),{isFavorite:ge,toggleFavorite:_e,refreshLabel:ve}=Te(),{addRecentItem:ye}=De(),[be,xe]=(0,F.useState)(!0),[Se,M]=(0,F.useState)([]),[N,Ce]=(0,F.useState)([]),[we,L]=(0,F.useState)(0),[ze,R]=(0,F.useState)(null),[Ve,z]=(0,F.useState)({}),[B,He]=(0,F.useState)(null),[Ue,We]=(0,F.useState)(!1),[V,Ge]=(0,F.useState)(),H=t.find(e=>e.name===T);Be(x?void 0:V);let U=E,Ke=gt(T,U),W=(0,F.useMemo)(()=>!T||!U?null:{id:`record:${T}:${U}`,label:V||U||``,href:`/apps/${w}/${T}/record/${U}`,type:`record`},[w,T,U,V]),qe=W?ge(W.id):!1,Je=(0,F.useCallback)(()=>{W&&_e(W)},[W,_e]),{page:G,slots:K}=v(T),Ye=(0,F.useMemo)(()=>{if(typeof window<`u`)try{let e=new URLSearchParams(window.location.search).get(`renderViaSchema`);if(e===`0`||e===`false`)return!1;if(e===`1`||e===`true`)return!0}catch{}return H?.detail?.renderViaSchema!==!1},[H]),Xe=(0,F.useMemo)(()=>G||!H||!Ye&&!K?null:Pe(H,K?{slots:K}:void 0),[Ye,G,K,H]),q=G||Xe,[J,Ze]=(0,F.useState)(null),[Qe,$e]=(0,F.useState)(`idle`);(0,F.useEffect)(()=>{let t=!1;if(!q||!U||!T||!e?.findOne){Ze(null),$e(`idle`);return}let n=_(H?.fields),r=n.length>0?{$expand:n}:void 0,i=()=>{$e(`loading`),(r?e.findOne(T,U,r):e.findOne(T,U)).then(e=>{t||(e&&typeof e==`object`?(Ze(e),$e(`loaded`)):(Ze(null),$e(`missing`)))}).catch(()=>{t||(Ze(null),$e(`missing`))})};i();let a=e=>{let t=e.detail||{};t.objectName!==T||String(t.recordId)!==String(U)||i()};return window.addEventListener(`objectui:record-changed`,a),()=>{t=!0,window.removeEventListener(`objectui:record-changed`,a)}},[q,T,U,e,H]),(0,F.useEffect)(()=>{if(!J||typeof J!=`object`||!H)return;let e=y(H,J);e&&e!==`Untitled`&&e!==V&&Ge(e)},[J,H,V]),(0,F.useEffect)(()=>{if(!T||!U||!w||!V)return;let e=`record:${T}:${U}`;ye({id:e,label:V,href:`/apps/${w}/${T}/record/${U}`,type:`record`}),ve(e,V)},[w,T,U,V,ye,ve]);let[et,tt]=(0,F.useState)({open:!1,message:``}),[nt,rt]=(0,F.useState)({open:!1,params:[]}),[it,at]=(0,F.useState)({open:!1}),ot=(0,F.useCallback)((e,t)=>new Promise(n=>{at({open:!0,spec:e,data:t,resolve:n})}),[]),st=(0,F.useCallback)((e,t)=>new Promise(n=>{tt({open:!0,message:e,options:t,resolve:n})}),[]),ct=(0,F.useCallback)((e,n)=>new Promise(r=>{let i=Lt(e,{objectName:T||H?.name||``,objects:t||[],fieldLabel:pe,fieldOptionLabel:me}),a=T||H?.name;rt({open:!0,params:i.map(e=>({...e,label:ue(a,n?.name,e.name,`label`,e.label)??e.label,placeholder:ue(a,n?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:ue(a,n?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(t=>({...t,label:de(a,n?.name,e.name,t.value,t.label)})):e.options})),title:n?.label||n?.title,description:fe(a,n?.name,n?.description),resolve:r})}),[T,H,t,pe,me,ue,de]),lt=g({dataSource:e,onUndo:()=>{L(e=>e+1),P.success(`Change undone`)}}),ut=(0,F.useCallback)((e,t)=>{if(t?.type===`error`){P.error(e);return}if(t?.undo){P.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{lt.undo()}}});return}P.success(e,{duration:t?.duration})},[lt]),dt=(0,F.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):k(e)},[k]),ft=(0,F.useCallback)(async t=>{try{let n=t.target||t.name,r={...t.params||{}};delete r._rowRecord,t.bodyExtra&&typeof t.bodyExtra==`object`&&Object.assign(r,t.bodyExtra);let i;switch(n){case`opportunity_change_stage`:await e.update(T,U,{stage:r.new_stage});break;case`opportunity_mark_won`:await e.update(T,U,{stage:`closed_won`});break;case`opportunity_mark_lost`:await e.update(T,U,{stage:`closed_lost`,loss_reason:r.loss_reason});break;default:if(Object.keys(r).length>0){if(t.undoable&&J&&T&&U){let e={};for(let t of Object.keys(r))e[t]=J[t]??null;i={id:`undo-${T}-${U}-${Date.now()}`,type:`update`,objectName:T,recordId:String(U),timestamp:Date.now(),description:t.label||`Undo ${T}`,undoData:e,redoData:{...r}}}await e.update(T,U,r)}break}let a=t.refreshAfter===!0;return(a||i)&&L(e=>e+1),{success:!0,reload:a,undo:i}}catch(e){return{success:!1,error:e.message}}},[e,T,U,J]),{modalHandler:pt,modalElement:ht}=Oe(e),Y=(0,F.useMemo)(()=>u(),[]),_t=(0,F.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No flow target provided for flow action`};try{let n=await Y(`/api/v1/automation/${encodeURIComponent(t)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:U,objectName:T,params:e.params??{}})}),r=await n.json().catch(()=>null);if(!n.ok||r&&r.success===!1)return{success:!1,error:r?.error||`Flow "${t}" failed (HTTP ${n.status})`};let i=r?.data??{};if(i.status===`paused`&&i.screen)return R({flowName:t,runId:i.runId,screen:i.screen}),{success:!0,silent:!0};let a=e.refreshAfter!==!1;return a&&L(e=>e+1),{success:!0,data:r?.data,reload:a}}catch(e){return{success:!1,error:e.message}}},[Y,U,T]),yt=(0,F.useRef)(new Set),Ct=(0,F.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No action target provided`};let n=e.params&&!Array.isArray(e.params)?e.params:{},r=`${t}:${U??``}`;if(yt.current.has(r))return{success:!1,error:`Action already in progress`};yt.current.add(r);let i=null;if(e.opensInNewTab)try{i=window.open(`about:blank`,`_blank`),i&&(i.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),i.document.close())}catch{i=null}try{let r=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&r){if(U==null){if(i)try{i.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let t=`${window.location.origin}${r.replace(`{recordId}`,encodeURIComponent(String(U)))}`;if(i)try{i.location.href=t}catch{try{i.close()}catch{}window.location.href=t}else{let e=null;try{e=window.open(t,`_blank`)}catch{e=null}e||P(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(t,`_blank`)}catch{window.location.href=t}}},duration:1e4})}return e.refreshAfter===!0&&L(e=>e+1),{success:!0}}let a=e.objectName||T||`global`,o=await Y(`/api/v1/actions/${encodeURIComponent(a)}/${encodeURIComponent(t)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:U,params:n})}),s=await o.json().catch(()=>null),c=s?.data,l=c&&typeof c==`object`&&c.success===!1;if(!o.ok||s&&s.success===!1||l){let e=l&&c.error||s?.error||`Action "${t}" failed (HTTP ${o.status})`;if(i)try{i.close()}catch{}return P.error(e),{success:!1,error:e}}let u=e.refreshAfter!==!1;u&&L(e=>e+1);let d=s?.data;if(d&&typeof d==`object`&&typeof d.redirectUrl==`string`){let e=d.redirectUrl;if(i)try{i.location.href=e}catch{try{i.close()}catch{}window.location.href=e}else{let t=null;try{t=window.open(e,`_blank`)}catch{t=null}t||P(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(e,`_blank`)}catch{window.location.href=e}}},duration:1e4})}}else if(i)try{i.close()}catch{}return{success:!0,data:d,reload:u}}catch(e){if(i)try{i.close()}catch{}let t=e.message;return P.error(t),{success:!1,error:t}}finally{yt.current.delete(r)}},[Y,U,T]),X=Ee(T,U,O?.id),Tt=(0,F.useRef)(X);Tt.current=X;let Et=(0,F.useCallback)(async e=>{let t=e.target||e.name,n=e.params&&!Array.isArray(e.params)?e.params:{};try{if(t===`approve_request`)await Tt.current.approve({comment:n.comment});else if(t===`reject_request`)await Tt.current.reject({comment:n.comment});else return{success:!1,error:`Unknown approval target: ${t}`};return L(e=>e+1),{success:!0,reload:!0}}catch(e){return{success:!1,error:e?.message||String(e)}}},[]),Z=(0,F.useMemo)(()=>ke(H,t),[H,t]);(0,F.useEffect)(()=>{if(q||!e||!U||Z.length===0)return;let t=!1;return Promise.all(Z.map(({childObject:t,referenceField:n})=>e.find(t,{$filter:{[n]:U}}).then(e=>({childObject:t,items:Array.isArray(e)?e:e?.data||[]})).catch(e=>(console.warn(`[RecordDetailView] Failed to fetch related ${t}:`,e),{childObject:t,items:[]})))).then(e=>{if(t)return;let n={};for(let{childObject:t,items:r}of e)n[t]=r;z(n)}),()=>{t=!0}},[e,U,Z,H,q]);let Dt=(0,F.useMemo)(()=>!H||H.name===`sys_audit_log`||H.enable?.trackHistory!==!0?!1:t.some(e=>e.name===`sys_audit_log`),[H,t]);(0,F.useEffect)(()=>{if(!e||!U||!H||!Dt){He(null);return}let t=!1;return We(!0),e.find(`sys_audit_log`,{$filter:{record_id:U,object_name:H.name},$orderby:{created_at:`desc`},$top:50,$select:[`id`,`created_at`,`action`,`user_id`,`old_value`,`new_value`]}).then(async n=>{if(t)return;let r=Array.isArray(n)?n:n?.data||[],i=Array.from(new Set(r.map(e=>e?.user_id).filter(e=>typeof e==`string`&&e.length>0))),a=new Map;if(i.length>0)try{let t=await e.find(`sys_user`,{$filter:{id:{$in:i}},$top:i.length,$select:[`id`,`name`,`email`,`image`]}),n=Array.isArray(t)?t:t?.data||[];a=new Map(n.map(e=>[e.id,{name:e.name||e.email||null,image:e.image||null}]))}catch(e){console.warn(`[RecordDetailView] Failed to resolve audit user names:`,e)}let o={};for(let[e,t]of Object.entries(H.fields||{}))t?.label&&(o[e]=t.label);let s=e=>{if(!e)return null;if(typeof e==`object`)return e;if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return null};He(r.map(e=>{let t=e?.user_id?a.get(e.user_id):void 0,n=s(e?.old_value)||{},r=s(e?.new_value)||{},i=new Set([...Object.keys(n),...Object.keys(r)]),c=Array.from(i).filter(e=>JSON.stringify(n[e])!==JSON.stringify(r[e])).map(e=>({field:e,label:o[e]||e,from:n[e],to:r[e]}));return{...e,user_name:t?.name??null,user_avatar:t?.image??null,changes:c.length>0?c:void 0}}))}).catch(e=>{t||(console.warn(`[RecordDetailView] Failed to fetch sys_audit_log:`,e),He([]))}).finally(()=>{t||We(!1)}),()=>{t=!0}},[e,U,H,Dt]),(0,F.useEffect)(()=>{if(!e)return;let t=!1,n=O?[{id:String(O.id),label:O.name||O.email||String(O.id),avatarUrl:O.image||void 0}]:[];return(async()=>{try{let r=await e.find(`sys_user`,{$top:50,$select:[`id`,`name`,`email`,`image`]});if(t)return;let i=(Array.isArray(r)?r:r?.data||[]).map(e=>({id:String(e.id),label:e.name||e.email||String(e.id),avatarUrl:e.image||void 0})).filter(e=>e.label),a=new Set(n.map(e=>e.id)),o=[...n,...i.filter(e=>!a.has(e.id))];Ce(o.length>0?o:n)}catch{if(t)return;Ce(n)}})(),()=>{t=!0}},[e,O?.id,O?.name,O?.email]);let Q=(0,F.useMemo)(()=>O?{id:O.id,name:O.name,avatar:O.image}:zt,[O?.id,O?.name,O?.image]);(0,F.useEffect)(()=>{if(!e||!T||!U)return;let t=`${T}:${U}`,n=e=>{if(!e)return;let t;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}else typeof e==`object`&&(t=e);if(t)return Object.entries(t).map(([e,t])=>({emoji:e,count:Array.isArray(t)?t.length:0,reacted:Array.isArray(t)&&t.includes(Q.id)}))};e.find(`sys_comment`,{$filter:{thread_id:t},$orderby:{created_at:`asc`}}).then(e=>{if(!e?.data?.length)return;let t=e.data.map(e=>({id:e.id,type:`comment`,actor:e.author_name??j(`detail.unknownUser`,{defaultValue:`Unknown`}),actorAvatarUrl:e.author_avatar_url??void 0,body:e.body??``,createdAt:e.created_at,updatedAt:e.updated_at,parentId:e.parent_id??void 0,reactions:n(e.reactions)}));M(e=>{let n=new Map;for(let r of[...e,...t])n.set(String(r.id),r);return Array.from(n.values()).sort((e,t)=>(e.createdAt?Date.parse(e.createdAt):0)-(t.createdAt?Date.parse(t.createdAt):0))})}).catch(()=>{});let r={created:`field_change`,updated:`field_change`,deleted:`field_change`,assigned:`field_change`,shared:`field_change`,system:`system`,completed:`task`,commented:void 0,mentioned:void 0,login:void 0,logout:void 0};e.find(`sys_activity`,{$filter:{object_name:T,record_id:U},$orderby:{timestamp:`asc`},$top:200}).then(e=>{if(!e?.data?.length)return;let t=[];for(let n of e.data){let e=r[n.type];if(!e)continue;let i=n.timestamp;(!i||i===`NOW()`||Number.isNaN(Date.parse(i)))&&(i=n.created_at),t.push({id:n.id,type:e,actor:n.actor_name??j(`detail.systemActor`,{defaultValue:`System`}),actorAvatarUrl:n.actor_avatar_url??void 0,body:n.summary??``,createdAt:i,sourceObject:n.source_object??void 0,sourceId:n.source_id??void 0})}t.length&&M(e=>{let n=new Map;for(let r of[...e,...t])n.set(String(r.id),r);return Array.from(n.values()).sort((e,t)=>(e.createdAt?Date.parse(e.createdAt):0)-(t.createdAt?Date.parse(t.createdAt):0))})}).catch(()=>{})},[e,T,U,Q]);let Ot=(0,F.useCallback)(async t=>{let n={id:crypto.randomUUID(),type:`comment`,actor:Q.name,actorAvatarUrl:`avatar`in Q?Q.avatar:void 0,body:t,createdAt:new Date().toISOString()};if(M(e=>[...e,n]),e){let r=`${T}:${U}`,i=Ne(t,N);e.create(`sys_comment`,{id:n.id,thread_id:r,author_id:Q.id,author_name:Q.name,author_avatar_url:`avatar`in Q?Q.avatar:void 0,body:t,mentions:JSON.stringify(i),created_at:n.createdAt}).catch(()=>{})}},[Q,e,T,U,N]),kt=(0,F.useCallback)(async(t,n)=>{let r={id:crypto.randomUUID(),type:`comment`,actor:Q.name,actorAvatarUrl:`avatar`in Q?Q.avatar:void 0,body:n,createdAt:new Date().toISOString(),parentId:t};if(M(e=>[...e,r].map(e=>e.id===t?{...e,replyCount:(e.replyCount??0)+1}:e)),e){let i=`${T}:${U}`,a=Ne(n,N);e.create(`sys_comment`,{id:r.id,thread_id:i,author_id:Q.id,author_name:Q.name,author_avatar_url:`avatar`in Q?Q.avatar:void 0,body:n,mentions:JSON.stringify(a),created_at:r.createdAt,parent_id:t}).catch(()=>{})}},[Q,e,T,U,N]),At=(0,F.useCallback)((t,n)=>{M(r=>r.map(r=>{if(r.id!==t)return r;let i=[...r.reactions??[]],a=i.findIndex(e=>e.emoji===n);if(a>=0){let e=i[a];e.reacted?e.count<=1?i.splice(a,1):i[a]={...e,count:e.count-1,reacted:!1}:i[a]={...e,count:e.count+1,reacted:!0}}else i.push({emoji:n,count:1,reacted:!0});let o={...r,reactions:i};if(e){let n=Q.id,r={};for(let e of i){let t=[];for(e.reacted&&t.push(n);t.length<e.count;)t.push(`__other__`);r[e.emoji]=t}e.update(`sys_comment`,String(t),{reactions:JSON.stringify(r)}).catch(()=>{})}return o}))},[Q.id,e]);(0,F.useEffect)(()=>{xe(!0),queueMicrotask(()=>xe(!1))},[T,E]);let $=(0,F.useMemo)(()=>{if(!H)return{type:`detail-view`};let n=H.primaryField||Object.keys(H.fields||{}).find(e=>e===`name`||e===`title`),r=(()=>{let e=e=>{let t=H.fields[e],n=t.reference_to||t.reference;return{name:e,label:t.label||e,type:t.type||`text`,...t.options&&{options:t.options},...n&&{reference_to:n},...t.reference_field&&{reference_field:t.reference_field},...t.currency&&{currency:t.currency}}},t=t=>{let n=t.filter(e=>!Wt(e,H.fields[e])),r=t.filter(e=>Wt(e,H.fields[e]));return r.length===0||n.length===0?[{showBorder:!1,fields:t.map(e)}]:[{showBorder:!1,fields:n.map(e)},{name:`details`,title:oe(H.name,`details`,j(`detail.sectionMoreDetails`,`More details`)),collapsible:!0,defaultCollapsed:!1,showBorder:!0,fields:r.map(e)}]},n=Fe(H);return n?n.flatMap(e=>e.name?[{...e,title:oe(H.name,e.name,e.title),showBorder:!0}]:t(e.fields.map(e=>e.name))):t(Object.keys(H.fields||{}).filter(e=>!Bt.has(e)&&!Vt.has(e)&&!H.fields[e]?.hidden))})(),i=(()=>{let e=new Set,t=(H.actions||[]).filter(t=>t.locations?.includes(`record_header`)?t.name?e.has(t.name)?!1:(e.add(t.name),!0):!0:!1).map(e=>({...e,label:se(H.name,e.name,e.label||e.name),...e.confirmText!==void 0&&{confirmText:ce(H.name,e.name,e.confirmText)},...e.successMessage!==void 0&&{successMessage:le(H.name,e.name,e.successMessage)}}));if(X.available&&X.canDecide){let e={name:`comment`,label:j(`approvals.comment`,{defaultValue:`Comment (optional)`}),type:`text`,multiline:!0};t.push({name:`approve_request`,type:`approval`,target:`approve_request`,label:j(`approvals.approve`,{defaultValue:`Approve`}),icon:`check`,variant:`default`,locations:[`record_header`],refreshAfter:!0,collectParams:[e],successMessage:j(`approvals.approveSuccess`,{defaultValue:`Approved`})}),t.push({name:`reject_request`,type:`approval`,target:`reject_request`,label:j(`approvals.reject`,{defaultValue:`Reject`}),icon:`x`,variant:`destructive`,locations:[`record_header`],refreshAfter:!0,confirmText:j(`approvals.rejectConfirm`,{defaultValue:`Reject this approval request?`}),collectParams:[e],successMessage:j(`approvals.rejectSuccess`,{defaultValue:`Rejected`})})}return t})(),a=H.highlightFields??H.compactLayout??[],o=(Array.isArray(a)?a:[]).map(e=>{let t=typeof e==`string`?e:e?.name;if(!t)return null;let n=H.fields?.[t];return{name:t,label:n?.label||t,...n?.type?{type:n.type}:{}}}).filter(e=>!!e),s=w?`/apps/${w}`:``,c=Z.map(({childObject:n,childLabel:r,referenceField:i,title:a,columns:o})=>{let c=t.find(e=>e.name===n),l=U||``,u=a||(c?re({name:c.name,label:c.label||r}):r),d=()=>{let e=new URLSearchParams({[i]:l}).toString();return`${s}/${n}/new${e?`?${e}`:``}`},f=()=>{let e=new URLSearchParams({[`filter[${i}]`]:l}).toString();return`${s}/${n}${e?`?${e}`:``}`},p=e=>{let t=e?.id||e?._id;return t?`${s}/${n}/record/${encodeURIComponent(String(t))}/edit`:null},m=e=>{let t=e?.id||e?._id;return t?`${s}/${n}/record/${encodeURIComponent(String(t))}`:null},h=s?()=>k(d()):void 0,g=s?()=>k(f()):void 0,_=s?e=>{let t=m(e);t&&k(t)}:void 0,v=s?e=>{let t=p(e);t&&k(t)}:void 0,y=e&&l?async t=>{let r=t?.id||t?._id;if(r)try{await e.delete(n,r),P.success(j(`detail.deleteSuccess`,{defaultValue:`Deleted`})),z(e=>({...e,[n]:(e[n]||[]).filter(e=>(e.id||e._id)!==r)}))}catch(e){P.error(e?.message||j(`detail.deleteError`,{defaultValue:`Delete failed`}))}}:void 0;return{title:u,type:`table`,api:n,data:Ve[n]||[],referenceField:i,...Array.isArray(o)&&o.length>0?{columns:o}:{},icon:c?.icon,displayField:c?.nameField||c?.displayNameField||(Array.isArray(c?.highlightFields)?c.highlightFields[0]:Array.isArray(c?.compactLayout)?c.compactLayout[0]:void 0),onNew:h,onViewAll:g,onRowClick:_,onRowEdit:v,onRowDelete:y}}),l=vt(H);return{type:`detail-view`,objectName:H.name,resourceId:U,showBack:!x,onBack:`history`,showEdit:l.edit,title:H.label,primaryField:n,sections:r,autoTabs:!0,autoDiscoverRelated:!0,...Dt&&{history:{entries:B??[],loading:Ue&&B===null}},...c.length>0&&{related:c},...o.length>0&&{highlightFields:o},...i.length>0&&{actions:[{type:`action:bar`,location:`record_header`,actions:i}]}}},[H?.name,U,Ve,we,w,k,e,j,re,t,Dt,B,Ue,X.available,X.canDecide,X.pendingRequest,X.latestRequest,x]);if(be)return(0,I.jsx)(Re,{});if(!H)return(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,I.jsxs)(C,{children:[(0,I.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,I.jsx)(he,{className:`h-6 w-6 text-muted-foreground`})}),(0,I.jsx)(ie,{children:j(`empty.objectNotFound`)}),(0,I.jsx)(ee,{children:j(`empty.objectNotFoundDescription`,{name:T})})]})});if(q&&Qe===`missing`)return(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,I.jsxs)(C,{children:[(0,I.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,I.jsx)(he,{className:`h-6 w-6 text-muted-foreground`})}),(0,I.jsx)(ie,{children:j(`empty.recordNotFound`,{defaultValue:`Record not found`})}),(0,I.jsx)(ee,{children:j(`empty.recordNotFoundDescription`,{defaultValue:`The record you are looking for does not exist or may have been deleted.`})})]})});if(q){let r=q?.disableDiscussion===!0,i=bt(q),a=!r&&!i,s=(()=>{let e=$.actions;if(!Array.isArray(e))return[];let t=e.find(e=>Array.isArray(e?.actions))?.actions??e;return Array.isArray(t)?t:[]})(),c=(()=>{let t=vt(H),r=[];return t.edit&&(r.push({name:`sys_inline_edit`,label:j(`detail.editFieldsInline`,{defaultValue:`Edit fields`}),type:`script`,locations:[`record_header`],variant:`outline`,onClick:()=>{window.dispatchEvent(new CustomEvent(`objectui:record:inline-edit-toggle`,{detail:{recordId:U,objectName:T}}))}}),r.push({name:`sys_edit`,label:j(`detail.edit`,{defaultValue:`Edit`}),type:`script`,locations:[`record_header`],variant:`default`,onClick:()=>n({id:U})})),r.push({name:`sys_share`,label:j(`detail.share`,{defaultValue:`Share`}),type:`script`,locations:[`record_header`],variant:`outline`,onClick:async()=>{try{if(navigator.share){await navigator.share({title:document.title,url:window.location.href});return}}catch{return}try{await navigator.clipboard.writeText(window.location.href),P.success(j(`detail.linkCopied`,{defaultValue:`Link copied`}))}catch(e){P.error(j(`detail.linkCopyFailed`,{defaultValue:`Failed to copy link`})+(e?.message?`: ${e.message}`:``))}}}),t.delete&&r.push({name:`sys_delete`,label:j(`detail.delete`,{defaultValue:`Delete`}),type:`script`,locations:[`record_header`],variant:`destructive`,onClick:async()=>{let t=j(`detail.deleteConfirmation`,{defaultValue:`Are you sure you want to delete this record?`});if(window.confirm(t))try{await e.delete(T,U),P.success(j(`detail.deleted`,{defaultValue:`Record deleted`})),k(`${w?`/apps/${w}`:``}/${T}`,{replace:!0})}catch(e){P.error(e?.message||`Delete failed`)}}}),r})(),l=s.length>0?s:void 0,u=Array.isArray($.related)?$.related.filter(e=>e?.api&&e?.referenceField).map(e=>({title:e.title,objectName:e.api,relationshipField:e.referenceField,...Array.isArray(e.columns)?{columns:e.columns}:{},...typeof e.pageSize==`number`?{limit:e.pageSize}:{},...e.icon?{icon:e.icon}:{}})):void 0,h=$.history?{entries:$.history.entries??[],loading:!!$.history.loading,emptyText:$.history.emptyText}:void 0,g=G?q:Pe(H,{sections:$.sections,highlightFields:Array.isArray($.highlightFields)?$.highlightFields.map(e=>typeof e==`string`?e:e?.name).filter(e=>!!e):void 0,headerActions:l,related:u,history:h,...K?{slots:K}:{}});return(0,I.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,I.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[Ke.length>0&&(0,I.jsx)(mt,{users:Ke,size:`sm`,maxVisible:3,showStatus:!0}),(0,I.jsx)(Le,{managedBy:H?.managedBy})]}),(0,I.jsx)(m,{objectName:T,recordId:U,data:J,objectSchema:H,dataSource:e,embedded:x,headerSystemActions:c,isFavorite:qe,onToggleFavorite:W?Je:void 0,children:(0,I.jsx)(b,{children:(0,I.jsx)(p,{items:Se,onAddComment:Ot,onAddReply:kt,onToggleReaction:At,mentionSuggestions:N,children:(0,I.jsxs)(f,{context:{record:J||{},objectName:T,user:Q},onConfirm:st,onToast:ut,onNavigate:dt,onParamCollection:ct,onResultDialog:ot,onModal:pt,handlers:{api:ft,flow:_t,script:Ct,approval:Et},children:[(0,I.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,I.jsxs)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:[A?.pathname&&A?.label&&(0,I.jsxs)(o,{to:A.pathname,className:`inline-flex items-center gap-1 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,I.jsx)(ne,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{children:A.label})]}),(0,I.jsx)(d,{schema:g}),a&&(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsx)(Ie,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:Se,onAddComment:Ot,onAddReply:kt,onToggleReaction:At,mentionSuggestions:N})})]}),(0,I.jsx)(je,{open:D,sections:[{title:`Page Schema`,data:g}]})]}),ht]})})})}),(0,I.jsx)(xt,{state:et,onOpenChange:e=>{e||tt(e=>({...e,open:!1}))}}),(0,I.jsx)(St,{state:nt,onOpenChange:e=>{e||rt(e=>({...e,open:!1}))}}),(0,I.jsx)(wt,{state:it,onAcknowledge:()=>{it.resolve?.(),at({open:!1})}}),(0,I.jsx)(Pt,{state:ze,authFetch:Y,baseUrl:``,dataSource:e,objects:t,onClose:()=>R(null),onComplete:()=>{R(null),L(e=>e+1)}})]})}return(0,I.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,I.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[Ke.length>0&&(0,I.jsx)(mt,{users:Ke,size:`sm`,maxVisible:3,showStatus:!0}),(0,I.jsx)(Le,{managedBy:H?.managedBy})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,I.jsx)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[1400px]`,children:(0,I.jsxs)(f,{context:{record:{},objectName:T,user:Q},onConfirm:st,onToast:ut,onNavigate:dt,onParamCollection:ct,onResultDialog:ot,onModal:pt,handlers:{api:ft,flow:_t,script:Ct,approval:Et},children:[(0,I.jsx)(Me,{schema:$,dataSource:e,objectLabel:re({name:H.name,label:H.label}),isFavorite:qe,onToggleFavorite:W?Je:void 0,onDataLoaded:e=>{if(!e||typeof e!=`object`)return;let t=y(H,e);t&&t!==V&&t!==`Untitled`&&Ge(t)},onEdit:()=>{n({id:U})},discussionSlot:(0,I.jsx)(Ie,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:Se,onAddComment:Ot,onAddReply:kt,onToggleReaction:At})},we),ht]})})}),(0,I.jsx)(je,{open:D,sections:[{title:`View Schema`,data:$}]})]}),(0,I.jsx)(xt,{state:et,onOpenChange:e=>{e||tt(e=>({...e,open:!1}))}}),(0,I.jsx)(St,{state:nt,onOpenChange:e=>{e||rt(e=>({...e,open:!1}))}}),(0,I.jsx)(wt,{state:it,onAcknowledge:()=>{it.resolve?.(),at({open:!1})}}),(0,I.jsx)(Pt,{state:ze,authFetch:Y,baseUrl:``,dataSource:e,objects:t,onClose:()=>R(null),onComplete:()=>{R(null),L(e=>e+1)}})]})}export{ze as _,Mt as a,wt as c,vt as d,Y as f,it as g,at as h,Pt as i,St as l,ut as m,Rt as n,jt as o,mt as p,Lt as r,$ as s,Gt as t,xt as u,R as v};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,p as i,r as a,t as o,u as s}from"./vendor-react-slxo-5GC.js";import{f as c}from"./infrastructure-BySW-NB0.js";import{M as l,a as u,j as d,kt as f}from"./framework-WZr4krBC.js";import{Cr as p,G as m,K as h,Lc as g,Tc as _,Y as v,is as y}from"./ui-components-BTSIX9CP.js";import{r as b}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-DVX_k0gB.js";import{t as x}from"./plugin-form-CUnJuXVB.js";import"./MetadataProvider-Cu56xdi9.js";import{n as S,t as C}from"./ExpressionProvider-DGF3MugJ.js";import{t as w}from"./ManagedByBadge-CDDSvYHn.js";import{t as T}from"./skeletons-DQtGqEIo.js";var E=t({RecordFormPage:()=>k}),D=e(n(),1),O=o();function k({mode:e}){let{appName:t,objectName:n,recordId:o}=r(),E=s(),[k]=i(),A=d(),{objects:j,loading:M}=l(),{t:N}=u(),{objectLabel:P}=g(),{user:F,getAuthConfig:I}=c(),[L,R]=(0,D.useState)({});(0,D.useEffect)(()=>{let e=!1;return I().then(t=>{e||R(t?.features??{})}).catch(()=>{}),()=>{e=!0}},[I]);let z=(0,D.useMemo)(()=>{if(e!==`create`)return;let t=[];for(let[e,n]of k.entries())e&&n&&t.push([e,n]);return t.length>0?Object.fromEntries(t):void 0},[e,k.toString()]),B=(0,D.useMemo)(()=>j.find(e=>e.name===n),[j,n]),V=`/apps/${t}`,H=`${V}/${n}`,U=e===`edit`&&o?`${V}/${n}/record/${encodeURIComponent(o)}`:H,W=(0,D.useCallback)(()=>{typeof window<`u`&&window.history.length>1?E(-1):E(U,{replace:!0})},[E,U]),G=B?P(B):n??``,K=e===`create`?N(`form.createTitle`,{object:G,defaultValue:`New ${G}`}):N(`form.editTitle`,{object:G,defaultValue:`Edit ${G}`}),q=(0,D.useCallback)(()=>{b.success(e===`create`?N(`form.createSuccess`,{object:G,defaultValue:`${G} created successfully`}):N(`form.updateSuccess`,{object:G,defaultValue:`${G} updated successfully`})),W()},[e,N,G,W]),J=(0,D.useCallback)(()=>{W()},[W]),Y=(0,D.useMemo)(()=>F?{name:F.name,email:F.email,role:F.role??`user`}:{name:`Anonymous`,email:``,role:`guest`},[F]),X=(0,D.useMemo)(()=>new f({user:Y,app:{name:t},data:{}}),[Y,t]),Z=(0,D.useMemo)(()=>B?.fields?Array.isArray(B.fields)?B.fields.filter(e=>typeof e==`string`?!0:S(e.visible,X)).map(e=>typeof e==`string`?e:e.name):Object.entries(B.fields).filter(([,e])=>S(e.visible,X)).map(([e])=>e):[],[B,X]);if(M)return(0,O.jsx)(T,{});if(!B)return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,O.jsxs)(m,{children:[(0,O.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,O.jsx)(y,{className:`h-6 w-6 text-muted-foreground`})}),(0,O.jsx)(v,{children:N(`empty.objectNotFound`)}),(0,O.jsx)(h,{children:N(`empty.objectNotFoundDescription`,{name:n})}),(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsxs)(p,{variant:`outline`,onClick:()=>E(V),children:[(0,O.jsx)(_,{className:`mr-2 h-4 w-4`}),N(`empty.back`)]})})]})});let Q=B.form??B.formViews?.default??{},$=[`tabbed`,`wizard`,`split`].includes(Q.type)?Q.type:`simple`,ee=$!==`simple`&&Array.isArray(Q.sections)?{sections:Q.sections,defaultTab:Q.defaultTab,tabPosition:Q.tabPosition,allowSkip:Q.allowSkip,showStepIndicator:Q.showStepIndicator,splitDirection:Q.splitDirection,splitSize:Q.splitSize,splitResizable:Q.splitResizable}:{};return(0,O.jsx)(C,{user:Y,app:{name:t},data:{},features:L,children:(0,O.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,"data-testid":`record-form-page`,"data-mode":e,children:[(0,O.jsxs)(`header`,{className:`sticky top-0 z-10 flex items-center gap-3 border-b bg-background px-4 py-3 sm:px-6`,children:[(0,O.jsx)(p,{variant:`ghost`,size:`sm`,onClick:W,"data-testid":`record-form-page-back`,"aria-label":N(`common.back`,{defaultValue:`Back`}),children:(0,O.jsx)(_,{className:`h-4 w-4`})}),(0,O.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(a,{to:H,className:`hover:text-foreground transition-colors`,children:G}),(0,O.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,O.jsx)(`span`,{className:`text-foreground font-medium`,"data-testid":`record-form-page-title`,children:K}),(0,O.jsx)(w,{managedBy:B?.managedBy,className:`ml-1`})]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl`,children:(0,O.jsx)(x,{schema:{type:`object-form`,formType:$,...ee,objectName:B.name,mode:e,recordId:e===`edit`?o:void 0,...z&&{initialValues:z},title:K,description:e===`create`?N(`form.createDescription`,{object:G,defaultValue:`Create a new ${G}.`}):N(`form.editDescription`,{object:G,defaultValue:`Edit this ${G}.`}),layout:`vertical`,fields:Z,subforms:B.form?.subforms??B.formViews?.default?.subforms,onSuccess:q,onCancel:J,showSubmit:!0,showCancel:!0,submitText:N(`form.saveRecord`,{defaultValue:`Save`}),cancelText:N(`common.cancel`,{defaultValue:`Cancel`})},dataSource:A??void 0},`${e}:${n}:${o??`new`}`)})})]})})}export{E as t};
|