@objectstack/console 7.1.0 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AiPendingActionsPage-DfPQB-bV.js → AiPendingActionsPage-DYX4ANzZ.js} +1 -1
- package/dist/assets/ApiConsolePage-C70S6MYv.js +1 -0
- package/dist/assets/{AppManagementPage-DuIaI8a2.js → AppManagementPage-BnwBNW_m.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-CQQmK4Pz.js +1 -0
- package/dist/assets/{AuditLogPage-CDXmY4Lg.js → AuditLogPage-C1CgKWC8.js} +1 -1
- package/dist/assets/ComponentNavView-g_X1YUdk.js +1 -0
- package/dist/assets/{ConsoleFloatingChatbot-c1A9X4w7.js → ConsoleFloatingChatbot-DJW7zeKU.js} +1 -1
- package/dist/assets/{DeveloperHubPage-E4ydudW4.js → DeveloperHubPage-CcV4mWRr.js} +1 -1
- package/dist/assets/FlowRunsPage-Rtd6u1e_.js +1 -0
- package/dist/assets/MonacoImpl-DcAVOHcx.js +1 -0
- package/dist/assets/{ProfilePage-4wnWye8l.js → ProfilePage-DPGkAZWG.js} +1 -1
- package/dist/assets/PublicFormsPage-BNIOSFr1.js +1 -0
- package/dist/assets/RecentItemsProvider-Dt0K6V1V.js +1 -0
- package/dist/assets/{SettingsHub-B4d9Pn8t.js → SettingsHub-4RDkAyKq.js} +1 -1
- package/dist/assets/{SettingsView-cRQBVn6H.js → SettingsView-_5h2mExc.js} +1 -1
- package/dist/assets/{SystemHubPage-DIKmhwy1.js → SystemHubPage-DRRxgNWV.js} +1 -1
- package/dist/assets/data-adapter-Bi1Re1fK.js +1 -0
- package/dist/assets/dist-Dal4BOHf.js +11 -0
- package/dist/assets/{framework-ClI3DbWX.js → framework-DVkqUSPj.js} +4 -4
- package/dist/assets/{highlighted-body-OFNGDK62-Dynkkk0t.js → highlighted-body-OFNGDK62-Dp9QBuY-.js} +1 -1
- package/dist/assets/index-DWtLSzKK.js +33 -0
- package/dist/assets/index-JLLCOoA3.css +2 -0
- package/dist/assets/infrastructure-IQKE4Vv8.js +3 -0
- package/dist/assets/mermaid-GHXKKRXX-PDO-QkSF.js +1 -0
- package/dist/assets/plugin-calendar-D1wyyvEx.js +1 -0
- package/dist/assets/{plugin-charts-Mt2y8Sdm.js → plugin-charts-DrCI3cJo.js} +2 -2
- package/dist/assets/{plugin-chatbot-DXGXTdLU.js → plugin-chatbot-CiVctLlf.js} +8 -8
- package/dist/assets/plugin-dashboard-BRn9AjyQ.js +3 -0
- package/dist/assets/{plugin-form-BBc-xwrZ.js → plugin-form-KOOMD5ZY.js} +1 -1
- package/dist/assets/plugin-gantt-D3OFukY1.js +1 -0
- package/dist/assets/plugin-grid-DGQxmfxn.js +6 -0
- package/dist/assets/plugin-kanban-C-qMP4VL.js +1 -0
- package/dist/assets/plugin-map-DRf0LmJy.js +1 -0
- package/dist/assets/plugin-markdown-BVFW0U6V.js +7 -0
- package/dist/assets/plugin-report-CJSBthhg.js +59 -0
- package/dist/assets/plugin-timeline-RAn1F_nX.js +1 -0
- package/dist/assets/plugin-view-DspcF1Mc.js +1 -0
- package/dist/assets/plugins-views-DUx-xpiH.js +4 -0
- package/dist/assets/src-DL8N52oz.js +2 -0
- package/dist/assets/{types-BsFD2pPK.js → types-CbmNTewl.js} +1 -1
- package/dist/assets/ui-components-CIdYg6m3.js +41 -0
- package/dist/assets/ui-layout-DGPxy1gI.js +1 -0
- package/dist/assets/{vendor-charts-vh1WJI0j.js → vendor-charts-Ba_-W-di.js} +3 -3
- package/dist/assets/{vendor-dndkit-0jp7h5ty.js → vendor-dndkit-CucFgdMa.js} +1 -1
- package/dist/assets/{vendor-i18n-CnFu8bdi.js → vendor-i18n-DPyFo2xM.js} +1 -1
- package/dist/assets/{vendor-icons-core-D5MicM14.js → vendor-icons-core-Cx2WYOuR.js} +1 -1
- package/dist/assets/{vendor-markdown-CvMSBmgq.js → vendor-markdown-B0mCB2Nu.js} +2 -2
- package/dist/assets/vendor-objectstack-B3zP6Fz_.js +65 -0
- package/dist/assets/{vendor-radix-BNWIlSsV.js → vendor-radix-thTS_QfF.js} +1 -1
- package/dist/assets/vendor-react-CyVA1SE-.js +13 -0
- package/dist/assets/{vendor-sentry-D5yZpZ5X.js → vendor-sentry-DjMgMAaz.js} +1 -1
- package/dist/assets/{vendor-ui-utils-D3GsyZyi.js → vendor-ui-utils-BbOuugky.js} +1 -1
- package/dist/favicon.svg +11 -0
- package/dist/index.html +7 -7
- package/dist/logo.svg +15 -0
- package/dist/manifest.json +2 -2
- package/package.json +1 -1
- package/dist/assets/ApiConsolePage-CVt86JW9.js +0 -1
- package/dist/assets/ApprovalsInboxPage-BRv2RqN4.js +0 -1
- package/dist/assets/ComponentNavView-B2VAx_8W.js +0 -1
- package/dist/assets/FlowRunsPage-CF-nkx9E.js +0 -1
- package/dist/assets/MonacoImpl-CKoKq1tG.js +0 -11
- package/dist/assets/PublicFormsPage-B1cdfwoQ.js +0 -1
- package/dist/assets/data-adapter-Be-s1kWX.js +0 -1
- package/dist/assets/index-D7iz-IIn.js +0 -24
- package/dist/assets/index-Db8Nmh4R.css +0 -2
- package/dist/assets/infrastructure-ezj3FgNE.js +0 -3
- package/dist/assets/mermaid-GHXKKRXX-DJsGdxYj.js +0 -1
- package/dist/assets/plugin-calendar-wl24Whh9.js +0 -1
- package/dist/assets/plugin-dashboard-DqF5vvlQ.js +0 -3
- package/dist/assets/plugin-gantt-scBgVq2Q.js +0 -1
- package/dist/assets/plugin-grid-u5JmW5Ui.js +0 -6
- package/dist/assets/plugin-kanban-0qj1Kr3T.js +0 -1
- package/dist/assets/plugin-map-CjA33cHV.js +0 -1
- package/dist/assets/plugin-markdown-BPsaoDf-.js +0 -7
- package/dist/assets/plugin-report-C35V4A8F.js +0 -59
- package/dist/assets/plugin-timeline-Bmy8v-AN.js +0 -1
- package/dist/assets/plugin-view-tV_8MnpT.js +0 -1
- package/dist/assets/plugins-views-DM6-O61C.js +0 -4
- package/dist/assets/src-BJJhwsID.js +0 -2
- package/dist/assets/ui-components-DYQ4Pai7.js +0 -41
- package/dist/assets/ui-layout-Dmw4Ab7P.js +0 -1
- package/dist/assets/vendor-objectstack-CwZ3saTl.js +0 -65
- package/dist/assets/vendor-react-CIpZOxG3.js +0 -13
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{g as t,r as n}from"./vendor-react-CIpZOxG3.js";var r=e(t(),1),i=(0,r.createContext)(null);i.displayName=`AuthContext`;var a=`1.6.11`,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();if(o.length>0&&o[0]===`"`&&o.endsWith(`"`)&&!o.slice(1,-1).includes(`"`))return o.slice(1,-1);let 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 ee(e,t={strict:!0}){return S(e,t)}var C=[],w=0,T=4,E=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=w+T;t<C.length;)C[t]===e?C.splice(t,T):t+=T;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){E.epoch++;let i=!C.length;for(let i of t)C.push(i,n.value,e,r);if(i){for(w=0;w<C.length;w+=T)C[w](C[w+1],C[w+2],C[w+3]);C.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,A=(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])}),ne=1e3,j=(e,t)=>A(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]=[]}},ne)},()=>{e.listen=n,e.off=r}}),re=()=>typeof window>`u`,M=(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()=>{re()||(o?await a():j(i,()=>{let e=setTimeout(async()=>{o||(o=!0,await a())},0);return()=>{i.off(),t.off(),clearTimeout(e)}}))});return i},N=()=>Math.floor(Date.now()/1e3);function P(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}var F=5;function ie(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=N(),n.set(!n.get());return}let i=t.get(),a=()=>{c.lastSessionRequest=N(),r(`/get-session`).then(async e=>{let{data:a,error:o}=P(e);if(a?.needsRefresh)try{let e=await r(`/get-session`,{method:`POST`});({data:a,error:o}=P(e))}catch{}let s=a?.session&&a?.user?a:null;t.set({...i,data:s,error:o}),c.lastSync=N(),n.set(!n.get())}).catch(()=>{})};if(e?.event===`poll`){a();return}if(e?.event===`visibilitychange`){if(N()-c.lastSessionRequest<F)return;c.lastSessionRequest=N()}if(e?.event===`visibilitychange`){a();return}(i?.data===null||i?.data===void 0)&&(c.lastSync=N(),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 I=Object.create(null),L=e=>({}),R=new Proxy(I,{get(e,t){return L()[t]??I[t]},has(e,t){return t in L()||t in I},set(e,t,n){let r=L(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=L(!0);return delete n[t],!0},ownKeys(){let e=L(!0);return Object.keys(e)}});function z(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 z(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return z(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return z(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return z(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return z(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return z(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return z(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function ae(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}function oe(){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 se(e){let t=e.split(`
|
|
2
|
-
at `);return t.length<=1?e:(t.splice(1,1),t.join(`
|
|
3
|
-
at `))}function ce(e,t){class n extends e{#e;constructor(...e){if(oe()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=se(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 B={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};ce(class extends Error{constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:B[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 V=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}};function H(e){try{return(new URL(e).pathname.replace(/\/+$/,``)||`/`)!==`/`}catch{throw new V(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function U(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new V(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof V?t:new V(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function W(e,t=`/api/auth`){if(U(e),H(e))return e;let n=e.replace(/\/+$/,``);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function G(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 K(e,t,n,r,i){if(e)return W(e,t);if(r!==!1){let e=R.BETTER_AUTH_URL||R.NEXT_PUBLIC_BETTER_AUTH_URL||R.PUBLIC_BETTER_AUTH_URL||R.NUXT_PUBLIC_BETTER_AUTH_URL||R.NUXT_PUBLIC_AUTH_URL||(R.BASE_URL===`/`?void 0:R.BASE_URL);if(e)return W(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&G(o,`proto`)&&G(a,`host`))try{return W(`${o}://${a}`,t)}catch{}if(n){let e=le(n.url);if(!e)throw new V(`Could not get origin from request. Please provide a valid base URL.`);return W(e,t)}if(typeof window<`u`&&window.location)return W(window.location.origin,t)}function le(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var ue={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function de(e,t){let n=D(!1),r=M(n,`/get-session`,e,{method:`GET`}),i=()=>{};return j(r,()=>{let a=ie({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 fe(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 pe(e,t,n=`.`,r){if(!fe(t))return pe(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]]:fe(a)&&fe(i[t])?i[t]=pe(a,i[t],(n?`${n}.`:``)+t.toString(),r):i[t]=a))}return i}function me(e){return(...t)=>t.reduce((t,n)=>pe(t,n,``,e),{})}var he=me(),ge=Object.defineProperty,_e=Object.defineProperties,ve=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,Se=(e,t,n)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t)=>{for(var n in t||={})be.call(t,n)&&Se(e,n,t[n]);if(ye)for(var n of ye(t))xe.call(t,n)&&Se(e,n,t[n]);return e},J=(e,t)=>_e(e,ve(t)),Ce=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)}},we=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}},Te=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}},Ee=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 De(e){if(typeof e==`number`)return new Te({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new Te(e);case`exponential`:return new Ee(e);default:throw Error(`Invalid retry strategy`)}}var Oe=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},ke=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ae(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 ke.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function je(e){try{return JSON.parse(e),!0}catch{return!1}}function Me(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 Ne(e){try{return JSON.parse(e)}catch{return e}}function Pe(e){return typeof e==`function`}function Fe(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&Pe(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&Pe(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}async function Ie(e){let t=new Headers(e?.headers),n=await Oe(e);for(let[e,r]of Object.entries(n||{}))t.set(e,r);if(!t.has(`content-type`)){let n=Le(e?.body);n&&t.set(`content-type`,n)}return t}function Le(e){return Me(e)?`application/json`:null}function Re(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(Me(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`&&Me(e.body)?new URLSearchParams(e.body).toString():e.body}function ze(e,t){if(t?.method)return t.method.toUpperCase();if(e.startsWith(`@`)){let n=e.split(`@`)[1]?.split(`/`)[0];return He.includes(n)?n.toUpperCase():t?.body?`POST`:`GET`}return t?.body?`POST`:`GET`}function Be(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Ve=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function Y(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Ve(n.issues);return n.value}var He=[`get`,`post`,`put`,`patch`,`delete`],Ue=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=J(q({},n),{method:i.method,output:i.output});return n?.disableValidation||(e=J(q({},e),{body:i.input?await Y(i.input,n?.body):n?.body,params:i.params?await Y(i.params,n?.params):n?.params,query:i.query?await Y(i.query,n?.query):n?.query})),{url:t,options:e}}}return{url:t,options:n}}}),We=e=>{async function t(t,n){let r=J(q(q({},e),n),{plugins:[...e?.plugins||[],Ue(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await Ke(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 Ke(t,r)}return t};function Ge(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];He.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 Ke=async(e,t)=>{let{hooks:n,url:r,options:i}=await we(e,t),a=Fe(i),o=new AbortController,s=i.signal??o.signal,c=Ge(r,i),l=Re(i),u=await Ie(i),d=ze(r,i),f=J(q({},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}=Be(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(J(q({},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=Ae(m),r={data:null,response:m,request:f};if(e===`json`||e===`text`){let e=await m.text();r.data=await(f.jsonParser??Ne)(e)}else r.data=await m[e]();f?.output&&f.output&&!f.disableValidation&&(r.data=await Y(f.output,r.data));for(let e of n.onSuccess)e&&await e(J(q({},r),{response:t?.hookOptions?.cloneResponse?m.clone():m}));return t?.throw?r.data:{data:r.data,error:null}}let g=t?.jsonParser??Ne,_=await m.text(),v=je(_),y=v?await g(_):null,b={response:m,responseText:_,request:f,error:J(q({},y),{status:m.status,statusText:m.statusText})};for(let e of n.onError)e&&await e(J(q({},b),{response:t?.hookOptions?.cloneResponse?m.clone():m}));if(t?.retry){let r=De(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 Ke(e,J(q({},t),{retryAttempt:i+1}))}}if(t?.throw)throw new Ce(m.status,m.statusText,v?y:_);return{data:null,error:J(q({},y),{status:m.status,statusText:m.statusText})}},qe=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{}}},Je=(e,t)=>{let n=`credentials`in Request.prototype,r=K(e?.baseURL,e?.basePath,void 0,t)??qe(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=We({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?ee(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[ue],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=de(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=he(t.getActions?.(d,b,e)??{},g));return{get baseURL(){return r},pluginsActions:g,pluginsAtoms:_,pluginPathMethods:v,atomListeners:y,$fetch:d,$store:b}};function Ye(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function Xe(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 Ze(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`||Ye(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=Xe(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 Qe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function $e(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,$fetch:i,atomListeners:a,$store:o}=Je(e),s={};for(let[e,t]of Object.entries(r))s[`use${Qe(e)}`]=t;return Ze({...n,...s,$fetch:i,$store:o},i,t,r,a)}function et(e){return{authorize(t,n=`AND`){let r=!1;for(let[i,a]of Object.entries(t)){let t=e[i];if(!t)return{success:!1,error:`You are not allowed to access resource: ${i}`};if(Array.isArray(a))r=a.every(e=>t.includes(e));else if(typeof a==`object`){let e=a;r=e.connector===`OR`?e.actions.some(e=>t.includes(e)):e.actions.every(e=>t.includes(e))}else throw new V(`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 tt(e){return{newRole(e){return et(e)},statements:e}}var nt=ae({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`}),rt=tt({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),it=rt.newRole({organization:[`update`],invitation:[`create`,`cancel`],member:[`create`,`update`,`delete`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),at=rt.newRole({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),ot=rt.newRole({organization:[],member:[],invitation:[],team:[],ac:[`read`]}),st={admin:it,owner:at,member:ot},ct=(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},lt=e=>ct(e,e.options.roles||st),ut=e=>{let t=D(!1),n=D(!1),r=D(!1),i=D(!1),o={admin:it,member:ot,owner:at,...e?.roles};return{id:`organization`,version:a,$InferServerPlugin:{},getActions:(t,n,r)=>({$Infer:{ActiveOrganization:{},Organization:{},Invitation:{},Member:{},Team:{}},organization:{checkRolePermission:t=>lt({role:t.role,options:{ac:e?.ac,roles:o},permissions:t.permissions})}}),getAtoms:e=>{let a=M(t,`/organization/list`,e,{method:`GET`});return{$listOrg:t,$activeOrgSignal:n,$activeMemberSignal:r,$activeMemberRoleSignal:i,activeOrganization:M([n],`/organization/get-full-organization`,e,()=>({method:`GET`})),listOrganizations:a,activeMember:M([n,r],`/organization/get-active-member`,e,{method:`GET`}),activeMemberRole:M([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:nt}},X=`auth-session-token`,Z={_memoryToken:null,get(){try{if(typeof localStorage<`u`)return localStorage.getItem(X)}catch{}return this._memoryToken},set(e){this._memoryToken=e;try{typeof localStorage<`u`&&localStorage.setItem(X,e)}catch{}},clear(){this._memoryToken=null;try{typeof localStorage<`u`&&localStorage.removeItem(X)}catch{}}};function dt(e){try{let t=new URL(e);return{origin:t.origin,basePath:t.pathname.replace(/\/$/,``)}}catch{return{origin:ft()??`http://localhost`,basePath:e.replace(/\/$/,``)}}}function ft(){try{if(typeof window<`u`&&window.location?.origin)return window.location.origin}catch{}}function pt(e){let t=e||globalThis.fetch.bind(globalThis);return async(e,n)=>{let r=new Headers(n?.headers),i=Z.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&&Z.set(o),a}}function mt(e){let{baseURL:t,fetchFn:n}=e,{origin:r,basePath:i}=dt(t),a=pt(n),o=$e({baseURL:r,basePath:i,disableDefaultFetchPlugins:!0,fetchOptions:{customFetchImpl:a},plugins:[ut()]});return{async signIn(e){let{data:t,error:n}=await o.signIn.email({email:e.email,password:e.password});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`);let r=t;return r.session?.token&&Z.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 Error(n.message??`Auth request failed with status ${n.status}`);let r=t,i=r.token??r.session?.token??null;i&&Z.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(Z.clear(),e)throw Error(e.message??`Auth request failed with status ${e.status}`)},async getSession(){let{data:e,error:t}=await o.getSession();if(t||!e)return null;let n=e;return n.session?.token&&Z.set(n.session.token),{user:n.user,session:n.session}},async forgotPassword(e){let t=o.forgetPassword,{error:n}=await t({email:e,redirectTo:`/`});if(n)throw Error(n.message??`Auth request failed with status ${n.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{error:n}=await t({providerId:e,callbackURL:r,errorCallbackURL:i});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`);return}let{error:a}=await o.signIn.social({provider:e,callbackURL:r,errorCallbackURL:i});if(a)throw Error(a.message??`Auth request failed with status ${a.status}`)},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 ht=`auth-active-organization-id`,Q={_memoryValue:null,get(){try{if(typeof localStorage<`u`)return localStorage.getItem(ht)}catch{}return this._memoryValue},set(e){this._memoryValue=e;try{typeof localStorage<`u`&&localStorage.setItem(ht,e)}catch{}},clear(){this._memoryValue=null;try{typeof localStorage<`u`&&localStorage.removeItem(ht)}catch{}}};function gt(){return async(e,t)=>{let n=new Headers(t?.headers),r=Z.get();if(r){let t=typeof e==`string`?e:e instanceof URL?e.href:e.url;/\/api\//i.test(t)&&n.set(`Authorization`,`Bearer ${r}`)}let i=Q.get();return i&&n.set(`X-Tenant-ID`,i),fetch(e,{...t,headers:n})}}var $=n();function _t({authUrl:e,client:t,onAuthStateChange:n,enabled:a=!0,previewMode:o,children:s}){let c=(0,r.useMemo)(()=>t??mt({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),[ee,C]=(0,r.useState)(!1),w=o!=null,T=a&&!w?l!==null&&d!==null:!0;(0,r.useEffect)(()=>{if(w){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,w,o]),(0,r.useEffect)(()=>{n?.({user:l,session:d,isAuthenticated:T,isLoading:p,error:h})},[l,d,T,p,h,n]);let E=(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]),A=(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]),ne=(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]),j=(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]),re=(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]),M=(0,r.useCallback)(()=>c.hasLocalPassword(),[c]),N=(0,r.useCallback)(()=>c.getConfig(),[c]),P=(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]),F=(0,r.useCallback)(async()=>{if(!(!a||w)){C(!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{C(!1)}}},[c,a,w,y]),ie=(0,r.useCallback)(async()=>{if(!a||w){let e=w?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,w,o,y]);(0,r.useEffect)(()=>{ie()},[ie]),(0,r.useEffect)(()=>{l&&a&&!w&&F()},[l,a,w]);let I=(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]),L=(0,r.useCallback)(async e=>{g(null);try{let t=await c.createOrganization(e);return await F(),await I(t.id),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw g(t),t}},[c,F,I]),R=(0,r.useCallback)(async(e,t)=>{let n=await c.updateOrganization(e,t);return await F(),y?.id===e&&b(n),n},[c,F,y]),z=(0,r.useCallback)(async e=>{await c.deleteOrganization(e),y?.id===e&&(b(null),Q.clear()),await F()},[c,y,F]),ae=(0,r.useCallback)(async e=>{await c.leaveOrganization(e),y?.id===e&&(b(null),Q.clear()),await F()},[c,y,F]),oe=(0,r.useCallback)(e=>c.getMembers(e),[c]),se=(0,r.useCallback)(e=>c.inviteMember(e),[c]),ce=(0,r.useCallback)(e=>c.removeMember(e),[c]),B=(0,r.useCallback)(e=>c.updateMemberRole(e),[c]),V=(0,r.useCallback)(e=>c.listInvitations(e),[c]),H=(0,r.useCallback)(e=>c.cancelInvitation(e),[c]),U=(0,r.useCallback)(e=>c.getInvitation(e),[c]),W=(0,r.useCallback)(async e=>{await c.acceptInvitation(e),await F()},[c,F]),G=(0,r.useCallback)(e=>c.rejectInvitation(e),[c]),K=(0,r.useCallback)(()=>c.listUserInvitations(),[c]),le=a&&!w,ue=(0,r.useMemo)(()=>({user:l,session:d,isAuthenticated:T,isAuthEnabled:le,isLoading:p,error:h,isPreviewMode:w,previewMode:w?o:null,signIn:E,signUp:D,signOut:te,updateUser:O,forgotPassword:k,sendVerificationEmail:A,resetPassword:ne,changePassword:j,setInitialPassword:re,hasLocalPassword:M,getAuthConfig:N,signInWithProvider:P,organizations:_,activeOrganization:y,activeMember:x,isOrganizationsLoading:ee,switchOrganization:I,createOrganization:L,refreshOrganizations:F,updateOrganization:R,deleteOrganization:z,leaveOrganization:ae,getMembers:oe,inviteMember:se,removeMember:ce,updateMemberRole:B,listInvitations:V,cancelInvitation:H,getInvitation:U,acceptInvitation:W,rejectInvitation:G,listUserInvitations:K}),[l,d,T,le,p,h,w,o,E,D,te,O,k,A,ne,j,re,M,N,P,_,y,x,ee,I,L,F,R,z,ae,oe,se,ce,B,V,H,U,W,G,K]);return(0,$.jsx)(i.Provider,{value:ue,children:s})}function vt(){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 yt=new Set([`owner`,`admin`,`super_admin`,`superadmin`,`platform_admin`,`system_admin`]);function bt(e){return typeof e==`string`&&yt.has(e.toLowerCase())}function xt(){let{activeMember:e,user:t}=vt();return!!(bt(e?.role)||bt(t?.role)||Array.isArray(t?.roles)&&t.roles.some(bt))}function St({fallback:e=null,requiredRoles:t,loadingFallback:n,children:r}){let{isAuthenticated:i,isLoading:a,user:o}=vt();if(a)return(0,$.jsx)($.Fragment,{children:n??null});if(!i)return(0,$.jsx)($.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,$.jsx)($.Fragment,{children:e})}return(0,$.jsx)($.Fragment,{children:r})}function Ct(e){return e?e.name?e.name.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2):e.email?.[0]?.toUpperCase()??`?`:`?`}function wt(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 Tt=[`apps`,`messages`,`validationMessages`,`dashboards`,`globalActions`];function Et(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 Tt)e[t]!==void 0&&(a[t]=e[t]);let o=new Set([`objects`,...Tt]);for(let[t,n]of Object.entries(e))o.has(t)||(a[t]=n);return{app:a}}var Dt=(0,r.createContext)(null);Dt.displayName=`PermissionContext`;var Ot=`/api/v1/auth/me/permissions`;function kt({endpoint:e=Ot,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,$.jsx)($.Fragment,{children:n}):c&&!o?i?(0,$.jsx)($.Fragment,{children:i(c,f)}):(0,$.jsx)($.Fragment,{children:n}):(0,$.jsx)(Dt.Provider,{value:_,children:a})}function At(){let e=(0,r.useContext)(Dt);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 jt(e){let{checkField:t,getFieldPermissions:n}=At(),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{Et as a,xt as c,gt as d,wt as i,vt as l,At as n,Ct as o,kt as r,St as s,jt as t,_t as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./plugin-chatbot-DXGXTdLU.js";export{e as Mermaid};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{g as n,r}from"./vendor-react-CIpZOxG3.js";import{H as i,M as a,at as o,ot as s,r as c,ut as l}from"./framework-ClI3DbWX.js";import{$t as u,Bn as d,Bt as f,Fn as p,Ht as m,In as h,Ln as g,Oo as _,Qt as v,Rn as y,Rt as b,Ti as x,Vt as S,Zn as C,Zt as w,bo as T,en as E,es as D,in as O,jt as k,mr as A,xo as j,zn as ee,zt as te}from"./ui-components-DYQ4Pai7.js";import{i as M,r as N}from"./plugins-views-DM6-O61C.js";import{a as ne}from"./plugin-grid-u5JmW5Ui.js";var P=e(n(),1),F=r(),re=`bg-blue-100 text-blue-900 border border-blue-200`,ie=new Date,I=[`bg-blue-100 text-blue-900 border border-blue-200`,`bg-emerald-100 text-emerald-900 border border-emerald-200`,`bg-amber-100 text-amber-900 border border-amber-200`,`bg-rose-100 text-rose-900 border border-rose-200`,`bg-violet-100 text-violet-900 border border-violet-200`,`bg-cyan-100 text-cyan-900 border border-cyan-200`,`bg-orange-100 text-orange-900 border border-orange-200`,`bg-fuchsia-100 text-fuchsia-900 border border-fuchsia-200`],L=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,R=/(^|\s)(bg|text|from|to|via)-/;function z(e){if(!e)return{className:re};if(L.test(e))return{className:`text-white`,inlineColor:e};if(R.test(e))return{className:e};let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return{className:I[Math.abs(t)%I.length]}}var ae={"calendar.today":`Today`,"calendar.month":`Month`,"calendar.week":`Week`,"calendar.day":`Day`,"calendar.newEvent":`New event`,"calendar.moreEvents":`+{{count}} more`,"calendar.allDay":`all-day`};function B(){try{let e=c();return e.t(`calendar.today`)===`calendar.today`?{t:(e,t)=>{let n=ae[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}:{t:e.t,language:e.language}}catch{return{t:(e,t)=>{let n=ae[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}}}function V({events:e=[],view:t=`month`,currentDate:n=ie,locale:r=`default`,onEventClick:i,onDateClick:a,onViewChange:o,onNavigate:s,onAddClick:c,onEventDrop:l,onTimeRangeSelect:d,slotMinutes:p=30,className:h}){let[g,y]=P.useState(t),[E,O]=P.useState(n),{t:k,language:ee}=B(),M=r===`default`?ee:r;P.useEffect(()=>{O(n)},[n]),P.useEffect(()=>{y(t)},[t]);let N=P.useRef(o);N.current=o,P.useEffect(()=>{let e=window.matchMedia(`(max-width: 639px)`),t=e=>{e.matches&&(y(`day`),N.current?.(`day`))};return t(e),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let ne=()=>{let e=new Date(E);g===`month`?e.setMonth(e.getMonth()-1):g===`week`?e.setDate(e.getDate()-7):e.setDate(e.getDate()-1),O(e),s?.(e)},re=()=>{let e=new Date(E);g===`month`?e.setMonth(e.getMonth()+1):g===`week`?e.setDate(e.getDate()+7):e.setDate(e.getDate()+1),O(e),s?.(e)},I=()=>{let e=new Date;O(e),s?.(e)},L=e=>{y(e),o?.(e)},R=()=>{if(g===`month`)return E.toLocaleDateString(M,{month:`long`,year:`numeric`});if(g===`week`){let e=H(E),t=new Date(e);return t.setDate(t.getDate()+6),`${e.toLocaleDateString(M,{month:`short`,day:`numeric`})} - ${t.toLocaleDateString(M,{month:`short`,day:`numeric`,year:`numeric`})}`}else return E.toLocaleDateString(M,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})},z=P.useRef(0);return(0,F.jsxs)(`div`,{role:`region`,"aria-label":`Calendar`,className:D(`flex flex-col h-full bg-background min-w-0 overflow-hidden`,h),children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center bg-muted/50 rounded-lg p-1 gap-1`,children:[(0,F.jsx)(A,{variant:`ghost`,size:`sm`,onClick:I,className:`h-8`,"aria-label":`Go to today`,children:k(`calendar.today`)}),(0,F.jsx)(`div`,{className:`h-4 w-px bg-border mx-1`}),(0,F.jsx)(A,{variant:`ghost`,size:`icon`,"aria-label":`Previous period`,onClick:ne,className:`h-8 w-8`,children:(0,F.jsx)(j,{className:`h-4 w-4`})}),(0,F.jsx)(A,{variant:`ghost`,size:`icon`,"aria-label":`Next period`,onClick:re,className:`h-8 w-8`,children:(0,F.jsx)(T,{className:`h-4 w-4`})})]}),(0,F.jsxs)(w,{children:[(0,F.jsx)(u,{asChild:!0,children:(0,F.jsxs)(A,{variant:`ghost`,"aria-label":`Current date: ${R()}`,className:D(`text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors`,`flex items-center gap-2`),children:[(0,F.jsx)(_,{className:`h-5 w-5 text-muted-foreground`}),(0,F.jsx)(`span`,{children:R()})]})}),(0,F.jsx)(v,{className:`w-auto p-0`,align:`start`,children:(0,F.jsx)(C,{mode:`single`,selected:E,onSelect:e=>{e&&(O(e),s?.(e))},autoFocus:!0,startMonth:new Date(2e3,0),endMonth:new Date(2050,11)})})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(b,{value:g,onValueChange:L,children:[(0,F.jsx)(S,{className:`w-32 bg-background`,children:(0,F.jsx)(m,{})}),(0,F.jsxs)(te,{children:[(0,F.jsx)(f,{value:`day`,children:k(`calendar.day`)}),(0,F.jsx)(f,{value:`week`,children:k(`calendar.week`)}),(0,F.jsx)(f,{value:`month`,children:k(`calendar.month`)})]})]}),c&&(0,F.jsxs)(A,{onClick:c,size:`sm`,className:`gap-1`,children:[(0,F.jsx)(x,{className:`h-4 w-4`}),k(`calendar.newEvent`)]})]})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-auto`,onTouchStart:e=>{z.current=e.touches[0].clientX},onTouchEnd:e=>{let t=z.current-e.changedTouches[0].clientX;if(Math.abs(t)>50){let e=new Date(E);g===`day`?e.setDate(e.getDate()+(t>0?1:-1)):g===`week`?e.setDate(e.getDate()+(t>0?7:-7)):e.setMonth(e.getMonth()+(t>0?1:-1)),O(e),s?.(e)}},children:[g===`month`&&(0,F.jsx)(W,{date:E,events:e,locale:M,onEventClick:i,onDateClick:a,onEventDrop:l}),g===`week`&&(0,F.jsx)(Y,{mode:`week`,date:E,events:e,locale:M,slotMinutes:p,onEventClick:i,onEventDrop:l,onTimeRangeSelect:d}),g===`day`&&(0,F.jsx)(Y,{mode:`day`,date:E,events:e,locale:M,slotMinutes:p,onEventClick:i,onEventDrop:l,onTimeRangeSelect:d})]})]})}function H(e){let t=new Date(e),n=t.getDay(),r=t.getDate()-n;return t.setDate(r),t}function oe(e){let t=e.getFullYear(),n=e.getMonth(),r=new Date(t,n,1),i=new Date(t,n+1,0),a=r.getDay(),o=[];for(let e=a-1;e>=0;e--){let t=new Date(r.getTime());t.setDate(t.getDate()-(e+1)),o.push(t)}for(let e=1;e<=i.getDate();e++)o.push(new Date(t,n,e));let s=42-o.length;for(let e=1;e<=s;e++){let t=new Date(i.getTime());t.setDate(t.getDate()+e),o.push(t)}return o}function U(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function W({date:e,events:t,locale:n=`default`,onEventClick:r,onDateClick:i,onEventDrop:a}){let o=P.useMemo(()=>oe(e),[e.getFullYear(),e.getMonth()]),s=P.useMemo(()=>new Date,[]),{t:c}=B(),l=P.useMemo(()=>{let e=new Date(2024,0,7);return Array.from({length:7},(t,r)=>{let i=new Date(e);return i.setDate(i.getDate()+r),i.toLocaleDateString(n,{weekday:`short`})})},[n]),[u,d]=P.useState(null),[f,p]=P.useState(null),m=P.useMemo(()=>{let e=new Map;for(let n of t){let t=new Date(n.start),r=n.end?new Date(n.end):new Date(t);t.setHours(0,0,0,0),r.setHours(0,0,0,0);let i=new Date(t);for(;i<=r;){let a=`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`,o=i.getTime()===t.getTime(),s=i.getTime()===r.getTime(),c=o||s||i.getDay()===0,l=e.get(a),u={event:n,isTitleDay:c,isSpanStart:o,isSpanEnd:s};l?l.push(u):e.set(a,[u]),i.setDate(i.getDate()+1)}}return e},[t]),h=(e,t,n=`move`,r)=>{d(t.id),e.dataTransfer.effectAllowed=`move`;let i={id:t.id,mode:n,...r?{sourceDay:`${r.getFullYear()}-${r.getMonth()}-${r.getDate()}`}:{}};e.dataTransfer.setData(`text/plain`,JSON.stringify(i)),n===`resize-end`&&e.stopPropagation()},g=()=>{d(null),p(null)},_=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,p(t)},v=e=>{e.currentTarget.contains(e.relatedTarget)||p(null)},y=(e,n)=>{if(e.preventDefault(),p(null),d(null),!a)return;let r=e.dataTransfer.getData(`text/plain`),i;try{i=JSON.parse(r)}catch{i={id:r,mode:`move`}}let o=t.find(e=>String(e.id)===String(i.id));if(!o)return;let s=new Date(n);if(s.setHours(0,0,0,0),i.mode===`resize-end`){let e=o.end?new Date(o.end):new Date(o.start),t=new Date(e);if(t.setHours(0,0,0,0),s.getTime()===t.getTime())return;let n=new Date(o.start);if(n.setHours(0,0,0,0),s.getTime()<n.getTime())return;let r=new Date(s);r.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),0),a(o,new Date(o.start),r);return}let c=new Date(o.start),l;if(i.sourceDay){let[e,t,n]=i.sourceDay.split(`-`).map(e=>parseInt(e,10));l=new Date(e,t,n)}else l=new Date(c);l.setHours(0,0,0,0);let u=s.getTime()-l.getTime();if(u===0)return;let f=new Date(c.getTime()+u),m;o.end&&(m=new Date(new Date(o.end).getTime()+u)),a(o,f,m)};return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsx)(`div`,{role:`row`,className:`grid grid-cols-7 border-b`,children:l.map(e=>(0,F.jsx)(`div`,{role:`columnheader`,className:`p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0`,children:e},e))}),(0,F.jsx)(`div`,{role:`grid`,"aria-label":`Calendar grid`,className:`grid grid-cols-7 flex-1 auto-rows-fr`,children:o.map((t,n)=>{let o=`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`,l=m.get(o)||[],d=t.getMonth()===e.getMonth(),p=U(t,s);return(0,F.jsxs)(`div`,{role:`gridcell`,"aria-label":`${t.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${l.length>0?`, ${l.length} event${l.length>1?`s`:``}`:``}`,className:D(`border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50`,!d&&`bg-muted/50 text-muted-foreground opacity-50`,f===n&&`ring-2 ring-primary`),onClick:()=>i?.(t),onDragOver:e=>_(e,n),onDragLeave:v,onDrop:e=>y(e,t),children:[(0,F.jsx)(`div`,{className:D(`text-sm font-medium mb-2`,p&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6`),...p?{"aria-current":`date`}:{},children:t.getDate()}),(0,F.jsxs)(`div`,{className:`space-y-0.5`,children:[l.slice(0,4).map(({event:e,isTitleDay:n,isSpanStart:i,isSpanEnd:o},s)=>{let c=!n,{className:l,inlineColor:d}=z(e.color),f=!!a&&o;return(0,F.jsxs)(`div`,{role:`button`,title:e.title,"aria-label":e.title,draggable:!!a,onDragStart:n=>h(n,e,`move`,t),onDragEnd:g,className:D(`relative text-xs hover:opacity-80 truncate`,a?`cursor-move`:`cursor-pointer`,c?`h-1.5`:`px-2 py-0.5`,i?`rounded-l`:`rounded-l-none`,o?`rounded-r`:`rounded-r-none`,!o&&`-mr-2`,l,u===e.id&&`opacity-50`),style:d?{backgroundColor:d}:void 0,onClick:t=>{t.stopPropagation(),r?.(e)},children:[c?``:e.title,f&&(0,F.jsx)(`span`,{role:`separator`,"aria-label":`Resize event end`,title:`Drag to change end date`,draggable:!0,onDragStart:n=>h(n,e,`resize-end`,t),onDragEnd:g,onClick:e=>e.stopPropagation(),className:`absolute inset-y-0 right-0 w-2 cursor-ew-resize bg-black/25 hover:bg-black/50 rounded-r`})]},`${e.id}-${s}`)}),l.length>4&&(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground px-2`,children:c(`calendar.moreEvents`,{count:l.length-4})})]})]},n)})})]})}var G=48;function K(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function q(e){return e.getHours()*60+e.getMinutes()}function J(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Y({mode:e,date:t,events:n,locale:r=`default`,slotMinutes:i=30,onEventClick:a,onEventDrop:o,onTimeRangeSelect:s}){let{t:c}=B(),l=G*i/60,u=G*24,d=P.useMemo(()=>{if(e===`day`)return[K(t)];let n=H(t);return Array.from({length:7},(e,t)=>{let r=new Date(n);return r.setDate(n.getDate()+t),K(r)})},[e,t.getFullYear(),t.getMonth(),t.getDate()]),f=P.useMemo(()=>new Date,[]),p=P.useCallback(e=>{if(e.allDay)return!0;let t=new Date(e.start),n=e.end?new Date(e.end):new Date(t),r=t.getHours()===0&&t.getMinutes()===0&&t.getSeconds()===0,i=n.getHours()===0&&n.getMinutes()===0&&n.getSeconds()===0,a=n.getTime()-t.getTime();return!!(r&&i||a>=1440*60*1e3)},[]),{allDayEvents:m,timedEvents:h}=P.useMemo(()=>{let e=[],t=[];for(let r of n)p(r)?e.push(r):t.push(r);return{allDayEvents:e,timedEvents:t}},[n,p]),g=P.useMemo(()=>{let e=new Map;for(let t of d)e.set(J(t),[]);for(let t of m){let n=K(new Date(t.start)),r=t.end?new Date(t.end):new Date(t.start),i=K(r);r.getHours()===0&&r.getMinutes()===0&&r.getSeconds()===0&&r.getTime()>n.getTime()&&(i=new Date(i),i.setDate(i.getDate()-1));for(let r of d){let a=K(r);a<n||a>i||e.get(J(r)).push({event:t,isStart:a.getTime()===n.getTime(),isEnd:a.getTime()===i.getTime()})}}return e},[d,m]),_=P.useMemo(()=>{let e=new Map;for(let t of d)e.set(J(t),[]);for(let t of h){let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n.getTime()+3600*1e3);for(let i of d){let a=K(i),o=new Date(a);if(o.setDate(o.getDate()+1),r<=a||n>=o)continue;let s=n<a?a:n,c=r>o?o:r,l=q(s),u=c.getTime()===o.getTime()?1440:q(c);e.get(J(i)).push({event:t,startMin:l,endMin:Math.max(u,l+15),isStart:s.getTime()===n.getTime(),isEnd:c.getTime()===r.getTime()})}}return e},[d,h]),v=P.useMemo(()=>{let e=new Map;for(let[t,n]of _){let r=[...n].sort((e,t)=>e.startMin-t.startMin||e.endMin-t.endMin),i=[],a=[],o=[];for(let e of r){let t=0;for(;i[t]&&i[t].endMin>e.startMin;)t++;i[t]={endMin:e.endMin},a.push({entry:e,col:t})}for(let e=0;e<a.length;e++){let t=a[e],n=t.col;for(let r=0;r<a.length;r++){if(r===e)continue;let i=a[r];i.entry.startMin<t.entry.endMin&&i.entry.endMin>t.entry.startMin&&i.col>n&&(n=i.col)}o.push({...t.entry,col:t.col,cols:n+1})}e.set(t,o)}return e},[_]),y=P.useRef(null),b=P.useRef([]),[x,S]=P.useState(null),C=P.useRef(null);C.current=x;let w=P.useRef(!1),T=P.useCallback((e,t)=>{let n=b.current[t];if(!n)return 0;let r=(e-n.getBoundingClientRect().top+n.scrollTop)/G*60,a=Math.round(r/i)*i;return Math.max(0,Math.min(1440,a))},[i]),E=P.useCallback(e=>{for(let t=0;t<b.current.length;t++){let n=b.current[t];if(!n)continue;let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right)return t}return-1},[]);P.useEffect(()=>{if(!x)return;let e=e=>{let t=x.kind===`select`||x.kind===`move`?E(e.clientX):x.dayIndex,n=t<0?x.dayIndex??0:t,r=T(e.clientY,n);S(e=>e&&(e.kind===`select`?{...e,dayIndex:n>=0?n:e.dayIndex,headMinutes:r}:e.kind===`move`?{...e,dayIndex:n,minutes:r}:{...e,minutes:r}))},t=e=>{let t=C.current;if(!t){S(null);return}try{if(t.kind===`select`&&s){let e=Math.min(t.anchorMinutes,t.headMinutes),n=Math.max(t.anchorMinutes,t.headMinutes),r=e,a=n===e?Math.min(1440,e+i):n,o=d[t.dayIndex]??d[0],c=new Date(o);c.setHours(0,Math.round(r),0,0);let l=new Date(o);l.setHours(0,Math.round(a),0,0),w.current=!0,s(c,l)}else if(t.kind===`move`&&o){let e=n.find(e=>String(e.id)===String(t.eventId));if(e){let n=t.dayIndex<0?0:t.dayIndex,r=t.minutes-t.grabMinuteOffset,a=Math.max(0,Math.min(1440-t.durationMin,Math.round(r/i)*i)),s=d[n]??d[0],c=new Date(s);c.setHours(0,a,0,0);let l=new Date(c.getTime()+t.durationMin*60*1e3);w.current=!0,o(e,c,l)}}else if(t.kind===`resize-top`&&o){let e=n.find(e=>String(e.id)===String(t.eventId));if(e){let n=d[t.dayIndex]??d[0],r=Math.min(t.anchorEndMin-i,Math.max(0,t.minutes)),a=new Date(n);a.setHours(0,r,0,0);let s=new Date(n);s.setHours(0,t.anchorEndMin,0,0),w.current=!0,o(e,a,s)}}else if(t.kind===`resize-bottom`&&o){let e=n.find(e=>String(e.id)===String(t.eventId));if(e){let n=d[t.dayIndex]??d[0],r=Math.max(t.anchorStartMin+i,Math.min(1440,t.minutes)),a=new Date(n);a.setHours(0,t.anchorStartMin,0,0);let s=new Date(n);s.setHours(0,r,0,0),w.current=!0,o(e,a,s)}}}finally{S(null),setTimeout(()=>{w.current=!1},50)}};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[x,d,n,i,o,s,E,T]);let O=P.useMemo(()=>d.map(e=>({weekday:e.toLocaleDateString(r,{weekday:`short`}),day:e.getDate(),month:e.toLocaleDateString(r,{month:`short`}),isToday:U(e,f)})),[d,r,f]),k=P.useMemo(()=>Array.from({length:24},(e,t)=>new Date(2024,0,1,t,0).toLocaleTimeString(r,{hour:`numeric`})),[r]),A=(e,t,n,r)=>{if(!o||e.button!==0)return;e.stopPropagation(),e.preventDefault();let i=T(e.clientY,n);S(r===`body`?{kind:`move`,eventId:t.event.id,grabMinuteOffset:Math.max(0,i-t.startMin),durationMin:t.endMin-t.startMin,dayIndex:n,minutes:i}:r===`top`?{kind:`resize-top`,eventId:t.event.id,anchorEndMin:t.endMin,dayIndex:n,minutes:i}:{kind:`resize-bottom`,eventId:t.event.id,anchorStartMin:t.startMin,dayIndex:n,minutes:i})},j=(e,t)=>{if(!s||e.button!==0)return;e.preventDefault();let n=T(e.clientY,t);S({kind:`select`,dayIndex:t,anchorMinutes:n,headMinutes:n})},ee=e=>{if(!x)return null;if(x.kind===`select`&&x.dayIndex===e){let t=Math.min(x.anchorMinutes,x.headMinutes),n=Math.max(x.anchorMinutes,x.headMinutes);return(0,F.jsx)(`div`,{className:`absolute left-1 right-1 rounded bg-primary/30 border border-primary pointer-events-none z-10`,style:{top:t/60*G,height:Math.max(l,(n-t)/60*G)},"aria-hidden":!0,children:(0,F.jsx)(`div`,{className:`px-2 py-0.5 text-xs font-medium text-primary`,children:X(d[e],t,n,r)})})}if(x.kind===`move`&&x.dayIndex===e){let t=x.minutes-x.grabMinuteOffset,n=Math.max(0,Math.min(1440-x.durationMin,Math.round(t/i)*i));return(0,F.jsx)(`div`,{className:`absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10`,style:{top:n/60*G,height:x.durationMin/60*G},"aria-hidden":!0,children:(0,F.jsx)(`div`,{className:`px-2 py-0.5 text-xs font-medium text-primary`,children:X(d[e],n,n+x.durationMin,r)})})}if((x.kind===`resize-top`||x.kind===`resize-bottom`)&&x.dayIndex===e){let t,n;return x.kind===`resize-top`?(t=Math.min(x.anchorEndMin-i,Math.max(0,x.minutes)),n=x.anchorEndMin):(t=x.anchorStartMin,n=Math.max(x.anchorStartMin+i,Math.min(1440,x.minutes))),(0,F.jsx)(`div`,{className:`absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10`,style:{top:t/60*G,height:(n-t)/60*G},"aria-hidden":!0,children:(0,F.jsx)(`div`,{className:`px-2 py-0.5 text-xs font-medium text-primary`,children:X(d[e],t,n,r)})})}return null};return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,ref:y,children:[(0,F.jsxs)(`div`,{className:`flex border-b sticky top-0 bg-background z-20`,children:[(0,F.jsx)(`div`,{className:`w-14 shrink-0 border-r`,"aria-hidden":!0}),O.map((e,t)=>(0,F.jsxs)(`div`,{role:`columnheader`,className:D(`flex-1 p-2 text-center text-sm border-r last:border-r-0`,e.isToday&&`bg-primary/5`),children:[(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.weekday}),(0,F.jsx)(`div`,{className:D(`font-medium`,e.isToday&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6 mx-auto`),children:e.day})]},t))]}),m.length>0&&(0,F.jsxs)(`div`,{className:`flex border-b bg-muted/20 max-h-[140px] overflow-y-auto`,children:[(0,F.jsx)(`div`,{className:`w-14 shrink-0 border-r flex items-start justify-end pr-1 pt-1 text-[10px] text-muted-foreground sticky left-0 bg-muted/20`,children:c(`calendar.allDay`)===`calendar.allDay`?`all-day`:c(`calendar.allDay`)}),d.map(e=>{let t=J(e);return(0,F.jsx)(`div`,{className:`flex-1 border-r last:border-r-0 min-h-[28px] p-0.5 space-y-0.5`,children:(g.get(t)??[]).map(({event:e,isStart:t,isEnd:n},r)=>{let{className:i,inlineColor:o}=z(e.color);return(0,F.jsx)(`div`,{role:`button`,title:e.title,onClick:t=>{t.stopPropagation(),a?.(e)},className:D(`text-[11px] px-2 py-0.5 truncate cursor-pointer hover:opacity-80`,t?`rounded-l`:`rounded-l-none -ml-0.5`,n?`rounded-r`:`rounded-r-none -mr-0.5`,i),style:o?{backgroundColor:o}:void 0,children:t?e.title:`\xA0`},`${e.id}-${r}`)})},t)})]}),(0,F.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,F.jsxs)(`div`,{className:`flex`,style:{height:u},children:[(0,F.jsx)(`div`,{className:`w-14 shrink-0 border-r relative`,children:k.map((e,t)=>(0,F.jsx)(`div`,{className:`absolute right-1 text-[10px] text-muted-foreground -translate-y-1/2`,style:{top:t*G},children:t===0?``:e},t))}),d.map((e,t)=>{let n=J(e),s=v.get(n)??[];return(0,F.jsxs)(`div`,{ref:e=>{b.current[t]=e},className:`flex-1 border-r last:border-r-0 relative select-none`,style:{height:u},onPointerDown:e=>j(e,t),"aria-label":e.toLocaleDateString(r,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`}),children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`absolute left-0 right-0 border-t border-muted/60 pointer-events-none`,style:{top:t*G}},t)),i<60&&Array.from({length:Math.floor(1440/i)},(e,t)=>{let n=t*i;return n%60==0?null:(0,F.jsx)(`div`,{className:`absolute left-0 right-0 border-t border-dashed border-muted/30 pointer-events-none`,style:{top:n/60*G}},t)}),s.map(n=>{let i=n.startMin/60*G,s=Math.max(l,(n.endMin-n.startMin)/60*G),c=100/n.cols,u=n.col*c,{className:d,inlineColor:f}=z(n.event.color),p=x&&x.eventId===n.event.id;return(0,F.jsxs)(`div`,{role:`button`,tabIndex:0,title:n.event.title,"aria-label":n.event.title,onPointerDown:e=>A(e,n,t,`body`),onClick:e=>{if(w.current){e.stopPropagation();return}e.stopPropagation(),a?.(n.event)},className:D(`absolute rounded text-xs px-2 py-1 overflow-hidden shadow-sm`,o?`cursor-move`:`cursor-pointer`,d,p&&`opacity-40`),style:{top:i,height:s,left:`calc(${u}% + 2px)`,width:`calc(${c}% - 4px)`,...f?{backgroundColor:f}:{}},children:[(0,F.jsx)(`div`,{className:`font-medium truncate`,children:n.event.title}),(0,F.jsx)(`div`,{className:`text-[10px] opacity-80 truncate`,children:X(e,n.startMin,n.endMin,r)}),o&&n.isStart&&(0,F.jsx)(`div`,{onPointerDown:e=>A(e,n,t,`top`),className:`absolute top-0 left-0 right-0 h-1.5 cursor-ns-resize`,"aria-label":`Resize start`}),o&&n.isEnd&&(0,F.jsx)(`div`,{onPointerDown:e=>A(e,n,t,`bottom`),className:`absolute bottom-0 left-0 right-0 h-1.5 cursor-ns-resize`,"aria-label":`Resize end`})]},`${n.event.id}-${n.startMin}`)}),ee(t)]},n)})]})})]})}function X(e,t,n,r){let i=new Date(e);i.setHours(0,Math.round(t),0,0);let a=new Date(e);a.setHours(0,Math.round(n),0,0);let o=e=>e.toLocaleTimeString(r,{hour:`numeric`,minute:`2-digit`});return`${o(i)} – ${o(a)}`}function se(e){return`data`in e&&e.data?e.data:`staticData`in e&&e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function ce(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function le(e){return`filter`in e&&e.filter&&typeof e.filter==`object`&&`calendar`in e.filter?e.filter.calendar:e.calendar?e.calendar:e.startDateField||e.dateField?{startDateField:e.startDateField||e.dateField,endDateField:e.endDateField||e.endField,titleField:e.titleField,colorField:e.colorField,allDayField:e.allDayField}:null}var Z=({schema:e,dataSource:t,className:n,data:r,loading:i,onEventClick:c,onRowClick:l,onDateClick:u,onNavigate:f,onViewChange:m,onEventDrop:_,locale:v})=>{let b=Array.isArray(r),[x,S]=(0,P.useState)(b?r:[]),[C,w]=(0,P.useState)(b?i??!1:!0),[T,D]=(0,P.useState)(null),[j,te]=(0,P.useState)(null),[re,ie]=(0,P.useState)(new Date),I=k(),L=e.defaultView,[R,z]=(0,P.useState)(()=>{let e=L===`day`||!L;return typeof window<`u`&&window.innerWidth<768&&e?`month`:L||`month`});(0,P.useEffect)(()=>{I&&R===`day`&&(L===`day`||!L)&&z(`month`)},[I]);let[ae,B]=(0,P.useState)(0);(0,P.useEffect)(()=>{if(!b&&!(!t?.onMutation||!e.objectName))return t.onMutation(t=>{t.resource===e.objectName&&B(e=>e+1)})},[t,e.objectName,b]);let{ref:H,isRefreshing:oe,pullDistance:U}=ne({onRefresh:(0,P.useCallback)(async()=>{B(e=>e+1)},[]),enabled:!!t&&!!e.objectName}),W=(0,P.useMemo)(()=>se(e),[e.data,e.staticData,e.objectName]),G=(0,P.useMemo)(()=>le(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),K=W?.provider===`value`,q=(0,P.useRef)(null);q.current=j,(0,P.useEffect)(()=>{b&&S(r)},[r,b]),(0,P.useEffect)(()=>{b&&i!==void 0&&w(i)},[i,b]),(0,P.useEffect)(()=>{if(b)return;let n=!0;return(async()=>{try{if(!n)return;if(w(!0),K&&W?.provider===`value`){n&&(S(W.items),w(!1));return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(W?.provider===`object`){let r=W.object,i=o(q.current?.fields),a=s(await t.find(r,{$filter:e.filter,$orderby:ce(e.sort),...i.length>0?{$expand:i}:{}}));n&&S(a)}else W?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectCalendar`),n&&S([]));n&&w(!1)}catch(e){console.error(`[ObjectCalendar] Error fetching data:`,e),n&&(D(e),w(!1))}})(),()=>{n=!1}},[b,W,t,K,e.filter,e.sort,ae]),(0,P.useEffect)(()=>{!K&&t&&(async()=>{try{if(!t)return;let n=W?.provider===`object`?W.object:e.objectName;if(!n)return;te(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,K,W]);let J=(0,P.useMemo)(()=>{if(!G||!x.length)return[];let{startDateField:e,endDateField:t,titleField:n,colorField:r}=G,i=j?.titleFormat,a=typeof i==`string`?i:i&&typeof i==`object`&&typeof i.source==`string`?i.source:void 0,o=j?.NAME_FIELD_KEY,s=[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`],c=(e,t)=>{let n=`[-\\u2013\\u2014|/·,:]`,r=!1,i=e.replace(/\{([^{}]+)\}/g,(e,n)=>{let i=t[n.trim()];return i!=null&&i!==``?(r=!0,String(i)):`\0`});return r?i.replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim():``},l=e=>{let t;if(n&&(t=e[n],typeof t==`string`&&(t=t.trim())),!t&&a){let n=c(a,e);n&&(t=n)}if(!t&&o){let n=e[o];typeof n==`string`?t=n.trim():n&&(t=n)}if(!t)for(let n of s){let r=e[n],i=typeof r==`string`?r.trim():r;if(i){t=i;break}}return t||`Untitled`};return x.map((n,i)=>{let a=n[e],o=t?n[t]:null,s=l(n),c=r?n[r]:void 0;return{id:n.id||n._id||`event-${i}`,title:s,start:a?new Date(a):new Date,end:o?new Date(o):void 0,color:c,allDay:!o,data:n}}).filter(e=>!isNaN(e.start.getTime()))},[x,G,j]);(0,P.useCallback)(()=>{u?.(new Date)},[u]);let Y=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},X=Y.mode===`drawer`||Y.mode===`modal`||Y.mode===`split`||Y.mode===`popover`,Z=a({navigation:Y,objectName:e.objectName,onRowClick:X?void 0:l}),ue=(0,P.useCallback)(async(n,r,i)=>{if(!G)return;let{startDateField:a,endDateField:o}=G,s=n?.id??n?._id;if(!s||!e.objectName||!t?.update)return;let c={[a]:r.toISOString()};o&&i&&(c[o]=i.toISOString());let l=x;S(e=>e.map(e=>(e?.id??e?._id)===s?{...e,...c}:e));try{await t.update(e.objectName,s,c)}catch(e){S(l),console.error(`[ObjectCalendar] Failed to persist drag-and-drop reschedule:`,e)}},[G,e.objectName,t,x]),[Q,$]=(0,P.useState)(null),de=(0,P.useCallback)(n=>{!G||!e.objectName||!t?.create||$({start:n,title:``,submitting:!1})},[G,e.objectName,t]),fe=(0,P.useCallback)((n,r)=>{!G||!e.objectName||!t?.create||$({start:n,end:r,title:``,submitting:!1})},[G,e.objectName,t]),pe=(0,P.useCallback)(async()=>{if(!Q||!G)return;let n=Q.title.trim();if(!n){$(e=>e&&{...e,error:`Title is required`});return}if(!e.objectName||!t?.create)return;$(e=>e&&{...e,submitting:!0,error:void 0});let{startDateField:r,endDateField:i,titleField:a}=G,o={[a||`name`]:n,[r]:Q.start.toISOString()};i&&(o[i]=(Q.end??Q.start).toISOString());let s=j?.fields;if(s&&typeof s==`object`){let e=Array.isArray(s)?s.map(e=>[e.name??e.apiName,e]):Object.entries(s);for(let[t,n]of e){if(!t||t in o||!n?.required)continue;if(n.defaultValue!==void 0&&n.defaultValue!==null){o[t]=n.defaultValue;continue}let e=n.type;if(e===`select`||e===`picklist`||e===`status`){let e=(n.options||n.choices||[])[0];e!==void 0&&(o[t]=typeof e==`object`?e.value??e.id:e)}else e===`boolean`||e===`checkbox`?o[t]=!1:(e===`number`||e===`integer`||e===`decimal`||e===`currency`||e===`percent`)&&(o[t]=0)}}try{let n=await t.create(e.objectName,o),r=(n&&(n.record||n.data||n))??null;r&&(r.id!==void 0||r._id!==void 0)&&S(e=>[...e,r]),$(null)}catch(e){let t=e?.message||String(e);$(e=>e&&{...e,submitting:!1,error:t}),console.error(`[ObjectCalendar] Quick-create failed:`,e)}},[Q,G,e.objectName,t,j]);return C?(0,F.jsx)(`div`,{className:n,children:(0,F.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,F.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading calendar...`})})}):T?(0,F.jsx)(`div`,{className:n,children:(0,F.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,F.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,T.message]})})}):G?(0,F.jsxs)(`div`,{ref:H,className:n,children:[U>0&&(0,F.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:U},children:oe?`Refreshing…`:`Pull to refresh`}),(0,F.jsx)(`div`,{className:`bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]`,children:(0,F.jsx)(V,{events:J,currentDate:re,view:R,locale:v,onEventClick:e=>{Z.handleClick(e.data),X||c?.(e.data)},onDateClick:e=>{u?u(e):de(e)},onNavigate:e=>{ie(e),f?.(e)},onViewChange:e=>{z(e),m?.(e)},onAddClick:void 0,onEventDrop:(e,t,n)=>{_?_(e.data,t,n):ue(e.data,t,n)},onTimeRangeSelect:fe})}),(0,F.jsx)(p,{open:!!Q,onOpenChange:e=>{e||$(null)},children:(0,F.jsxs)(h,{className:`sm:max-w-md`,children:[(0,F.jsxs)(ee,{children:[(0,F.jsx)(d,{children:`New event`}),(0,F.jsx)(g,{children:Q&&(()=>{let e=Q.end&&Q.end.getTime()!==Q.start.getTime(),t=Q.start.toLocaleDateString(v,{year:`numeric`,month:`long`,day:`numeric`});if(e){let e=e=>e.toLocaleTimeString(v,{hour:`numeric`,minute:`2-digit`});return(0,F.jsxs)(F.Fragment,{children:[t,` · `,e(Q.start),` – `,e(Q.end)]})}return(0,F.jsxs)(F.Fragment,{children:[`On `,t]})})()})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(O,{htmlFor:`quick-create-title`,children:`Title`}),(0,F.jsx)(E,{id:`quick-create-title`,autoFocus:!0,value:Q?.title??``,onChange:e=>$(t=>t&&{...t,title:e.target.value,error:void 0}),onKeyDown:e=>{e.key===`Enter`&&!Q?.submitting&&(e.preventDefault(),pe())},placeholder:`What's this event about?`,disabled:Q?.submitting}),Q?.error&&(0,F.jsx)(`p`,{className:`text-sm text-destructive`,children:Q.error})]}),(0,F.jsxs)(y,{children:[(0,F.jsx)(A,{variant:`outline`,onClick:()=>$(null),disabled:Q?.submitting,children:`Cancel`}),(0,F.jsx)(A,{onClick:()=>void pe(),disabled:Q?.submitting||!Q?.title.trim(),children:Q?.submitting?`Creating…`:`Create`})]})]})}),Z.isOverlay&&Z.isOpen&&Z.selectedRecord&&(()=>{let n=W?.provider===`object`?W.object:e.objectName,r=Z.selectedRecord,i=r.id??r._id;if(!n||i==null)return null;let a=G?.titleField?String(r[G.titleField]??`Event Details`):`Event Details`;return(0,F.jsx)(N,{open:!0,onClose:Z.close,title:a,record:r,objectName:n,recordId:i,dataSource:t,objectSchema:j,width:Z.width??`min(960px, 60vw)`,fullPageHref:M(n,i)??void 0,onFieldSave:async(e,r)=>{t?.update&&(await t.update(n,String(i),{[e]:r}),S(t=>t.map(t=>String(t.id??t._id)===String(i)?{...t,[e]:r}:t)))},onDelete:async()=>{t?.delete&&(await t.delete(n,String(i)),S(e=>e.filter(e=>String(e.id??e._id)!==String(i))))}})})()]}):(0,F.jsx)(`div`,{className:n,children:(0,F.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,F.jsx)(`div`,{className:`text-muted-foreground`,children:`Calendar configuration required. Please specify startDateField and titleField.`})})})};l.register(`calendar-view`,({schema:e,className:t,onAction:n,...r})=>{let i=P.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((t,n)=>{let r=e.titleField||`title`,i=e.startDateField||`start`,a=e.endDateField||`end`,o=e.colorField||`color`,s=e.allDayField||`allDay`;return{id:t.id||t._id||n,title:t[r]||`Untitled Event`,start:new Date(t[i]),end:t[a]?new Date(t[a]):void 0,allDay:t[s],color:t[o],data:t}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]);return(0,F.jsx)(V,{className:t,events:i,onEventClick:e=>{n?.({type:`event-click`,payload:e})},...r})},{namespace:`plugin-calendar`,label:`Calendar View`,inputs:[{name:`data`,type:`array`,label:`Data`,description:`Array of record objects to display as events`},{name:`titleField`,type:`string`,label:`Title Field`,defaultValue:`title`,description:`Field name to use for event title`},{name:`startDateField`,type:`string`,label:`Start Date Field`,defaultValue:`start`,description:`Field name for event start date`},{name:`endDateField`,type:`string`,label:`End Date Field`,defaultValue:`end`,description:`Field name for event end date (optional)`},{name:`allDayField`,type:`string`,label:`All Day Field`,defaultValue:`allDay`,description:`Field name for all-day flag`},{name:`colorField`,type:`string`,label:`Color Field`,defaultValue:`color`,description:`Field name for event color`},{name:`colorMapping`,type:`object`,label:`Color Mapping`,description:`Map field values to colors (e.g., {meeting: "blue", deadline: "red"})`},{name:`view`,type:`enum`,enum:[`month`,`week`,`day`],defaultValue:`month`,label:`View Mode`,description:`Calendar view mode (month, week, or day)`},{name:`currentDate`,type:`string`,label:`Current Date`,description:`ISO date string for initial calendar date`},{name:`allowCreate`,type:`boolean`,label:`Allow Create`,defaultValue:!1,description:`Allow creating events by clicking on dates`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{view:`month`,titleField:`title`,startDateField:`start`,endDateField:`end`,allDayField:`allDay`,colorField:`color`,allowCreate:!1,data:[{id:1,title:`Team Meeting`,start:new Date(new Date().setHours(10,0,0,0)).toISOString(),end:new Date(new Date().setHours(11,0,0,0)).toISOString(),color:`#3b82f6`,allDay:!1},{id:2,title:`Project Deadline`,start:new Date(new Date().setDate(new Date().getDate()+3)).toISOString(),color:`#ef4444`,allDay:!0},{id:3,title:`Conference`,start:new Date(new Date().setDate(new Date().getDate()+7)).toISOString(),end:new Date(new Date().setDate(new Date().getDate()+9)).toISOString(),color:`#10b981`,allDay:!0}],className:`h-[600px] border rounded-lg`}});var ue=t({CalendarView:()=>V,ObjectCalendar:()=>Z,ObjectCalendarRenderer:()=>Q}),Q=({schema:e,...t})=>{let{dataSource:n}=i()||{};return(0,F.jsx)(Z,{schema:e,dataSource:n,...t})};l.register(`object-calendar`,Q,{namespace:`plugin-calendar`,label:`Object Calendar`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),l.register(`calendar`,Q,{namespace:`view`,label:`Calendar View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]});export{ue as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t,t as n}from"./rolldown-runtime-CMxvf4Kt.js";import{g as r,h as i,r as a}from"./vendor-react-CIpZOxG3.js";import{G as o,J as s,K as c,L as l,U as u,V as d,W as f,g as p,h as m,ot as h,q as g,r as _,t as v,ut as y,w as b,z as x}from"./framework-ClI3DbWX.js";import{A as S,Aa as C,At as w,Bn as T,Fn as E,Ft as D,G as O,In as k,It as A,J as j,K as M,Kn as N,Mt as ee,Nt as te,Uo as P,V as F,Xn as I,Yn as ne,Yo as L,Yr as re,a as R,es as z,i as ie,ia as B,k as V,l as H,m as U,mr as W,ns as ae,pi as oe,qi as G,qn as se,rs as ce,s as K,si as q,vo as J,w as Y,xr as X,yi as le,zn as ue}from"./ui-components-DYQ4Pai7.js";import{i as de,t as fe}from"./vendor-ui-utils-D3GsyZyi.js";import{_ as pe,c as me,d as he,g as ge,h as _e,i as ve,n as ye,o as be,p as xe,s as Se,t as Z}from"./vendor-dndkit-0jp7h5ty.js";var Q=e(r(),1),$=a();function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function we(e,t){if(t==null||e==null||typeof e!=`number`||!Number.isFinite(e)||typeof t!=`number`||!Number.isFinite(t))return null;if(t===0)return e===0?{value:0,direction:`neutral`}:{value:100,direction:e>0?`up`:`down`};let n=e-t;if(n===0)return{value:0,direction:`neutral`};let r=Math.round(n/Math.abs(t)*100);return{value:Math.abs(r),direction:r>0?`up`:`down`}}function Te({id:e,disabled:t,gridSpan:n,className:r,children:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u,isOver:d}=be({id:e,disabled:t});return(0,$.jsx)(`div`,{ref:s,style:{transform:pe.Transform.toString(c),transition:l,opacity:u?.4:1,...n?{gridColumn:`span ${n.w}`,gridRow:`span ${n.h}`}:{}},className:z(`h-full w-full`,r,!t&&`cursor-grab active:cursor-grabbing`,d&&!u&&`ring-2 ring-primary ring-offset-2 rounded-lg`),"data-sortable-widget-id":e,...a,...o,children:i})}function Ee(e){return e?j(e):null}function De(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var Oe=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],ke=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`]);function Ae(e){return ke.has(e)?{enabled:!0}:void 0}var je=(0,Q.forwardRef)(({schema:e,className:t,dataSource:n,onRefresh:r,recordCount:i,userActions:a,designMode:o,selectedWidgetId:s,onWidgetClick:c,onWidgetsReorder:u,modalHandler:d,scriptHandlers:f,hideHeaderText:p,...m},h)=>{let g=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),v=g,y=e.gap||4,[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(null),{executeAction:E,engine:D}=b({actions:(0,Q.useMemo)(()=>(e.header?.actions??[]).map(e=>({name:e.actionUrl||e.label,type:e.actionType||`url`,target:e.actionUrl,label:e.label})),[e.header?.actions])}),{dashboardLabel:O,dashboardDescription:k,dashboardActionLabel:A,widgetTitle:j,widgetDescription:M,fieldLabel:ee}=ae(),{t:te}=_(),P=(0,Q.useCallback)((e,t,n)=>n&&(!t||t===`value`||t===`count`||n===`count`)?te(`report.aggregate.${n}`,{defaultValue:n}):e?ee(e,t,t):t,[te,ee]),F=e.name,L=(0,Q.useCallback)(e=>F?A(F,e.actionUrl||e.label,e.label):e.label,[F,A]),re=(0,Q.useCallback)(e=>{let t=De(e.title);return!F||!e.id||t===void 0?t:j(F,e.id,t)},[F,j]),R=(0,Q.useCallback)(e=>{let t=De(e.description);return!F||!e.id?t:M(F,e.id,t)},[F,M]);(0,Q.useEffect)(()=>{let e=D.getRunner();if(d&&e.setModalHandler(d),f)for(let[t,n]of Object.entries(f))e.registerScript(t,n)},[D,d,f]),(0,Q.useEffect)(()=>{let e=()=>w(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let ie=(0,Q.useCallback)(()=>{r&&(S(!0),r(),setTimeout(()=>S(!1),600))},[r]);(0,Q.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!r))return T.current=setInterval(ie,e.refreshInterval*1e3),()=>{T.current&&clearInterval(T.current)}},[e.refreshInterval,r,ie]);let B=(0,Q.useCallback)((e,t)=>{!o||!c||!t||(e.stopPropagation(),c(t))},[o,c]),V=(0,Q.useCallback)((t,n,r)=>{if(!o||!c)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),c(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&c(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&c(e.id)}else t.key===`Escape`&&(t.preventDefault(),c(null))},[o,c,e.widgets]),H=(0,Q.useCallback)(e=>{!o||!c||e.target===e.currentTarget&&c(null)},[o,c]),U=!!(o&&u),oe=ge(_e(he,{activationConstraint:{distance:5}})),G=(0,Q.useCallback)(t=>{if(!U)return;let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.widgets??[],a=i.findIndex(e=>e.id===n.id),o=i.findIndex(e=>e.id===r.id);a<0||o<0||u?.(ye(i,a,o))},[U,e.widgets,u]),ce=(e,t,r)=>{let i=e.layout?{...e.layout,w:Math.min(e.layout.w,v)}:void 0,a=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`metric`&&e.object){let t=n.data,r=Ce(t)&&t.aggregate?{field:e.valueField||t.aggregate.field,function:e.aggregate||t.aggregate.function,groupBy:e.categoryField??t.aggregate.groupBy??`_all`}:e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object||(Ce(t)?t.object:void 0),aggregate:r,filter:(Ce(t)?t.filter:void 0)||e.filter,label:n.label||re(e)||``,fallbackValue:n.value,trend:n.trend,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,drillDown:n.drillDown??{enabled:!0},title:n.label||re(e)||``,compareTo:e.compareTo}}if((t===`gauge`||t===`solid-gauge`)&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object,aggregate:t,filter:e.filter,label:n.label||re(e)||``,fallbackValue:n.fallbackValue??n.value,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,invert:n.invert,compareTo:e.compareTo}}let r=t&&{}[t]||t;if(r===`bar`||r===`horizontal-bar`||r===`line`||r===`area`||r===`pie`||r===`donut`||r===`scatter`||r===`funnel`){let t=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(Ce(t)){let o=t.aggregate,s=(()=>{let t=e.categoryField||o?.groupBy;if(t)return e.categoryGranularity&&typeof t==`string`?{field:t,dateGranularity:e.categoryGranularity}:t})(),c=o?{field:e.valueField||o.field,function:e.aggregate||o.function,groupBy:s}:void 0,l=c?.field||a,u=e.object||t.object;return{type:`object-chart`,chartType:r,objectName:u,aggregate:c,filter:t.filter||e.filter,xAxisKey:i,series:[{dataKey:l,label:P(u,l,c?.function)}],colors:Oe,drillDown:n.drillDown??Ae(r),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!t&&e.object){let t=e.categoryField||`name`,a=e.categoryGranularity?{field:t,dateGranularity:e.categoryGranularity}:t,o=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:a}:void 0,s=e.valueField||`value`;return{type:`object-chart`,chartType:r,objectName:e.object,aggregate:o,filter:e.filter,xAxisKey:i,series:[{dataKey:s,label:P(e.object,s,e.aggregate)}],colors:Oe,drillDown:n.drillDown??Ae(r),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}return{type:`chart`,chartType:r,data:Array.isArray(t)?t:t?.items||[],xAxisKey:i,series:[{dataKey:a,label:P(e.object,a,e.aggregate)}],colors:Oe,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data;if(Ce(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data,r=e,i={rowField:r.rowField??n.rowField,columnField:r.columnField??n.columnField,valueField:r.valueField??n.valueField,aggregation:r.aggregation??n.aggregation??`sum`,showRowTotals:r.showRowTotals??n.showRowTotals,showColumnTotals:r.showColumnTotals??n.showColumnTotals,format:r.format??n.format},a=(Ce(t)||!t&&e.object)&&n.drillDown===void 0?{...n,drillDown:{enabled:!0}}:n;if(Ce(t)){let{data:n,...r}=a;return{type:`object-pivot`,...r,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter}}return!t&&e.object?{type:`object-pivot`,...a,...i,objectName:e.object,filter:e.filter}:{type:`pivot`,...n,...i,data:Array.isArray(t)?t:t?.items||[]}}if(t===`list`){let t=e.data||n.data;if(Ce(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:Array.isArray(t)?t:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}return t===`custom`?{type:`text`,value:"Custom widget — set `component` to a UIComponent schema.",variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:{...e,...n}})(),c=e.type===`metric`,u=re(e),d=R(e),f=e.id||u||`widget-${t}`,p=o&&s===e.id,m=o?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":p,"aria-label":`Widget: ${u||`Widget ${t+1}`}`,onClick:t=>B(t,e.id),onKeyDown:n=>V(n,e.id,t)}:{},h=o?z(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,p?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0,g=!C&&i&&!U?{gridColumn:`span ${i.w}`,gridRow:`span ${i.h}`}:void 0,_=c?(0,$.jsxs)(`div`,{className:z(`h-full w-full`,o&&`relative`,h),style:g,...m,children:[(0,$.jsx)(l,{schema:a,className:z(`h-full w-full`,o&&`pointer-events-none`),dataSource:n}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]}):(0,$.jsxs)(N,{className:z(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,r&&`w-full`,o&&`relative`,h),style:g,...m,children:[u&&(0,$.jsxs)(ne,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,$.jsx)(I,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:u,children:u}),d&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:d})]}),(0,$.jsx)(se,{className:`p-0`,children:(0,$.jsx)(`div`,{className:z(`h-full w-full`,`p-3 sm:p-4 md:p-6`,o&&`pointer-events-none`),children:(0,$.jsx)(l,{schema:a,dataSource:n})})}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]});return U&&e.id?(0,$.jsx)(Te,{id:e.id,gridSpan:!C&&i?{w:i.w,h:i.h}:void 0,children:_},f):(0,$.jsx)(Q.Fragment,{children:_},f)},K=e.header&&(0,$.jsxs)(`div`,{className:`col-span-full mb-4`,children:[!p&&e.header.showTitle!==!1&&e.title&&(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:F?O({name:F,label:De(e.title)}):De(e.title)}),!p&&e.header.showDescription!==!1&&e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:F?k({name:F,description:De(e.description)}):De(e.description)}),e.header.actions&&e.header.actions.length>0&&(0,$.jsx)(`div`,{className:`flex gap-2 mt-3`,children:e.header.actions.map((e,t)=>{let n=Ee(e.icon);return(0,$.jsxs)(W,{variant:`outline`,size:`sm`,onClick:async()=>{let{actionType:t,actionUrl:n,label:r}=e;if(!t||!n){console.warn(`[DashboardRenderer] Header action missing actionType/actionUrl:`,e);return}if(t===`url`){/^https?:\/\//.test(n)||n.startsWith(`//`)?window.location.assign(n):(window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)));return}if(t===`modal`||t===`script`){let e=await E(n||r);e?.success||console.warn(`[DashboardRenderer] action failed`,e?.error);return}console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`)},children:[n&&(0,$.jsx)(n,{className:`w-4 h-4 mr-1.5`}),L(e)]},t)})})]}),q=i!==void 0&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.toLocaleString(),` records`]}),J=a?JSON.stringify(a):void 0,Y=r&&(0,$.jsxs)(`div`,{className:z(`flex items-center justify-end gap-3 mb-2`,!C&&`col-span-full`),children:[q,(0,$.jsxs)(W,{variant:`outline`,size:`sm`,onClick:ie,disabled:x,"aria-label":`Refresh dashboard`,children:[(0,$.jsx)(le,{className:z(`h-4 w-4 mr-2`,x&&`animate-spin`)}),x?`Refreshing…`:`Refresh All`]})]}),X=(0,Q.useMemo)(()=>(e.widgets??[]).map(e=>e.id).filter(e=>!!e),[e.widgets]),ue=(0,Q.useMemo)(()=>(e.widgets??[]).filter(e=>e.type===`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]),de=(0,Q.useMemo)(()=>(e.widgets??[]).filter(e=>e.type!==`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]);if(C){let n=e.widgets?.filter(e=>e.type===`metric`)||[],r=e.widgets?.filter(e=>e.type!==`metric`)||[],i=(0,$.jsxs)(`div`,{ref:h,className:z(`flex flex-col gap-4 px-4`,t),"data-user-actions":J,onClick:H,...m,children:[K,Y,n.length>0&&(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:H,children:(0,$.jsx)(Z,{items:ue,strategy:ve,disabled:!U,children:n.map((e,t)=>ce(e,t))})}),r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:H,children:(0,$.jsx)(Z,{items:de,strategy:Se,disabled:!U,children:r.map((e,t)=>ce(e,t,!0))})})]});return U?(0,$.jsx)(me,{sensors:oe,collisionDetection:xe,onDragEnd:G,children:i}):i}let fe=e.columns!=null||g!==4,pe=(0,$.jsxs)(`div`,{ref:h,className:z(`grid auto-rows-min`,!fe&&`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...fe&&{gridTemplateColumns:`repeat(${v}, minmax(0, 1fr))`},gap:`${y*.25}rem`},"data-user-actions":J,onClick:H,...m,children:[K,Y,(0,$.jsx)(Z,{items:X,strategy:ve,disabled:!U,children:e.widgets?.map((e,t)=>ce(e,t))})]});return U?(0,$.jsx)(me,{sensors:oe,collisionDetection:xe,onDragEnd:G,children:pe}):pe});function Me(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function Ne(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function Pe(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=Me(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=Ne(r,u,s[0]),f=Ne(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function Fe(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=Me(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=Re(d,0,s-r),f=Re(f,0,l-i),{x:d,y:f}}function Ie(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=Me(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function Le(e,t,n){let{margin:r,rowHeight:i}=e,a=Me(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function Re(e,t,n){return Math.max(Math.min(e,n),t)}function ze(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function Be(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&ze(r,t))return r}}function Ve(e,t){return e.filter(e=>ze(e,t))}function He(e,t){return t===`horizontal`?We(e):t===`vertical`||t===`wrap`?Ue(e):[...e]}function Ue(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function We(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Ge(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=r.y+r.h;e>t&&(t=e)}}return t}function Ke(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function qe(e){return e.filter(e=>e.static===!0)}function Je(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function Ye(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=Je(r))}return t}function Xe(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];i!==void 0&&(t.i===i.i?n[r]=t:n[r]=i)}return n}function Ze(e,t,n){let r=Ke(e,t);return r?(r=n(Je(r)),[Xe(e,r),r]):[[...e],null]}function Qe(e,t){let n=qe(e);for(let r=0;r<e.length;r++){let i=e[r];if(i!==void 0)if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;Be(n,i);)i.y++}return e}function $e(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=He(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=Ve(d,t),p=f.length>0;if(p&&c)return Ye(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;e<f.length;e++){let n=f[e];n!==void 0&&(n.moved||(m=n.static?et(m,n,t,i,o):et(m,t,n,i,o)))}return m}function et(e,t,n,r,i,a){let o=i===`horizontal`,s=i===`vertical`,c=t.static;if(r){r=!1;let a={x:o?Math.max(t.x-n.w,0):n.x,y:s?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:`-1`},l=Be(e,a),u=l!==void 0&&l.y+l.h>t.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return $e(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return $e(e,n,void 0,n.y+1,r,c,i);if(u&&i===null)return t.y=n.y,n.y+=n.h,[...e];if(d&&o)return $e(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:$e(e,n,l,u,r,c,i)}function tt(e,t,n){return Math.max(t,Math.min(n,e))}var nt=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:tt(t,0,Math.max(0,r-e.w)),y:tt(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:tt(t,1,Math.max(1,o)),h:tt(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:tt(t,e.minW??1,e.maxW??1/0),h:tt(n,e.minH??1,e.maxH??1/0)}}}];function rt(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function it(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function at({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function ot({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function st(e){return e*100+`%`}function ct(e,t,n,r){return e+n>r?t:n}function lt(e,t,n){return e<0?t:n}function ut(e){return Math.max(0,e)}function dt(e){return Math.max(0,e)}var ft=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:lt(o,e.height,i),top:dt(o)}},pt=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:ct(e.left,e.width,o,n),left:ut(i)}},mt=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:dt(r),left:0}:{height:i,width:a,top:dt(r),left:o}},ht=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:lt(r,e.height,a),top:dt(r)}},gt={n:ft,ne:(e,t,n)=>ft(e,pt(e,t,n)),e:pt,se:(e,t,n)=>ht(e,pt(e,t,n)),s:ht,sw:(e,t,n)=>ht(e,mt(e,t)),w:mt,nw:(e,t,n)=>ft(e,mt(e,t))};function _t(e,t,n,r){let i=gt[e];return i?i(t,{...t,...n},r):n}var vt={type:`transform`,scale:1,calcStyle(e){return at(e)}},yt={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},bt={enabled:!0,bounded:!1,threshold:3},xt={enabled:!0,handles:[`se`]},St={enabled:!1,defaultItem:{w:1,h:1}};function Ct(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??qe(e).length>0;for(let i=o+1;i<e.length;i++){let o=e[i];if(o!==void 0&&!o.static){if(!s&&o.y>t.y+t.h)break;ze(t,o)&&Ct(e,o,n+t[a],r,s)}}t[r]=n}function wt(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!Be(e,t);)t.y--;let i;for(;(i=Be(e,t))!==void 0;)Ct(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function Tt(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!Be(e,t);)t.x--;let i;for(;(i=Be(e,t))!==void 0;)if(Ct(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!Be(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var Et={type:`vertical`,allowOverlap:!1,compact(e,t){let n=qe(e),r=Ge(n),i=Ue(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=Je(o);s.static||(s=wt(n,s,i,r),r=Math.max(r,s.y+s.h),n.push(s));let c=e.indexOf(o);a[c]=s,s.moved=!1}return a}},Dt={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=qe(e),r=We(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=Je(o);s.static||(s=Tt(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},Ot={type:null,allowOverlap:!1,compact(e,t){return Ye(e)}},kt={...Et,allowOverlap:!0,compact(e,t){return Ye(e)}},At={...Dt,allowOverlap:!0,compact(e,t){return Ye(e)}},jt={...Ot,allowOverlap:!0};function Mt(e,t=!1,n=!1){let r;return r=t?e===`vertical`?kt:e===`horizontal`?At:jt:e===`vertical`?Et:e===`horizontal`?Dt:Ot,n?{...r,preventCollision:n}:r}function Nt(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function Pt(e,t){let n=Nt(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;i<n.length;i++){let a=n[i];a!==void 0&&t>e[a]&&(r=a)}return r}function Ft(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function It(e,t,n,r,i,a){let o=e[n];if(o)return Ye(o);let s=e[r],c=Nt(t),l=c.slice(c.indexOf(n));for(let t=0;t<l.length;t++){let n=l[t];if(n===void 0)continue;let r=e[n];if(r){s=r;break}}let u=Qe(Ye(s||[]),{cols:i});return(typeof a==`object`&&a?a:Mt(a)).compact(u,i)}function Lt(e,t){if(Array.isArray(e))return e;let n=e,r=n[t];if(r!==void 0)return r;let i=Object.keys(n);for(let e of i){let t=n[e];if(t!==void 0)return t}return[10,10]}var Rt=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(e,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=`[object Arguments]`,c=`[object Boolean]`,l=`[object Date]`,u=`[object RegExp]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object Set]`,h=`[object String]`,g=Object.prototype.toString;function _(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,_=e.areObjectsEqual,v=e.areRegExpsEqual,y=e.areSetsEqual,b=e.createIsNestedEqual,x=b(S);function S(e,b,S){if(e===b)return!0;if(!e||!b||typeof e!=`object`||typeof b!=`object`)return e!==e&&b!==b;if(i(e)&&i(b))return _(e,b,x,S);var C=Array.isArray(e),w=Array.isArray(b);if(C||w)return C===w&&t(e,b,x,S);var T=g.call(e);return T===g.call(b)?T===l?n(e,b,x,S):T===u?v(e,b,x,S):T===d?r(e,b,x,S):T===m?y(e,b,x,S):T===p||T===s?a(e)||a(b)?!1:_(e,b,x,S):T===c||T===f||T===h?o(e.valueOf(),b.valueOf()):!1:!1}return S}function v(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-- >0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var y=n(v);function b(e,t){return o(e.valueOf(),t.valueOf())}function x(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var S=n(x),C=`_owner`,w=Object.prototype.hasOwnProperty;function T(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-- >0;){if(o=i[a],o===C){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!w.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var E=n(T);function D(e,t){return e.source===t.source&&e.flags===t.flags}function O(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var k=n(O),A=Object.freeze({areArraysEqual:v,areDatesEqual:b,areMapsEqual:x,areObjectsEqual:T,areRegExpsEqual:D,areSetsEqual:O,createIsNestedEqual:t}),j=Object.freeze({areArraysEqual:y,areDatesEqual:b,areMapsEqual:S,areObjectsEqual:E,areRegExpsEqual:D,areSetsEqual:k,createIsNestedEqual:t}),M=_(A);function N(e,t){return M(e,t,void 0)}var ee=_(r(A,{createIsNestedEqual:function(){return o}}));function te(e,t){return ee(e,t,void 0)}var P=_(j);function F(e,t){return P(e,t,new WeakMap)}var I=_(r(j,{createIsNestedEqual:function(){return o}}));function ne(e,t){return I(e,t,new WeakMap)}function L(e){return _(r(A,e(A)))}function re(e){var t=_(r(j,e(j)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=F,e.circularShallowEqual=ne,e.createCustomCircularEqual=re,e.createCustomEqual=L,e.deepEqual=N,e.sameValueZeroEqual=o,e.shallowEqual=te,Object.defineProperty(e,"__esModule",{value:!0})}))}));function zt(e={}){let{measureBeforeMount:t=!1,initialWidth:n=1280}=e,[r,i]=(0,Q.useState)(n),[a,o]=(0,Q.useState)(!t),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useCallback)(()=>{let e=s.current;if(e){let t=e.offsetWidth;i(t),a||o(!0)}},[a]);return(0,Q.useEffect)(()=>{let e=s.current;if(e){if(l(),typeof ResizeObserver<`u`){let t=null;return c.current=new ResizeObserver(e=>{let n=e[0];if(n){let e=n.contentRect.width;t!==null&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{i(e),t=null})}}),c.current.observe(e),()=>{t!==null&&cancelAnimationFrame(t),c.current&&=(c.current.disconnect(),null)}}return()=>{c.current&&=(c.current.disconnect(),null)}}},[l]),{width:r,mounted:a,containerRef:s,measureWidth:l}}var Bt=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Vt=n(((e,t)=>{var n=Bt();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Ht=n(((e,t)=>{t.exports=Vt()()})),Ut=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dontSetMe=a,e.findInArray=t,e.int=i,e.isFunction=n,e.isNum=r;function t(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function n(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function r(e){return typeof e==`number`&&!isNaN(e)}function i(e){return parseInt(e,10)}function a(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}})),Wt=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.browserPrefixToKey=r,e.browserPrefixToStyle=i,e.default=void 0,e.getPrefix=n;var t=[`Moz`,`Webkit`,`O`,`ms`];function n(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`transform`;if(typeof window>`u`)return``;let n=window.document?.documentElement?.style;if(!n||e in n)return``;for(let i=0;i<t.length;i++)if(r(e,t[i])in n)return t[i];return``}function r(e,t){return t?`${t}${a(e)}`:e}function i(e,t){return t?`-${t.toLowerCase()}-${e}`:e}function a(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}e.default=n()})),Gt=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.addClassName=S,e.addEvent=s,e.addUserSelectStyles=y,e.createCSSTransform=m,e.createSVGTransform=h,e.getTouch=_,e.getTouchIdentifier=v,e.getTranslation=g,e.innerHeight=d,e.innerWidth=f,e.matchesSelector=a,e.matchesSelectorAndParentsTo=o,e.offsetXYFromParent=p,e.outerHeight=l,e.outerWidth=u,e.removeClassName=C,e.removeEvent=c,e.scheduleRemoveUserSelectStyles=b;var t=Ut(),n=r(Wt());function r(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,i=new WeakMap;return(r=function(e,t){if(!t&&e&&e.__esModule)return e;var r,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(r=t?i:n){if(r.has(e))return r.get(e);r.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?r(o,t,a):o[t]=e[t]);return o})(e,t)}var i=``;function a(e,n){return i||=(0,t.findInArray)([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(n){return(0,t.isFunction)(e[n])}),(0,t.isFunction)(e[i])?e[i](n):!1}function o(e,t,n){let r=e;do{if(a(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function s(e,t,n,r){if(!e)return;let i={capture:!0,...r};e.addEventListener?e.addEventListener(t,n,i):e.attachEvent?e.attachEvent(`on`+t,n):e[`on`+t]=n}function c(e,t,n,r){if(!e)return;let i={capture:!0,...r};e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent?e.detachEvent(`on`+t,n):e[`on`+t]=null}function l(e){let n=e.clientHeight,r=e.ownerDocument.defaultView.getComputedStyle(e);return n+=(0,t.int)(r.borderTopWidth),n+=(0,t.int)(r.borderBottomWidth),n}function u(e){let n=e.clientWidth,r=e.ownerDocument.defaultView.getComputedStyle(e);return n+=(0,t.int)(r.borderLeftWidth),n+=(0,t.int)(r.borderRightWidth),n}function d(e){let n=e.clientHeight,r=e.ownerDocument.defaultView.getComputedStyle(e);return n-=(0,t.int)(r.paddingTop),n-=(0,t.int)(r.paddingBottom),n}function f(e){let n=e.clientWidth,r=e.ownerDocument.defaultView.getComputedStyle(e);return n-=(0,t.int)(r.paddingLeft),n-=(0,t.int)(r.paddingRight),n}function p(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function m(e,t){let r=g(e,t,`px`);return{[(0,n.browserPrefixToKey)(`transform`,n.default)]:r}}function h(e,t){return g(e,t,``)}function g(e,t,n){let{x:r,y:i}=e,a=`translate(${r}${n},${i}${n})`;return t&&(a=`translate(${`${typeof t.x==`string`?t.x:t.x+n}`}, ${`${typeof t.y==`string`?t.y:t.y+n}`})`+a),a}function _(e,n){return e.targetTouches&&(0,t.findInArray)(e.targetTouches,e=>n===e.identifier)||e.changedTouches&&(0,t.findInArray)(e.changedTouches,e=>n===e.identifier)}function v(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function y(e){if(!e)return;let t=e.getElementById(`react-draggable-style-el`);t||(t=e.createElement(`style`),t.type=`text/css`,t.id=`react-draggable-style-el`,t.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
|
|
2
|
-
`,t.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
|
|
3
|
-
`,e.getElementsByTagName(`head`)[0].appendChild(t)),e.body&&S(e.body,`react-draggable-transparent-selection`)}function b(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{x(e)}):x(e)}function x(e){if(e)try{if(e.body&&C(e.body,`react-draggable-transparent-selection`),e.selection)e.selection.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function S(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function C(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}})),Kt=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.canDragX=a,e.canDragY=o,e.createCoreData=c,e.createDraggableData=l,e.getBoundPosition=r,e.getControlPosition=s,e.snapToGrid=i;var t=Ut(),n=Gt();function r(e,r,i){if(!e.props.bounds)return[r,i];let{bounds:a}=e.props;a=typeof a==`string`?a:u(a);let o=d(e);if(typeof a==`string`){let{ownerDocument:e}=o,r=e.defaultView,i;if(i=a===`parent`?o.parentNode:o.getRootNode().querySelector(a),!(i instanceof r.HTMLElement))throw Error(`Bounds selector "`+a+`" could not find an element.`);let s=i,c=r.getComputedStyle(o),l=r.getComputedStyle(s);a={left:-o.offsetLeft+(0,t.int)(l.paddingLeft)+(0,t.int)(c.marginLeft),top:-o.offsetTop+(0,t.int)(l.paddingTop)+(0,t.int)(c.marginTop),right:(0,n.innerWidth)(s)-(0,n.outerWidth)(o)-o.offsetLeft+(0,t.int)(l.paddingRight)-(0,t.int)(c.marginRight),bottom:(0,n.innerHeight)(s)-(0,n.outerHeight)(o)-o.offsetTop+(0,t.int)(l.paddingBottom)-(0,t.int)(c.marginBottom)}}return(0,t.isNum)(a.right)&&(r=Math.min(r,a.right)),(0,t.isNum)(a.bottom)&&(i=Math.min(i,a.bottom)),(0,t.isNum)(a.left)&&(r=Math.max(r,a.left)),(0,t.isNum)(a.top)&&(i=Math.max(i,a.top)),[r,i]}function i(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function a(e){return e.props.axis===`both`||e.props.axis===`x`}function o(e){return e.props.axis===`both`||e.props.axis===`y`}function s(e,t,r){let i=typeof t==`number`?(0,n.getTouch)(e,t):null;if(typeof t==`number`&&!i)return null;let a=d(r),o=r.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,n.offsetXYFromParent)(i||e,o,r.props.scale)}function c(e,n,r){let i=!(0,t.isNum)(e.lastX),a=d(e);return i?{node:a,deltaX:0,deltaY:0,lastX:n,lastY:r,x:n,y:r}:{node:a,deltaX:n-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:n,y:r}}function l(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function u(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function d(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}})),qt=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(){}})),Jt=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=d(r()),n=u(Ht()),a=u(i()),o=Gt(),s=Kt(),c=Ut(),l=u(qt());function u(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(d=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function f(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=m(e,`string`);return typeof t==`symbol`?t:t+``}function m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var h={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},g=h.mouse,_=class extends t.Component{constructor(){super(...arguments),f(this,`dragging`,!1),f(this,`lastX`,NaN),f(this,`lastY`,NaN),f(this,`touchIdentifier`,null),f(this,`mounted`,!1),f(this,`handleDragStart`,e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&typeof e.button==`number`&&e.button!==0)return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!(0,o.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,o.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=(0,o.getTouchIdentifier)(e);this.touchIdentifier=r;let i=(0,s.getControlPosition)(e,r,this);if(i==null)return;let{x:a,y:c}=i,u=(0,s.createCoreData)(this,a,c);(0,l.default)(`DraggableCore: handleDragStart: %j`,u),(0,l.default)(`calling`,this.props.onStart),!(this.props.onStart(e,u)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,o.addUserSelectStyles)(n),this.dragging=!0,this.lastX=a,this.lastY=c,(0,o.addEvent)(n,g.move,this.handleDrag),(0,o.addEvent)(n,g.stop,this.handleDragStop))}),f(this,`handleDrag`,e=>{let t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=(0,s.snapToGrid)(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=(0,s.createCoreData)(this,n,r);if((0,l.default)(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r}),f(this,`handleDragStop`,e=>{if(!this.dragging)return;let t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=(0,s.snapToGrid)(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=(0,s.createCoreData)(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&(0,o.scheduleRemoveUserSelectStyles)(a.ownerDocument),(0,l.default)(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&((0,l.default)(`DraggableCore: Removing handlers`),(0,o.removeEvent)(a.ownerDocument,g.move,this.handleDrag),(0,o.removeEvent)(a.ownerDocument,g.stop,this.handleDragStop))}),f(this,`onMouseDown`,e=>(g=h.mouse,this.handleDragStart(e))),f(this,`onMouseUp`,e=>(g=h.mouse,this.handleDragStop(e))),f(this,`onTouchStart`,e=>(g=h.touch,this.handleDragStart(e))),f(this,`onTouchEnd`,e=>(g=h.touch,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&(0,o.addEvent)(e,h.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;(0,o.removeEvent)(t,h.mouse.move,this.handleDrag),(0,o.removeEvent)(t,h.touch.move,this.handleDrag),(0,o.removeEvent)(t,h.mouse.stop,this.handleDragStop),(0,o.removeEvent)(t,h.touch.stop,this.handleDragStop),(0,o.removeEvent)(e,h.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,o.scheduleRemoveUserSelectStyles)(t)}}findDOMNode(){return this.props?.nodeRef?this.props?.nodeRef?.current:a.default.findDOMNode(this)}render(){return t.cloneElement(t.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};e.default=_,f(_,`displayName`,`DraggableCore`),f(_,`propTypes`,{allowAnyClick:n.default.bool,allowMobileScroll:n.default.bool,children:n.default.node.isRequired,disabled:n.default.bool,enableUserSelectHack:n.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:n.default.arrayOf(n.default.number),handle:n.default.string,cancel:n.default.string,nodeRef:n.default.object,onStart:n.default.func,onDrag:n.default.func,onStop:n.default.func,onMouseDown:n.default.func,scale:n.default.number,className:c.dontSetMe,style:c.dontSetMe,transform:c.dontSetMe}),f(_,`defaultProps`,{allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})})),Yt=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return u.default}}),e.default=void 0;var t=p(r()),n=f(Ht()),a=f(i()),o=fe(),s=Gt(),c=Kt(),l=Ut(),u=f(Jt()),d=f(qt());function f(e){return e&&e.__esModule?e:{default:e}}function p(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(p=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},m.apply(null,arguments)}function h(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e){var t=_(e,`string`);return typeof t==`symbol`?t:t+``}function _(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var v=class extends t.Component{static getDerivedStateFromProps(e,t){let{position:n}=e,{prevPropsPosition:r}=t;return n&&(!r||n.x!==r.x||n.y!==r.y)?((0,d.default)(`Draggable: getDerivedStateFromProps %j`,{position:n,prevPropsPosition:r}),{x:n.x,y:n.y,prevPropsPosition:{...n}}):null}constructor(e){super(e),h(this,`onDragStart`,(e,t)=>{if((0,d.default)(`Draggable: onDragStart: %j`,t),this.props.onStart(e,(0,c.createDraggableData)(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),h(this,`onDrag`,(e,t)=>{if(!this.state.dragging)return!1;(0,d.default)(`Draggable: onDrag: %j`,t);let n=(0,c.createDraggableData)(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=(0,c.getBoundPosition)(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)}),h(this,`onDragStop`,(e,t)=>{if(!this.state.dragging||this.props.onStop(e,(0,c.createDraggableData)(this,t))===!1)return!1;(0,d.default)(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)}),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){return this.props?.nodeRef?.current??a.default.findDOMNode(this)}render(){let{axis:e,bounds:n,children:r,defaultPosition:i,defaultClassName:a,defaultClassNameDragging:l,defaultClassNameDragged:d,position:f,positionOffset:p,scale:h,...g}=this.props,_={},v=null,y=!f||this.state.dragging,b=f||i,x={x:(0,c.canDragX)(this)&&y?this.state.x:b.x,y:(0,c.canDragY)(this)&&y?this.state.y:b.y};this.state.isElementSVG?v=(0,s.createSVGTransform)(x,p):_=(0,s.createCSSTransform)(x,p);let S=(0,o.clsx)(r.props.className||``,a,{[l]:this.state.dragging,[d]:this.state.dragged});return t.createElement(u.default,m({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(r),{className:S,style:{...r.props.style,..._},transform:v}))}};e.default=v,h(v,`displayName`,`Draggable`),h(v,`propTypes`,{...u.default.propTypes,axis:n.default.oneOf([`both`,`x`,`y`,`none`]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),h(v,`defaultProps`,{...u.default.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1})})),Xt=n(((e,t)=>{var{default:n,DraggableCore:r}=Yt();t.exports=n,t.exports.default=n,t.exports.DraggableCore=r})),Zt=n((e=>{e.__esModule=!0,e.cloneElement=l;var t=n(r());function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){var t=c(e,`string`);return typeof t==`symbol`?t:t+``}function c(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e,n){return n.style&&e.props.style&&(n.style=a(a({},e.props.style),n.style)),n.className&&e.props.className&&(n.className=`${e.props.className} ${n.className}`),t.default.cloneElement(e,n)}})),Qt=n((e=>{e.__esModule=!0,e.resizableProps=void 0;var t=n(Ht());Xt();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let[n]=e;return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let[n]=e;return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),$t=n((e=>{e.__esModule=!0,e.default=void 0;var t=s(r()),n=Xt(),i=Zt(),a=Qt(),o=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(null,arguments)}function l(e,t){if(e==null)return{};var n,r,i=u(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function u(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?d(Object(n),!0).forEach(function(t){p(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function p(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){var t=h(e,`string`);return typeof t==`symbol`?t:t+``}function h(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var g=class extends t.Component{constructor(){super(...arguments),this.handleRefs={},this.lastHandleRect=null,this.slack=null,this.lastSize=null}componentWillUnmount(){this.resetData()}resetData(){this.lastHandleRect=this.slack=this.lastSize=null}runConstraints(e,t){let{minConstraints:n,maxConstraints:r,lockAspectRatio:i}=this.props;if(!n&&!r&&!i)return[e,t];if(i){let n=this.props.width/this.props.height,r=e-this.props.width,i=t-this.props.height;Math.abs(r)>Math.abs(i*n)?t=e/n:e=t*n}let[a,o]=[e,t],[s,c]=this.slack||[0,0];return e+=s,t+=c,n&&(e=Math.max(n[0],e),t=Math.max(n[1],t)),r&&(e=Math.min(r[0],e),t=Math.min(r[1],t)),this.slack=[s+(a-e),c+(o-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let{node:i,deltaX:a,deltaY:o}=r;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.props.width+(s?a/this.props.transformScale:0),p=this.props.height+(c?o/this.props.transformScale:0);[f,p]=this.runConstraints(f,p),e===`onResizeStop`&&this.lastSize&&({width:f,height:p}=this.lastSize);let m=f!==this.props.width||p!==this.props.height;e!==`onResizeStop`&&(this.lastSize={width:f,height:p});let h=typeof this.props[e]==`function`?this.props[e]:null;h&&!(e===`onResize`&&!m)&&(n.persist?.(),h(n,{node:i,size:{width:f,height:p},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,n){let{handle:r}=this.props;if(!r)return t.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-${e}`,ref:n});if(typeof r==`function`)return r(e,n);let i=typeof r.type==`string`,a=f({ref:n},i?{}:{handleAxis:e});return t.cloneElement(r,a)}render(){let e=this.props,{children:r,className:a,draggableOpts:s,width:u,height:d,handle:p,handleSize:m,lockAspectRatio:h,axis:g,minConstraints:_,maxConstraints:v,onResize:y,onResizeStop:b,onResizeStart:x,resizeHandles:S,transformScale:C}=e,w=l(e,o);return(0,i.cloneElement)(r,f(f({},w),{},{className:`${a?`${a} `:``}react-resizable`,children:[...t.Children.toArray(r.props.children),...S.map(e=>{let r=this.handleRefs[e]??(this.handleRefs[e]=t.createRef());return t.createElement(n.DraggableCore,c({},s,{nodeRef:r,key:`resizableHandle-${e}`,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,r))})]}))}};e.default=g,g.propTypes=a.resizableProps,g.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),en=n((e=>{e.__esModule=!0,e.default=void 0;var t=c(r()),n=s(Ht()),i=s($t()),a=Qt(),o=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function s(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(c=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l.apply(null,arguments)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=m(e,`string`);return typeof t==`symbol`?t:t+``}function m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e,t){if(e==null)return{};var n,r,i=g(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var _=class extends t.Component{constructor(){super(...arguments),this.state={width:this.props.width,height:this.props.height,propsWidth:this.props.width,propsHeight:this.props.height},this.onResize=(e,t)=>{let{size:n}=t;this.props.onResize?(e.persist?.(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,{handle:n,handleSize:r,onResize:a,onResizeStart:s,onResizeStop:c,draggableOpts:u,minConstraints:f,maxConstraints:p,lockAspectRatio:m,axis:g,width:_,height:v,resizeHandles:y,style:b,transformScale:x}=e,S=h(e,o);return t.createElement(i.default,{axis:g,draggableOpts:u,handle:n,handleSize:r,height:this.state.height,lockAspectRatio:m,maxConstraints:p,minConstraints:f,onResizeStart:s,onResize:this.onResize,onResizeStop:c,resizeHandles:y,transformScale:x,width:this.state.width},t.createElement(`div`,l({},S,{style:d(d({},b),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=_,_.propTypes=d(d({},a.resizableProps),{},{children:n.default.element})})),tn=n(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=$t().default,t.exports.ResizableBox=en().default})),nn=Xt(),rn=tn(),an=Rt();function on(e){let{children:t,cols:n,containerWidth:r,margin:i,containerPadding:a,rowHeight:o,maxRows:s,isDraggable:c,isResizable:l,isBounded:u,static:d,useCSSTransforms:f=!0,usePercentages:p=!1,transformScale:m=1,positionStrategy:h,dragThreshold:g=0,droppingPosition:_,className:v=``,style:y,handle:b=``,cancel:x=``,x:S,y:C,w,h:T,minW:E=1,maxW:D=1/0,minH:O=1,maxH:k=1/0,i:A,resizeHandles:j,resizeHandle:M,constraints:N=nt,layoutItem:ee,layout:te=[],onDragStart:P,onDrag:F,onDragStop:I,onResizeStart:ne,onResize:L,onResizeStop:re}=e,[R,z]=(0,Q.useState)(!1),[ie,B]=(0,Q.useState)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)({left:0,top:0}),U=(0,Q.useRef)({top:0,left:0,width:0,height:0}),W=(0,Q.useRef)(void 0),ae=(0,Q.useRef)(te);ae.current=te;let oe=(0,Q.useRef)(null),G=(0,Q.useRef)(null),se=(0,Q.useRef)(!1),ce=(0,Q.useRef)({x:0,y:0}),K=(0,Q.useRef)(!1),q=(0,Q.useMemo)(()=>({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),J=(0,Q.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),Y=(0,Q.useCallback)(()=>({...J,layout:ae.current}),[J]),X=(0,Q.useMemo)(()=>ee??{i:A,x:S,y:C,w,h:T,minW:E,maxW:D,minH:O,maxH:k},[ee,A,S,C,w,T,E,D,O,k]),le=(0,Q.useCallback)(e=>{if(h?.calcStyle)return h.calcStyle(e);if(f)return at(e);let t=ot(e);return p?{...t,left:st(e.left/r),width:st(e.width/r)}:t},[h,f,p,r]),ue=(0,Q.useCallback)((e,{node:t})=>{if(!P)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/m,o=r.left/m,s=i.top/m,c=r.top/m,l;if(h?.calcDragPosition){let t=e;l=h.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(H.current=l,g>0){let t=e;ce.current={x:t.clientX,y:t.clientY},se.current=!0,K.current=!1,z(!0);return}z(!0);let u=Ie(q,l.top,l.left),{x:d,y:f}=rt(N,X,u.x,u.y,Y());P(A,d,f,{e,node:t,newPosition:l})},[P,m,q,h,g,N,X,Y,A]),fe=(0,Q.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!F||!R)return;let s=e;if(se.current&&!K.current){let n=s.clientX-ce.current.x,r=s.clientY-ce.current.y;if(Math.hypot(n,r)<g)return;if(K.current=!0,se.current=!1,P){let n=Ie(q,H.current.top,H.current.left),{x:r,y:i}=rt(N,X,n.x,n.y,Y());P(A,r,i,{e,node:t,newPosition:H.current})}}let c=H.current.top+a,l=H.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-Ne(T,o,i[1]);c=Re(c,0,t);let n=r-Ne(w,Me(q),i[0]);l=Re(l,0,n)}}let d={top:c,left:l};H.current=d;let f=Ie(q,c,l),{x:p,y:m}=rt(N,X,f.x,f.y,Y());F(A,p,m,{e,node:t,newPosition:d})},[F,P,R,g,u,T,o,i,q,r,w,A,N,X,Y]),pe=(0,Q.useCallback)((e,{node:t})=>{if(!I||!R)return;let n=se.current;if(se.current=!1,K.current=!1,ce.current={x:0,y:0},n){z(!1),H.current={left:0,top:0};return}let{left:r,top:i}=H.current,a={top:i,left:r};z(!1),H.current={left:0,top:0};let o=Ie(q,i,r),{x:s,y:c}=rt(N,X,o.x,o.y,Y());I(A,s,c,{e,node:t,newPosition:a})},[I,R,q,N,X,Y,A]);oe.current=ue,G.current=fe;let me=(0,Q.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?ne:o===`onResize`?L:re;if(!s)return;let c;c=t?_t(i,a,n,r):{...n,top:a.top,left:a.left},U.current=c;let l=Le(q,c.width,c.height),{w:u,h:d}=it(N,X,l.w,l.h,i,Y());s(A,u,d,{e:e.nativeEvent,node:t,size:c,handle:i})},[ne,L,re,r,q,A,N,X,Y]),he=(0,Q.useCallback)((e,t)=>{B(!0);let n=Pe(q,S,C,w,T);me(e,{...t,handle:t.handle},n,`onResizeStart`)},[me,q,S,C,w,T]),ge=(0,Q.useCallback)((e,t)=>{let n=Pe(q,S,C,w,T);me(e,{...t,handle:t.handle},n,`onResize`)},[me,q,S,C,w,T]),_e=(0,Q.useCallback)((e,t)=>{B(!1),U.current={top:0,left:0,width:0,height:0};let n=Pe(q,S,C,w,T);me(e,{...t,handle:t.handle},n,`onResizeStop`)},[me,q,S,C,w,T]);(0,Q.useEffect)(()=>{if(!_)return;let e=V.current;if(!e)return;let t=W.current||{left:0,top:0},n=R&&(_.left!==t.left||_.top!==t.top);if(!R){let t={node:e,deltaX:_.left,deltaY:_.top,lastX:0,lastY:0,x:_.left,y:_.top};oe.current?.(_.e,t)}else if(n){let t={node:e,deltaX:_.left-H.current.left,deltaY:_.top-H.current.top,lastX:H.current.left,lastY:H.current.top,x:_.left,y:_.top};G.current?.(_.e,t)}W.current=_},[_,R,A]);let ve=Pe(q,S,C,w,T,R?H.current:null,ie?U.current:null),ye=Q.Children.only(t),be=Me(q),xe=[Ne(E,be,i[0]),Ne(O,o,i[1])],Se=[Ne(D,be,i[0]),Ne(k,o,i[1])],Z=ye.props,Ce=Z.className,we=Z.style,Te=Q.cloneElement(ye,{ref:V,className:de(`react-grid-item`,Ce,v,{static:d,resizing:ie,"react-draggable":c,"react-draggable-dragging":R,dropping:!!_,cssTransforms:f}),style:{...y,...we,...le(ve)}}),Ee=M;return Te=(0,$.jsx)(rn.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:ve.width,height:ve.height,minConstraints:xe,maxConstraints:Se,onResizeStart:he,onResize:ge,onResizeStop:_e,transformScale:m,resizeHandles:j,handle:Ee,children:Te}),Te=(0,$.jsx)(nn.DraggableCore,{disabled:!c,onStart:ue,onDrag:fe,onStop:pe,handle:b,cancel:`.react-resizable-handle`+(x?`,`+x:``),scale:m,nodeRef:V,children:Te}),Te}var sn=()=>{},cn=`react-grid-layout`,ln=!1;try{ln=/firefox/i.test(navigator.userAgent)}catch{}function un(e,t){let n=Q.Children.toArray(e),r=Q.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t?.key!==i?.key)return!1}return!0}function dn(e,t,n,r){let i=[],a=new Set;Q.Children.forEach(t,t=>{if(!Q.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(Je(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Ge(i),w:1,h:1})}});let o=Qe(i,{cols:n});return r.compact(o,n)}function fn(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=vt,compactor:c,constraints:l=nt,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=sn,onDragStart:_=sn,onDrag:v=sn,onDragStop:y=sn,onResizeStart:b=sn,onResize:x=sn,onResizeStop:S=sn,onDrop:C=sn,onDropDragOver:w=sn}=e,T=(0,Q.useMemo)(()=>({...yt,...r}),[r]),E=(0,Q.useMemo)(()=>({...bt,...i}),[i]),D=(0,Q.useMemo)(()=>({...xt,...a}),[a]),O=(0,Q.useMemo)(()=>({...St,...o}),[o]),{cols:k,rowHeight:A,maxRows:j,margin:M,containerPadding:N}=T,{enabled:ee,bounded:te,handle:P,cancel:F,threshold:I}=E,{enabled:ne,handles:L,handleComponent:re}=D,{enabled:R,defaultItem:z,onDragOver:ie}=O,B=c??Mt(`vertical`),V=B.type,H=B.allowOverlap,U=B.preventCollision??!1,W=(0,Q.useMemo)(()=>d??{i:`__dropping-elem__`,...z},[d,z]),ae=s.type===`transform`,oe=s.scale,G=N??M,[se,ce]=(0,Q.useState)(!1),[K,q]=(0,Q.useState)(()=>dn(u,t,k,B)),[J,Y]=(0,Q.useState)(null),[X,le]=(0,Q.useState)(!1),[ue,fe]=(0,Q.useState)(null),[pe,me]=(0,Q.useState)(),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(0),ye=(0,Q.useRef)(K),be=(0,Q.useRef)(u),xe=(0,Q.useRef)(t),Se=(0,Q.useRef)(V),Z=(0,Q.useRef)(K);Z.current=K,(0,Q.useEffect)(()=>{ce(!0),(0,an.deepEqual)(K,u)||g(K)},[]),(0,Q.useEffect)(()=>{if(J||ue)return;let e=!(0,an.deepEqual)(u,be.current),n=!un(t,xe.current),r=V!==Se.current;if(e||n||r){let n=dn(e?u:K,t,k,B);(0,an.deepEqual)(n,K)||q(n)}be.current=u,xe.current=t,Se.current=V},[u,t,k,V,B,J,ue,K]),(0,Q.useEffect)(()=>{!J&&!(0,an.deepEqual)(K,ye.current)&&(ye.current=K,g(K.filter(e=>e.i!==W.i)))},[K,J,g,W.i]);let Ce=(0,Q.useMemo)(()=>{if(!f)return;let e=Ge(K),t=G[1];return e*A+(e-1)*M[1]+t*2+`px`},[f,K,A,M,G]),we=(0,Q.useCallback)((e,t,n,r)=>{let i=Z.current,a=Ke(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};he.current=Je(a),_e.current=i,Y(o),_(i,a,a,null,r.e,r.node)},[_]),Te=(0,Q.useCallback)((e,t,n,r)=>{let i=Z.current,a=he.current,o=Ke(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=$e(i,o,t,n,!0,U,V,k,H);v(c,a,o,s,r.e,r.node),q(B.compact(c,k)),Y(s)},[U,V,k,H,B,v]),Ee=(0,Q.useCallback)((e,t,n,r)=>{if(!J)return;let i=Z.current,a=he.current,o=Ke(i,e);if(!o)return;let s=$e(i,o,t,n,!0,U,V,k,H),c=B.compact(s,k);y(c,a,o,null,r.e,r.node);let l=_e.current;he.current=null,_e.current=null,Y(null),q(c),l&&!(0,an.deepEqual)(l,c)&&g(c)},[J,U,V,k,H,B,y,g]),De=(0,Q.useCallback)((e,t,n,r)=>{let i=Z.current,a=Ke(i,e);a&&(ge.current=Je(a),_e.current=i,le(!0),b(i,a,a,null,r.e,r.node))},[b]),Oe=(0,Q.useCallback)((e,t,n,r)=>{let i=Z.current,a=ge.current,{handle:o}=r,s=!1,c,l,[u,d]=Ze(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),U&&!H&&Ve(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=$e(u,d,c,l,!0,U,V,k,H));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node),q(B.compact(f,k)),Y(p)},[U,V,k,H,B,x]),ke=(0,Q.useCallback)((e,t,n,r)=>{let i=Z.current,a=ge.current,o=Ke(i,e),s=B.compact(i,k);S(s,a,o??null,null,r.e,r.node);let c=_e.current;ge.current=null,_e.current=null,Y(null),le(!1),q(s),c&&!(0,an.deepEqual)(c,s)&&g(s)},[k,B,S,g]),Ae=(0,Q.useCallback)(()=>{let e=Z.current;if(!e.some(e=>e.i===W.i)){fe(null),Y(null),me(void 0);return}q(B.compact(e.filter(e=>e.i!==W.i),k)),fe(null),Y(null),me(void 0)},[W.i,k,B]),je=(0,Q.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),ln&&!e.nativeEvent.target?.classList.contains(cn))return!1;let t=ie?ie(e.nativeEvent):w(e);if(t===!1)return ue&&Ae(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...W,...a},s=e.currentTarget.getBoundingClientRect(),c={cols:k,margin:M,maxRows:j,rowHeight:A,containerWidth:n,containerPadding:G},l=Me(c),u=Ne(o.w,l,M[0]),d=Ne(o.h,A,M[1]),f=u/2,p=d/2,m=e.clientX-s.left+r-f,h=e.clientY-s.top+i-p,g=Math.max(0,m),_=Math.max(0,h),v={left:g/oe,top:_/oe,e:e.nativeEvent};if(ue)pe&&(pe.left!==v.left||pe.top!==v.top)&&me(v);else{let e=Fe(c,_,g,o.w,o.h);fe((0,$.jsx)(`div`,{},o.i)),me(v),q([...Z.current.filter(e=>e.i!==o.i),{...o,x:e.x,y:e.y,static:!1,isDraggable:!0}])}},[ue,pe,W,ie,w,Ae,oe,k,M,j,A,n,G]),Pe=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),ve.current--,ve.current<0&&(ve.current=0),ve.current===0&&Ae()},[Ae]),Ie=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),ve.current++},[]),Le=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=Z.current,n=t.find(e=>e.i===W.i);ve.current=0,Ae(),C(t,n,e.nativeEvent)},[W.i,Ae,C]),Re=(0,Q.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=Ke(K,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&ee,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&ne,o=r.resizeHandles||[...L],c=i&&te&&r.isBounded!==!1,u=re;return(0,$.jsx)(on,{containerWidth:n,cols:k,margin:M,containerPadding:G,maxRows:j,rowHeight:A,cancel:F,handle:P,onDragStart:we,onDrag:Te,onDragStop:Ee,onResizeStart:De,onResize:Oe,onResizeStop:ke,isDraggable:i,isResizable:a,isBounded:c,useCSSTransforms:ae&&se,usePercentages:!se,transformScale:oe,positionStrategy:s,dragThreshold:I,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?pe:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:K,children:e},r.i)},[K,n,k,M,G,j,A,F,P,we,Te,Ee,De,Oe,ke,ee,ne,te,ae,se,oe,s,I,pe,L,re,l]),ze=()=>J?(0,$.jsx)(on,{w:J.w,h:J.h,x:J.x,y:J.y,i:J.i,className:`react-grid-placeholder ${X?`placeholder-resizing`:``}`,containerWidth:n,cols:k,margin:M,containerPadding:G,maxRows:j,rowHeight:A,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:ae,transformScale:oe,constraints:l,layout:K,children:(0,$.jsx)(`div`,{})}):null;return(0,$.jsxs)(`div`,{ref:h,className:de(cn,p),style:{height:Ce,...m},onDrop:R?Le:void 0,onDragLeave:R?Pe:void 0,onDragEnter:R?Ie:void 0,onDragOver:R?je:void 0,children:[Q.Children.map(t,e=>Q.isValidElement(e)?Re(e):null),R&&ue&&Re(ue,!0),ze()]})}var pn={lg:1200,md:996,sm:768,xs:480,xxs:0},mn={lg:12,md:10,sm:6,xs:4,xxs:2},hn=()=>{};function gn(e,t,n,r){let i=[];Q.Children.forEach(t,t=>{if(!Q.isValidElement(t)||t.key===null)return;let n=String(t.key),r=e.find(e=>e.i===n);if(r)i.push({...r,i:n});else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Ge(i),w:1,h:1})}});let a=Qe(i,{cols:n});return r.compact(a,n)}function _n(e){let{children:t,width:n,breakpoint:r,breakpoints:i=pn,cols:a=mn,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=hn,onLayoutChange:p=hn,onWidthChange:m=hn,...h}=e,g=d??Mt(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Q.useMemo)(()=>r??Pt(i,n),[]),b=(0,Q.useMemo)(()=>Ft(y,a),[y,a]),x=(0,Q.useMemo)(()=>It(o,i,y,y,b,_),[]),[S,C]=(0,Q.useState)(y),[w,T]=(0,Q.useState)(b),[E,D]=(0,Q.useState)(x),[O,k]=(0,Q.useState)(o),A=(0,Q.useRef)(n),j=(0,Q.useRef)(r),M=(0,Q.useRef)(i),N=(0,Q.useRef)(a),ee=(0,Q.useRef)(o),te=(0,Q.useRef)(_),P=(0,Q.useRef)(O);(0,Q.useEffect)(()=>{P.current=O},[O]);let F=(0,Q.useMemo)(()=>(0,an.deepEqual)(o,ee.current)?null:It(o,i,S,S,w,g),[o,i,S,w,g]),I=F??E;(0,Q.useEffect)(()=>{F!==null&&(D(F),k(o),P.current=o,ee.current=o)},[F,o]),(0,Q.useEffect)(()=>{if(_!==te.current){let e=g.compact(Ye(I),w),t={...P.current,[S]:e};D(e),k(t),P.current=t,p(e,t),te.current=_}},[_,g,I,w,v,S,p]),(0,Q.useEffect)(()=>{let e=n!==A.current,o=r!==j.current,s=!(0,an.deepEqual)(i,M.current),c=!(0,an.deepEqual)(a,N.current);if(e||o||s||c){let e=r??Pt(i,n),o=Ft(e,a),d=S;if(d!==e||s||c){let n={...P.current};n[d]||(n[d]=Ye(E));let r=It(n,i,e,d,o,g);r=gn(r,t,o,g),n[e]=r,C(e),T(o),D(r),k(n),P.current=n,f(e,o),p(r,n)}m(n,Lt(l,e),o,u?Lt(u,e):null),A.current=n,j.current=r,M.current=i,N.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let ne=(0,Q.useCallback)(e=>{let t={...P.current,[S]:e};D(e),k(t),P.current=t,p(e,t)},[S,p]),L=(0,Q.useMemo)(()=>Lt(l,S),[l,S]),re=(0,Q.useMemo)(()=>u===null?null:Lt(u,S),[u,S]),R=(0,Q.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:L,containerPadding:re}),[w,s,c,L,re]);return(0,$.jsx)(fn,{...h,width:n,gridConfig:R,compactor:g,onLayoutChange:ne,layout:I,children:t})}function vn({editMode:e}){let t=m();return Q.useEffect(()=>{if(e)return t.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{t.endDrag()};t.endDrag(`dashboard`)},[e,t]),null}var yn=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];function bn(e,t){if(!e.widgets?.length)return e;let n=new Map(t.map(e=>[e.i,e])),r=e.widgets.map((e,t)=>{let r=e.id||`widget-${t}`,i=n.get(r);return i?{...e,layout:{x:i.x,y:i.y,w:i.w,h:i.h}}:e});return{...e,widgets:r}}function xn(e){return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x??t%4*3,y:e.layout?.y??Math.floor(t/4)*4,w:e.layout?.w??3,h:e.layout?.h??4}))||[]}}var Sn=({schema:e,className:t,onLayoutChange:n,onSchemaChange:r,onRefresh:i})=>{let{width:a,containerRef:o,mounted:s}=zt(),[c,u]=Q.useState(!1),[d,f]=Q.useState(!1),m=p(),h=Q.useRef(null),g=Q.useCallback(()=>{i&&(f(!0),i(),setTimeout(()=>f(!1),600))},[i]);Q.useEffect(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!i))return h.current=setInterval(g,e.refreshInterval*1e3),()=>{h.current&&clearInterval(h.current)}},[e.refreshInterval,i,g]);let[_,v]=Q.useState(()=>xn(e)),y=Q.useMemo(()=>JSON.stringify(e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x,y:e.layout?.y,w:e.layout?.w,h:e.layout?.h}))??[]),[e.widgets]);Q.useEffect(()=>{v(xn(e))},[y]);let b=Q.useCallback((e,t)=>{v(t),n?.(e)},[n]),x=Q.useCallback(()=>{r?r(bn(e,_.lg)):globalThis.process?.env?.NODE_ENV!==`production`&&console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."),u(!1)},[r,e,_]),S=Q.useCallback(()=>{v(xn(e))},[e]),w=Q.useCallback(e=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`horizontal-bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`||t===`funnel`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(Ce(r)){let n=r.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a;return{type:`object-chart`,chartType:t,objectName:e.object||r.object,aggregate:o,xAxisKey:i,series:[{dataKey:s}],colors:yn,className:`h-full`}}if(!r&&e.object){let n=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0;return{type:`object-chart`,chartType:t,objectName:e.object,aggregate:n,xAxisKey:i,series:[{dataKey:e.valueField||`value`}],colors:yn,className:`h-full`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:yn,className:`h-full`}}if(t===`table`){let t=e.data||n.data;if(Ce(t)){let{data:r,...i}=n;return{type:`data-table`,...i,objectName:e.object||t.object,dataProvider:t,data:[],searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`data-table`,...n,objectName:e.object,data:[],searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data;if(Ce(t)){let{data:r,...i}=n;return{type:`pivot`,...i,objectName:e.object||t.object,dataProvider:t,data:[]}}return{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}},[]);return(0,$.jsxs)(`div`,{ref:o,className:z(`w-full`,t),"data-testid":`grid-layout`,children:[m&&(0,$.jsx)(vn,{editMode:c}),(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`text-2xl font-bold`,children:e.title||`Dashboard`}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(W,{onClick:x,size:`sm`,variant:`default`,children:[(0,$.jsx)(oe,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,$.jsxs)(W,{onClick:S,size:`sm`,variant:`outline`,children:[(0,$.jsx)(X,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,$.jsx)(W,{onClick:()=>u(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,$.jsxs)($.Fragment,{children:[i&&(0,$.jsxs)(W,{onClick:g,size:`sm`,variant:`outline`,disabled:d,"aria-label":`Refresh dashboard`,children:[(0,$.jsx)(le,{className:z(`h-4 w-4 mr-2`,d&&`animate-spin`)}),d?`Refreshing…`:`Refresh All`]}),(0,$.jsxs)(W,{onClick:()=>u(!0),size:`sm`,variant:`outline`,children:[(0,$.jsx)(re,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),s&&(0,$.jsx)(_n,{className:`layout`,width:a,layouts:_,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:c,handle:`.drag-handle`},resizeConfig:{enabled:c},onLayoutChange:b,children:e.widgets?.map((e,t)=>{let n=e.id||`widget-${t}`,r=w(e);return(0,$.jsx)(`div`,{className:`h-full`,children:e.type===`metric`?(0,$.jsxs)(`div`,{className:`h-full w-full relative`,children:[c&&(0,$.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,$.jsx)(C,{className:`h-4 w-4`})}),(0,$.jsx)(l,{schema:r,className:`h-full w-full`})]}):(0,$.jsxs)(N,{className:z(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,c&&`ring-2 ring-primary/20`),children:[e.title&&(0,$.jsxs)(ne,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,$.jsx)(I,{className:`text-base font-medium tracking-tight truncate`,title:e.title,children:e.title}),c&&(0,$.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,$.jsx)(C,{className:`h-4 w-4`})})]}),(0,$.jsx)(se,{className:`p-0 h-full`,children:(0,$.jsx)(`div`,{className:z(`h-full w-full overflow-auto p-4`),children:(0,$.jsx)(l,{schema:r})})})]})},n)})})]})},Cn=v({"dashboard.trend.vsLastQuarter":`vs last quarter`,"dashboard.trend.vsLastMonth":`vs last month`,"dashboard.trend.vsLastWeek":`vs last week`,"dashboard.trend.vsLastYear":`vs last year`,"dashboard.trend.vsYesterday":`vs yesterday`,"dashboard.trend.vsPreviousPeriod":`vs previous period`},`dashboard.trend.vsLastQuarter`);function wn(e){switch(e.trim().toLowerCase().replace(/\s+/g,` `)){case`vs last quarter`:case`vs previous quarter`:return`dashboard.trend.vsLastQuarter`;case`vs last month`:case`vs previous month`:return`dashboard.trend.vsLastMonth`;case`vs last week`:case`vs previous week`:return`dashboard.trend.vsLastWeek`;case`vs last year`:case`vs previous year`:return`dashboard.trend.vsLastYear`;case`vs yesterday`:return`dashboard.trend.vsYesterday`;case`vs previous period`:case`vs prior period`:return`dashboard.trend.vsPreviousPeriod`;default:return}}function Tn(e,t,n){if(e==null)return``;if(typeof e==`string`){let r=Number(e);return!isFinite(r)||e.trim()===``?e:Tn(r,t,n)}if(!isFinite(e))return String(e);let r={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`},i=(t||``).trim(),a=!!n||i.length>0&&r[i[0]]!==void 0,o=i.endsWith(`%`),s=i.match(/0\.(0+)/),c=s?s[1].length:0;if(a){let t=n||r[i[0]]||`USD`;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}catch{return`${t} ${e.toFixed(c)}`}}return o?`${(e>1?e:e*100).toFixed(c)}%`:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}function En(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var Dn={default:`bg-muted text-muted-foreground`,blue:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,teal:`bg-teal-500/10 text-teal-600 dark:text-teal-400`,orange:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,purple:`bg-purple-500/10 text-purple-600 dark:text-purple-400`,success:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},On=({label:e,value:t,trend:n,icon:r,className:i,description:a,loading:o,error:s,colorVariant:c=`default`,format:l,currency:u,prefix:d,suffix:f,onClick:p,...m})=>{let h=Dn[c]||Dn.default,{t:g}=Cn(),_=(0,Q.useMemo)(()=>{let e=En(a)||En(n?.label);if(!e)return e;let t=wn(e);return t?g(t):e},[a,n?.label,g]),v=(0,Q.useMemo)(()=>{let e=typeof t==`number`||typeof t==`string`&&t.trim()!==``&&isFinite(Number(t))?Tn(t,l,u):t??``,n=String(e);return`${d&&n.startsWith(d)?``:d??``}${n}${f&&n.endsWith(f)?``:f??``}`},[t,l,u,d,f]),y=(0,Q.useMemo)(()=>{if(typeof r==`string`){let e=j(r);return e?(0,$.jsx)(e,{className:`h-4 w-4`}):null}return r},[r]);return(0,$.jsxs)(N,{className:z(`h-full overflow-hidden`,p&&`cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,i),onClick:p,role:p?`button`:void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())}:void 0,...m,children:[(0,$.jsxs)(ne,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,$.jsx)(I,{className:`text-sm font-medium truncate`,children:En(e)}),y&&(0,$.jsx)(`div`,{className:z(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,h),children:y})]}),(0,$.jsx)(se,{children:o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,$.jsx)(B,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,$.jsx)(J,{className:`h-4 w-4 text-destructive shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:s})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-2xl font-bold truncate`,children:v}),(n||a)&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0`,children:[n&&(0,$.jsxs)(`span`,{className:z(`flex items-center shrink-0 font-medium`,n.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,n.direction===`down`&&`text-rose-600 dark:text-rose-400`,n.direction===`neutral`&&`text-muted-foreground`),children:[n.direction===`up`&&(0,$.jsx)(P,{className:`h-3 w-3 mr-1`}),n.direction===`down`&&(0,$.jsx)(L,{className:`h-3 w-3 mr-1`}),n.direction===`neutral`&&(0,$.jsx)(G,{className:`h-3 w-3 mr-1`}),n.value,`%`]}),(0,$.jsx)(`span`,{className:`truncate min-w-0`,children:_})]})]})})]})};function kn(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var An=({title:e,value:t,icon:n,trend:r,trendValue:i,description:a,className:o,loading:s,error:c,...l})=>{let u=n?j(n):null;return(0,$.jsxs)(N,{className:z(`h-full`,o),...l,children:[(0,$.jsxs)(ne,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,$.jsx)(I,{className:`text-sm font-medium`,children:kn(e)}),u&&(0,$.jsx)(u,{className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(se,{children:s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,$.jsx)(B,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):c?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,$.jsx)(J,{className:`h-4 w-4 text-destructive shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:c})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(r||i||a)&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[r&&i&&(0,$.jsxs)(`span`,{className:z(`flex items-center mr-2`,r===`up`&&`text-green-500`,r===`down`&&`text-red-500`,r===`neutral`&&`text-yellow-500`),children:[r===`up`&&(0,$.jsx)(P,{className:`h-3 w-3 mr-1`}),r===`down`&&(0,$.jsx)(L,{className:`h-3 w-3 mr-1`}),r===`neutral`&&(0,$.jsx)(G,{className:`h-3 w-3 mr-1`}),i]}),kn(a)]})]})})]})},jn=({objectName:e,aggregate:t,filter:n,label:r,fallbackValue:i,trend:a,icon:c,className:d,description:p,dataSource:m,colorVariant:h,format:_,currency:v,prefix:y,suffix:b,invert:S,drillDown:C,title:w,compareTo:O,t:j})=>{let M=(0,Q.useContext)(x),N=m||M?.dataSource,[P,F]=(0,Q.useState)(!1),[I,ne]=(0,Q.useState)(null),[L,re]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(!1),[ie,B]=(0,Q.useState)(null),[V,H]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let t=!0;if(!(!N||!e||typeof N.getObjectSchema!=`function`))return N.getObjectSchema(e).then(e=>{t&&H(e)}).catch(()=>{}),()=>{t=!1}},[N,e]);let U=(0,Q.useMemo)(()=>{let e=t?.field;if(!e||!V?.fields)return null;let n=V.fields;return Array.isArray(n)?n.find(t=>t?.name===e)||null:n[e]||null},[V,t?.field]),W=(0,Q.useMemo)(()=>{if(_)return _;if(U){if(U.type===`currency`){let e=U.precision??U.scale??0;return e>0?`0,0.${`0`.repeat(e)}`:`0,0`}if(U.type===`percent`)return`0,0%`;if(U.type===`number`||U.type===`integer`)return`0,0`}},[_,U]),ae=(0,Q.useMemo)(()=>{if(v)return v;if(U?.type===`currency`)return U.defaultCurrency||U.currency||void 0},[v,U]),oe=(0,Q.useMemo)(()=>t?JSON.stringify(t):``,[t]),G=(0,Q.useMemo)(()=>o(n),[n]),se=(0,Q.useMemo)(()=>G?JSON.stringify(G):``,[G]),ce=(0,Q.useMemo)(()=>O?JSON.stringify(O):``,[O]),K=(0,Q.useCallback)(async(n,r)=>{if(t&&typeof n.aggregate==`function`){let i=await n.aggregate(e,{field:t.field,function:t.function,groupBy:t.groupBy||`_all`,filter:r}),a=Array.isArray(i)?i:[];if(a.length===0)return 0;if(t.function===`count`){let e=`${t.field}_count`;return a.reduce((n,r)=>n+(Number(r[e])||Number(r[t.field])||Number(r.count)||0),0)}let o=a[0];return o[`${t.field}_${t.function}`]??o[t.field]??o.value??0}if(typeof n.find==`function`){let t=await n.find(e,{$filter:r});return(Array.isArray(t)?t:t?.data||t?.records||[]).length}return null},[e,oe]),q=(0,Q.useCallback)(async(t,r)=>{if(!(!t||!e)){r.current&&(z(!0),B(null));try{let e=O?f(n,O):null,[i,a]=await Promise.all([K(t,G),e?K(t,e):Promise.resolve(null)]);if(i===null)return;r.current&&(ne(i),re(typeof a==`number`&&Number.isFinite(a)?a:null))}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),r.current&&B(e instanceof Error?e.message:`Failed to load metric`)}finally{r.current&&z(!1)}}},[e,oe,se,ce,K]);(0,Q.useEffect)(()=>{let t={current:!0};return N&&e?q(N,t):(ne(null),B(null)),()=>{t.current=!1}},[N,e,q]);let J=I===null?N?`—`:i??`—`:I;S&&typeof J==`number`&&isFinite(J)&&J>=0&&J<=1&&(J=1-J);let Y=(0,Q.useMemo)(()=>{if(!O||typeof I!=`number`||!Number.isFinite(I)||L===null)return;let e=we(I,L);if(!e)return;let t=u(O,n),r=`dashboard.trend.${t}`,i={vsPreviousPeriod:`vs previous period`,vsLastWeek:`vs last week`,vsLastMonth:`vs last month`,vsLastQuarter:`vs last quarter`,vsLastYear:`vs last year`,vsYesterday:`vs yesterday`},a=j?j(r,i[t]||t):i[t]||t;return{value:e.value,direction:e.direction,label:a}},[O,I,L,n,j])??a,X=g(C)&&!!e&&!!N,le=(0,Q.useMemo)(()=>{let e=typeof r==`string`?r:r?.defaultValue||``;return s(C,{},(typeof w==`string`?w:w?.defaultValue||``)||e||`Details`)},[C,r,w]),de=(0,Q.useMemo)(()=>{if(!X)return null;let t=C?.target??`drawer`,n=C?.report,r=n&&typeof n==`object`&&(Array.isArray(n.columns)||`objectName`in n),i;if(r){let e=n.filter,t=e?G?{$and:[e,G]}:e:G;i=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsx)(l,{schema:{type:`spec-report`,...n,filter:t}})})}else i=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsx)(l,{schema:{type:`object-data-table`,objectName:e,filter:G,pageSize:25,drillDown:{enabled:!1}}})});return t===`dialog`?(0,$.jsx)(E,{open:!0,onOpenChange:e=>!e&&F(!1),children:(0,$.jsxs)(k,{className:`max-w-5xl`,children:[(0,$.jsx)(ue,{children:(0,$.jsx)(T,{children:le})}),i]})}):(0,$.jsx)(ee,{open:!0,onOpenChange:e=>!e&&F(!1),children:(0,$.jsxs)(te,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col`,children:[(0,$.jsx)(D,{children:(0,$.jsx)(A,{children:le})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:i})]})})},[X,C,e,G,le]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(On,{label:r,value:J,trend:Y,icon:c,className:d,description:p,loading:R,error:ie,colorVariant:h,format:W,currency:ae,prefix:y,suffix:b,onClick:X?()=>F(!0):void 0}),P&&de]})};function Mn(){try{let{t:e}=_(),t=e(`dashboard.total`);return!t||t===`dashboard.total`?`Total`:t}catch{return`Total`}}function Nn(){try{let{t:e}=_(),t=e(`dashboard.noDataAvailable`);return!t||t===`dashboard.noDataAvailable`?`No data available`:t}catch{return`No data available`}}function Pn(e,t){if(!t)return String(e);let n=``,r=``,i=!1,a,o=t,s=o.match(/^([^0-9.,#]*)/);if(s&&s[1]){let e=s[1];n=e.replace(`,`,``),e.includes(`,`)&&(i=!0),o=o.slice(s[1].length)}o.includes(`,`)&&(i=!0,o=o.replace(/,/g,``));let c=o.match(/\.(\d+)f?/);c&&(a=Number(c[1]),o=o.slice(c[0].length)),r=o.replace(/[0-9#.f]/g,``);let l=a===void 0?String(e):e.toFixed(a);if(i){let[e,t]=l.split(`.`),i=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?i:`${i}.${t}`)+r}return n+l+r}var Fn=`—`;function In(e,t){return e===``?Fn:t?.[e]??e}function Ln(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return e.reduce((e,t)=>e+t,0)}}var Rn=({schema:e,className:t,rowLabels:n,columnLabels:r,rowFieldLabel:i,onDrillDown:a})=>{let{title:o,rowField:s,columnField:c,valueField:l,aggregation:u=`sum`,data:d=[],showRowTotals:f=!1,showColumnTotals:p=!1,format:m,columnColors:h,drillDown:_}=e,v=Mn(),y=Nn(),b=g(_)&&typeof a==`function`,x=e=>{b&&a({...e,rowLabel:e.rowKey===void 0?e.rowLabel:n?.[e.rowKey]??e.rowKey,colLabel:e.colKey===void 0?e.colLabel:r?.[e.colKey]??e.colKey})},S=e=>t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},C=b?`cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]`:``,w=Array.isArray(d)?d:[],{rowKeys:T,colKeys:E,matrix:D,rowTotals:O,colTotals:k,grandTotal:A}=(0,Q.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let r of w){let i=String(r[s]??``),a=String(r[c]??``),o=Number(r[l])||0;e.set(i,!0),t.set(a,!0),n[i]||(n[i]={}),n[i][a]||(n[i][a]=[]),n[i][a].push(o)}let r=Array.from(e.keys()),i=Array.from(t.keys()),a={},o={},d={};for(let e of r){a[e]={};let t=[];for(let r of i){let i=n[e]?.[r]??[],o=Ln(i,u);a[e][r]=o,t.push(...i),!d[r]&&d[r]}o[e]=Ln(t,u)}for(let e of i){let t=[];for(let i of r){let r=n[i]?.[e]??[];t.push(...r)}d[e]=Ln(t,u)}let f=[];for(let e of w)f.push(Number(e[l])||0);return{rowKeys:r,colKeys:i,matrix:a,rowTotals:o,colTotals:d,grandTotal:Ln(f,u)}},[w,s,c,l,u]),j=e=>Pn(e,m);return w.length===0?(0,$.jsxs)(`div`,{className:z(`overflow-auto`,t),children:[o&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:o}),(0,$.jsx)(V,{"data-testid":`pivot-empty-state`,className:`py-8 gap-2 [&>h3]:hidden`,icon:(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`})]}),iconWrapperClassName:``,title:``,description:y})]}):(0,$.jsxs)(`div`,{className:z(`overflow-auto`,t),children:[o&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:o}),(0,$.jsxs)(`table`,{className:`w-full text-sm border-collapse table-auto`,role:`table`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,$.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground whitespace-nowrap`,children:i||s}),E.map(e=>{let t=()=>x({scope:`column`,colKey:e});return(0,$.jsx)(`th`,{className:z(`text-right p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,h?.[e]??`text-muted-foreground`,C),title:e===``?`${c}: (empty)`:`${c}: ${e}`,role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?t:void 0,onKeyDown:b?S(t):void 0,"aria-label":b?`Drill into ${c}: ${e||`(empty)`}`:void 0,children:In(e,r)},e)}),f&&(0,$.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap`,children:v})]})}),(0,$.jsx)(`tbody`,{children:T.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,$.jsx)(`td`,{className:z(`p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`row`,rowKey:e}):void 0,onKeyDown:b?S(()=>x({scope:`row`,rowKey:e})):void 0,"aria-label":b?`Drill into ${s}: ${e||`(empty)`}`:void 0,children:In(e,n)}),E.map(t=>{let n=D[e]?.[t]??0,r=()=>x({scope:`cell`,rowKey:e,colKey:t,value:n});return(0,$.jsx)(`td`,{className:z(`text-right p-2 tabular-nums`,h?.[t],C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?r:void 0,onKeyDown:b?S(r):void 0,"aria-label":b?`Drill into ${s}=${e||`(empty)`}, ${c}=${t||`(empty)`}`:void 0,children:j(n)},t)}),f&&(0,$.jsx)(`td`,{className:z(`text-right p-2 font-semibold tabular-nums bg-muted/20`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`row`,rowKey:e,value:O[e]??0}):void 0,onKeyDown:b?S(()=>x({scope:`row`,rowKey:e,value:O[e]??0})):void 0,children:j(O[e]??0)})]},e))}),p&&(0,$.jsx)(`tfoot`,{children:(0,$.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,$.jsx)(`td`,{className:`p-2`,children:v}),E.map(e=>(0,$.jsx)(`td`,{className:z(`text-right p-2 tabular-nums`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`column`,colKey:e,value:k[e]??0}):void 0,onKeyDown:b?S(()=>x({scope:`column`,colKey:e,value:k[e]??0})):void 0,children:j(k[e]??0)},e)),f&&(0,$.jsx)(`td`,{className:z(`text-right p-2 tabular-nums font-bold`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`total`,value:A}):void 0,onKeyDown:b?S(()=>x({scope:`total`,value:A})):void 0,children:j(A)})]})})]})]})};function zn(e){return e.map(e=>typeof e==`string`?{header:e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase()),accessorKey:e}:e)}function Bn(e,t){if(!t?.fields)return[];let n={};if(Array.isArray(t.fields))for(let e of t.fields)e?.name&&(n[e.name]=e);else for(let[e,r]of Object.entries(t.fields))n[e]={name:e,...r};let r=e=>e===`lookup`||e===`reference`||e===`master_detail`||e===`user`||e===`owner`,i=Array.isArray(e.columns)?e.columns:[],a=new Set;if(i.length>0){let e=i.map(e=>typeof e==`string`?e:e.accessorKey||e.name).filter(Boolean);for(let t of e){let e=n[t];e&&r(e.type)&&a.add(t)}}else for(let[e,t]of Object.entries(n))r(t?.type)&&a.add(e);return Array.from(a)}var Vn=({schema:e,dataSource:t,className:n})=>{let r=(0,Q.useContext)(x),i=t||r?.dataSource,a=d(e.bind),{fieldLabel:s,fieldOptionLabel:c}=ce(),u=`No data available`,f=`No data source available for`;try{let{t:e}=_(),t=e(`dashboard.noDataAvailable`);t&&t!==`dashboard.noDataAvailable`&&(u=t);let n=e(`dashboard.noDataSourceFor`);n&&n!==`dashboard.noDataSourceFor`&&(f=n)}catch{}let[p,m]=(0,Q.useState)([]),[g,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(()=>!(Array.isArray(e.data)&&e.data.length>0)&&!!e.objectName),[C,T]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)?(async()=>{if(!i||!e.objectName){t&&b(!1);return}t&&(b(!0),T(null));try{let n;if(typeof i.find==`function`){let t=Bn(e,g),r={$filter:o(e.filter)};t.length&&(r.$expand=t),n=h(await i.find(e.objectName,r))}else return;t&&m(n)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),t&&T(e instanceof Error?e.message:`Failed to load data`)}finally{t&&b(!1)}})():t&&b(!1),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter,g]),(0,Q.useEffect)(()=>{let t=!0;if(!(!i||!e.objectName||typeof i.getObjectSchema!=`function`))return i.getObjectSchema(e.objectName).then(e=>{t&&v(e)}).catch(()=>{}),()=>{t=!1}},[e.objectName,i]);let E=a||e.data||p,D=Array.isArray(E)?E:[],O=(0,Q.useMemo)(()=>{let t=e.objectName,n={};if(g?.fields){let e=g.fields;if(Array.isArray(e))for(let t of e)t?.name&&(n[t.name]=t);else for(let[t,r]of Object.entries(e))n[t]={name:t,...r}}let r=e=>{let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`);return t?s(t,e,n):n},i=e=>{let r=n[e.accessorKey],i=e.referenceTo??r?.referenceTo??(typeof r?.reference==`string`?r.reference:r?.reference?.to)??r?.target,a=e.options??r?.options;t&&a&&(r?.type===`select`||r?.type===`picklist`||r?.type===`dropdown`||r?.type===`status`)&&(a=a.map(n=>{if(n==null)return n;let r=typeof n==`object`?n.value:n,i=typeof n==`object`&&n.label||String(r);return{value:r,label:c(t,e.accessorKey,String(r),i),color:typeof n==`object`?n.color:void 0}}));let o={name:e.accessorKey,label:e.header,type:e.type??r?.type,options:a,referenceTo:i,format:e.format??r?.format,currency:e.currency??r?.currency??r?.defaultCurrency,decimals:e.decimals??r?.decimals??r?.precision??r?.scale},s=new Set([`currency`,`money`,`number`,`integer`,`decimal`,`float`,`percent`,`percentage`]),l=e.align??(s.has(o.type)||typeof o.format==`string`&&/^[\$¥€£]|%$|0/.test(o.format)?`right`:void 0);if(typeof e.cell==`function`)return{...e,...o,align:l};let u=e=>{if(e==null||e===``)return``;let t=o.format;if(typeof t==`string`&&/^\$|¥|€|£/.test(t)&&typeof e==`number`){let n={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`}[t[0]];return ie(e,o.currency||n)}if(typeof t==`string`&&/%/.test(t)&&typeof e==`number`){let n=(t.match(/0\.(0+)%/)||[,``])[1].length;return K((e>1?e/100:e)*100,n)}return typeof t==`string`&&/[YMDHms]/.test(t)?R(e,t):(0,$.jsx)(H(U(o)),{value:e,field:o})};return{...e,...o,align:l,cell:u}};if(e.columns&&e.columns.length>0){let n=zn(e.columns);return(t?n.map(e=>({...e,header:s(t,e.accessorKey,e.header)})):n).map(i)}if(D.length===0)return[];let a=new Set([`id`,`organization_id`,`tenant_id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`deleted_at`,`deleted_by`,`version`,`_id`,`__typename`]),o=(e,t)=>t&&(t.isSystem===!0||t.system===!0)?!0:a.has(e);return(Object.keys(n).length>0?Object.keys(n).filter(e=>!o(e,n[e])):Object.keys(D[0]).filter(e=>!e.startsWith(`_`)&&!o(e))).map(e=>i({header:r(e),accessorKey:e}))},[e.columns,e.objectName,D,g,s,c]);if(y&&D.length===0)return(0,$.jsx)(`div`,{className:z(`overflow-auto`,n),"data-testid":`table-loading`,children:(0,$.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(w,{className:`h-6 w-1/4`}),(0,$.jsx)(w,{className:`h-6 w-1/4`}),(0,$.jsx)(w,{className:`h-6 w-1/4`}),(0,$.jsx)(w,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(w,{className:`h-5 w-1/4`}),(0,$.jsx)(w,{className:`h-5 w-1/4`}),(0,$.jsx)(w,{className:`h-5 w-1/4`}),(0,$.jsx)(w,{className:`h-5 w-1/4`})]},e))]})});if(C)return(0,$.jsx)(`div`,{className:z(`overflow-auto`,n),"data-testid":`table-error`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,$.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,$.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:C})]})});if(!i&&e.objectName&&D.length===0)return(0,$.jsx)(`div`,{className:z(`overflow-auto`,n),children:(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,$.jsxs)(`p`,{className:`text-xs`,children:[f,` “`,e.objectName,`”`]})})});if(D.length===0)return(0,$.jsx)(`div`,{className:z(`overflow-auto`,n),"data-testid":`table-empty-state`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,$.jsx)(`line`,{x1:`3`,y1:`9`,x2:`21`,y2:`9`}),(0,$.jsx)(`line`,{x1:`9`,y1:`21`,x2:`9`,y2:`9`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:u})]})});let k={...e,type:`data-table`,data:D,columns:O};return(0,$.jsxs)(`div`,{className:z(`relative`,n),children:[(0,$.jsx)(S,{active:y&&D.length>0}),(0,$.jsx)(l,{schema:k,className:n})]})},Hn=({open:e,onClose:t,title:n,target:r=`drawer`,objectName:i,filter:a,dataSource:o,columns:s,maxRows:c,className:u,report:d})=>{let f=d&&typeof d==`object`&&(Array.isArray(d.columns)||`objectName`in d),p=(0,$.jsx)(`div`,{className:z(`overflow-auto`,u),"data-testid":`drill-down-body`,children:f?(()=>{let e=d.filter,t=e?a?{$and:[e,a]}:e:a;return(0,$.jsx)(l,{schema:{...d,type:`spec-report`,report:{...d,filter:t},filter:t}})})():(0,$.jsx)(Vn,{schema:{type:`object-data-table`,objectName:i,filter:a,columns:s?.map(e=>({accessorKey:e,header:e})),pagination:!0,searchable:!1,pageSize:c},dataSource:o})});return r===`dialog`?(0,$.jsx)(E,{open:e,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(k,{className:`max-w-5xl`,children:[(0,$.jsx)(ue,{children:(0,$.jsx)(T,{children:n})}),p]})}):(0,$.jsx)(ee,{open:e,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(te,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,$.jsx)(D,{children:(0,$.jsx)(A,{children:n})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:p})]})})},Un=({schema:e,dataSource:t,className:n})=>{let r=(0,Q.useContext)(x),i=t||r?.dataSource,a=d(e.bind),[l,u]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)({}),[b,S]=(0,Q.useState)({}),[C,T]=(0,Q.useState)(null),{fieldLabel:E,fieldOptionLabel:D}=ce(),O=(0,Q.useRef)(E),k=(0,Q.useRef)(D);(0,Q.useEffect)(()=>{O.current=E,k.current=D},[E,D]),(0,Q.useEffect)(()=>{if(!i||!e.objectName)return;let t=i.getObjectSchema;if(typeof t!=`function`)return;let n=!0;return Promise.resolve(t.call(i,e.objectName)).then(t=>{if(!n||!t?.fields)return;let r=e.objectName,i={},a={};for(let[e,n]of Object.entries(t.fields)){let t=n?.label?String(n.label):e;a[e]=O.current(r,e,t);let o=n?.options;if(Array.isArray(o)&&o.length>0){let t={};for(let n of o)if(n&&n.value!==void 0&&n.label!==void 0){let i=String(n.value),a=String(n.label);t[i]=k.current(r,e,i,a)}Object.keys(t).length>0&&(i[e]=t)}}y(i),S(a)}).catch(()=>{}),()=>{n=!1}},[i,e.objectName]),(0,Q.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)&&(async()=>{if(!(!i||!e.objectName)){t&&(p(!0),_(null));try{let n;if(typeof i.find==`function`)n=h(await i.find(e.objectName,{$filter:o(e.filter)}));else return;t&&u(n)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),t&&_(e instanceof Error?e.message:`Failed to load data`)}finally{t&&p(!1)}}})(),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter]);let A=a||e.data||l,j=Array.isArray(A)?A:[];if(f&&j.length===0)return(0,$.jsxs)(`div`,{className:z(`overflow-auto`,n),"data-testid":`pivot-loading`,children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(w,{className:`h-6 w-24`}),(0,$.jsx)(w,{className:`h-6 w-20`}),(0,$.jsx)(w,{className:`h-6 w-20`}),(0,$.jsx)(w,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(w,{className:`h-5 w-24`}),(0,$.jsx)(w,{className:`h-5 w-20`}),(0,$.jsx)(w,{className:`h-5 w-20`}),(0,$.jsx)(w,{className:`h-5 w-20`})]},e))]})]});if(m)return(0,$.jsxs)(`div`,{className:z(`overflow-auto`,n),"data-testid":`pivot-error`,children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,$.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,$.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:m})]})]});if(!i&&e.objectName&&j.length===0)return(0,$.jsxs)(`div`,{className:z(`overflow-auto`,n),children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,$.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]});let M={...e,data:j},N=e.rowField?v[e.rowField]:void 0,ee=e.columnField?v[e.columnField]:void 0,te=e.rowField?b[e.rowField]:void 0,P=e.drillDown,F=g(P)?e=>T(e):void 0;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rn,{schema:M,className:n,rowLabels:N,columnLabels:ee,rowFieldLabel:te,onDrillDown:F}),(()=>{if(!C||!e.objectName)return null;let t=c(P,C,{rowField:e.rowField,columnField:e.columnField}),n={...e.filter||{},...t};return(0,$.jsx)(Hn,{open:!0,onClose:()=>T(null),title:s(P,C,e.title||`Details`),target:P?.target??`drawer`,objectName:e.objectName,filter:n,dataSource:i,columns:P?.columns,maxRows:P?.maxRows,report:P?.report})})()]})},Wn={breadcrumb:[`Dashboard`,`Configuration`],sections:[{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`columns`,label:`Columns`,type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:`Gap`,type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:`Row height (px)`,type:`slider`,defaultValue:120,min:40,max:320,step:10}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`refreshInterval`,label:`Auto refresh`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Off`},{value:`30`,label:`Every 30s`},{value:`60`,label:`Every 1 min`},{value:`300`,label:`Every 5 min`},{value:`900`,label:`Every 15 min`},{value:`1800`,label:`Every 30 min`},{value:`3600`,label:`Every 1 hour`}]}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Dashboard title`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Short summary shown under the title`},{key:`showDescription`,label:`Show description`,type:`switch`,defaultValue:!0},{key:`theme`,label:`Theme`,type:`select`,defaultValue:`auto`,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`auto`,label:`Auto`}]}]}]};function Gn({open:e,onClose:t,config:n,onSave:r,onFieldChange:i}){let{draft:a,isDirty:o,updateField:s,discard:c}=Y(n,{onUpdate:i});return(0,$.jsx)(F,{open:e,onClose:t,schema:Wn,draft:a,isDirty:o,onFieldChange:s,onSave:()=>r(a),onDiscard:c})}var Kn=[{value:`metric`,label:`Metric`},{value:`bar`,label:`Bar Chart`},{value:`horizontal-bar`,label:`Horizontal Bar`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`donut`,label:`Donut Chart`},{value:`area`,label:`Area Chart`},{value:`scatter`,label:`Scatter Plot`},{value:`funnel`,label:`Funnel`},{value:`table`,label:`Table`},{value:`pivot`,label:`Pivot Table`}],qn=[{value:`default`,label:`Default`},{value:`blue`,label:`Blue`},{value:`teal`,label:`Teal`},{value:`orange`,label:`Orange`},{value:`purple`,label:`Purple`},{value:`success`,label:`Success`},{value:`warning`,label:`Warning`},{value:`danger`,label:`Danger`}],Jn=[{value:`count`,label:`Count`},{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}],Yn=[`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`],Xn=[`bar`,`horizontal-bar`,`line`,`area`,`scatter`],Zn=[`pie`,`donut`,`funnel`],Qn=[`metric`,...Yn],$n=[...Yn],er=[`pivot`,`metric`,`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`];function tr(e){return!!e&&Yn.includes(e)}function nr(e){return!!e&&Xn.includes(e)}function rr(e){return!!e&&$n.includes(e)}function ir(e){return!!e&&Qn.includes(e)}function ar(e){return!!e&&er.includes(e)}var or=[{value:`drawer`,label:`Side drawer`},{value:`dialog`,label:`Center dialog`}],sr=[{value:`group`,label:`Group`},{value:`value`,label:`Value`}],cr=[{value:`asc`,label:`↑`},{value:`desc`,label:`↓`}];function lr(e,t,n,r){return{key:e,label:t,type:`custom`,render:(i,a,o)=>(0,$.jsx)(O,{label:t,children:(0,$.jsx)(`div`,{"data-testid":`config-field-${e}`,children:(0,$.jsx)(M,{options:r??[],value:i??``,onValueChange:a,placeholder:n,searchPlaceholder:`Search fields…`,emptyText:`No fields found.`,className:`h-7 w-32 text-xs`,disabled:!o.object})})})}}function ur(e,t,n){let r=e&&e.length>0,i=r?{key:`object`,label:`Data source`,type:`custom`,render:(t,n)=>(0,$.jsx)(O,{label:`Data source`,children:(0,$.jsx)(`div`,{"data-testid":`config-field-object`,children:(0,$.jsx)(M,{options:e,value:t??``,onValueChange:n,placeholder:`Select object…`,searchPlaceholder:`Search objects…`,emptyText:`No objects found.`,className:`h-7 w-32 text-xs`})})})}:{key:`object`,label:`Data source`,type:`input`,placeholder:`Object name`},a=r?{...lr(`categoryField`,`Category field`,`Select field…`,t),helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>rr(e.type)}:{key:`categoryField`,label:`Category field`,type:`input`,placeholder:`e.g. status`,helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>rr(e.type)},o=r?{...lr(`valueField`,`Value field`,`Select field…`,t),helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>ir(e.type)&&(e.aggregate??`count`)!==`count`}:{key:`valueField`,label:`Value field`,type:`input`,placeholder:`e.g. amount`,helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>ir(e.type)&&(e.aggregate??`count`)!==`count`},s=r?lr(`rowField`,`Field`,`Select row field…`,t):{key:`rowField`,label:`Field`,type:`input`,placeholder:`e.g. owner`},c=r?lr(`columnField`,`Field`,`Select column field…`,t):{key:`columnField`,label:`Field`,type:`input`,placeholder:`e.g. stage`},l=r?lr(`valueField`,`Field`,`Select value field…`,t):{key:`valueField`,label:`Field`,type:`input`,placeholder:`e.g. amount`};return{breadcrumb:[`Dashboard`,{pivot:`Pivot table`,table:`Table`}[n??``]??(tr(n)?`Chart`:`Widget`)],sections:[{key:`general`,title:`General`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Widget title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Widget description`},{key:`type`,label:`Widget type`,type:`select`,options:Kn,defaultValue:`metric`}]},{key:`data`,title:`Data Binding`,collapsible:!0,visibleWhen:e=>e.type!==`pivot`,fields:[i,a,o,{key:`aggregate`,label:`Aggregation`,type:`select`,options:Jn,defaultValue:`count`,helpText:`Count ignores Value field; Sum / Avg / Min / Max require it.`,visibleWhen:e=>ir(e.type)}]},{key:`pivot-data`,title:`Data`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[i]},{key:`pivot-rows`,title:`Rows`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[s,{key:`rowSortBy`,label:`Sort by`,type:`icon-group`,options:sr,defaultValue:`group`},{key:`rowSortOrder`,label:`Sort order`,type:`icon-group`,options:cr,defaultValue:`asc`},{key:`showRowLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showRowTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-columns`,title:`Columns`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[c,{key:`columnSortBy`,label:`Sort by`,type:`icon-group`,options:sr,defaultValue:`group`},{key:`columnSortOrder`,label:`Sort order`,type:`icon-group`,options:cr,defaultValue:`asc`},{key:`showColumnLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showColumnTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-values`,title:`Values`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[l,{key:`aggregation`,label:`Aggregation`,type:`select`,options:Jn,defaultValue:`sum`},{key:`format`,label:`Number format`,type:`input`,placeholder:`e.g. $,.2f`}]},{key:`chart-axis`,title:`Axis & Series`,collapsible:!0,visibleWhen:e=>nr(e.type),fields:[{key:`xAxisLabel`,label:`X-axis label`,type:`input`,placeholder:`e.g. Month`},{key:`yAxisLabel`,label:`Y-axis label`,type:`input`,placeholder:`e.g. Revenue`},{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`chart-legend`,title:`Display`,collapsible:!0,visibleWhen:e=>!!e.type&&Zn.includes(e.type),fields:[{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`table-options`,title:`Table options`,collapsible:!0,visibleWhen:e=>e.type===`table`,fields:[{key:`searchable`,label:`Searchable`,type:`switch`,defaultValue:!1},{key:`pagination`,label:`Pagination`,type:`switch`,defaultValue:!1}]},{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`layoutW`,label:`Width (columns)`,type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:`Height (rows)`,type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`drill-down`,title:`Drill-down`,collapsible:!0,defaultCollapsed:!0,visibleWhen:e=>ar(e.type),fields:[{key:`drillDownEnabled`,label:`Enable drill-down`,type:`switch`,defaultValue:!1,helpText:`When enabled, clicking a cell / segment opens a filtered list of underlying records.`},{key:`drillDownTarget`,label:`Open in`,type:`select`,options:or,defaultValue:`drawer`,visibleWhen:e=>!!e.drillDownEnabled}]},{key:`behavior`,title:`Behavior`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`actionUrl`,label:`Click-through URL`,type:`input`,placeholder:`https://...`}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:`Color variant`,type:`select`,options:qn,defaultValue:`default`}]}]}}function dr(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.defaultValue||t.key||``}return String(e)}function fr(e){let t=e.type,n={...e};return rr(t)||delete n.categoryField,ir(t)?(n.aggregate??`count`)===`count`&&delete n.valueField:(delete n.valueField,delete n.aggregate),nr(t)||(delete n.xAxisLabel,delete n.yAxisLabel),t===`pivot`?(delete n.aggregate,delete n.categoryField):(delete n.rowField,delete n.columnField,delete n.aggregation,delete n.rowSortBy,delete n.rowSortOrder,delete n.columnSortBy,delete n.columnSortOrder,delete n.showRowLabels,delete n.showRowTotals,delete n.showColumnLabels,delete n.showColumnTotals,delete n.format),t!==`table`&&(delete n.searchable,delete n.pagination),ar(t)||(delete n.drillDownEnabled,delete n.drillDownTarget),n}function pr({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,headerExtra:a,availableObjects:o,availableFields:s}){let{draft:c,isDirty:l,updateField:u,discard:d}=Y(Q.useMemo(()=>({...n,title:typeof n.title==`object`?dr(n.title):n.title,description:typeof n.description==`object`?dr(n.description):n.description}),[n]),{onUpdate:i});return(0,$.jsx)(F,{open:e,onClose:t,schema:Q.useMemo(()=>ur(o,s,c.type),[o,s,c.type]),draft:c,isDirty:l,onFieldChange:u,onSave:()=>r(fr(c)),onDiscard:d,headerExtra:a})}function mr({schema:e,config:t,onConfigSave:n,onWidgetSave:r,onRefresh:i,recordCount:a,defaultConfigOpen:o=!1,className:s}){let[c,l]=(0,Q.useState)(o),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(e),[m,h]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{p(e),h(e=>e+1)},[e]);let g=Q.useMemo(()=>{if(!u||!f.widgets)return null;let e=f.widgets.find(e=>(e.id||e.title)===u);if(!e)return null;let t=e.options||{};return{...t,id:e.id??``,title:e.title??``,description:e.description??``,type:e.type??``,object:e.object??``,categoryField:e.categoryField??t.categoryField??``,valueField:e.valueField??t.valueField??``,aggregate:e.aggregate??t.aggregate??``,colorVariant:e.colorVariant??t.colorVariant??`default`,actionUrl:e.actionUrl??t.actionUrl??``,drillDownEnabled:t.drillDown?.enabled??!!(e.object&&(e.type===`pivot`||e.type===`metric`||e.type===`bar`||e.type===`horizontal-bar`||e.type===`line`||e.type===`area`||e.type===`pie`||e.type===`donut`||e.type===`funnel`)),drillDownTarget:t.drillDown?.target??`drawer`,layoutW:e.layout?.w??1,layoutH:e.layout?.h??1}},[u,m]),_=(0,Q.useCallback)(e=>{d(e),l(!0)},[]),v=(0,Q.useCallback)(()=>{d(null)},[]),y=(0,Q.useCallback)((e,t)=>{u&&p(n=>n.widgets?{...n,widgets:n.widgets.map(n=>{if((n.id||n.title)!==u)return n;if(e===`layoutW`)return{...n,layout:{...n.layout||{},w:t}};if(e===`layoutH`)return{...n,layout:{...n.layout||{},h:t}};if(e===`drillDownEnabled`||e===`drillDownTarget`){let r=n.options?.drillDown??{},i=e===`drillDownEnabled`?{...r,enabled:!!t}:{...r,target:t};return{...n,options:{...n.options||{},drillDown:i}}}return{...n,[e]:t}})}:n)},[u]),b=(0,Q.useCallback)(e=>{if(u&&r){let{drillDownEnabled:t,drillDownTarget:n,...i}=e,a={...i};(t||n)&&(a.options={...i.options||{},drillDown:{...i.options?.drillDown||{},...t===void 0?{}:{enabled:!!t},...n===void 0?{}:{target:n}}}),r(u,a)}d(null),h(e=>e+1)},[u,r]),x=(0,Q.useCallback)(()=>{l(e=>!e),d(null)},[]);return(0,$.jsxs)(`div`,{className:z(`flex h-full w-full`,s),"data-testid":`dashboard-with-config`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-auto relative`,children:[(0,$.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,$.jsxs)(W,{size:`sm`,variant:c?`default`:`outline`,onClick:x,"data-testid":`dashboard-config-toggle`,children:[(0,$.jsx)(q,{className:`h-3.5 w-3.5 mr-1`}),`Settings`]})}),(0,$.jsx)(je,{schema:f,onRefresh:i,recordCount:a,designMode:c,selectedWidgetId:u,onWidgetClick:_})]}),c&&(0,$.jsx)(`div`,{className:`relative shrink-0`,children:u&&g?(0,$.jsx)(pr,{open:!0,onClose:v,config:g,onSave:b,onFieldChange:y}):(0,$.jsx)(Gn,{open:!0,onClose:()=>l(!1),config:t,onSave:n})})]})}var hr=t({DashboardConfigPanel:()=>Gn,DashboardGridLayout:()=>Sn,DashboardRenderer:()=>je,DashboardWithConfig:()=>mr,DrillDownDrawer:()=>Hn,MetricCard:()=>An,MetricWidget:()=>On,ObjectDataTable:()=>Vn,ObjectMetricWidget:()=>jn,ObjectPivotTable:()=>Un,PivotTable:()=>Rn,WidgetConfigPanel:()=>pr,dashboardComponents:()=>gr});y.register(`dashboard`,je,{namespace:`view`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`columns`,type:`number`,label:`Columns`,defaultValue:3},{name:`gap`,type:`number`,label:`Gap`,defaultValue:4},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:3,widgets:[]}}),y.register(`metric`,On,{namespace:`plugin-dashboard`,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`,label:`Label`},{name:`value`,type:`string`,label:`Value`}]}),y.register(`metric-card`,An,{namespace:`plugin-dashboard`,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`value`,type:`string`,label:`Value`,required:!0},{name:`icon`,type:`string`,label:`Icon (Lucide name)`},{name:`trend`,type:`enum`,label:`Trend`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`,label:`Trend Value (e.g., +12%)`},{name:`description`,type:`string`,label:`Description`}],defaultProps:{title:`Metric`,value:`0`}}),y.register(`object-metric`,jn,{namespace:`plugin-dashboard`,label:`Object Metric`,category:`Dashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`label`,type:`string`,label:`Label`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`},{name:`icon`,type:`string`,label:`Icon (Lucide name)`}],defaultProps:{label:`Metric`}}),y.register(`pivot`,Rn,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}}),y.register(`object-pivot`,Un,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`filter`,type:`array`,label:`Filter`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),y.register(`dashboard-grid`,Sn,{namespace:`plugin-dashboard`,label:`Dashboard Grid (Editable)`,category:`Complex`,icon:`layout-grid`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{title:`Dashboard`,widgets:[]}}),y.register(`object-data-table`,Vn,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`searchable`,type:`boolean`,label:`Searchable`},{name:`pagination`,type:`boolean`,label:`Pagination`}],defaultProps:{searchable:!1,pagination:!1}});var gr={DashboardRenderer:je,DashboardGridLayout:Sn,MetricWidget:On,MetricCard:An,ObjectMetricWidget:jn,PivotTable:Rn,ObjectPivotTable:Un,ObjectDataTable:Vn,DashboardConfigPanel:Gn,WidgetConfigPanel:pr,DashboardWithConfig:mr};export{je as i,pr as n,Gn as r,hr as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{g as n,r}from"./vendor-react-CIpZOxG3.js";import{t as i}from"./vendor-objectstack-CwZ3saTl.js";import{H as a,M as o,at as s,ot as c,r as l,ut as u}from"./framework-ClI3DbWX.js";import{C as d,Li as f,Ri as p,_r as ee,ar as te,bo as m,cr as h,d as g,dr as _,es as v,fr as ne,ko as y,lr as b,mr as x,or as S,sr as C,u as w,ur as T,vr as E,xo as D}from"./ui-components-DYQ4Pai7.js";import{i as O,r as k}from"./plugins-views-DM6-O61C.js";var A=e(n(),1),j={"gantt.column.taskName":`Task Name`,"gantt.column.start":`Start`,"gantt.column.end":`End`,"gantt.toolbar.prevPeriod":`Previous period`,"gantt.toolbar.nextPeriod":`Next period`,"gantt.toolbar.zoomIn":`Zoom in`,"gantt.toolbar.zoomOut":`Zoom out`,"gantt.toolbar.jumpToToday":`Jump to today`,"gantt.toolbar.today":`Today`,"gantt.toolbar.showTaskList":`Show task list`,"gantt.toolbar.hideTaskList":`Hide task list`},M=`gantt.column.taskName`;function N(e,t){let n=j[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function P(){try{let e=l();return e.t(M)===M?{t:N}:{t:e.t}}catch{return{t:N}}}var F=r();function re(e){return e<640?35:e<1024?50:60}function I(e){return e<640?140:e<1024?220:320}function L(e){return e>=280}function R(e){return e<640?32:40}function z({tasks:e,startDate:t,endDate:n,onTaskClick:r,onTaskUpdate:i,className:a,inlineEdit:o=!1}){let{t:s}=P(),[c,l]=A.useState(new Date),u=A.useRef(null),{width:te}=d(u),h=te||(typeof window<`u`?window.innerWidth:1024),g=h<640,_=R(h),ne=re(h),[b,S]=A.useState(null),C=b??ne,[w,T]=A.useState(!1),O=A.useRef(!1);A.useEffect(()=>{!O.current&&g&&(T(!0),O.current=!0)},[g]);let k=w?0:I(h),j=L(k),[M,N]=A.useState(null),[z,B]=A.useState({}),[V,H]=A.useState(null),U=A.useRef(null);A.useEffect(()=>{U.current=V},[V]);let W=A.useRef(!1),G=A.useCallback(e=>{let t=1e3*60*60*24,n=t,r=e.dayDelta*t,i=new Date(e.originStart),a=new Date(e.originEnd);return e.mode===`move`?(i=new Date(e.originStart.getTime()+r),a=new Date(e.originEnd.getTime()+r)):e.mode===`resize-left`?(i=new Date(e.originStart.getTime()+r),a.getTime()-i.getTime()<n&&(i=new Date(a.getTime()-n))):e.mode===`resize-right`&&(a=new Date(e.originEnd.getTime()+r),a.getTime()-i.getTime()<n&&(a=new Date(i.getTime()+n))),{start:i,end:a}},[]);A.useEffect(()=>{if(!V)return;let t=e=>{let t=U.current;if(!t)return;let n=Math.round((e.clientX-t.originClientX)/Math.max(C,1));n!==t.dayDelta&&H({...t,dayDelta:n})},n=()=>{let t=U.current;if(t){if(t.dayDelta!==0){let n=e.find(e=>e.id===t.taskId);if(n&&i){let{start:e,end:r}=G(t);i(n,{start:e,end:r})}W.current=!0,window.setTimeout(()=>{W.current=!1},0)}H(null)}};return window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n)}},[V,C,e,i,G]);let K=A.useCallback((e,t,n)=>{i&&(n.stopPropagation(),n.preventDefault(),H({taskId:e.id,mode:t,originStart:new Date(e.start),originEnd:new Date(e.end),originClientX:n.clientX,dayDelta:0}))},[i]),q=A.useMemo(()=>{let r=t?new Date(t):new Date,i=n?new Date(n):new Date;return!t&&e.length>0&&(r=new Date(Math.min(...e.map(e=>e.start.getTime()))),r.setDate(r.getDate()-7)),!n&&e.length>0&&(i=new Date(Math.max(...e.map(e=>e.end.getTime()))),i.setDate(i.getDate()+14)),r.setHours(0,0,0,0),i.setHours(23,59,59,999),{start:r,end:i}},[t,n,e]),J=A.useMemo(()=>{let e=[],t=new Date(q.start);for(;t<=q.end;)e.push({date:new Date(t),label:t.getDate().toString(),isWeekend:t.getDay()===0||t.getDay()===6}),t.setDate(t.getDate()+1);return e},[q]),Y=A.useRef(null),X=A.useRef(null),ie=A.useRef(null),Z=A.useRef(null),Q=A.useRef(null),ae=A.useCallback(e=>{if(e.touches.length===2){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;Q.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:C}}},[C]),oe=A.useCallback(e=>{if(e.touches.length!==2||!Q.current)return;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.max(1,Math.sqrt(t*t+n*n))/Q.current.baseDistance;S(Math.max(15,Math.min(120,Math.round(Q.current.baseColumn*r))))},[]),se=A.useCallback(()=>{Q.current=null},[]),$=A.useMemo(()=>{let e=new Date;if(e<q.start||e>q.end)return null;let t=(e.getTime()-q.start.getTime())/(1440*60*1e3);return Math.round(t*C)},[q,C]),ce=A.useCallback(()=>{if($==null||!Z.current)return;let e=Math.max(0,$-Z.current.clientWidth/2);Z.current.scrollTo({left:e,behavior:`smooth`})},[$]),le=e=>{Y.current&&(Y.current.scrollLeft=e.currentTarget.scrollLeft),X.current&&(X.current.scrollTop=e.currentTarget.scrollTop)},ue=e=>{q.end.getTime()-q.start.getTime();let t=C,n=1e3*60*60*24,r=e.start.getTime()-q.start.getTime(),i=e.end.getTime()-e.start.getTime();return{left:r/n*t,width:Math.max(i/n*t,t)}};return(0,F.jsxs)(`div`,{ref:u,className:v(`flex flex-col h-full bg-background overflow-hidden min-w-0`,a),children:[(0,F.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(x,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":s(`gantt.toolbar.prevPeriod`),children:(0,F.jsx)(D,{className:`h-4 w-4`})}),(0,F.jsx)(x,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":s(`gantt.toolbar.nextPeriod`),children:(0,F.jsx)(m,{className:`h-4 w-4`})}),(0,F.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:q.start.toLocaleDateString(void 0,{month:`long`,year:`numeric`})})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,F.jsx)(x,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>S(Math.max(15,C-10)),"aria-label":s(`gantt.toolbar.zoomOut`),children:(0,F.jsx)(E,{className:`h-3 w-3`})}),(0,F.jsx)(x,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>S(Math.min(120,C+10)),"aria-label":s(`gantt.toolbar.zoomIn`),children:(0,F.jsx)(ee,{className:`h-3 w-3`})})]}),(0,F.jsx)(x,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>T(e=>!e),"aria-label":s(w?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":w,"data-testid":`gantt-toggle-task-list`,children:w?(0,F.jsx)(f,{className:`h-4 w-4`}):(0,F.jsx)(p,{className:`h-4 w-4`})}),(0,F.jsx)(x,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ce,disabled:$==null,"aria-label":s(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:(0,F.jsx)(y,{className:`h-4 w-4`})})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 sm:h-[50px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm`,style:{width:k,minWidth:k},children:[(0,F.jsx)(`div`,{className:`flex-1 truncate`,children:s(`gantt.column.taskName`)}),j&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`w-16 sm:w-20 text-right`,children:s(`gantt.column.start`)}),(0,F.jsx)(`div`,{className:`w-16 sm:w-20 text-right`,children:s(`gantt.column.end`)})]})]}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:Y,children:(0,F.jsx)(`div`,{className:`flex h-full`,style:{width:J.length*C},children:J.map((e,t)=>(0,F.jsxs)(`div`,{className:v(`flex flex-col items-center justify-center border-r text-xs text-muted-foreground h-full`,e.isWeekend&&`bg-muted/50`),style:{width:C,minWidth:C},children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),(0,F.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.date.toLocaleDateString(void 0,{weekday:`narrow`})})]},t))})})]}),(0,F.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,F.jsx)(`div`,{className:`overflow-hidden border-r bg-card z-10 shadow-sm`,ref:X,style:{width:k,minWidth:k},children:e.map(e=>{let t=o&&M===e.id;return(0,F.jsxs)(`div`,{className:`group/task-row flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation`,style:{height:_},onClick:()=>!t&&r?.(e),onDoubleClick:()=>{o&&i&&(N(e.id),B({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:e.end.toLocaleDateString(`en-CA`),progress:String(e.progress)}))},children:[(0,F.jsxs)(`div`,{className:`flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:e.color||`#3b82f6`}}),t?(0,F.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:z.title||``,onChange:e=>B(t=>({...t,title:e.target.value})),onKeyDown:t=>{t.key===`Enter`?(i?.(e,{title:z.title,start:new Date(z.start),end:new Date(z.end),progress:Number(z.progress)||0}),N(null)):t.key===`Escape`&&N(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,F.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:e.title}),(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground sm:hidden`,children:[e.start.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})]})]})]}),(0,F.jsx)(`div`,{className:`w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!j,style:j?void 0:{display:`none`},children:t?(0,F.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:z.start||``,onChange:e=>B(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})}),(0,F.jsx)(`div`,{className:`w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!j,style:j?void 0:{display:`none`},children:t?(0,F.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:z.end||``,onChange:e=>B(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})})]},e.id)})}),(0,F.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{ie.current=e,Z.current=e},onScroll:le,onTouchStart:ae,onTouchMove:oe,onTouchEnd:se,"data-testid":`gantt-timeline`,children:(0,F.jsxs)(`div`,{className:`relative`,style:{width:J.length*C},children:[$!=null&&(0,F.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px bg-red-500/80 z-20 pointer-events-none`,style:{left:$},"data-testid":`gantt-today-marker`,"aria-label":s(`gantt.toolbar.today`),children:(0,F.jsx)(`div`,{className:`absolute -top-2 -translate-x-1/2 left-0 text-[10px] font-semibold text-white bg-red-500 rounded-sm px-1 py-0.5 whitespace-nowrap`,children:s(`gantt.toolbar.today`)})}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`div`,{className:`absolute inset-0 flex pointer-events-none z-0`,children:J.map((e,t)=>(0,F.jsx)(`div`,{className:v(`border-r h-full`,e.isWeekend&&`bg-muted/20`),style:{width:C,minWidth:C}},t))}),e.map(e=>{let t=ue(e),n=V?.taskId===e.id,a=t;if(n&&V){let t=G(V);a=ue({...e,start:t.start,end:t.end})}let o=!!i;return(0,F.jsxs)(`div`,{className:`relative border-b hover:bg-black/5`,style:{height:_},children:[n&&(0,F.jsx)(`div`,{className:`absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm border border-dashed border-primary/60 pointer-events-none`,style:{left:t.left,width:t.width,opacity:.35},"aria-hidden":`true`}),(0,F.jsxs)(`div`,{className:v(`absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm bg-primary border border-primary-foreground/20 shadow-sm hover:brightness-110 flex items-center px-2 group select-none`,o?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,n&&`ring-2 ring-primary/60 brightness-110 z-10`),style:{left:a.left,width:a.width,backgroundColor:e.color||`#3b82f6`},"data-testid":`gantt-task-bar-${e.id}`,onClick:()=>{W.current||r?.(e)},onPointerDown:o?t=>{t.button===0&&K(e,`move`,t)}:void 0,children:[o&&a.width>=14&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-white/40`,"data-testid":`gantt-task-resize-left-${e.id}`,onPointerDown:t=>{t.button===0&&K(e,`resize-left`,t)},onClick:e=>e.stopPropagation()}),(0,F.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-white/40`,"data-testid":`gantt-task-resize-right-${e.id}`,onPointerDown:t=>{t.button===0&&K(e,`resize-right`,t)},onClick:e=>e.stopPropagation()})]}),e.progress>0&&(0,F.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 bg-black/20 rounded-l-sm pointer-events-none`,style:{width:`${e.progress}%`}}),(0,F.jsx)(`span`,{className:`text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`,children:n?`${G(V).start.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})} → ${G(V).end.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})}`:`${Math.round(e.progress)}%`})]})]},e.id)}),(0,F.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px bg-red-500 z-20 pointer-events-none`,style:{left:(new Date().getTime()-q.start.getTime())/(1e3*60*60*24)*C},children:(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-red-500 -ml-[3px]`})})]})]})})]})]})]})}function B(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function V(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function H(e){let t=null;if(e.startDateField&&e.endDateField)return t={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||`name`,progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField},t;if(e.gantt&&(t=e.gantt),t){let e=i.safeParse(t);return e.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,e.error.format()),t}return null}var U=({schema:e,dataSource:t,className:n,onTaskClick:r,onRowClick:i,...a})=>{let[l,u]=(0,A.useState)([]),[d,f]=(0,A.useState)(!0),[p,ee]=(0,A.useState)(null),[m,v]=(0,A.useState)(null),y=B(e),x=(0,A.useMemo)(()=>y,[JSON.stringify(y)]),E=H(e),D=x?.provider===`value`;(0,A.useEffect)(()=>{(async()=>{try{if(f(!0),a.data&&Array.isArray(a.data)){u(a.data),f(!1);return}if(D&&x?.provider===`value`){u(x.items),f(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(x?.provider===`object`){let n=x.object,r=s(m?.fields);u(c(await t.find(n,{$filter:e.filter,$orderby:V(e.sort),...r.length>0?{$expand:r}:{}})))}else x?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectGantt`),u([]));f(!1)}catch(e){ee(e),f(!1)}})()},[x,t,D,e.filter,e.sort,m]),(0,A.useEffect)(()=>{!D&&t&&(async()=>{try{if(!t)return;let n=x?.provider===`object`?x.object:e.objectName;if(!n)return;v(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,D,x]);let j=(0,A.useMemo)(()=>{if(!E||!l.length)return[];let{startDateField:e,endDateField:t,titleField:n,progressField:r,dependenciesField:i,colorField:a}=E,o=(e,t)=>{if(!t)return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r},s=e=>{let t=[o(e,n),e?.name,e?.title,e?.subject,e?.label,e?.account?.name,e?.opportunity?.name,e?.contact&&[e.contact.first_name,e.contact.last_name].filter(Boolean).join(` `),e?.id,e?._id];for(let e of t)if(e!=null&&String(e).trim()!==``)return String(e);return`Untitled`};return l.map((n,o)=>{let c=n[e],l=n[t],u=s(n),d=r?n[r]:0,f=i?n[i]:[],p=a?n[a]:void 0;if(!p){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=w(void 0,e);t&&(p=g(t))}}return{id:n.id||n._id||`task-${o}`,title:u,start:c?new Date(c):new Date,end:l?new Date(l):new Date,progress:Math.min(100,Math.max(0,d||0)),dependencies:Array.isArray(f)?f:[],color:p,data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[l,E]),M=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},N=M.mode===`drawer`||M.mode===`modal`||M.mode===`split`||M.mode===`popover`,P=o({navigation:M,objectName:e.objectName,onRowClick:N?void 0:i}),re=(0,A.useCallback)(async(n,r)=>{if(!E)return;let i=x?.provider===`object`?x.object:e.objectName;if(!i||!t||typeof t.update!=`function`)return;let{startDateField:a,endDateField:o,titleField:s,progressField:c}=E,d={};if(r.start instanceof Date&&(d[a]=r.start.toISOString()),r.end instanceof Date&&(d[o]=r.end.toISOString()),typeof r.title==`string`&&s&&(d[s]=r.title),typeof r.progress==`number`&&c&&(d[c]=r.progress),Object.keys(d).length===0)return;let f=n.data?.id??n.data?._id??n.id;if(f==null)return;let p=l;u(e=>e.map(e=>String(e.id??e._id)===String(f)?{...e,...d}:e));try{await t.update(i,String(f),d)}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),u(p)}},[E,x,t,e.objectName,l]),[I,L]=(0,A.useState)(null),[R,U]=(0,A.useState)(!1),W=(0,A.useCallback)(e=>{L(e)},[]),G=(0,A.useCallback)(async()=>{if(!I)return;let n=x?.provider===`object`?x.object:e.objectName;if(!n||!t?.delete){L(null);return}let r=I.data?.id??I.data?._id??I.id;if(r==null){L(null);return}U(!0);let i=l;u(e=>e.filter(e=>String(e.id??e._id)!==String(r)));try{await t.delete(n,String(r)),L(null)}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),u(i),L(null)}finally{U(!1)}},[I,x,t,e.objectName,l]);return d?(0,F.jsx)(`div`,{className:n,children:(0,F.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,F.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):p?(0,F.jsx)(`div`,{className:n,children:(0,F.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,F.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,p.message]})})}):E?(0,F.jsxs)(`div`,{className:n,children:[(0,F.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:(0,F.jsx)(z,{tasks:j,onTaskClick:e=>{P.handleClick(e.data),r?.(e.data)},onTaskUpdate:re,onTaskDelete:W,inlineEdit:!0})}),P.isOverlay&&P.isOpen&&P.selectedRecord&&(()=>{let n=x?.provider===`object`?x.object:e.objectName,r=P.selectedRecord,i=r.id??r._id;if(!n||i==null)return null;let a=E?.titleField?String(r[E.titleField]??`Task Details`):`Task Details`;return(0,F.jsx)(k,{open:!0,onClose:P.close,title:a,record:r,objectName:n,recordId:i,dataSource:t,objectSchema:m,width:P.width,fullPageHref:O(n,i)??void 0,onFieldSave:async(e,r)=>{t?.update&&(await t.update(n,String(i),{[e]:r}),u(t=>t.map(t=>String(t.id??t._id)===String(i)?{...t,[e]:r}:t)))},onDelete:async()=>{t?.delete&&(await t.delete(n,String(i)),u(e=>e.filter(e=>String(e.id??e._id)!==String(i))))}})})(),(0,F.jsx)(te,{open:!!I,onOpenChange:e=>{!e&&!R&&L(null)},children:(0,F.jsxs)(h,{children:[(0,F.jsxs)(_,{children:[(0,F.jsx)(ne,{children:`Delete this task?`}),(0,F.jsx)(b,{children:I?(0,F.jsxs)(F.Fragment,{children:[`"`,I.title,`" will be permanently removed. This action cannot be undone.`]}):null})]}),(0,F.jsxs)(T,{children:[(0,F.jsx)(C,{disabled:R,children:`Cancel`}),(0,F.jsx)(S,{onClick:e=>{e.preventDefault(),G()},disabled:R,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:R?`Deleting…`:`Delete`})]})]})})]}):(0,F.jsx)(`div`,{className:n,children:(0,F.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,F.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},W=t({GanttView:()=>z,ObjectGantt:()=>U,ObjectGanttRenderer:()=>G}),G=({schema:e})=>{let{dataSource:t}=a()||{};return(0,F.jsx)(U,{schema:e,dataSource:t})};u.register(`object-gantt`,G,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),u.register(`gantt`,G,{namespace:`view`,label:`Gantt View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]});export{W as t};
|