react-semaphor 0.1.439 → 0.1.440
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/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +1 -1
- package/dist/chunks/{code-editor-25d16KDV.js → code-editor-CIWiSltV.js} +3182 -3152
- package/dist/chunks/{code-editor-BSENCZwR.js → code-editor-M7HTUhdF.js} +14 -14
- package/dist/chunks/{dashboard-DXTiQI-G.js → dashboard--bQrQeiz.js} +26285 -26106
- package/dist/chunks/{dashboard-DuS8HC11.js → dashboard-C-eTAAKs.js} +212 -212
- package/dist/chunks/{dashboard-briefing-launcher-FFtLgrV4.js → dashboard-briefing-launcher-dgTjPWHX.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DD8lR1Au.js → dashboard-briefing-launcher-xulAb1Oz.js} +108 -108
- package/dist/chunks/{dashboard-controls-dlVDuUIE.js → dashboard-controls-CWu1wt6_.js} +79 -79
- package/dist/chunks/{dashboard-controls-Jd2pIzDA.js → dashboard-controls-D8BDZ5_q.js} +1 -1
- package/dist/chunks/{dashboard-json-BV47cQM5.js → dashboard-json-Bpm-ePrD.js} +1 -1
- package/dist/chunks/{dashboard-json--vVimEkU.js → dashboard-json-ZgLCrrSW.js} +2 -2
- package/dist/chunks/edit-dashboard-visual-BCMupXbq.js +182 -0
- package/dist/chunks/{edit-dashboard-visual-BJ2q0svk.js → edit-dashboard-visual-DEtVA2re.js} +6987 -6912
- package/dist/chunks/{report-preferences-dialog-Dpu8q4pi.js → report-preferences-dialog-Bjj_tIgL.js} +2 -2
- package/dist/chunks/{report-preferences-dialog-Oe6nmu2r.js → report-preferences-dialog-Ju8DjgyW.js} +1 -1
- package/dist/chunks/use-create-flow-overlay-state-B6a3gmF0.js +1890 -0
- package/dist/chunks/use-create-flow-overlay-state-wcIRGLSM.js +11 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +66 -66
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -6
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/edit-dashboard-visual-BpPTfU9y.js +0 -182
- package/dist/chunks/use-create-flow-overlay-state-CqKpuL7v.js +0 -1941
- package/dist/chunks/use-create-flow-overlay-state-CsWhd5aC.js +0 -11
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";const v=require("react"),s=require("./code-editor-M7HTUhdF.js"),f=require("./dashboard-C-eTAAKs.js"),e=require("react/jsx-runtime"),ee=require("./index-jSrCwPQz.js");require("./analyze-result-contract-BswhsmWT.js");require("../value-format-preferences/index.cjs");const Se=require("./save-Xdc4pnys.js"),ge=require("./search-Dcud9ajy.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 je=ee.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"}]]);/**
|
|
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 ke=ee.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"}]]);function De(r){const[a,i]=v.useState(null),[o,d]=v.useState(null),u=f.useEnsureReactGlobals();return v.useEffect(()=>{if(!r||r.trim()===""){i(null),d(null);return}if(!u)return;(async()=>{try{if(!r.startsWith("http://")&&!r.startsWith("https://"))throw new Error(`Invalid URL format: ${r}`);try{new URL(r)}catch{throw new Error(`Invalid URL: ${r}`)}const p=`${r.endsWith("/")?r:`${r}/`}index.js`;try{if(!(await fetch(p,{method:"HEAD"})).ok)throw new Error(`Module not found at ${p}`)}catch{}const C=await import(p);if(typeof C.useChartStore!="function")throw new Error("useChartStore is not a function");i(()=>C.useChartStore),d(null)}catch(x){const p=x instanceof Error?x.message:"Unknown error";console.error("Failed to load remote chart store:",p),d(p),i(null)}})()},[r,u]),a}function Fe(r,a){if(r.length===0)return"";const i=r.find(o=>{var d,u;return((d=o.customCardPreferences)==null?void 0:d.visualType)==="multiple"||!!((u=o.customCardPreferences)!=null&&u.dataInputCardIds)});if(i)return i.id;if(a){const o=r.find(d=>d.id===a);if(o){const d=o.tabTitle;if(d=="All__Header")return r[0].id;if(d&&d.endsWith("__Header")){const m=d.split("__")[0],x=r.find(p=>p.tabTitle===m);return x?x.id:r[0].id}return a}}return r[0].id}const Ve=r=>{if(!r||!("detailTableBackup"in r))return r;const{detailTableBackup:a,...i}=r;return i};async function be(r,a,i,o,d="Opening library visual..."){if(!a||!i)throw new Error("Missing auth token or visual ID");const u=["resource-by-id","visual",i],m=o.getQueryData(u);if(m)return console.log("Using cached visual data for:",i),{data:m,fromCache:!0};console.log("Fetching visual data from network for:",i);const x=f.ue.loading(d,{position:"top-center"});try{const p=await fetch(`${r}/management/v1/visuals/${i}`,{headers:{Authorization:`Bearer ${a}`}});if(!p.ok)throw new Error("Failed to load visual");const C=await p.json();return o.setQueryData(u,C),f.ue.dismiss(x),{data:C,fromCache:!1}}catch(p){throw f.ue.dismiss(x),p}}function Ne(r){if(typeof r=="string")return JSON.parse(r);if(typeof r=="object")return r;throw new Error("Invalid frame object format")}function Ie(r,a){var u,m;const i=(r==null?void 0:r.frameObject)??((u=r==null?void 0:r.visual)==null?void 0:u.frameObject);if(!i)return!1;const o=Ne(i);if(!(o!=null&&o.cards)||o.cards.length===0)return!1;const d=(m=o.cards)==null?void 0:m.find(x=>x.id===o.activeCardId);return d?(f.setupEditorWithCard({...a,frame:o,card:d,visualId:(r==null?void 0:r.id)||o.visualId}),!0):!1}function Te(){const r=s.useEditorStore(o=>{var d;return((d=o.card.customCardPreferences)==null?void 0:d.url)||""}),a=De(r);return{getUpdatedFrame:v.useCallback(()=>{var I;f.flushPendingEditorDrafts();const{frame:o,card:d,isDevMode:u,isShowingVisual:m,selectedSchemaName:x,selectedDatamodelId:p,selectedDatabaseName:C,selectedTableName:y,selectedConnectionId:g}=s.useEditorStore.getState(),S=d.sql,w=(I=a==null?void 0:a.getState())==null?void 0:I.settings,k=s.buildSavedEditorCard(d,{isDevMode:u,cardSql:S,isShowingVisual:m,selectedSchemaName:x,selectedDatamodelId:p,selectedDatabaseName:C,selectedTableName:y,selectedConnectionId:g,remoteChartSettings:w,stripConfig:Ve}),E=o.cards.map(U=>U.id===d.id?k:U);return{...o,cards:E,activeCardId:Fe(E,o.activeCardId)}},[a])}}function ae(){const{authToken:r,tokenProps:a}=f.useSemaphorContext(),i=f.useQueryClient(),o=f.useAddFrameWithFreshSemanticExecutionPayload(),d=f.useSelectedVisual(),{selectVisual:u}=f.useManagementActions(),{setFrame:m,setCard:x,setIsDevMode:p,initializeModeDrafts:C,setActiveTabCardId:y,updateDataSource:g,setQueryResultColumns:S,setSelectedConnectionId:w,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:I,setSelectedDatamodelId:U,setFilterValues:Y,setInlineFilterValuesMap:H,setApplyFilters:K,clearEditorContext:J}=s.useEditorActions(),{setIsDashboardEditing:q,setIsVisualEditing:n,setSelectedFrameId:D,clearSelectedFrameId:T}=s.useDashboardActions(),M=s.useDashboardStore(A=>A.selectedSheetId),Q=s.useDashboardStore(A=>A.selectedFrameId),W=s.useDashboardStore(A=>A.dashboard),G=s.useDashboardStore(A=>A.filterValues),_=s.useDashboardStore(A=>A.inlineFilterValuesMap),z=f.useVisualById((d==null?void 0:d.id)||"",{enabled:!!(d!=null&&d.id)&&!!(r!=null&&r.accessToken)}),$=v.useCallback(async A=>{try{u(A),T(),J();const{data:F,fromCache:P}=await be(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,i,"Opening library visual...");if(!Ie(F,{setFrame:m,setCard:x,setIsDevMode:p,initializeModeDrafts:C,setActiveTabCardId:y,updateDataSource:g,setQueryResultColumns:S,setSelectedConnectionId:w,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:I,setSelectedDatamodelId:U,setFilterValues:Y,setInlineFilterValuesMap:H,setApplyFilters:K,setIsDashboardEditing:q,setIsVisualEditing:n,dashboard:W,selectedSheetId:M,selectedFrameId:Q,filterValues:G,inlineFilterValuesMap:_}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:P}}catch(F){return console.error("Error editing visual:",F),{success:!1,error:"Failed to load visual for editing"}}},[r==null?void 0:r.accessToken,a.apiServiceUrl,i,u,m,x,q,n,p,C,y,g,S,w,k,E,I,U,Y,H,K,J,T,W,M,Q,G,_]),ne=v.useCallback(async A=>{var P;const F=B=>(f.ue.error(B),{success:!1,error:B});try{if(u(A),!M)return F("No sheet selected. Please select a sheet first.");const{data:B,fromCache:oe}=await be(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,i,"Adding visual to dashboard..."),re=(B==null?void 0:B.frameObject)??((P=B==null?void 0:B.visual)==null?void 0:P.frameObject);if(!re)return F("Visual has no frame data");const R=Ne(re);if(!(R!=null&&R.cards)||R.cards.length===0)return F("Visual frame is malformed");const te={...f.cloneLinkedFrameWithSourceMapping(R),visualId:A.id};return await o(M,te,"end"),q(!0),D(te.id),{success:!0,fromCache:oe}}catch(B){return console.error("Error adding visual:",B),F(B instanceof Error?B.message:"Failed to add visual to dashboard")}},[r==null?void 0:r.accessToken,a.apiServiceUrl,i,u,M,q,D,o]);return{visual:z.data,isLoading:z.isLoading,isError:z.isError,error:z.error,handleEditLibraryVisual:$,handleAddLibraryVisual:ne,getUpdatedFrame:Te().getUpdatedFrame,refetch:z.refetch}}function Le(){const r=s.useEditorStore(m=>m.card.dataSource),{setSelectedConnectionId:a,setSelectedDatabaseName:i,setSelectedSchemaName:o,setSelectedTableName:d,setSelectedDatamodelId:u}=s.useEditorActions();v.useEffect(()=>{var w;if(!r)return;const{tableName:m,schemaName:x,databaseName:p,connectionId:C}=f.extractTableMetadata(r),y=(w=r.selectedEntities)==null?void 0:w[0],S=(y==null?void 0:y.type)==="model"&&"id"in y?y.id:"";a(C||""),i(p||""),o(x||""),d(m||""),u(S)},[r,a,i,o,d,u])}function Ae({type:r,isLinked:a,className:i,showLabel:o=!1,showLocal:d=!1}){const u=s.useDashboardStore(E=>E.selectedFrameId),m=f.useManagementStore(E=>E.selectedVisual),x=s.useEditorStore(E=>E.frame);let p;if(r)p=r;else if(a!==void 0)p=a?"linked":"library";else if(!!!(x!=null&&x.visualId||m!=null&&m.id)&&u)p="local";else if(m&&!u)p="library";else if(x!=null&&x.visualId&&u)p="linked";else if(m!=null&&m.id&&u)p="library";else return null;if(p==="local"&&!d)return null;const C={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"},y={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."},g={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"},S={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(ke,{className:"h-3.5 w-3.5"}),library:e.jsx(je,{className:"h-3.5 w-3.5"})},k={local:"Local",linked:"Linked",library:"Library"};return e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{delayDuration:300,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(f.Badge,{variant:"outline",className:s.cn("cursor-help select-none transition-all",C[p],i),children:[w[p],o&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:k[p]})]})}),e.jsxs(s.TooltipContent,{side:"bottom",className:s.cn("max-w-xs",g[p]),children:[e.jsx(s.TooltipArrow,{className:S[p]}),e.jsx("p",{children:y[p]})]})]})})}function _e(r,a){return{...r,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?r.customCardPreferences:void 0,visualizationMode:"builtin",type:a?r.type:"bar"}}function ue(r){const a=s.getDynamicFrameSaveIssue(r);return a?(f.ue.error(a),!1):!0}function Be({className:r,variant:a="outline"}){const i=s.useEditorStore(u=>u.onSave),{getUpdatedFrame:o}=ae();function d(){const u=o();ue(u)&&(i==null||i(u))}return e.jsxs(s.Button,{onClick:d,className:r,size:"xs",variant:a,children:[e.jsx(s.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function qe({className:r,variant:a="default"}){const i=f.useQueryClient(),[o,d]=v.useState(!1),{setIsVisualEditing:u}=s.useDashboardActions(),{getUpdatedFrame:m}=ae(),x=f.useSelectedVisual(),p=s.useEditorStore(g=>g.frame),C=f.useUpdateVisualMutation(),y=()=>{const g=m();if(!ue(g))return;const S=(p==null?void 0:p.visualId)||(x==null?void 0:x.id);if(!S){f.ue.error("No visual to save");return}d(!0),C.mutate({visualId:S,data:{frameObject:g}},{onSuccess:()=>{d(!1),f.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{d(!1),f.ue.error("Failed to update visual")}})};return e.jsx(s.Button,{onClick:y,className:r,size:"xs",variant:a,children:o?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(Se.Save,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Me({className:r}){const a=f.useQueryClient(),[i,o]=v.useState(!1),d=f.useSelectedVisual(),u=s.useEditorStore(k=>k.frame),m=s.useDashboardStore(k=>k.selectedSheetId),x=s.useDashboardStore(k=>k.dashboard),{updateFrame:p,setIsVisualEditing:C}=s.useDashboardActions(),{getUpdatedFrame:y}=ae(),g=f.useUpdateVisualMutation(),S=f.useResolveExistingFrameSemanticExecutionPayload(),w=async()=>{if(!m){f.ue.error("No sheet selected");return}const k=(u==null?void 0:u.visualId)||(d==null?void 0:d.id);if(!k){f.ue.error("No visual to update");return}o(!0);try{const E=y();if(!ue(E)){o(!1);return}const I={...E,visualId:k},U=s.findDashboardFrameById(x,I.id),Y=await S(I,{previousFrame:U});await g.mutateAsync({visualId:k,data:{frameObject:E}}),p(m,I,{semanticExecutionPayload:Y}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",k]}),f.ue.success("Saved to library and applied locally"),setTimeout(()=>{C(!1)},300)}catch(E){console.error("Failed to save and apply:",E),f.ue.error(E instanceof Error?E.message:"Failed to save and apply changes")}finally{o(!1)}};return e.jsx(s.Button,{onClick:w,className:r,size:"xs",variant:"default",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Se.Save,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Oe({className:r}){const{setTempQueryData:a,setSqlGen:i}=s.useEditorActions(),o=f.useQueryClient(),d=s.useEditorStore(g=>g.tempQueryData),u=s.useEditorStore(g=>g.onClose),m=s.useEditorStore(g=>g.card),x=f.useEffectiveEditorCardType(),p=v.useMemo(()=>x!==m.type?{...m,type:x}:m,[m,x]),{queryKey:C}=f.useEditorCardQuery(p);function y(){if(d){const{queryKey:g,queryData:S}=d;g&&S&&o.setQueryData(g,S)}i({}),u==null||u()}return e.jsxs(s.Button,{onClick:y,className:r,size:"xs",variant:"outline",children:[e.jsx(ee.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Ue({label:r="Clear",variant:a="secondary",className:i}={}){const{setTempQueryData:o}=s.useEditorActions(),d=f.useQueryClient(),u=s.useEditorStore(q=>q.tempQueryData),m=s.useEditorStore(q=>q.card),x=f.useEffectiveEditorCardType(),p=v.useMemo(()=>x!==m.type?{...m,type:x}:m,[m,x]),{queryKey:C}=f.useEditorCardQuery(p),{setCardSql:y,setSqlGen:g,setCardPython:S,setCardCustomCfg:w,setCardPreferences:k,clearQueryConfig:E,setCardConfig:I,setCardType:U,setFrame:Y,setCard:H,setActiveTabCardId:K}=s.useEditorActions();function J(){var W,G,_,z;const q=d.getQueryData(C);u!=null&&u.queryData||o({queryKey:C,queryData:q}),d.setQueryData(C,null),d.removeQueries({queryKey:C,exact:!0}),y(""),g({}),E(),I(void 0),S(""),w(""),k({});const n=s.useEditorStore.getState().frame,D=s.useEditorStore.getState().card,T=f.findCustomVisualConfigCard(n,D),M=((W=T==null?void 0:T.customCardPreferences)==null?void 0:W.visualType)==="multiple"||!!((G=T==null?void 0:T.customCardPreferences)!=null&&G.dataInputCardIds)||(((_=T==null?void 0:T.customCardPreferences)==null?void 0:_.minInputs)||0)>1||(((z=T==null?void 0:T.customCardPreferences)==null?void 0:z.maxInputs)||0)>1,Q=_e(D,M);Y({...n,cards:n.cards.map($=>$.id===Q.id?Q:$)}),K(Q.id),H(Q),M||U("bar")}return e.jsxs(s.Button,{onClick:J,className:i,size:"xs",variant:a,children:[e.jsx(ee.X,{className:"h-3.5 w-3.5"}),r]})}function Ee(r){const{control:a,onChange:i}=r;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:o=>i(o.target.value)})]})}function ze(r){const{currentStep:a,labels:i}=r;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((o,d)=>{const u=d+1,m=u===a,x=u<a;return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:s.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",m?"border-foreground bg-foreground text-background":x?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),e.jsx("span",{className:s.cn("text-[12px]",m?"font-medium text-foreground":"text-muted-foreground"),children:o})]}),d<i.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},o)})})})}function se(r){const{secondary:a,tertiary:i,primary:o}=r;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,o]})}function Re(r){const{control:a,scope:i,detail:o}=r;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-control border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(f.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:[s.getFriendlyTypeOption(a.type).label," ·"," ",s.getControlOptionPreview(a)," ·"," ",s.getPlacementLabel(i,a.placement)]}),o?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:o}):null]})]})}function ye(r){const{control:a,defaultValue:i,availableFieldChoices:o,availableMetricChoices:d,previewControlDefinitions:u,previewControlValues:m,onControlChange:x,onLabelChange:p,onDefaultValueChange:C,onBack:y,onNext:g,nextDisabled:S}=r;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ee,{control:a,onChange:p}),e.jsx(f.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:o,availableMetricChoices:d,previewControlDefinitions:u,previewControlValues:m,controlLifecycle:"create",onChange:x}),e.jsx(f.ControlDefaultValueEditor,{control:a,value:i,onChange:C,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:m}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:g,disabled:S,children:"Next"})})]})}const Qe=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function Ce(r){const{text:a,ariaLabel:i}=r,[o,d]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(a),d(!0),setTimeout(()=>d(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-control 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:o?"Copied":"Click to copy"})]})}function ve(r){const{control:a,scope:i,createdReference:o,explorerContent:d,sqlDescription:u,summaryDetail:m,onBack:x,onCancel:p,onDone:C}=r,y=Qe.has(a.type),g=o.match(/\[\[param\.(.+?)\]\]/),S=g?`{{ param('${g[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{control:a,scope:i,detail:m}),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-control border border-border/60",children:[y?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:d})]}):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(Ce,{text:o,ariaLabel:"Copy SQL control reference"}),S?e.jsx(Ce,{text:S,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(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:x,children:"Back"}),tertiary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:p,children:"Cancel"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:C,children:"Done"})})]})}function Pe(r){const a=s.createBlankControl(r.scope,r.existingControls,r.reservedIds),i=r.type===a.type?{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}:{...s.applyControlTypeChange({controls:[{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}],controlId:a.id,nextType:r.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[r.type]};return{step:2,control:i,defaultValue:s.getDefaultValueForType(i,void 0)}}function $e({scope:r,controls:a,reservedControlIds:i,defaultValues:o,onChange:d,emptyMessage:u,initialCreateFlow:m=!1,usageByControlId:x,availableFieldChoices:p,availableMetricChoices:C,structuralParticipants:y,structuralParticipantIdsByControlId:g,card:S,allowedControlTypes:w,onCreateFlowActiveChange:k,onCreateFlowComplete:E}){const I=v.useMemo(()=>new Set(i||[]),[i]),U=s.getPlacementOptionsForScope(r),Y=s.getDefaultPlacement(r),[H,K]=v.useState(null),[J,q]=v.useState(null),[n,D]=v.useState(()=>m?{step:1,control:s.createBlankControl(r,a,Array.from(I))}:null),T=v.useRef({}),M=v.useRef(void 0),Q=v.useRef(m),W=v.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:r,card:S});if(!w)return t;const c=new Set(w);return t.filter(l=>c.has(l.value))},[w,S,r]),G=v.useCallback(t=>{const c=s.getFriendlyControlTypeOptions({scope:r,card:S,includeType:w?void 0:t});if(!w)return c;const l=new Set(w);return c.filter(h=>l.has(h.value))},[w,S,r]),_=v.useCallback(t=>r==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[r]),z=v.useMemo(()=>n?s.getEligibleParticipantsForStructuralControl(y||[],n.control.type):[],[n,y]),$=v.useMemo(()=>{if(!n)return{fields:p||[],metrics:C||[]};if(!_(n.control.type))return{fields:p||[],metrics:C||[]};const t=n.selectedCardIds||[],c=s.getCompatibleStructuralChoiceCatalog({controlType:n.control.type,participants:y||[],selectedCardIds:t});return{fields:n.control.type==="field_selector"?c.choices.map(l=>({option:l,target:c.fieldTargetMap[l.value]})):[],metrics:n.control.type==="metric_selector"?c.choices.map(l=>({option:l,target:c.metricTargetMap[l.value]})):[]}},[p,C,n,_,y]);v.useEffect(()=>{k==null||k(!!n)},[n,k]),v.useEffect(()=>{const t=m&&!Q.current;Q.current=m,t&&(D({step:1,control:s.createBlankControl(r,a,Array.from(I))}),q(null),K(null))},[a,m,I,r]);const ne=t=>{if(!_(t.type))return{fields:p||[],metrics:C||[]};const c=(g==null?void 0:g[t.id])||[];if(c.length===0)return{fields:p||[],metrics:C||[]};const l=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:y||[],selectedCardIds:c});return{fields:t.type==="field_selector"?l.choices.map(h=>({option:h,target:l.fieldTargetMap[h.value]})):[],metrics:t.type==="metric_selector"?l.choices.map(h=>({option:h,target:l.metricTargetMap[h.value]})):[]}},A=t=>{if(!_(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const c=(g==null?void 0:g[t.control.id])||[],l=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:y||[],selectedCardIds:t.nextSelectedCardIds}),h=s.reconcileStructuralControlChoices({control:t.control,choices:l.choices}),j=Object.fromEntries(c.filter(N=>!t.nextSelectedCardIds.includes(N)).map(N=>[N,void 0]));return t.nextSelectedCardIds.length>0&&h.source.kind==="manual"&&h.source.options.length>0&&Object.assign(j,s.buildStructuralControlBindingsForParticipants({control:h,participants:y||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:h,cardBindingsById:j}},F=v.useCallback((t,c=o,l={type:"update"})=>{const h=t.map(j=>(s.resolveAuthoringControlDefaultValue({control:j,defaultValues:c}),s.syncSqlQueryControlExecutionRequirement(j)));d(h,c,l)},[o,d]),P=(t,c)=>{const l=a.find(L=>L.id===t);let h=a.map(L=>L.id!==t?L:c(L));const j=h.find(L=>L.id===t);let N,b;if(j&&r==="dashboard"&&(j.type==="field_selector"||j.type==="metric_selector")){const L=(g==null?void 0:g[j.id])||[],Z=A({control:j,nextSelectedCardIds:L});h=h.map(X=>X.id===t?Z.nextControl:X),N=Z.cardBindingsById,b=[j.id]}else if(l&&r==="dashboard"&&(l.type==="field_selector"||l.type==="metric_selector")){const L=(g==null?void 0:g[l.id])||[];N=Object.fromEntries(L.map(Z=>[Z,void 0])),b=[l.id]}const V=h.find(L=>L.id===t);let O=o;if(l&&V){const L=s.resolveAuthoringControlDefaultValue({control:l,defaultValues:o});l.source.kind==="manual"&&V.source.kind==="sql_query"&&(T.current[t]=L);const Z=L===void 0&&l.source.kind==="sql_query"&&V.source.kind==="manual"?T.current[t]:L,X=s.getNextEditedControlDefaultValue({previousControl:l,nextControl:V,currentDefaultValue:Z});V.source.kind==="manual"&&(T.current[t]=X),o&&(O={...o},X===void 0?delete O[t]:O[t]=X),h=h.map(he=>he.id===t?{...V,defaultValue:X}:he)}F(h,O,{type:"update",cardBindingsById:N,affectedBindingControlIds:b})},B=(t,c)=>{if(!c.trim())return;const l=f.normalizeDashboardInputVariableName(c);if(l===t||I.has(l)||a.some(N=>N.id===l&&N.id!==t))return;const h=a.map(N=>N.id===t?{...N,id:l}:N);if(!o){F(h,void 0,{type:"rename",oldId:t,newId:l});return}const j={...o};Object.prototype.hasOwnProperty.call(j,t)&&(j[l]=j[t],delete j[t]),F(h,j,{type:"rename",oldId:t,newId:l})},oe=t=>{const c=a.filter(h=>h.id!==t);if(!o){F(c,void 0,{type:"remove",controlId:t});return}const l={...o};delete l[t],F(c,l,{type:"remove",controlId:t})},re=v.useCallback(()=>{M.current=void 0,D({step:1,control:s.createBlankControl(r,a,Array.from(I))}),q(null),K(null)},[a,I,r]),R=t=>{D(c=>c&&(()=>{const l=t(c.control);c.control.source.kind==="manual"&&l.source.kind==="sql_query"&&(M.current=c.defaultValue);const h=c.defaultValue===void 0&&c.control.source.kind==="sql_query"&&l.source.kind==="manual"?M.current:c.defaultValue,j=s.getNextEditedControlDefaultValue({previousControl:c.control,nextControl:l,currentDefaultValue:h});return l.source.kind==="manual"&&(M.current=j),{...c,control:l,defaultValue:j}})())},te=t=>{D(c=>c&&(c.control.source.kind==="manual"&&(M.current=t),{...c,defaultValue:t}))},le=(()=>{if(!n)return!1;if(n.step===2&&_(n.control.type))return(n.selectedCardIds||[]).length>0;if(n.step!==2&&n.step!==3||!n.control.label.trim())return!1;const c=n.control.source.kind==="sql_query"?n.control:s.ensureManualSource(n.control);if(c.source.kind==="manual"&&(s.needsManualOptions(c)&&c.source.options.length===0||c.source.options.some(h=>h.label.trim().length===0||h.value.trim().length===0)))return!1;if(c.source.kind==="sql_query"){const{connectionId:l,sql:h,valueColumn:j}=c.source;return l.trim().length>0&&h.trim().length>0&&j.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(c,n.defaultValue))})(),pe=()=>{var N;if(!n)return;const t=s.ensureManualSource(n.control),c=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:a,reservedIds:Array.from(I)}),l={...t,id:c},h=r==="dashboard"&&(l.type==="field_selector"||l.type==="metric_selector")&&((N=n.selectedCardIds)!=null&&N.length)?s.buildStructuralControlBindingsForParticipants({control:l,participants:y||[],selectedCardIds:n.selectedCardIds}):void 0,j=s.getDefaultValueForType(l,n.defaultValue);D({step:r==="dashboard"&&(l.type==="field_selector"||l.type==="metric_selector")?4:3,control:l,defaultValue:j,createdControlId:c,selectedCardIds:n.selectedCardIds,cardBindingsById:h})},ie=v.useCallback(()=>{D(null)},[]),me=v.useCallback(()=>{if(!(n!=null&&n.createdControlId)){D(null);return}const t=n.control,c=n.createdControlId,l=s.getDefaultValueForType(t,n.defaultValue);if(o){const h={...o};l===void 0?delete h[c]:h[c]=l,F([...a,{...t,defaultValue:l}],h,{type:"add",cardBindingsById:n.cardBindingsById})}else F([...a,{...t,defaultValue:l}],void 0,{type:"add",cardBindingsById:n.cardBindingsById});q(c),D(null),E==null||E()},[a,n,o,F,E]),we=n?_(n.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],fe=n!=null&&n.createdControlId?`[[param.${n.createdControlId}]]`:n?`[[param.${s.slugifyControlValue(n.control.label)||n.control.id}]]`:"",de=s.buildAuthoringPreviewControlValues({controls:a,defaultValues:o}),ce=n?[...a,n.control]:a,xe=n?s.buildAuthoringPreviewControlValues({controls:ce,defaultValues:o,overrides:[{controlId:n.control.id,value:n.defaultValue}]}):de;return e.jsxs("div",{className:"space-y-4",children:[n?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(ze,{currentStep:n.step,labels:we}),n.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),c=new Set(["date","text"]),l=W.filter(N=>!t.has(N.value)&&!c.has(N.value)),h=W.filter(N=>t.has(N.value)),j=N=>e.jsxs("button",{type:"button",className:"rounded-control 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:()=>D(Pe({scope:r,existingControls:a,reservedIds:Array.from(I),type:N.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:N.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:N.description})]},N.value);return e.jsxs("div",{className:"space-y-4",children:[r==="card"&&(S==null?void 0:S.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,l.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:l.map(j)})]}),h.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:h.map(j)})]}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:ie,children:"Back to controls"})})]})})(),n.step===2&&_(n.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ee,{control:n.control,onChange:t=>R(c=>({...c,label:t}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),z.length===0?e.jsx("div",{className:"rounded-control 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-control border border-border/60 bg-background p-2",children:z.map(t=>{const c=(n.selectedCardIds||[]).includes(t.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(f.Checkbox,{checked:c,onCheckedChange:l=>D(h=>h&&{...h,selectedCardIds:l===!0?[...h.selectedCardIds||[],t.cardId]:(h.selectedCardIds||[]).filter(j=>j!==t.cardId)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground",children:t.title}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:n.control.type==="field_selector"?`${t.fieldChoices.length} compatible group-by fields`:`${t.metricChoices.length} compatible metrics`})]})]},t.cardId)})}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>D(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:()=>D(t=>t&&{...t,step:3}),disabled:!le,children:"Next"})})]}),n.step===2&&!_(n.control.type)&&e.jsx(ye,{control:n.control,defaultValue:n.defaultValue,availableFieldChoices:$.fields,availableMetricChoices:$.metrics,previewControlDefinitions:ce,previewControlValues:xe,onControlChange:t=>R(()=>t),onLabelChange:t=>R(c=>({...c,label:t})),onDefaultValueChange:te,onBack:()=>D(t=>t&&{...t,step:1}),onNext:pe,nextDisabled:!le}),n.step===3&&_(n.control.type)&&e.jsx(ye,{control:n.control,defaultValue:n.defaultValue,availableFieldChoices:$.fields,availableMetricChoices:$.metrics,previewControlDefinitions:ce,previewControlValues:xe,onControlChange:t=>R(()=>t),onLabelChange:t=>R(c=>({...c,label:t})),onDefaultValueChange:te,onBack:()=>D(t=>t&&{...t,step:2}),onNext:pe,nextDisabled:!le}),n.step===3&&!_(n.control.type)&&e.jsx(ve,{control:n.control,scope:r,createdReference:fe,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:()=>D(t=>t&&{...t,step:2}),onCancel:ie,onDone:me}),n.step===4&&_(n.control.type)&&e.jsx(ve,{control:n.control,scope:r,createdReference:fe,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(n.selectedCardIds||[]).length," selected card",(n.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:()=>D(t=>t&&{...t,step:3}),onCancel:ie,onDone:me})]}):null,!n&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!n&&a.map(t=>{const c=ne(t),l=x==null?void 0:x[t.id],h=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:o}),j=J===t.id,N="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-control 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-control text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>q(b=>b===t.id?null:t.id),children:[j?e.jsx(ee.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ge.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:t.label||"Untitled control"}),e.jsx("span",{className:N,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:N,children:s.getPlacementLabel(r,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),l!=null&&l.status?` · ${l.status}`:""]})]})]}),e.jsx(s.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>oe(t.id),"aria-label":`Remove ${t.label}`,children:e.jsx(f.Trash2,{className:"h-3.5 w-3.5"})})]}),j&&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(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:t.label,placeholder:"Control label",onChange:b=>P(t.id,V=>({...V,label:b.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(s.Select,{value:t.type,onValueChange:b=>{const V=s.applyControlTypeChange({controls:a,controlId:t.id,nextType:b,defaultValues:o});F(V.controls,V.defaultValues)},children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:G(t.type).map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(s.Select,{value:t.placement||Y,onValueChange:b=>P(t.id,V=>({...V,placement:b})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:U.map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.value))})]})]})]}),_(t.type)?e.jsx(f.StructuralParticipantSelector,{type:t.type,participants:s.getEligibleParticipantsForStructuralControl(y||[],t.type).map(b=>({cardId:b.cardId,title:b.title,choiceCount:t.type==="field_selector"?b.fieldChoices.length:b.metricChoices.length})),selectedCardIds:(g==null?void 0:g[t.id])||[],onChange:b=>{const V=A({control:t,nextSelectedCardIds:b}),O=a.map(L=>L.id===t.id?V.nextControl:L);F(O,o,{type:"update",cardBindingsById:V.cardBindingsById})}}):null,e.jsx(f.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:c.fields,availableMetricChoices:c.metrics,previewControlDefinitions:a,previewControlValues:de,controlLifecycle:"edit",onChange:b=>P(t.id,()=>b)}),t.initialValueStrategy==="saved_default"&&e.jsx(f.ControlDefaultValueEditor,{control:t,value:h,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:de,onChange:b=>{const V=a.map(O=>O.id===t.id?{...O,defaultValue:b}:O);if(t.source.kind==="manual"&&(T.current[t.id]=b),o){const O={...o};b===void 0?delete O[t.id]:O[t.id]=b,F(V,O);return}F(V,void 0)}}),e.jsxs(f.Collapsible,{open:H===t.id,onOpenChange:b=>K(b?t.id:null),children:[e.jsx(f.CollapsibleTrigger,{asChild:!0,children:e.jsxs(s.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[H===t.id?e.jsx(ee.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(ge.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(f.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(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),e.jsx(f.ControlIdInput,{controlId:t.id,onCommit:b=>B(t.id,b)},t.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(s.Select,{value:t.initialValueStrategy,onValueChange:b=>P(t.id,V=>({...V,initialValueStrategy:b})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.value))})]})]})]}),e.jsx(f.ControlVisibilitySettings,{control:t,onChange:b=>P(t.id,()=>b)})]})]})]})]},t.id)}),!n&&e.jsxs(s.Button,{type:"button",variant:"outline",size:"xs",onClick:re,children:[e.jsx(f.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Ye(r){const{open:a,onOpenChange:i,initialCreateFlowActive:o=!1,dismissMode:d="passive"}=r,u=a!==void 0,[m,x]=v.useState(!1),[p,C]=v.useState(o),y=u?a:m,g=v.useCallback(k=>{!k&&p&&d==="passive"||(u||x(k),k||C(!1),i==null||i(k))},[u,p,d,i]),S=v.useCallback(()=>{u||x(!1),C(!1),i==null||i(!1)},[u,i]);v.useEffect(()=>{y||C(!1)},[y]);const w=v.useCallback(k=>{p&&k.preventDefault()},[p]);return{forceClose:S,handleOpenChange:g,isCreateFlowActive:p,preventPassiveDismissDuringCreate:w,resolvedOpen:y,setIsCreateFlowActive:C}}exports.ControlDefinitionListEditor=$e;exports.EditorAcceptButton=Be;exports.EditorCancelButton=Oe;exports.EditorClearButton=Ue;exports.Library=je;exports.Link2=ke;exports.VisualBadge=Ae;exports.VisualSaveAndApplyButton=Me;exports.VisualSaveButton=qe;exports.useCreateFlowOverlayState=Ye;exports.useSyncLegacyEditorState=Le;exports.useVisualUtils=ae;
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/dashboard-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/dashboard-C-eTAAKs.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/dashboard-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/dashboard-C-eTAAKs.js"),w=require("../chunks/code-editor-M7HTUhdF.js"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),Q=require("../chunks/index-jSrCwPQz.js"),Cn=require("../chunks/save-Xdc4pnys.js"),tt=require("../chunks/search-Dcud9ajy.js");function Tr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const Rn=Tr(p),Bn=Tr(An);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as r, jsxs as c, Fragment as re } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import { useContext as
|
|
2
|
+
import * as Yn from "react";
|
|
3
|
+
import { useContext as Zn, useState as x, useRef as oe, useMemo as ze, useEffect as W, useCallback as Ot } from "react";
|
|
4
4
|
import * as Xn from "react-dom/client";
|
|
5
|
-
import {
|
|
6
|
-
import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, L as me, R as ma, d as _t } from "../chunks/code-editor-
|
|
5
|
+
import { bd as ea, be as ta, bf as Ir, bg as jr, bh as zr, bi as ra, bj as Wr, bk as Hr, bl as Jr, bm as Vr, bn as _r, bo as Ur, bp as Gr, ba as na, bq as aa, br as oa, bs as Ht, bt as on, R as Kr, bu as sa, bv as Vt, bw as sn, bx as ia, by as la } from "../chunks/dashboard--bQrQeiz.js";
|
|
6
|
+
import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, L as me, R as ma, d as _t } from "../chunks/code-editor-CIWiSltV.js";
|
|
7
7
|
import { loadSemaphorBrowserRuntime as ot } from "../data-app-builder-browser-runtime/index.js";
|
|
8
8
|
import { c as $e, X as Je } from "../chunks/index-xHCrHprY.js";
|
|
9
9
|
import { S as fa } from "../chunks/save-HCJjjzdX.js";
|
|
@@ -161,7 +161,7 @@ const ka = $e("PanelLeft", [
|
|
|
161
161
|
reasoningEffort: "low"
|
|
162
162
|
},
|
|
163
163
|
{ id: "gpt-4.1-mini", label: "GPT-4.1 mini", model: "gpt-4.1-mini" }
|
|
164
|
-
], Qr = "semaphor-data-app-builder-transcript",
|
|
164
|
+
], Qr = "semaphor-data-app-builder-transcript", qr = "semaphor-data-app-builder-preview-url", Yr = "semaphor-data-app-builder-bridge-url", Zr = "semaphor-data-app-builder-project-dir", Lt = "http://semaphor-data-app.localhost:8088", Xr = "http://localhost:8787", It = "/Users/rohit/code/sandbox/semaphor-data-apps/data-app", We = 3, Aa = 18, jt = 12;
|
|
165
165
|
function he(e, a) {
|
|
166
166
|
return `${e}:${a}`;
|
|
167
167
|
}
|
|
@@ -445,10 +445,10 @@ async function Fa(e, {
|
|
|
445
445
|
contentType: z.contentType
|
|
446
446
|
})
|
|
447
447
|
}
|
|
448
|
-
),
|
|
448
|
+
), Y = await O(ve, "Data App publish upload");
|
|
449
449
|
if (!ve.ok)
|
|
450
450
|
throw new Error(
|
|
451
|
-
|
|
451
|
+
Y.error || `Upload failed for ${z.path}.`
|
|
452
452
|
);
|
|
453
453
|
}
|
|
454
454
|
l == null || l({
|
|
@@ -918,7 +918,7 @@ function Qa({
|
|
|
918
918
|
] })
|
|
919
919
|
] });
|
|
920
920
|
}
|
|
921
|
-
function
|
|
921
|
+
function qa({
|
|
922
922
|
plan: e,
|
|
923
923
|
changedFiles: a
|
|
924
924
|
}) {
|
|
@@ -967,9 +967,9 @@ function ko({
|
|
|
967
967
|
adapters: l
|
|
968
968
|
}) {
|
|
969
969
|
var v, B;
|
|
970
|
-
const p =
|
|
970
|
+
const p = Zn(ea), h = typeof window > "u" ? void 0 : window.location.origin, g = d || ((v = p.tokenProps) == null ? void 0 : v.apiServiceUrl) || h, S = (B = p.authToken) == null ? void 0 : B.accessToken, [f, R] = x(() => fe("builder-session"));
|
|
971
971
|
return /* @__PURE__ */ r("main", { className: "flex h-full min-h-0 w-full min-w-0 flex-1 flex-col self-stretch bg-muted/40 text-foreground", children: /* @__PURE__ */ r(
|
|
972
|
-
|
|
972
|
+
Ya,
|
|
973
973
|
{
|
|
974
974
|
adapters: l,
|
|
975
975
|
apiServiceUrl: g,
|
|
@@ -984,7 +984,7 @@ function ko({
|
|
|
984
984
|
f
|
|
985
985
|
) });
|
|
986
986
|
}
|
|
987
|
-
function
|
|
987
|
+
function Ya({
|
|
988
988
|
adapters: e,
|
|
989
989
|
apiServiceUrl: a,
|
|
990
990
|
accessToken: s,
|
|
@@ -996,22 +996,22 @@ function Za({
|
|
|
996
996
|
onRestart: S
|
|
997
997
|
}) {
|
|
998
998
|
var Or, Lr;
|
|
999
|
-
const [f, R] = x(Lt), [v, B] = x(Xr), [b, E] = x(It), [j, L] = x(!1), [F, z] = x(Lt), [ve,
|
|
999
|
+
const [f, R] = x(Lt), [v, B] = x(Xr), [b, E] = x(It), [j, L] = x(!1), [F, z] = x(Lt), [ve, Y] = x(0), [A] = x(p), [_e, ct] = x(
|
|
1000
1000
|
l || ""
|
|
1001
|
-
), [ut, Ue] = x([]), [De, Pe] = x([]), [
|
|
1001
|
+
), [ut, Ue] = x([]), [De, Pe] = x([]), [Z, ge] = x([]), [Qt, Ge] = x(null), [X, Ke] = x(!1), [ee, qt] = x(!1), [Fe, un] = x(!0), [pn, se] = x("idle"), [hn, ie] = x(null), [Yt, Zt] = x(null), [Xt, Qe] = x(() => Date.now()), [Me, er] = x(null), [pt, mn] = x("gpt-5.5-low"), q = oe(null), G = oe(null), ht = oe([]), mt = oe(null), ft = oe(null), tr = oe(null), [be, ke] = x(!1), [rr, le] = x(null), [nr, gt] = x(!1), [ar, or] = x(!1), [Te, bt] = x("idle"), [sr, ir] = x(
|
|
1002
1002
|
null
|
|
1003
|
-
), [fn, lr] = x(""), [gn, dr] = x([]), [xt, cr] = x([]), [wt, ur] = x(null), [pr, bn] = x([]), [xn, wn] = x(null), [yt, hr] = x(null), [vt, mr] = x(null), [xe,
|
|
1003
|
+
), [fn, lr] = x(""), [gn, dr] = x([]), [xt, cr] = x([]), [wt, ur] = x(null), [pr, bn] = x([]), [xn, wn] = x(null), [yt, hr] = x(null), [vt, mr] = x(null), [xe, qe] = x(
|
|
1004
1004
|
d || null
|
|
1005
|
-
), [
|
|
1005
|
+
), [Ye, kt] = x("idle"), [fr, Nt] = x("idle"), [gr, br] = x(null), [xr, wr] = x(null), [St, Ne] = x(null), [de, J] = x(null), [yr, Ze] = x(null), [Xe, At] = x(null), [Ct, et] = x(!1), [Rt, vr] = x(""), [kr, Bt] = x(null), [Nr, Sr] = x(!1), Ee = oe(
|
|
1006
1006
|
null
|
|
1007
1007
|
), $t = oe(null), Se = oe(null), Ar = (e == null ? void 0 : e.readStatus) || Ra, tt = (e == null ? void 0 : e.runTurn) || Ba, Dt = (e == null ? void 0 : e.saveDraft) || Da, yn = (e == null ? void 0 : e.loadApp) || Pa, Pt = (e == null ? void 0 : e.publish) || Fa, V = ze(() => Ca(pt), [pt]), vn = ze(
|
|
1008
|
-
() =>
|
|
1008
|
+
() => Z.find(
|
|
1009
1009
|
(t) => t.type === "run" && t.id === Qt
|
|
1010
1010
|
),
|
|
1011
|
-
[Qt,
|
|
1011
|
+
[Qt, Z]
|
|
1012
1012
|
), Ft = ze(
|
|
1013
|
-
() => [...
|
|
1014
|
-
[
|
|
1013
|
+
() => [...Z].reverse().find((t) => t.type === "run"),
|
|
1014
|
+
[Z]
|
|
1015
1015
|
), Mt = ze(() => {
|
|
1016
1016
|
const t = F.includes("?") ? "&" : "?";
|
|
1017
1017
|
return `${F}${t}dataAppBuilderRefresh=${ve}`;
|
|
@@ -1020,8 +1020,8 @@ function Za({
|
|
|
1020
1020
|
const t = window.setInterval(() => Qe(Date.now()), 500);
|
|
1021
1021
|
return () => window.clearInterval(t);
|
|
1022
1022
|
}, []), W(() => {
|
|
1023
|
-
ht.current =
|
|
1024
|
-
}, [
|
|
1023
|
+
ht.current = Z;
|
|
1024
|
+
}, [Z]), W(() => {
|
|
1025
1025
|
if (!Ct) return;
|
|
1026
1026
|
const t = () => {
|
|
1027
1027
|
et(!1);
|
|
@@ -1031,7 +1031,7 @@ function Za({
|
|
|
1031
1031
|
};
|
|
1032
1032
|
}, [Ct]), W(() => {
|
|
1033
1033
|
L(!1);
|
|
1034
|
-
const t = window.localStorage.getItem(he(
|
|
1034
|
+
const t = window.localStorage.getItem(he(qr, h)) || Lt, n = window.localStorage.getItem(he(Yr, h)) || Xr, i = window.localStorage.getItem(he(Zr, h)) || It, o = window.localStorage.getItem(
|
|
1035
1035
|
he(Qr, h)
|
|
1036
1036
|
);
|
|
1037
1037
|
if (R(t), z(t), B(n), E(i), L(!0), o)
|
|
@@ -1042,29 +1042,29 @@ function Za({
|
|
|
1042
1042
|
}
|
|
1043
1043
|
}, [h]), W(() => {
|
|
1044
1044
|
window.localStorage.setItem(
|
|
1045
|
-
he(
|
|
1045
|
+
he(qr, h),
|
|
1046
1046
|
f
|
|
1047
1047
|
);
|
|
1048
1048
|
}, [f, h]), W(() => {
|
|
1049
1049
|
window.localStorage.setItem(
|
|
1050
|
-
he(
|
|
1050
|
+
he(Yr, h),
|
|
1051
1051
|
v
|
|
1052
1052
|
);
|
|
1053
1053
|
}, [v, h]), W(() => {
|
|
1054
1054
|
window.localStorage.setItem(
|
|
1055
|
-
he(
|
|
1055
|
+
he(Zr, h),
|
|
1056
1056
|
b
|
|
1057
1057
|
);
|
|
1058
1058
|
}, [b, h]), W(() => {
|
|
1059
1059
|
var t;
|
|
1060
1060
|
window.localStorage.setItem(
|
|
1061
1061
|
he(Qr, h),
|
|
1062
|
-
JSON.stringify(
|
|
1062
|
+
JSON.stringify(Z.map(oo))
|
|
1063
1063
|
), (t = mt.current) == null || t.scrollTo({
|
|
1064
1064
|
top: mt.current.scrollHeight,
|
|
1065
1065
|
behavior: "smooth"
|
|
1066
1066
|
});
|
|
1067
|
-
}, [
|
|
1067
|
+
}, [Z, h]), W(() => {
|
|
1068
1068
|
Se.current = yt;
|
|
1069
1069
|
}, [yt]);
|
|
1070
1070
|
const Tt = Ot(
|
|
@@ -1091,14 +1091,14 @@ function Za({
|
|
|
1091
1091
|
if (A !== "bridge" || !a) return;
|
|
1092
1092
|
const t = new AbortController();
|
|
1093
1093
|
return Tt(t.signal).then(() => {
|
|
1094
|
-
|
|
1094
|
+
Y((n) => n + 1);
|
|
1095
1095
|
}).catch((n) => {
|
|
1096
1096
|
t.signal.aborted || (gt(!1), le(
|
|
1097
1097
|
n instanceof Error ? n.message : "Bridge could not sync runtime context."
|
|
1098
1098
|
));
|
|
1099
1099
|
}), () => t.abort();
|
|
1100
1100
|
}, [a, A, Tt]), W(() => {
|
|
1101
|
-
|
|
1101
|
+
qe(d || null);
|
|
1102
1102
|
}, [d]), W(() => {
|
|
1103
1103
|
if (!d || !j || $t.current === `${d}:${A}:${b}`)
|
|
1104
1104
|
return;
|
|
@@ -1115,7 +1115,7 @@ function Za({
|
|
|
1115
1115
|
{ apiServiceUrl: a, accessToken: s, signal: t.signal }
|
|
1116
1116
|
);
|
|
1117
1117
|
if (t.signal.aborted) return;
|
|
1118
|
-
|
|
1118
|
+
qe(o.id);
|
|
1119
1119
|
const u = Ja(o);
|
|
1120
1120
|
if (!u) {
|
|
1121
1121
|
J({
|
|
@@ -1139,7 +1139,7 @@ function Za({
|
|
|
1139
1139
|
snapshot: u.sourceSnapshot,
|
|
1140
1140
|
targetProjectDir: k,
|
|
1141
1141
|
signal: t.signal
|
|
1142
|
-
}), w &&
|
|
1142
|
+
}), w && Y((C) => C + 1)), A === "bridge" && k !== b && E(k), t.signal.aborted) return;
|
|
1143
1143
|
J({
|
|
1144
1144
|
state: "done",
|
|
1145
1145
|
label: "Data App opened",
|
|
@@ -1210,7 +1210,7 @@ function Za({
|
|
|
1210
1210
|
async (t = G.current) => {
|
|
1211
1211
|
if (!t) return;
|
|
1212
1212
|
const n = await t.compileBrowserSandboxPreviewHtml();
|
|
1213
|
-
lr(n.html), dr(n.diagnostics), cr(n.warnings || []), ur(n.cssMode || null),
|
|
1213
|
+
lr(n.html), dr(n.diagnostics), cr(n.warnings || []), ur(n.cssMode || null), Y((i) => i + 1);
|
|
1214
1214
|
},
|
|
1215
1215
|
[]
|
|
1216
1216
|
), Oe = Ot(
|
|
@@ -1229,7 +1229,7 @@ function Za({
|
|
|
1229
1229
|
let t = !1;
|
|
1230
1230
|
async function n() {
|
|
1231
1231
|
bt("loading"), ir(null), window.__SEMAPHOR_BROWSER_SANDBOX_VENDOR__ = {
|
|
1232
|
-
React:
|
|
1232
|
+
React: Yn,
|
|
1233
1233
|
ReactDOMClient: Xn
|
|
1234
1234
|
};
|
|
1235
1235
|
try {
|
|
@@ -1262,7 +1262,7 @@ function Za({
|
|
|
1262
1262
|
}
|
|
1263
1263
|
async function Nn() {
|
|
1264
1264
|
if (X || ee) return;
|
|
1265
|
-
if (At(null),
|
|
1265
|
+
if (At(null), Ze(null), vr(""), Bt(null), A === "browser") {
|
|
1266
1266
|
await Cr();
|
|
1267
1267
|
return;
|
|
1268
1268
|
}
|
|
@@ -1284,7 +1284,7 @@ function Za({
|
|
|
1284
1284
|
);
|
|
1285
1285
|
if (!i.ok || !o.ok)
|
|
1286
1286
|
throw new Error(o.error || "Bridge could not reset the app.");
|
|
1287
|
-
z(f),
|
|
1287
|
+
z(f), Y((u) => u + 1), J({
|
|
1288
1288
|
state: "done",
|
|
1289
1289
|
label: "App reset",
|
|
1290
1290
|
detail: "Blank template restored and typecheck passed."
|
|
@@ -1373,7 +1373,7 @@ function Za({
|
|
|
1373
1373
|
const n = (i = t.artifacts) == null ? void 0 : i.find(
|
|
1374
1374
|
(o) => o.type === "dataset_inspector"
|
|
1375
1375
|
);
|
|
1376
|
-
n &&
|
|
1376
|
+
n && Ze(n);
|
|
1377
1377
|
}
|
|
1378
1378
|
function Rr(t) {
|
|
1379
1379
|
se({
|
|
@@ -1400,7 +1400,7 @@ function Za({
|
|
|
1400
1400
|
createdAt: i,
|
|
1401
1401
|
attachments: t.attachments
|
|
1402
1402
|
}
|
|
1403
|
-
]),
|
|
1403
|
+
]), Zt(i), se("context"), ie("Preparing app context and available files."), Kn({ ...t, prompt: n });
|
|
1404
1404
|
}
|
|
1405
1405
|
async function Bn(t) {
|
|
1406
1406
|
if (!t.type.startsWith("image/")) {
|
|
@@ -1477,7 +1477,7 @@ function Za({
|
|
|
1477
1477
|
}
|
|
1478
1478
|
ke(!0), le(
|
|
1479
1479
|
t ? "Loading inspector in the preview…" : "Click an element in the preview. Press Esc to cancel."
|
|
1480
|
-
), t ? (z(f),
|
|
1480
|
+
), t ? (z(f), Y((n) => n + 1)) : window.setTimeout(() => at("inspect-enable"), 50);
|
|
1481
1481
|
} catch (t) {
|
|
1482
1482
|
ke(!1), le(null), M(
|
|
1483
1483
|
t instanceof Error ? t.message : String(t),
|
|
@@ -1581,9 +1581,9 @@ function Za({
|
|
|
1581
1581
|
}
|
|
1582
1582
|
async function Ln(t, n, i) {
|
|
1583
1583
|
var k, w, C, y;
|
|
1584
|
-
(k =
|
|
1584
|
+
(k = q.current) == null || k.abort();
|
|
1585
1585
|
const o = new AbortController(), u = Date.now();
|
|
1586
|
-
|
|
1586
|
+
q.current = o, Ke(!0), Ge(n), Qe(u), K(n, "reading");
|
|
1587
1587
|
const m = window.setTimeout(() => {
|
|
1588
1588
|
o.abort();
|
|
1589
1589
|
}, 18e4);
|
|
@@ -1645,7 +1645,7 @@ function Za({
|
|
|
1645
1645
|
};
|
|
1646
1646
|
if (we.ok) {
|
|
1647
1647
|
const P = await N.compileBrowserSandboxPreviewHtml();
|
|
1648
|
-
if (lr(P.html), dr(P.diagnostics), cr(P.warnings || []), ur(P.cssMode || null),
|
|
1648
|
+
if (lr(P.html), dr(P.diagnostics), cr(P.warnings || []), ur(P.cssMode || null), Y((U) => U + 1), Oe(N), P.diagnostics.length > 0) {
|
|
1649
1649
|
const U = {
|
|
1650
1650
|
command: "browser sandbox preview compile",
|
|
1651
1651
|
durationMs: 0,
|
|
@@ -1704,14 +1704,14 @@ function Za({
|
|
|
1704
1704
|
"blocked"
|
|
1705
1705
|
), K(n, "failed");
|
|
1706
1706
|
} finally {
|
|
1707
|
-
Ke(!1), Ge(null),
|
|
1707
|
+
Ke(!1), Ge(null), q.current = null, window.clearTimeout(m);
|
|
1708
1708
|
}
|
|
1709
1709
|
}
|
|
1710
1710
|
async function In(t, n, i) {
|
|
1711
1711
|
var k, w, C, y;
|
|
1712
|
-
(k =
|
|
1712
|
+
(k = q.current) == null || k.abort();
|
|
1713
1713
|
const o = new AbortController(), u = Date.now();
|
|
1714
|
-
|
|
1714
|
+
q.current = o, Ke(!0), Ge(n), Qe(u), K(n, "reading");
|
|
1715
1715
|
const m = window.setTimeout(() => {
|
|
1716
1716
|
o.abort();
|
|
1717
1717
|
}, 18e4);
|
|
@@ -1830,7 +1830,7 @@ function Za({
|
|
|
1830
1830
|
...U,
|
|
1831
1831
|
attemptLabel: P
|
|
1832
1832
|
});
|
|
1833
|
-
if (z(f),
|
|
1833
|
+
if (z(f), Y((je) => je + 1), we.push(...ae.attempts || []), _ = {
|
|
1834
1834
|
...ae,
|
|
1835
1835
|
attempts: [...we],
|
|
1836
1836
|
filePlan: U.plan,
|
|
@@ -1839,7 +1839,7 @@ function Za({
|
|
|
1839
1839
|
contextChars: ne,
|
|
1840
1840
|
generatedFileCount: U.files.length,
|
|
1841
1841
|
generatedChars: U.files.reduce(
|
|
1842
|
-
(je,
|
|
1842
|
+
(je, qn) => je + qn.contents.length,
|
|
1843
1843
|
0
|
|
1844
1844
|
),
|
|
1845
1845
|
repairAttempts: we.filter(
|
|
@@ -1884,7 +1884,7 @@ function Za({
|
|
|
1884
1884
|
"blocked"
|
|
1885
1885
|
), K(n, "failed");
|
|
1886
1886
|
} finally {
|
|
1887
|
-
Ke(!1), Ge(null),
|
|
1887
|
+
Ke(!1), Ge(null), q.current = null, window.clearTimeout(m);
|
|
1888
1888
|
}
|
|
1889
1889
|
}
|
|
1890
1890
|
async function jn(t) {
|
|
@@ -2186,7 +2186,7 @@ function Za({
|
|
|
2186
2186
|
},
|
|
2187
2187
|
{ apiServiceUrl: a, accessToken: s, signal: t.signal }
|
|
2188
2188
|
);
|
|
2189
|
-
return
|
|
2189
|
+
return qe(w.dataAppId), br(w.savedAt || (/* @__PURE__ */ new Date()).toISOString()), kt("saved"), J({
|
|
2190
2190
|
state: "done",
|
|
2191
2191
|
label: "Draft saved",
|
|
2192
2192
|
detail: "Semaphor has the latest source snapshot."
|
|
@@ -2236,7 +2236,7 @@ function Za({
|
|
|
2236
2236
|
);
|
|
2237
2237
|
return;
|
|
2238
2238
|
}
|
|
2239
|
-
if (
|
|
2239
|
+
if (Ye === "saving" && !Ee.current) {
|
|
2240
2240
|
M("Save draft is already in progress.", "blocked");
|
|
2241
2241
|
return;
|
|
2242
2242
|
}
|
|
@@ -2302,7 +2302,7 @@ function Za({
|
|
|
2302
2302
|
}
|
|
2303
2303
|
}
|
|
2304
2304
|
);
|
|
2305
|
-
|
|
2305
|
+
qe(o.dataAppId), wr(o.publishedAt || (/* @__PURE__ */ new Date()).toISOString()), Nt("published"), J({
|
|
2306
2306
|
state: "done",
|
|
2307
2307
|
label: "Published",
|
|
2308
2308
|
detail: `Version ${o.version ?? o.versionId} is ready.`
|
|
@@ -2322,7 +2322,7 @@ function Za({
|
|
|
2322
2322
|
async function Kn(t) {
|
|
2323
2323
|
var m, k;
|
|
2324
2324
|
const { attachments: n, prompt: i } = t, o = new AbortController();
|
|
2325
|
-
|
|
2325
|
+
q.current = o, qt(!0);
|
|
2326
2326
|
const u = window.setTimeout(() => {
|
|
2327
2327
|
o.abort();
|
|
2328
2328
|
}, 18e4);
|
|
@@ -2451,7 +2451,7 @@ function Za({
|
|
|
2451
2451
|
createdAt: I,
|
|
2452
2452
|
startedAt: I
|
|
2453
2453
|
}
|
|
2454
|
-
]),
|
|
2454
|
+
]), q.current = null, A === "browser" ? Ln(i, N, y.revision) : In(i, N, y.revision);
|
|
2455
2455
|
} catch (w) {
|
|
2456
2456
|
const C = w instanceof DOMException && w.name === "AbortError";
|
|
2457
2457
|
M(
|
|
@@ -2459,7 +2459,7 @@ function Za({
|
|
|
2459
2459
|
"blocked"
|
|
2460
2460
|
);
|
|
2461
2461
|
} finally {
|
|
2462
|
-
|
|
2462
|
+
qt(!1), se("idle"), ie(null), Zt(null), q.current === o && (q.current = null), window.clearTimeout(u);
|
|
2463
2463
|
}
|
|
2464
2464
|
}
|
|
2465
2465
|
function Qn(t) {
|
|
@@ -2530,7 +2530,7 @@ function Za({
|
|
|
2530
2530
|
ref: mt,
|
|
2531
2531
|
className: "min-h-0 flex-1 overflow-y-auto px-3 py-4",
|
|
2532
2532
|
children: /* @__PURE__ */ c("div", { className: "space-y-4", children: [
|
|
2533
|
-
|
|
2533
|
+
Z.length === 0 && /* @__PURE__ */ c("div", { children: [
|
|
2534
2534
|
/* @__PURE__ */ r("p", { className: "text-[12.5px] font-medium text-foreground", children: "Start with a question or a build instruction" }),
|
|
2535
2535
|
/* @__PURE__ */ r("p", { className: "mt-1 text-[11.5px] leading-relaxed text-muted-foreground", children: "Ask about the current files, or describe the app you want." }),
|
|
2536
2536
|
/* @__PURE__ */ r("div", { className: "mt-3 grid gap-1.5", children: Na.slice(0, 3).map((t) => /* @__PURE__ */ c(
|
|
@@ -2547,12 +2547,12 @@ function Za({
|
|
|
2547
2547
|
t.id
|
|
2548
2548
|
)) })
|
|
2549
2549
|
] }),
|
|
2550
|
-
|
|
2550
|
+
Z.map(
|
|
2551
2551
|
(t) => t.type === "user" ? /* @__PURE__ */ r(ao, { message: t }, t.id) : t.type === "assistant" ? /* @__PURE__ */ r(
|
|
2552
2552
|
so,
|
|
2553
2553
|
{
|
|
2554
2554
|
message: t,
|
|
2555
|
-
onOpenDatasetInspector:
|
|
2555
|
+
onOpenDatasetInspector: Ze
|
|
2556
2556
|
},
|
|
2557
2557
|
t.id
|
|
2558
2558
|
) : /* @__PURE__ */ r(
|
|
@@ -2569,7 +2569,7 @@ function Za({
|
|
|
2569
2569
|
{
|
|
2570
2570
|
phase: pn,
|
|
2571
2571
|
detail: hn,
|
|
2572
|
-
elapsedMs:
|
|
2572
|
+
elapsedMs: Yt ? Math.max(0, Xt - Yt) : 0
|
|
2573
2573
|
}
|
|
2574
2574
|
)
|
|
2575
2575
|
] })
|
|
@@ -2713,7 +2713,7 @@ function Za({
|
|
|
2713
2713
|
title: "Stop the current run",
|
|
2714
2714
|
onClick: () => {
|
|
2715
2715
|
var t;
|
|
2716
|
-
return (t =
|
|
2716
|
+
return (t = q.current) == null ? void 0 : t.abort();
|
|
2717
2717
|
},
|
|
2718
2718
|
children: [
|
|
2719
2719
|
/* @__PURE__ */ r(Je, { className: "h-3 w-3" }),
|
|
@@ -2913,11 +2913,11 @@ function Za({
|
|
|
2913
2913
|
variant: "ghost",
|
|
2914
2914
|
size: "xs",
|
|
2915
2915
|
className: "gap-1.5 text-muted-foreground",
|
|
2916
|
-
disabled: X || ee ||
|
|
2916
|
+
disabled: X || ee || Ye === "saving" || A !== "bridge" || !Dt,
|
|
2917
2917
|
title: "Save the current local source snapshot as a Semaphor draft",
|
|
2918
2918
|
onClick: () => void Er(),
|
|
2919
2919
|
children: [
|
|
2920
|
-
|
|
2920
|
+
Ye === "saving" ? /* @__PURE__ */ r(me, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ r(fa, { className: "h-3.5 w-3.5" }),
|
|
2921
2921
|
"Save draft"
|
|
2922
2922
|
]
|
|
2923
2923
|
}
|
|
@@ -2929,7 +2929,7 @@ function Za({
|
|
|
2929
2929
|
variant: "ghost",
|
|
2930
2930
|
size: "xs",
|
|
2931
2931
|
className: "gap-1.5 text-muted-foreground",
|
|
2932
|
-
disabled: X || ee ||
|
|
2932
|
+
disabled: X || ee || Ye === "saving" || fr === "publishing" || A !== "bridge" || !Pt,
|
|
2933
2933
|
title: "Build, upload, and publish the current Data App",
|
|
2934
2934
|
onClick: () => void Gn(),
|
|
2935
2935
|
children: [
|
|
@@ -3032,7 +3032,7 @@ function Za({
|
|
|
3032
3032
|
title: "Reload the live preview",
|
|
3033
3033
|
"aria-label": "Reload the live preview",
|
|
3034
3034
|
onClick: () => {
|
|
3035
|
-
A === "browser" ? (rt(), Oe()) : (z(f),
|
|
3035
|
+
A === "browser" ? (rt(), Oe()) : (z(f), Y((t) => t + 1));
|
|
3036
3036
|
},
|
|
3037
3037
|
children: /* @__PURE__ */ r(Kr, { className: "h-3.5 w-3.5" })
|
|
3038
3038
|
}
|
|
@@ -3096,7 +3096,7 @@ function Za({
|
|
|
3096
3096
|
lo,
|
|
3097
3097
|
{
|
|
3098
3098
|
artifact: yr,
|
|
3099
|
-
onClose: () =>
|
|
3099
|
+
onClose: () => Ze(null)
|
|
3100
3100
|
}
|
|
3101
3101
|
) : null
|
|
3102
3102
|
] })
|
|
@@ -3129,7 +3129,7 @@ function Wt({
|
|
|
3129
3129
|
)
|
|
3130
3130
|
] });
|
|
3131
3131
|
}
|
|
3132
|
-
function
|
|
3132
|
+
function Za({ code: e, lang: a }) {
|
|
3133
3133
|
const [s, d] = x(!1);
|
|
3134
3134
|
return /* @__PURE__ */ c("div", { className: "my-2 overflow-hidden rounded-[6px] border border-border", children: [
|
|
3135
3135
|
/* @__PURE__ */ c("div", { className: "flex items-center justify-between gap-2 border-b border-border bg-muted/40 px-2.5 py-1", children: [
|
|
@@ -3203,7 +3203,7 @@ function ro(e) {
|
|
|
3203
3203
|
const h = a.slice(0, p).trim();
|
|
3204
3204
|
h && /^[A-Za-z0-9_.+-]{1,16}$/.test(h) && (d = h, l = a.slice(p + 1));
|
|
3205
3205
|
}
|
|
3206
|
-
return l = l.replace(/^\n/, "").replace(/\s+$/, ""), /* @__PURE__ */ r(
|
|
3206
|
+
return l = l.replace(/^\n/, "").replace(/\s+$/, ""), /* @__PURE__ */ r(Za, { code: l, lang: d }, s);
|
|
3207
3207
|
}
|
|
3208
3208
|
return /* @__PURE__ */ r("span", { children: to(a, s) }, s);
|
|
3209
3209
|
});
|
|
@@ -3630,7 +3630,7 @@ function uo({
|
|
|
3630
3630
|
e.result.changedFiles.join(", ")
|
|
3631
3631
|
] }) : null,
|
|
3632
3632
|
/* @__PURE__ */ r(
|
|
3633
|
-
|
|
3633
|
+
qa,
|
|
3634
3634
|
{
|
|
3635
3635
|
plan: e.result.filePlan,
|
|
3636
3636
|
changedFiles: e.result.changedFiles
|