@objectstack/console 9.3.0 → 9.5.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/assets/AdapterProvider-SUUXFZyj.js +1 -0
- package/dist/assets/{AiPendingActionsPage-Y9r83gqj.js → AiPendingActionsPage-CO8ZvJjv.js} +1 -1
- package/dist/assets/ApiConsolePage-Lut37HSM.js +1 -0
- package/dist/assets/AppDocsIndex-pApFrxYy.js +1 -0
- package/dist/assets/{AppManagementPage-0JEALVYK.js → AppManagementPage-02_IDuK5.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-jrOq7K_-.js +1 -0
- package/dist/assets/{AuditLogPage-CXhNSVOU.js → AuditLogPage-dNTjEy4d.js} +1 -1
- package/dist/assets/{ComponentNavView-BI4O_zkC.js → ComponentNavView-DZTCPZQw.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-aVi2RipX.js +1 -0
- package/dist/assets/DashboardView-tRpQP3s_.js +1 -0
- package/dist/assets/DashboardWidgetInspector-BZXT2waT.js +1 -0
- package/dist/assets/{DeveloperHubPage-D-UigRUA.js → DeveloperHubPage-D1Gr8nhZ.js} +1 -1
- package/dist/assets/ExpressionProvider-w-i3oDR9.js +1 -0
- package/dist/assets/FlowRunsPage-CntX-tGf.js +1 -0
- package/dist/assets/{IntegrationsPage-DsWyxKR6.js → IntegrationsPage-BoWdvbMh.js} +2 -2
- package/dist/assets/InterfaceListPage-CtbkRAlr.js +1 -0
- package/dist/assets/ManagedByBadge-BYezQxs4.js +1 -0
- package/dist/assets/MarketplaceInstalledPage-CuPkbetm.js +1 -0
- package/dist/assets/MarketplacePackagePage-CKJ_NEnI.js +4 -0
- package/dist/assets/MarketplacePage-BTGE5DuS.js +1 -0
- package/dist/assets/MetadataInspector-eUKibp4P.js +1 -0
- package/dist/assets/MetadataProvider-DVGxIr-Y.js +1 -0
- package/dist/assets/PageView-CoZhWVVc.js +1 -0
- package/dist/assets/ProfilePage-qRetxYIs.js +1 -0
- package/dist/assets/PublicFormsPage-Cpy38W-9.js +1 -0
- package/dist/assets/{RecentItemsProvider-DiJIrHwK.js → RecentItemsProvider-gLV-GFpQ.js} +1 -1
- package/dist/assets/RecordDetailView-CD05ObAk.js +1 -0
- package/dist/assets/RecordFormPage-OOn5fyVq.js +1 -0
- package/dist/assets/ReportDefaultInspector--g5afStS.js +1 -0
- package/dist/assets/ReportView-w6a1FyHp.js +2 -0
- package/dist/assets/RuntimeDraftBar-e5TgPCLp.js +1 -0
- package/dist/assets/SearchResultsPage-B2D6vns1.js +1 -0
- package/dist/assets/{SettingsHub-B4oSx4ed.js → SettingsHub-Bi06edK0.js} +1 -1
- package/dist/assets/SettingsView-zJInYHeN.js +1 -0
- package/dist/assets/{SystemHubPage-Di6eqozE.js → SystemHubPage-DV53wHHA.js} +1 -1
- package/dist/assets/appRoute-D5vwtoc_.js +1 -0
- package/dist/assets/architecture-7EHR7CIX-BdMnUPE0.js +1 -0
- package/dist/assets/architectureDiagram-3BPJPVTR-SscyJlk0.js +36 -0
- package/dist/assets/blockDiagram-GPEHLZMM-D6-9deBJ.js +132 -0
- package/dist/assets/c4Diagram-AAUBKEIU-VLeNt7tD.js +10 -0
- package/dist/assets/channel-ByUUDCyR.js +1 -0
- package/dist/assets/chunk-2J33WTMH-DyXQVMuc.js +1 -0
- package/dist/assets/chunk-3OPIFGDE-3g0dk_di.js +62 -0
- package/dist/assets/chunk-4BX2VUAB-BpAZJ7ZC.js +1 -0
- package/dist/assets/chunk-55IACEB6-BhOjfCrn.js +1 -0
- package/dist/assets/chunk-5ZQYHXKU-DG12s6lW.js +2 -0
- package/dist/assets/chunk-727SXJPM-DwSFE_v-.js +206 -0
- package/dist/assets/chunk-AQP2D5EJ-DWgSztUW.js +231 -0
- package/dist/assets/chunk-BSJP7CBP-okvguKD4.js +1 -0
- package/dist/assets/chunk-CSCIHK7Q-DfSAlgJl.js +124 -0
- package/dist/assets/chunk-FMBD7UC4-CZzqt4RW.js +15 -0
- package/dist/assets/chunk-KSCS5N6A-IxEh4Ag5.js +10 -0
- package/dist/assets/chunk-L5ZTLDWV-DW1lPBoG.js +1 -0
- package/dist/assets/chunk-LZXEDZCA-C_-aaYcd.js +1 -0
- package/dist/assets/chunk-ND2GUHAM-C1toj0H3.js +1 -0
- package/dist/assets/chunk-NNHCCRGN-Ud6GGuM7.js +159 -0
- package/dist/assets/chunk-NZK2D7GU-H2MwBqQV.js +1 -0
- package/dist/assets/chunk-O5CBEL6O-BzyWPZhZ.js +70 -0
- package/dist/assets/chunk-QZHKN3VN-ujroCBCz.js +1 -0
- package/dist/assets/chunk-WU5MYG2G-DwQt8tuZ.js +1 -0
- package/dist/assets/chunk-XPW4576I-DPNxFY7Q.js +32 -0
- package/dist/assets/classDiagram-4FO5ZUOK-B7mTyEXp.js +1 -0
- package/dist/assets/classDiagram-v2-Q7XG4LA2-B7mTyEXp.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-HKJWDQRL.js +1 -0
- package/dist/assets/cytoscape.esm-h6BdjjI9.js +321 -0
- package/dist/assets/dagre-BM42HDAG-CU8nx02l.js +4 -0
- package/dist/assets/dagre-Bx709z4p.js +1 -0
- package/dist/assets/data-adapter-BEs3zHWP.js +1 -0
- package/dist/assets/diagram-2AECGRRQ-CormMz8j.js +43 -0
- package/dist/assets/diagram-5GNKFQAL-Dh1SagBx.js +10 -0
- package/dist/assets/diagram-KO2AKTUF-DcG6Z05V.js +3 -0
- package/dist/assets/diagram-LMA3HP47-DrVLZ6ZE.js +24 -0
- package/dist/assets/diagram-OG6HWLK6-C4_MMUc2.js +24 -0
- package/dist/assets/dist-Cna34lZe.js +1 -0
- package/dist/assets/erDiagram-TEJ5UH35-BZH_OrBL.js +85 -0
- package/dist/assets/eventmodeling-FCH6USID-CFiyy8DS.js +1 -0
- package/dist/assets/flowDiagram-I6XJVG4X-CnjHQUK0.js +162 -0
- package/dist/assets/{framework-crD8qZlm.js → framework-BSpP7C0B.js} +11 -11
- package/dist/assets/ganttDiagram-6RSMTGT7-rVbHlqzo.js +292 -0
- package/dist/assets/gitGraph-WXDBUCRP-9vsQCBlr.js +1 -0
- package/dist/assets/gitGraphDiagram-PVQCEYII-CH2LgClA.js +106 -0
- package/dist/assets/graphlib-B8gBHxth.js +1 -0
- package/dist/assets/{highlighted-body-OFNGDK62-B3OlR_Nx.js → highlighted-body-OFNGDK62-BgGi60U1.js} +1 -1
- package/dist/assets/index-QQUFI17s.js +4 -0
- package/dist/assets/index-mrmp6qU6.css +2 -0
- package/dist/assets/info-J43DQDTF-CfWeH1Bg.js +1 -0
- package/dist/assets/infoDiagram-5YYISTIA-CRC7ojj-.js +2 -0
- package/dist/assets/infrastructure-ckitl7Ev.js +3 -0
- package/dist/assets/ishikawaDiagram-YF4QCWOH-8v73fBR1.js +70 -0
- package/dist/assets/journeyDiagram-JHISSGLW-DbRK-WaU.js +139 -0
- package/dist/assets/kanban-definition-UN3LZRKU-BggLxHvZ.js +89 -0
- package/dist/assets/katex-Vhh-h91d.js +257 -0
- package/dist/assets/marketplaceApi-C2Xs-8x9.js +1 -0
- package/dist/assets/mergeServerFields-C7bGC7hp.js +7 -0
- package/dist/assets/mermaid-GHXKKRXX-DpdgSEiY.js +1 -0
- package/dist/assets/mermaid-parser.core-iuxcj-n_.js +3 -0
- package/dist/assets/mermaid.core-C41Aiku8.js +8 -0
- package/dist/assets/metadata-admin-B5BnMMNz.js +19 -0
- package/dist/assets/mindmap-definition-RKZ34NQL-kqhi9XCR.js +96 -0
- package/dist/assets/packet-YPE3B663-C0xexAqH.js +1 -0
- package/dist/assets/pie-LRSECV5Y-DbQVOiyX.js +1 -0
- package/dist/assets/pieDiagram-4H26LBE5-9fHcPmFE.js +30 -0
- package/dist/assets/plugin-calendar-DqouTXvx.js +1 -0
- package/dist/assets/plugin-charts-Bg-32_xO.js +7 -0
- package/dist/assets/plugin-chatbot-1Bip2OCu.js +120 -0
- package/dist/assets/plugin-dashboard-bF8okIBS.js +5 -0
- package/dist/assets/plugin-form-DkI3TvRN.js +1 -0
- package/dist/assets/plugin-gantt-iFmeqHwf.js +23 -0
- package/dist/assets/plugin-grid-KSDSYH4h.js +6 -0
- package/dist/assets/plugin-kanban-CecteZ3L.js +1 -0
- package/dist/assets/{plugin-map-C8Jxhxs1.js → plugin-map-DD9uSXB0.js} +1 -1
- package/dist/assets/plugin-markdown-BR56zxrV.js +113 -0
- package/dist/assets/plugin-report-KJw4u9x7.js +59 -0
- package/dist/assets/plugin-timeline-D8Lkn6Qk.js +1 -0
- package/dist/assets/plugin-view-DJrJBUdE.js +1 -0
- package/dist/assets/plugins-views-BhPRkeWo.js +4 -0
- package/dist/assets/quadrantDiagram-W4KKPZXB-CaMxia_k.js +7 -0
- package/dist/assets/radar-GUYGQ44K-DapGfmwo.js +1 -0
- package/dist/assets/requirementDiagram-4Y6WPE33-CXwY4Gdd.js +84 -0
- package/dist/assets/resolveActionParams-C1HIbU1j.js +9 -0
- package/dist/assets/rough.esm-CSKSodPl.js +1 -0
- package/dist/assets/runtime-config-BeHVOPm3.js +1 -0
- package/dist/assets/sankeyDiagram-5OEKKPKP-KEb3hSPZ.js +40 -0
- package/dist/assets/sequenceDiagram-3UESZ5HK-BfbOOh3M.js +162 -0
- package/dist/assets/skeletons-qACAXjbp.js +1 -0
- package/dist/assets/src-CVz7aDdY.js +1 -0
- package/dist/assets/{src-Tw2eleSi.js → src-CZAP7E6v.js} +1 -1
- package/dist/assets/stateDiagram-AJRCARHV-BLJI6xj_.js +1 -0
- package/dist/assets/stateDiagram-v2-BHNVJYJU-DPQJ1_JB.js +1 -0
- package/dist/assets/timeline-definition-PNZ67QCA-aiklZXLq.js +120 -0
- package/dist/assets/treeView-BLDUP644-Byr_7ESV.js +1 -0
- package/dist/assets/treemap-LRROVOQU-B6DiJnlo.js +1 -0
- package/dist/assets/{types-BkFEpiv3.js → types-CW2d8LfD.js} +1 -1
- package/dist/assets/ui-components-D7IOmcqZ.js +42 -0
- package/dist/assets/{ui-layout-KICrO2Oe.js → ui-layout-toYvxCNh.js} +1 -1
- package/dist/assets/useActionModal-yawBu4nr.js +1 -0
- package/dist/assets/usePackageL10n-shLsxEAx.js +1 -0
- package/dist/assets/utils-bipVuqQL.js +1 -0
- package/dist/assets/vendor-charts-fo4ZbB_t.js +39 -0
- package/dist/assets/vendor-i18n-Bz5UncqE.js +1 -0
- package/dist/assets/vendor-markdown-DIJxJfmj.js +46 -0
- package/dist/assets/vennDiagram-CIIHVFJN-DsKC4yvC.js +34 -0
- package/dist/assets/wardley-L42UT6IY-f1iiSYpj.js +1 -0
- package/dist/assets/wardleyDiagram-YWT4CUSO-DbrUmWlY.js +78 -0
- package/dist/assets/xychartDiagram-2RQKCTM6-B4biX1Sz.js +7 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ApiConsolePage-Dwbms0Zh.js +0 -1
- package/dist/assets/ApprovalsInboxPage-B-drSsxQ.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-CiODZIcp.js +0 -1
- package/dist/assets/FlowRunsPage-_UeeNdBc.js +0 -1
- package/dist/assets/ProfilePage-T27zVrMO.js +0 -1
- package/dist/assets/PublicFormsPage-Pd453sW6.js +0 -1
- package/dist/assets/SettingsView-CkQEI5DW.js +0 -1
- package/dist/assets/assistantBus-B-xBT6j1.js +0 -1
- package/dist/assets/data-adapter-3AJO7A2o.js +0 -1
- package/dist/assets/index-Cf7NsvAk.css +0 -2
- package/dist/assets/index-CiI7zDDo.js +0 -32
- package/dist/assets/infrastructure-CxityHZF.js +0 -3
- package/dist/assets/mergeServerFields-DUkbynPg.js +0 -7
- package/dist/assets/mermaid-GHXKKRXX-CBocchJ2.js +0 -1
- package/dist/assets/plugin-calendar-ed7RoEFF.js +0 -1
- package/dist/assets/plugin-charts-QabQJ_NJ.js +0 -7
- package/dist/assets/plugin-chatbot-Cy3tiXkg.js +0 -120
- package/dist/assets/plugin-dashboard-PA0xf59v.js +0 -5
- package/dist/assets/plugin-form-BABEMaum.js +0 -1
- package/dist/assets/plugin-gantt-BNjfLkTR.js +0 -1
- package/dist/assets/plugin-grid-BxyuFeJP.js +0 -6
- package/dist/assets/plugin-kanban-D4yCkUn_.js +0 -1
- package/dist/assets/plugin-markdown-CR5TpghH.js +0 -7
- package/dist/assets/plugin-report-rz8HUIsi.js +0 -59
- package/dist/assets/plugin-timeline-DQHQwtdw.js +0 -1
- package/dist/assets/plugin-view-BykLknWa.js +0 -1
- package/dist/assets/plugins-views-CBO5qxO-.js +0 -4
- package/dist/assets/runtime-config-ir5bt3TX.js +0 -1
- package/dist/assets/ui-components-BrY5joKQ.js +0 -42
- package/dist/assets/vendor-charts-DAigH0Ti.js +0 -39
- package/dist/assets/vendor-i18n-CdF5ccW5.js +0 -1
- package/dist/assets/vendor-markdown-C9mPywRm.js +0 -38
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-NNHCCRGN-Ud6GGuM7.js";import{h as e}from"./mermaid-parser.core-iuxcj-n_.js";export{e as createInfoServices};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./mermaid-parser.core-iuxcj-n_.js";import{n as t,r as n}from"./src-CVz7aDdY.js";import{c as r}from"./chunk-CSCIHK7Q-DfSAlgJl.js";import{t as i}from"./chunk-WU5MYG2G-DwQt8tuZ.js";var a={parse:t(async t=>{let r=await e(`info`,t);n.debug(r)},`parse`)},o={version:`11.15.0`},s={parser:a,db:{getVersion:t(()=>o.version,`getVersion`)},renderer:{draw:t((e,t,a)=>{n.debug(`rendering info diagram
|
|
2
|
+
`+e);let o=i(t);r(o,100,400,!0),o.append(`g`).append(`text`).attr(`x`,100).attr(`y`,40).attr(`class`,`version`).attr(`font-size`,32).style(`text-anchor`,`middle`).text(`v${a}`)},`draw`)}};export{s as diagram};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";var r=e(t(),1),i=(0,r.createContext)(null);i.displayName=`AuthContext`;var a=`1.6.15`,o=Symbol.for(`better-auth:broadcast-channel`),s=()=>Math.floor(Date.now()/1e3),c=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(!(typeof window>`u`))try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:s()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event!==`session`||!t?.data||this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function l(e=`better-auth.message`){return globalThis[o]||(globalThis[o]=new c(e)),globalThis[o]}var u=Symbol.for(`better-auth:focus-manager`),d=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function f(){return globalThis[u]||(globalThis[u]=new d),globalThis[u]}var p=Symbol.for(`better-auth:online-manager`),m=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function h(){return globalThis[p]||(globalThis[p]=new m),globalThis[p]}var g={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},_=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,v={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},y=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function b(e){return e instanceof Date&&!isNaN(e.getTime())}function x(e){let t=y.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return b(f)?f:null}function S(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in v)return v[s];if(!_.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(g).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=x(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function C(e,t={strict:!0}){return S(e,t)}var w=[],T=0,E=4,ee=globalThis.nanostoresGlobal||={epoch:0},D=e=>{let t=[],n={get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{for(let t=T+E;t<w.length;)w[t]===e?w.splice(t,E):t+=E;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){ee.epoch++;let i=!w.length;for(let i of t)w.push(i,n.value,e,r);if(i){for(T=0;T<w.length;T+=E)w[T](w[T+1],w[T+2],w[T+3]);w.length=0}},off(){},set(e){let t=n.value;t!==e&&(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},te=5,O=6,k=10,ne=(e,t,n,r)=>(e.events=e.events||{},e.events[n+k]||(e.events[n+k]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);r.splice(i,1),r.length||(delete e.events[n],e.events[n+k](),delete e.events[n+k])}),re=1e3,A=(e,t)=>ne(e,n=>{let r=t(n);r&&e.events[O].push(r)},te,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[O]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[O])t();e.events[O]=[]}},re)},()=>{e.listen=n,e.off=r}}),ie=()=>typeof window>`u`,j=(e,t,n,r)=>{let i=D({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>a(e)}),a=async e=>new Promise(a=>{let o=typeof r==`function`?r({data:i.get().data,error:i.get().error,isPending:i.get().isPending}):r;n(t,{...o,query:{...o?.query,...e?.query},async onSuccess(e){i.set({data:e.data,error:null,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onSuccess?.(e)},async onError(e){let{request:t}=e,n=typeof t.retry==`number`?t.retry:t.retry?.attempts,r=t.retryAttempt||0;if(n&&r<n)return;let a=e.error.status===401;i.set({error:e.error,data:a?null:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onError?.(e)},async onRequest(e){let t=i.get();i.set({isPending:t.data===null,data:t.data,error:null,isRefetching:!0,refetch:i.value.refetch}),await o?.onRequest?.(e)}}).catch(e=>{i.set({error:e,data:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}).finally(()=>{a(void 0)})});e=Array.isArray(e)?e:[e];let o=!1;for(let t of e)t.subscribe(async()=>{ie()||(o?await a():A(i,()=>{let e=setTimeout(async()=>{o||(o=!0,await a())},0);return()=>{i.off(),t.off(),clearTimeout(e)}}))});return i},M=()=>Math.floor(Date.now()/1e3);function N(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}var P=5;function ae(e){let{sessionAtom:t,sessionSignal:n,$fetch:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={lastSync:0,lastSessionRequest:0,cachedSession:void 0},u=()=>s||h().isOnline,d=e=>{if(!u())return;if(e?.event===`storage`){c.lastSync=M(),n.set(!n.get());return}let i=t.get(),a=()=>{c.lastSessionRequest=M(),r(`/get-session`).then(async e=>{let{data:a,error:o}=N(e);if(a?.needsRefresh)try{let e=await r(`/get-session`,{method:`POST`});({data:a,error:o}=N(e))}catch{}let s=a?.session&&a?.user?a:null;t.set({...i,data:s,error:o}),c.lastSync=M(),n.set(!n.get())}).catch(()=>{})};if(e?.event===`poll`){a();return}if(e?.event===`visibilitychange`){if(M()-c.lastSessionRequest<P)return;c.lastSessionRequest=M()}if(e?.event===`visibilitychange`){a();return}(i?.data===null||i?.data===void 0)&&(c.lastSync=M(),n.set(!n.get()))},p=e=>{l().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},m=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{t.get()?.data&&d({event:`poll`})},a*1e3))},g=()=>{c.unsubscribeBroadcast=l().subscribe(()=>{d({event:`storage`})})},_=()=>{o&&(c.unsubscribeFocus=f().subscribe(()=>{d({event:`visibilitychange`})}))},v=()=>{c.unsubscribeOnline=h().subscribe(e=>{e&&d({event:`visibilitychange`})})};return{init:()=>{m(),g(),_(),v(),l().setup(),f().setup(),h().setup()},cleanup:()=>{c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.lastSync=0,c.lastSessionRequest=0,c.cachedSession=void 0},triggerRefetch:d,broadcastSessionUpdate:p}}var F=Object.create(null),I=e=>({}),L=new Proxy(F,{get(e,t){return I()[t]??F[t]},has(e,t){return t in I()||t in F},set(e,t,n){let r=I(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=I(!0);return delete n[t],!0},ownKeys(){let e=I(!0);return Object.keys(e)}});function R(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return R(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return R(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return R(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return R(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return R(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return R(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return R(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function oe(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}function se(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function ce(e){let t=e.split(`
|
|
2
|
+
at `);return t.length<=1?e:(t.splice(1,1),t.join(`
|
|
3
|
+
at `))}function le(e,t){class n extends e{#e;constructor(...e){if(se()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=ce(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var ue={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};le(class extends Error{constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:ue[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var z=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},de=47;function B(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===de;)t--;return t===e.length?e:e.slice(0,t)}function fe(e){try{return(B(new URL(e).pathname)||`/`)!==`/`}catch{throw new z(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function pe(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new z(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof z?t:new z(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function V(e,t=`/api/auth`){if(pe(e),fe(e))return e;let n=B(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function H(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function me(e,t,n,r,i){if(e)return V(e,t);if(r!==!1){let e=L.BETTER_AUTH_URL||L.NEXT_PUBLIC_BETTER_AUTH_URL||L.PUBLIC_BETTER_AUTH_URL||L.NUXT_PUBLIC_BETTER_AUTH_URL||L.NUXT_PUBLIC_AUTH_URL||(L.BASE_URL===`/`?void 0:L.BASE_URL);if(e)return V(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&H(o,`proto`)&&H(a,`host`))try{return V(`${o}://${a}`,t)}catch{}if(n){let e=he(n.url);if(!e)throw new z(`Could not get origin from request. Please provide a valid base URL.`);return V(e,t)}if(typeof window<`u`&&window.location)return V(window.location.origin,t)}function he(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var ge=[`javascript:`,`data:`,`vbscript:`];function _e(e){let t;try{t=new URL(e)}catch{return!0}return!ge.includes(t.protocol)}var ve={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&_e(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function ye(e,t){let n=D(!1),r=j(n,`/get-session`,e,{method:`GET`}),i=()=>{};return A(r,()=>{let a=ae({sessionAtom:r,sessionSignal:n,$fetch:e,options:t});return a.init(),i=a.broadcastSessionUpdate,()=>{a.cleanup()}}),{session:r,$sessionSignal:n,broadcastSessionUpdate:e=>i(e)}}function be(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function xe(e,t,n=`.`,r){if(!be(t))return xe(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(Array.isArray(a)&&Array.isArray(i[t])?i[t]=[...a,...i[t]]:be(a)&&be(i[t])?i[t]=xe(a,i[t],(n?`${n}.`:``)+t.toString(),r):i[t]=a))}return i}function Se(e){return(...t)=>t.reduce((t,n)=>xe(t,n,``,e),{})}var Ce=Se(),we=Object.defineProperty,Te=Object.defineProperties,Ee=Object.getOwnPropertyDescriptors,De=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable,Ae=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,U=(e,t)=>{for(var n in t||={})Oe.call(t,n)&&Ae(e,n,t[n]);if(De)for(var n of De(t))ke.call(t,n)&&Ae(e,n,t[n]);return e},W=(e,t)=>Te(e,Ee(t)),je=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},Me=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let r=await i.init?.call(i,e.toString(),t);n=r.options||n,e=r.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},Ne=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Pe=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Fe(e){if(typeof e==`number`)return new Ne({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new Ne(e);case`exponential`:return new Pe(e);default:throw Error(`Invalid retry strategy`)}}var Ie=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},Le=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Re(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return Le.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function ze(e){try{return JSON.parse(e),!0}catch{return!1}}function Be(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function Ve(e){try{return JSON.parse(e)}catch{return e}}function He(e){return typeof e==`function`}function Ue(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&He(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&He(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}async function We(e){let t=new Headers(e?.headers),n=await Ie(e);for(let[e,r]of Object.entries(n||{}))t.set(e,r);if(!t.has(`content-type`)){let n=Ge(e?.body);n&&t.set(`content-type`,n)}return t}function Ge(e){return Be(e)?`application/json`:null}function Ke(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(Be(e.body)&&!t.has(`content-type`)){for(let[t,n]of Object.entries(e?.body))n instanceof Date&&(e.body[t]=n.toISOString());return JSON.stringify(e.body)}return t.has(`content-type`)&&t.get(`content-type`)===`application/x-www-form-urlencoded`&&Be(e.body)?new URLSearchParams(e.body).toString():e.body}function qe(e,t){if(t?.method)return t.method.toUpperCase();if(e.startsWith(`@`)){let n=e.split(`@`)[1]?.split(`/`)[0];return Xe.includes(n)?n.toUpperCase():t?.body?`POST`:`GET`}return t?.body?`POST`:`GET`}function Je(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Ye=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function G(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Ye(n.issues);return n.value}var Xe=[`get`,`post`,`put`,`patch`,`delete`],Ze=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){let r=e.plugins?.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1)?.schema||e.schema;if(r){let e=t;r.config?.prefix&&e.startsWith(r.config.prefix)&&(e=e.replace(r.config.prefix,``),r.config.baseURL&&(t=t.replace(r.config.prefix,r.config.baseURL))),r.config?.baseURL&&e.startsWith(r.config.baseURL)&&(e=e.replace(r.config.baseURL,``));let i=r.schema[e];if(i){let e=W(U({},n),{method:i.method,output:i.output});return n?.disableValidation||(e=W(U({},e),{body:i.input?await G(i.input,n?.body):n?.body,params:i.params?await G(i.params,n?.params):n?.params,query:i.query?await G(i.query,n?.query):n?.query})),{url:t,options:e}}}return{url:t,options:n}}}),Qe=e=>{async function t(t,n){let r=W(U(U({},e),n),{plugins:[...e?.plugins||[],Ze(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await et(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await et(t,r)}return t};function $e(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``;if(e.startsWith(`@`)){let t=e.toString().split(`@`)[1].split(`/`)[0];Xe.includes(t)&&(e=e.replace(`@${t}/`,`/`))}a.endsWith(`/`)||(a+=`/`);let[o,s]=e.replace(a,``).split(`?`),c=new URLSearchParams(s);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)c.append(e,n);continue}else n=JSON.stringify(t);c.set(e,n)}if(r)if(Array.isArray(r)){let e=o.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];o=o.replace(n,e)}}else for(let[e,t]of Object.entries(r))o=o.replace(`:${e}`,String(t));o=o.split(`/`).map(encodeURIComponent).join(`/`),o.startsWith(`/`)&&(o=o.slice(1));let l=c.toString();return l=l.length>0?`?${l}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${o}${l}`,a):`${a}${o}${l}`}var et=async(e,t)=>{let{hooks:n,url:r,options:i}=await Me(e,t),a=Ue(i),o=new AbortController,s=i.signal??o.signal,c=$e(r,i),l=Ke(i),u=await We(i),d=qe(r,i),f=W(U({},i),{url:c,headers:u,body:l,method:d,signal:s});for(let e of n.onRequest)if(e){let t=await e(f);typeof t==`object`&&t&&(f=t)}(`pipeTo`in f&&typeof f.pipeTo==`function`||typeof t?.body?.pipe==`function`)&&(`duplex`in f||(f.duplex=`half`));let{clearTimeout:p}=Je(i,o),m=await a(f.url,f);p();let h={response:m,request:f};for(let e of n.onResponse)if(e){let n=await e(W(U({},h),{response:t?.hookOptions?.cloneResponse?m.clone():m}));n instanceof Response?m=n:typeof n==`object`&&n&&(m=n.response)}if(m.ok){if(f.method===`HEAD`)return{data:``,error:null};let e=Re(m),r={data:null,response:m,request:f};if(e===`json`||e===`text`){let e=await m.text();r.data=await(f.jsonParser??Ve)(e)}else r.data=await m[e]();f?.output&&f.output&&!f.disableValidation&&(r.data=await G(f.output,r.data));for(let e of n.onSuccess)e&&await e(W(U({},r),{response:t?.hookOptions?.cloneResponse?m.clone():m}));return t?.throw?r.data:{data:r.data,error:null}}let g=t?.jsonParser??Ve,_=await m.text(),v=ze(_),y=v?await g(_):null,b={response:m,responseText:_,request:f,error:W(U({},y),{status:m.status,statusText:m.statusText})};for(let e of n.onError)e&&await e(W(U({},b),{response:t?.hookOptions?.cloneResponse?m.clone():m}));if(t?.retry){let r=Fe(t.retry),i=t.retryAttempt??0;if(await r.shouldAttemptRetry(i,m)){for(let e of n.onRetry)e&&await e(h);let a=r.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await et(e,W(U({},t),{retryAttempt:i+1}))}}if(t?.throw)throw new je(m.status,m.statusText,v?y:_);return{data:null,error:W(U({},y),{status:m.status,statusText:m.statusText})}},tt=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},nt=(e,t)=>{let n=`credentials`in Request.prototype,r=me(e?.baseURL,e?.basePath,void 0,t)??tt(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=Qe({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?C(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[ve],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=ye(d,e),h=e?.plugins||[],g={},_={$sessionSignal:f,session:p},v={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},y=[{signal:`$sessionSignal`,matcher(e){return e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`},callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of h)e.getAtoms&&Object.assign(_,e.getAtoms?.(d)),e.pathMethods&&Object.assign(v,e.pathMethods),e.atomListeners&&y.push(...e.atomListeners);let b={notify:e=>{_[e].set(!_[e].get())},listen:(e,t)=>{_[e].subscribe(t)},atoms:_};for(let t of h)t.getActions&&(g=Ce(t.getActions?.(d,b,e)??{},g));return{get baseURL(){return r},pluginsActions:g,pluginsAtoms:_,pluginPathMethods:v,atomListeners:y,$fetch:d,$store:b}};function rt(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function it(e){return e.charAt(0).toUpperCase()+e.slice(1)}var at=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,ot=/['\u2019]/g;function st(e){return e.replace(ot,``).match(at)??[]}function ct(e){return st(e).map(e=>e.toLowerCase()).join(`-`)}function lt(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function ut(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||rt(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(ct).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=lt(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function dt(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,$fetch:i,atomListeners:a,$store:o}=nt(e),s={};for(let[e,t]of Object.entries(r))s[`use${it(e)}`]=t;return ut({...n,...s,$fetch:i,$store:o},i,t,r,a)}function ft(e){return{authorize(t,n=`AND`){let r=!1;for(let[i,a]of Object.entries(t)){let t=e[i];if(!t){if(n===`AND`)return{success:!1,error:`You are not allowed to access resource: ${i}`};r=!1;continue}if(Array.isArray(a))r=a.length>0&&a.every(e=>t.includes(e));else if(typeof a==`object`){let e=a;r=!Array.isArray(e.actions)||e.actions.length===0?!1:e.connector===`OR`?e.actions.some(e=>t.includes(e)):e.actions.every(e=>t.includes(e))}else throw new z(`Invalid access control request`);if(r&&n===`OR`)return{success:r};if(!r&&n===`AND`)return{success:!1,error:`unauthorized to access resource "${i}"`}}return r?{success:r}:{success:!1,error:`Not authorized`}},statements:e}}function pt(e){return{newRole(e){return ft(e)},statements:e}}var mt=oe({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:`You are not allowed to create a new organization`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:`You have reached the maximum number of organizations`,ORGANIZATION_ALREADY_EXISTS:`Organization already exists`,ORGANIZATION_SLUG_ALREADY_TAKEN:`Organization slug already taken`,ORGANIZATION_NOT_FOUND:`Organization not found`,USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:`User is not a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:`You are not allowed to update this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:`You are not allowed to delete this organization`,NO_ACTIVE_ORGANIZATION:`No active organization`,USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:`User is already a member of this organization`,MEMBER_NOT_FOUND:`Member not found`,ROLE_NOT_FOUND:`Role not found`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:`You are not allowed to create a new team`,TEAM_ALREADY_EXISTS:`Team already exists`,TEAM_NOT_FOUND:`Team not found`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:`You cannot leave the organization as the only owner`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:`You cannot leave the organization without an owner`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:`You are not allowed to delete this member`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:`You are not allowed to invite users to this organization`,USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:`User is already invited to this organization`,INVITATION_NOT_FOUND:`Invitation not found`,YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:`You are not the recipient of the invitation`,EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:`Email verification required before accepting or rejecting invitation`,EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION:`Email verification required to view or list invitations for the session email`,YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:`You are not allowed to cancel this invitation`,INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:`Inviter is no longer a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:`You are not allowed to invite a user with this role`,FAILED_TO_RETRIEVE_INVITATION:`Failed to retrieve invitation`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:`You have reached the maximum number of teams`,UNABLE_TO_REMOVE_LAST_TEAM:`Unable to remove last team`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:`You are not allowed to update this member`,ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:`Organization membership limit reached`,YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to create teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to delete teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:`You are not allowed to update this team`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:`You are not allowed to delete this team`,INVITATION_LIMIT_REACHED:`Invitation limit reached`,TEAM_MEMBER_LIMIT_REACHED:`Team member limit reached`,USER_IS_NOT_A_MEMBER_OF_THE_TEAM:`User is not a member of the team`,YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:`You are not allowed to list the members of this team`,YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:`You do not have an active team`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:`You are not allowed to create a new member`,YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:`You are not allowed to remove a team member`,YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:`You are not allowed to access this organization as an owner`,YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:`You are not a member of this organization`,MISSING_AC_INSTANCE:`Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information`,YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:`You must be in an organization to create a role`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:`You are not allowed to create a role`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:`You are not allowed to update a role`,YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:`You are not allowed to delete a role`,YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:`You are not allowed to read a role`,YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:`You are not allowed to list a role`,YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:`You are not allowed to get a role`,TOO_MANY_ROLES:`This organization has too many roles`,INVALID_RESOURCE:`The provided permission includes an invalid resource`,ROLE_NAME_IS_ALREADY_TAKEN:`That role name is already taken`,CANNOT_DELETE_A_PRE_DEFINED_ROLE:`Cannot delete a pre-defined role`,ROLE_IS_ASSIGNED_TO_MEMBERS:`Cannot delete a role that is assigned to members. Please reassign the members to a different role first`,INVALID_TEAM_ID:`Team id contains a reserved character`}),ht=pt({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),gt=ht.newRole({organization:[`update`],invitation:[`create`,`cancel`],member:[`create`,`update`,`delete`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),_t=ht.newRole({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),vt=ht.newRole({organization:[],member:[],invitation:[],team:[],ac:[`read`]}),yt={admin:gt,owner:_t,member:vt},bt=(e,t)=>{if(!e.permissions)return!1;let n=e.role.split(`,`),r=e.options.creatorRole||`owner`,i=n.includes(r),a=e.allowCreatorAllPermissions||!1;if(i&&a)return!0;for(let r of n)if(t[r]?.authorize(e.permissions)?.success)return!0;return!1},xt=e=>bt(e,e.options.roles||yt),St=e=>{let t=D(!1),n=D(!1),r=D(!1),i=D(!1),o={admin:gt,member:vt,owner:_t,...e?.roles};return{id:`organization`,version:a,$InferServerPlugin:{},getActions:(t,n,r)=>({$Infer:{ActiveOrganization:{},Organization:{},Invitation:{},Member:{},Team:{}},organization:{checkRolePermission:t=>xt({role:t.role,options:{ac:e?.ac,roles:o},permissions:t.permissions})}}),getAtoms:e=>{let a=j(t,`/organization/list`,e,{method:`GET`});return{$listOrg:t,$activeOrgSignal:n,$activeMemberSignal:r,$activeMemberRoleSignal:i,activeOrganization:j([n],`/organization/get-full-organization`,e,()=>({method:`GET`})),listOrganizations:a,activeMember:j([n,r],`/organization/get-active-member`,e,{method:`GET`}),activeMemberRole:j([n,i],`/organization/get-active-member-role`,e,{method:`GET`})}},pathMethods:{"/organization/get-full-organization":`GET`,"/organization/list-user-teams":`GET`},atomListeners:[{matcher(e){return e===`/organization/create`||e===`/organization/delete`||e===`/organization/update`},signal:`$listOrg`},{matcher(e){return e===`/sign-out`||e.startsWith(`/organization`)},signal:`$activeOrgSignal`},{matcher(e){return e.startsWith(`/organization/set-active`)||e===`/organization/create`||e===`/organization/delete`||e===`/organization/remove-member`||e===`/organization/leave`||e===`/organization/accept-invitation`},signal:`$sessionSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberRoleSignal`}],$ERROR_CODES:mt}},Ct=`auth-session-token`,K={_memoryToken:null,get(){try{if(typeof localStorage<`u`)return localStorage.getItem(Ct)}catch{}return this._memoryToken},set(e){this._memoryToken=e;try{typeof localStorage<`u`&&localStorage.setItem(Ct,e)}catch{}},clear(){this._memoryToken=null;try{typeof localStorage<`u`&&localStorage.removeItem(Ct)}catch{}}};function wt(e){let t=Error(e.message??`Auth request failed with status ${e.status}`);return e.code&&(t.code=e.code),t}function Tt(e){try{let t=new URL(e);return{origin:t.origin,basePath:t.pathname.replace(/\/$/,``)}}catch{return{origin:Et()??`http://localhost`,basePath:e.replace(/\/$/,``)}}}function Et(){try{if(typeof window<`u`&&window.location?.origin)return window.location.origin}catch{}}function Dt(){try{if(typeof document<`u`){let e=document.querySelector(`base`)?.getAttribute(`href`);if(e)return`${new URL(e,Et()??`http://localhost`).pathname.replace(/\/$/,``)}/reset-password`}}catch{}return`/reset-password`}function Ot(e){let t=e||globalThis.fetch.bind(globalThis);return async(e,n)=>{let r=new Headers(n?.headers),i=K.get();if(i){let t=typeof e==`string`?e:e instanceof URL?e.href:e.url;/\/api\//i.test(t)&&r.set(`Authorization`,`Bearer ${i}`)}let a=await t(e,{...n,headers:r}),o=a.headers.get(`set-auth-token`);return o&&K.set(o),a}}function kt(e){let{baseURL:t,fetchFn:n}=e,{origin:r,basePath:i}=Tt(t),a=Ot(n),o=dt({baseURL:r,basePath:i,disableDefaultFetchPlugins:!0,fetchOptions:{customFetchImpl:a},plugins:[St()]});return{async signIn(e){let{data:t,error:n}=await o.signIn.email({email:e.email,password:e.password});if(n)throw wt(n);let r=t;return r.session?.token&&K.set(r.session.token),{user:r.user,session:r.session}},async signUp(e){let{data:t,error:n}=await o.signUp.email({email:e.email,password:e.password,name:e.name});if(n)throw wt(n);let r=t,i=r.token??r.session?.token??null;i&&K.set(i);let a=r.session??null;return!a&&i&&(a={token:i}),{user:r.user,session:a,requiresVerification:i===null}},async sendVerificationEmail(e,t){let{error:n}=await o.sendVerificationEmail({email:e,callbackURL:t});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`)},async signOut(){let{error:e}=await o.signOut();if(K.clear(),e)throw Error(e.message??`Auth request failed with status ${e.status}`)},async getSession(){let e=null;try{let t=await o.getSession();t.error||(e=t.data)}catch{}if(e){let t=e;return t.session?.token&&K.set(t.session.token),{user:t.user,session:t.session}}if(K.get())try{let e=await(n||globalThis.fetch.bind(globalThis))(`${r}${i}/get-session`,{method:`GET`,credentials:`include`,headers:{"Content-Type":`application/json`}});if(e.ok){let t=await e.json().catch(()=>null);if(t?.user&&t?.session)return t.session.token?K.set(t.session.token):K.clear(),{user:t.user,session:t.session};K.clear()}}catch{}return null},async forgotPassword(e){let t=o,n=t.requestPasswordReset??t.forgetPassword;if(typeof n!=`function`)throw Error(`password reset is not available on this auth backend`);let{error:r}=await n({email:e,redirectTo:Dt()});if(r)throw Error(r.message??`Auth request failed with status ${r.status}`)},async resetPassword(e,t){let{error:n}=await o.resetPassword({token:e,newPassword:t});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`)},async changePassword(e,t,n){let r=o.changePassword;if(typeof r!=`function`)throw Error(`change-password is not available on this auth backend`);let{error:i}=await r({currentPassword:e,newPassword:t,...n?.revokeOtherSessions==null?{}:{revokeOtherSessions:n.revokeOtherSessions}});if(i)throw Error(i.message??`Auth request failed with status ${i.status}`)},async setInitialPassword(e){let t=await a(`${r}${i}/set-initial-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newPassword:e})});if(!t.ok){let e=`Set password failed with status ${t.status}`;try{let n=await t.json();n?.error?.message&&(e=n.error.message)}catch{}throw Error(e)}},async hasLocalPassword(){let e=`${r}${i}/list-accounts`;try{let t=await a(e,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!t.ok)return!1;let n=await t.json();return(Array.isArray(n)?n:n&&`data`in n&&Array.isArray(n.data)?n.data:[]).some(e=>e?.providerId===`credential`)}catch{return!1}},async updateUser(e){let{data:t,error:n}=await o.updateUser(e);if(n)throw Error(n.message??`Auth request failed with status ${n.status}`);if(!t)throw Error(`Update user returned no data`);let r=t;return r&&typeof r==`object`&&`user`in r?r.user:r},async getConfig(){let e=await a(`${r}${i}/config`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`Failed to load auth config (status ${e.status})`);let t=await e.json();return t&&typeof t==`object`&&`data`in t&&t.data?t.data:t},async signInWithProvider(e,t={}){let{type:n=`social`,callbackURL:r,errorCallbackURL:i}=t;if(n===`oidc`){let t=o.signIn.oauth2;if(!t)throw Error(`OIDC sign-in is not supported by this auth client build`);let{data:n,error:a}=await t({providerId:e,callbackURL:r,errorCallbackURL:i});if(a)throw Error(a.message??`Auth request failed with status ${a.status}`);n?.url&&typeof window<`u`&&(window.location.href=n.url);return}let{data:a,error:s}=await o.signIn.social({provider:e,callbackURL:r,errorCallbackURL:i});if(s)throw Error(s.message??`Auth request failed with status ${s.status}`);let c=a?.url;c&&typeof window<`u`&&(window.location.href=c)},async listOrganizations(){let{data:e,error:t}=await o.organization.list();if(t)throw Error(t.message??`Failed to list organizations`);return e??[]},async createOrganization(e){let{data:t,error:n}=await o.organization.create({name:e.name,slug:e.slug,logo:e.logo});if(n)throw Error(n.message??`Failed to create organization`);return t},async setActiveOrganization(e){let{data:t,error:n}=await o.organization.setActive({organizationId:e});if(n)throw Error(n.message??`Failed to set active organization`);return t??null},async getActiveOrganization(){let{data:e,error:t}=await o.organization.getFullOrganization();return t||!e?null:e},async getActiveMember(){let e=o.organization?.getActiveMember;if(typeof e!=`function`)return null;let{data:t,error:n}=await e();return n||!t?null:t},async getMembers(e){let{data:t,error:n}=await o.organization.listMembers({query:{organizationId:e}});if(n)throw Error(n.message??`Failed to get members`);let r=t;return Array.isArray(r)?r:r?.members??[]},async inviteMember(e){let{data:t,error:n}=await o.organization.inviteMember({organizationId:e.organizationId,email:e.email,role:e.role});if(n)throw Error(n.message??`Failed to invite member`);return t},async removeMember(e){let{error:t}=await o.organization.removeMember({organizationId:e.organizationId,memberIdOrUserId:e.memberIdOrUserId});if(t)throw Error(t.message??`Failed to remove member`)},async updateMemberRole(e){let{error:t}=await o.organization.updateMemberRole({organizationId:e.organizationId,memberId:e.memberId,role:e.role});if(t)throw Error(t.message??`Failed to update member role`)},async updateOrganization(e,t){let{data:n,error:r}=await o.organization.update({organizationId:e,data:t});if(r)throw Error(r.message??`Failed to update organization`);return n},async deleteOrganization(e){let{error:t}=await o.organization.delete({organizationId:e});if(t)throw Error(t.message??`Failed to delete organization`)},async leaveOrganization(e){let{error:t}=await o.organization.leave({organizationId:e});if(t)throw Error(t.message??`Failed to leave organization`)},async listInvitations(e){let{data:t,error:n}=await o.organization.listInvitations({query:{organizationId:e}});if(n)throw Error(n.message??`Failed to list invitations`);return t??[]},async cancelInvitation(e){let{error:t}=await o.organization.cancelInvitation({invitationId:e});if(t)throw Error(t.message??`Failed to cancel invitation`)},async getInvitation(e){let{data:t,error:n}=await o.organization.getInvitation({query:{id:e}});if(n)throw Error(n.message??`Failed to load invitation`);return t},async acceptInvitation(e){let{error:t}=await o.organization.acceptInvitation({invitationId:e});if(t)throw Error(t.message??`Failed to accept invitation`)},async rejectInvitation(e){let{error:t}=await o.organization.rejectInvitation({invitationId:e});if(t)throw Error(t.message??`Failed to reject invitation`)},async listUserInvitations(){let{data:e,error:t}=await o.organization.listUserInvitations();if(t)throw Error(t.message??`Failed to list invitations`);return e??[]}}}var At=`auth-active-organization-id`,q={_memoryValue:null,get(){try{if(typeof localStorage<`u`)return localStorage.getItem(At)}catch{}return this._memoryValue},set(e){this._memoryValue=e;try{typeof localStorage<`u`&&localStorage.setItem(At,e)}catch{}},clear(){this._memoryValue=null;try{typeof localStorage<`u`&&localStorage.removeItem(At)}catch{}}};function jt(){return async(e,t)=>{let n=new Headers(t?.headers),r=typeof e==`string`?e:e instanceof URL?e.href:e.url,i=/\/api\//i.test(r),a=K.get();a&&i&&n.set(`Authorization`,`Bearer ${a}`);let o=q.get();if(o&&n.set(`X-Tenant-ID`,o),i&&!n.has(`Accept-Language`)&&typeof document<`u`){let e=document.documentElement.lang;e&&n.set(`Accept-Language`,e)}return fetch(e,{...t,headers:n})}}var J=n();function Mt({authUrl:e,client:t,onAuthStateChange:n,enabled:a=!0,previewMode:o,children:s}){let c=(0,r.useMemo)(()=>t??kt({baseURL:e}),[t,e]),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(null),[p,m]=(0,r.useState)(!0),[h,g]=(0,r.useState)(null),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(null),[x,S]=(0,r.useState)(null),[C,w]=(0,r.useState)(!1),T=o!=null,E=a&&!T?l!==null&&d!==null:!0;(0,r.useEffect)(()=>{if(T){let e=o.simulatedRole??`admin`,t=o.simulatedUserName??`Preview User`,n=o.expiresInSeconds??0;u({id:`preview-user`,email:`preview@preview.local`,name:t,role:e,roles:[e]}),f({token:`preview-token`,expiresAt:n>0?new Date(Date.now()+n*1e3):new Date(Date.now()+365*24*60*60*1e3)}),m(!1);return}if(!a){u({id:`guest`,email:`guest@local`,name:`Guest User`,role:`admin`}),f({token:`guest-token`,expiresAt:new Date(Date.now()+365*24*60*60*1e3)}),m(!1);return}let e=!1;async function t(){try{let t=await c.getSession();if(e)return;t&&(u(t.user),f(t.session))}catch(t){if(e)return;g(t instanceof Error?t:Error(String(t)))}finally{e||m(!1)}}return t(),()=>{e=!0}},[c,a,T,o]),(0,r.useEffect)(()=>{n?.({user:l,session:d,isAuthenticated:E,isLoading:p,error:h})},[l,d,E,p,h,n]);let ee=(0,r.useCallback)(async(e,t)=>{m(!0),g(null);try{let n=await c.signIn({email:e,password:t});u(n.user),f(n.session)}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}finally{m(!1)}},[c]),D=(0,r.useCallback)(async(e,t,n)=>{m(!0),g(null);try{let r=await c.signUp({name:e,email:t,password:n});return r.requiresVerification?{requiresVerification:!0}:(u(r.user),f(r.session),{requiresVerification:!1})}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}finally{m(!1)}},[c]),te=(0,r.useCallback)(async()=>{m(!0);try{await c.signOut(),u(null),f(null),g(null)}catch(e){g(e instanceof Error?e:Error(String(e)))}finally{m(!1)}},[c]),O=(0,r.useCallback)(async e=>{g(null);try{u(await c.updateUser(e))}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),k=(0,r.useCallback)(async e=>{g(null);try{await c.forgotPassword(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),ne=(0,r.useCallback)(async(e,t)=>{g(null);try{await c.sendVerificationEmail(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),re=(0,r.useCallback)(async(e,t)=>{g(null);try{await c.resetPassword(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),A=(0,r.useCallback)(async(e,t,n)=>{g(null);try{await c.changePassword(e,t,n)}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),ie=(0,r.useCallback)(async e=>{g(null);try{await c.setInitialPassword(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),j=(0,r.useCallback)(()=>c.hasLocalPassword(),[c]),M=(0,r.useCallback)(()=>c.getConfig(),[c]),N=(0,r.useCallback)(async(e,t)=>{g(null);try{await c.signInWithProvider(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),P=(0,r.useCallback)(async()=>{if(!(!a||T)){w(!0);try{let e=await c.listOrganizations();if(v(e),e.length>0&&!y)try{let e=await c.getActiveOrganization();e&&(b(e),q.set(e.id))}catch{}}catch(e){console.warn(`[AuthProvider] Failed to load organizations:`,e)}finally{w(!1)}}},[c,a,T,y]),ae=(0,r.useCallback)(async()=>{if(!a||T){let e=T?o?.simulatedRole??`admin`:`admin`;S({id:`preview-member`,organizationId:y?.id??`preview-org`,userId:`preview-user`,role:e});return}if(!y){S(null);return}try{S(await c.getActiveMember())}catch(e){console.warn(`[AuthProvider] Failed to load active member:`,e),S(null)}},[c,a,T,o,y]);(0,r.useEffect)(()=>{ae()},[ae]),(0,r.useEffect)(()=>{l&&a&&!T&&P()},[l,a,T]);let F=(0,r.useCallback)(async e=>{g(null);try{let t=await c.setActiveOrganization(e);b(t),t?q.set(t.id):q.clear()}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c]),I=(0,r.useCallback)(async e=>{g(null);try{let t=await c.createOrganization(e);return await P(),await F(t.id),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c,P,F]),L=(0,r.useCallback)(async(e,t)=>{let n=await c.updateOrganization(e,t);return await P(),y?.id===e&&b(n),n},[c,P,y]),R=(0,r.useCallback)(async e=>{await c.deleteOrganization(e),y?.id===e&&(b(null),q.clear()),await P()},[c,y,P]),oe=(0,r.useCallback)(async e=>{await c.leaveOrganization(e),y?.id===e&&(b(null),q.clear()),await P()},[c,y,P]),se=(0,r.useCallback)(e=>c.getMembers(e),[c]),ce=(0,r.useCallback)(e=>c.inviteMember(e),[c]),le=(0,r.useCallback)(e=>c.removeMember(e),[c]),ue=(0,r.useCallback)(e=>c.updateMemberRole(e),[c]),z=(0,r.useCallback)(e=>c.listInvitations(e),[c]),de=(0,r.useCallback)(e=>c.cancelInvitation(e),[c]),B=(0,r.useCallback)(e=>c.getInvitation(e),[c]),fe=(0,r.useCallback)(async e=>{await c.acceptInvitation(e),await P()},[c,P]),pe=(0,r.useCallback)(e=>c.rejectInvitation(e),[c]),V=(0,r.useCallback)(()=>c.listUserInvitations(),[c]),H=a&&!T,me=(0,r.useMemo)(()=>({user:l,session:d,isAuthenticated:E,isAuthEnabled:H,isLoading:p,error:h,isPreviewMode:T,previewMode:T?o:null,signIn:ee,signUp:D,signOut:te,updateUser:O,forgotPassword:k,sendVerificationEmail:ne,resetPassword:re,changePassword:A,setInitialPassword:ie,hasLocalPassword:j,getAuthConfig:M,signInWithProvider:N,organizations:_,activeOrganization:y,activeMember:x,isOrganizationsLoading:C,switchOrganization:F,createOrganization:I,refreshOrganizations:P,updateOrganization:L,deleteOrganization:R,leaveOrganization:oe,getMembers:se,inviteMember:ce,removeMember:le,updateMemberRole:ue,listInvitations:z,cancelInvitation:de,getInvitation:B,acceptInvitation:fe,rejectInvitation:pe,listUserInvitations:V}),[l,d,E,H,p,h,T,o,ee,D,te,O,k,ne,re,A,ie,j,M,N,_,y,x,C,F,I,P,L,R,oe,se,ce,le,ue,z,de,B,fe,pe,V]);return(0,J.jsx)(i.Provider,{value:me,children:s})}function Y(){return(0,r.useContext)(i)||{user:null,session:null,isAuthenticated:!1,isAuthEnabled:!1,isLoading:!1,error:null,isPreviewMode:!1,previewMode:null,signIn:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signUp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signOut:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateUser:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},forgotPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},sendVerificationEmail:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},resetPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},changePassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},setInitialPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},hasLocalPassword:async()=>!1,getAuthConfig:async()=>({}),signInWithProvider:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},organizations:[],activeOrganization:null,activeMember:null,isOrganizationsLoading:!1,switchOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},createOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},refreshOrganizations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},deleteOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},leaveOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},getMembers:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},inviteMember:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},removeMember:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateMemberRole:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},listInvitations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},cancelInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},getInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},acceptInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},rejectInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},listUserInvitations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)}}}var Nt=new Set([`owner`,`admin`,`super_admin`,`superadmin`,`platform_admin`,`system_admin`]);function Pt(e){return typeof e==`string`&&Nt.has(e.toLowerCase())}function Ft(){let{activeMember:e,user:t}=Y();return!!(Pt(e?.role)||Pt(t?.role)||Array.isArray(t?.roles)&&t.roles.some(Pt))}function It({fallback:e=null,requiredRoles:t,loadingFallback:n,children:r}){let{isAuthenticated:i,isLoading:a,user:o}=Y();if(a)return(0,J.jsx)(J.Fragment,{children:n??null});if(!i)return(0,J.jsx)(J.Fragment,{children:e});if(t&&t.length>0&&o){let n=o.roles??(o.role?[o.role]:[]);if(!t.some(e=>n.includes(e)))return(0,J.jsx)(J.Fragment,{children:e})}return(0,J.jsx)(J.Fragment,{children:r})}var Lt={google:`Google`,github:`GitHub`,microsoft:`Microsoft`,apple:`Apple`,facebook:`Facebook`,twitter:`Twitter`,discord:`Discord`,gitlab:`GitLab`,linkedin:`LinkedIn`},Rt={google:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{fill:`#EA4335`,d:`M12 10.2v3.9h5.5c-.24 1.4-1.7 4.1-5.5 4.1-3.3 0-6-2.74-6-6.1s2.7-6.1 6-6.1c1.88 0 3.14.8 3.86 1.5l2.64-2.55C16.84 3.36 14.66 2.4 12 2.4 6.92 2.4 2.8 6.52 2.8 11.6S6.92 20.8 12 20.8c6.92 0 9.2-4.86 9.2-7.4 0-.5-.06-.88-.14-1.2H12z`})}),github:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{d:`M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56v-2.07c-3.2.7-3.87-1.37-3.87-1.37-.52-1.33-1.27-1.69-1.27-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.18 1.76 1.18 1.02 1.75 2.68 1.25 3.34.96.1-.74.4-1.25.73-1.54-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.18-3.1-.12-.29-.51-1.46.11-3.04 0 0 .97-.31 3.18 1.18a11.04 11.04 0 015.79 0c2.21-1.49 3.18-1.18 3.18-1.18.62 1.58.23 2.75.11 3.04.74.81 1.18 1.84 1.18 3.1 0 4.42-2.7 5.39-5.27 5.68.41.36.78 1.06.78 2.13v3.16c0 .31.21.68.8.56C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5z`})}),microsoft:(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:[(0,J.jsx)(`path`,{fill:`#F25022`,d:`M2 2h9.5v9.5H2z`}),(0,J.jsx)(`path`,{fill:`#7FBA00`,d:`M12.5 2H22v9.5h-9.5z`}),(0,J.jsx)(`path`,{fill:`#00A4EF`,d:`M2 12.5h9.5V22H2z`}),(0,J.jsx)(`path`,{fill:`#FFB900`,d:`M12.5 12.5H22V22h-9.5z`})]}),apple:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{d:`M16.37 12.55c-.02-2.27 1.85-3.36 1.94-3.42-1.06-1.55-2.71-1.76-3.3-1.79-1.4-.14-2.74.83-3.45.83-.71 0-1.81-.81-2.98-.79-1.53.02-2.95.89-3.74 2.27-1.6 2.77-.41 6.86 1.14 9.11.76 1.1 1.66 2.34 2.83 2.3 1.14-.05 1.57-.74 2.94-.74 1.37 0 1.76.74 2.96.71 1.22-.02 2-1.12 2.75-2.23.87-1.28 1.22-2.52 1.24-2.59-.03-.01-2.38-.91-2.4-3.66zM14.1 5.31c.62-.76 1.05-1.81.93-2.86-.9.04-2 .6-2.65 1.35-.58.66-1.1 1.74-.96 2.76 1.01.08 2.04-.51 2.68-1.25z`})}),facebook:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{fill:`#1877F2`,d:`M24 12C24 5.37 18.63 0 12 0S0 5.37 0 12c0 5.99 4.39 10.95 10.13 11.85V15.47H7.08V12h3.05V9.36c0-3.01 1.79-4.67 4.53-4.67 1.31 0 2.69.23 2.69.23v2.96h-1.51c-1.49 0-1.96.93-1.96 1.88V12h3.33l-.53 3.47h-2.8v8.38C19.61 22.95 24 17.99 24 12z`})}),twitter:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),discord:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{fill:`#5865F2`,d:`M20.32 4.37A19.79 19.79 0 0016.56 3l-.18.36a18.27 18.27 0 00-8.76 0L7.44 3a19.79 19.79 0 00-3.76 1.37C.99 8.4.27 12.34.63 16.22a19.94 19.94 0 006.07 3.07l.49-.7a13.2 13.2 0 01-2.07-.99c.17-.13.34-.27.5-.41a14.13 14.13 0 0012.76 0c.16.14.33.28.5.41-.66.4-1.36.73-2.07.99l.49.7a19.92 19.92 0 006.07-3.07c.43-4.5-.66-8.41-2.95-11.85zM8.52 14.12c-1.18 0-2.15-1.08-2.15-2.41 0-1.33.95-2.42 2.15-2.42 1.2 0 2.17 1.09 2.15 2.42 0 1.33-.96 2.41-2.15 2.41zm6.96 0c-1.18 0-2.15-1.08-2.15-2.41 0-1.33.95-2.42 2.15-2.42 1.2 0 2.17 1.09 2.15 2.42 0 1.33-.95 2.41-2.15 2.41z`})}),gitlab:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{fill:`#FC6D26`,d:`M23.6 9.6L23.57 9.5 20.3.81a.84.84 0 00-1.6.05L16.5 7.6H7.5L5.3.86a.84.84 0 00-1.6-.05L.43 9.5l-.03.1a5.84 5.84 0 001.94 6.74l.01.01.03.02 4.8 3.6 2.38 1.8 1.45 1.1a1 1 0 001.2 0l1.45-1.1 2.38-1.8 4.83-3.62.01-.01a5.84 5.84 0 001.93-6.74z`})}),linkedin:(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{fill:`#0A66C2`,d:`M20.45 20.45h-3.55v-5.57c0-1.33-.02-3.04-1.85-3.04-1.85 0-2.13 1.45-2.13 2.94v5.67H9.36V9h3.41v1.56h.05c.48-.9 1.64-1.85 3.37-1.85 3.6 0 4.27 2.37 4.27 5.45v6.29zM5.34 7.43a2.06 2.06 0 11.01-4.13 2.06 2.06 0 010 4.13zM7.12 20.45H3.56V9h3.56v11.45zM22.22 0H1.77C.79 0 0 .77 0 1.72v20.56C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.72V1.72C24 .77 23.2 0 22.22 0z`})})};function zt({id:e}){let t=Rt[e];return t?(0,J.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center`,children:t}):(0,J.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center rounded-sm bg-muted text-[10px] font-bold uppercase`,children:e[0]})}function Bt({mode:e=`sign-in`,callbackURL:t,errorCallbackURL:n,dividerText:i=`or continue with email`,onProvidersResolved:a}){let{getAuthConfig:o,signInWithProvider:s}=Y(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)(!0),[f,p]=(0,r.useState)(null);if((0,r.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>o()).then(t=>{if(e)return;let n=(t?.socialProviders??[]).filter(e=>e.enabled);l(n),a?.(n.length>0)}).catch(t=>{e||(console.warn(`[SocialSignInButtons] failed to load auth config`,t),a?.(!1))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[o]),u||c.length===0)return null;let m=e===`sign-in`?`Continue with`:`Sign up with`,h=typeof window<`u`?window.location.href:void 0,g=async e=>{p(null);try{await s(e.id,{callbackURL:t??h,errorCallbackURL:n??t??h,type:e.type??`social`})}catch(e){p(e instanceof Error?e.message:String(e))}};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[f&&(0,J.jsx)(`div`,{className:`rounded-md bg-destructive/15 p-3 text-sm text-destructive`,role:`alert`,children:f}),c.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>g(e),className:`inline-flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,children:[(0,J.jsx)(zt,{id:e.id}),m,` `,Lt[e.id]??e.name]},e.id)),(0,J.jsxs)(`div`,{className:`relative my-1`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,J.jsx)(`span`,{className:`w-full border-t`})}),(0,J.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,J.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:i})})]})]})}var X=`flex h-11 w-full rounded-lg border border-input bg-background px-3.5 py-2 text-sm shadow-sm ring-offset-background transition-colors placeholder:text-muted-foreground hover:border-primary/40 focus-visible:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50`,Z=`inline-flex h-11 w-full items-center justify-center gap-2 rounded-lg bg-gradient-to-r from-primary to-primary/85 px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm ring-offset-background transition-[box-shadow,background-color,transform] hover:shadow-md hover:from-primary hover:to-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 active:scale-[0.99] disabled:pointer-events-none disabled:opacity-60 motion-reduce:transition-none motion-reduce:active:transform-none`,Q=`text-sm font-medium leading-none text-foreground`;function Vt(){return(0,J.jsxs)(`svg`,{className:`h-4 w-4 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,J.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,J.jsx)(`path`,{className:`opacity-90`,d:`M4 12a8 8 0 018-8`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`})]})}function Ht({className:e}){return(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e??`h-4 w-4 shrink-0`,"aria-hidden":`true`,children:[(0,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,J.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,J.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}function Ut({className:e}){return(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e??`h-7 w-7`,"aria-hidden":`true`,children:[(0,J.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`}),(0,J.jsx)(`path`,{d:`m22 6-10 7L2 6`})]})}function $({icon:e,title:t,description:n}){return(0,J.jsxs)(`div`,{className:`flex flex-col items-center space-y-3 text-center`,children:[e&&(0,J.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-primary/15`,children:e}),(0,J.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground sm:text-[1.6rem]`,children:t}),n&&(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:n})]})}function Wt({message:e}){return(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:[(0,J.jsx)(Ht,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`leading-snug`,children:e})]})}function Gt({label:e=`or`}){return(0,J.jsxs)(`div`,{className:`relative my-1`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center`,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{className:`w-full border-t border-border`})}),(0,J.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase tracking-wider`,children:(0,J.jsx)(`span`,{className:`bg-background px-3 text-muted-foreground`,children:e})})]})}var Kt=({href:e,className:t,children:n})=>(0,J.jsx)(`a`,{href:e,className:t,children:n}),qt=()=>(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:[(0,J.jsx)(`rect`,{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`}),(0,J.jsx)(`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`})]});function Jt({onSuccess:e,onError:t,registerUrl:n=`/register`,forgotPasswordUrl:i=`/forgot-password`,title:a=`Sign in to your account`,description:o=`Enter your email and password to continue`,icon:s,hideIcon:c=!1,linkComponent:l=Kt,labels:u={},errorMessages:d}){let{signIn:f,isLoading:p}=Y(),[m,h]=(0,r.useState)(``),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(null),[b,x]=(0,r.useState)(!1),S={emailLabel:u.emailLabel??`Email`,emailPlaceholder:u.emailPlaceholder??`name@example.com`,passwordLabel:u.passwordLabel??`Password`,passwordPlaceholder:u.passwordPlaceholder??`Enter your password`,forgotPasswordText:u.forgotPasswordText??`Forgot password?`,submitButton:u.submitButton??`Sign In`,submittingButton:u.submittingButton??`Signing in…`,noAccountText:u.noAccountText??`Don't have an account?`,signUpText:u.signUpText??`Sign up`,orText:u.orText??`or`};return(0,J.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,J.jsx)($,{icon:c?void 0:s??(0,J.jsx)(qt,{}),title:a,description:o}),(0,J.jsxs)(`div`,{className:`space-y-5`,children:[(0,J.jsx)(Bt,{mode:`sign-in`,onProvidersResolved:e=>x(e)}),(0,J.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),y(null);try{await f(m,g),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e)),r=n.code;y(r&&d?.[r]||n.message),t?.(n)}},className:`space-y-4`,children:[b&&(0,J.jsx)(Gt,{label:S.orText}),v&&(0,J.jsx)(Wt,{message:v}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`login-email`,className:Q,children:S.emailLabel}),(0,J.jsx)(`input`,{id:`login-email`,type:`email`,placeholder:S.emailPlaceholder,value:m,onChange:e=>h(e.target.value),required:!0,autoComplete:`email`,disabled:p,className:X})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`label`,{htmlFor:`login-password`,className:Q,children:S.passwordLabel}),i&&(0,J.jsx)(l,{href:i,className:`text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:S.forgotPasswordText})]}),(0,J.jsx)(`input`,{id:`login-password`,type:`password`,placeholder:S.passwordPlaceholder,value:g,onChange:e=>_(e.target.value),required:!0,autoComplete:`current-password`,disabled:p,className:X})]}),(0,J.jsxs)(`button`,{type:`submit`,disabled:p,className:Z,children:[p&&(0,J.jsx)(Vt,{}),p?S.submittingButton:S.submitButton]})]})]}),n&&(0,J.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[S.noAccountText,` `,(0,J.jsx)(l,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:S.signUpText})]})]})}var Yt=({href:e,className:t,children:n})=>(0,J.jsx)(`a`,{href:e,className:t,children:n}),Xt=()=>(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:[(0,J.jsx)(`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`}),(0,J.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,J.jsx)(`line`,{x1:`19`,y1:`8`,x2:`19`,y2:`14`}),(0,J.jsx)(`line`,{x1:`22`,y1:`11`,x2:`16`,y2:`11`})]});function Zt({onSuccess:e,onVerificationRequired:t,onError:n,loginUrl:i=`/login`,title:a=`Create an account`,description:o=`Enter your information to get started`,icon:s,hideIcon:c=!1,linkComponent:l=Yt,labels:u={},errorMessages:d}){let{signUp:f,isLoading:p}=Y(),[m,h]=(0,r.useState)(``),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(``),[S,C]=(0,r.useState)(null),[w,T]=(0,r.useState)(!1),E={nameLabel:u.nameLabel??`Name`,namePlaceholder:u.namePlaceholder??`John Doe`,emailLabel:u.emailLabel??`Email`,emailPlaceholder:u.emailPlaceholder??`name@example.com`,passwordLabel:u.passwordLabel??`Password`,passwordPlaceholder:u.passwordPlaceholder??`Create a password (min. 8 characters)`,confirmPasswordLabel:u.confirmPasswordLabel??`Confirm Password`,confirmPasswordPlaceholder:u.confirmPasswordPlaceholder??`Confirm your password`,passwordMismatchError:u.passwordMismatchError??`Passwords do not match`,passwordTooShortError:u.passwordTooShortError??`Password must be at least 8 characters`,submitButton:u.submitButton??`Create Account`,submittingButton:u.submittingButton??`Creating account…`,hasAccountText:u.hasAccountText??`Already have an account?`,signInText:u.signInText??`Sign in`,orText:u.orText??`or`};return(0,J.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,J.jsx)($,{icon:c?void 0:s??(0,J.jsx)(Xt,{}),title:a,description:o}),(0,J.jsxs)(`div`,{className:`space-y-5`,children:[(0,J.jsx)(Bt,{mode:`sign-up`,onProvidersResolved:e=>T(e)}),(0,J.jsxs)(`form`,{onSubmit:async r=>{if(r.preventDefault(),C(null),v!==b){C(E.passwordMismatchError);return}if(v.length<8){C(E.passwordTooShortError);return}try{if((await f(m,g,v))?.requiresVerification){t?.(g);return}e?.()}catch(e){let t=e instanceof Error?e:Error(String(e)),r=t.code;C(r&&d?.[r]||t.message),n?.(t)}},className:`space-y-4`,children:[w&&(0,J.jsx)(Gt,{label:E.orText}),S&&(0,J.jsx)(Wt,{message:S}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`register-name`,className:Q,children:E.nameLabel}),(0,J.jsx)(`input`,{id:`register-name`,type:`text`,placeholder:E.namePlaceholder,value:m,onChange:e=>h(e.target.value),required:!0,autoComplete:`name`,disabled:p,className:X})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`register-email`,className:Q,children:E.emailLabel}),(0,J.jsx)(`input`,{id:`register-email`,type:`email`,placeholder:E.emailPlaceholder,value:g,onChange:e=>_(e.target.value),required:!0,autoComplete:`email`,disabled:p,className:X})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`register-password`,className:Q,children:E.passwordLabel}),(0,J.jsx)(`input`,{id:`register-password`,type:`password`,placeholder:E.passwordPlaceholder,value:v,onChange:e=>y(e.target.value),required:!0,minLength:8,autoComplete:`new-password`,disabled:p,className:X})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`register-confirm-password`,className:Q,children:E.confirmPasswordLabel}),(0,J.jsx)(`input`,{id:`register-confirm-password`,type:`password`,placeholder:E.confirmPasswordPlaceholder,value:b,onChange:e=>x(e.target.value),required:!0,minLength:8,autoComplete:`new-password`,disabled:p,className:X})]}),(0,J.jsxs)(`button`,{type:`submit`,disabled:p,className:Z,children:[p&&(0,J.jsx)(Vt,{}),p?E.submittingButton:E.submitButton]})]})]}),i&&(0,J.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[E.hasAccountText,` `,(0,J.jsx)(l,{href:i,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:E.signInText})]})]})}var Qt=({href:e,className:t,children:n})=>(0,J.jsx)(`a`,{href:e,className:t,children:n}),$t=()=>(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:(0,J.jsx)(`path`,{d:`M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4`})});function en({onSuccess:e,onError:t,loginUrl:n=`/login`,title:i=`Reset your password`,description:a=`Enter your email address and we'll send you a link to reset your password`,icon:o,hideIcon:s=!1,linkComponent:c=Qt,labels:l={}}){let{forgotPassword:u,isLoading:d}=Y(),[f,p]=(0,r.useState)(``),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(!1),v={emailLabel:l.emailLabel??`Email`,emailPlaceholder:l.emailPlaceholder??`name@example.com`,submitButton:l.submitButton??`Send Reset Link`,submittingButton:l.submittingButton??`Sending…`,successTitle:l.successTitle??`Check your email`,successDescription:l.successDescription??`We've sent a password reset link to {{email}}. Please check your inbox.`,backToSignInText:l.backToSignInText??`Back to sign in`,rememberPasswordText:l.rememberPasswordText??`Remember your password?`,signInText:l.signInText??`Sign in`},y=async n=>{n.preventDefault(),h(null);try{await u(f),_(!0),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e));h(n.message),t?.(n)}};if(g){let e=v.successDescription.includes(`{{email}}`)?v.successDescription.replace(`{{email}}`,f):`${v.successDescription} ${f}`;return(0,J.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,J.jsx)($,{icon:(0,J.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-emerald-500/10 text-emerald-600 ring-1 ring-emerald-500/15 dark:text-emerald-400`,children:(0,J.jsx)(Ut,{})}),title:v.successTitle,description:e}),n&&(0,J.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:(0,J.jsxs)(c,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:[`← `,v.backToSignInText]})})]})}return(0,J.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,J.jsx)($,{icon:s?void 0:o??(0,J.jsx)($t,{}),title:i,description:a}),(0,J.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[m&&(0,J.jsx)(Wt,{message:m}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`forgot-email`,className:Q,children:v.emailLabel}),(0,J.jsx)(`input`,{id:`forgot-email`,type:`email`,placeholder:v.emailPlaceholder,value:f,onChange:e=>p(e.target.value),required:!0,autoComplete:`email`,disabled:d,className:X})]}),(0,J.jsxs)(`button`,{type:`submit`,disabled:d,className:Z,children:[d&&(0,J.jsx)(Vt,{}),d?v.submittingButton:v.submitButton]})]}),n&&(0,J.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[v.rememberPasswordText,` `,(0,J.jsx)(c,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:v.signInText})]})]})}function tn(e){return e?e.name?e.name.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2):e.email?.[0]?.toUpperCase()??`?`:`?`}function nn(e){if(!e)return!1;let t=e.objects;if(!t||typeof t!=`object`||Array.isArray(t))return!1;for(let e of Object.values(t))if(e&&typeof e==`object`&&!Array.isArray(e)&&`fields`in e)return!0;return!1}var rn=[`apps`,`messages`,`validationMessages`,`dashboards`,`globalActions`];function an(e){let t={},n={},r={},i=e.objects;if(i)for(let[e,a]of Object.entries(i)){if(!a||typeof a!=`object`)continue;let i={};a.label&&(i.label=a.label),a.pluralLabel&&(i.pluralLabel=a.pluralLabel),a.description&&(i.description=a.description);for(let[e,t]of Object.entries(a))e.startsWith(`_`)&&(i[e]=t);if(t[e]=i,a.fields&&typeof a.fields==`object`){let t=Object.entries(a.fields);for(let[i,a]of t)a?.label&&(n[e]||(n[e]={}),n[e][i]=a.label),a?.options&&typeof a.options==`object`&&Object.keys(a.options).length>0&&(r[e]||(r[e]={}),r[e][i]=a.options)}}let a={};Object.keys(t).length>0&&(a.objects=t),Object.keys(n).length>0&&(a.fields=n),Object.keys(r).length>0&&(a.fieldOptions=r);for(let t of rn)e[t]!==void 0&&(a[t]=e[t]);let o=new Set([`objects`,...rn]);for(let[t,n]of Object.entries(e))o.has(t)||(a[t]=n);return{app:a}}var on=(0,r.createContext)(null);on.displayName=`PermissionContext`;var sn=`/api/v1/auth/me/permissions`;function cn({endpoint:e=sn,initialPermissions:t,loadingFallback:n=null,errorFallback:i,children:a}){let[o,s]=(0,r.useState)(t??null),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!t),f=(0,r.useCallback)(async()=>{d(!0),l(null);try{let t=await fetch(e,{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Permissions endpoint returned ${t.status}`);s(await t.json())}catch(e){l(e instanceof Error?e:Error(String(e)))}finally{d(!1)}},[e]);(0,r.useEffect)(()=>{t||f()},[f,t]);let p=(0,r.useCallback)((e,t,n)=>{if(!o)return!1;let r=(e??``).toLowerCase(),i=`${r}.${t}`,a=o.fields?.[i]??o.fields?.[`${e}.${t}`];if(a)return n===`read`?a.readable!==!1:a.editable!==!1;let s=o.objects?.[r]??o.objects?.[e]??o.objects?.[`*`];return s?n===`read`?s.allowRead!==!1:s.allowEdit!==!1:!0},[o]),m=(0,r.useCallback)((e,t)=>{if(!o)return{allowed:!1,reason:`permissions-loading`};let n=o.objects?.[e]??o.objects?.[`*`],r={read:`allowRead`,view:`allowRead`,create:`allowCreate`,update:`allowEdit`,edit:`allowEdit`,delete:`allowDelete`}[t]??`allowRead`,i=n?n[r]!==!1:!0;return{allowed:i,reason:i?void 0:`denied-by-permission-set`}},[o]),h=(0,r.useCallback)(e=>{if(!o)return[];let t=`${e}.`,n=[];for(let[e,r]of Object.entries(o.fields??{})){if(!e.startsWith(t))continue;let i=e.slice(t.length);n.push({field:i,read:r.readable!==!1,write:r.editable!==!1})}return n},[o]),g=(0,r.useCallback)(()=>void 0,[]),_=(0,r.useMemo)(()=>({check:m,checkField:p,getFieldPermissions:h,getRowFilter:g,roles:o?.roles??[],isLoaded:!u&&!c&&o!==null}),[m,p,h,g,o,u,c]);return u&&!o?(0,J.jsx)(J.Fragment,{children:n}):c&&!o?i?(0,J.jsx)(J.Fragment,{children:i(c,f)}):(0,J.jsx)(J.Fragment,{children:n}):(0,J.jsx)(on.Provider,{value:_,children:a})}function ln(){let e=(0,r.useContext)(on);return(0,r.useMemo)(()=>e?{...e,can:(t,n)=>e.check(t,n).allowed,cannot:(t,n)=>!e.check(t,n).allowed}:{check:()=>({allowed:!0}),checkField:()=>!0,getFieldPermissions:()=>[],getRowFilter:()=>void 0,roles:[],isLoaded:!1,can:()=>!0,cannot:()=>!1},[e])}function un(e){let{checkField:t,getFieldPermissions:n}=ln(),i=(0,r.useMemo)(()=>n(e),[n,e]);return(0,r.useMemo)(()=>({permissions:i,canRead:n=>t(e,n,`read`),canWrite:n=>t(e,n,`write`),readableFields:n=>n.filter(n=>t(e,n,`read`)),writableFields:n=>n.filter(n=>t(e,n,`write`))}),[i,t,e])}export{an as a,Zt as c,Ft as d,Y as f,K as h,nn as i,Jt as l,jt as m,ln as n,tn as o,Mt as p,cn as r,en as s,un as t,It as u};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import{n as e}from"./src-CVz7aDdY.js";import{H as t,K as n,U as r,a as i,c as a,s as o,v as s,w as c,x as l,y as u}from"./chunk-CSCIHK7Q-DfSAlgJl.js";import{t as d}from"./chunk-WU5MYG2G-DwQt8tuZ.js";import{p as f}from"./chunk-5ZQYHXKU-DG12s6lW.js";import{t as p}from"./rough.esm-CSKSodPl.js";var m=(function(){var t=e(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),n=[1,4],r=[1,14],i=[1,12],a=[1,13],o=[6,7,8],s=[1,20],c=[1,18],l=[1,19],u=[6,7,11],d=[1,6,13,14],f=[1,23],p=[1,24],m=[1,6,7,11,13,14],h={trace:e(function(){},`trace`),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:`error`,6:`SPACELINE`,7:`NL`,8:`ISHIKAWA`,11:`EOF`,13:`SPACELIST`,14:`TEXT`},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:e(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 6:case 7:return r;case 15:r.addNode(a[s-1].length,a[s].trim());break;case 16:r.addNode(0,a[s].trim());break}},`anonymous`),table:[{3:1,4:2,5:3,6:[1,5],8:n},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:n},{6:r,7:[1,10],9:9,12:11,13:i,14:a},t(o,[2,3]),{1:[2,2]},t(o,[2,4]),t(o,[2,5]),{1:[2,6],6:r,12:15,13:i,14:a},{6:r,9:16,12:11,13:i,14:a},{6:s,7:c,10:17,11:l},t(u,[2,18],{14:[1,21]}),t(u,[2,16]),t(u,[2,17]),{6:s,7:c,10:22,11:l},{1:[2,7],6:r,12:15,13:i,14:a},t(d,[2,14],{7:f,11:p}),t(m,[2,8]),t(m,[2,9]),t(m,[2,10]),t(u,[2,15]),t(d,[2,13],{7:f,11:p}),t(m,[2,11]),t(m,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:e(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:e(function(t){var n=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(t,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;typeof g.yy.parseError==`function`?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}e(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=n.symbols_[e]||e),e}e(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
|
|
2
|
+
`+h.showPosition()+`
|
|
3
|
+
Expecting `+j.join(`, `)+`, got '`+(this.terminals_[S]||S)+`'`:`Parse error on line `+(l+1)+`: Unexpected `+(S==p?`end of input`:`'`+(this.terminals_[S]||S)+`'`),this.parseError(M,{text:h.match,token:this.terminals_[S]||S,line:h.yylineno,loc:v,expected:j})}if(T[0]instanceof Array&&T.length>1)throw Error(`Parse Error: multiple actions possible at state: `+w+`, token: `+S);switch(T[0]){case 1:r.push(S),a.push(h.yytext),o.push(h.yylloc),r.push(T[1]),S=null,C?(S=C,C=null):(u=h.yyleng,c=h.yytext,l=h.yylineno,v=h.yylloc,d>0&&d--);break;case 2:if(k=this.productions_[T[1]][1],D.$=a[a.length-k],D._$={first_line:o[o.length-(k||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(k||1)].first_column,last_column:o[o.length-1].last_column},y&&(D._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),E=this.performAction.apply(D,[c,u,l,g.yy,T[1],a,o].concat(m)),E!==void 0)return E;k&&(r=r.slice(0,-1*k*2),a=a.slice(0,-1*k),o=o.slice(0,-1*k)),r.push(this.productions_[T[1]][0]),a.push(D.$),o.push(D._$),A=s[r[r.length-2]][r[r.length-1]],r.push(A);break;case 3:return!0}}return!0},`parse`)};h.lexer=(function(){return{EOF:1,parseError:e(function(e,t){if(this.yy.parser)this.yy.parser.parseError(e,t);else throw Error(e)},`parseError`),setInput:e(function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match=``,this.conditionStack=[`INITIAL`],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},`setInput`),input:e(function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},`input`),unput:e(function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},`unput`),more:e(function(){return this._more=!0,this},`more`),reject:e(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError(`Lexical error on line `+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno});return this},`reject`),less:e(function(e){this.unput(this.match.slice(e))},`less`),pastInput:e(function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?`...`:``)+e.substr(-20).replace(/\n/g,``)},`pastInput`),upcomingInput:e(function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?`...`:``)).replace(/\n/g,``)},`upcomingInput`),showPosition:e(function(){var e=this.pastInput(),t=Array(e.length+1).join(`-`);return e+this.upcomingInput()+`
|
|
5
|
+
`+t+`^`},`showPosition`),test_match:e(function(e,t){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),r=e[0].match(/(?:\r\n?|\n).*/g),r&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return!1}return!1},`test_match`),next:e(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,t,n,r;this._more||(this.yytext=``,this.match=``);for(var i=this._currentRules(),a=0;a<i.length;a++)if(n=this._input.match(this.rules[i[a]]),n&&(!t||n[0].length>t[0].length)){if(t=n,r=a,this.options.backtrack_lexer){if(e=this.test_match(n,i[a]),e!==!1)return e;if(this._backtrack){t=!1;continue}else return!1}else if(!this.options.flex)break}return t?(e=this.test_match(t,i[r]),e===!1?!1:e):this._input===``?this.EOF:this.parseError(`Lexical error on line `+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno})},`next`),lex:e(function(){return this.next()||this.lex()},`lex`),begin:e(function(e){this.conditionStack.push(e)},`begin`),popState:e(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},`popState`),_currentRules:e(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},`_currentRules`),topState:e(function(e){return e=this.conditionStack.length-1-Math.abs(e||0),e>=0?this.conditionStack[e]:`INITIAL`},`topState`),pushState:e(function(e){this.begin(e)},`pushState`),stateStackSize:e(function(){return this.conditionStack.length},`stateStackSize`),options:{"case-insensitive":!0},performAction:e(function(e,t,n,r){switch(n){case 0:return 6;case 1:return 8;case 2:return 8;case 3:return 6;case 4:return 7;case 5:return 13;case 6:return 14;case 7:return 11}},`anonymous`),rules:[/^(?:\s*%%.*)/i,/^(?:ishikawa-beta\b)/i,/^(?:ishikawa\b)/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:[^\n]+)/i,/^(?:$)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}}})();function g(){this.yy={}}return e(g,`Parser`),g.prototype=h,h.Parser=g,new g})();m.parser=m;var h=m,g=class{constructor(){this.stack=[],this.clear=this.clear.bind(this),this.addNode=this.addNode.bind(this),this.getRoot=this.getRoot.bind(this)}static{e(this,`IshikawaDB`)}clear(){this.root=void 0,this.stack=[],this.baseLevel=void 0,i()}getRoot(){return this.root}addNode(e,t){let r=o.sanitizeText(t,l());if(!this.root){this.root={text:r,children:[]},this.stack=[{level:0,node:this.root}],n(r);return}this.baseLevel??=e;let i=e-this.baseLevel+1;for(i<=0&&(i=1);this.stack.length>1&&this.stack[this.stack.length-1].level>=i;)this.stack.pop();let a=this.stack[this.stack.length-1].node,s={text:r,children:[]};a.children.push(s),this.stack.push({level:i,node:s})}getAccTitle(){return u()}setAccTitle(e){r(e)}getAccDescription(){return s()}setAccDescription(e){t(e)}getDiagramTitle(){return c()}setDiagramTitle(e){n(e)}},_=14,v=250,y=30,b=60,x=5,S=82*Math.PI/180,C=Math.cos(S),w=Math.sin(S),T=e((e,t,n)=>{let r=e.node().getBBox(),i=r.width+t*2,o=r.height+t*2;a(e,o,i,n),e.attr(`viewBox`,`${r.x-t} ${r.y-t} ${i} ${o}`)},`applyPaddedViewBox`),E=e((e,t,n,r)=>{let i=r.db.getRoot();if(!i)return;let a=l(),{look:o,handDrawnSeed:s,themeVariables:c}=a,u=f(a.fontSize)[0]??_,m=o===`handDrawn`,h=i.children??[],g=a.ishikawa?.diagramPadding??20,y=a.ishikawa?.useMaxWidth??!1,b=d(t),x=b.append(`g`).attr(`class`,`ishikawa`),S=m?p.svg(b.node()):void 0,C=S?{roughSvg:S,seed:s??0,lineColor:c?.lineColor??`#333`,fillColor:c?.mainBkg??`#fff`}:void 0,w=`ishikawa-arrow-${t}`;m||x.append(`defs`).append(`marker`).attr(`id`,w).attr(`viewBox`,`0 0 10 10`).attr(`refX`,0).attr(`refY`,5).attr(`markerWidth`,6).attr(`markerHeight`,6).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 10 0 L 0 5 L 10 10 Z`).attr(`class`,`ishikawa-arrow`);let E=0,k=v,A=m?void 0:L(x,E,k,E,k,`ishikawa-spine`);if(O(x,E,k,i.text,u,C),!h.length){m&&L(x,E,k,E,k,`ishikawa-spine`,C),T(b,g,y);return}E-=20;let j=h.filter((e,t)=>t%2==0),N=h.filter((e,t)=>t%2==1),P=D(j),F=D(N),I=P.total+F.total,R=v,z=v;if(I>0){let e=v*2,t=v*.3;R=Math.max(t,e*(P.total/I)),z=Math.max(t,e*(F.total/I))}let B=u*2;R=Math.max(R,P.max*B),z=Math.max(z,F.max*B),k=Math.max(R,v),A&&A.attr(`y1`,k).attr(`y2`,k),x.select(`.ishikawa-head-group`).attr(`transform`,`translate(0,${k})`);let V=Math.ceil(h.length/2);for(let e=0;e<V;e++){let t=x.append(`g`).attr(`class`,`ishikawa-pair`);for(let[n,r,i]of[[h[e*2],-1,R],[h[e*2+1],1,z]])n&&M(t,n,E,k,r,i,u,C);E=t.selectAll(`text`).nodes().reduce((e,t)=>Math.min(e,t.getBBox().x),1/0)}if(m)L(x,E,k,0,k,`ishikawa-spine`,C);else{A.attr(`x1`,E);let e=`url(#${w})`;x.selectAll(`line.ishikawa-branch, line.ishikawa-sub-branch`).attr(`marker-start`,e)}T(b,g,y)},`draw`),D=e(t=>{let n=e(e=>e.children.reduce((e,t)=>e+1+n(t),0),`countDescendants`);return t.reduce((e,t)=>{let r=n(t);return e.total+=r,e.max=Math.max(e.max,r),e},{total:0,max:0})},`sideStats`),O=e((e,t,n,r,i,a)=>{let o=Math.max(6,Math.floor(110/(i*.6))),s=e.append(`g`).attr(`class`,`ishikawa-head-group`).attr(`transform`,`translate(${t},${n})`),c=F(s,P(r,o),0,0,`ishikawa-head-label`,`start`,i),l=c.node().getBBox(),u=Math.max(60,l.width+6),d=Math.max(40,l.height*2+40),f=`M 0 ${-d/2} L 0 ${d/2} Q ${u*2.4} 0 0 ${-d/2} Z`;if(a){let e=a.roughSvg.path(f,{roughness:1.5,seed:a.seed,fill:a.fillColor,fillStyle:`hachure`,fillWeight:2.5,hachureGap:5,stroke:a.lineColor,strokeWidth:2});s.insert(()=>e,`:first-child`).attr(`class`,`ishikawa-head`)}else s.insert(`path`,`:first-child`).attr(`class`,`ishikawa-head`).attr(`d`,f);c.attr(`transform`,`translate(${(u-l.width)/2-l.x+3},${-l.y-l.height/2})`)},`drawHead`),k=e((t,n)=>{let r=[],i=[],a=e((e,t,o)=>{let s=n===-1?[...e].reverse():e;for(let e of s){let n=r.length,s=e.children??[];r.push({depth:o,text:P(e.text,15),parentIndex:t,childCount:s.length}),o%2==0?(i.push(n),s.length&&a(s,n,o+1)):(s.length&&a(s,n,o+1),i.push(n))}},`walk`);return a(t,-1,2),{entries:r,yOrder:i}},`flattenTree`),A=e((e,t,n,r,i,a,o)=>{let s=e.append(`g`).attr(`class`,`ishikawa-label-group`),c=F(s,t,n,r+11*i,`ishikawa-label cause`,`middle`,a).node().getBBox();if(o){let e=o.roughSvg.rectangle(c.x-20,c.y-2,c.width+40,c.height+4,{roughness:1.5,seed:o.seed,fill:o.fillColor,fillStyle:`hachure`,fillWeight:2.5,hachureGap:5,stroke:o.lineColor,strokeWidth:2});s.insert(()=>e,`:first-child`).attr(`class`,`ishikawa-label-box`)}else s.insert(`rect`,`:first-child`).attr(`class`,`ishikawa-label-box`).attr(`x`,c.x-20).attr(`y`,c.y-2).attr(`width`,c.width+40).attr(`height`,c.height+4)},`drawCauseLabel`),j=e((e,t,n,r,i,a)=>{let o=Math.sqrt(r*r+i*i);if(o===0)return;let s=r/o,c=i/o,l=-c*6,u=s*6,d=t,f=n,p=`M ${d} ${f} L ${d-s*6*2+l} ${f-c*6*2+u} L ${d-s*6*2-l} ${f-c*6*2-u} Z`,m=a.roughSvg.path(p,{roughness:1,seed:a.seed,fill:a.lineColor,fillStyle:`solid`,stroke:a.lineColor,strokeWidth:1});e.append(()=>m)},`drawArrowMarker`),M=e((e,t,n,r,i,a,o,s)=>{let c=t.children??[],l=a*(c.length?1:.2),u=-C*l,d=w*l*i,f=n+u,p=r+d;if(L(e,n,r,f,p,`ishikawa-branch`,s),s&&j(e,n,r,n-f,r-p,s),A(e,t.text,f,p,i,o,s),!c.length)return;let{entries:m,yOrder:h}=k(c,i),g=m.length,_=Array(g);for(let[e,t]of h.entries())_[t]=r+d*((e+1)/(g+1));let v=new Map;v.set(-1,{x0:n,y0:r,x1:f,y1:p,childCount:c.length,childrenDrawn:0});let S=-C,T=w*i,E=i<0?`ishikawa-label up`:`ishikawa-label down`;for(let[t,n]of m.entries()){let r=_[t],i=v.get(n.parentIndex),a=e.append(`g`).attr(`class`,`ishikawa-sub-group`),c=0,l=0,u=0;if(n.depth%2==0){let e=i.y1-i.y0;c=I(i.x0,i.x1,e?(r-i.y0)/e:.5),l=r,u=c-(n.childCount>0?b+n.childCount*x:y),L(a,c,r,u,r,`ishikawa-sub-branch`,s),s&&j(a,c,r,1,0,s),F(a,n.text,u,r,`ishikawa-label align`,`end`,o)}else{let e=i.childrenDrawn++;c=I(i.x0,i.x1,(i.childCount-e)/(i.childCount+1)),l=i.y0,u=c+S*((r-l)/T),L(a,c,l,u,r,`ishikawa-sub-branch`,s),s&&j(a,c,l,c-u,l-r,s),F(a,n.text,u,r,E,`end`,o)}n.childCount>0&&v.set(t,{x0:c,y0:l,x1:u,y1:r,childCount:n.childCount,childrenDrawn:0})}},`drawBranch`),N=e(e=>e.split(/<br\s*\/?>|\n/),`splitLines`),P=e((e,t)=>{if(e.length<=t)return e;let n=[];for(let r of e.split(/\s+/)){let e=n.length-1;e>=0&&n[e].length+1+r.length<=t?n[e]+=` `+r:n.push(r)}return n.join(`
|
|
7
|
+
`)},`wrapText`),F=e((e,t,n,r,i,a,o)=>{let s=N(t),c=o*1.05,l=e.append(`text`).attr(`class`,i).attr(`text-anchor`,a).attr(`x`,n).attr(`y`,r-(s.length-1)*c/2);for(let[e,t]of s.entries())l.append(`tspan`).attr(`x`,n).attr(`dy`,e===0?0:c).text(t);return l},`drawMultilineText`),I=e((e,t,n)=>e+(t-e)*n,`lerp`),L=e((e,t,n,r,i,a,o)=>{if(o){let s=o.roughSvg.line(t,n,r,i,{roughness:1.5,seed:o.seed,stroke:o.lineColor,strokeWidth:2});e.append(()=>s).attr(`class`,a);return}return e.append(`line`).attr(`class`,a).attr(`x1`,t).attr(`y1`,n).attr(`x2`,r).attr(`y2`,i)},`drawLine`),R={parser:h,get db(){return new g},renderer:{draw:E},styles:e(e=>`
|
|
8
|
+
.ishikawa .ishikawa-spine,
|
|
9
|
+
.ishikawa .ishikawa-branch,
|
|
10
|
+
.ishikawa .ishikawa-sub-branch {
|
|
11
|
+
stroke: ${e.lineColor};
|
|
12
|
+
stroke-width: 2;
|
|
13
|
+
fill: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ishikawa .ishikawa-sub-branch {
|
|
17
|
+
stroke-width: 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ishikawa .ishikawa-arrow {
|
|
21
|
+
fill: ${e.lineColor};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ishikawa .ishikawa-head {
|
|
25
|
+
fill: ${e.mainBkg};
|
|
26
|
+
stroke: ${e.lineColor};
|
|
27
|
+
stroke-width: 2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.ishikawa .ishikawa-label-box {
|
|
31
|
+
fill: ${e.mainBkg};
|
|
32
|
+
stroke: ${e.lineColor};
|
|
33
|
+
stroke-width: 2;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ishikawa text {
|
|
37
|
+
font-family: ${e.fontFamily};
|
|
38
|
+
font-size: ${e.fontSize};
|
|
39
|
+
fill: ${e.textColor};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ishikawa .ishikawa-head-label {
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
text-anchor: middle;
|
|
45
|
+
dominant-baseline: middle;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ishikawa .ishikawa-label {
|
|
50
|
+
text-anchor: end;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.ishikawa .ishikawa-label.cause {
|
|
54
|
+
text-anchor: middle;
|
|
55
|
+
dominant-baseline: middle;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ishikawa .ishikawa-label.align {
|
|
59
|
+
text-anchor: end;
|
|
60
|
+
dominant-baseline: middle;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ishikawa .ishikawa-label.up {
|
|
64
|
+
dominant-baseline: baseline;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ishikawa .ishikawa-label.down {
|
|
68
|
+
dominant-baseline: hanging;
|
|
69
|
+
}
|
|
70
|
+
`,`getStyles`)};export{R as diagram};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import{jt as e,u as t}from"./vendor-charts-fo4ZbB_t.js";import{n}from"./src-CVz7aDdY.js";import{H as r,K as i,U as a,a as o,c as s,v as c,w as l,x as u,y as d}from"./chunk-CSCIHK7Q-DfSAlgJl.js";import{t as f}from"./chunk-FMBD7UC4-CZzqt4RW.js";import{a as p,n as m,o as h,s as g}from"./chunk-ND2GUHAM-C1toj0H3.js";var _=(function(){var e=n(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),t=[6,8,10,11,12,14,16,17,18],r=[1,9],i=[1,10],a=[1,11],o=[1,12],s=[1,13],c=[1,14],l={trace:n(function(){},`trace`),yy:{},symbols_:{error:2,start:3,journey:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,title:11,acc_title:12,acc_title_value:13,acc_descr:14,acc_descr_value:15,acc_descr_multiline_value:16,section:17,taskName:18,taskData:19,$accept:0,$end:1},terminals_:{2:`error`,4:`journey`,6:`EOF`,8:`SPACE`,10:`NEWLINE`,11:`title`,12:`acc_title`,13:`acc_title_value`,14:`acc_descr`,15:`acc_descr_value`,16:`acc_descr_multiline_value`,17:`section`,18:`taskName`,19:`taskData`},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,2],[9,2],[9,1],[9,1],[9,2]],performAction:n(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 1:return a[s-1];case 2:this.$=[];break;case 3:a[s-1].push(a[s]),this.$=a[s-1];break;case 4:case 5:this.$=a[s];break;case 6:case 7:this.$=[];break;case 8:r.setDiagramTitle(a[s].substr(6)),this.$=a[s].substr(6);break;case 9:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 10:case 11:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 12:r.addSection(a[s].substr(8)),this.$=a[s].substr(8);break;case 13:r.addTask(a[s-1],a[s]),this.$=`task`;break}},`anonymous`),table:[{3:1,4:[1,2]},{1:[3]},e(t,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:r,12:i,14:a,16:o,17:s,18:c},e(t,[2,7],{1:[2,1]}),e(t,[2,3]),{9:15,11:r,12:i,14:a,16:o,17:s,18:c},e(t,[2,5]),e(t,[2,6]),e(t,[2,8]),{13:[1,16]},{15:[1,17]},e(t,[2,11]),e(t,[2,12]),{19:[1,18]},e(t,[2,4]),e(t,[2,9]),e(t,[2,10]),e(t,[2,13])],defaultActions:{},parseError:n(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:n(function(e){var t=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(e,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;typeof g.yy.parseError==`function`?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}n(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=t.symbols_[e]||e),e}n(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
|
|
2
|
+
`+h.showPosition()+`
|
|
3
|
+
Expecting `+j.join(`, `)+`, got '`+(this.terminals_[S]||S)+`'`:`Parse error on line `+(l+1)+`: Unexpected `+(S==p?`end of input`:`'`+(this.terminals_[S]||S)+`'`),this.parseError(M,{text:h.match,token:this.terminals_[S]||S,line:h.yylineno,loc:v,expected:j})}if(T[0]instanceof Array&&T.length>1)throw Error(`Parse Error: multiple actions possible at state: `+w+`, token: `+S);switch(T[0]){case 1:r.push(S),a.push(h.yytext),o.push(h.yylloc),r.push(T[1]),S=null,C?(S=C,C=null):(u=h.yyleng,c=h.yytext,l=h.yylineno,v=h.yylloc,d>0&&d--);break;case 2:if(k=this.productions_[T[1]][1],D.$=a[a.length-k],D._$={first_line:o[o.length-(k||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(k||1)].first_column,last_column:o[o.length-1].last_column},y&&(D._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),E=this.performAction.apply(D,[c,u,l,g.yy,T[1],a,o].concat(m)),E!==void 0)return E;k&&(r=r.slice(0,-1*k*2),a=a.slice(0,-1*k),o=o.slice(0,-1*k)),r.push(this.productions_[T[1]][0]),a.push(D.$),o.push(D._$),A=s[r[r.length-2]][r[r.length-1]],r.push(A);break;case 3:return!0}}return!0},`parse`)};l.lexer=(function(){return{EOF:1,parseError:n(function(e,t){if(this.yy.parser)this.yy.parser.parseError(e,t);else throw Error(e)},`parseError`),setInput:n(function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match=``,this.conditionStack=[`INITIAL`],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},`setInput`),input:n(function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},`input`),unput:n(function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},`unput`),more:n(function(){return this._more=!0,this},`more`),reject:n(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError(`Lexical error on line `+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno});return this},`reject`),less:n(function(e){this.unput(this.match.slice(e))},`less`),pastInput:n(function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?`...`:``)+e.substr(-20).replace(/\n/g,``)},`pastInput`),upcomingInput:n(function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?`...`:``)).replace(/\n/g,``)},`upcomingInput`),showPosition:n(function(){var e=this.pastInput(),t=Array(e.length+1).join(`-`);return e+this.upcomingInput()+`
|
|
5
|
+
`+t+`^`},`showPosition`),test_match:n(function(e,t){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),r=e[0].match(/(?:\r\n?|\n).*/g),r&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return!1}return!1},`test_match`),next:n(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,t,n,r;this._more||(this.yytext=``,this.match=``);for(var i=this._currentRules(),a=0;a<i.length;a++)if(n=this._input.match(this.rules[i[a]]),n&&(!t||n[0].length>t[0].length)){if(t=n,r=a,this.options.backtrack_lexer){if(e=this.test_match(n,i[a]),e!==!1)return e;if(this._backtrack){t=!1;continue}else return!1}else if(!this.options.flex)break}return t?(e=this.test_match(t,i[r]),e===!1?!1:e):this._input===``?this.EOF:this.parseError(`Lexical error on line `+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno})},`next`),lex:n(function(){return this.next()||this.lex()},`lex`),begin:n(function(e){this.conditionStack.push(e)},`begin`),popState:n(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},`popState`),_currentRules:n(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},`_currentRules`),topState:n(function(e){return e=this.conditionStack.length-1-Math.abs(e||0),e>=0?this.conditionStack[e]:`INITIAL`},`topState`),pushState:n(function(e){this.begin(e)},`pushState`),stateStackSize:n(function(){return this.conditionStack.length},`stateStackSize`),options:{"case-insensitive":!0},performAction:n(function(e,t,n,r){switch(n){case 0:break;case 1:break;case 2:return 10;case 3:break;case 4:break;case 5:return 4;case 6:return 11;case 7:return this.begin(`acc_title`),12;case 8:return this.popState(),`acc_title_value`;case 9:return this.begin(`acc_descr`),14;case 10:return this.popState(),`acc_descr_value`;case 11:this.begin(`acc_descr_multiline`);break;case 12:this.popState();break;case 13:return`acc_descr_multiline_value`;case 14:return 17;case 15:return 18;case 16:return 19;case 17:return`:`;case 18:return 6;case 19:return`INVALID`}},`anonymous`),rules:[/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:journey\b)/i,/^(?:title\s[^#\n;]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^#:\n;]+)/i,/^(?:[^#:\n;]+)/i,/^(?::[^#\n;]+)/i,/^(?::)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,9,11,14,15,16,17,18,19],inclusive:!0}}}})();function u(){this.yy={}}return n(u,`Parser`),u.prototype=l,l.Parser=u,new u})();_.parser=_;var v=_,y=``,b=[],x=[],S=[],C=n(function(){b.length=0,x.length=0,y=``,S.length=0,o()},`clear`),w=n(function(e){y=e,b.push(e)},`addSection`),T=n(function(){return b},`getSections`),E=n(function(){let e=A(),t=0;for(;!e&&t<100;)e=A(),t++;return x.push(...S),x},`getTasks`),D=n(function(){let e=[];return x.forEach(t=>{t.people&&e.push(...t.people)}),[...new Set(e)].sort()},`updateActors`),O=n(function(e,t){let n=t.substr(1).split(`:`),r=0,i=[];n.length===1?(r=Number(n[0]),i=[]):(r=Number(n[0]),i=n[1].split(`,`));let a=i.map(e=>e.trim()),o={section:y,type:y,people:a,task:e,score:r};S.push(o)},`addTask`),k=n(function(e){let t={section:y,type:y,description:e,task:e,classes:[]};x.push(t)},`addTaskOrg`),A=n(function(){let e=n(function(e){return S[e].processed},`compileTask`),t=!0;for(let[n,r]of S.entries())e(n),t&&=r.processed;return t},`compileTasks`),j={getConfig:n(()=>u().journey,`getConfig`),clear:C,setDiagramTitle:i,getDiagramTitle:l,setAccTitle:a,getAccTitle:d,setAccDescription:r,getAccDescription:c,addSection:w,getSections:T,getTasks:E,addTask:O,addTaskOrg:k,getActors:n(function(){return D()},`getActors`)},M=n(e=>`.label {
|
|
7
|
+
font-family: ${e.fontFamily};
|
|
8
|
+
color: ${e.textColor};
|
|
9
|
+
}
|
|
10
|
+
.mouth {
|
|
11
|
+
stroke: #666;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
line {
|
|
15
|
+
stroke: ${e.textColor}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.legend {
|
|
19
|
+
fill: ${e.textColor};
|
|
20
|
+
font-family: ${e.fontFamily};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.label text {
|
|
24
|
+
fill: #333;
|
|
25
|
+
}
|
|
26
|
+
.label {
|
|
27
|
+
color: ${e.textColor}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.face {
|
|
31
|
+
${e.faceColor?`fill: ${e.faceColor}`:`fill: #FFF8DC`};
|
|
32
|
+
stroke: #999;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.node rect,
|
|
36
|
+
.node circle,
|
|
37
|
+
.node ellipse,
|
|
38
|
+
.node polygon,
|
|
39
|
+
.node path {
|
|
40
|
+
fill: ${e.mainBkg};
|
|
41
|
+
stroke: ${e.nodeBorder};
|
|
42
|
+
stroke-width: 1px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.node .label {
|
|
46
|
+
text-align: center;
|
|
47
|
+
}
|
|
48
|
+
.node.clickable {
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.arrowheadPath {
|
|
53
|
+
fill: ${e.arrowheadColor};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.edgePath .path {
|
|
57
|
+
stroke: ${e.lineColor};
|
|
58
|
+
stroke-width: 1.5px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.flowchart-link {
|
|
62
|
+
stroke: ${e.lineColor};
|
|
63
|
+
fill: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.edgeLabel {
|
|
67
|
+
background-color: ${e.edgeLabelBackground};
|
|
68
|
+
rect {
|
|
69
|
+
opacity: 0.5;
|
|
70
|
+
}
|
|
71
|
+
text-align: center;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.cluster rect {
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.cluster text {
|
|
78
|
+
fill: ${e.titleColor};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
div.mermaidTooltip {
|
|
82
|
+
position: absolute;
|
|
83
|
+
text-align: center;
|
|
84
|
+
max-width: 200px;
|
|
85
|
+
padding: 2px;
|
|
86
|
+
font-family: ${e.fontFamily};
|
|
87
|
+
font-size: 12px;
|
|
88
|
+
background: ${e.tertiaryColor};
|
|
89
|
+
border: 1px solid ${e.border2};
|
|
90
|
+
border-radius: 2px;
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
z-index: 100;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.task-type-0, .section-type-0 {
|
|
96
|
+
${e.fillType0?`fill: ${e.fillType0}`:``};
|
|
97
|
+
}
|
|
98
|
+
.task-type-1, .section-type-1 {
|
|
99
|
+
${e.fillType0?`fill: ${e.fillType1}`:``};
|
|
100
|
+
}
|
|
101
|
+
.task-type-2, .section-type-2 {
|
|
102
|
+
${e.fillType0?`fill: ${e.fillType2}`:``};
|
|
103
|
+
}
|
|
104
|
+
.task-type-3, .section-type-3 {
|
|
105
|
+
${e.fillType0?`fill: ${e.fillType3}`:``};
|
|
106
|
+
}
|
|
107
|
+
.task-type-4, .section-type-4 {
|
|
108
|
+
${e.fillType0?`fill: ${e.fillType4}`:``};
|
|
109
|
+
}
|
|
110
|
+
.task-type-5, .section-type-5 {
|
|
111
|
+
${e.fillType0?`fill: ${e.fillType5}`:``};
|
|
112
|
+
}
|
|
113
|
+
.task-type-6, .section-type-6 {
|
|
114
|
+
${e.fillType0?`fill: ${e.fillType6}`:``};
|
|
115
|
+
}
|
|
116
|
+
.task-type-7, .section-type-7 {
|
|
117
|
+
${e.fillType0?`fill: ${e.fillType7}`:``};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.actor-0 {
|
|
121
|
+
${e.actor0?`fill: ${e.actor0}`:``};
|
|
122
|
+
}
|
|
123
|
+
.actor-1 {
|
|
124
|
+
${e.actor1?`fill: ${e.actor1}`:``};
|
|
125
|
+
}
|
|
126
|
+
.actor-2 {
|
|
127
|
+
${e.actor2?`fill: ${e.actor2}`:``};
|
|
128
|
+
}
|
|
129
|
+
.actor-3 {
|
|
130
|
+
${e.actor3?`fill: ${e.actor3}`:``};
|
|
131
|
+
}
|
|
132
|
+
.actor-4 {
|
|
133
|
+
${e.actor4?`fill: ${e.actor4}`:``};
|
|
134
|
+
}
|
|
135
|
+
.actor-5 {
|
|
136
|
+
${e.actor5?`fill: ${e.actor5}`:``};
|
|
137
|
+
}
|
|
138
|
+
${f()}
|
|
139
|
+
`,`getStyles`),N=n(function(e,t){return p(e,t)},`drawRect`),P=n(function(t,r){let i=t.append(`circle`).attr(`cx`,r.cx).attr(`cy`,r.cy).attr(`class`,`face`).attr(`r`,15).attr(`stroke-width`,2).attr(`overflow`,`visible`),a=t.append(`g`);a.append(`circle`).attr(`cx`,r.cx-15/3).attr(`cy`,r.cy-15/3).attr(`r`,1.5).attr(`stroke-width`,2).attr(`fill`,`#666`).attr(`stroke`,`#666`),a.append(`circle`).attr(`cx`,r.cx+15/3).attr(`cy`,r.cy-15/3).attr(`r`,1.5).attr(`stroke-width`,2).attr(`fill`,`#666`).attr(`stroke`,`#666`);function o(t){let n=e().startAngle(Math.PI/2).endAngle(Math.PI/2*3).innerRadius(15/2).outerRadius(15/2.2);t.append(`path`).attr(`class`,`mouth`).attr(`d`,n).attr(`transform`,`translate(`+r.cx+`,`+(r.cy+2)+`)`)}n(o,`smile`);function s(t){let n=e().startAngle(3*Math.PI/2).endAngle(Math.PI/2*5).innerRadius(15/2).outerRadius(15/2.2);t.append(`path`).attr(`class`,`mouth`).attr(`d`,n).attr(`transform`,`translate(`+r.cx+`,`+(r.cy+7)+`)`)}n(s,`sad`);function c(e){e.append(`line`).attr(`class`,`mouth`).attr(`stroke`,2).attr(`x1`,r.cx-5).attr(`y1`,r.cy+7).attr(`x2`,r.cx+5).attr(`y2`,r.cy+7).attr(`class`,`mouth`).attr(`stroke-width`,`1px`).attr(`stroke`,`#666`)}return n(c,`ambivalent`),r.score>3?o(a):r.score<3?s(a):c(a),i},`drawFace`),F=n(function(e,t){let n=e.append(`circle`);return n.attr(`cx`,t.cx),n.attr(`cy`,t.cy),n.attr(`class`,`actor-`+t.pos),n.attr(`fill`,t.fill),n.attr(`stroke`,t.stroke),n.attr(`r`,t.r),n.class!==void 0&&n.attr(`class`,n.class),t.title!==void 0&&n.append(`title`).text(t.title),n},`drawCircle`),I=n(function(e,t){return h(e,t)},`drawText`),L=n(function(e,t){function r(e,t,n,r,i){return e+`,`+t+` `+(e+n)+`,`+t+` `+(e+n)+`,`+(t+r-i)+` `+(e+n-i*1.2)+`,`+(t+r)+` `+e+`,`+(t+r)}n(r,`genPoints`);let i=e.append(`polygon`);i.attr(`points`,r(t.x,t.y,50,20,7)),i.attr(`class`,`labelBox`),t.y+=t.labelMargin,t.x+=.5*t.labelMargin,I(e,t)},`drawLabel`),R=n(function(e,t,n){let r=e.append(`g`),i=g();i.x=t.x,i.y=t.y,i.fill=t.fill,i.width=n.width*t.taskCount+n.diagramMarginX*(t.taskCount-1),i.height=n.height,i.class=`journey-section section-type-`+t.num,i.rx=3,i.ry=3,N(r,i),H(n)(t.text,r,i.x,i.y,i.width,i.height,{class:`journey-section section-type-`+t.num},n,t.colour)},`drawSection`),z=-1,B=n(function(e,t,n,r){let i=t.x+n.width/2,a=e.append(`g`);z++,a.append(`line`).attr(`id`,r+`-task`+z).attr(`x1`,i).attr(`y1`,t.y).attr(`x2`,i).attr(`y2`,450).attr(`class`,`task-line`).attr(`stroke-width`,`1px`).attr(`stroke-dasharray`,`4 2`).attr(`stroke`,`#666`),P(a,{cx:i,cy:300+(5-t.score)*30,score:t.score});let o=g();o.x=t.x,o.y=t.y,o.fill=t.fill,o.width=n.width,o.height=n.height,o.class=`task task-type-`+t.num,o.rx=3,o.ry=3,N(a,o);let s=t.x+14;t.people.forEach(e=>{let n=t.actors[e].color;F(a,{cx:s,cy:t.y,r:7,fill:n,stroke:`#000`,title:e,pos:t.actors[e].position}),s+=10}),H(n)(t.task,a,o.x,o.y,o.width,o.height,{class:`task`},n,t.colour)},`drawTask`),V=n(function(e,t){m(e,t)},`drawBackgroundRect`),H=(function(){function e(e,t,n,r,a,o,s,c){i(t.append(`text`).attr(`x`,n+a/2).attr(`y`,r+o/2+5).style(`font-color`,c).style(`text-anchor`,`middle`).text(e),s)}n(e,`byText`);function t(e,t,n,r,a,o,s,c,l){let{taskFontSize:u,taskFontFamily:d}=c,f=e.split(/<br\s*\/?>/gi);for(let e=0;e<f.length;e++){let c=e*u-u*(f.length-1)/2,p=t.append(`text`).attr(`x`,n+a/2).attr(`y`,r).attr(`fill`,l).style(`text-anchor`,`middle`).style(`font-size`,u).style(`font-family`,d);p.append(`tspan`).attr(`x`,n+a/2).attr(`dy`,c).text(f[e]),p.attr(`y`,r+o/2).attr(`dominant-baseline`,`central`).attr(`alignment-baseline`,`central`),i(p,s)}}n(t,`byTspan`);function r(e,n,r,a,o,s,c,l){let u=n.append(`switch`),d=u.append(`foreignObject`).attr(`x`,r).attr(`y`,a).attr(`width`,o).attr(`height`,s).attr(`position`,`fixed`).append(`xhtml:div`).style(`display`,`table`).style(`height`,`100%`).style(`width`,`100%`);d.append(`div`).attr(`class`,`label`).style(`display`,`table-cell`).style(`text-align`,`center`).style(`vertical-align`,`middle`).text(e),t(e,u,r,a,o,s,c,l),i(d,c)}n(r,`byFo`);function i(e,t){for(let n in t)n in t&&e.attr(n,t[n])}return n(i,`_setTextAttrs`),function(n){return n.textPlacement===`fo`?r:n.textPlacement===`old`?e:t}})(),U={drawRect:N,drawCircle:F,drawSection:R,drawText:I,drawLabel:L,drawTask:B,drawBackgroundRect:V,initGraphics:n(function(e,t){z=-1,e.append(`defs`).append(`marker`).attr(`id`,t+`-arrowhead`).attr(`refX`,5).attr(`refY`,2).attr(`markerWidth`,6).attr(`markerHeight`,4).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 0,0 V 4 L6,2 Z`)},`initGraphics`)},W=n(function(e){Object.keys(e).forEach(function(t){J[t]=e[t]})},`setConf`),G={},K=0;function q(e){let t=u().journey,n=t.maxLabelWidth;K=0;let r=60;Object.keys(G).forEach(i=>{let a=G[i].color,o={cx:20,cy:r,r:7,fill:a,stroke:`#000`,pos:G[i].position};U.drawCircle(e,o);let s=e.append(`text`).attr(`visibility`,`hidden`).text(i),c=s.node().getBoundingClientRect().width;s.remove();let l=[];if(c<=n)l=[i];else{let t=i.split(` `),r=``;s=e.append(`text`).attr(`visibility`,`hidden`),t.forEach(e=>{let t=r?`${r} ${e}`:e;if(s.text(t),s.node().getBoundingClientRect().width>n){if(r&&l.push(r),r=e,s.text(e),s.node().getBoundingClientRect().width>n){let t=``;for(let r of e)t+=r,s.text(t+`-`),s.node().getBoundingClientRect().width>n&&(l.push(t.slice(0,-1)+`-`),t=r);r=t}}else r=t}),r&&l.push(r),s.remove()}l.forEach((n,i)=>{let a={x:40,y:r+7+i*20,fill:`#666`,text:n,textMargin:t.boxTextMargin??5},o=U.drawText(e,a).node().getBoundingClientRect().width;o>K&&o>t.leftMargin-o&&(K=o)}),r+=Math.max(20,l.length*20)})}n(q,`drawActorLegend`);var J=u().journey,Y=0,ee=n(function(e,n,r,i){let a=u(),o=a.journey.titleColor,c=a.journey.titleFontSize,l=a.journey.titleFontFamily,d=a.securityLevel,f;d===`sandbox`&&(f=t(`#i`+n));let p=t(d===`sandbox`?f.nodes()[0].contentDocument.body:`body`);X.init();let m=p.select(`#`+n);U.initGraphics(m,n);let h=i.db.getTasks(),g=i.db.getDiagramTitle(),_=i.db.getActors();for(let e in G)delete G[e];let v=0;_.forEach(e=>{G[e]={color:J.actorColours[v%J.actorColours.length],position:v},v++}),q(m),Y=J.leftMargin+K,X.insert(0,0,Y,Object.keys(G).length*50),te(m,h,0,n);let y=X.getBounds();g&&m.append(`text`).text(g).attr(`x`,Y).attr(`font-size`,c).attr(`font-weight`,`bold`).attr(`y`,25).attr(`fill`,o).attr(`font-family`,l);let b=y.stopy-y.starty+2*J.diagramMarginY,x=Y+y.stopx+2*J.diagramMarginX;s(m,b,x,J.useMaxWidth),m.append(`line`).attr(`x1`,Y).attr(`y1`,J.height*4).attr(`x2`,x-Y-4).attr(`y2`,J.height*4).attr(`stroke-width`,4).attr(`stroke`,`black`).attr(`marker-end`,`url(#`+n+`-arrowhead)`);let S=g?70:0;m.attr(`viewBox`,`${y.startx} -25 ${x} ${b+S}`),m.attr(`preserveAspectRatio`,`xMinYMin meet`),m.attr(`height`,b+S+25)},`draw`),X={data:{startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},verticalPos:0,sequenceItems:[],init:n(function(){this.sequenceItems=[],this.data={startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},this.verticalPos=0},`init`),updateVal:n(function(e,t,n,r){e[t]===void 0?e[t]=n:e[t]=r(n,e[t])},`updateVal`),updateBounds:n(function(e,t,r,i){let a=u().journey,o=this,s=0;function c(c){return n(function(n){s++;let l=o.sequenceItems.length-s+1;o.updateVal(n,`starty`,t-l*a.boxMargin,Math.min),o.updateVal(n,`stopy`,i+l*a.boxMargin,Math.max),o.updateVal(X.data,`startx`,e-l*a.boxMargin,Math.min),o.updateVal(X.data,`stopx`,r+l*a.boxMargin,Math.max),c!==`activation`&&(o.updateVal(n,`startx`,e-l*a.boxMargin,Math.min),o.updateVal(n,`stopx`,r+l*a.boxMargin,Math.max),o.updateVal(X.data,`starty`,t-l*a.boxMargin,Math.min),o.updateVal(X.data,`stopy`,i+l*a.boxMargin,Math.max))},`updateItemBounds`)}n(c,`updateFn`),this.sequenceItems.forEach(c())},`updateBounds`),insert:n(function(e,t,n,r){let i=Math.min(e,n),a=Math.max(e,n),o=Math.min(t,r),s=Math.max(t,r);this.updateVal(X.data,`startx`,i,Math.min),this.updateVal(X.data,`starty`,o,Math.min),this.updateVal(X.data,`stopx`,a,Math.max),this.updateVal(X.data,`stopy`,s,Math.max),this.updateBounds(i,o,a,s)},`insert`),bumpVerticalPos:n(function(e){this.verticalPos+=e,this.data.stopy=this.verticalPos},`bumpVerticalPos`),getVerticalPos:n(function(){return this.verticalPos},`getVerticalPos`),getBounds:n(function(){return this.data},`getBounds`)},Z=J.sectionFills,Q=J.sectionColours,te=n(function(e,t,n,r){let i=u().journey,a=``,o=n+(i.height*2+i.diagramMarginY),s=0,c=`#CCC`,l=`black`,d=0;for(let[n,u]of t.entries()){if(a!==u.section){c=Z[s%Z.length],d=s%Z.length,l=Q[s%Q.length];let r=0,o=u.section;for(let e=n;e<t.length&&t[e].section==o;e++)r+=1;let f={x:n*i.taskMargin+n*i.width+Y,y:50,text:u.section,fill:c,num:d,colour:l,taskCount:r};U.drawSection(e,f,i),a=u.section,s++}let f=u.people.reduce((e,t)=>(G[t]&&(e[t]=G[t]),e),{});u.x=n*i.taskMargin+n*i.width+Y,u.y=o,u.width=i.diagramMarginX,u.height=i.diagramMarginY,u.colour=l,u.fill=c,u.num=d,u.actors=f,U.drawTask(e,u,i,r),X.insert(u.x,u.y,u.x+u.width+i.taskMargin,450)}},`drawTasks`),$={setConf:W,draw:ee},ne={parser:v,db:j,renderer:$,styles:M,init:n(e=>{$.setConf(e.journey),j.clear()},`init`)};export{ne as diagram};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import{n as e,r as t}from"./src-CVz7aDdY.js";import{J as n,et as r,f as i,rt as a,tt as o,x as s,z as c}from"./chunk-CSCIHK7Q-DfSAlgJl.js";import{t as l}from"./chunk-WU5MYG2G-DwQt8tuZ.js";import"./chunk-5ZQYHXKU-DG12s6lW.js";import"./chunk-O5CBEL6O-BzyWPZhZ.js";import{t as u}from"./chunk-FMBD7UC4-CZzqt4RW.js";import"./chunk-L5ZTLDWV-DW1lPBoG.js";import"./chunk-NZK2D7GU-H2MwBqQV.js";import{a as d,c as f,i as p}from"./chunk-3OPIFGDE-3g0dk_di.js";import{n as m,t as h}from"./chunk-XPW4576I-DPNxFY7Q.js";var g=(function(){var t=e(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),n=[1,4],r=[1,13],i=[1,12],a=[1,15],o=[1,16],s=[1,20],c=[1,19],l=[6,7,8],u=[1,26],d=[1,24],f=[1,25],p=[6,7,11],m=[1,31],h=[6,7,11,24],g=[1,6,13,16,17,20,23],_=[1,35],v=[1,36],y=[1,6,7,11,13,16,17,20,23],b=[1,38],x={trace:e(function(){},`trace`),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,KANBAN:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,shapeData:15,ICON:16,CLASS:17,nodeWithId:18,nodeWithoutId:19,NODE_DSTART:20,NODE_DESCR:21,NODE_DEND:22,NODE_ID:23,SHAPE_DATA:24,$accept:0,$end:1},terminals_:{2:`error`,6:`SPACELINE`,7:`NL`,8:`KANBAN`,11:`EOF`,13:`SPACELIST`,16:`ICON`,17:`CLASS`,20:`NODE_DSTART`,21:`NODE_DESCR`,22:`NODE_DEND`,23:`NODE_ID`,24:`SHAPE_DATA`},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,3],[12,2],[12,2],[12,2],[12,1],[12,2],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[19,3],[18,1],[18,4],[15,2],[15,1]],performAction:e(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 6:case 7:return r;case 8:r.getLogger().trace(`Stop NL `);break;case 9:r.getLogger().trace(`Stop EOF `);break;case 11:r.getLogger().trace(`Stop NL2 `);break;case 12:r.getLogger().trace(`Stop EOF2 `);break;case 15:r.getLogger().info(`Node: `,a[s-1].id),r.addNode(a[s-2].length,a[s-1].id,a[s-1].descr,a[s-1].type,a[s]);break;case 16:r.getLogger().info(`Node: `,a[s].id),r.addNode(a[s-1].length,a[s].id,a[s].descr,a[s].type);break;case 17:r.getLogger().trace(`Icon: `,a[s]),r.decorateNode({icon:a[s]});break;case 18:case 23:r.decorateNode({class:a[s]});break;case 19:r.getLogger().trace(`SPACELIST`);break;case 20:r.getLogger().trace(`Node: `,a[s-1].id),r.addNode(0,a[s-1].id,a[s-1].descr,a[s-1].type,a[s]);break;case 21:r.getLogger().trace(`Node: `,a[s].id),r.addNode(0,a[s].id,a[s].descr,a[s].type);break;case 22:r.decorateNode({icon:a[s]});break;case 27:r.getLogger().trace(`node found ..`,a[s-2]),this.$={id:a[s-1],descr:a[s-1],type:r.getType(a[s-2],a[s])};break;case 28:this.$={id:a[s],descr:a[s],type:0};break;case 29:r.getLogger().trace(`node found ..`,a[s-3]),this.$={id:a[s-3],descr:a[s-1],type:r.getType(a[s-2],a[s])};break;case 30:this.$=a[s-1]+a[s];break;case 31:this.$=a[s];break}},`anonymous`),table:[{3:1,4:2,5:3,6:[1,5],8:n},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:n},{6:r,7:[1,10],9:9,12:11,13:i,14:14,16:a,17:o,18:17,19:18,20:s,23:c},t(l,[2,3]),{1:[2,2]},t(l,[2,4]),t(l,[2,5]),{1:[2,6],6:r,12:21,13:i,14:14,16:a,17:o,18:17,19:18,20:s,23:c},{6:r,9:22,12:11,13:i,14:14,16:a,17:o,18:17,19:18,20:s,23:c},{6:u,7:d,10:23,11:f},t(p,[2,24],{18:17,19:18,14:27,16:[1,28],17:[1,29],20:s,23:c}),t(p,[2,19]),t(p,[2,21],{15:30,24:m}),t(p,[2,22]),t(p,[2,23]),t(h,[2,25]),t(h,[2,26]),t(h,[2,28],{20:[1,32]}),{21:[1,33]},{6:u,7:d,10:34,11:f},{1:[2,7],6:r,12:21,13:i,14:14,16:a,17:o,18:17,19:18,20:s,23:c},t(g,[2,14],{7:_,11:v}),t(y,[2,8]),t(y,[2,9]),t(y,[2,10]),t(p,[2,16],{15:37,24:m}),t(p,[2,17]),t(p,[2,18]),t(p,[2,20],{24:b}),t(h,[2,31]),{21:[1,39]},{22:[1,40]},t(g,[2,13],{7:_,11:v}),t(y,[2,11]),t(y,[2,12]),t(p,[2,15],{24:b}),t(h,[2,30]),{22:[1,41]},t(h,[2,27]),t(h,[2,29])],defaultActions:{2:[2,1],6:[2,2]},parseError:e(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:e(function(t){var n=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(t,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;typeof g.yy.parseError==`function`?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}e(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=n.symbols_[e]||e),e}e(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
|
|
2
|
+
`+h.showPosition()+`
|
|
3
|
+
Expecting `+j.join(`, `)+`, got '`+(this.terminals_[S]||S)+`'`:`Parse error on line `+(l+1)+`: Unexpected `+(S==p?`end of input`:`'`+(this.terminals_[S]||S)+`'`),this.parseError(M,{text:h.match,token:this.terminals_[S]||S,line:h.yylineno,loc:v,expected:j})}if(T[0]instanceof Array&&T.length>1)throw Error(`Parse Error: multiple actions possible at state: `+w+`, token: `+S);switch(T[0]){case 1:r.push(S),a.push(h.yytext),o.push(h.yylloc),r.push(T[1]),S=null,C?(S=C,C=null):(u=h.yyleng,c=h.yytext,l=h.yylineno,v=h.yylloc,d>0&&d--);break;case 2:if(k=this.productions_[T[1]][1],D.$=a[a.length-k],D._$={first_line:o[o.length-(k||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(k||1)].first_column,last_column:o[o.length-1].last_column},y&&(D._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),E=this.performAction.apply(D,[c,u,l,g.yy,T[1],a,o].concat(m)),E!==void 0)return E;k&&(r=r.slice(0,-1*k*2),a=a.slice(0,-1*k),o=o.slice(0,-1*k)),r.push(this.productions_[T[1]][0]),a.push(D.$),o.push(D._$),A=s[r[r.length-2]][r[r.length-1]],r.push(A);break;case 3:return!0}}return!0},`parse`)};x.lexer=(function(){return{EOF:1,parseError:e(function(e,t){if(this.yy.parser)this.yy.parser.parseError(e,t);else throw Error(e)},`parseError`),setInput:e(function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match=``,this.conditionStack=[`INITIAL`],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},`setInput`),input:e(function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},`input`),unput:e(function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},`unput`),more:e(function(){return this._more=!0,this},`more`),reject:e(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError(`Lexical error on line `+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno});return this},`reject`),less:e(function(e){this.unput(this.match.slice(e))},`less`),pastInput:e(function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?`...`:``)+e.substr(-20).replace(/\n/g,``)},`pastInput`),upcomingInput:e(function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?`...`:``)).replace(/\n/g,``)},`upcomingInput`),showPosition:e(function(){var e=this.pastInput(),t=Array(e.length+1).join(`-`);return e+this.upcomingInput()+`
|
|
5
|
+
`+t+`^`},`showPosition`),test_match:e(function(e,t){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),r=e[0].match(/(?:\r\n?|\n).*/g),r&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return!1}return!1},`test_match`),next:e(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,t,n,r;this._more||(this.yytext=``,this.match=``);for(var i=this._currentRules(),a=0;a<i.length;a++)if(n=this._input.match(this.rules[i[a]]),n&&(!t||n[0].length>t[0].length)){if(t=n,r=a,this.options.backtrack_lexer){if(e=this.test_match(n,i[a]),e!==!1)return e;if(this._backtrack){t=!1;continue}else return!1}else if(!this.options.flex)break}return t?(e=this.test_match(t,i[r]),e===!1?!1:e):this._input===``?this.EOF:this.parseError(`Lexical error on line `+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:``,token:null,line:this.yylineno})},`next`),lex:e(function(){return this.next()||this.lex()},`lex`),begin:e(function(e){this.conditionStack.push(e)},`begin`),popState:e(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},`popState`),_currentRules:e(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},`_currentRules`),topState:e(function(e){return e=this.conditionStack.length-1-Math.abs(e||0),e>=0?this.conditionStack[e]:`INITIAL`},`topState`),pushState:e(function(e){this.begin(e)},`pushState`),stateStackSize:e(function(){return this.conditionStack.length},`stateStackSize`),options:{"case-insensitive":!0},performAction:e(function(e,t,n,r){switch(n){case 0:return this.pushState(`shapeData`),t.yytext=``,24;case 1:return this.pushState(`shapeDataStr`),24;case 2:return this.popState(),24;case 3:return t.yytext=t.yytext.replace(/\n\s*/g,`<br/>`),24;case 4:return 24;case 5:this.popState();break;case 6:return e.getLogger().trace(`Found comment`,t.yytext),6;case 7:return 8;case 8:this.begin(`CLASS`);break;case 9:return this.popState(),17;case 10:this.popState();break;case 11:e.getLogger().trace(`Begin icon`),this.begin(`ICON`);break;case 12:return e.getLogger().trace(`SPACELINE`),6;case 13:return 7;case 14:return 16;case 15:e.getLogger().trace(`end icon`),this.popState();break;case 16:return e.getLogger().trace(`Exploding node`),this.begin(`NODE`),20;case 17:return e.getLogger().trace(`Cloud`),this.begin(`NODE`),20;case 18:return e.getLogger().trace(`Explosion Bang`),this.begin(`NODE`),20;case 19:return e.getLogger().trace(`Cloud Bang`),this.begin(`NODE`),20;case 20:return this.begin(`NODE`),20;case 21:return this.begin(`NODE`),20;case 22:return this.begin(`NODE`),20;case 23:return this.begin(`NODE`),20;case 24:return 13;case 25:return 23;case 26:return 11;case 27:this.begin(`NSTR2`);break;case 28:return`NODE_DESCR`;case 29:this.popState();break;case 30:e.getLogger().trace(`Starting NSTR`),this.begin(`NSTR`);break;case 31:return e.getLogger().trace(`description:`,t.yytext),`NODE_DESCR`;case 32:this.popState();break;case 33:return this.popState(),e.getLogger().trace(`node end ))`),`NODE_DEND`;case 34:return this.popState(),e.getLogger().trace(`node end )`),`NODE_DEND`;case 35:return this.popState(),e.getLogger().trace(`node end ...`,t.yytext),`NODE_DEND`;case 36:return this.popState(),e.getLogger().trace(`node end ((`),`NODE_DEND`;case 37:return this.popState(),e.getLogger().trace(`node end (-`),`NODE_DEND`;case 38:return this.popState(),e.getLogger().trace(`node end (-`),`NODE_DEND`;case 39:return this.popState(),e.getLogger().trace(`node end ((`),`NODE_DEND`;case 40:return this.popState(),e.getLogger().trace(`node end ((`),`NODE_DEND`;case 41:return e.getLogger().trace(`Long description:`,t.yytext),21;case 42:return e.getLogger().trace(`Long description:`,t.yytext),21}},`anonymous`),rules:[/^(?:@\{)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^\"]+)/i,/^(?:[^}^"]+)/i,/^(?:\})/i,/^(?:\s*%%.*)/i,/^(?:kanban\b)/i,/^(?::::)/i,/^(?:.+)/i,/^(?:\n)/i,/^(?:::icon\()/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[^\)]+)/i,/^(?:\))/i,/^(?:-\))/i,/^(?:\(-)/i,/^(?:\)\))/i,/^(?:\))/i,/^(?:\(\()/i,/^(?:\{\{)/i,/^(?:\()/i,/^(?:\[)/i,/^(?:[\s]+)/i,/^(?:[^\(\[\n\)\{\}@]+)/i,/^(?:$)/i,/^(?:["][`])/i,/^(?:[^`"]+)/i,/^(?:[`]["])/i,/^(?:["])/i,/^(?:[^"]+)/i,/^(?:["])/i,/^(?:[\)]\))/i,/^(?:[\)])/i,/^(?:[\]])/i,/^(?:\}\})/i,/^(?:\(-)/i,/^(?:-\))/i,/^(?:\(\()/i,/^(?:\()/i,/^(?:[^\)\]\(\}]+)/i,/^(?:.+(?!\(\())/i],conditions:{shapeDataEndBracket:{rules:[],inclusive:!1},shapeDataStr:{rules:[2,3],inclusive:!1},shapeData:{rules:[1,4,5],inclusive:!1},CLASS:{rules:[9,10],inclusive:!1},ICON:{rules:[14,15],inclusive:!1},NSTR2:{rules:[28,29],inclusive:!1},NSTR:{rules:[31,32],inclusive:!1},NODE:{rules:[27,30,33,34,35,36,37,38,39,40,41,42],inclusive:!1},INITIAL:{rules:[0,6,7,8,11,12,13,16,17,18,19,20,21,22,23,24,25,26],inclusive:!0}}}})();function S(){this.yy={}}return e(S,`Parser`),S.prototype=x,x.Parser=S,new S})();g.parser=g;var _=g,v=[],y=[],b=0,x={},S=e(()=>{v=[],y=[],b=0,x={}},`clear`),C=e(e=>{if(v.length===0)return null;let t=v[0].level,n=null;for(let e=v.length-1;e>=0;e--)if(v[e].level===t&&!n&&(n=v[e]),v[e].level<t)throw Error(`Items without section detected, found section ("`+v[e].label+`")`);return e===n?.level?null:n},`getSection`),w=e(function(){return y},`getSections`),T=e(function(){let e=[],t=[],n=w(),r=s();for(let e of n){let n={id:e.id,label:c(e.label??``,r),labelType:`markdown`,isGroup:!0,ticket:e.ticket,shape:`kanbanSection`,level:e.level,look:r.look};t.push(n);let i=v.filter(t=>t.parentId===e.id);for(let n of i){let i={id:n.id,parentId:e.id,label:c(n.label??``,r),labelType:`markdown`,isGroup:!1,ticket:n?.ticket,priority:n?.priority,assigned:n?.assigned,icon:n?.icon,shape:`kanbanItem`,level:n.level,rx:5,ry:5,cssStyles:[`text-align: left`]};t.push(i)}}return{nodes:t,edges:e,other:{},config:s()}},`getData`),E=e((e,t,n,r,a)=>{let o=s(),l=o.mindmap?.padding??i.mindmap.padding;switch(r){case D.ROUNDED_RECT:case D.RECT:case D.HEXAGON:l*=2}let u={id:c(t,o)||`kbn`+ b++,level:e,label:c(n,o),width:o.mindmap?.maxNodeWidth??i.mindmap.maxNodeWidth,padding:l,isGroup:!1};if(a!==void 0){let e;e=a.includes(`
|
|
7
|
+
`)?a+`
|
|
8
|
+
`:`{
|
|
9
|
+
`+a+`
|
|
10
|
+
}`;let t=m(e,{schema:h});if(t.shape&&(t.shape!==t.shape.toLowerCase()||t.shape.includes(`_`)))throw Error(`No such shape: ${t.shape}. Shape names should be lowercase.`);t?.shape&&t.shape===`kanbanItem`&&(u.shape=t?.shape),t?.label&&(u.label=t?.label),t?.icon&&(u.icon=t?.icon.toString()),t?.assigned&&(u.assigned=t?.assigned.toString()),t?.ticket&&(u.ticket=t?.ticket.toString()),t?.priority&&(u.priority=t?.priority)}let d=C(e);d?u.parentId=d.id||`kbn`+ b++:y.push(u),v.push(u)},`addNode`),D={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6},O={clear:S,addNode:E,getSections:w,getData:T,nodeType:D,getType:e((e,n)=>{switch(t.debug(`In get type`,e,n),e){case`[`:return D.RECT;case`(`:return n===`)`?D.ROUNDED_RECT:D.CLOUD;case`((`:return D.CIRCLE;case`)`:return D.CLOUD;case`))`:return D.BANG;case`{{`:return D.HEXAGON;default:return D.DEFAULT}},`getType`),setElementForId:e((e,t)=>{x[e]=t},`setElementForId`),decorateNode:e(e=>{if(!e)return;let t=s(),n=v[v.length-1];e.icon&&(n.icon=c(e.icon,t)),e.class&&(n.cssClasses=c(e.class,t))},`decorateNode`),type2Str:e(e=>{switch(e){case D.DEFAULT:return`no-border`;case D.RECT:return`rect`;case D.ROUNDED_RECT:return`rounded-rect`;case D.CIRCLE:return`circle`;case D.CLOUD:return`cloud`;case D.BANG:return`bang`;case D.HEXAGON:return`hexgon`;default:return`no-border`}},`type2Str`),getLogger:e(()=>t,`getLogger`),getElementById:e(e=>x[e],`getElementById`)},k={draw:e(async(e,r,a,o)=>{t.debug(`Rendering kanban diagram
|
|
11
|
+
`+e);let c=o.db.getData(),u=s();u.htmlLabels=!1;let m=l(r);for(let e of c.nodes)e.domId=`${r}-${e.id}`;let h=m.append(`g`);h.attr(`class`,`sections`);let g=m.append(`g`);g.attr(`class`,`items`);let _=c.nodes.filter(e=>e.isGroup),v=0,y=[],b=25;for(let e of _){let t=u?.kanban?.sectionWidth||200;v+=1,e.x=t*v+(v-1)*10/2,e.width=t,e.y=0,e.height=t*3,e.rx=5,e.ry=5,e.cssClasses=e.cssClasses+` section-`+v;let n=await p(h,e);b=Math.max(b,n?.labelBBox?.height),y.push(n)}let x=0;for(let e of _){let t=y[x];x+=1;let n=u?.kanban?.sectionWidth||200,r=-n*3/2+b,i=r,a=c.nodes.filter(t=>t.parentId===e.id);for(let t of a){if(t.isGroup)throw Error(`Groups within groups are not allowed in Kanban diagrams`);t.x=e.x,t.width=n-1.5*10;let r=(await d(g,t,{config:u})).node().getBBox();t.y=i+r.height/2,await f(t),i=t.y+r.height/2+10/2}let o=t.cluster.select(`rect`),s=Math.max(i-r+30,50)+(b-25);o.attr(`height`,s)}n(void 0,m,u.mindmap?.padding??i.kanban.padding,u.mindmap?.useMaxWidth??i.kanban.useMaxWidth)},`draw`)},A=e(t=>{let n=``;for(let e=0;e<t.THEME_COLOR_LIMIT;e++)t[`lineColor`+e]=t[`lineColor`+e]||t[`cScaleInv`+e],a(t[`lineColor`+e])?t[`lineColor`+e]=o(t[`lineColor`+e],20):t[`lineColor`+e]=r(t[`lineColor`+e],20);let i=e((e,n)=>t.darkMode?r(e,n):o(e,n),`adjuster`);for(let e=0;e<t.THEME_COLOR_LIMIT;e++){let r=``+(17-3*e);n+=`
|
|
12
|
+
.section-${e-1} rect, .section-${e-1} path, .section-${e-1} circle, .section-${e-1} polygon, .section-${e-1} path {
|
|
13
|
+
fill: ${i(t[`cScale`+e],10)};
|
|
14
|
+
stroke: ${i(t[`cScale`+e],10)};
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
.section-${e-1} text {
|
|
18
|
+
fill: ${t[`cScaleLabel`+e]};
|
|
19
|
+
}
|
|
20
|
+
.node-icon-${e-1} {
|
|
21
|
+
font-size: 40px;
|
|
22
|
+
color: ${t[`cScaleLabel`+e]};
|
|
23
|
+
}
|
|
24
|
+
.section-edge-${e-1}{
|
|
25
|
+
stroke: ${t[`cScale`+e]};
|
|
26
|
+
}
|
|
27
|
+
.edge-depth-${e-1}{
|
|
28
|
+
stroke-width: ${r};
|
|
29
|
+
}
|
|
30
|
+
.section-${e-1} line {
|
|
31
|
+
stroke: ${t[`cScaleInv`+e]} ;
|
|
32
|
+
stroke-width: 3;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.disabled, .disabled circle, .disabled text {
|
|
36
|
+
fill: lightgray;
|
|
37
|
+
}
|
|
38
|
+
.disabled text {
|
|
39
|
+
fill: #efefef;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.node rect,
|
|
43
|
+
.node circle,
|
|
44
|
+
.node ellipse,
|
|
45
|
+
.node polygon,
|
|
46
|
+
.node path {
|
|
47
|
+
fill: ${t.background};
|
|
48
|
+
stroke: ${t.nodeBorder};
|
|
49
|
+
stroke-width: 1px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.kanban-ticket-link {
|
|
53
|
+
fill: ${t.background};
|
|
54
|
+
stroke: ${t.nodeBorder};
|
|
55
|
+
text-decoration: underline;
|
|
56
|
+
}
|
|
57
|
+
`}return n},`genSections`),j={db:O,renderer:k,parser:_,styles:e(e=>`
|
|
58
|
+
.edge {
|
|
59
|
+
stroke-width: 3;
|
|
60
|
+
}
|
|
61
|
+
${A(e)}
|
|
62
|
+
.section-root rect, .section-root path, .section-root circle, .section-root polygon {
|
|
63
|
+
fill: ${e.git0};
|
|
64
|
+
}
|
|
65
|
+
.section-root text {
|
|
66
|
+
fill: ${e.gitBranchLabel0};
|
|
67
|
+
}
|
|
68
|
+
.icon-container {
|
|
69
|
+
height:100%;
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
align-items: center;
|
|
73
|
+
}
|
|
74
|
+
.edge {
|
|
75
|
+
fill: none;
|
|
76
|
+
}
|
|
77
|
+
.cluster-label, .label {
|
|
78
|
+
color: ${e.textColor};
|
|
79
|
+
fill: ${e.textColor};
|
|
80
|
+
}
|
|
81
|
+
.kanban-label {
|
|
82
|
+
dy: 1em;
|
|
83
|
+
alignment-baseline: middle;
|
|
84
|
+
text-anchor: middle;
|
|
85
|
+
dominant-baseline: middle;
|
|
86
|
+
text-align: center;
|
|
87
|
+
}
|
|
88
|
+
${u()}
|
|
89
|
+
`,`getStyles`)};export{j as diagram};
|