react-semaphor 0.1.295 → 0.1.297
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/chunks/{braces-DWldEFn5.js → braces-BT-cB4J_.js} +1 -1
- package/dist/chunks/{braces-BdoTYzuj.js → braces-CSunPeAg.js} +1 -1
- package/dist/chunks/dashboard-controls-C6254Ugx.js +2219 -0
- package/dist/chunks/dashboard-controls-Za3WPtTh.js +47 -0
- package/dist/chunks/{dashboard-filter-controls-button-XwenlcXw.js → dashboard-filter-controls-button-DZnR5IgP.js} +487 -513
- package/dist/chunks/dashboard-filter-controls-button-dYWccDmw.js +11 -0
- package/dist/chunks/{dashboard-json-CU55qPXj.js → dashboard-json-CuI5gkwY.js} +1 -1
- package/dist/chunks/{dashboard-json-V6m6lJ_c.js → dashboard-json-DjpkfbSZ.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-DRLPzp1P.js → dashboard-summary-settings-dialog-C6FUhXQy.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-0CIiWsKc.js → dashboard-summary-settings-dialog-vC2shhM-.js} +1 -1
- package/dist/chunks/edit-dashboard-visual-CoG-tE_T.js +188 -0
- package/dist/chunks/{edit-dashboard-visual-8ha6EM_g.js → edit-dashboard-visual-TBI9_Pyh.js} +6351 -6452
- package/dist/chunks/index--CoasbAE.js +1523 -0
- package/dist/chunks/{index-14M0TnH6.js → index-D0iNspb-.js} +102960 -87712
- package/dist/chunks/{resource-management-panel-CcDAn86l.js → resource-management-panel-Cf4FTR33.js} +2 -2
- package/dist/chunks/{resource-management-panel-BL5-5ouC.js → resource-management-panel-HOWOJUap.js} +31 -30
- package/dist/chunks/{use-create-flow-overlay-state-D3PxfjYv.js → use-create-flow-overlay-state-B7bE6z5B.js} +572 -568
- package/dist/chunks/use-create-flow-overlay-state-BqiJrgeK.js +21 -0
- package/dist/chunks/use-visual-utils-DP6ty2_T.js +1 -0
- package/dist/chunks/{use-visual-utils-CdIOq4nt.js → use-visual-utils-DyvrB6Zh.js} +70 -68
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +113 -112
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +245 -1
- package/dist/types/main.d.ts +317 -12
- package/dist/types/shared.d.ts +214 -1
- package/dist/types/surfboard.d.ts +245 -1
- package/dist/types/types.d.ts +245 -1
- package/package.json +7 -1
- package/dist/chunks/dashboard-controls-B3lrnI_r.js +0 -47
- package/dist/chunks/dashboard-controls-D7U6E1sB.js +0 -2014
- package/dist/chunks/dashboard-filter-controls-button-D0AsV28-.js +0 -11
- package/dist/chunks/edit-dashboard-visual-sSLAkmgf.js +0 -183
- package/dist/chunks/index-Ze8VskG1.js +0 -1435
- package/dist/chunks/use-create-flow-overlay-state-BbQVNDCj.js +0 -21
- package/dist/chunks/use-visual-utils-kh8p2QFm.js +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";const t=require("./index--CoasbAE.js"),e=require("react/jsx-runtime"),v=require("react"),se=require("./use-visual-utils-DP6ty2_T.js");/**
|
|
2
|
+
* @license lucide-react v0.453.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Se=t.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
7
|
+
* @license lucide-react v0.453.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const he=t.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
|
|
12
|
+
* @license lucide-react v0.453.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ge=t.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
17
|
+
* @license lucide-react v0.453.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const re=t.createLucideIcon("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function ae(){var f,j;const l=t.useEditorStore(b=>b.card),a=t.useEditorStore(b=>b.frame),i=v.useMemo(()=>t.findCustomVisualConfigCard(a,l),[a,l]),{manifest:d}=t.useCustomVisual(((f=i==null?void 0:i.customCardPreferences)==null?void 0:f.url)||""),x=v.useMemo(()=>{var b;return(b=d==null?void 0:d.visuals)==null?void 0:b.find(p=>{var C;return p.name===((C=i==null?void 0:i.customCardPreferences)==null?void 0:C.componentName)})},[d,(j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName]),u=t.resolveMultiInputType(i,x),h=v.useMemo(()=>t.getCustomVisualInputCards({frame:a,configCard:i,isMultiInputVisual:u==="multiple"}),[a,i,u]),y=v.useMemo(()=>{const b=h.findIndex(p=>(p==null?void 0:p.id)===l.id);return b<0?-1:t.getSlotIndexForCard(l,b)},[h,l]);return v.useMemo(()=>!i||u!=="multiple"||y<0?l.type:t.getEffectiveCardTypeForSlot(l,y,x==null?void 0:x.slots)??l.type,[i,u,y,l,x==null?void 0:x.slots])}function Ne({type:l,isLinked:a,className:i,showLabel:d=!1,showLocal:x=!1}){const u=t.useDashboardStore(S=>S.selectedFrameId),h=t.useManagementStore(S=>S.selectedVisual),y=t.useEditorStore(S=>S.frame);let f;if(l)f=l;else if(a!==void 0)f=a?"linked":"library";else if(!!!(y!=null&&y.visualId||h!=null&&h.id)&&u)f="local";else if(h&&!u)f="library";else if(y!=null&&y.visualId&&u)f="linked";else if(h!=null&&h.id&&u)f="library";else return null;if(f==="local"&&!x)return null;const j={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},b={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},p={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},C={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},w={local:e.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:e.jsx(ge,{className:"h-3.5 w-3.5"}),library:e.jsx(he,{className:"h-3.5 w-3.5"})},k={local:"Local",linked:"Linked",library:"Library"};return e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{delayDuration:300,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs(t.Badge,{variant:"outline",className:t.cn("cursor-help select-none transition-all",j[f],i),children:[w[f],d&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:k[f]})]})}),e.jsxs(t.TooltipContent,{side:"bottom",className:t.cn("max-w-xs",p[f]),children:[e.jsx(t.TooltipArrow,{className:C[f]}),e.jsx("p",{children:b[f]})]})]})})}function De(l,a){return{...l,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?l.customCardPreferences:void 0,visualizationMode:"builtin",type:a?l.type:"bar"}}function le(l){const a=t.getDynamicFrameSaveIssue(l);return a?(t.ue.error(a),!1):!0}function Ee({className:l,variant:a="outline"}){const i=t.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=se.useVisualUtils();function x(){const u=d();le(u)&&(i==null||i(u))}return e.jsxs(t.Button,{onClick:x,className:l,size:"xs",variant:a,children:[e.jsx(t.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function we({className:l,variant:a="default"}){const i=t.useQueryClient(),[d,x]=v.useState(!1),u=t.useDashboardStore(C=>C.actions.setIsDashboardPanelOpen),{setIsVisualEditing:h}=t.useDashboardActions(),{getUpdatedFrame:y}=se.useVisualUtils(),f=t.useSelectedVisual(),j=t.useEditorStore(C=>C.frame),b=t.useUpdateVisualMutation(),p=()=>{const C=y();if(!le(C))return;const w=(j==null?void 0:j.visualId)||(f==null?void 0:f.id);if(!w){t.ue.error("No visual to save");return}x(!0),b.mutate({visualId:w,data:{frameObject:C}},{onSuccess:()=>{x(!1),u(!0),t.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",w],exact:!0})},onError:()=>{x(!1),t.ue.error("Failed to update visual")}})};return e.jsx(t.Button,{onClick:p,className:l,size:"xs",variant:a,children:d?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Ve({className:l}){const a=t.useQueryClient(),[i,d]=v.useState(!1),x=t.useSelectedVisual(),u=t.useEditorStore(k=>k.frame),h=t.useDashboardStore(k=>k.selectedSheetId),y=t.useDashboardStore(k=>k.dashboard),{updateFrame:f,setIsVisualEditing:j}=t.useDashboardActions(),{getUpdatedFrame:b}=se.useVisualUtils(),p=t.useUpdateVisualMutation(),C=t.useResolveExistingFrameSemanticExecutionPayload(),w=async()=>{if(!h){t.ue.error("No sheet selected");return}const k=(u==null?void 0:u.visualId)||(x==null?void 0:x.id);if(!k){t.ue.error("No visual to update");return}d(!0);try{const S=b();if(!le(S)){d(!1);return}const F={...S,visualId:k},Q=t.findDashboardFrameById(y,F.id),R=await C(F,{previousFrame:Q});await p.mutateAsync({visualId:k,data:{frameObject:S}}),f(h,F,{semanticExecutionPayload:R}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",k]}),t.ue.success("Saved to library and applied locally"),setTimeout(()=>{j(!1)},300)}catch(S){console.error("Failed to save and apply:",S),t.ue.error(S instanceof Error?S.message:"Failed to save and apply changes")}finally{d(!1)}};return e.jsx(t.Button,{onClick:w,className:l,size:"xs",variant:"default",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Te({className:l}){const{setTempQueryData:a,setSqlGen:i}=t.useEditorActions(),d=t.useQueryClient(),x=t.useEditorStore(p=>p.tempQueryData),u=t.useEditorStore(p=>p.onClose),h=t.useEditorStore(p=>p.card),y=ae(),f=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=t.useEditorCardQuery(f);function b(){if(x){const{queryKey:p,queryData:C}=x;p&&C&&d.setQueryData(p,C)}i({}),u==null||u()}return e.jsxs(t.Button,{onClick:b,className:l,size:"xs",variant:"outline",children:[e.jsx(t.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Ie({label:l="Clear",variant:a="secondary",className:i}={}){const{setTempQueryData:d}=t.useEditorActions(),x=t.useQueryClient(),u=t.useEditorStore(_=>_.tempQueryData),h=t.useEditorStore(_=>_.card),y=ae(),f=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=t.useEditorCardQuery(f),{setCardSql:b,setSqlGen:p,setCardPython:C,setCardCustomCfg:w,setCardPreferences:k,clearQueryConfig:S,setCardConfig:F,setCardType:Q,setFrame:R,setCard:$,setActiveTabCardId:U}=t.useEditorActions();function J(){var P,H,I,Y;const _=x.getQueryData(j);u!=null&&u.queryData||d({queryKey:j,queryData:_}),x.setQueryData(j,null),x.removeQueries({queryKey:j,exact:!0}),b(""),p({}),S(),F(void 0),C(""),w(""),k({});const r=t.useEditorStore.getState().frame,V=t.useEditorStore.getState().card,T=t.findCustomVisualConfigCard(r,V),q=((P=T==null?void 0:T.customCardPreferences)==null?void 0:P.visualType)==="multiple"||!!((H=T==null?void 0:T.customCardPreferences)!=null&&H.dataInputCardIds)||(((I=T==null?void 0:T.customCardPreferences)==null?void 0:I.minInputs)||0)>1||(((Y=T==null?void 0:T.customCardPreferences)==null?void 0:Y.maxInputs)||0)>1,A=De(V,q);R({...r,cards:r.cards.map(M=>M.id===A.id?A:M)}),U(A.id),$(A),q||Q("bar")}return e.jsxs(t.Button,{onClick:J,className:i,size:"xs",variant:a,children:[e.jsx(t.X,{className:"h-3.5 w-3.5"}),l]})}function be(l){const{control:a,onChange:i}=l;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(t.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function Fe(l){const{currentStep:a,labels:i}=l;return e.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:i.map((d,x)=>{const u=x+1,h=u===a,y=u<a;return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:t.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",h?"border-foreground bg-foreground text-background":y?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),e.jsx("span",{className:t.cn("text-[12px]",h?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),x<i.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function G(l){const{secondary:a,tertiary:i,primary:d}=l;return e.jsxs("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[a,i,d]})}function Le(l){const{control:a,scope:i,detail:d}=l;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(t.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:a.label}),e.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[t.getFriendlyTypeOption(a.type).label," ·"," ",t.getControlOptionPreview(a)," ·"," ",t.getPlacementLabel(i,a.placement)]}),d?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function me(l){const{control:a,defaultValue:i,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,onControlChange:y,onLabelChange:f,onDefaultValueChange:j,onBack:b,onNext:p,nextDisabled:C}=l;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{control:a,onChange:f}),e.jsx(t.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,controlLifecycle:"create",onChange:y}),e.jsx(t.ControlDefaultValueEditor,{control:a,value:i,onChange:j,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:h}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:b,children:"Back"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:p,disabled:C,children:"Next"})})]})}const Be=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function xe(l){const{text:a,ariaLabel:i}=l,[d,x]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(a),x(!0),setTimeout(()=>x(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-[4px] bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[e.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:a}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:d?"Copied":"Click to copy"})]})}function fe(l){const{control:a,scope:i,createdReference:d,explorerContent:x,sqlDescription:u,summaryDetail:h,onBack:y,onCancel:f,onDone:j}=l,b=Be.has(a.type),p=d.match(/\[\[param\.(.+?)\]\]/),C=p?`{{ param('${p[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Le,{control:a,scope:i,detail:h}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),e.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-[6px] border border-border/60",children:[b?e.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:x})]}):null,e.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),e.jsx(xe,{text:d,ariaLabel:"Copy SQL control reference"}),C?e.jsx(xe,{text:C,ariaLabel:"Copy Jinja control reference"}):null,e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[u," ",e.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),tertiary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:f,children:"Cancel"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:j,children:"Done"})})]})}function _e(l){const a=t.createBlankControl(l.scope,l.existingControls,l.reservedIds),i=l.type===a.type?{...a,label:t.DEFAULT_LABEL_BY_TYPE[l.type]}:{...t.applyControlTypeChange({controls:[{...a,label:t.DEFAULT_LABEL_BY_TYPE[l.type]}],controlId:a.id,nextType:l.type}).controls[0],label:t.DEFAULT_LABEL_BY_TYPE[l.type]};return{step:2,control:i,defaultValue:t.getDefaultValueForType(i,void 0)}}function qe({scope:l,controls:a,reservedControlIds:i,defaultValues:d,onChange:x,emptyMessage:u,initialCreateFlow:h=!1,usageByControlId:y,availableFieldChoices:f,availableMetricChoices:j,structuralParticipants:b,structuralParticipantIdsByControlId:p,card:C,allowedControlTypes:w,onCreateFlowActiveChange:k,onCreateFlowComplete:S}){const F=v.useMemo(()=>new Set(i||[]),[i]),Q=t.getPlacementOptionsForScope(l),R=t.getDefaultPlacement(l),[$,U]=v.useState(null),[J,_]=v.useState(null),[r,V]=v.useState(()=>h?{step:1,control:t.createBlankControl(l,a,Array.from(F))}:null),T=v.useRef({}),q=v.useRef(void 0),A=v.useRef(h),P=v.useMemo(()=>{const s=t.getFriendlyControlTypeOptions({scope:l,card:C});if(!w)return s;const o=new Set(w);return s.filter(n=>o.has(n.value))},[w,C,l]),H=v.useCallback(s=>{const o=t.getFriendlyControlTypeOptions({scope:l,card:C,includeType:w?void 0:s});if(!w)return o;const n=new Set(w);return o.filter(c=>n.has(c.value))},[w,C,l]),I=v.useCallback(s=>l==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[l]),Y=v.useMemo(()=>r?t.getEligibleParticipantsForStructuralControl(b||[],r.control.type):[],[r,b]),M=v.useMemo(()=>{if(!r)return{fields:f||[],metrics:j||[]};if(!I(r.control.type))return{fields:f||[],metrics:j||[]};const s=r.selectedCardIds||[],o=t.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:b||[],selectedCardIds:s});return{fields:r.control.type==="field_selector"?o.choices.map(n=>({option:n,target:o.fieldTargetMap[n.value]})):[],metrics:r.control.type==="metric_selector"?o.choices.map(n=>({option:n,target:o.metricTargetMap[n.value]})):[]}},[f,j,r,I,b]);v.useEffect(()=>{k==null||k(!!r)},[r,k]),v.useEffect(()=>{const s=h&&!A.current;A.current=h,s&&(V({step:1,control:t.createBlankControl(l,a,Array.from(F))}),_(null),U(null))},[a,h,F,l]);const ye=s=>{if(!I(s.type))return{fields:f||[],metrics:j||[]};const o=(p==null?void 0:p[s.id])||[];if(o.length===0)return{fields:f||[],metrics:j||[]};const n=t.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:b||[],selectedCardIds:o});return{fields:s.type==="field_selector"?n.choices.map(c=>({option:c,target:n.fieldTargetMap[c.value]})):[],metrics:s.type==="metric_selector"?n.choices.map(c=>({option:c,target:n.metricTargetMap[c.value]})):[]}},ne=s=>{if(!I(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const o=(p==null?void 0:p[s.control.id])||[],n=t.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:b||[],selectedCardIds:s.nextSelectedCardIds}),c=t.reconcileStructuralControlChoices({control:s.control,choices:n.choices}),g=Object.fromEntries(o.filter(D=>!s.nextSelectedCardIds.includes(D)).map(D=>[D,void 0]));return s.nextSelectedCardIds.length>0&&c.source.kind==="manual"&&c.source.options.length>0&&Object.assign(g,t.buildStructuralControlBindingsForParticipants({control:c,participants:b||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:c,cardBindingsById:g}},B=v.useCallback((s,o=d,n={type:"update"})=>{const c=s.map(g=>(t.resolveAuthoringControlDefaultValue({control:g,defaultValues:o}),t.syncSqlQueryControlExecutionRequirement(g)));x(c,o,n)},[d,x]),K=(s,o)=>{const n=a.find(E=>E.id===s);let c=a.map(E=>E.id!==s?E:o(E));const g=c.find(E=>E.id===s);let D,m;if(g&&l==="dashboard"&&(g.type==="field_selector"||g.type==="metric_selector")){const E=(p==null?void 0:p[g.id])||[],z=ne({control:g,nextSelectedCardIds:E});c=c.map(O=>O.id===s?z.nextControl:O),D=z.cardBindingsById,m=[g.id]}else if(n&&l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const E=(p==null?void 0:p[n.id])||[];D=Object.fromEntries(E.map(z=>[z,void 0])),m=[n.id]}const N=c.find(E=>E.id===s);let L=d;if(n&&N){const E=t.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&N.source.kind==="sql_query"&&(T.current[s]=E);const z=E===void 0&&n.source.kind==="sql_query"&&N.source.kind==="manual"?T.current[s]:E,O=t.getNextEditedControlDefaultValue({previousControl:n,nextControl:N,currentDefaultValue:z});N.source.kind==="manual"&&(T.current[s]=O),d&&(L={...d},O===void 0?delete L[s]:L[s]=O),c=c.map(pe=>pe.id===s?{...N,defaultValue:O}:pe)}B(c,L,{type:"update",cardBindingsById:D,affectedBindingControlIds:m})},ve=(s,o)=>{const n=o.trim();if(n.length===0||n===s||F.has(n)||a.some(D=>D.id===n&&D.id!==s))return;const c=a.map(D=>D.id===s?{...D,id:n}:D);if(!d){B(c,void 0,{type:"rename",oldId:s,newId:n});return}const g={...d};Object.prototype.hasOwnProperty.call(g,s)&&(g[n]=g[s],delete g[s]),B(c,g,{type:"rename",oldId:s,newId:n})},Ce=s=>{const o=a.filter(c=>c.id!==s);if(!d){B(o,void 0,{type:"remove",controlId:s});return}const n={...d};delete n[s],B(o,n,{type:"remove",controlId:s})},je=v.useCallback(()=>{q.current=void 0,V({step:1,control:t.createBlankControl(l,a,Array.from(F))}),_(null),U(null)},[a,F,l]),X=s=>{V(o=>o&&(()=>{const n=s(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(q.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?q.current:o.defaultValue,g=t.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(q.current=g),{...o,control:n,defaultValue:g}})())},oe=s=>{V(o=>o&&(o.control.source.kind==="manual"&&(q.current=s),{...o,defaultValue:s}))},W=(()=>{if(!r)return!1;if(r.step===2&&I(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const o=r.control.source.kind==="sql_query"?r.control:t.ensureManualSource(r.control);if(o.source.kind==="manual"&&(t.needsManualOptions(o)&&o.source.options.length===0||o.source.options.some(c=>c.label.trim().length===0||c.value.trim().length===0)))return!1;if(o.source.kind==="sql_query"){const{connectionId:n,sql:c,valueColumn:g}=o.source;return n.trim().length>0&&c.trim().length>0&&g.trim().length>0}return t.hasConcreteDefaultValue(t.getDefaultValueForType(o,r.defaultValue))})(),ie=()=>{var D;if(!r)return;const s=t.ensureManualSource(r.control),o=t.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:a,reservedIds:Array.from(F)}),n={...s,id:o},c=l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((D=r.selectedCardIds)!=null&&D.length)?t.buildStructuralControlBindingsForParticipants({control:n,participants:b||[],selectedCardIds:r.selectedCardIds}):void 0,g=t.getDefaultValueForType(n,r.defaultValue);V({step:l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:g,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},Z=v.useCallback(()=>{V(null)},[]),de=v.useCallback(()=>{if(!(r!=null&&r.createdControlId)){V(null);return}const s=r.control,o=r.createdControlId,n=t.getDefaultValueForType(s,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,B([...a,{...s,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else B([...a,{...s,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});_(o),V(null),S==null||S()},[a,r,d,B,S]),ke=r?I(r.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],ce=r!=null&&r.createdControlId?`[[param.${r.createdControlId}]]`:r?`[[param.${t.slugifyControlValue(r.control.label)||r.control.id}]]`:"",ee=t.buildAuthoringPreviewControlValues({controls:a,defaultValues:d}),te=r?[...a,r.control]:a,ue=r?t.buildAuthoringPreviewControlValues({controls:te,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):ee;return e.jsxs("div",{className:"space-y-4",children:[r?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(Fe,{currentStep:r.step,labels:ke}),r.step===1&&(()=>{const s=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=P.filter(g=>!s.has(g.value)),n=P.filter(g=>s.has(g.value)),c=g=>e.jsxs("button",{type:"button",className:"rounded-[6px] border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",onClick:()=>V(_e({scope:l,existingControls:a,reservedIds:Array.from(F),type:g.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:g.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:g.description})]},g.value);return e.jsxs("div",{className:"space-y-4",children:[l==="card"&&(C==null?void 0:C.sql)==null?e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,o.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:o.map(c)})]}),n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(c)})]}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:Z,children:"Back to controls"})})]})})(),r.step===2&&I(r.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{control:r.control,onChange:s=>X(o=>({...o,label:s}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),Y.length===0?e.jsx("div",{className:"rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):e.jsx("div",{className:"space-y-1 rounded-[6px] border border-border/60 bg-background p-2",children:Y.map(s=>{const o=(r.selectedCardIds||[]).includes(s.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-[4px] px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(t.Checkbox,{checked:o,onCheckedChange:n=>V(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],s.cardId]:(c.selectedCardIds||[]).filter(g=>g!==s.cardId)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.title}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:r.control.type==="field_selector"?`${s.fieldChoices.length} compatible group-by fields`:`${s.metricChoices.length} compatible metrics`})]})]},s.cardId)})}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>V(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:()=>V(s=>s&&{...s,step:3}),disabled:!W,children:"Next"})})]}),r.step===2&&!I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:M.fields,availableMetricChoices:M.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>X(()=>s),onLabelChange:s=>X(o=>({...o,label:s})),onDefaultValueChange:oe,onBack:()=>V(s=>s&&{...s,step:1}),onNext:ie,nextDisabled:!W}),r.step===3&&I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:M.fields,availableMetricChoices:M.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>X(()=>s),onLabelChange:s=>X(o=>({...o,label:s})),onDefaultValueChange:oe,onBack:()=>V(s=>s&&{...s,step:2}),onNext:ie,nextDisabled:!W}),r.step===3&&!I(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,explorerContent:e.jsxs(e.Fragment,{children:["Open the card and use"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Settings → Controls"})," ","to choose what this control changes."]}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>V(s=>s&&{...s,step:2}),onCancel:Z,onDone:de}),r.step===4&&I(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(r.selectedCardIds||[]).length," selected card",(r.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:e.jsx(e.Fragment,{children:"Selected cards have been set up to respond to this control automatically."}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>V(s=>s&&{...s,step:3}),onCancel:Z,onDone:de})]}):null,!r&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&a.map(s=>{const o=ye(s),n=y==null?void 0:y[s.id],c=t.resolveAuthoringControlDefaultValue({control:s,defaultValues:d}),g=J===s.id,D="inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";return e.jsxs("div",{className:"rounded-[6px] border border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-[4px] text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>_(m=>m===s.id?null:s.id),children:[g?e.jsx(t.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(t.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:s.label||"Untitled control"}),e.jsx("span",{className:D,children:t.getFriendlyTypeOption(s.type).label}),e.jsx("span",{className:D,children:t.getPlacementLabel(l,s.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[t.getControlOptionPreview(s),n!=null&&n.status?` · ${n.status}`:""]})]})]}),e.jsx(t.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>Ce(s.id),"aria-label":`Remove ${s.label}`,children:e.jsx(t.Trash2,{className:"h-3.5 w-3.5"})})]}),g&&e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(t.Input,{size:"xs",value:s.label,placeholder:"Control label",onChange:m=>K(s.id,N=>({...N,label:m.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(t.Select,{value:s.type,onValueChange:m=>{const N=t.applyControlTypeChange({controls:a,controlId:s.id,nextType:m,defaultValues:d});B(N.controls,N.defaultValues)},children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:H(s.type).map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(t.Select,{value:s.placement||R,onValueChange:m=>K(s.id,N=>({...N,placement:m})),children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Q.map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),I(s.type)?e.jsx(t.StructuralParticipantSelector,{type:s.type,participants:t.getEligibleParticipantsForStructuralControl(b||[],s.type).map(m=>({cardId:m.cardId,title:m.title,choiceCount:s.type==="field_selector"?m.fieldChoices.length:m.metricChoices.length})),selectedCardIds:(p==null?void 0:p[s.id])||[],onChange:m=>{const N=ne({control:s,nextSelectedCardIds:m}),L=a.map(E=>E.id===s.id?N.nextControl:E);B(L,d,{type:"update",cardBindingsById:N.cardBindingsById})}}):null,e.jsx(t.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:a,previewControlValues:ee,controlLifecycle:"edit",onChange:m=>K(s.id,()=>m)}),s.initialValueStrategy==="saved_default"&&e.jsx(t.ControlDefaultValueEditor,{control:s,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:ee,onChange:m=>{const N=a.map(L=>L.id===s.id?{...L,defaultValue:m}:L);if(s.source.kind==="manual"&&(T.current[s.id]=m),d){const L={...d};m===void 0?delete L[s.id]:L[s.id]=m,B(N,L);return}B(N,void 0)}}),e.jsxs(t.Collapsible,{open:$===s.id,onOpenChange:m=>U(m?s.id:null),children:[e.jsx(t.CollapsibleTrigger,{asChild:!0,children:e.jsxs(t.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[$===s.id?e.jsx(t.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(t.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(t.CollapsibleContent,{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Control ID"}),e.jsx(t.ControlIdInput,{controlId:s.id,onCommit:m=>ve(s.id,m)},s.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(t.Select,{value:s.initialValueStrategy,onValueChange:m=>K(s.id,N=>({...N,initialValueStrategy:m})),children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:t.INITIAL_VALUE_STRATEGY_OPTIONS.map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),e.jsx(t.ControlVisibilitySettings,{control:s,onChange:m=>K(s.id,()=>m)})]})]})]})]},s.id)}),!r&&e.jsxs(t.Button,{type:"button",variant:"outline",size:"xs",onClick:je,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Ae(l){const{open:a,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:x="passive"}=l,u=a!==void 0,[h,y]=v.useState(!1),[f,j]=v.useState(d),b=u?a:h,p=v.useCallback(k=>{!k&&f&&x==="passive"||(u||y(k),k||j(!1),i==null||i(k))},[u,f,x,i]),C=v.useCallback(()=>{u||y(!1),j(!1),i==null||i(!1)},[u,i]);v.useEffect(()=>{b||j(!1)},[b]);const w=v.useCallback(k=>{f&&k.preventDefault()},[f]);return{forceClose:C,handleOpenChange:p,isCreateFlowActive:f,preventPassiveDismissDuringCreate:w,resolvedOpen:b,setIsCreateFlowActive:j}}exports.CircleX=Se;exports.ControlDefinitionListEditor=qe;exports.EditorAcceptButton=Ee;exports.EditorCancelButton=Te;exports.EditorClearButton=Ie;exports.Library=he;exports.Link2=ge;exports.Save=re;exports.VisualBadge=Ne;exports.VisualSaveAndApplyButton=Ve;exports.VisualSaveButton=we;exports.useCreateFlowOverlayState=Ae;exports.useEffectiveEditorCardType=ae;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const a=require("./index--CoasbAE.js"),p=require("react");function J(e){const[o,s]=p.useState(null),[r,t]=p.useState(null),n=a.useEnsureReactGlobals();return p.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!n)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const c=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(c,{method:"HEAD"})).ok)throw new Error(`Module not found at ${c}`)}catch{}const h=await import(c);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>h.useChartStore),t(null)}catch(i){const c=i instanceof Error?i.message:"Unknown error";console.error("Failed to load remote chart store:",c),t(c),s(null)}})()},[e,n]),o}function K(e,o){if(e.length===0)return"";const s=e.find(r=>{var t,n;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((n=r.customCardPreferences)!=null&&n.dataInputCardIds)});if(s)return s.id;if(o){const r=e.find(t=>t.id===o);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const u=t.split("__")[0],i=e.find(c=>c.tabTitle===u);return i?i.id:e[0].id}return o}}return e[0].id}const D=new Set;function X(e){return D.add(e),()=>{D.delete(e)}}function q(){D.forEach(e=>{e()})}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:o,...s}=e;return s};async function B(e,o,s,r){if(!o||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],n=r.getQueryData(t);if(n)return console.log("Using cached visual data for:",s),{data:n,fromCache:!0};console.log("Fetching visual data from network for:",s);const u=a.ue.loading("Loading visual...",{position:"top-center"});try{const i=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${o}`}});if(!i.ok)throw new Error("Failed to load visual");const c=await i.json();return r.setQueryData(t,c),a.ue.dismiss(u),{data:c,fromCache:!1}}catch(i){throw a.ue.dismiss(u),i}}function z(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Z(e,o){var n,u;const s=(e==null?void 0:e.frameObject)??((n=e==null?void 0:e.visual)==null?void 0:n.frameObject);if(!s)return!1;const r=z(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(u=r.cards)==null?void 0:u.find(i=>i.id===r.activeCardId);return t?(a.setupEditorWithCard({...o,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function ee(){const e=a.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),o=J(e);return{getUpdatedFrame:p.useCallback(()=>{var g;q();const{frame:r,card:t,isDevMode:n,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C}=a.useEditorStore.getState(),y=t.sql,I=(g=o==null?void 0:o.getState())==null?void 0:g.settings,U=a.buildSavedEditorCard(t,{isDevMode:n,cardSql:y,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C,remoteChartSettings:I,stripConfig:Y}),S=r.cards.map(b=>b.id===t.id?U:b);return{...r,cards:S,activeCardId:K(S,r.activeCardId)}},[o])}}function te(){const{authToken:e,tokenProps:o}=a.useSemaphorContext(),s=a.useQueryClient(),r=a.useAddFrameWithFreshSemanticExecutionPayload(),t=a.useSelectedVisual(),{selectVisual:n}=a.useManagementActions(),{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M,clearEditorContext:k}=a.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:L,setSelectedFrameId:T,clearSelectedFrameId:j,setIsDashboardPanelOpen:N}=a.useDashboardActions(),E=a.useDashboardStore(d=>d.selectedSheetId),R=a.useDashboardStore(d=>d.selectedFrameId),W=a.useDashboardStore(d=>d.dashboard),$=a.useDashboardStore(d=>d.filterValues),x=a.useDashboardStore(d=>d.inlineFilterValuesMap),w=a.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),H=p.useCallback(async d=>{try{n(d),j(),k();const{data:f,fromCache:v}=await B(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s);if(!Z(f,{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M,setIsDashboardEditing:V,setIsVisualEditing:L,dashboard:W,selectedSheetId:E,selectedFrameId:R,filterValues:$,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:v}}catch(f){return console.error("Error editing visual:",f),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,u,i,V,L,c,h,m,C,y,I,U,S,g,b,A,P,M,k,j,W,E,R,$,x]),Q=p.useCallback(async d=>{var v;const f=l=>(a.ue.error(l),{success:!1,error:l});try{if(n(d),!E)return f("No sheet selected. Please select a sheet first.");const{data:l,fromCache:G}=await B(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s),O=(l==null?void 0:l.frameObject)??((v=l==null?void 0:l.visual)==null?void 0:v.frameObject);if(!O)return f("Visual has no frame data");const F=z(O);if(!(F!=null&&F.cards)||F.cards.length===0)return f("Visual frame is malformed");const _={...a.cloneLinkedFrameWithSourceMapping(F),visualId:d.id};return await r(E,_,"end"),V(!0),T(_.id),N(!1),{success:!0,fromCache:G}}catch(l){return console.error("Error adding visual:",l),f(l instanceof Error?l.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,E,V,T,N,r]);return{visual:w.data,isLoading:w.isLoading,isError:w.isError,error:w.error,handleEditLibraryVisual:H,handleAddLibraryVisual:Q,getUpdatedFrame:ee().getUpdatedFrame,refetch:w.refetch}}exports.flushPendingEditorDrafts=q;exports.registerPendingEditorDraftFlusher=X;exports.useVisualUtils=te;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { H as
|
|
2
|
-
import { useState as
|
|
3
|
-
function
|
|
4
|
-
const [a, s] =
|
|
5
|
-
return
|
|
1
|
+
import { H as Y, d as X, J as Z, K as ee, M as te, N as re, O as se, Q as ae, u as b, T as oe, U as ne, y as v, V as ie, W as H, Y as ce } from "./index-D0iNspb-.js";
|
|
2
|
+
import { useState as Q, useEffect as de, useCallback as A } from "react";
|
|
3
|
+
function le(e) {
|
|
4
|
+
const [a, s] = Q(null), [r, t] = Q(null), o = Y();
|
|
5
|
+
return de(() => {
|
|
6
6
|
if (!e || e.trim() === "") {
|
|
7
7
|
s(null), t(null);
|
|
8
8
|
return;
|
|
@@ -39,7 +39,7 @@ function de(e) {
|
|
|
39
39
|
})();
|
|
40
40
|
}, [e, o]), a;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function ue(e, a) {
|
|
43
43
|
if (e.length === 0)
|
|
44
44
|
return "";
|
|
45
45
|
const s = e.find(
|
|
@@ -68,23 +68,23 @@ function le(e, a) {
|
|
|
68
68
|
return e[0].id;
|
|
69
69
|
}
|
|
70
70
|
const M = /* @__PURE__ */ new Set();
|
|
71
|
-
function
|
|
71
|
+
function Ee(e) {
|
|
72
72
|
return M.add(e), () => {
|
|
73
73
|
M.delete(e);
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function fe() {
|
|
77
77
|
M.forEach((e) => {
|
|
78
78
|
e();
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const he = (e) => {
|
|
82
82
|
if (!e || !("detailTableBackup" in e))
|
|
83
83
|
return e;
|
|
84
84
|
const { detailTableBackup: a, ...s } = e;
|
|
85
85
|
return s;
|
|
86
86
|
};
|
|
87
|
-
async function
|
|
87
|
+
async function z(e, a, s, r) {
|
|
88
88
|
if (!a || !s)
|
|
89
89
|
throw new Error("Missing auth token or visual ID");
|
|
90
90
|
const t = ["resource-by-id", "visual", s], o = r.getQueryData(t);
|
|
@@ -111,41 +111,41 @@ async function Q(e, a, s, r) {
|
|
|
111
111
|
throw v.dismiss(l), n;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function q(e) {
|
|
115
115
|
if (typeof e == "string")
|
|
116
116
|
return JSON.parse(e);
|
|
117
117
|
if (typeof e == "object")
|
|
118
118
|
return e;
|
|
119
119
|
throw new Error("Invalid frame object format");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function me(e, a) {
|
|
122
122
|
var o, l;
|
|
123
123
|
const s = (e == null ? void 0 : e.frameObject) ?? ((o = e == null ? void 0 : e.visual) == null ? void 0 : o.frameObject);
|
|
124
124
|
if (!s)
|
|
125
125
|
return !1;
|
|
126
|
-
const r =
|
|
126
|
+
const r = q(s);
|
|
127
127
|
if (!(r != null && r.cards) || r.cards.length === 0)
|
|
128
128
|
return !1;
|
|
129
129
|
const t = (l = r.cards) == null ? void 0 : l.find(
|
|
130
130
|
(n) => n.id === r.activeCardId
|
|
131
131
|
);
|
|
132
|
-
return t ? (
|
|
132
|
+
return t ? (ie({
|
|
133
133
|
...a,
|
|
134
134
|
frame: r,
|
|
135
135
|
card: t,
|
|
136
136
|
visualId: (e == null ? void 0 : e.id) || r.visualId
|
|
137
137
|
}), !0) : !1;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
const e =
|
|
139
|
+
function pe() {
|
|
140
|
+
const e = H(
|
|
141
141
|
(r) => {
|
|
142
142
|
var t;
|
|
143
143
|
return ((t = r.card.customCardPreferences) == null ? void 0 : t.url) || "";
|
|
144
144
|
}
|
|
145
|
-
), a =
|
|
145
|
+
), a = le(e);
|
|
146
146
|
return { getUpdatedFrame: A(() => {
|
|
147
147
|
var p;
|
|
148
|
-
|
|
148
|
+
fe();
|
|
149
149
|
const {
|
|
150
150
|
frame: r,
|
|
151
151
|
card: t,
|
|
@@ -156,73 +156,74 @@ function me() {
|
|
|
156
156
|
selectedDatabaseName: f,
|
|
157
157
|
selectedTableName: h,
|
|
158
158
|
selectedConnectionId: F
|
|
159
|
-
} =
|
|
159
|
+
} = H.getState(), C = t.sql, y = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ce(t, {
|
|
160
160
|
isDevMode: o,
|
|
161
|
-
cardSql:
|
|
161
|
+
cardSql: C,
|
|
162
162
|
isShowingVisual: l,
|
|
163
163
|
selectedSchemaName: n,
|
|
164
164
|
selectedDatamodelId: i,
|
|
165
165
|
selectedDatabaseName: f,
|
|
166
166
|
selectedTableName: h,
|
|
167
167
|
selectedConnectionId: F,
|
|
168
|
-
remoteChartSettings:
|
|
169
|
-
stripConfig:
|
|
168
|
+
remoteChartSettings: y,
|
|
169
|
+
stripConfig: he
|
|
170
170
|
}), m = r.cards.map(
|
|
171
171
|
(g) => g.id === t.id ? I : g
|
|
172
172
|
);
|
|
173
173
|
return {
|
|
174
174
|
...r,
|
|
175
175
|
cards: m,
|
|
176
|
-
activeCardId:
|
|
176
|
+
activeCardId: ue(m, r.activeCardId)
|
|
177
177
|
};
|
|
178
178
|
}, [a]) };
|
|
179
179
|
}
|
|
180
|
-
function
|
|
181
|
-
const { authToken: e, tokenProps: a } =
|
|
180
|
+
function we() {
|
|
181
|
+
const { authToken: e, tokenProps: a } = X(), s = Z(), r = ee(), t = te(), { selectVisual: o } = re(), {
|
|
182
182
|
setFrame: l,
|
|
183
183
|
setCard: n,
|
|
184
184
|
setIsDevMode: i,
|
|
185
185
|
initializeModeDrafts: f,
|
|
186
186
|
setActiveTabCardId: h,
|
|
187
187
|
updateDataSource: F,
|
|
188
|
-
setQueryResultColumns:
|
|
189
|
-
setSelectedConnectionId:
|
|
188
|
+
setQueryResultColumns: C,
|
|
189
|
+
setSelectedConnectionId: y,
|
|
190
190
|
setSelectedDatabaseName: I,
|
|
191
191
|
setSelectedSchemaName: m,
|
|
192
192
|
setSelectedTableName: p,
|
|
193
193
|
setSelectedDatamodelId: g,
|
|
194
194
|
setFilterValues: P,
|
|
195
195
|
setInlineFilterValuesMap: T,
|
|
196
|
-
setApplyFilters: D
|
|
197
|
-
|
|
196
|
+
setApplyFilters: D,
|
|
197
|
+
clearEditorContext: L
|
|
198
|
+
} = se(), {
|
|
198
199
|
setIsDashboardEditing: U,
|
|
199
|
-
setIsVisualEditing:
|
|
200
|
-
setSelectedFrameId:
|
|
201
|
-
clearSelectedFrameId:
|
|
202
|
-
setIsDashboardPanelOpen:
|
|
203
|
-
} =
|
|
200
|
+
setIsVisualEditing: N,
|
|
201
|
+
setSelectedFrameId: W,
|
|
202
|
+
clearSelectedFrameId: j,
|
|
203
|
+
setIsDashboardPanelOpen: k
|
|
204
|
+
} = ae(), S = b((c) => c.selectedSheetId), $ = b((c) => c.selectedFrameId), O = b((c) => c.dashboard), R = b((c) => c.filterValues), x = b(
|
|
204
205
|
(c) => c.inlineFilterValuesMap
|
|
205
|
-
), E =
|
|
206
|
+
), E = oe((t == null ? void 0 : t.id) || "", {
|
|
206
207
|
enabled: !!(t != null && t.id) && !!(e != null && e.accessToken)
|
|
207
|
-
}),
|
|
208
|
+
}), J = A(
|
|
208
209
|
async (c) => {
|
|
209
210
|
try {
|
|
210
|
-
o(c),
|
|
211
|
-
const { data: u, fromCache: V } = await
|
|
211
|
+
o(c), j(), L();
|
|
212
|
+
const { data: u, fromCache: V } = await z(
|
|
212
213
|
a.apiServiceUrl,
|
|
213
214
|
(e == null ? void 0 : e.accessToken) || "",
|
|
214
215
|
c.id,
|
|
215
216
|
s
|
|
216
217
|
);
|
|
217
|
-
if (!
|
|
218
|
+
if (!me(u, {
|
|
218
219
|
setFrame: l,
|
|
219
220
|
setCard: n,
|
|
220
221
|
setIsDevMode: i,
|
|
221
222
|
initializeModeDrafts: f,
|
|
222
223
|
setActiveTabCardId: h,
|
|
223
224
|
updateDataSource: F,
|
|
224
|
-
setQueryResultColumns:
|
|
225
|
-
setSelectedConnectionId:
|
|
225
|
+
setQueryResultColumns: C,
|
|
226
|
+
setSelectedConnectionId: y,
|
|
226
227
|
setSelectedDatabaseName: I,
|
|
227
228
|
setSelectedSchemaName: m,
|
|
228
229
|
setSelectedTableName: p,
|
|
@@ -231,12 +232,12 @@ function Ee() {
|
|
|
231
232
|
setInlineFilterValuesMap: T,
|
|
232
233
|
setApplyFilters: D,
|
|
233
234
|
setIsDashboardEditing: U,
|
|
234
|
-
setIsVisualEditing:
|
|
235
|
-
dashboard:
|
|
235
|
+
setIsVisualEditing: N,
|
|
236
|
+
dashboard: O,
|
|
236
237
|
selectedSheetId: S,
|
|
237
|
-
selectedFrameId:
|
|
238
|
-
filterValues:
|
|
239
|
-
inlineFilterValuesMap:
|
|
238
|
+
selectedFrameId: $,
|
|
239
|
+
filterValues: R,
|
|
240
|
+
inlineFilterValuesMap: x
|
|
240
241
|
}))
|
|
241
242
|
throw new Error("Failed to setup editor with visual data");
|
|
242
243
|
return { success: !0, fromCache: V };
|
|
@@ -252,13 +253,13 @@ function Ee() {
|
|
|
252
253
|
l,
|
|
253
254
|
n,
|
|
254
255
|
U,
|
|
255
|
-
|
|
256
|
+
N,
|
|
256
257
|
i,
|
|
257
258
|
f,
|
|
258
259
|
h,
|
|
259
260
|
F,
|
|
260
|
-
y,
|
|
261
261
|
C,
|
|
262
|
+
y,
|
|
262
263
|
I,
|
|
263
264
|
m,
|
|
264
265
|
p,
|
|
@@ -266,21 +267,22 @@ function Ee() {
|
|
|
266
267
|
P,
|
|
267
268
|
T,
|
|
268
269
|
D,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
S,
|
|
272
|
-
k,
|
|
270
|
+
L,
|
|
271
|
+
j,
|
|
273
272
|
O,
|
|
274
|
-
|
|
273
|
+
S,
|
|
274
|
+
$,
|
|
275
|
+
R,
|
|
276
|
+
x
|
|
275
277
|
]
|
|
276
|
-
),
|
|
278
|
+
), K = A(
|
|
277
279
|
async (c) => {
|
|
278
280
|
var V;
|
|
279
281
|
const u = (d) => (v.error(d), { success: !1, error: d });
|
|
280
282
|
try {
|
|
281
283
|
if (o(c), !S)
|
|
282
284
|
return u("No sheet selected. Please select a sheet first.");
|
|
283
|
-
const { data: d, fromCache:
|
|
285
|
+
const { data: d, fromCache: G } = await z(
|
|
284
286
|
a.apiServiceUrl,
|
|
285
287
|
(e == null ? void 0 : e.accessToken) || "",
|
|
286
288
|
c.id,
|
|
@@ -288,19 +290,19 @@ function Ee() {
|
|
|
288
290
|
), _ = (d == null ? void 0 : d.frameObject) ?? ((V = d == null ? void 0 : d.visual) == null ? void 0 : V.frameObject);
|
|
289
291
|
if (!_)
|
|
290
292
|
return u("Visual has no frame data");
|
|
291
|
-
const w =
|
|
293
|
+
const w = q(_);
|
|
292
294
|
if (!(w != null && w.cards) || w.cards.length === 0)
|
|
293
295
|
return u("Visual frame is malformed");
|
|
294
|
-
const
|
|
295
|
-
...
|
|
296
|
+
const B = {
|
|
297
|
+
...ne(w),
|
|
296
298
|
visualId: c.id
|
|
297
299
|
// Link this frame to the library visual
|
|
298
300
|
};
|
|
299
301
|
return await r(
|
|
300
302
|
S,
|
|
301
|
-
|
|
303
|
+
B,
|
|
302
304
|
"end"
|
|
303
|
-
), U(!0),
|
|
305
|
+
), U(!0), W(B.id), k(!1), { success: !0, fromCache: G };
|
|
304
306
|
} catch (d) {
|
|
305
307
|
return console.error("Error adding visual:", d), u(
|
|
306
308
|
d instanceof Error ? d.message : "Failed to add visual to dashboard"
|
|
@@ -314,8 +316,8 @@ function Ee() {
|
|
|
314
316
|
o,
|
|
315
317
|
S,
|
|
316
318
|
U,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
W,
|
|
320
|
+
k,
|
|
319
321
|
r
|
|
320
322
|
]
|
|
321
323
|
);
|
|
@@ -324,14 +326,14 @@ function Ee() {
|
|
|
324
326
|
isLoading: E.isLoading,
|
|
325
327
|
isError: E.isError,
|
|
326
328
|
error: E.error,
|
|
327
|
-
handleEditLibraryVisual:
|
|
328
|
-
handleAddLibraryVisual:
|
|
329
|
-
getUpdatedFrame:
|
|
329
|
+
handleEditLibraryVisual: J,
|
|
330
|
+
handleAddLibraryVisual: K,
|
|
331
|
+
getUpdatedFrame: pe().getUpdatedFrame,
|
|
330
332
|
refetch: E.refetch
|
|
331
333
|
};
|
|
332
334
|
}
|
|
333
335
|
export {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
fe as f,
|
|
337
|
+
Ee as r,
|
|
338
|
+
we as u
|
|
337
339
|
};
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index--CoasbAE.js"),e=require("../types/index.cjs");exports.Dashboard=r.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-Ze8VskG1.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-DRLPzp1P.js"),t=require("react/jsx-runtime"),u=require("react"),O=require("./chunks/resource-management-panel-CcDAn86l.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const C=require("./chunks/dashboard-filter-controls-button-D0AsV28-.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(u);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=u.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),m=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var h;return(h=i==null?void 0:i.cards)==null?void 0:h.find(f=>(f==null?void 0:f.id)===s)});return{card:m,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W(s,r,n,o){u.useEffect(()=>{s&&!n&&r&&o(e.cloneDeep(r))},[s,n,r,o])}function H({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:m,className:a,icon:i,showNone:h=!1}){const f=R.useRef(null),[D,A]=R.useState(!1),[b,j]=R.useState("100%"),y=h?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var x;return l?"Loading...":c?"Error":n?(x=r==null?void 0:r.find(S=>S.id===n))==null?void 0:x.name:`Select ${s}`}function T(x,S){o(S),A(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:A,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:I()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:m,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(x=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:x.name,onSelect:S=>T(S,x.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===x.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:x.name,children:x.name})]})},x.id))})]})]})})]})}function $({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=u.useState(!1),l=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function G(s,r){u.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function K(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function Y({alertId:s,onBack:r}){var x,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:m}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,h]=u.useState([]),[f,D]=u.useState([]),[A,b]=u.useState(null),j=u.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=A&&N.some(B=>B.id===A)?A:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,A,o]),y=u.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??A;if(!p||!g||!s||!v){h([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();h(Array.isArray(N.attempts)?N.attempts:[])}else h([])}catch{h([])}},[s,n,A,o]),I=u.useCallback(async()=>{await m();const d=await j();await y(d)},[y,j,m]);u.useEffect(()=>{j().catch(()=>{})},[j]),u.useEffect(()=>{y().catch(()=>{})},[y]);const T=u.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:K(a)}),((x=a.alertState)==null?void 0:x.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void I(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===A?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function X(){var c,m;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((m=r.data)==null?void 0:m.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",h=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(h==null?void 0:h.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=C.AdvancedModeToggle;exports.DashboardControlsSettings=C.DashboardControlsSettings;exports.DashboardFilterControlsButton=C.DashboardFilterControlsButton;exports.ExportNotificationItem=C.ExportNotificationItem;exports.ExportNotificationList=C.ExportNotificationList;exports.NotificationBell=C.NotificationBell;exports.UnsavedChangesAlert=C.UnsavedChangesAlert;exports.VisualEditingControls=C.VisualEditingControls;exports.useExportPolling=C.useExportPolling;exports.useExportRecovery=C.useExportRecovery;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=Y;exports.Combobox=H;exports.ScheduleDashboard=$;exports.TenantQuotaPage=X;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=G;exports.usePristineSnapshotInitializer=W;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index--CoasbAE.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-C6FUhXQy.js"),t=require("react/jsx-runtime"),u=require("react"),O=require("./chunks/resource-management-panel-Cf4FTR33.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const C=require("./chunks/dashboard-filter-controls-button-dYWccDmw.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(u);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=u.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),m=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var h;return(h=i==null?void 0:i.cards)==null?void 0:h.find(f=>(f==null?void 0:f.id)===s)});return{card:m,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W(s,r,n,o){u.useEffect(()=>{s&&!n&&r&&o(e.cloneDeep(r))},[s,n,r,o])}function H({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:m,className:a,icon:i,showNone:h=!1}){const f=R.useRef(null),[S,A]=R.useState(!1),[b,j]=R.useState("100%"),y=h?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function w(){var x;return l?"Loading...":c?"Error":n?(x=r==null?void 0:r.find(D=>D.id===n))==null?void 0:x.name:`Select ${s}`}function T(x,D){o(D),A(!1)}return t.jsxs(e.Popover,{open:S,onOpenChange:A,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":S,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:w()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:m,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(x=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:x.name,onSelect:D=>T(D,x.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===x.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:x.name,children:x.name})]})},x.id))})]})]})})]})}function $({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=u.useState(!1),l=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function G(s,r){u.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function K(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function Y({alertId:s,onBack:r}){var x,D,I,F;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:m}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,h]=u.useState([]),[f,S]=u.useState([]),[A,b]=u.useState(null),j=u.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=A&&N.some(B=>B.id===A)?A:((g=N[0])==null?void 0:g.id)??null;return S(N),b(k),k}S([]),b(null)}catch{return S([]),b(null),null}return null},[s,n,A,o]),y=u.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??A;if(!p||!g||!s||!v){h([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();h(Array.isArray(N.attempts)?N.attempts:[])}else h([])}catch{h([])}},[s,n,A,o]),w=u.useCallback(async()=>{await m();const d=await j();await y(d)},[y,j,m]);u.useEffect(()=>{j().catch(()=>{})},[j]),u.useEffect(()=>{y().catch(()=>{})},[y]);const T=u.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:K(a)}),((x=a.alertState)==null?void 0:x.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void w(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((D=a.alertState)==null?void 0:D.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((I=a.alertState)==null?void 0:I.lastTriggeredAt)]})]})]}),((F=a.deliveryConfig)==null?void 0:F.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===A?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function X(){var c,m;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((m=r.data)==null?void 0:m.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",h=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(h==null?void 0:h.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=C.AdvancedModeToggle;exports.DashboardControlsSettings=C.DashboardControlsSettings;exports.DashboardFilterControlsButton=C.DashboardFilterControlsButton;exports.ExportNotificationItem=C.ExportNotificationItem;exports.ExportNotificationList=C.ExportNotificationList;exports.NotificationBell=C.NotificationBell;exports.UnsavedChangesAlert=C.UnsavedChangesAlert;exports.VisualEditingControls=C.VisualEditingControls;exports.useExportPolling=C.useExportPolling;exports.useExportRecovery=C.useExportRecovery;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=Y;exports.Combobox=H;exports.ScheduleDashboard=$;exports.TenantQuotaPage=X;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=G;exports.usePristineSnapshotInitializer=W;
|