react-semaphor 0.0.148 → 0.0.150
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/{dashboard-plus-PXF4M2Zw.js → dashboard-plus-1qhhIbxX.js} +10 -10
- package/dist/chunks/{dashboard-plus-ucXms5nl.js → dashboard-plus-yoSVBMke.js} +1316 -1308
- package/dist/chunks/index-e4IBsALI.js +364 -0
- package/dist/chunks/{index-7tEMw5Sc.js → index-yLUZIbzY.js} +12616 -14926
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/main.d.ts +2 -1
- package/package.json +1 -1
- package/dist/chunks/2DAFLIRC-98edXt2R.js +0 -9088
- package/dist/chunks/2DAFLIRC-QEwj8O5E.js +0 -1086
- package/dist/chunks/index-nnROM_wm.js +0 -364
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./index-
|
|
1
|
+
"use strict";const t=require("./index-e4IBsALI.js"),A=require("react");/**
|
|
2
2
|
* @license lucide-react v0.379.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -158,10 +158,10 @@
|
|
|
158
158
|
*
|
|
159
159
|
* This source code is licensed under the ISC license.
|
|
160
160
|
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const Ti=t.createLucideIcon("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function zi(){const[e,n]=A.useState(""),[r,i]=A.useState(!1),[s,o]=A.useState(!1),l=t.useDashboardStore(u=>u.dashboard);function a(){const u=t.getDashbaordStateWithoutData(l),c=t.getBookmarkKey(l.id),x=JSON.parse(localStorage.getItem(c)||"[]");if(x.some(m=>m.name===e)){i(!0);return}x.push({name:e,template:u}),localStorage.setItem(c,JSON.stringify(x)),o(!1)}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:s,onOpenChange:o,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsxs(t.Button,{variant:"outline",className:"h-7 p-2",size:"sm",children:[t.jsxRuntimeExports.jsx(lr,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Lens"]})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Add a Lens"}),t.jsxRuntimeExports.jsx(t.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),t.jsxRuntimeExports.jsx("div",{className:"grid gap-4 py-4",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-right",children:"Name"}),t.jsxRuntimeExports.jsx(t.Input,{value:e,onChange:u=>{r&&i(!1),n(u.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),r&&t.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),t.jsxRuntimeExports.jsx(t.DialogFooter,{children:t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",type:"submit",disabled:!e,onClick:a,children:"Save"})})]})]})}function Li(){const[e,n]=A.useState(!1),[r,i]=A.useState(""),s=t.useDashboardStore(d=>d.dashboard),o=t.useDashboardStore(d=>d.bookmarkKey),[l,a]=A.useState([]),u=t.useDashboardStore(d=>d.actions.setDashboard),c=t.useDashboardStore(d=>d.actions.setFilterValues),x=t.useDashboardStore(d=>d.actions.setBookmarkKey);A.useEffect(()=>{const d=t.getBookmarkKey(s.id),j=JSON.parse(localStorage.getItem(d)||"[]");a(j);const E=j.find(k=>k.default);E&&E.name===o&&i(E.name)},[e,s,o]);function p(d){if(d===r)return;const j=l.find(k=>k.name===d),E=j==null?void 0:j.template;E&&(u(E),c(j.filterValues||[]),x(d==="Original"?"":d)),i(d)}function m(d){const j=t.getBookmarkKey(s.id),k=JSON.parse(localStorage.getItem(j)||"[]").filter(y=>y.name!==d);localStorage.setItem(j,JSON.stringify(k)),a(k)}return t.jsxRuntimeExports.jsxs(t.DropdownMenu,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DropdownMenuTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",className:"h-7 p-2",children:t.jsxRuntimeExports.jsx(di,{className:"h-4 w-4",strokeWidth:1.5})})}),t.jsxRuntimeExports.jsxs(t.DropdownMenuContent,{className:"w-56",children:[t.jsxRuntimeExports.jsx(t.DropdownMenuLabel,{children:"Lenses"}),t.jsxRuntimeExports.jsx(t.DropdownMenuSeparator,{}),t.jsxRuntimeExports.jsxs(t.DropdownMenuRadioGroup,{value:r,onValueChange:p,children:[t.jsxRuntimeExports.jsx(t.DropdownMenuRadioItem,{value:"Original",children:"Original"}),l.filter(d=>d.name!="Original").map((d,j)=>t.jsxRuntimeExports.jsxs(t.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:d.name,defaultChecked:d.name===o,children:[t.jsxRuntimeExports.jsx("p",{children:d.name}),t.jsxRuntimeExports.jsx(t.Cross2Icon,{onClick:E=>{E.preventDefault(),m(d.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},j))]})]})]})}function Oi(){const[e,n]=A.useState(!1),r=t.useDashboardStore(o=>o.dashboard),i=t.useDashboardStore(o=>o.bookmarkKey);A.useEffect(()=>{if(!i){n(!1);return}const o=t.getBookmarkKey(r.id),a=JSON.parse(localStorage.getItem(o)||"[]").find(u=>u.name===i);n(a?a.default:!1)},[i,r.id]);function s(o){if(n(o),!i)return;const l=t.getBookmarkKey(r.id),u=JSON.parse(localStorage.getItem(l)||"[]").map(c=>(c.name===i?c.default=o:c.default=!1,c));console.log(u),localStorage.setItem(l,JSON.stringify(u))}return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:e,onCheckedChange:s,id:"terms"}),t.jsxRuntimeExports.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function Di(){const e=t.useDashboardStore(y=>y.bookmarkKey),n=t.useDashboardStore(y=>y.dashboard);t.useDashboardStore(y=>y.selectedSheetId);const r=t.useDashboardStore(y=>y.isDashboardEditing),i=t.useDashboardStore(y=>y.filterValues),s=t.useDashboardStore(y=>y.isVisualEditing),o=t.useDashboardStore(y=>y.showFilters);t.useDashboardStore(y=>y.showDashboardJSON);const l=t.useDashboardStore(y=>y.onSaveFunction),a=t.useDashboardStore(y=>y.actions.setShowFilters),{addFrame:u,setSelectedFrameId:c}=t.useDashboardStore(y=>y.actions),{getSelectedSheet:x,setIsDashboardEditing:p,setShowDashboardJSON:m}=t.useDashboardStore(y=>y.actions),d=x(),j=()=>{if(!r||!d)return;const y={id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},w={id:t.v4(),cards:[y],activeCardId:y.id};u(d.id,w),c(w.id)},E=()=>{p(!0)};function k(){if(!e||e==="")return;const y=t.getDashbaordStateWithoutData(n),w=t.getBookmarkKey(n.id),R=JSON.parse(localStorage.getItem(w)||"[]"),O=R.findIndex(D=>D.name===e);O!==-1?R[O]={name:e,template:y,default:R[O].default,filterValues:i}:R.push({name:e,template:y,filterValues:i}),localStorage.setItem(w,JSON.stringify(R)),l==null||l(y)}return s?null:t.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pt-2",role:"dashboard-controls",children:[!s&&t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxRuntimeExports.jsx(t.Label,{children:e}),!!e&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"|"}),t.jsxRuntimeExports.jsx(Oi,{})]})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[r&&!s&&t.jsxRuntimeExports.jsx(zi,{}),!s&&t.jsxRuntimeExports.jsx(Li,{}),r&&!s&&t.jsxRuntimeExports.jsxs(t.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!r,onClick:j,children:[t.jsxRuntimeExports.jsx(lr,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Add Frame"]}),!r&&t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",className:"h-7 p-2",onClick:E,size:"sm",children:t.jsxRuntimeExports.jsx(sr,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!s&&t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{p(!1),m(!1)},size:"sm",children:t.jsxRuntimeExports.jsx(t.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!s&&t.jsxRuntimeExports.jsx(t.Button,{className:"h-7 p-2",variant:"outline",onClick:k,size:"sm",children:t.jsxRuntimeExports.jsx(Ci,{className:"h-4 w-4",strokeWidth:1.5})}),!o&&!s&&r&&t.jsxRuntimeExports.jsx(t.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>a(!0),size:"sm",children:t.jsxRuntimeExports.jsx(ir,{className:"h-4 w-4",strokeWidth:1.5})}),!s&&r&&!1,!s&&!1]})]})}function Ue({title:e,items:n,value:r,isLoading:i,isError:s,connectionTooltip:o,onChange:l,className:a,showIcon:u=!0}){const c=i?"Loading...":s?"Error":r;function x(){if(e==="Connection")return t.jsxRuntimeExports.jsx(Ri,{className:"size-4 rotate-90"});if(e==="Database")return t.jsxRuntimeExports.jsx(pi,{className:"size-4"});if(e==="Schema")return t.jsxRuntimeExports.jsx(ki,{className:"size-4"});if(e==="Table")return t.jsxRuntimeExports.jsx(Kt,{className:"size-4"})}return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[u&&t.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:o?t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:x()}),t.jsxRuntimeExports.jsx(t.TooltipContent,{className:"text-xs",align:"start",children:o})]}):x()}),t.jsxRuntimeExports.jsxs(t.Select,{value:c,onValueChange:l,children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:t.cn("h-9 w-[190px] focus:ring-1 focus:ring-offset-0",a),children:t.jsxRuntimeExports.jsx(t.SelectValue,{placeholder:i?"Loading...":s?"Error":`Select ${e}`})}),t.jsxRuntimeExports.jsx(t.SelectContent,{children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[i?t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Loading..."}):t.jsxRuntimeExports.jsx(t.SelectLabel,{children:e}),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:n&&n.map((p,m)=>t.jsxRuntimeExports.jsx(t.SelectItem,{value:p.id,children:p.name},m))}),(i||s)&&t.jsxRuntimeExports.jsx(t.SelectItem,{value:c,children:c})]})})]})]})}function Fi({column:e}){const[n,r]=A.useState(!1),i=t.useEditorStore(x=>x.selectedTableName),s=t.useEditorStore(x=>x.selectedSchemaName),o=t.useEditorStore(x=>x.sqlGen),l=t.useEditorStore(x=>x.actions.setSqlGen),a=t.useEditorStore(x=>x.actions.setCardSql),u=t.useEditorStore(x=>x.actions.setRunSql);function c(x,p){const m=t.createSqlGenConfig(x,o,p);l(m);const d=t.getSql(m,t.fmt(s||""),t.fmt(i));d&&(a(d),u(!0)),r(!1)}return t.jsxRuntimeExports.jsxs(t.Popover,{open:n,onOpenChange:r,children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.ChevronDown,{className:"h-4 w-4 cursor-pointer text-foreground/40"})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{align:"center",className:"w-18 rounded-md p-0 shadow-none",children:t.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function ur({column:e}){return t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.$a093c7e1ec25a057$export$8c610744efcf8a1d,{asChild:!0,children:t.TEXT_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(Ai,{className:"size-3"}):t.NUMBER_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(fi,{className:"size-3"}):t.DATE_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(t.Calendar,{className:"size-3"}):t.BOOLEAN_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(Ii,{className:"size-3"}):t.jsxRuntimeExports.jsx(wi,{className:"size-3"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{children:t.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:e.data_type})})]})}function Mi({schemaName:e,tableName:n,columns:r,status:i}){const s=t.useEditorStore(p=>p.sqlGen),o=t.useEditorStore(p=>p.actions.setRunSql),l=t.useEditorStore(p=>p.actions.setSqlGen),a=t.useEditorStore(p=>p.actions.setIsShowingVisual),u=t.useEditorStore(p=>p.actions.setCardSql);function c(p){const m=t.createSqlGenConfig(p,s);l(m);const d=t.getSql(m,t.fmt(e),t.fmt(n));d&&(u(d),o(!0))}function x(){let m=t.getQualifiedTableName(e,n);(j=>j.charAt(0)===j.charAt(0).toUpperCase())(n)&&(m=`"${n}"`),a(!1),u(`SELECT * FROM ${m} LIMIT 10`),o(!0)}return t.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-6",children:[t.jsxRuntimeExports.jsx("div",{className:"font-medium",children:t.jsxRuntimeExports.jsxs(t.Button,{disabled:i!=="Success",onClick:x,size:"sm",variant:"secondary",className:"flex w-full",children:[i!=="Success"?t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):t.jsxRuntimeExports.jsx(vi,{className:"mr-2 size-4"}),"Show top 10 rows"]})}),t.jsxRuntimeExports.jsxs(t.ScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",children:[r==null?void 0:r.map(p=>t.jsxRuntimeExports.jsxs("div",{onClick:()=>c(p),className:t.cn("mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":t.isColumnInSqlGen(p,s)}),children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(ur,{column:p}),t.jsxRuntimeExports.jsx("span",{children:p.column_name})]}),t.NUMBER_DATA_TYPES.includes(p.data_type)&&t.jsxRuntimeExports.jsx("div",{onClick:m=>m.stopPropagation(),className:"flex items-center justify-end",children:t.jsxRuntimeExports.jsx(Fi,{column:p})})]},p.column_name)),t.jsxRuntimeExports.jsx(t.ScrollBar,{orientation:"vertical"}),t.jsxRuntimeExports.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function cr({ColumnsComponent:e}){var I;const n=t.useEditorStore(v=>v.selectedConnectionId),r=t.useEditorStore(v=>v.selectedDatabaseName),i=t.useEditorStore(v=>v.selectedSchemaName),s=t.useEditorStore(v=>v.selectedTableName),o=t.useEditorStore(v=>v.actions.setSelectedTableName),{connectionItems:l,schemaItems:a,databaseItems:u,tableItems:c,columns:x,isConnectionsLoading:p,isConnectionsError:m,isDatabasesLoadingOrFetching:d,isDatabaseError:j,isSchemaLoadingOrFetching:E,isSchemaError:k,isColumnsError:y,isColumnsLoadingOrFetching:w,isAPIConnection:R,handleConnectionChange:O,handleDatabaseChange:D,handleSchemaChange:b,tableName:M,schemaName:T}=t.useEditorAside();function z(){return e?e(T,M,x):t.jsxRuntimeExports.jsx(Mi,{schemaName:T,tableName:M,columns:x,status:w?"Loading...":y?"Error":"Success"})}function H(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}return t.jsxRuntimeExports.jsxs("aside",{className:"xbg-red-100 flex grow flex-col justify-between",children:[t.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[t.jsxRuntimeExports.jsx(Ue,{items:l,title:"Connection",value:n||"",onChange:O,isLoading:p,isError:m,connectionTooltip:((I=l==null?void 0:l.find(v=>v.id===n))==null?void 0:I.type)||""}),!R&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Ue,{onChange:D,isError:j,isLoading:d,items:u,value:r||"",title:"Database"}),t.jsxRuntimeExports.jsx(Ue,{onChange:b,isError:k,isLoading:E,items:a,value:i||"",title:"Schema"}),t.jsxRuntimeExports.jsx(Ue,{onChange:o,isError:j,items:c,isLoading:d,value:s||"",title:"Table"})]})]}),z(),t.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center px-6 py-4",children:t.jsxRuntimeExports.jsxs(t.Button,{onClick:H,size:"sm",variant:"secondary",className:"w-full",children:[t.jsxRuntimeExports.jsx(bi,{className:"mr-2 size-4"}),"Help"]})})]})}const Lt=({className:e,...n})=>t.jsxRuntimeExports.jsx(t.PanelGroup,{className:t.cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...n}),Fe=t.Panel,Ot=({withHandle:e,className:n,...r})=>t.jsxRuntimeExports.jsx(t.PanelResizeHandle,{className:t.cn("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",n),...r,children:e&&t.jsxRuntimeExports.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsxRuntimeExports.jsx(mi,{className:"h-2.5 w-2.5"})})});function Pi(e){const n=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),i=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let o=e.length;if(s!==-1&&(o=s),i!==-1&&i<o&&(o=i),n!==-1){const l=e.substring(0,n),a=e.substring(n);return`${l} {{ filters | where }} AND ${a.substring(6)}`}else if(r!==-1){const l=e.substring(0,r),a=e.substring(r);return`${l} {{ filters | where }} ${a}`}else{const l=e.substring(0,o),a=e.substring(o);return`${l} {{ filters | where }} ${a}`}}function Bi({error:e,setShowAIDialog:n,setUserInputforAI:r,setTriggerAIRun:i}){return t.jsxRuntimeExports.jsxs(t.HoverCard,{openDelay:0,children:[t.jsxRuntimeExports.jsx(t.HoverCardTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{variant:"link",className:" p-0 h-5",children:t.jsxRuntimeExports.jsx(ci,{className:"h-4 w-4 text-red-500"})})}),t.jsxRuntimeExports.jsx(t.HoverCardContent,{align:"start",className:" min-w-fit max-w-[500px]",children:t.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:t.jsxRuntimeExports.jsxs("div",{className:"grow space-y-1 flex flex-col ",children:[t.jsxRuntimeExports.jsxs(t.Button,{onClick:()=>{n(!0),r(e),i(!0)},size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(hi,{className:"h-4 w-4 mr-2"}),"Fix It"]}),t.jsxRuntimeExports.jsx(t.ScrollArea,{className:" min-h-0 max-h-[250px] overflow-scroll ",children:t.jsxRuntimeExports.jsx("p",{className:" overflow-auto text-sm leading-relaxed font-mono ",children:e})})]})})})]})}function _i({text:e,onCheckedChange:n,checked:r}){return t.jsxRuntimeExports.jsxs("div",{className:"xbg-red-100 ml-6 flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:r,onCheckedChange:n}),t.jsxRuntimeExports.jsx("label",{className:"text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function Vi(){const{authToken:e}=t.useSemaphorContext(),n=A.useRef(null),r=t.useEditorStore(a=>a.applyFilters),[i,s]=A.useState(""),o=t.useEditorStore(a=>a.filterValues),l=t.useEditorStore(a=>a.card.sql);return t.jsxRuntimeExports.jsxs(t.HoverCard,{openDelay:0,onOpenChange:async a=>{if(!a)return;console.log("onOpenChange");const u=await t.postRequest("https://semaphor.cloud/api/v1/filter-sql",(e==null?void 0:e.accessToken)||"",{sql:l,active_filters:o});console.log(u),u.sql?(console.log(u.records),s(u.sql)):s("Error")},children:[t.jsxRuntimeExports.jsx(t.HoverCardTrigger,{asChild:!0,children:r&&t.jsxRuntimeExports.jsx("p",{className:"p-0 text-xs hover:cursor-pointer",children:"| Filter Query"})}),t.jsxRuntimeExports.jsxs(t.HoverCardContent,{align:"end",className:"w-[600px]",children:[t.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:t.jsxRuntimeExports.jsx("div",{className:"rounded-sm bg-muted p-2",children:t.jsxRuntimeExports.jsxs("code",{ref:n,className:"font-mono text-sm",children:[i,t.jsxRuntimeExports.jsx(t.ClipboardCopyIcon,{onClick:()=>t.copyToClipboard(n),className:"ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"})]})})}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[t.jsxRuntimeExports.jsx(t.InfoCircledIcon,{className:"h-4 w-4 opacity-70"}),t.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"A preview of the query with filters applied."})]})]})]})}function Hi(e,n){const r=n||{};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const qi=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ui=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$i={};function cn(e,n){return((n||$i).jsx?Ui:qi).test(e)}const Ki=/[ \t\n\f\r]/g;function Wi(e){return typeof e=="object"?e.type==="text"?pn(e.value):!1:pn(e)}function pn(e){return e.replace(Ki,"")===""}class Ge{constructor(n,r,i){this.property=n,this.normal=r,i&&(this.space=i)}}Ge.prototype.property={};Ge.prototype.normal={};Ge.prototype.space=null;function pr(e,n){const r={},i={};let s=-1;for(;++s<e.length;)Object.assign(r,e[s].property),Object.assign(i,e[s].normal);return new Ge(r,i,n)}function Dt(e){return e.toLowerCase()}class me{constructor(n,r){this.property=n,this.attribute=r}}me.prototype.space=null;me.prototype.boolean=!1;me.prototype.booleanish=!1;me.prototype.overloadedBoolean=!1;me.prototype.number=!1;me.prototype.commaSeparated=!1;me.prototype.spaceSeparated=!1;me.prototype.commaOrSpaceSeparated=!1;me.prototype.mustUseProperty=!1;me.prototype.defined=!1;let Gi=0;const _=Te(),Z=Te(),xr=Te(),S=Te(),K=Te(),Me=Te(),ce=Te();function Te(){return 2**++Gi}const Ft=Object.freeze(Object.defineProperty({__proto__:null,boolean:_,booleanish:Z,commaOrSpaceSeparated:ce,commaSeparated:Me,number:S,overloadedBoolean:xr,spaceSeparated:K},Symbol.toStringTag,{value:"Module"})),bt=Object.keys(Ft);class Wt extends me{constructor(n,r,i,s){let o=-1;if(super(n,r),xn(this,"space",s),typeof i=="number")for(;++o<bt.length;){const l=bt[o];xn(this,bt[o],(i&Ft[l])===Ft[l])}}}Wt.prototype.defined=!0;function xn(e,n,r){r&&(e[n]=r)}const Qi={}.hasOwnProperty;function Be(e){const n={},r={};let i;for(i in e.properties)if(Qi.call(e.properties,i)){const s=e.properties[i],o=new Wt(i,e.transform(e.attributes||{},i),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),n[i]=o,r[Dt(i)]=i,r[Dt(o.attribute)]=i}return new Ge(n,r,e.space)}const dr=Be({space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()},properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),mr=Be({space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()},properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function hr(e,n){return n in e?e[n]:n}function fr(e,n){return hr(e,n.toLowerCase())}const gr=Be({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:fr,properties:{xmlns:null,xmlnsXLink:null}}),jr=Be({transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()},properties:{ariaActiveDescendant:null,ariaAtomic:Z,ariaAutoComplete:null,ariaBusy:Z,ariaChecked:Z,ariaColCount:S,ariaColIndex:S,ariaColSpan:S,ariaControls:K,ariaCurrent:null,ariaDescribedBy:K,ariaDetails:null,ariaDisabled:Z,ariaDropEffect:K,ariaErrorMessage:null,ariaExpanded:Z,ariaFlowTo:K,ariaGrabbed:Z,ariaHasPopup:null,ariaHidden:Z,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:K,ariaLevel:S,ariaLive:null,ariaModal:Z,ariaMultiLine:Z,ariaMultiSelectable:Z,ariaOrientation:null,ariaOwns:K,ariaPlaceholder:null,ariaPosInSet:S,ariaPressed:Z,ariaReadOnly:Z,ariaRelevant:null,ariaRequired:Z,ariaRoleDescription:K,ariaRowCount:S,ariaRowIndex:S,ariaRowSpan:S,ariaSelected:Z,ariaSetSize:S,ariaSort:null,ariaValueMax:S,ariaValueMin:S,ariaValueNow:S,ariaValueText:null,role:null}}),Ji=Be({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:fr,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Me,acceptCharset:K,accessKey:K,action:null,allow:null,allowFullScreen:_,allowPaymentRequest:_,allowUserMedia:_,alt:null,as:null,async:_,autoCapitalize:null,autoComplete:K,autoFocus:_,autoPlay:_,blocking:K,capture:null,charSet:null,checked:_,cite:null,className:K,cols:S,colSpan:null,content:null,contentEditable:Z,controls:_,controlsList:K,coords:S|Me,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_,defer:_,dir:null,dirName:null,disabled:_,download:xr,draggable:Z,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_,formTarget:null,headers:K,height:S,hidden:_,high:S,href:null,hrefLang:null,htmlFor:K,httpEquiv:K,id:null,imageSizes:null,imageSrcSet:null,inert:_,inputMode:null,integrity:null,is:null,isMap:_,itemId:null,itemProp:K,itemRef:K,itemScope:_,itemType:K,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_,low:S,manifest:null,max:null,maxLength:S,media:null,method:null,min:null,minLength:S,multiple:_,muted:_,name:null,nonce:null,noModule:_,noValidate:_,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:_,optimum:S,pattern:null,ping:K,placeholder:null,playsInline:_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_,referrerPolicy:null,rel:K,required:_,reversed:_,rows:S,rowSpan:S,sandbox:K,scope:null,scoped:_,seamless:_,selected:_,shadowRootDelegatesFocus:_,shadowRootMode:null,shape:null,size:S,sizes:null,slot:null,span:S,spellCheck:Z,src:null,srcDoc:null,srcLang:null,srcSet:null,start:S,step:null,style:null,tabIndex:S,target:null,title:null,translate:null,type:null,typeMustMatch:_,useMap:null,value:Z,width:S,wrap:null,align:null,aLink:null,archive:K,axis:null,background:null,bgColor:null,border:S,borderColor:null,bottomMargin:S,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_,declare:_,event:null,face:null,frame:null,frameBorder:null,hSpace:S,leftMargin:S,link:null,longDesc:null,lowSrc:null,marginHeight:S,marginWidth:S,noResize:_,noHref:_,noShade:_,noWrap:_,object:null,profile:null,prompt:null,rev:null,rightMargin:S,rules:null,scheme:null,scrolling:Z,standby:null,summary:null,text:null,topMargin:S,valueType:null,version:null,vAlign:null,vLink:null,vSpace:S,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_,disableRemotePlayback:_,prefix:null,property:null,results:S,security:null,unselectable:null}}),Xi=Be({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:hr,properties:{about:ce,accentHeight:S,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:S,amplitude:S,arabicForm:null,ascent:S,attributeName:null,attributeType:null,azimuth:S,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:S,by:null,calcMode:null,capHeight:S,className:K,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:S,diffuseConstant:S,direction:null,display:null,dur:null,divisor:S,dominantBaseline:null,download:_,dx:null,dy:null,edgeMode:null,editable:null,elevation:S,enableBackground:null,end:null,event:null,exponent:S,externalResourcesRequired:null,fill:null,fillOpacity:S,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Me,g2:Me,glyphName:Me,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:S,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:S,horizOriginX:S,horizOriginY:S,id:null,ideographic:S,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:S,k:S,k1:S,k2:S,k3:S,k4:S,kernelMatrix:ce,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:S,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:S,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:S,overlineThickness:S,paintOrder:null,panose1:null,path:null,pathLength:S,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:K,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:S,pointsAtY:S,pointsAtZ:S,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ce,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ce,rev:ce,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ce,requiredFeatures:ce,requiredFonts:ce,requiredFormats:ce,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:S,specularExponent:S,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:S,strikethroughThickness:S,string:null,stroke:null,strokeDashArray:ce,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:S,strokeOpacity:S,strokeWidth:null,style:null,surfaceScale:S,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ce,tabIndex:S,tableValues:null,target:null,targetX:S,targetY:S,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ce,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:S,underlineThickness:S,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:S,values:null,vAlphabetic:S,vMathematical:S,vectorEffect:null,vHanging:S,vIdeographic:S,version:null,vertAdvY:S,vertOriginX:S,vertOriginY:S,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:S,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),Yi=/^data[-\w.:]+$/i,dn=/-[a-z]/g,Zi=/[A-Z]/g;function es(e,n){const r=Dt(n);let i=n,s=me;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&Yi.test(n)){if(n.charAt(4)==="-"){const o=n.slice(5).replace(dn,ns);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=n.slice(4);if(!dn.test(o)){let l=o.replace(Zi,ts);l.charAt(0)!=="-"&&(l="-"+l),n="data"+l}}s=Wt}return new s(i,n)}function ts(e){return"-"+e.toLowerCase()}function ns(e){return e.charAt(1).toUpperCase()}const rs={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},is=pr([mr,dr,gr,jr,Ji],"html"),Gt=pr([mr,dr,gr,jr,Xi],"svg");function ss(e){return e.join(" ").trim()}var yr={},mn=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,os=/\n/g,ls=/^\s*/,as=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,us=/^:\s*/,cs=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,ps=/^[;\s]*/,xs=/^\s+|\s+$/g,ds=`
|
|
162
|
-
`,hn="/",fn="*",Ae="",ms="comment",hs="declaration",fs=function(e,n){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];n=n||{};var r=1,i=1;function s(j){var E=j.match(os);E&&(r+=E.length);var k=j.lastIndexOf(ds);i=~k?j.length-k:i+j.length}function o(){var j={line:r,column:i};return function(E){return E.position=new l(j),c(),E}}function l(j){this.start=j,this.end={line:r,column:i},this.source=n.source}l.prototype.content=e;function a(j){var E=new Error(n.source+":"+r+":"+i+": "+j);if(E.reason=j,E.filename=n.source,E.line=r,E.column=i,E.source=e,!n.silent)throw E}function u(j){var E=j.exec(e);if(E){var k=E[0];return s(k),e=e.slice(k.length),E}}function c(){u(ls)}function x(j){var E;for(j=j||[];E=p();)E!==!1&&j.push(E);return j}function p(){var j=o();if(!(hn!=e.charAt(0)||fn!=e.charAt(1))){for(var E=2;Ae!=e.charAt(E)&&(fn!=e.charAt(E)||hn!=e.charAt(E+1));)++E;if(E+=2,Ae===e.charAt(E-1))return a("End of comment missing");var k=e.slice(2,E-2);return i+=2,s(k),e=e.slice(E),i+=2,j({type:ms,comment:k})}}function m(){var j=o(),E=u(as);if(E){if(p(),!u(us))return a("property missing ':'");var k=u(cs),y=j({type:hs,property:gn(E[0].replace(mn,Ae)),value:k?gn(k[0].replace(mn,Ae)):Ae});return u(ps),y}}function d(){var j=[];x(j);for(var E;E=m();)E!==!1&&(j.push(E),x(j));return j}return c(),d()};function gn(e){return e?e.replace(xs,Ae):Ae}var gs=t.commonjsGlobal&&t.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yr,"__esModule",{value:!0});var js=gs(fs);function ys(e,n){var r=null;if(!e||typeof e!="string")return r;var i=(0,js.default)(e),s=typeof n=="function";return i.forEach(function(o){if(o.type==="declaration"){var l=o.property,a=o.value;s?n(l,a,o):a&&(r=r||{},r[l]=a)}}),r}var jn=yr.default=ys;const Es=jn.default||jn,Er=br("end"),Qt=br("start");function br(e){return n;function n(r){const i=r&&r.position&&r.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function bs(e){const n=Qt(e),r=Er(e);if(n&&r)return{start:n,end:r}}function $e(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?yn(e.position):"start"in e||"end"in e?yn(e):"line"in e||"column"in e?Mt(e):""}function Mt(e){return En(e&&e.line)+":"+En(e&&e.column)}function yn(e){return Mt(e&&e.start)+"-"+Mt(e&&e.end)}function En(e){return e&&typeof e=="number"?e:1}class ie extends Error{constructor(n,r,i){super(),typeof r=="string"&&(i=r,r=void 0);let s="",o={},l=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),typeof n=="string"?s=n:!o.cause&&n&&(l=!0,s=n.message,o.cause=n),!o.ruleId&&!o.source&&typeof i=="string"){const u=i.indexOf(":");u===-1?o.ruleId=i:(o.source=i.slice(0,u),o.ruleId=i.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=s,this.line=a?a.line:void 0,this.name=$e(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=l&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}ie.prototype.file="";ie.prototype.name="";ie.prototype.reason="";ie.prototype.message="";ie.prototype.stack="";ie.prototype.column=void 0;ie.prototype.line=void 0;ie.prototype.ancestors=void 0;ie.prototype.cause=void 0;ie.prototype.fatal=void 0;ie.prototype.place=void 0;ie.prototype.ruleId=void 0;ie.prototype.source=void 0;const Jt={}.hasOwnProperty,ks=new Map,Ss=/[A-Z]/g,Rs=/-([a-z])/g,Cs=new Set(["table","tbody","thead","tfoot","tr"]),ws=new Set(["td","th"]),kr="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function vs(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=Ds(r,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=Os(r,n.jsx,n.jsxs)}const s={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Gt:is,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},o=Sr(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function Sr(e,n,r){if(n.type==="element")return Ns(e,n,r);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Is(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Ts(e,n,r);if(n.type==="mdxjsEsm")return As(e,n);if(n.type==="root")return zs(e,n,r);if(n.type==="text")return Ls(e,n)}function Ns(e,n,r){const i=e.schema;let s=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(s=Gt,e.schema=s),e.ancestors.push(n);const o=Cr(e,n.tagName,!1),l=Fs(e,n);let a=Yt(e,n);return Cs.has(n.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!Wi(u):!0})),Rr(e,l,o,n),Xt(l,a),e.ancestors.pop(),e.schema=i,e.create(n,o,l,r)}function Is(e,n){if(n.data&&n.data.estree&&e.evaluater){const i=n.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}We(e,n.position)}function As(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);We(e,n.position)}function Ts(e,n,r){const i=e.schema;let s=i;n.name==="svg"&&i.space==="html"&&(s=Gt,e.schema=s),e.ancestors.push(n);const o=n.name===null?e.Fragment:Cr(e,n.name,!0),l=Ms(e,n),a=Yt(e,n);return Rr(e,l,o,n),Xt(l,a),e.ancestors.pop(),e.schema=i,e.create(n,o,l,r)}function zs(e,n,r){const i={};return Xt(i,Yt(e,n)),e.create(n,e.Fragment,i,r)}function Ls(e,n){return n.value}function Rr(e,n,r,i){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(n.node=i)}function Xt(e,n){if(n.length>0){const r=n.length>1?n:n[0];r&&(e.children=r)}}function Os(e,n,r){return i;function i(s,o,l,a){const c=Array.isArray(l.children)?r:n;return a?c(o,l,a):c(o,l)}}function Ds(e,n){return r;function r(i,s,o,l){const a=Array.isArray(o.children),u=Qt(i);return n(s,o,l,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function Fs(e,n){const r={};let i,s;for(s in n.properties)if(s!=="children"&&Jt.call(n.properties,s)){const o=Ps(e,s,n.properties[s]);if(o){const[l,a]=o;e.tableCellAlignToStyle&&l==="align"&&typeof a=="string"&&ws.has(n.tagName)?i=a:r[l]=a}}if(i){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return r}function Ms(e,n){const r={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const o=i.data.estree.body[0];o.type;const l=o.expression;l.type;const a=l.properties[0];a.type,Object.assign(r,e.evaluater.evaluateExpression(a.argument))}else We(e,n.position);else{const s=i.name;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const a=i.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else We(e,n.position);else o=i.value===null?!0:i.value;r[s]=o}return r}function Yt(e,n){const r=[];let i=-1;const s=e.passKeys?new Map:ks;for(;++i<n.children.length;){const o=n.children[i];let l;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const c=s.get(u)||0;l=u+"-"+c,s.set(u,c+1)}}const a=Sr(e,o,l);a!==void 0&&r.push(a)}return r}function Ps(e,n,r){const i=es(e.schema,n);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=i.commaSeparated?Hi(r):ss(r)),i.property==="style"){let s=typeof r=="object"?r:Bs(e,String(r));return e.stylePropertyNameCase==="css"&&(s=_s(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&i.space?rs[i.property]||i.property:i.attribute,r]}}function Bs(e,n){const r={};try{Es(n,i)}catch(s){if(!e.ignoreInvalidStyle){const o=s,l=new ie("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:o,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=kr+"#cannot-parse-style-attribute",l}}return r;function i(s,o){let l=s;l.slice(0,2)!=="--"&&(l.slice(0,4)==="-ms-"&&(l="ms-"+l.slice(4)),l=l.replace(Rs,Hs)),r[l]=o}}function Cr(e,n,r){let i;if(!r)i={type:"Literal",value:n};else if(n.includes(".")){const s=n.split(".");let o=-1,l;for(;++o<s.length;){const a=cn(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};l=l?{type:"MemberExpression",object:l,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}i=l}else i=cn(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const s=i.value;return Jt.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(i);We(e)}function We(e,n){const r=new ie("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=kr+"#cannot-handle-mdx-estrees-without-createevaluater",r}function _s(e){const n={};let r;for(r in e)Jt.call(e,r)&&(n[Vs(r)]=e[r]);return n}function Vs(e){let n=e.replace(Ss,qs);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function Hs(e,n){return n.toUpperCase()}function qs(e){return"-"+e.toLowerCase()}const kt={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Us={};function $s(e,n){const r=n||Us,i=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,s=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return wr(e,i,s)}function wr(e,n,r){if(Ks(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return bn(e.children,n,r)}return Array.isArray(e)?bn(e,n,r):""}function bn(e,n,r){const i=[];let s=-1;for(;++s<e.length;)i[s]=wr(e[s],n,r);return i.join("")}function Ks(e){return!!(e&&typeof e=="object")}const kn=document.createElement("i");function Zt(e){const n="&"+e+";";kn.innerHTML=n;const r=kn.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===n?!1:r}function be(e,n,r,i){const s=e.length;let o=0,l;if(n<0?n=-n>s?0:s+n:n=n>s?s:n,r=r>0?r:0,i.length<1e4)l=Array.from(i),l.unshift(n,r),e.splice(...l);else for(r&&e.splice(n,r);o<i.length;)l=i.slice(o,o+1e4),l.unshift(n,0),e.splice(...l),o+=1e4,n+=1e4}function de(e,n){return e.length>0?(be(e,e.length,0,n),e):n}const Sn={}.hasOwnProperty;function Ws(e){const n={};let r=-1;for(;++r<e.length;)Gs(n,e[r]);return n}function Gs(e,n){let r;for(r in n){const s=(Sn.call(e,r)?e[r]:void 0)||(e[r]={}),o=n[r];let l;if(o)for(l in o){Sn.call(s,l)||(s[l]=[]);const a=o[l];Qs(s[l],Array.isArray(a)?a:a?[a]:[])}}}function Qs(e,n){let r=-1;const i=[];for(;++r<n.length;)(n[r].add==="after"?e:i).push(n[r]);be(e,0,0,i)}function vr(e,n){const r=Number.parseInt(e,n);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Pe(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Js=Ne(new RegExp("\\p{P}","u")),Ee=Ne(/[A-Za-z]/),pe=Ne(/[\dA-Za-z]/),Xs=Ne(/[#-'*+\--9=?A-Z^-~]/);function Pt(e){return e!==null&&(e<32||e===127)}const Bt=Ne(/\d/),Ys=Ne(/[\dA-Fa-f]/),Nr=Ne(/[!-/:-@[-`{-~]/);function F(e){return e!==null&&e<-2}function le(e){return e!==null&&(e<0||e===32)}function U(e){return e===-2||e===-1||e===32}function Zs(e){return Nr(e)||Js(e)}const eo=Ne(/\s/);function Ne(e){return n;function n(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function _e(e){const n=[];let r=-1,i=0,s=0;for(;++r<e.length;){const o=e.charCodeAt(r);let l="";if(o===37&&pe(e.charCodeAt(r+1))&&pe(e.charCodeAt(r+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(l=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(r+1);o<56320&&a>56319&&a<57344?(l=String.fromCharCode(o,a),s=1):l="�"}else l=String.fromCharCode(o);l&&(n.push(e.slice(i,r),encodeURIComponent(l)),i=r+s+1,l=""),s&&(r+=s,s=0)}return n.join("")+e.slice(i)}function W(e,n,r,i){const s=i?i-1:Number.POSITIVE_INFINITY;let o=0;return l;function l(u){return U(u)?(e.enter(r),a(u)):n(u)}function a(u){return U(u)&&o++<s?(e.consume(u),a):(e.exit(r),n(u))}}const to={tokenize:no};function no(e){const n=e.attempt(this.parser.constructs.contentInitial,i,s);let r;return n;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),W(e,n,"linePrefix")}function s(a){return e.enter("paragraph"),o(a)}function o(a){const u=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=u),r=u,l(a)}function l(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return F(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),l)}}const ro={tokenize:io},Rn={tokenize:so};function io(e){const n=this,r=[];let i=0,s,o,l;return a;function a(R){if(i<r.length){const O=r[i];return n.containerState=O[1],e.attempt(O[0].continuation,u,c)(R)}return c(R)}function u(R){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,s&&w();const O=n.events.length;let D=O,b;for(;D--;)if(n.events[D][0]==="exit"&&n.events[D][1].type==="chunkFlow"){b=n.events[D][1].end;break}y(i);let M=O;for(;M<n.events.length;)n.events[M][1].end=Object.assign({},b),M++;return be(n.events,D+1,0,n.events.slice(O)),n.events.length=M,c(R)}return a(R)}function c(R){if(i===r.length){if(!s)return m(R);if(s.currentConstruct&&s.currentConstruct.concrete)return j(R);n.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Rn,x,p)(R)}function x(R){return s&&w(),y(i),m(R)}function p(R){return n.parser.lazy[n.now().line]=i!==r.length,l=n.now().offset,j(R)}function m(R){return n.containerState={},e.attempt(Rn,d,j)(R)}function d(R){return i++,r.push([n.currentConstruct,n.containerState]),m(R)}function j(R){if(R===null){s&&w(),y(0),e.consume(R);return}return s=s||n.parser.flow(n.now()),e.enter("chunkFlow",{contentType:"flow",previous:o,_tokenizer:s}),E(R)}function E(R){if(R===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(R);return}return F(R)?(e.consume(R),k(e.exit("chunkFlow")),i=0,n.interrupt=void 0,a):(e.consume(R),E)}function k(R,O){const D=n.sliceStream(R);if(O&&D.push(null),R.previous=o,o&&(o.next=R),o=R,s.defineSkip(R.start),s.write(D),n.parser.lazy[R.start.line]){let b=s.events.length;for(;b--;)if(s.events[b][1].start.offset<l&&(!s.events[b][1].end||s.events[b][1].end.offset>l))return;const M=n.events.length;let T=M,z,H;for(;T--;)if(n.events[T][0]==="exit"&&n.events[T][1].type==="chunkFlow"){if(z){H=n.events[T][1].end;break}z=!0}for(y(i),b=M;b<n.events.length;)n.events[b][1].end=Object.assign({},H),b++;be(n.events,T+1,0,n.events.slice(M)),n.events.length=b}}function y(R){let O=r.length;for(;O-- >R;){const D=r[O];n.containerState=D[1],D[0].exit.call(n,e)}r.length=R}function w(){s.write([null]),o=void 0,s=void 0,n.containerState._closeFlow=void 0}}function so(e,n,r){return W(e,e.attempt(this.parser.constructs.document,n,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Cn(e){if(e===null||le(e)||eo(e))return 1;if(Zs(e))return 2}function en(e,n,r){const i=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!i.includes(o)&&(n=o(n,r),i.push(o))}return n}const _t={name:"attention",tokenize:lo,resolveAll:oo};function oo(e,n){let r=-1,i,s,o,l,a,u,c,x;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(i=r;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[i][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;u=e[i][1].end.offset-e[i][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p=Object.assign({},e[i][1].end),m=Object.assign({},e[r][1].start);wn(p,-u),wn(m,u),l={type:u>1?"strongSequence":"emphasisSequence",start:p,end:Object.assign({},e[i][1].end)},a={type:u>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[r][1].start),end:m},o={type:u>1?"strongText":"emphasisText",start:Object.assign({},e[i][1].end),end:Object.assign({},e[r][1].start)},s={type:u>1?"strong":"emphasis",start:Object.assign({},l.start),end:Object.assign({},a.end)},e[i][1].end=Object.assign({},l.start),e[r][1].start=Object.assign({},a.end),c=[],e[i][1].end.offset-e[i][1].start.offset&&(c=de(c,[["enter",e[i][1],n],["exit",e[i][1],n]])),c=de(c,[["enter",s,n],["enter",l,n],["exit",l,n],["enter",o,n]]),c=de(c,en(n.parser.constructs.insideSpan.null,e.slice(i+1,r),n)),c=de(c,[["exit",o,n],["enter",a,n],["exit",a,n],["exit",s,n]]),e[r][1].end.offset-e[r][1].start.offset?(x=2,c=de(c,[["enter",e[r][1],n],["exit",e[r][1],n]])):x=0,be(e,i-1,r-i+3,c),r=i+c.length-x-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function lo(e,n){const r=this.parser.constructs.attentionMarkers.null,i=this.previous,s=Cn(i);let o;return l;function l(u){return o=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===o)return e.consume(u),a;const c=e.exit("attentionSequence"),x=Cn(u),p=!x||x===2&&s||r.includes(u),m=!s||s===2&&x||r.includes(i);return c._open=!!(o===42?p:p&&(s||!m)),c._close=!!(o===42?m:m&&(x||!p)),n(u)}}function wn(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const ao={name:"autolink",tokenize:uo};function uo(e,n,r){let i=0;return s;function s(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(d){return Ee(d)?(e.consume(d),l):c(d)}function l(d){return d===43||d===45||d===46||pe(d)?(i=1,a(d)):c(d)}function a(d){return d===58?(e.consume(d),i=0,u):(d===43||d===45||d===46||pe(d))&&i++<32?(e.consume(d),a):(i=0,c(d))}function u(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),n):d===null||d===32||d===60||Pt(d)?r(d):(e.consume(d),u)}function c(d){return d===64?(e.consume(d),x):Xs(d)?(e.consume(d),c):r(d)}function x(d){return pe(d)?p(d):r(d)}function p(d){return d===46?(e.consume(d),i=0,x):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),n):m(d)}function m(d){if((d===45||pe(d))&&i++<63){const j=d===45?m:p;return e.consume(d),j}return r(d)}}const pt={tokenize:co,partial:!0};function co(e,n,r){return i;function i(o){return U(o)?W(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||F(o)?n(o):r(o)}}const Ir={name:"blockQuote",tokenize:po,continuation:{tokenize:xo},exit:mo};function po(e,n,r){const i=this;return s;function s(l){if(l===62){const a=i.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),o}return r(l)}function o(l){return U(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(l))}}function xo(e,n,r){const i=this;return s;function s(l){return U(l)?W(e,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):o(l)}function o(l){return e.attempt(Ir,n,r)(l)}}function mo(e){e.exit("blockQuote")}const Ar={name:"characterEscape",tokenize:ho};function ho(e,n,r){return i;function i(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return Nr(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):r(o)}}const Tr={name:"characterReference",tokenize:fo};function fo(e,n,r){const i=this;let s=0,o,l;return a;function a(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),o=31,l=pe,x(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,l=Ys,x):(e.enter("characterReferenceValue"),o=7,l=Bt,x(p))}function x(p){if(p===59&&s){const m=e.exit("characterReferenceValue");return l===pe&&!Zt(i.sliceSerialize(m))?r(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return l(p)&&s++<o?(e.consume(p),x):r(p)}}const vn={tokenize:jo,partial:!0},Nn={name:"codeFenced",tokenize:go,concrete:!0};function go(e,n,r){const i=this,s={tokenize:D,partial:!0};let o=0,l=0,a;return u;function u(b){return c(b)}function c(b){const M=i.events[i.events.length-1];return o=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,a=b,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(b)}function x(b){return b===a?(l++,e.consume(b),x):l<3?r(b):(e.exit("codeFencedFenceSequence"),U(b)?W(e,p,"whitespace")(b):p(b))}function p(b){return b===null||F(b)?(e.exit("codeFencedFence"),i.interrupt?n(b):e.check(vn,E,O)(b)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===null||F(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(b)):U(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),W(e,d,"whitespace")(b)):b===96&&b===a?r(b):(e.consume(b),m)}function d(b){return b===null||F(b)?p(b):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(b))}function j(b){return b===null||F(b)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(b)):b===96&&b===a?r(b):(e.consume(b),j)}function E(b){return e.attempt(s,O,k)(b)}function k(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),y}function y(b){return o>0&&U(b)?W(e,w,"linePrefix",o+1)(b):w(b)}function w(b){return b===null||F(b)?e.check(vn,E,O)(b):(e.enter("codeFlowValue"),R(b))}function R(b){return b===null||F(b)?(e.exit("codeFlowValue"),w(b)):(e.consume(b),R)}function O(b){return e.exit("codeFenced"),n(b)}function D(b,M,T){let z=0;return H;function H(V){return b.enter("lineEnding"),b.consume(V),b.exit("lineEnding"),I}function I(V){return b.enter("codeFencedFence"),U(V)?W(b,v,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):v(V)}function v(V){return V===a?(b.enter("codeFencedFenceSequence"),q(V)):T(V)}function q(V){return V===a?(z++,b.consume(V),q):z>=l?(b.exit("codeFencedFenceSequence"),U(V)?W(b,$,"whitespace")(V):$(V)):T(V)}function $(V){return V===null||F(V)?(b.exit("codeFencedFence"),M(V)):T(V)}}}function jo(e,n,r){const i=this;return s;function s(l){return l===null?r(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o)}function o(l){return i.parser.lazy[i.now().line]?r(l):n(l)}}const St={name:"codeIndented",tokenize:Eo},yo={tokenize:bo,partial:!0};function Eo(e,n,r){const i=this;return s;function s(c){return e.enter("codeIndented"),W(e,o,"linePrefix",5)(c)}function o(c){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?l(c):r(c)}function l(c){return c===null?u(c):F(c)?e.attempt(yo,l,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||F(c)?(e.exit("codeFlowValue"),l(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),n(c)}}function bo(e,n,r){const i=this;return s;function s(l){return i.parser.lazy[i.now().line]?r(l):F(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s):W(e,o,"linePrefix",5)(l)}function o(l){const a=i.events[i.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(l):F(l)?s(l):r(l)}}const ko={name:"codeText",tokenize:Co,resolve:So,previous:Ro};function So(e){let n=e.length-4,r=3,i,s;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=r;++i<n;)if(e[i][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[n][1].type="codeTextPadding",r+=2,n-=2;break}}for(i=r-1,n++;++i<=n;)s===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(s=i):(i===n||e[i][1].type==="lineEnding")&&(e[s][1].type="codeTextData",i!==s+2&&(e[s][1].end=e[i-1][1].end,e.splice(s+2,i-s-2),n-=i-s-2,i=s+2),s=void 0);return e}function Ro(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Co(e,n,r){let i=0,s,o;return l;function l(p){return e.enter("codeText"),e.enter("codeTextSequence"),a(p)}function a(p){return p===96?(e.consume(p),i++,a):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?r(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(o=e.enter("codeTextSequence"),s=0,x(p)):F(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(p))}function c(p){return p===null||p===32||p===96||F(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),c)}function x(p){return p===96?(e.consume(p),s++,x):s===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(p)):(o.type="codeTextData",c(p))}}function zr(e){const n={};let r=-1,i,s,o,l,a,u,c;for(;++r<e.length;){for(;r in n;)r=n[r];if(i=e[r],r&&i[1].type==="chunkFlow"&&e[r-1][1].type==="listItemPrefix"&&(u=i[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,wo(e,r)),r=n[r],c=!0);else if(i[1]._container){for(o=r,s=void 0;o--&&(l=e[o],l[1].type==="lineEnding"||l[1].type==="lineEndingBlank");)l[0]==="enter"&&(s&&(e[s][1].type="lineEndingBlank"),l[1].type="lineEnding",s=o);s&&(i[1].end=Object.assign({},e[s][1].start),a=e.slice(s,r),a.unshift(i),be(e,s,r-s+1,a))}}return!c}function wo(e,n){const r=e[n][1],i=e[n][2];let s=n-1;const o=[],l=r._tokenizer||i.parser[r.contentType](r.start),a=l.events,u=[],c={};let x,p,m=-1,d=r,j=0,E=0;const k=[E];for(;d;){for(;e[++s][1]!==d;);o.push(s),d._tokenizer||(x=i.sliceStream(d),d.next||x.push(null),p&&l.defineSkip(d.start),d._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(x),d._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),p=d,d=d.next}for(d=r;++m<a.length;)a[m][0]==="exit"&&a[m-1][0]==="enter"&&a[m][1].type===a[m-1][1].type&&a[m][1].start.line!==a[m][1].end.line&&(E=m+1,k.push(E),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(l.events=[],d?(d._tokenizer=void 0,d.previous=void 0):k.pop(),m=k.length;m--;){const y=a.slice(k[m],k[m+1]),w=o.pop();u.unshift([w,w+y.length-1]),be(e,w,2,y)}for(m=-1;++m<u.length;)c[j+u[m][0]]=j+u[m][1],j+=u[m][1]-u[m][0]-1;return c}const vo={tokenize:Ao,resolve:Io},No={tokenize:To,partial:!0};function Io(e){return zr(e),e}function Ao(e,n){let r;return i;function i(a){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?o(a):F(a)?e.check(No,l,o)(a):(e.consume(a),s)}function o(a){return e.exit("chunkContent"),e.exit("content"),n(a)}function l(a){return e.consume(a),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}function To(e,n,r){const i=this;return s;function s(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),W(e,o,"linePrefix")}function o(l){if(l===null||F(l))return r(l);const a=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(l):e.interrupt(i.parser.constructs.flow,r,n)(l)}}function Lr(e,n,r,i,s,o,l,a,u){const c=u||Number.POSITIVE_INFINITY;let x=0;return p;function p(y){return y===60?(e.enter(i),e.enter(s),e.enter(o),e.consume(y),e.exit(o),m):y===null||y===32||y===41||Pt(y)?r(y):(e.enter(i),e.enter(l),e.enter(a),e.enter("chunkString",{contentType:"string"}),E(y))}function m(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),e.exit(i),n):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(y))}function d(y){return y===62?(e.exit("chunkString"),e.exit(a),m(y)):y===null||y===60||F(y)?r(y):(e.consume(y),y===92?j:d)}function j(y){return y===60||y===62||y===92?(e.consume(y),d):d(y)}function E(y){return!x&&(y===null||y===41||le(y))?(e.exit("chunkString"),e.exit(a),e.exit(l),e.exit(i),n(y)):x<c&&y===40?(e.consume(y),x++,E):y===41?(e.consume(y),x--,E):y===null||y===32||y===40||Pt(y)?r(y):(e.consume(y),y===92?k:E)}function k(y){return y===40||y===41||y===92?(e.consume(y),E):E(y)}}function Or(e,n,r,i,s,o){const l=this;let a=0,u;return c;function c(d){return e.enter(i),e.enter(s),e.consume(d),e.exit(s),e.enter(o),x}function x(d){return a>999||d===null||d===91||d===93&&!u||d===94&&!a&&"_hiddenFootnoteSupport"in l.parser.constructs?r(d):d===93?(e.exit(o),e.enter(s),e.consume(d),e.exit(s),e.exit(i),n):F(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===null||d===91||d===93||F(d)||a++>999?(e.exit("chunkString"),x(d)):(e.consume(d),u||(u=!U(d)),d===92?m:p)}function m(d){return d===91||d===92||d===93?(e.consume(d),a++,p):p(d)}}function Dr(e,n,r,i,s,o){let l;return a;function a(m){return m===34||m===39||m===40?(e.enter(i),e.enter(s),e.consume(m),e.exit(s),l=m===40?41:m,u):r(m)}function u(m){return m===l?(e.enter(s),e.consume(m),e.exit(s),e.exit(i),n):(e.enter(o),c(m))}function c(m){return m===l?(e.exit(o),u(l)):m===null?r(m):F(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),W(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(m))}function x(m){return m===l||m===null||F(m)?(e.exit("chunkString"),c(m)):(e.consume(m),m===92?p:x)}function p(m){return m===l||m===92?(e.consume(m),x):x(m)}}function Ke(e,n){let r;return i;function i(s){return F(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),r=!0,i):U(s)?W(e,i,r?"linePrefix":"lineSuffix")(s):n(s)}}const zo={name:"definition",tokenize:Oo},Lo={tokenize:Do,partial:!0};function Oo(e,n,r){const i=this;let s;return o;function o(d){return e.enter("definition"),l(d)}function l(d){return Or.call(i,e,a,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return s=Pe(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),d===58?(e.enter("definitionMarker"),e.consume(d),e.exit("definitionMarker"),u):r(d)}function u(d){return le(d)?Ke(e,c)(d):c(d)}function c(d){return Lr(e,x,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function x(d){return e.attempt(Lo,p,p)(d)}function p(d){return U(d)?W(e,m,"whitespace")(d):m(d)}function m(d){return d===null||F(d)?(e.exit("definition"),i.parser.defined.push(s),n(d)):r(d)}}function Do(e,n,r){return i;function i(a){return le(a)?Ke(e,s)(a):r(a)}function s(a){return Dr(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return U(a)?W(e,l,"whitespace")(a):l(a)}function l(a){return a===null||F(a)?n(a):r(a)}}const Fo={name:"hardBreakEscape",tokenize:Mo};function Mo(e,n,r){return i;function i(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return F(o)?(e.exit("hardBreakEscape"),n(o)):r(o)}}const Po={name:"headingAtx",tokenize:_o,resolve:Bo};function Bo(e,n){let r=e.length-2,i=3,s,o;return e[i][1].type==="whitespace"&&(i+=2),r-2>i&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(i===r-1||r-4>i&&e[r-2][1].type==="whitespace")&&(r-=i+1===r?2:4),r>i&&(s={type:"atxHeadingText",start:e[i][1].start,end:e[r][1].end},o={type:"chunkText",start:e[i][1].start,end:e[r][1].end,contentType:"text"},be(e,i,r-i+1,[["enter",s,n],["enter",o,n],["exit",o,n],["exit",s,n]])),e}function _o(e,n,r){let i=0;return s;function s(x){return e.enter("atxHeading"),o(x)}function o(x){return e.enter("atxHeadingSequence"),l(x)}function l(x){return x===35&&i++<6?(e.consume(x),l):x===null||le(x)?(e.exit("atxHeadingSequence"),a(x)):r(x)}function a(x){return x===35?(e.enter("atxHeadingSequence"),u(x)):x===null||F(x)?(e.exit("atxHeading"),n(x)):U(x)?W(e,a,"whitespace")(x):(e.enter("atxHeadingText"),c(x))}function u(x){return x===35?(e.consume(x),u):(e.exit("atxHeadingSequence"),a(x))}function c(x){return x===null||x===35||le(x)?(e.exit("atxHeadingText"),a(x)):(e.consume(x),c)}}const Vo=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],In=["pre","script","style","textarea"],Ho={name:"htmlFlow",tokenize:Ko,resolveTo:$o,concrete:!0},qo={tokenize:Go,partial:!0},Uo={tokenize:Wo,partial:!0};function $o(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function Ko(e,n,r){const i=this;let s,o,l,a,u;return c;function c(f){return x(f)}function x(f){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(f),p}function p(f){return f===33?(e.consume(f),m):f===47?(e.consume(f),o=!0,E):f===63?(e.consume(f),s=3,i.interrupt?n:h):Ee(f)?(e.consume(f),l=String.fromCharCode(f),k):r(f)}function m(f){return f===45?(e.consume(f),s=2,d):f===91?(e.consume(f),s=5,a=0,j):Ee(f)?(e.consume(f),s=4,i.interrupt?n:h):r(f)}function d(f){return f===45?(e.consume(f),i.interrupt?n:h):r(f)}function j(f){const ae="CDATA[";return f===ae.charCodeAt(a++)?(e.consume(f),a===ae.length?i.interrupt?n:v:j):r(f)}function E(f){return Ee(f)?(e.consume(f),l=String.fromCharCode(f),k):r(f)}function k(f){if(f===null||f===47||f===62||le(f)){const ae=f===47,ge=l.toLowerCase();return!ae&&!o&&In.includes(ge)?(s=1,i.interrupt?n(f):v(f)):Vo.includes(l.toLowerCase())?(s=6,ae?(e.consume(f),y):i.interrupt?n(f):v(f)):(s=7,i.interrupt&&!i.parser.lazy[i.now().line]?r(f):o?w(f):R(f))}return f===45||pe(f)?(e.consume(f),l+=String.fromCharCode(f),k):r(f)}function y(f){return f===62?(e.consume(f),i.interrupt?n:v):r(f)}function w(f){return U(f)?(e.consume(f),w):H(f)}function R(f){return f===47?(e.consume(f),H):f===58||f===95||Ee(f)?(e.consume(f),O):U(f)?(e.consume(f),R):H(f)}function O(f){return f===45||f===46||f===58||f===95||pe(f)?(e.consume(f),O):D(f)}function D(f){return f===61?(e.consume(f),b):U(f)?(e.consume(f),D):R(f)}function b(f){return f===null||f===60||f===61||f===62||f===96?r(f):f===34||f===39?(e.consume(f),u=f,M):U(f)?(e.consume(f),b):T(f)}function M(f){return f===u?(e.consume(f),u=null,z):f===null||F(f)?r(f):(e.consume(f),M)}function T(f){return f===null||f===34||f===39||f===47||f===60||f===61||f===62||f===96||le(f)?D(f):(e.consume(f),T)}function z(f){return f===47||f===62||U(f)?R(f):r(f)}function H(f){return f===62?(e.consume(f),I):r(f)}function I(f){return f===null||F(f)?v(f):U(f)?(e.consume(f),I):r(f)}function v(f){return f===45&&s===2?(e.consume(f),G):f===60&&s===1?(e.consume(f),Q):f===62&&s===4?(e.consume(f),J):f===63&&s===3?(e.consume(f),h):f===93&&s===5?(e.consume(f),N):F(f)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(qo,te,q)(f)):f===null||F(f)?(e.exit("htmlFlowData"),q(f)):(e.consume(f),v)}function q(f){return e.check(Uo,$,te)(f)}function $(f){return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),V}function V(f){return f===null||F(f)?q(f):(e.enter("htmlFlowData"),v(f))}function G(f){return f===45?(e.consume(f),h):v(f)}function Q(f){return f===47?(e.consume(f),l="",re):v(f)}function re(f){if(f===62){const ae=l.toLowerCase();return In.includes(ae)?(e.consume(f),J):v(f)}return Ee(f)&&l.length<8?(e.consume(f),l+=String.fromCharCode(f),re):v(f)}function N(f){return f===93?(e.consume(f),h):v(f)}function h(f){return f===62?(e.consume(f),J):f===45&&s===2?(e.consume(f),h):v(f)}function J(f){return f===null||F(f)?(e.exit("htmlFlowData"),te(f)):(e.consume(f),J)}function te(f){return e.exit("htmlFlow"),n(f)}}function Wo(e,n,r){const i=this;return s;function s(l){return F(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):r(l)}function o(l){return i.parser.lazy[i.now().line]?r(l):n(l)}}function Go(e,n,r){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(pt,n,r)}}const Qo={name:"htmlText",tokenize:Jo};function Jo(e,n,r){const i=this;let s,o,l;return a;function a(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),u}function u(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),D):h===63?(e.consume(h),R):Ee(h)?(e.consume(h),T):r(h)}function c(h){return h===45?(e.consume(h),x):h===91?(e.consume(h),o=0,j):Ee(h)?(e.consume(h),w):r(h)}function x(h){return h===45?(e.consume(h),d):r(h)}function p(h){return h===null?r(h):h===45?(e.consume(h),m):F(h)?(l=p,Q(h)):(e.consume(h),p)}function m(h){return h===45?(e.consume(h),d):p(h)}function d(h){return h===62?G(h):h===45?m(h):p(h)}function j(h){const J="CDATA[";return h===J.charCodeAt(o++)?(e.consume(h),o===J.length?E:j):r(h)}function E(h){return h===null?r(h):h===93?(e.consume(h),k):F(h)?(l=E,Q(h)):(e.consume(h),E)}function k(h){return h===93?(e.consume(h),y):E(h)}function y(h){return h===62?G(h):h===93?(e.consume(h),y):E(h)}function w(h){return h===null||h===62?G(h):F(h)?(l=w,Q(h)):(e.consume(h),w)}function R(h){return h===null?r(h):h===63?(e.consume(h),O):F(h)?(l=R,Q(h)):(e.consume(h),R)}function O(h){return h===62?G(h):R(h)}function D(h){return Ee(h)?(e.consume(h),b):r(h)}function b(h){return h===45||pe(h)?(e.consume(h),b):M(h)}function M(h){return F(h)?(l=M,Q(h)):U(h)?(e.consume(h),M):G(h)}function T(h){return h===45||pe(h)?(e.consume(h),T):h===47||h===62||le(h)?z(h):r(h)}function z(h){return h===47?(e.consume(h),G):h===58||h===95||Ee(h)?(e.consume(h),H):F(h)?(l=z,Q(h)):U(h)?(e.consume(h),z):G(h)}function H(h){return h===45||h===46||h===58||h===95||pe(h)?(e.consume(h),H):I(h)}function I(h){return h===61?(e.consume(h),v):F(h)?(l=I,Q(h)):U(h)?(e.consume(h),I):z(h)}function v(h){return h===null||h===60||h===61||h===62||h===96?r(h):h===34||h===39?(e.consume(h),s=h,q):F(h)?(l=v,Q(h)):U(h)?(e.consume(h),v):(e.consume(h),$)}function q(h){return h===s?(e.consume(h),s=void 0,V):h===null?r(h):F(h)?(l=q,Q(h)):(e.consume(h),q)}function $(h){return h===null||h===34||h===39||h===60||h===61||h===96?r(h):h===47||h===62||le(h)?z(h):(e.consume(h),$)}function V(h){return h===47||h===62||le(h)?z(h):r(h)}function G(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),n):r(h)}function Q(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),re}function re(h){return U(h)?W(e,N,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):N(h)}function N(h){return e.enter("htmlTextData"),l(h)}}const tn={name:"labelEnd",tokenize:nl,resolveTo:tl,resolveAll:el},Xo={tokenize:rl},Yo={tokenize:il},Zo={tokenize:sl};function el(e){let n=-1;for(;++n<e.length;){const r=e[n][1];(r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd")&&(e.splice(n+1,r.type==="labelImage"?4:2),r.type="data",n++)}return e}function tl(e,n){let r=e.length,i=0,s,o,l,a;for(;r--;)if(s=e[r][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[r][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(l){if(e[r][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=r,s.type!=="labelLink")){i=2;break}}else s.type==="labelEnd"&&(l=r);const u={type:e[o][1].type==="labelLink"?"link":"image",start:Object.assign({},e[o][1].start),end:Object.assign({},e[e.length-1][1].end)},c={type:"label",start:Object.assign({},e[o][1].start),end:Object.assign({},e[l][1].end)},x={type:"labelText",start:Object.assign({},e[o+i+2][1].end),end:Object.assign({},e[l-2][1].start)};return a=[["enter",u,n],["enter",c,n]],a=de(a,e.slice(o+1,o+i+3)),a=de(a,[["enter",x,n]]),a=de(a,en(n.parser.constructs.insideSpan.null,e.slice(o+i+4,l-3),n)),a=de(a,[["exit",x,n],e[l-2],e[l-1],["exit",c,n]]),a=de(a,e.slice(l+1)),a=de(a,[["exit",u,n]]),be(e,o,e.length,a),e}function nl(e,n,r){const i=this;let s=i.events.length,o,l;for(;s--;)if((i.events[s][1].type==="labelImage"||i.events[s][1].type==="labelLink")&&!i.events[s][1]._balanced){o=i.events[s][1];break}return a;function a(m){return o?o._inactive?p(m):(l=i.parser.defined.includes(Pe(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),u):r(m)}function u(m){return m===40?e.attempt(Xo,x,l?x:p)(m):m===91?e.attempt(Yo,x,l?c:p)(m):l?x(m):p(m)}function c(m){return e.attempt(Zo,x,p)(m)}function x(m){return n(m)}function p(m){return o._balanced=!0,r(m)}}function rl(e,n,r){return i;function i(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),s}function s(p){return le(p)?Ke(e,o)(p):o(p)}function o(p){return p===41?x(p):Lr(e,l,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function l(p){return le(p)?Ke(e,u)(p):x(p)}function a(p){return r(p)}function u(p){return p===34||p===39||p===40?Dr(e,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):x(p)}function c(p){return le(p)?Ke(e,x)(p):x(p)}function x(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),n):r(p)}}function il(e,n,r){const i=this;return s;function s(a){return Or.call(i,e,o,l,"reference","referenceMarker","referenceString")(a)}function o(a){return i.parser.defined.includes(Pe(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(a):r(a)}function l(a){return r(a)}}function sl(e,n,r){return i;function i(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),n):r(o)}}const ol={name:"labelStartImage",tokenize:ll,resolveAll:tn.resolveAll};function ll(e,n,r){const i=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),l):r(a)}function l(a){return a===94&&"_hiddenFootnoteSupport"in i.parser.constructs?r(a):n(a)}}const al={name:"labelStartLink",tokenize:ul,resolveAll:tn.resolveAll};function ul(e,n,r){const i=this;return s;function s(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),o}function o(l){return l===94&&"_hiddenFootnoteSupport"in i.parser.constructs?r(l):n(l)}}const Rt={name:"lineEnding",tokenize:cl};function cl(e,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),W(e,n,"linePrefix")}}const it={name:"thematicBreak",tokenize:pl};function pl(e,n,r){let i=0,s;return o;function o(c){return e.enter("thematicBreak"),l(c)}function l(c){return s=c,a(c)}function a(c){return c===s?(e.enter("thematicBreakSequence"),u(c)):i>=3&&(c===null||F(c))?(e.exit("thematicBreak"),n(c)):r(c)}function u(c){return c===s?(e.consume(c),i++,u):(e.exit("thematicBreakSequence"),U(c)?W(e,a,"whitespace")(c):a(c))}}const oe={name:"list",tokenize:ml,continuation:{tokenize:hl},exit:gl},xl={tokenize:jl,partial:!0},dl={tokenize:fl,partial:!0};function ml(e,n,r){const i=this,s=i.events[i.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,l=0;return a;function a(d){const j=i.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!i.containerState.marker||d===i.containerState.marker:Bt(d)){if(i.containerState.type||(i.containerState.type=j,e.enter(j,{_container:!0})),j==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(it,r,c)(d):c(d);if(!i.interrupt||d===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(d)}return r(d)}function u(d){return Bt(d)&&++l<10?(e.consume(d),u):(!i.interrupt||l<2)&&(i.containerState.marker?d===i.containerState.marker:d===41||d===46)?(e.exit("listItemValue"),c(d)):r(d)}function c(d){return e.enter("listItemMarker"),e.consume(d),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||d,e.check(pt,i.interrupt?r:x,e.attempt(xl,m,p))}function x(d){return i.containerState.initialBlankLine=!0,o++,m(d)}function p(d){return U(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),m):r(d)}function m(d){return i.containerState.size=o+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(d)}}function hl(e,n,r){const i=this;return i.containerState._closeFlow=void 0,e.check(pt,s,o);function s(a){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,W(e,n,"listItemIndent",i.containerState.size+1)(a)}function o(a){return i.containerState.furtherBlankLines||!U(a)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,l(a)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(dl,n,l)(a))}function l(a){return i.containerState._closeFlow=!0,i.interrupt=void 0,W(e,e.attempt(oe,n,r),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function fl(e,n,r){const i=this;return W(e,s,"listItemIndent",i.containerState.size+1);function s(o){const l=i.events[i.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===i.containerState.size?n(o):r(o)}}function gl(e){e.exit(this.containerState.type)}function jl(e,n,r){const i=this;return W(e,s,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const l=i.events[i.events.length-1];return!U(o)&&l&&l[1].type==="listItemPrefixWhitespace"?n(o):r(o)}}const An={name:"setextUnderline",tokenize:El,resolveTo:yl};function yl(e,n){let r=e.length,i,s,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){i=r;break}e[r][1].type==="paragraph"&&(s=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);const l={type:"setextHeading",start:Object.assign({},e[s][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",l,n]),e.splice(o+1,0,["exit",e[i][1],n]),e[i][1].end=Object.assign({},e[o][1].end)):e[i][1]=l,e.push(["exit",l,n]),e}function El(e,n,r){const i=this;let s;return o;function o(c){let x=i.events.length,p;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){p=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||p)?(e.enter("setextHeadingLine"),s=c,l(c)):r(c)}function l(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===s?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),U(c)?W(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||F(c)?(e.exit("setextHeadingLine"),n(c)):r(c)}}const bl={tokenize:kl};function kl(e){const n=this,r=e.attempt(pt,i,e.attempt(this.parser.constructs.flowInitial,s,W(e,e.attempt(this.parser.constructs.flow,s,e.attempt(vo,s)),"linePrefix")));return r;function i(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),n.currentConstruct=void 0,r}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n.currentConstruct=void 0,r}}const Sl={resolveAll:Mr()},Rl=Fr("string"),Cl=Fr("text");function Fr(e){return{tokenize:n,resolveAll:Mr(e==="text"?wl:void 0)};function n(r){const i=this,s=this.parser.constructs[e],o=r.attempt(s,l,a);return l;function l(x){return c(x)?o(x):a(x)}function a(x){if(x===null){r.consume(x);return}return r.enter("data"),r.consume(x),u}function u(x){return c(x)?(r.exit("data"),o(x)):(r.consume(x),u)}function c(x){if(x===null)return!0;const p=s[x];let m=-1;if(p)for(;++m<p.length;){const d=p[m];if(!d.previous||d.previous.call(i,i.previous))return!0}return!1}}}function Mr(e){return n;function n(r,i){let s=-1,o;for(;++s<=r.length;)o===void 0?r[s]&&r[s][1].type==="data"&&(o=s,s++):(!r[s]||r[s][1].type!=="data")&&(s!==o+2&&(r[o][1].end=r[s-1][1].end,r.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(r,i):r}}function wl(e,n){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const i=e[r-1][1],s=n.sliceStream(i);let o=s.length,l=-1,a=0,u;for(;o--;){const c=s[o];if(typeof c=="string"){for(l=c.length;c.charCodeAt(l-1)===32;)a++,l--;if(l)break;l=-1}else if(c===-2)u=!0,a++;else if(c!==-1){o++;break}}if(a){const c={type:r===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{line:i.end.line,column:i.end.column-a,offset:i.end.offset-a,_index:i.start._index+o,_bufferIndex:o?l:i.start._bufferIndex+l},end:Object.assign({},i.end)};i.end=Object.assign({},c.start),i.start.offset===i.end.offset?Object.assign(i,c):(e.splice(r,0,["enter",c,n],["exit",c,n]),r+=2)}r++}return e}function vl(e,n,r){let i=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1});const s={},o=[];let l=[],a=[];const u={consume:w,enter:R,exit:O,attempt:M(D),check:M(b),interrupt:M(b,{interrupt:!0})},c={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:d,sliceSerialize:m,now:j,defineSkip:E,write:p};let x=n.tokenize.call(c,u);return n.resolveAll&&o.push(n),c;function p(I){return l=de(l,I),k(),l[l.length-1]!==null?[]:(T(n,0),c.events=en(o,c.events,c),c.events)}function m(I,v){return Il(d(I),v)}function d(I){return Nl(l,I)}function j(){const{line:I,column:v,offset:q,_index:$,_bufferIndex:V}=i;return{line:I,column:v,offset:q,_index:$,_bufferIndex:V}}function E(I){s[I.line]=I.column,H()}function k(){let I;for(;i._index<l.length;){const v=l[i._index];if(typeof v=="string")for(I=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===I&&i._bufferIndex<v.length;)y(v.charCodeAt(i._bufferIndex));else y(v)}}function y(I){x=x(I)}function w(I){F(I)?(i.line++,i.column=1,i.offset+=I===-3?2:1,H()):I!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===l[i._index].length&&(i._bufferIndex=-1,i._index++)),c.previous=I}function R(I,v){const q=v||{};return q.type=I,q.start=j(),c.events.push(["enter",q,c]),a.push(q),q}function O(I){const v=a.pop();return v.end=j(),c.events.push(["exit",v,c]),v}function D(I,v){T(I,v.from)}function b(I,v){v.restore()}function M(I,v){return q;function q($,V,G){let Q,re,N,h;return Array.isArray($)?te($):"tokenize"in $?te([$]):J($);function J(X){return ke;function ke(ne){const he=ne!==null&&X[ne],xe=ne!==null&&X.null,Le=[...Array.isArray(he)?he:he?[he]:[],...Array.isArray(xe)?xe:xe?[xe]:[]];return te(Le)(ne)}}function te(X){return Q=X,re=0,X.length===0?G:f(X[re])}function f(X){return ke;function ke(ne){return h=z(),N=X,X.partial||(c.currentConstruct=X),X.name&&c.parser.constructs.disable.null.includes(X.name)?ge():X.tokenize.call(v?Object.assign(Object.create(c),v):c,u,ae,ge)(ne)}}function ae(X){return I(N,h),V}function ge(X){return h.restore(),++re<Q.length?f(Q[re]):G}}}function T(I,v){I.resolveAll&&!o.includes(I)&&o.push(I),I.resolve&&be(c.events,v,c.events.length-v,I.resolve(c.events.slice(v),c)),I.resolveTo&&(c.events=I.resolveTo(c.events,c))}function z(){const I=j(),v=c.previous,q=c.currentConstruct,$=c.events.length,V=Array.from(a);return{restore:G,from:$};function G(){i=I,c.previous=v,c.currentConstruct=q,c.events.length=$,a=V,H()}}function H(){i.line in s&&i.column<2&&(i.column=s[i.line],i.offset+=s[i.line]-1)}}function Nl(e,n){const r=n.start._index,i=n.start._bufferIndex,s=n.end._index,o=n.end._bufferIndex;let l;if(r===s)l=[e[r].slice(i,o)];else{if(l=e.slice(r,s),i>-1){const a=l[0];typeof a=="string"?l[0]=a.slice(i):l.shift()}o>0&&l.push(e[s].slice(0,o))}return l}function Il(e,n){let r=-1;const i=[];let s;for(;++r<e.length;){const o=e[r];let l;if(typeof o=="string")l=o;else switch(o){case-5:{l="\r";break}case-4:{l=`
|
|
161
|
+
*/const Ti=t.createLucideIcon("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function zi(){const[e,n]=A.useState(""),[r,i]=A.useState(!1),[s,o]=A.useState(!1),l=t.useDashboardStore(u=>u.dashboard);function a(){const u=t.getDashbaordStateWithoutData(l),c=t.getBookmarkKey(l.id),x=JSON.parse(localStorage.getItem(c)||"[]");if(x.some(m=>m.name===e)){i(!0);return}x.push({name:e,template:u}),localStorage.setItem(c,JSON.stringify(x)),o(!1)}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:s,onOpenChange:o,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsxs(t.Button,{variant:"outline",className:"h-7 p-2",size:"sm",children:[t.jsxRuntimeExports.jsx(lr,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Lens"]})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Add a Lens"}),t.jsxRuntimeExports.jsx(t.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),t.jsxRuntimeExports.jsx("div",{className:"grid gap-4 py-4",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-right",children:"Name"}),t.jsxRuntimeExports.jsx(t.Input,{value:e,onChange:u=>{r&&i(!1),n(u.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),r&&t.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),t.jsxRuntimeExports.jsx(t.DialogFooter,{children:t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",type:"submit",disabled:!e,onClick:a,children:"Save"})})]})]})}function Li(){const[e,n]=A.useState(!1),[r,i]=A.useState(""),s=t.useDashboardStore(d=>d.dashboard),o=t.useDashboardStore(d=>d.bookmarkKey),[l,a]=A.useState([]),u=t.useDashboardStore(d=>d.actions.setDashboard),c=t.useDashboardStore(d=>d.actions.setFilterValues),x=t.useDashboardStore(d=>d.actions.setBookmarkKey);A.useEffect(()=>{const d=t.getBookmarkKey(s.id),j=JSON.parse(localStorage.getItem(d)||"[]");a(j);const E=j.find(k=>k.default);E&&E.name===o&&i(E.name)},[e,s,o]);function p(d){if(d===r)return;const j=l.find(k=>k.name===d),E=j==null?void 0:j.template;E&&(u(E),c(j.filterValues||[]),x(d==="Original"?"":d)),i(d)}function m(d){const j=t.getBookmarkKey(s.id),k=JSON.parse(localStorage.getItem(j)||"[]").filter(y=>y.name!==d);localStorage.setItem(j,JSON.stringify(k)),a(k)}return t.jsxRuntimeExports.jsxs(t.DropdownMenu,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DropdownMenuTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",className:"h-7 p-2",children:t.jsxRuntimeExports.jsx(di,{className:"h-4 w-4",strokeWidth:1.5})})}),t.jsxRuntimeExports.jsxs(t.DropdownMenuContent,{className:"w-56",children:[t.jsxRuntimeExports.jsx(t.DropdownMenuLabel,{children:"Lenses"}),t.jsxRuntimeExports.jsx(t.DropdownMenuSeparator,{}),t.jsxRuntimeExports.jsxs(t.DropdownMenuRadioGroup,{value:r,onValueChange:p,children:[t.jsxRuntimeExports.jsx(t.DropdownMenuRadioItem,{value:"Original",children:"Original"}),l.filter(d=>d.name!="Original").map((d,j)=>t.jsxRuntimeExports.jsxs(t.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:d.name,defaultChecked:d.name===o,children:[t.jsxRuntimeExports.jsx("p",{children:d.name}),t.jsxRuntimeExports.jsx(t.Cross2Icon,{onClick:E=>{E.preventDefault(),m(d.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},j))]})]})]})}function Oi(){const[e,n]=A.useState(!1),r=t.useDashboardStore(o=>o.dashboard),i=t.useDashboardStore(o=>o.bookmarkKey);A.useEffect(()=>{if(!i){n(!1);return}const o=t.getBookmarkKey(r.id),a=JSON.parse(localStorage.getItem(o)||"[]").find(u=>u.name===i);n(a?a.default:!1)},[i,r.id]);function s(o){if(n(o),!i)return;const l=t.getBookmarkKey(r.id),u=JSON.parse(localStorage.getItem(l)||"[]").map(c=>(c.name===i?c.default=o:c.default=!1,c));console.log(u),localStorage.setItem(l,JSON.stringify(u))}return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:e,onCheckedChange:s,id:"terms"}),t.jsxRuntimeExports.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function Di(){const e=t.useDashboardStore(y=>y.bookmarkKey),n=t.useDashboardStore(y=>y.dashboard);t.useDashboardStore(y=>y.selectedSheetId);const r=t.useDashboardStore(y=>y.isDashboardEditing),i=t.useDashboardStore(y=>y.filterValues),s=t.useDashboardStore(y=>y.isVisualEditing),o=t.useDashboardStore(y=>y.showFilters);t.useDashboardStore(y=>y.showDashboardJSON);const l=t.useDashboardStore(y=>y.onSaveFunction),a=t.useDashboardStore(y=>y.actions.setShowFilters),{addFrame:u,setSelectedFrameId:c}=t.useDashboardStore(y=>y.actions),{getSelectedSheet:x,setIsDashboardEditing:p,setShowDashboardJSON:m}=t.useDashboardStore(y=>y.actions),d=x(),j=()=>{if(!r||!d)return;const y={id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},w={id:t.v4(),cards:[y],activeCardId:y.id};u(d.id,w),c(w.id)},E=()=>{p(!0)};function k(){if(!e||e==="")return;const y=t.getDashbaordStateWithoutData(n),w=t.getBookmarkKey(n.id),S=JSON.parse(localStorage.getItem(w)||"[]"),D=S.findIndex(O=>O.name===e);D!==-1?S[D]={name:e,template:y,default:S[D].default,filterValues:i}:S.push({name:e,template:y,filterValues:i}),localStorage.setItem(w,JSON.stringify(S)),l==null||l(y)}return s?null:t.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pt-2",role:"dashboard-controls",children:[!s&&t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxRuntimeExports.jsx(t.Label,{children:e}),!!e&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"|"}),t.jsxRuntimeExports.jsx(Oi,{})]})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[r&&!s&&t.jsxRuntimeExports.jsx(zi,{}),!s&&t.jsxRuntimeExports.jsx(Li,{}),r&&!s&&t.jsxRuntimeExports.jsxs(t.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!r,onClick:j,children:[t.jsxRuntimeExports.jsx(lr,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Add Frame"]}),!r&&t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",className:"h-7 p-2",onClick:E,size:"sm",children:t.jsxRuntimeExports.jsx(sr,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!s&&t.jsxRuntimeExports.jsx(t.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{p(!1),m(!1)},size:"sm",children:t.jsxRuntimeExports.jsx(t.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!s&&t.jsxRuntimeExports.jsx(t.Button,{className:"h-7 p-2",variant:"outline",onClick:k,size:"sm",children:t.jsxRuntimeExports.jsx(Ci,{className:"h-4 w-4",strokeWidth:1.5})}),!o&&!s&&r&&t.jsxRuntimeExports.jsx(t.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>a(!0),size:"sm",children:t.jsxRuntimeExports.jsx(ir,{className:"h-4 w-4",strokeWidth:1.5})}),!s&&r&&!1,!s&&!1]})]})}function Ue({title:e,items:n,value:r,isLoading:i,isError:s,connectionTooltip:o,onChange:l,className:a,showIcon:u=!0}){const c=i?"Loading...":s?"Error":r;function x(){if(e==="Connection")return t.jsxRuntimeExports.jsx(Ri,{className:"size-4 rotate-90"});if(e==="Database")return t.jsxRuntimeExports.jsx(pi,{className:"size-4"});if(e==="Schema")return t.jsxRuntimeExports.jsx(ki,{className:"size-4"});if(e==="Table")return t.jsxRuntimeExports.jsx(Kt,{className:"size-4"})}return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[u&&t.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:o?t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:x()}),t.jsxRuntimeExports.jsx(t.TooltipContent,{className:"text-xs",align:"start",children:o})]}):x()}),t.jsxRuntimeExports.jsxs(t.Select,{value:c,onValueChange:l,children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:t.cn("h-9 w-[190px] focus:ring-1 focus:ring-offset-0",a),children:t.jsxRuntimeExports.jsx(t.SelectValue,{placeholder:i?"Loading...":s?"Error":`Select ${e}`})}),t.jsxRuntimeExports.jsx(t.SelectContent,{children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[i?t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Loading..."}):t.jsxRuntimeExports.jsx(t.SelectLabel,{children:e}),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:n&&n.map((p,m)=>t.jsxRuntimeExports.jsx(t.SelectItem,{value:p.id,children:p.name},m))}),(i||s)&&t.jsxRuntimeExports.jsx(t.SelectItem,{value:c,children:c})]})})]})]})}function Fi({column:e}){const[n,r]=A.useState(!1),i=t.useEditorStore(x=>x.selectedTableName),s=t.useEditorStore(x=>x.selectedSchemaName),o=t.useEditorStore(x=>x.sqlGen),l=t.useEditorStore(x=>x.actions.setSqlGen),a=t.useEditorStore(x=>x.actions.setCardSql),u=t.useEditorStore(x=>x.actions.setRunSql);function c(x,p){const m=t.createSqlGenConfig(x,o,p);l(m);const d=t.getSql(m,t.fmt(s||""),t.fmt(i));d&&(a(d),u(!0)),r(!1)}return t.jsxRuntimeExports.jsxs(t.Popover,{open:n,onOpenChange:r,children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.ChevronDown,{className:"h-4 w-4 cursor-pointer text-foreground/40"})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{align:"center",className:"w-18 rounded-md p-0 shadow-none",children:t.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),t.jsxRuntimeExports.jsx("li",{onClick:()=>c(e,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function ur({column:e}){return t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.$a093c7e1ec25a057$export$8c610744efcf8a1d,{asChild:!0,children:t.TEXT_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(Ai,{className:"size-3"}):t.NUMBER_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(fi,{className:"size-3"}):t.DATE_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(t.Calendar,{className:"size-3"}):t.BOOLEAN_DATA_TYPES.includes(e.data_type.toLowerCase())?t.jsxRuntimeExports.jsx(Ii,{className:"size-3"}):t.jsxRuntimeExports.jsx(wi,{className:"size-3"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{children:t.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:e.data_type})})]})}function Mi({schemaName:e,tableName:n,columns:r,status:i}){const s=t.useEditorStore(p=>p.sqlGen),o=t.useEditorStore(p=>p.actions.setRunSql),l=t.useEditorStore(p=>p.actions.setSqlGen),a=t.useEditorStore(p=>p.actions.setIsShowingVisual),u=t.useEditorStore(p=>p.actions.setCardSql);function c(p){const m=t.createSqlGenConfig(p,s);l(m);const d=t.getSql(m,t.fmt(e),t.fmt(n));d&&(u(d),o(!0))}function x(){let m=t.getQualifiedTableName(e,n);(j=>j.charAt(0)===j.charAt(0).toUpperCase())(n)&&(m=`"${n}"`),a(!1),u(`SELECT * FROM ${m} LIMIT 10`),o(!0)}return t.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-6",children:[t.jsxRuntimeExports.jsx("div",{className:"font-medium",children:t.jsxRuntimeExports.jsxs(t.Button,{disabled:i!=="Success",onClick:x,size:"sm",variant:"secondary",className:"flex w-full",children:[i!=="Success"?t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):t.jsxRuntimeExports.jsx(vi,{className:"mr-2 size-4"}),"Show top 10 rows"]})}),t.jsxRuntimeExports.jsxs(t.ScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",children:[r==null?void 0:r.map(p=>t.jsxRuntimeExports.jsxs("div",{onClick:()=>c(p),className:t.cn("mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":t.isColumnInSqlGen(p,s)}),children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(ur,{column:p}),t.jsxRuntimeExports.jsx("span",{children:p.column_name})]}),t.NUMBER_DATA_TYPES.includes(p.data_type)&&t.jsxRuntimeExports.jsx("div",{onClick:m=>m.stopPropagation(),className:"flex items-center justify-end",children:t.jsxRuntimeExports.jsx(Fi,{column:p})})]},p.column_name)),t.jsxRuntimeExports.jsx(t.ScrollBar,{orientation:"vertical"}),t.jsxRuntimeExports.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function cr({ColumnsComponent:e}){var P;const n=t.useEditorStore(q=>q.selectedConnectionId),r=t.useEditorStore(q=>q.selectedDatabaseName),i=t.useEditorStore(q=>q.selectedSchemaName),s=t.useEditorStore(q=>q.selectedTableName),o=t.useEditorStore(q=>q.actions.setSelectedTableName),{connectionItems:l,schemaItems:a,databaseItems:u,tableItems:c,columns:x,isConnectionsLoading:p,isConnectionsError:m,isDatabasesLoadingOrFetching:d,isDatabaseError:j,isSchemaLoadingOrFetching:E,isSchemaError:k,isColumnsError:y,isColumnsLoadingOrFetching:w,connectionType:S,isNonDbConnection:D,handleConnectionChange:O,handleDatabaseChange:b,handleSchemaChange:M,tableName:T,schemaName:z}=t.useEditorAside();function H(){return e?e(z,T,x):t.jsxRuntimeExports.jsx(Mi,{schemaName:z,tableName:T,columns:x,status:w?"Loading...":y?"Error":"Success"})}function I(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function v(){return S==="S3"||S==="API"?null:t.jsxRuntimeExports.jsx(Ue,{onChange:b,isError:j,isLoading:d,items:u,value:r||"",title:"Database"})}function U(){return S==="S3"||S==="API"?null:t.jsxRuntimeExports.jsx(Ue,{onChange:M,isError:k,isLoading:E,items:a,value:i||"",title:"Schema"})}function $(){return S==="API"?null:t.jsxRuntimeExports.jsx(Ue,{onChange:o,isError:j,items:c,isLoading:d,value:s||"",title:"Table"})}return t.jsxRuntimeExports.jsxs("aside",{className:"xbg-red-100 flex grow flex-col justify-between",children:[t.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[t.jsxRuntimeExports.jsx(Ue,{items:l,title:"Connection",value:n||"",onChange:O,isLoading:p,isError:m,connectionTooltip:((P=l==null?void 0:l.find(q=>q.id===n))==null?void 0:P.type)||""}),v(),U(),$()]}),H(),t.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center px-6 py-4",children:t.jsxRuntimeExports.jsxs(t.Button,{onClick:I,size:"sm",variant:"secondary",className:"w-full",children:[t.jsxRuntimeExports.jsx(bi,{className:"mr-2 size-4"}),"Help"]})})]})}const Lt=({className:e,...n})=>t.jsxRuntimeExports.jsx(t.PanelGroup,{className:t.cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...n}),Fe=t.Panel,Ot=({withHandle:e,className:n,...r})=>t.jsxRuntimeExports.jsx(t.PanelResizeHandle,{className:t.cn("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",n),...r,children:e&&t.jsxRuntimeExports.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsxRuntimeExports.jsx(mi,{className:"h-2.5 w-2.5"})})});function Pi(e){const n=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),i=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let o=e.length;if(s!==-1&&(o=s),i!==-1&&i<o&&(o=i),n!==-1){const l=e.substring(0,n),a=e.substring(n);return`${l} {{ filters | where }} AND ${a.substring(6)}`}else if(r!==-1){const l=e.substring(0,r),a=e.substring(r);return`${l} {{ filters | where }} ${a}`}else{const l=e.substring(0,o),a=e.substring(o);return`${l} {{ filters | where }} ${a}`}}function Bi({error:e,setShowAIDialog:n,setUserInputforAI:r,setTriggerAIRun:i}){return t.jsxRuntimeExports.jsxs(t.HoverCard,{openDelay:0,children:[t.jsxRuntimeExports.jsx(t.HoverCardTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{variant:"link",className:" p-0 h-5",children:t.jsxRuntimeExports.jsx(ci,{className:"h-4 w-4 text-red-500"})})}),t.jsxRuntimeExports.jsx(t.HoverCardContent,{align:"start",className:" min-w-fit max-w-[500px]",children:t.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:t.jsxRuntimeExports.jsxs("div",{className:"grow space-y-1 flex flex-col ",children:[t.jsxRuntimeExports.jsxs(t.Button,{onClick:()=>{n(!0),r(e),i(!0)},size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(hi,{className:"h-4 w-4 mr-2"}),"Fix It"]}),t.jsxRuntimeExports.jsx(t.ScrollArea,{className:" min-h-0 max-h-[250px] overflow-scroll ",children:t.jsxRuntimeExports.jsx("p",{className:" overflow-auto text-sm leading-relaxed font-mono ",children:e})})]})})})]})}function _i({text:e,onCheckedChange:n,checked:r}){return t.jsxRuntimeExports.jsxs("div",{className:"xbg-red-100 ml-6 flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:r,onCheckedChange:n}),t.jsxRuntimeExports.jsx("label",{className:"text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function Vi(){const{authToken:e}=t.useSemaphorContext(),n=A.useRef(null),r=t.useEditorStore(a=>a.applyFilters),[i,s]=A.useState(""),o=t.useEditorStore(a=>a.filterValues),l=t.useEditorStore(a=>a.card.sql);return t.jsxRuntimeExports.jsxs(t.HoverCard,{openDelay:0,onOpenChange:async a=>{if(!a)return;console.log("onOpenChange");const u=await t.postRequest("https://semaphor.cloud/api/v1/filter-sql",(e==null?void 0:e.accessToken)||"",{sql:l,active_filters:o});console.log(u),u.sql?(console.log(u.records),s(u.sql)):s("Error")},children:[t.jsxRuntimeExports.jsx(t.HoverCardTrigger,{asChild:!0,children:r&&t.jsxRuntimeExports.jsx("p",{className:"p-0 text-xs hover:cursor-pointer",children:"| Filter Query"})}),t.jsxRuntimeExports.jsxs(t.HoverCardContent,{align:"end",className:"w-[600px]",children:[t.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:t.jsxRuntimeExports.jsx("div",{className:"rounded-sm bg-muted p-2",children:t.jsxRuntimeExports.jsxs("code",{ref:n,className:"font-mono text-sm",children:[i,t.jsxRuntimeExports.jsx(t.ClipboardCopyIcon,{onClick:()=>t.copyToClipboard(n),className:"ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"})]})})}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[t.jsxRuntimeExports.jsx(t.InfoCircledIcon,{className:"h-4 w-4 opacity-70"}),t.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"A preview of the query with filters applied."})]})]})]})}function Hi(e,n){const r=n||{};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const qi=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ui=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$i={};function cn(e,n){return((n||$i).jsx?Ui:qi).test(e)}const Ki=/[ \t\n\f\r]/g;function Wi(e){return typeof e=="object"?e.type==="text"?pn(e.value):!1:pn(e)}function pn(e){return e.replace(Ki,"")===""}class Ge{constructor(n,r,i){this.property=n,this.normal=r,i&&(this.space=i)}}Ge.prototype.property={};Ge.prototype.normal={};Ge.prototype.space=null;function pr(e,n){const r={},i={};let s=-1;for(;++s<e.length;)Object.assign(r,e[s].property),Object.assign(i,e[s].normal);return new Ge(r,i,n)}function Dt(e){return e.toLowerCase()}class me{constructor(n,r){this.property=n,this.attribute=r}}me.prototype.space=null;me.prototype.boolean=!1;me.prototype.booleanish=!1;me.prototype.overloadedBoolean=!1;me.prototype.number=!1;me.prototype.commaSeparated=!1;me.prototype.spaceSeparated=!1;me.prototype.commaOrSpaceSeparated=!1;me.prototype.mustUseProperty=!1;me.prototype.defined=!1;let Gi=0;const V=Te(),Z=Te(),xr=Te(),R=Te(),W=Te(),Me=Te(),ce=Te();function Te(){return 2**++Gi}const Ft=Object.freeze(Object.defineProperty({__proto__:null,boolean:V,booleanish:Z,commaOrSpaceSeparated:ce,commaSeparated:Me,number:R,overloadedBoolean:xr,spaceSeparated:W},Symbol.toStringTag,{value:"Module"})),bt=Object.keys(Ft);class Wt extends me{constructor(n,r,i,s){let o=-1;if(super(n,r),xn(this,"space",s),typeof i=="number")for(;++o<bt.length;){const l=bt[o];xn(this,bt[o],(i&Ft[l])===Ft[l])}}}Wt.prototype.defined=!0;function xn(e,n,r){r&&(e[n]=r)}const Qi={}.hasOwnProperty;function Be(e){const n={},r={};let i;for(i in e.properties)if(Qi.call(e.properties,i)){const s=e.properties[i],o=new Wt(i,e.transform(e.attributes||{},i),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),n[i]=o,r[Dt(i)]=i,r[Dt(o.attribute)]=i}return new Ge(n,r,e.space)}const dr=Be({space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()},properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),mr=Be({space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()},properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function hr(e,n){return n in e?e[n]:n}function fr(e,n){return hr(e,n.toLowerCase())}const gr=Be({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:fr,properties:{xmlns:null,xmlnsXLink:null}}),jr=Be({transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()},properties:{ariaActiveDescendant:null,ariaAtomic:Z,ariaAutoComplete:null,ariaBusy:Z,ariaChecked:Z,ariaColCount:R,ariaColIndex:R,ariaColSpan:R,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:Z,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:Z,ariaFlowTo:W,ariaGrabbed:Z,ariaHasPopup:null,ariaHidden:Z,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:R,ariaLive:null,ariaModal:Z,ariaMultiLine:Z,ariaMultiSelectable:Z,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:R,ariaPressed:Z,ariaReadOnly:Z,ariaRelevant:null,ariaRequired:Z,ariaRoleDescription:W,ariaRowCount:R,ariaRowIndex:R,ariaRowSpan:R,ariaSelected:Z,ariaSetSize:R,ariaSort:null,ariaValueMax:R,ariaValueMin:R,ariaValueNow:R,ariaValueText:null,role:null}}),Ji=Be({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:fr,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Me,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:W,autoFocus:V,autoPlay:V,blocking:W,capture:null,charSet:null,checked:V,cite:null,className:W,cols:R,colSpan:null,content:null,contentEditable:Z,controls:V,controlsList:W,coords:R|Me,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:xr,draggable:Z,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:W,height:R,hidden:V,high:R,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:W,itemRef:W,itemScope:V,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:R,manifest:null,max:null,maxLength:R,media:null,method:null,min:null,minLength:R,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:R,pattern:null,ping:W,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:W,required:V,reversed:V,rows:R,rowSpan:R,sandbox:W,scope:null,scoped:V,seamless:V,selected:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:R,sizes:null,slot:null,span:R,spellCheck:Z,src:null,srcDoc:null,srcLang:null,srcSet:null,start:R,step:null,style:null,tabIndex:R,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:Z,width:R,wrap:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:R,borderColor:null,bottomMargin:R,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:R,leftMargin:R,link:null,longDesc:null,lowSrc:null,marginHeight:R,marginWidth:R,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:R,rules:null,scheme:null,scrolling:Z,standby:null,summary:null,text:null,topMargin:R,valueType:null,version:null,vAlign:null,vLink:null,vSpace:R,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:R,security:null,unselectable:null}}),Xi=Be({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:hr,properties:{about:ce,accentHeight:R,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:R,amplitude:R,arabicForm:null,ascent:R,attributeName:null,attributeType:null,azimuth:R,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:R,by:null,calcMode:null,capHeight:R,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:R,diffuseConstant:R,direction:null,display:null,dur:null,divisor:R,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:R,enableBackground:null,end:null,event:null,exponent:R,externalResourcesRequired:null,fill:null,fillOpacity:R,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Me,g2:Me,glyphName:Me,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:R,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:R,horizOriginX:R,horizOriginY:R,id:null,ideographic:R,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:R,k:R,k1:R,k2:R,k3:R,k4:R,kernelMatrix:ce,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:R,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:R,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:R,overlineThickness:R,paintOrder:null,panose1:null,path:null,pathLength:R,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:R,pointsAtY:R,pointsAtZ:R,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ce,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ce,rev:ce,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ce,requiredFeatures:ce,requiredFonts:ce,requiredFormats:ce,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:R,specularExponent:R,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:R,strikethroughThickness:R,string:null,stroke:null,strokeDashArray:ce,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:R,strokeOpacity:R,strokeWidth:null,style:null,surfaceScale:R,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ce,tabIndex:R,tableValues:null,target:null,targetX:R,targetY:R,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ce,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:R,underlineThickness:R,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:R,values:null,vAlphabetic:R,vMathematical:R,vectorEffect:null,vHanging:R,vIdeographic:R,version:null,vertAdvY:R,vertOriginX:R,vertOriginY:R,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:R,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),Yi=/^data[-\w.:]+$/i,dn=/-[a-z]/g,Zi=/[A-Z]/g;function es(e,n){const r=Dt(n);let i=n,s=me;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&Yi.test(n)){if(n.charAt(4)==="-"){const o=n.slice(5).replace(dn,ns);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=n.slice(4);if(!dn.test(o)){let l=o.replace(Zi,ts);l.charAt(0)!=="-"&&(l="-"+l),n="data"+l}}s=Wt}return new s(i,n)}function ts(e){return"-"+e.toLowerCase()}function ns(e){return e.charAt(1).toUpperCase()}const rs={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},is=pr([mr,dr,gr,jr,Ji],"html"),Gt=pr([mr,dr,gr,jr,Xi],"svg");function ss(e){return e.join(" ").trim()}var yr={},mn=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,os=/\n/g,ls=/^\s*/,as=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,us=/^:\s*/,cs=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,ps=/^[;\s]*/,xs=/^\s+|\s+$/g,ds=`
|
|
162
|
+
`,hn="/",fn="*",Ae="",ms="comment",hs="declaration",fs=function(e,n){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];n=n||{};var r=1,i=1;function s(j){var E=j.match(os);E&&(r+=E.length);var k=j.lastIndexOf(ds);i=~k?j.length-k:i+j.length}function o(){var j={line:r,column:i};return function(E){return E.position=new l(j),c(),E}}function l(j){this.start=j,this.end={line:r,column:i},this.source=n.source}l.prototype.content=e;function a(j){var E=new Error(n.source+":"+r+":"+i+": "+j);if(E.reason=j,E.filename=n.source,E.line=r,E.column=i,E.source=e,!n.silent)throw E}function u(j){var E=j.exec(e);if(E){var k=E[0];return s(k),e=e.slice(k.length),E}}function c(){u(ls)}function x(j){var E;for(j=j||[];E=p();)E!==!1&&j.push(E);return j}function p(){var j=o();if(!(hn!=e.charAt(0)||fn!=e.charAt(1))){for(var E=2;Ae!=e.charAt(E)&&(fn!=e.charAt(E)||hn!=e.charAt(E+1));)++E;if(E+=2,Ae===e.charAt(E-1))return a("End of comment missing");var k=e.slice(2,E-2);return i+=2,s(k),e=e.slice(E),i+=2,j({type:ms,comment:k})}}function m(){var j=o(),E=u(as);if(E){if(p(),!u(us))return a("property missing ':'");var k=u(cs),y=j({type:hs,property:gn(E[0].replace(mn,Ae)),value:k?gn(k[0].replace(mn,Ae)):Ae});return u(ps),y}}function d(){var j=[];x(j);for(var E;E=m();)E!==!1&&(j.push(E),x(j));return j}return c(),d()};function gn(e){return e?e.replace(xs,Ae):Ae}var gs=t.commonjsGlobal&&t.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yr,"__esModule",{value:!0});var js=gs(fs);function ys(e,n){var r=null;if(!e||typeof e!="string")return r;var i=(0,js.default)(e),s=typeof n=="function";return i.forEach(function(o){if(o.type==="declaration"){var l=o.property,a=o.value;s?n(l,a,o):a&&(r=r||{},r[l]=a)}}),r}var jn=yr.default=ys;const Es=jn.default||jn,Er=br("end"),Qt=br("start");function br(e){return n;function n(r){const i=r&&r.position&&r.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function bs(e){const n=Qt(e),r=Er(e);if(n&&r)return{start:n,end:r}}function $e(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?yn(e.position):"start"in e||"end"in e?yn(e):"line"in e||"column"in e?Mt(e):""}function Mt(e){return En(e&&e.line)+":"+En(e&&e.column)}function yn(e){return Mt(e&&e.start)+"-"+Mt(e&&e.end)}function En(e){return e&&typeof e=="number"?e:1}class ie extends Error{constructor(n,r,i){super(),typeof r=="string"&&(i=r,r=void 0);let s="",o={},l=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),typeof n=="string"?s=n:!o.cause&&n&&(l=!0,s=n.message,o.cause=n),!o.ruleId&&!o.source&&typeof i=="string"){const u=i.indexOf(":");u===-1?o.ruleId=i:(o.source=i.slice(0,u),o.ruleId=i.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=s,this.line=a?a.line:void 0,this.name=$e(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=l&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}ie.prototype.file="";ie.prototype.name="";ie.prototype.reason="";ie.prototype.message="";ie.prototype.stack="";ie.prototype.column=void 0;ie.prototype.line=void 0;ie.prototype.ancestors=void 0;ie.prototype.cause=void 0;ie.prototype.fatal=void 0;ie.prototype.place=void 0;ie.prototype.ruleId=void 0;ie.prototype.source=void 0;const Jt={}.hasOwnProperty,ks=new Map,Ss=/[A-Z]/g,Rs=/-([a-z])/g,Cs=new Set(["table","tbody","thead","tfoot","tr"]),ws=new Set(["td","th"]),kr="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function vs(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=Ds(r,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=Os(r,n.jsx,n.jsxs)}const s={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Gt:is,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},o=Sr(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function Sr(e,n,r){if(n.type==="element")return Ns(e,n,r);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Is(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Ts(e,n,r);if(n.type==="mdxjsEsm")return As(e,n);if(n.type==="root")return zs(e,n,r);if(n.type==="text")return Ls(e,n)}function Ns(e,n,r){const i=e.schema;let s=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(s=Gt,e.schema=s),e.ancestors.push(n);const o=Cr(e,n.tagName,!1),l=Fs(e,n);let a=Yt(e,n);return Cs.has(n.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!Wi(u):!0})),Rr(e,l,o,n),Xt(l,a),e.ancestors.pop(),e.schema=i,e.create(n,o,l,r)}function Is(e,n){if(n.data&&n.data.estree&&e.evaluater){const i=n.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}We(e,n.position)}function As(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);We(e,n.position)}function Ts(e,n,r){const i=e.schema;let s=i;n.name==="svg"&&i.space==="html"&&(s=Gt,e.schema=s),e.ancestors.push(n);const o=n.name===null?e.Fragment:Cr(e,n.name,!0),l=Ms(e,n),a=Yt(e,n);return Rr(e,l,o,n),Xt(l,a),e.ancestors.pop(),e.schema=i,e.create(n,o,l,r)}function zs(e,n,r){const i={};return Xt(i,Yt(e,n)),e.create(n,e.Fragment,i,r)}function Ls(e,n){return n.value}function Rr(e,n,r,i){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(n.node=i)}function Xt(e,n){if(n.length>0){const r=n.length>1?n:n[0];r&&(e.children=r)}}function Os(e,n,r){return i;function i(s,o,l,a){const c=Array.isArray(l.children)?r:n;return a?c(o,l,a):c(o,l)}}function Ds(e,n){return r;function r(i,s,o,l){const a=Array.isArray(o.children),u=Qt(i);return n(s,o,l,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function Fs(e,n){const r={};let i,s;for(s in n.properties)if(s!=="children"&&Jt.call(n.properties,s)){const o=Ps(e,s,n.properties[s]);if(o){const[l,a]=o;e.tableCellAlignToStyle&&l==="align"&&typeof a=="string"&&ws.has(n.tagName)?i=a:r[l]=a}}if(i){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return r}function Ms(e,n){const r={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const o=i.data.estree.body[0];o.type;const l=o.expression;l.type;const a=l.properties[0];a.type,Object.assign(r,e.evaluater.evaluateExpression(a.argument))}else We(e,n.position);else{const s=i.name;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const a=i.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else We(e,n.position);else o=i.value===null?!0:i.value;r[s]=o}return r}function Yt(e,n){const r=[];let i=-1;const s=e.passKeys?new Map:ks;for(;++i<n.children.length;){const o=n.children[i];let l;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const c=s.get(u)||0;l=u+"-"+c,s.set(u,c+1)}}const a=Sr(e,o,l);a!==void 0&&r.push(a)}return r}function Ps(e,n,r){const i=es(e.schema,n);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=i.commaSeparated?Hi(r):ss(r)),i.property==="style"){let s=typeof r=="object"?r:Bs(e,String(r));return e.stylePropertyNameCase==="css"&&(s=_s(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&i.space?rs[i.property]||i.property:i.attribute,r]}}function Bs(e,n){const r={};try{Es(n,i)}catch(s){if(!e.ignoreInvalidStyle){const o=s,l=new ie("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:o,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=kr+"#cannot-parse-style-attribute",l}}return r;function i(s,o){let l=s;l.slice(0,2)!=="--"&&(l.slice(0,4)==="-ms-"&&(l="ms-"+l.slice(4)),l=l.replace(Rs,Hs)),r[l]=o}}function Cr(e,n,r){let i;if(!r)i={type:"Literal",value:n};else if(n.includes(".")){const s=n.split(".");let o=-1,l;for(;++o<s.length;){const a=cn(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};l=l?{type:"MemberExpression",object:l,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}i=l}else i=cn(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const s=i.value;return Jt.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(i);We(e)}function We(e,n){const r=new ie("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=kr+"#cannot-handle-mdx-estrees-without-createevaluater",r}function _s(e){const n={};let r;for(r in e)Jt.call(e,r)&&(n[Vs(r)]=e[r]);return n}function Vs(e){let n=e.replace(Ss,qs);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function Hs(e,n){return n.toUpperCase()}function qs(e){return"-"+e.toLowerCase()}const kt={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Us={};function $s(e,n){const r=n||Us,i=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,s=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return wr(e,i,s)}function wr(e,n,r){if(Ks(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return bn(e.children,n,r)}return Array.isArray(e)?bn(e,n,r):""}function bn(e,n,r){const i=[];let s=-1;for(;++s<e.length;)i[s]=wr(e[s],n,r);return i.join("")}function Ks(e){return!!(e&&typeof e=="object")}const kn=document.createElement("i");function Zt(e){const n="&"+e+";";kn.innerHTML=n;const r=kn.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===n?!1:r}function be(e,n,r,i){const s=e.length;let o=0,l;if(n<0?n=-n>s?0:s+n:n=n>s?s:n,r=r>0?r:0,i.length<1e4)l=Array.from(i),l.unshift(n,r),e.splice(...l);else for(r&&e.splice(n,r);o<i.length;)l=i.slice(o,o+1e4),l.unshift(n,0),e.splice(...l),o+=1e4,n+=1e4}function de(e,n){return e.length>0?(be(e,e.length,0,n),e):n}const Sn={}.hasOwnProperty;function Ws(e){const n={};let r=-1;for(;++r<e.length;)Gs(n,e[r]);return n}function Gs(e,n){let r;for(r in n){const s=(Sn.call(e,r)?e[r]:void 0)||(e[r]={}),o=n[r];let l;if(o)for(l in o){Sn.call(s,l)||(s[l]=[]);const a=o[l];Qs(s[l],Array.isArray(a)?a:a?[a]:[])}}}function Qs(e,n){let r=-1;const i=[];for(;++r<n.length;)(n[r].add==="after"?e:i).push(n[r]);be(e,0,0,i)}function vr(e,n){const r=Number.parseInt(e,n);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Pe(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Js=Ne(new RegExp("\\p{P}","u")),Ee=Ne(/[A-Za-z]/),pe=Ne(/[\dA-Za-z]/),Xs=Ne(/[#-'*+\--9=?A-Z^-~]/);function Pt(e){return e!==null&&(e<32||e===127)}const Bt=Ne(/\d/),Ys=Ne(/[\dA-Fa-f]/),Nr=Ne(/[!-/:-@[-`{-~]/);function F(e){return e!==null&&e<-2}function le(e){return e!==null&&(e<0||e===32)}function K(e){return e===-2||e===-1||e===32}function Zs(e){return Nr(e)||Js(e)}const eo=Ne(/\s/);function Ne(e){return n;function n(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function _e(e){const n=[];let r=-1,i=0,s=0;for(;++r<e.length;){const o=e.charCodeAt(r);let l="";if(o===37&&pe(e.charCodeAt(r+1))&&pe(e.charCodeAt(r+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(l=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(r+1);o<56320&&a>56319&&a<57344?(l=String.fromCharCode(o,a),s=1):l="�"}else l=String.fromCharCode(o);l&&(n.push(e.slice(i,r),encodeURIComponent(l)),i=r+s+1,l=""),s&&(r+=s,s=0)}return n.join("")+e.slice(i)}function G(e,n,r,i){const s=i?i-1:Number.POSITIVE_INFINITY;let o=0;return l;function l(u){return K(u)?(e.enter(r),a(u)):n(u)}function a(u){return K(u)&&o++<s?(e.consume(u),a):(e.exit(r),n(u))}}const to={tokenize:no};function no(e){const n=e.attempt(this.parser.constructs.contentInitial,i,s);let r;return n;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),G(e,n,"linePrefix")}function s(a){return e.enter("paragraph"),o(a)}function o(a){const u=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=u),r=u,l(a)}function l(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return F(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),l)}}const ro={tokenize:io},Rn={tokenize:so};function io(e){const n=this,r=[];let i=0,s,o,l;return a;function a(S){if(i<r.length){const D=r[i];return n.containerState=D[1],e.attempt(D[0].continuation,u,c)(S)}return c(S)}function u(S){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,s&&w();const D=n.events.length;let O=D,b;for(;O--;)if(n.events[O][0]==="exit"&&n.events[O][1].type==="chunkFlow"){b=n.events[O][1].end;break}y(i);let M=D;for(;M<n.events.length;)n.events[M][1].end=Object.assign({},b),M++;return be(n.events,O+1,0,n.events.slice(D)),n.events.length=M,c(S)}return a(S)}function c(S){if(i===r.length){if(!s)return m(S);if(s.currentConstruct&&s.currentConstruct.concrete)return j(S);n.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Rn,x,p)(S)}function x(S){return s&&w(),y(i),m(S)}function p(S){return n.parser.lazy[n.now().line]=i!==r.length,l=n.now().offset,j(S)}function m(S){return n.containerState={},e.attempt(Rn,d,j)(S)}function d(S){return i++,r.push([n.currentConstruct,n.containerState]),m(S)}function j(S){if(S===null){s&&w(),y(0),e.consume(S);return}return s=s||n.parser.flow(n.now()),e.enter("chunkFlow",{contentType:"flow",previous:o,_tokenizer:s}),E(S)}function E(S){if(S===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(S);return}return F(S)?(e.consume(S),k(e.exit("chunkFlow")),i=0,n.interrupt=void 0,a):(e.consume(S),E)}function k(S,D){const O=n.sliceStream(S);if(D&&O.push(null),S.previous=o,o&&(o.next=S),o=S,s.defineSkip(S.start),s.write(O),n.parser.lazy[S.start.line]){let b=s.events.length;for(;b--;)if(s.events[b][1].start.offset<l&&(!s.events[b][1].end||s.events[b][1].end.offset>l))return;const M=n.events.length;let T=M,z,H;for(;T--;)if(n.events[T][0]==="exit"&&n.events[T][1].type==="chunkFlow"){if(z){H=n.events[T][1].end;break}z=!0}for(y(i),b=M;b<n.events.length;)n.events[b][1].end=Object.assign({},H),b++;be(n.events,T+1,0,n.events.slice(M)),n.events.length=b}}function y(S){let D=r.length;for(;D-- >S;){const O=r[D];n.containerState=O[1],O[0].exit.call(n,e)}r.length=S}function w(){s.write([null]),o=void 0,s=void 0,n.containerState._closeFlow=void 0}}function so(e,n,r){return G(e,e.attempt(this.parser.constructs.document,n,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Cn(e){if(e===null||le(e)||eo(e))return 1;if(Zs(e))return 2}function en(e,n,r){const i=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!i.includes(o)&&(n=o(n,r),i.push(o))}return n}const _t={name:"attention",tokenize:lo,resolveAll:oo};function oo(e,n){let r=-1,i,s,o,l,a,u,c,x;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(i=r;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[i][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;u=e[i][1].end.offset-e[i][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p=Object.assign({},e[i][1].end),m=Object.assign({},e[r][1].start);wn(p,-u),wn(m,u),l={type:u>1?"strongSequence":"emphasisSequence",start:p,end:Object.assign({},e[i][1].end)},a={type:u>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[r][1].start),end:m},o={type:u>1?"strongText":"emphasisText",start:Object.assign({},e[i][1].end),end:Object.assign({},e[r][1].start)},s={type:u>1?"strong":"emphasis",start:Object.assign({},l.start),end:Object.assign({},a.end)},e[i][1].end=Object.assign({},l.start),e[r][1].start=Object.assign({},a.end),c=[],e[i][1].end.offset-e[i][1].start.offset&&(c=de(c,[["enter",e[i][1],n],["exit",e[i][1],n]])),c=de(c,[["enter",s,n],["enter",l,n],["exit",l,n],["enter",o,n]]),c=de(c,en(n.parser.constructs.insideSpan.null,e.slice(i+1,r),n)),c=de(c,[["exit",o,n],["enter",a,n],["exit",a,n],["exit",s,n]]),e[r][1].end.offset-e[r][1].start.offset?(x=2,c=de(c,[["enter",e[r][1],n],["exit",e[r][1],n]])):x=0,be(e,i-1,r-i+3,c),r=i+c.length-x-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function lo(e,n){const r=this.parser.constructs.attentionMarkers.null,i=this.previous,s=Cn(i);let o;return l;function l(u){return o=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===o)return e.consume(u),a;const c=e.exit("attentionSequence"),x=Cn(u),p=!x||x===2&&s||r.includes(u),m=!s||s===2&&x||r.includes(i);return c._open=!!(o===42?p:p&&(s||!m)),c._close=!!(o===42?m:m&&(x||!p)),n(u)}}function wn(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const ao={name:"autolink",tokenize:uo};function uo(e,n,r){let i=0;return s;function s(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(d){return Ee(d)?(e.consume(d),l):c(d)}function l(d){return d===43||d===45||d===46||pe(d)?(i=1,a(d)):c(d)}function a(d){return d===58?(e.consume(d),i=0,u):(d===43||d===45||d===46||pe(d))&&i++<32?(e.consume(d),a):(i=0,c(d))}function u(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),n):d===null||d===32||d===60||Pt(d)?r(d):(e.consume(d),u)}function c(d){return d===64?(e.consume(d),x):Xs(d)?(e.consume(d),c):r(d)}function x(d){return pe(d)?p(d):r(d)}function p(d){return d===46?(e.consume(d),i=0,x):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),n):m(d)}function m(d){if((d===45||pe(d))&&i++<63){const j=d===45?m:p;return e.consume(d),j}return r(d)}}const pt={tokenize:co,partial:!0};function co(e,n,r){return i;function i(o){return K(o)?G(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||F(o)?n(o):r(o)}}const Ir={name:"blockQuote",tokenize:po,continuation:{tokenize:xo},exit:mo};function po(e,n,r){const i=this;return s;function s(l){if(l===62){const a=i.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),o}return r(l)}function o(l){return K(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(l))}}function xo(e,n,r){const i=this;return s;function s(l){return K(l)?G(e,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):o(l)}function o(l){return e.attempt(Ir,n,r)(l)}}function mo(e){e.exit("blockQuote")}const Ar={name:"characterEscape",tokenize:ho};function ho(e,n,r){return i;function i(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return Nr(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):r(o)}}const Tr={name:"characterReference",tokenize:fo};function fo(e,n,r){const i=this;let s=0,o,l;return a;function a(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),o=31,l=pe,x(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,l=Ys,x):(e.enter("characterReferenceValue"),o=7,l=Bt,x(p))}function x(p){if(p===59&&s){const m=e.exit("characterReferenceValue");return l===pe&&!Zt(i.sliceSerialize(m))?r(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return l(p)&&s++<o?(e.consume(p),x):r(p)}}const vn={tokenize:jo,partial:!0},Nn={name:"codeFenced",tokenize:go,concrete:!0};function go(e,n,r){const i=this,s={tokenize:O,partial:!0};let o=0,l=0,a;return u;function u(b){return c(b)}function c(b){const M=i.events[i.events.length-1];return o=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,a=b,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(b)}function x(b){return b===a?(l++,e.consume(b),x):l<3?r(b):(e.exit("codeFencedFenceSequence"),K(b)?G(e,p,"whitespace")(b):p(b))}function p(b){return b===null||F(b)?(e.exit("codeFencedFence"),i.interrupt?n(b):e.check(vn,E,D)(b)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===null||F(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(b)):K(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),G(e,d,"whitespace")(b)):b===96&&b===a?r(b):(e.consume(b),m)}function d(b){return b===null||F(b)?p(b):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(b))}function j(b){return b===null||F(b)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(b)):b===96&&b===a?r(b):(e.consume(b),j)}function E(b){return e.attempt(s,D,k)(b)}function k(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),y}function y(b){return o>0&&K(b)?G(e,w,"linePrefix",o+1)(b):w(b)}function w(b){return b===null||F(b)?e.check(vn,E,D)(b):(e.enter("codeFlowValue"),S(b))}function S(b){return b===null||F(b)?(e.exit("codeFlowValue"),w(b)):(e.consume(b),S)}function D(b){return e.exit("codeFenced"),n(b)}function O(b,M,T){let z=0;return H;function H(P){return b.enter("lineEnding"),b.consume(P),b.exit("lineEnding"),I}function I(P){return b.enter("codeFencedFence"),K(P)?G(b,v,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):v(P)}function v(P){return P===a?(b.enter("codeFencedFenceSequence"),U(P)):T(P)}function U(P){return P===a?(z++,b.consume(P),U):z>=l?(b.exit("codeFencedFenceSequence"),K(P)?G(b,$,"whitespace")(P):$(P)):T(P)}function $(P){return P===null||F(P)?(b.exit("codeFencedFence"),M(P)):T(P)}}}function jo(e,n,r){const i=this;return s;function s(l){return l===null?r(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o)}function o(l){return i.parser.lazy[i.now().line]?r(l):n(l)}}const St={name:"codeIndented",tokenize:Eo},yo={tokenize:bo,partial:!0};function Eo(e,n,r){const i=this;return s;function s(c){return e.enter("codeIndented"),G(e,o,"linePrefix",5)(c)}function o(c){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?l(c):r(c)}function l(c){return c===null?u(c):F(c)?e.attempt(yo,l,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||F(c)?(e.exit("codeFlowValue"),l(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),n(c)}}function bo(e,n,r){const i=this;return s;function s(l){return i.parser.lazy[i.now().line]?r(l):F(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s):G(e,o,"linePrefix",5)(l)}function o(l){const a=i.events[i.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(l):F(l)?s(l):r(l)}}const ko={name:"codeText",tokenize:Co,resolve:So,previous:Ro};function So(e){let n=e.length-4,r=3,i,s;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=r;++i<n;)if(e[i][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[n][1].type="codeTextPadding",r+=2,n-=2;break}}for(i=r-1,n++;++i<=n;)s===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(s=i):(i===n||e[i][1].type==="lineEnding")&&(e[s][1].type="codeTextData",i!==s+2&&(e[s][1].end=e[i-1][1].end,e.splice(s+2,i-s-2),n-=i-s-2,i=s+2),s=void 0);return e}function Ro(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Co(e,n,r){let i=0,s,o;return l;function l(p){return e.enter("codeText"),e.enter("codeTextSequence"),a(p)}function a(p){return p===96?(e.consume(p),i++,a):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?r(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(o=e.enter("codeTextSequence"),s=0,x(p)):F(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(p))}function c(p){return p===null||p===32||p===96||F(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),c)}function x(p){return p===96?(e.consume(p),s++,x):s===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(p)):(o.type="codeTextData",c(p))}}function zr(e){const n={};let r=-1,i,s,o,l,a,u,c;for(;++r<e.length;){for(;r in n;)r=n[r];if(i=e[r],r&&i[1].type==="chunkFlow"&&e[r-1][1].type==="listItemPrefix"&&(u=i[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,wo(e,r)),r=n[r],c=!0);else if(i[1]._container){for(o=r,s=void 0;o--&&(l=e[o],l[1].type==="lineEnding"||l[1].type==="lineEndingBlank");)l[0]==="enter"&&(s&&(e[s][1].type="lineEndingBlank"),l[1].type="lineEnding",s=o);s&&(i[1].end=Object.assign({},e[s][1].start),a=e.slice(s,r),a.unshift(i),be(e,s,r-s+1,a))}}return!c}function wo(e,n){const r=e[n][1],i=e[n][2];let s=n-1;const o=[],l=r._tokenizer||i.parser[r.contentType](r.start),a=l.events,u=[],c={};let x,p,m=-1,d=r,j=0,E=0;const k=[E];for(;d;){for(;e[++s][1]!==d;);o.push(s),d._tokenizer||(x=i.sliceStream(d),d.next||x.push(null),p&&l.defineSkip(d.start),d._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(x),d._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),p=d,d=d.next}for(d=r;++m<a.length;)a[m][0]==="exit"&&a[m-1][0]==="enter"&&a[m][1].type===a[m-1][1].type&&a[m][1].start.line!==a[m][1].end.line&&(E=m+1,k.push(E),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(l.events=[],d?(d._tokenizer=void 0,d.previous=void 0):k.pop(),m=k.length;m--;){const y=a.slice(k[m],k[m+1]),w=o.pop();u.unshift([w,w+y.length-1]),be(e,w,2,y)}for(m=-1;++m<u.length;)c[j+u[m][0]]=j+u[m][1],j+=u[m][1]-u[m][0]-1;return c}const vo={tokenize:Ao,resolve:Io},No={tokenize:To,partial:!0};function Io(e){return zr(e),e}function Ao(e,n){let r;return i;function i(a){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?o(a):F(a)?e.check(No,l,o)(a):(e.consume(a),s)}function o(a){return e.exit("chunkContent"),e.exit("content"),n(a)}function l(a){return e.consume(a),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}function To(e,n,r){const i=this;return s;function s(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),G(e,o,"linePrefix")}function o(l){if(l===null||F(l))return r(l);const a=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(l):e.interrupt(i.parser.constructs.flow,r,n)(l)}}function Lr(e,n,r,i,s,o,l,a,u){const c=u||Number.POSITIVE_INFINITY;let x=0;return p;function p(y){return y===60?(e.enter(i),e.enter(s),e.enter(o),e.consume(y),e.exit(o),m):y===null||y===32||y===41||Pt(y)?r(y):(e.enter(i),e.enter(l),e.enter(a),e.enter("chunkString",{contentType:"string"}),E(y))}function m(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),e.exit(i),n):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(y))}function d(y){return y===62?(e.exit("chunkString"),e.exit(a),m(y)):y===null||y===60||F(y)?r(y):(e.consume(y),y===92?j:d)}function j(y){return y===60||y===62||y===92?(e.consume(y),d):d(y)}function E(y){return!x&&(y===null||y===41||le(y))?(e.exit("chunkString"),e.exit(a),e.exit(l),e.exit(i),n(y)):x<c&&y===40?(e.consume(y),x++,E):y===41?(e.consume(y),x--,E):y===null||y===32||y===40||Pt(y)?r(y):(e.consume(y),y===92?k:E)}function k(y){return y===40||y===41||y===92?(e.consume(y),E):E(y)}}function Or(e,n,r,i,s,o){const l=this;let a=0,u;return c;function c(d){return e.enter(i),e.enter(s),e.consume(d),e.exit(s),e.enter(o),x}function x(d){return a>999||d===null||d===91||d===93&&!u||d===94&&!a&&"_hiddenFootnoteSupport"in l.parser.constructs?r(d):d===93?(e.exit(o),e.enter(s),e.consume(d),e.exit(s),e.exit(i),n):F(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===null||d===91||d===93||F(d)||a++>999?(e.exit("chunkString"),x(d)):(e.consume(d),u||(u=!K(d)),d===92?m:p)}function m(d){return d===91||d===92||d===93?(e.consume(d),a++,p):p(d)}}function Dr(e,n,r,i,s,o){let l;return a;function a(m){return m===34||m===39||m===40?(e.enter(i),e.enter(s),e.consume(m),e.exit(s),l=m===40?41:m,u):r(m)}function u(m){return m===l?(e.enter(s),e.consume(m),e.exit(s),e.exit(i),n):(e.enter(o),c(m))}function c(m){return m===l?(e.exit(o),u(l)):m===null?r(m):F(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),G(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(m))}function x(m){return m===l||m===null||F(m)?(e.exit("chunkString"),c(m)):(e.consume(m),m===92?p:x)}function p(m){return m===l||m===92?(e.consume(m),x):x(m)}}function Ke(e,n){let r;return i;function i(s){return F(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),r=!0,i):K(s)?G(e,i,r?"linePrefix":"lineSuffix")(s):n(s)}}const zo={name:"definition",tokenize:Oo},Lo={tokenize:Do,partial:!0};function Oo(e,n,r){const i=this;let s;return o;function o(d){return e.enter("definition"),l(d)}function l(d){return Or.call(i,e,a,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return s=Pe(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),d===58?(e.enter("definitionMarker"),e.consume(d),e.exit("definitionMarker"),u):r(d)}function u(d){return le(d)?Ke(e,c)(d):c(d)}function c(d){return Lr(e,x,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function x(d){return e.attempt(Lo,p,p)(d)}function p(d){return K(d)?G(e,m,"whitespace")(d):m(d)}function m(d){return d===null||F(d)?(e.exit("definition"),i.parser.defined.push(s),n(d)):r(d)}}function Do(e,n,r){return i;function i(a){return le(a)?Ke(e,s)(a):r(a)}function s(a){return Dr(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return K(a)?G(e,l,"whitespace")(a):l(a)}function l(a){return a===null||F(a)?n(a):r(a)}}const Fo={name:"hardBreakEscape",tokenize:Mo};function Mo(e,n,r){return i;function i(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return F(o)?(e.exit("hardBreakEscape"),n(o)):r(o)}}const Po={name:"headingAtx",tokenize:_o,resolve:Bo};function Bo(e,n){let r=e.length-2,i=3,s,o;return e[i][1].type==="whitespace"&&(i+=2),r-2>i&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(i===r-1||r-4>i&&e[r-2][1].type==="whitespace")&&(r-=i+1===r?2:4),r>i&&(s={type:"atxHeadingText",start:e[i][1].start,end:e[r][1].end},o={type:"chunkText",start:e[i][1].start,end:e[r][1].end,contentType:"text"},be(e,i,r-i+1,[["enter",s,n],["enter",o,n],["exit",o,n],["exit",s,n]])),e}function _o(e,n,r){let i=0;return s;function s(x){return e.enter("atxHeading"),o(x)}function o(x){return e.enter("atxHeadingSequence"),l(x)}function l(x){return x===35&&i++<6?(e.consume(x),l):x===null||le(x)?(e.exit("atxHeadingSequence"),a(x)):r(x)}function a(x){return x===35?(e.enter("atxHeadingSequence"),u(x)):x===null||F(x)?(e.exit("atxHeading"),n(x)):K(x)?G(e,a,"whitespace")(x):(e.enter("atxHeadingText"),c(x))}function u(x){return x===35?(e.consume(x),u):(e.exit("atxHeadingSequence"),a(x))}function c(x){return x===null||x===35||le(x)?(e.exit("atxHeadingText"),a(x)):(e.consume(x),c)}}const Vo=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],In=["pre","script","style","textarea"],Ho={name:"htmlFlow",tokenize:Ko,resolveTo:$o,concrete:!0},qo={tokenize:Go,partial:!0},Uo={tokenize:Wo,partial:!0};function $o(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function Ko(e,n,r){const i=this;let s,o,l,a,u;return c;function c(f){return x(f)}function x(f){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(f),p}function p(f){return f===33?(e.consume(f),m):f===47?(e.consume(f),o=!0,E):f===63?(e.consume(f),s=3,i.interrupt?n:h):Ee(f)?(e.consume(f),l=String.fromCharCode(f),k):r(f)}function m(f){return f===45?(e.consume(f),s=2,d):f===91?(e.consume(f),s=5,a=0,j):Ee(f)?(e.consume(f),s=4,i.interrupt?n:h):r(f)}function d(f){return f===45?(e.consume(f),i.interrupt?n:h):r(f)}function j(f){const ae="CDATA[";return f===ae.charCodeAt(a++)?(e.consume(f),a===ae.length?i.interrupt?n:v:j):r(f)}function E(f){return Ee(f)?(e.consume(f),l=String.fromCharCode(f),k):r(f)}function k(f){if(f===null||f===47||f===62||le(f)){const ae=f===47,ge=l.toLowerCase();return!ae&&!o&&In.includes(ge)?(s=1,i.interrupt?n(f):v(f)):Vo.includes(l.toLowerCase())?(s=6,ae?(e.consume(f),y):i.interrupt?n(f):v(f)):(s=7,i.interrupt&&!i.parser.lazy[i.now().line]?r(f):o?w(f):S(f))}return f===45||pe(f)?(e.consume(f),l+=String.fromCharCode(f),k):r(f)}function y(f){return f===62?(e.consume(f),i.interrupt?n:v):r(f)}function w(f){return K(f)?(e.consume(f),w):H(f)}function S(f){return f===47?(e.consume(f),H):f===58||f===95||Ee(f)?(e.consume(f),D):K(f)?(e.consume(f),S):H(f)}function D(f){return f===45||f===46||f===58||f===95||pe(f)?(e.consume(f),D):O(f)}function O(f){return f===61?(e.consume(f),b):K(f)?(e.consume(f),O):S(f)}function b(f){return f===null||f===60||f===61||f===62||f===96?r(f):f===34||f===39?(e.consume(f),u=f,M):K(f)?(e.consume(f),b):T(f)}function M(f){return f===u?(e.consume(f),u=null,z):f===null||F(f)?r(f):(e.consume(f),M)}function T(f){return f===null||f===34||f===39||f===47||f===60||f===61||f===62||f===96||le(f)?O(f):(e.consume(f),T)}function z(f){return f===47||f===62||K(f)?S(f):r(f)}function H(f){return f===62?(e.consume(f),I):r(f)}function I(f){return f===null||F(f)?v(f):K(f)?(e.consume(f),I):r(f)}function v(f){return f===45&&s===2?(e.consume(f),q):f===60&&s===1?(e.consume(f),Q):f===62&&s===4?(e.consume(f),J):f===63&&s===3?(e.consume(f),h):f===93&&s===5?(e.consume(f),N):F(f)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(qo,te,U)(f)):f===null||F(f)?(e.exit("htmlFlowData"),U(f)):(e.consume(f),v)}function U(f){return e.check(Uo,$,te)(f)}function $(f){return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),P}function P(f){return f===null||F(f)?U(f):(e.enter("htmlFlowData"),v(f))}function q(f){return f===45?(e.consume(f),h):v(f)}function Q(f){return f===47?(e.consume(f),l="",re):v(f)}function re(f){if(f===62){const ae=l.toLowerCase();return In.includes(ae)?(e.consume(f),J):v(f)}return Ee(f)&&l.length<8?(e.consume(f),l+=String.fromCharCode(f),re):v(f)}function N(f){return f===93?(e.consume(f),h):v(f)}function h(f){return f===62?(e.consume(f),J):f===45&&s===2?(e.consume(f),h):v(f)}function J(f){return f===null||F(f)?(e.exit("htmlFlowData"),te(f)):(e.consume(f),J)}function te(f){return e.exit("htmlFlow"),n(f)}}function Wo(e,n,r){const i=this;return s;function s(l){return F(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):r(l)}function o(l){return i.parser.lazy[i.now().line]?r(l):n(l)}}function Go(e,n,r){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(pt,n,r)}}const Qo={name:"htmlText",tokenize:Jo};function Jo(e,n,r){const i=this;let s,o,l;return a;function a(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),u}function u(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),O):h===63?(e.consume(h),S):Ee(h)?(e.consume(h),T):r(h)}function c(h){return h===45?(e.consume(h),x):h===91?(e.consume(h),o=0,j):Ee(h)?(e.consume(h),w):r(h)}function x(h){return h===45?(e.consume(h),d):r(h)}function p(h){return h===null?r(h):h===45?(e.consume(h),m):F(h)?(l=p,Q(h)):(e.consume(h),p)}function m(h){return h===45?(e.consume(h),d):p(h)}function d(h){return h===62?q(h):h===45?m(h):p(h)}function j(h){const J="CDATA[";return h===J.charCodeAt(o++)?(e.consume(h),o===J.length?E:j):r(h)}function E(h){return h===null?r(h):h===93?(e.consume(h),k):F(h)?(l=E,Q(h)):(e.consume(h),E)}function k(h){return h===93?(e.consume(h),y):E(h)}function y(h){return h===62?q(h):h===93?(e.consume(h),y):E(h)}function w(h){return h===null||h===62?q(h):F(h)?(l=w,Q(h)):(e.consume(h),w)}function S(h){return h===null?r(h):h===63?(e.consume(h),D):F(h)?(l=S,Q(h)):(e.consume(h),S)}function D(h){return h===62?q(h):S(h)}function O(h){return Ee(h)?(e.consume(h),b):r(h)}function b(h){return h===45||pe(h)?(e.consume(h),b):M(h)}function M(h){return F(h)?(l=M,Q(h)):K(h)?(e.consume(h),M):q(h)}function T(h){return h===45||pe(h)?(e.consume(h),T):h===47||h===62||le(h)?z(h):r(h)}function z(h){return h===47?(e.consume(h),q):h===58||h===95||Ee(h)?(e.consume(h),H):F(h)?(l=z,Q(h)):K(h)?(e.consume(h),z):q(h)}function H(h){return h===45||h===46||h===58||h===95||pe(h)?(e.consume(h),H):I(h)}function I(h){return h===61?(e.consume(h),v):F(h)?(l=I,Q(h)):K(h)?(e.consume(h),I):z(h)}function v(h){return h===null||h===60||h===61||h===62||h===96?r(h):h===34||h===39?(e.consume(h),s=h,U):F(h)?(l=v,Q(h)):K(h)?(e.consume(h),v):(e.consume(h),$)}function U(h){return h===s?(e.consume(h),s=void 0,P):h===null?r(h):F(h)?(l=U,Q(h)):(e.consume(h),U)}function $(h){return h===null||h===34||h===39||h===60||h===61||h===96?r(h):h===47||h===62||le(h)?z(h):(e.consume(h),$)}function P(h){return h===47||h===62||le(h)?z(h):r(h)}function q(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),n):r(h)}function Q(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),re}function re(h){return K(h)?G(e,N,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):N(h)}function N(h){return e.enter("htmlTextData"),l(h)}}const tn={name:"labelEnd",tokenize:nl,resolveTo:tl,resolveAll:el},Xo={tokenize:rl},Yo={tokenize:il},Zo={tokenize:sl};function el(e){let n=-1;for(;++n<e.length;){const r=e[n][1];(r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd")&&(e.splice(n+1,r.type==="labelImage"?4:2),r.type="data",n++)}return e}function tl(e,n){let r=e.length,i=0,s,o,l,a;for(;r--;)if(s=e[r][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[r][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(l){if(e[r][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=r,s.type!=="labelLink")){i=2;break}}else s.type==="labelEnd"&&(l=r);const u={type:e[o][1].type==="labelLink"?"link":"image",start:Object.assign({},e[o][1].start),end:Object.assign({},e[e.length-1][1].end)},c={type:"label",start:Object.assign({},e[o][1].start),end:Object.assign({},e[l][1].end)},x={type:"labelText",start:Object.assign({},e[o+i+2][1].end),end:Object.assign({},e[l-2][1].start)};return a=[["enter",u,n],["enter",c,n]],a=de(a,e.slice(o+1,o+i+3)),a=de(a,[["enter",x,n]]),a=de(a,en(n.parser.constructs.insideSpan.null,e.slice(o+i+4,l-3),n)),a=de(a,[["exit",x,n],e[l-2],e[l-1],["exit",c,n]]),a=de(a,e.slice(l+1)),a=de(a,[["exit",u,n]]),be(e,o,e.length,a),e}function nl(e,n,r){const i=this;let s=i.events.length,o,l;for(;s--;)if((i.events[s][1].type==="labelImage"||i.events[s][1].type==="labelLink")&&!i.events[s][1]._balanced){o=i.events[s][1];break}return a;function a(m){return o?o._inactive?p(m):(l=i.parser.defined.includes(Pe(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),u):r(m)}function u(m){return m===40?e.attempt(Xo,x,l?x:p)(m):m===91?e.attempt(Yo,x,l?c:p)(m):l?x(m):p(m)}function c(m){return e.attempt(Zo,x,p)(m)}function x(m){return n(m)}function p(m){return o._balanced=!0,r(m)}}function rl(e,n,r){return i;function i(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),s}function s(p){return le(p)?Ke(e,o)(p):o(p)}function o(p){return p===41?x(p):Lr(e,l,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function l(p){return le(p)?Ke(e,u)(p):x(p)}function a(p){return r(p)}function u(p){return p===34||p===39||p===40?Dr(e,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):x(p)}function c(p){return le(p)?Ke(e,x)(p):x(p)}function x(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),n):r(p)}}function il(e,n,r){const i=this;return s;function s(a){return Or.call(i,e,o,l,"reference","referenceMarker","referenceString")(a)}function o(a){return i.parser.defined.includes(Pe(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(a):r(a)}function l(a){return r(a)}}function sl(e,n,r){return i;function i(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),n):r(o)}}const ol={name:"labelStartImage",tokenize:ll,resolveAll:tn.resolveAll};function ll(e,n,r){const i=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),l):r(a)}function l(a){return a===94&&"_hiddenFootnoteSupport"in i.parser.constructs?r(a):n(a)}}const al={name:"labelStartLink",tokenize:ul,resolveAll:tn.resolveAll};function ul(e,n,r){const i=this;return s;function s(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),o}function o(l){return l===94&&"_hiddenFootnoteSupport"in i.parser.constructs?r(l):n(l)}}const Rt={name:"lineEnding",tokenize:cl};function cl(e,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),G(e,n,"linePrefix")}}const it={name:"thematicBreak",tokenize:pl};function pl(e,n,r){let i=0,s;return o;function o(c){return e.enter("thematicBreak"),l(c)}function l(c){return s=c,a(c)}function a(c){return c===s?(e.enter("thematicBreakSequence"),u(c)):i>=3&&(c===null||F(c))?(e.exit("thematicBreak"),n(c)):r(c)}function u(c){return c===s?(e.consume(c),i++,u):(e.exit("thematicBreakSequence"),K(c)?G(e,a,"whitespace")(c):a(c))}}const oe={name:"list",tokenize:ml,continuation:{tokenize:hl},exit:gl},xl={tokenize:jl,partial:!0},dl={tokenize:fl,partial:!0};function ml(e,n,r){const i=this,s=i.events[i.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,l=0;return a;function a(d){const j=i.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!i.containerState.marker||d===i.containerState.marker:Bt(d)){if(i.containerState.type||(i.containerState.type=j,e.enter(j,{_container:!0})),j==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(it,r,c)(d):c(d);if(!i.interrupt||d===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(d)}return r(d)}function u(d){return Bt(d)&&++l<10?(e.consume(d),u):(!i.interrupt||l<2)&&(i.containerState.marker?d===i.containerState.marker:d===41||d===46)?(e.exit("listItemValue"),c(d)):r(d)}function c(d){return e.enter("listItemMarker"),e.consume(d),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||d,e.check(pt,i.interrupt?r:x,e.attempt(xl,m,p))}function x(d){return i.containerState.initialBlankLine=!0,o++,m(d)}function p(d){return K(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),m):r(d)}function m(d){return i.containerState.size=o+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(d)}}function hl(e,n,r){const i=this;return i.containerState._closeFlow=void 0,e.check(pt,s,o);function s(a){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,G(e,n,"listItemIndent",i.containerState.size+1)(a)}function o(a){return i.containerState.furtherBlankLines||!K(a)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,l(a)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(dl,n,l)(a))}function l(a){return i.containerState._closeFlow=!0,i.interrupt=void 0,G(e,e.attempt(oe,n,r),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function fl(e,n,r){const i=this;return G(e,s,"listItemIndent",i.containerState.size+1);function s(o){const l=i.events[i.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===i.containerState.size?n(o):r(o)}}function gl(e){e.exit(this.containerState.type)}function jl(e,n,r){const i=this;return G(e,s,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const l=i.events[i.events.length-1];return!K(o)&&l&&l[1].type==="listItemPrefixWhitespace"?n(o):r(o)}}const An={name:"setextUnderline",tokenize:El,resolveTo:yl};function yl(e,n){let r=e.length,i,s,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){i=r;break}e[r][1].type==="paragraph"&&(s=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);const l={type:"setextHeading",start:Object.assign({},e[s][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",l,n]),e.splice(o+1,0,["exit",e[i][1],n]),e[i][1].end=Object.assign({},e[o][1].end)):e[i][1]=l,e.push(["exit",l,n]),e}function El(e,n,r){const i=this;let s;return o;function o(c){let x=i.events.length,p;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){p=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||p)?(e.enter("setextHeadingLine"),s=c,l(c)):r(c)}function l(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===s?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),K(c)?G(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||F(c)?(e.exit("setextHeadingLine"),n(c)):r(c)}}const bl={tokenize:kl};function kl(e){const n=this,r=e.attempt(pt,i,e.attempt(this.parser.constructs.flowInitial,s,G(e,e.attempt(this.parser.constructs.flow,s,e.attempt(vo,s)),"linePrefix")));return r;function i(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),n.currentConstruct=void 0,r}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n.currentConstruct=void 0,r}}const Sl={resolveAll:Mr()},Rl=Fr("string"),Cl=Fr("text");function Fr(e){return{tokenize:n,resolveAll:Mr(e==="text"?wl:void 0)};function n(r){const i=this,s=this.parser.constructs[e],o=r.attempt(s,l,a);return l;function l(x){return c(x)?o(x):a(x)}function a(x){if(x===null){r.consume(x);return}return r.enter("data"),r.consume(x),u}function u(x){return c(x)?(r.exit("data"),o(x)):(r.consume(x),u)}function c(x){if(x===null)return!0;const p=s[x];let m=-1;if(p)for(;++m<p.length;){const d=p[m];if(!d.previous||d.previous.call(i,i.previous))return!0}return!1}}}function Mr(e){return n;function n(r,i){let s=-1,o;for(;++s<=r.length;)o===void 0?r[s]&&r[s][1].type==="data"&&(o=s,s++):(!r[s]||r[s][1].type!=="data")&&(s!==o+2&&(r[o][1].end=r[s-1][1].end,r.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(r,i):r}}function wl(e,n){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const i=e[r-1][1],s=n.sliceStream(i);let o=s.length,l=-1,a=0,u;for(;o--;){const c=s[o];if(typeof c=="string"){for(l=c.length;c.charCodeAt(l-1)===32;)a++,l--;if(l)break;l=-1}else if(c===-2)u=!0,a++;else if(c!==-1){o++;break}}if(a){const c={type:r===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{line:i.end.line,column:i.end.column-a,offset:i.end.offset-a,_index:i.start._index+o,_bufferIndex:o?l:i.start._bufferIndex+l},end:Object.assign({},i.end)};i.end=Object.assign({},c.start),i.start.offset===i.end.offset?Object.assign(i,c):(e.splice(r,0,["enter",c,n],["exit",c,n]),r+=2)}r++}return e}function vl(e,n,r){let i=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1});const s={},o=[];let l=[],a=[];const u={consume:w,enter:S,exit:D,attempt:M(O),check:M(b),interrupt:M(b,{interrupt:!0})},c={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:d,sliceSerialize:m,now:j,defineSkip:E,write:p};let x=n.tokenize.call(c,u);return n.resolveAll&&o.push(n),c;function p(I){return l=de(l,I),k(),l[l.length-1]!==null?[]:(T(n,0),c.events=en(o,c.events,c),c.events)}function m(I,v){return Il(d(I),v)}function d(I){return Nl(l,I)}function j(){const{line:I,column:v,offset:U,_index:$,_bufferIndex:P}=i;return{line:I,column:v,offset:U,_index:$,_bufferIndex:P}}function E(I){s[I.line]=I.column,H()}function k(){let I;for(;i._index<l.length;){const v=l[i._index];if(typeof v=="string")for(I=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===I&&i._bufferIndex<v.length;)y(v.charCodeAt(i._bufferIndex));else y(v)}}function y(I){x=x(I)}function w(I){F(I)?(i.line++,i.column=1,i.offset+=I===-3?2:1,H()):I!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===l[i._index].length&&(i._bufferIndex=-1,i._index++)),c.previous=I}function S(I,v){const U=v||{};return U.type=I,U.start=j(),c.events.push(["enter",U,c]),a.push(U),U}function D(I){const v=a.pop();return v.end=j(),c.events.push(["exit",v,c]),v}function O(I,v){T(I,v.from)}function b(I,v){v.restore()}function M(I,v){return U;function U($,P,q){let Q,re,N,h;return Array.isArray($)?te($):"tokenize"in $?te([$]):J($);function J(X){return ke;function ke(ne){const he=ne!==null&&X[ne],xe=ne!==null&&X.null,Le=[...Array.isArray(he)?he:he?[he]:[],...Array.isArray(xe)?xe:xe?[xe]:[]];return te(Le)(ne)}}function te(X){return Q=X,re=0,X.length===0?q:f(X[re])}function f(X){return ke;function ke(ne){return h=z(),N=X,X.partial||(c.currentConstruct=X),X.name&&c.parser.constructs.disable.null.includes(X.name)?ge():X.tokenize.call(v?Object.assign(Object.create(c),v):c,u,ae,ge)(ne)}}function ae(X){return I(N,h),P}function ge(X){return h.restore(),++re<Q.length?f(Q[re]):q}}}function T(I,v){I.resolveAll&&!o.includes(I)&&o.push(I),I.resolve&&be(c.events,v,c.events.length-v,I.resolve(c.events.slice(v),c)),I.resolveTo&&(c.events=I.resolveTo(c.events,c))}function z(){const I=j(),v=c.previous,U=c.currentConstruct,$=c.events.length,P=Array.from(a);return{restore:q,from:$};function q(){i=I,c.previous=v,c.currentConstruct=U,c.events.length=$,a=P,H()}}function H(){i.line in s&&i.column<2&&(i.column=s[i.line],i.offset+=s[i.line]-1)}}function Nl(e,n){const r=n.start._index,i=n.start._bufferIndex,s=n.end._index,o=n.end._bufferIndex;let l;if(r===s)l=[e[r].slice(i,o)];else{if(l=e.slice(r,s),i>-1){const a=l[0];typeof a=="string"?l[0]=a.slice(i):l.shift()}o>0&&l.push(e[s].slice(0,o))}return l}function Il(e,n){let r=-1;const i=[];let s;for(;++r<e.length;){const o=e[r];let l;if(typeof o=="string")l=o;else switch(o){case-5:{l="\r";break}case-4:{l=`
|
|
163
163
|
`;break}case-3:{l=`\r
|
|
164
|
-
`;break}case-2:{l=n?" ":" ";break}case-1:{if(!n&&s)continue;l=" ";break}default:l=String.fromCharCode(o)}s=o===-2,i.push(l)}return i.join("")}const Al={42:oe,43:oe,45:oe,48:oe,49:oe,50:oe,51:oe,52:oe,53:oe,54:oe,55:oe,56:oe,57:oe,62:Ir},Tl={91:zo},zl={[-2]:St,[-1]:St,32:St},Ll={35:Po,42:it,45:[An,it],60:Ho,61:An,95:it,96:Nn,126:Nn},Ol={38:Tr,92:Ar},Dl={[-5]:Rt,[-4]:Rt,[-3]:Rt,33:ol,38:Tr,42:_t,60:[ao,Qo],91:al,92:[Fo,Ar],93:tn,95:_t,96:ko},Fl={null:[_t,Sl]},Ml={null:[42,95]},Pl={null:[]},Bl=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ml,contentInitial:Tl,disable:Pl,document:Al,flow:Ll,flowInitial:zl,insideSpan:Fl,string:Ol,text:Dl},Symbol.toStringTag,{value:"Module"}));function _l(e){const r=Ws([Bl,...(e||{}).extensions||[]]),i={defined:[],lazy:{},constructs:r,content:s(to),document:s(ro),flow:s(bl),string:s(Rl),text:s(Cl)};return i;function s(o){return l;function l(a){return vl(i,o,a)}}}function Vl(e){for(;!zr(e););return e}const Tn=/[\0\t\n\r]/g;function Hl(){let e=1,n="",r=!0,i;return s;function s(o,l,a){const u=[];let c,x,p,m,d;for(o=n+(typeof o=="string"?o.toString():new TextDecoder(l||void 0).decode(o)),p=0,n="",r&&(o.charCodeAt(0)===65279&&p++,r=void 0);p<o.length;){if(Tn.lastIndex=p,c=Tn.exec(o),m=c&&c.index!==void 0?c.index:o.length,d=o.charCodeAt(m),!c){n=o.slice(p);break}if(d===10&&p===m&&i)u.push(-3),i=void 0;else switch(i&&(u.push(-5),i=void 0),p<m&&(u.push(o.slice(p,m)),e+=m-p),d){case 0:{u.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,u.push(-2);e++<x;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:i=!0,e=1}p=m+1}return a&&(i&&u.push(-5),n&&u.push(n),u.push(null)),u}}const ql=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ul(e){return e.replace(ql,$l)}function $l(e,n,r){if(n)return n;if(r.charCodeAt(0)===35){const s=r.charCodeAt(1),o=s===120||s===88;return vr(r.slice(o?2:1),o?16:10)}return Zt(r)||e}const Pr={}.hasOwnProperty;function Kl(e,n,r){return typeof n!="string"&&(r=n,n=void 0),Wl(r)(Vl(_l(r).document().write(Hl()(e,n,!0))))}function Wl(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ye),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(mt),blockQuote:o(he),characterEscape:z,characterReference:z,codeFenced:o(xe),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:o(xe,l),codeText:o(Le,l),codeTextData:z,data:z,codeFlowValue:z,definition:o(Oe),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:o(He),hardBreakEscape:o(Ie),hardBreakTrailing:o(Ie),htmlFlow:o(Je,l),htmlFlowData:z,htmlText:o(Je,l),htmlTextData:z,image:o(Xe),label:l,link:o(Ye),listItem:o(ht),listItemValue:m,listOrdered:o(Ze,p),listUnordered:o(Ze),paragraph:o(ft),reference:f,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:o(mt),strong:o(et),thematicBreak:o(jt)},exit:{atxHeading:u(),atxHeadingSequence:D,autolink:u(),autolinkEmail:ne,autolinkProtocol:ke,blockQuote:u(),characterEscapeValue:H,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:X,codeFenced:u(k),codeFencedFence:E,codeFencedFenceInfo:d,codeFencedFenceMeta:j,codeFlowValue:H,codeIndented:u(y),codeText:u(V),codeTextData:H,data:H,definition:u(),definitionDestinationString:O,definitionLabelString:w,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(v),hardBreakTrailing:u(v),htmlFlow:u(q),htmlFlowData:H,htmlText:u($),htmlTextData:H,image:u(Q),label:N,labelText:re,lineEnding:I,link:u(G),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ae,resourceDestinationString:h,resourceTitleString:J,resource:te,setextHeading:u(T),setextHeadingLineSequence:M,setextHeadingText:b,strong:u(),thematicBreak:u()}};Br(n,(e||{}).mdastExtensions||[]);const r={};return i;function i(g){let C={type:"root",children:[]};const L={stack:[C],tokenStack:[],config:n,enter:a,exit:c,buffer:l,resume:x,data:r},P=[];let B=-1;for(;++B<g.length;)if(g[B][1].type==="listOrdered"||g[B][1].type==="listUnordered")if(g[B][0]==="enter")P.push(B);else{const ue=P.pop();B=s(g,ue,B)}for(B=-1;++B<g.length;){const ue=n[g[B][0]];Pr.call(ue,g[B][1].type)&&ue[g[B][1].type].call(Object.assign({sliceSerialize:g[B][2].sliceSerialize},L),g[B][1])}if(L.tokenStack.length>0){const ue=L.tokenStack[L.tokenStack.length-1];(ue[1]||zn).call(L,void 0,ue[0])}for(C.position={start:ve(g.length>0?g[0][1].start:{line:1,column:1,offset:0}),end:ve(g.length>0?g[g.length-2][1].end:{line:1,column:1,offset:0})},B=-1;++B<n.transforms.length;)C=n.transforms[B](C)||C;return C}function s(g,C,L){let P=C-1,B=-1,ue=!1,Se,fe,we,se;for(;++P<=L;){const Y=g[P];switch(Y[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Y[0]==="enter"?B++:B--,se=void 0;break}case"lineEndingBlank":{Y[0]==="enter"&&(Se&&!se&&!B&&!we&&(we=P),se=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:se=void 0}if(!B&&Y[0]==="enter"&&Y[1].type==="listItemPrefix"||B===-1&&Y[0]==="exit"&&(Y[1].type==="listUnordered"||Y[1].type==="listOrdered")){if(Se){let je=P;for(fe=void 0;je--;){const ee=g[je];if(ee[1].type==="lineEnding"||ee[1].type==="lineEndingBlank"){if(ee[0]==="exit")continue;fe&&(g[fe][1].type="lineEndingBlank",ue=!0),ee[1].type="lineEnding",fe=je}else if(!(ee[1].type==="linePrefix"||ee[1].type==="blockQuotePrefix"||ee[1].type==="blockQuotePrefixWhitespace"||ee[1].type==="blockQuoteMarker"||ee[1].type==="listItemIndent"))break}we&&(!fe||we<fe)&&(Se._spread=!0),Se.end=Object.assign({},fe?g[fe][1].start:Y[1].end),g.splice(fe||P,0,["exit",Se,Y[2]]),P++,L++}if(Y[1].type==="listItemPrefix"){const je={type:"listItem",_spread:!1,start:Object.assign({},Y[1].start),end:void 0};Se=je,g.splice(P,0,["enter",je,Y[2]]),P++,L++,we=void 0,se=!0}}}return g[C][1]._spread=ue,L}function o(g,C){return L;function L(P){a.call(this,g(P),P),C&&C.call(this,P)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(g,C,L){this.stack[this.stack.length-1].children.push(g),this.stack.push(g),this.tokenStack.push([C,L]),g.position={start:ve(C.start),end:void 0}}function u(g){return C;function C(L){g&&g.call(this,L),c.call(this,L)}}function c(g,C){const L=this.stack.pop(),P=this.tokenStack.pop();if(P)P[0].type!==g.type&&(C?C.call(this,g,P[0]):(P[1]||zn).call(this,g,P[0]));else throw new Error("Cannot close `"+g.type+"` ("+$e({start:g.start,end:g.end})+"): it’s not open");L.position.end=ve(g.end)}function x(){return $s(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(g){if(this.data.expectingFirstListItemValue){const C=this.stack[this.stack.length-2];C.start=Number.parseInt(this.sliceSerialize(g),10),this.data.expectingFirstListItemValue=void 0}}function d(){const g=this.resume(),C=this.stack[this.stack.length-1];C.lang=g}function j(){const g=this.resume(),C=this.stack[this.stack.length-1];C.meta=g}function E(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g.replace(/(\r?\n|\r)$/g,"")}function w(g){const C=this.resume(),L=this.stack[this.stack.length-1];L.label=C,L.identifier=Pe(this.sliceSerialize(g)).toLowerCase()}function R(){const g=this.resume(),C=this.stack[this.stack.length-1];C.title=g}function O(){const g=this.resume(),C=this.stack[this.stack.length-1];C.url=g}function D(g){const C=this.stack[this.stack.length-1];if(!C.depth){const L=this.sliceSerialize(g).length;C.depth=L}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function M(g){const C=this.stack[this.stack.length-1];C.depth=this.sliceSerialize(g).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(g){const L=this.stack[this.stack.length-1].children;let P=L[L.length-1];(!P||P.type!=="text")&&(P=gt(),P.position={start:ve(g.start),end:void 0},L.push(P)),this.stack.push(P)}function H(g){const C=this.stack.pop();C.value+=this.sliceSerialize(g),C.position.end=ve(g.end)}function I(g){const C=this.stack[this.stack.length-1];if(this.data.atHardBreak){const L=C.children[C.children.length-1];L.position.end=ve(g.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(C.type)&&(z.call(this,g),H.call(this,g))}function v(){this.data.atHardBreak=!0}function q(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g}function $(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g}function V(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g}function G(){const g=this.stack[this.stack.length-1];if(this.data.inReference){const C=this.data.referenceType||"shortcut";g.type+="Reference",g.referenceType=C,delete g.url,delete g.title}else delete g.identifier,delete g.label;this.data.referenceType=void 0}function Q(){const g=this.stack[this.stack.length-1];if(this.data.inReference){const C=this.data.referenceType||"shortcut";g.type+="Reference",g.referenceType=C,delete g.url,delete g.title}else delete g.identifier,delete g.label;this.data.referenceType=void 0}function re(g){const C=this.sliceSerialize(g),L=this.stack[this.stack.length-2];L.label=Ul(C),L.identifier=Pe(C).toLowerCase()}function N(){const g=this.stack[this.stack.length-1],C=this.resume(),L=this.stack[this.stack.length-1];if(this.data.inReference=!0,L.type==="link"){const P=g.children;L.children=P}else L.alt=C}function h(){const g=this.resume(),C=this.stack[this.stack.length-1];C.url=g}function J(){const g=this.resume(),C=this.stack[this.stack.length-1];C.title=g}function te(){this.data.inReference=void 0}function f(){this.data.referenceType="collapsed"}function ae(g){const C=this.resume(),L=this.stack[this.stack.length-1];L.label=C,L.identifier=Pe(this.sliceSerialize(g)).toLowerCase(),this.data.referenceType="full"}function ge(g){this.data.characterReferenceType=g.type}function X(g){const C=this.sliceSerialize(g),L=this.data.characterReferenceType;let P;L?(P=vr(C,L==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):P=Zt(C);const B=this.stack.pop();B.value+=P,B.position.end=ve(g.end)}function ke(g){H.call(this,g);const C=this.stack[this.stack.length-1];C.url=this.sliceSerialize(g)}function ne(g){H.call(this,g);const C=this.stack[this.stack.length-1];C.url="mailto:"+this.sliceSerialize(g)}function he(){return{type:"blockquote",children:[]}}function xe(){return{type:"code",lang:null,meta:null,value:""}}function Le(){return{type:"inlineCode",value:""}}function Oe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function He(){return{type:"emphasis",children:[]}}function mt(){return{type:"heading",depth:0,children:[]}}function Ie(){return{type:"break"}}function Je(){return{type:"html",value:""}}function Xe(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function Ze(g){return{type:"list",ordered:g.type==="listOrdered",start:null,spread:g._spread,children:[]}}function ht(g){return{type:"listItem",spread:g._spread,checked:null,children:[]}}function ft(){return{type:"paragraph",children:[]}}function et(){return{type:"strong",children:[]}}function gt(){return{type:"text",value:""}}function jt(){return{type:"thematicBreak"}}}function ve(e){return{line:e.line,column:e.column,offset:e.offset}}function Br(e,n){let r=-1;for(;++r<n.length;){const i=n[r];Array.isArray(i)?Br(e,i):Gl(e,i)}}function Gl(e,n){let r;for(r in n)if(Pr.call(n,r))switch(r){case"canContainEols":{const i=n[r];i&&e[r].push(...i);break}case"transforms":{const i=n[r];i&&e[r].push(...i);break}case"enter":case"exit":{const i=n[r];i&&Object.assign(e[r],i);break}}}function zn(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+$e({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+$e({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+$e({start:n.start,end:n.end})+") is still open")}function Ql(e){const n=this;n.parser=r;function r(i){return Kl(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function Jl(e,n){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,r),e.applyData(n,r)}function Xl(e,n){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,r),[e.applyData(n,r),{type:"text",value:`
|
|
164
|
+
`;break}case-2:{l=n?" ":" ";break}case-1:{if(!n&&s)continue;l=" ";break}default:l=String.fromCharCode(o)}s=o===-2,i.push(l)}return i.join("")}const Al={42:oe,43:oe,45:oe,48:oe,49:oe,50:oe,51:oe,52:oe,53:oe,54:oe,55:oe,56:oe,57:oe,62:Ir},Tl={91:zo},zl={[-2]:St,[-1]:St,32:St},Ll={35:Po,42:it,45:[An,it],60:Ho,61:An,95:it,96:Nn,126:Nn},Ol={38:Tr,92:Ar},Dl={[-5]:Rt,[-4]:Rt,[-3]:Rt,33:ol,38:Tr,42:_t,60:[ao,Qo],91:al,92:[Fo,Ar],93:tn,95:_t,96:ko},Fl={null:[_t,Sl]},Ml={null:[42,95]},Pl={null:[]},Bl=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ml,contentInitial:Tl,disable:Pl,document:Al,flow:Ll,flowInitial:zl,insideSpan:Fl,string:Ol,text:Dl},Symbol.toStringTag,{value:"Module"}));function _l(e){const r=Ws([Bl,...(e||{}).extensions||[]]),i={defined:[],lazy:{},constructs:r,content:s(to),document:s(ro),flow:s(bl),string:s(Rl),text:s(Cl)};return i;function s(o){return l;function l(a){return vl(i,o,a)}}}function Vl(e){for(;!zr(e););return e}const Tn=/[\0\t\n\r]/g;function Hl(){let e=1,n="",r=!0,i;return s;function s(o,l,a){const u=[];let c,x,p,m,d;for(o=n+(typeof o=="string"?o.toString():new TextDecoder(l||void 0).decode(o)),p=0,n="",r&&(o.charCodeAt(0)===65279&&p++,r=void 0);p<o.length;){if(Tn.lastIndex=p,c=Tn.exec(o),m=c&&c.index!==void 0?c.index:o.length,d=o.charCodeAt(m),!c){n=o.slice(p);break}if(d===10&&p===m&&i)u.push(-3),i=void 0;else switch(i&&(u.push(-5),i=void 0),p<m&&(u.push(o.slice(p,m)),e+=m-p),d){case 0:{u.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,u.push(-2);e++<x;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:i=!0,e=1}p=m+1}return a&&(i&&u.push(-5),n&&u.push(n),u.push(null)),u}}const ql=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ul(e){return e.replace(ql,$l)}function $l(e,n,r){if(n)return n;if(r.charCodeAt(0)===35){const s=r.charCodeAt(1),o=s===120||s===88;return vr(r.slice(o?2:1),o?16:10)}return Zt(r)||e}const Pr={}.hasOwnProperty;function Kl(e,n,r){return typeof n!="string"&&(r=n,n=void 0),Wl(r)(Vl(_l(r).document().write(Hl()(e,n,!0))))}function Wl(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ye),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(mt),blockQuote:o(he),characterEscape:z,characterReference:z,codeFenced:o(xe),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:o(xe,l),codeText:o(Le,l),codeTextData:z,data:z,codeFlowValue:z,definition:o(Oe),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:o(He),hardBreakEscape:o(Ie),hardBreakTrailing:o(Ie),htmlFlow:o(Je,l),htmlFlowData:z,htmlText:o(Je,l),htmlTextData:z,image:o(Xe),label:l,link:o(Ye),listItem:o(ht),listItemValue:m,listOrdered:o(Ze,p),listUnordered:o(Ze),paragraph:o(ft),reference:f,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:o(mt),strong:o(et),thematicBreak:o(jt)},exit:{atxHeading:u(),atxHeadingSequence:O,autolink:u(),autolinkEmail:ne,autolinkProtocol:ke,blockQuote:u(),characterEscapeValue:H,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:X,codeFenced:u(k),codeFencedFence:E,codeFencedFenceInfo:d,codeFencedFenceMeta:j,codeFlowValue:H,codeIndented:u(y),codeText:u(P),codeTextData:H,data:H,definition:u(),definitionDestinationString:D,definitionLabelString:w,definitionTitleString:S,emphasis:u(),hardBreakEscape:u(v),hardBreakTrailing:u(v),htmlFlow:u(U),htmlFlowData:H,htmlText:u($),htmlTextData:H,image:u(Q),label:N,labelText:re,lineEnding:I,link:u(q),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ae,resourceDestinationString:h,resourceTitleString:J,resource:te,setextHeading:u(T),setextHeadingLineSequence:M,setextHeadingText:b,strong:u(),thematicBreak:u()}};Br(n,(e||{}).mdastExtensions||[]);const r={};return i;function i(g){let C={type:"root",children:[]};const L={stack:[C],tokenStack:[],config:n,enter:a,exit:c,buffer:l,resume:x,data:r},B=[];let _=-1;for(;++_<g.length;)if(g[_][1].type==="listOrdered"||g[_][1].type==="listUnordered")if(g[_][0]==="enter")B.push(_);else{const ue=B.pop();_=s(g,ue,_)}for(_=-1;++_<g.length;){const ue=n[g[_][0]];Pr.call(ue,g[_][1].type)&&ue[g[_][1].type].call(Object.assign({sliceSerialize:g[_][2].sliceSerialize},L),g[_][1])}if(L.tokenStack.length>0){const ue=L.tokenStack[L.tokenStack.length-1];(ue[1]||zn).call(L,void 0,ue[0])}for(C.position={start:ve(g.length>0?g[0][1].start:{line:1,column:1,offset:0}),end:ve(g.length>0?g[g.length-2][1].end:{line:1,column:1,offset:0})},_=-1;++_<n.transforms.length;)C=n.transforms[_](C)||C;return C}function s(g,C,L){let B=C-1,_=-1,ue=!1,Se,fe,we,se;for(;++B<=L;){const Y=g[B];switch(Y[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Y[0]==="enter"?_++:_--,se=void 0;break}case"lineEndingBlank":{Y[0]==="enter"&&(Se&&!se&&!_&&!we&&(we=B),se=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:se=void 0}if(!_&&Y[0]==="enter"&&Y[1].type==="listItemPrefix"||_===-1&&Y[0]==="exit"&&(Y[1].type==="listUnordered"||Y[1].type==="listOrdered")){if(Se){let je=B;for(fe=void 0;je--;){const ee=g[je];if(ee[1].type==="lineEnding"||ee[1].type==="lineEndingBlank"){if(ee[0]==="exit")continue;fe&&(g[fe][1].type="lineEndingBlank",ue=!0),ee[1].type="lineEnding",fe=je}else if(!(ee[1].type==="linePrefix"||ee[1].type==="blockQuotePrefix"||ee[1].type==="blockQuotePrefixWhitespace"||ee[1].type==="blockQuoteMarker"||ee[1].type==="listItemIndent"))break}we&&(!fe||we<fe)&&(Se._spread=!0),Se.end=Object.assign({},fe?g[fe][1].start:Y[1].end),g.splice(fe||B,0,["exit",Se,Y[2]]),B++,L++}if(Y[1].type==="listItemPrefix"){const je={type:"listItem",_spread:!1,start:Object.assign({},Y[1].start),end:void 0};Se=je,g.splice(B,0,["enter",je,Y[2]]),B++,L++,we=void 0,se=!0}}}return g[C][1]._spread=ue,L}function o(g,C){return L;function L(B){a.call(this,g(B),B),C&&C.call(this,B)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(g,C,L){this.stack[this.stack.length-1].children.push(g),this.stack.push(g),this.tokenStack.push([C,L]),g.position={start:ve(C.start),end:void 0}}function u(g){return C;function C(L){g&&g.call(this,L),c.call(this,L)}}function c(g,C){const L=this.stack.pop(),B=this.tokenStack.pop();if(B)B[0].type!==g.type&&(C?C.call(this,g,B[0]):(B[1]||zn).call(this,g,B[0]));else throw new Error("Cannot close `"+g.type+"` ("+$e({start:g.start,end:g.end})+"): it’s not open");L.position.end=ve(g.end)}function x(){return $s(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(g){if(this.data.expectingFirstListItemValue){const C=this.stack[this.stack.length-2];C.start=Number.parseInt(this.sliceSerialize(g),10),this.data.expectingFirstListItemValue=void 0}}function d(){const g=this.resume(),C=this.stack[this.stack.length-1];C.lang=g}function j(){const g=this.resume(),C=this.stack[this.stack.length-1];C.meta=g}function E(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g.replace(/(\r?\n|\r)$/g,"")}function w(g){const C=this.resume(),L=this.stack[this.stack.length-1];L.label=C,L.identifier=Pe(this.sliceSerialize(g)).toLowerCase()}function S(){const g=this.resume(),C=this.stack[this.stack.length-1];C.title=g}function D(){const g=this.resume(),C=this.stack[this.stack.length-1];C.url=g}function O(g){const C=this.stack[this.stack.length-1];if(!C.depth){const L=this.sliceSerialize(g).length;C.depth=L}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function M(g){const C=this.stack[this.stack.length-1];C.depth=this.sliceSerialize(g).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(g){const L=this.stack[this.stack.length-1].children;let B=L[L.length-1];(!B||B.type!=="text")&&(B=gt(),B.position={start:ve(g.start),end:void 0},L.push(B)),this.stack.push(B)}function H(g){const C=this.stack.pop();C.value+=this.sliceSerialize(g),C.position.end=ve(g.end)}function I(g){const C=this.stack[this.stack.length-1];if(this.data.atHardBreak){const L=C.children[C.children.length-1];L.position.end=ve(g.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(C.type)&&(z.call(this,g),H.call(this,g))}function v(){this.data.atHardBreak=!0}function U(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g}function $(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g}function P(){const g=this.resume(),C=this.stack[this.stack.length-1];C.value=g}function q(){const g=this.stack[this.stack.length-1];if(this.data.inReference){const C=this.data.referenceType||"shortcut";g.type+="Reference",g.referenceType=C,delete g.url,delete g.title}else delete g.identifier,delete g.label;this.data.referenceType=void 0}function Q(){const g=this.stack[this.stack.length-1];if(this.data.inReference){const C=this.data.referenceType||"shortcut";g.type+="Reference",g.referenceType=C,delete g.url,delete g.title}else delete g.identifier,delete g.label;this.data.referenceType=void 0}function re(g){const C=this.sliceSerialize(g),L=this.stack[this.stack.length-2];L.label=Ul(C),L.identifier=Pe(C).toLowerCase()}function N(){const g=this.stack[this.stack.length-1],C=this.resume(),L=this.stack[this.stack.length-1];if(this.data.inReference=!0,L.type==="link"){const B=g.children;L.children=B}else L.alt=C}function h(){const g=this.resume(),C=this.stack[this.stack.length-1];C.url=g}function J(){const g=this.resume(),C=this.stack[this.stack.length-1];C.title=g}function te(){this.data.inReference=void 0}function f(){this.data.referenceType="collapsed"}function ae(g){const C=this.resume(),L=this.stack[this.stack.length-1];L.label=C,L.identifier=Pe(this.sliceSerialize(g)).toLowerCase(),this.data.referenceType="full"}function ge(g){this.data.characterReferenceType=g.type}function X(g){const C=this.sliceSerialize(g),L=this.data.characterReferenceType;let B;L?(B=vr(C,L==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):B=Zt(C);const _=this.stack.pop();_.value+=B,_.position.end=ve(g.end)}function ke(g){H.call(this,g);const C=this.stack[this.stack.length-1];C.url=this.sliceSerialize(g)}function ne(g){H.call(this,g);const C=this.stack[this.stack.length-1];C.url="mailto:"+this.sliceSerialize(g)}function he(){return{type:"blockquote",children:[]}}function xe(){return{type:"code",lang:null,meta:null,value:""}}function Le(){return{type:"inlineCode",value:""}}function Oe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function He(){return{type:"emphasis",children:[]}}function mt(){return{type:"heading",depth:0,children:[]}}function Ie(){return{type:"break"}}function Je(){return{type:"html",value:""}}function Xe(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function Ze(g){return{type:"list",ordered:g.type==="listOrdered",start:null,spread:g._spread,children:[]}}function ht(g){return{type:"listItem",spread:g._spread,checked:null,children:[]}}function ft(){return{type:"paragraph",children:[]}}function et(){return{type:"strong",children:[]}}function gt(){return{type:"text",value:""}}function jt(){return{type:"thematicBreak"}}}function ve(e){return{line:e.line,column:e.column,offset:e.offset}}function Br(e,n){let r=-1;for(;++r<n.length;){const i=n[r];Array.isArray(i)?Br(e,i):Gl(e,i)}}function Gl(e,n){let r;for(r in n)if(Pr.call(n,r))switch(r){case"canContainEols":{const i=n[r];i&&e[r].push(...i);break}case"transforms":{const i=n[r];i&&e[r].push(...i);break}case"enter":case"exit":{const i=n[r];i&&Object.assign(e[r],i);break}}}function zn(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+$e({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+$e({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+$e({start:n.start,end:n.end})+") is still open")}function Ql(e){const n=this;n.parser=r;function r(i){return Kl(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function Jl(e,n){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,r),e.applyData(n,r)}function Xl(e,n){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,r),[e.applyData(n,r),{type:"text",value:`
|
|
165
165
|
`}]}function Yl(e,n){const r=n.value?n.value+`
|
|
166
166
|
`:"",i={};n.lang&&(i.className=["language-"+n.lang]);let s={type:"element",tagName:"code",properties:i,children:[{type:"text",value:r}]};return n.meta&&(s.data={meta:n.meta}),e.patch(n,s),s=e.applyData(n,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(n,s),s}function Zl(e,n){const r={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,r),e.applyData(n,r)}function ea(e,n){const r={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,r),e.applyData(n,r)}function ta(e,n){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),s=_e(i.toLowerCase()),o=e.footnoteOrder.indexOf(i);let l,a=e.footnoteCounts.get(i);a===void 0?(a=0,e.footnoteOrder.push(i),l=e.footnoteOrder.length):l=o+1,a+=1,e.footnoteCounts.set(i,a);const u={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+s,id:r+"fnref-"+s+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(l)}]};e.patch(n,u);const c={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(n,c),e.applyData(n,c)}function na(e,n){const r={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,r),e.applyData(n,r)}function ra(e,n){if(e.options.allowDangerousHtml){const r={type:"raw",value:n.value};return e.patch(n,r),e.applyData(n,r)}}function _r(e,n){const r=n.referenceType;let i="]";if(r==="collapsed"?i+="[]":r==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const s=e.all(n),o=s[0];o&&o.type==="text"?o.value="["+o.value:s.unshift({type:"text",value:"["});const l=s[s.length-1];return l&&l.type==="text"?l.value+=i:s.push({type:"text",value:i}),s}function ia(e,n){const r=String(n.identifier).toUpperCase(),i=e.definitionById.get(r);if(!i)return _r(e,n);const s={src:_e(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(s.title=i.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(n,o),e.applyData(n,o)}function sa(e,n){const r={src:_e(n.url)};n.alt!==null&&n.alt!==void 0&&(r.alt=n.alt),n.title!==null&&n.title!==void 0&&(r.title=n.title);const i={type:"element",tagName:"img",properties:r,children:[]};return e.patch(n,i),e.applyData(n,i)}function oa(e,n){const r={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,r);const i={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(n,i),e.applyData(n,i)}function la(e,n){const r=String(n.identifier).toUpperCase(),i=e.definitionById.get(r);if(!i)return _r(e,n);const s={href:_e(i.url||"")};i.title!==null&&i.title!==void 0&&(s.title=i.title);const o={type:"element",tagName:"a",properties:s,children:e.all(n)};return e.patch(n,o),e.applyData(n,o)}function aa(e,n){const r={href:_e(n.url)};n.title!==null&&n.title!==void 0&&(r.title=n.title);const i={type:"element",tagName:"a",properties:r,children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function ua(e,n,r){const i=e.all(n),s=r?ca(r):Vr(n),o={},l=[];if(typeof n.checked=="boolean"){const x=i[0];let p;x&&x.type==="element"&&x.tagName==="p"?p=x:(p={type:"element",tagName:"p",properties:{},children:[]},i.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<i.length;){const x=i[a];(s||a!==0||x.type!=="element"||x.tagName!=="p")&&l.push({type:"text",value:`
|
|
167
167
|
`}),x.type==="element"&&x.tagName==="p"&&!s?l.push(...x.children):l.push(x)}const u=i[i.length-1];u&&(s||u.type!=="element"||u.tagName!=="p")&&l.push({type:"text",value:`
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
`});++i<e.length;)i&&r.push({type:"text",value:`
|
|
172
172
|
`}),r.push(e[i]);return n&&e.length>0&&r.push({type:"text",value:`
|
|
173
173
|
`}),r}function _n(e){let n=0,r=e.charCodeAt(n);for(;r===9||r===32;)n++,r=e.charCodeAt(n);return e.slice(n)}function Vn(e,n){const r=Ba(e,n),i=r.one(e,void 0),s=Na(r),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
|
|
174
|
-
`},s),o}function Ua(e,n){return e&&"run"in e?async function(r,i){const s=Vn(r,{file:i,...n});await e.run(s,i)}:function(r,i){return Vn(r,{file:i,...n||e})}}function Hn(e){if(e)throw e}var st=Object.prototype.hasOwnProperty,Gr=Object.prototype.toString,qn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,$n=function(n){return typeof Array.isArray=="function"?Array.isArray(n):Gr.call(n)==="[object Array]"},Kn=function(n){if(!n||Gr.call(n)!=="[object Object]")return!1;var r=st.call(n,"constructor"),i=n.constructor&&n.constructor.prototype&&st.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!r&&!i)return!1;var s;for(s in n);return typeof s>"u"||st.call(n,s)},Wn=function(n,r){qn&&r.name==="__proto__"?qn(n,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0}):n[r.name]=r.newValue},Gn=function(n,r){if(r==="__proto__")if(st.call(n,r)){if(Un)return Un(n,r).value}else return;return n[r]},$a=function e(){var n,r,i,s,o,l,a=arguments[0],u=1,c=arguments.length,x=!1;for(typeof a=="boolean"&&(x=a,a=arguments[1]||{},u=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});u<c;++u)if(n=arguments[u],n!=null)for(r in n)i=Gn(a,r),s=Gn(n,r),a!==s&&(x&&s&&(Kn(s)||(o=$n(s)))?(o?(o=!1,l=i&&$n(i)?i:[]):l=i&&Kn(i)?i:{},Wn(a,{name:r,newValue:e(x,l,s)})):typeof s<"u"&&Wn(a,{name:r,newValue:s}));return a};const Ct=t.getDefaultExportFromCjs($a);function Ht(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ka(){const e=[],n={run:r,use:i};return n;function r(...s){let o=-1;const l=s.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);a(null,...s);function a(u,...c){const x=e[++o];let p=-1;if(u){l(u);return}for(;++p<s.length;)(c[p]===null||c[p]===void 0)&&(c[p]=s[p]);s=c,x?Wa(x,a)(...c):l(null,...c)}}function i(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),n}}function Wa(e,n){let r;return i;function i(...l){const a=e.length>l.length;let u;a&&l.push(s);try{u=e.apply(this,l)}catch(c){const x=c;if(a&&r)throw x;return s(x)}a||(u instanceof Promise?u.then(o,s):u instanceof Error?s(u):o(u))}function s(l,...a){r||(r=!0,n(l,...a))}function o(l){s(null,l)}}const ye={basename:Ga,dirname:Qa,extname:Ja,join:Xa,sep:"/"};function Ga(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Qe(e);let r=0,i=-1,s=e.length,o;if(n===void 0||n.length===0||n.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){r=s+1;break}}else i<0&&(o=!0,i=s+1);return i<0?"":e.slice(r,i)}if(n===e)return"";let l=-1,a=n.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){r=s+1;break}}else l<0&&(o=!0,l=s+1),a>-1&&(e.codePointAt(s)===n.codePointAt(a--)?a<0&&(i=s):(a=-1,i=l));return r===i?i=l:i<0&&(i=e.length),e.slice(r,i)}function Qa(e){if(Qe(e),e.length===0)return".";let n=-1,r=e.length,i;for(;--r;)if(e.codePointAt(r)===47){if(i){n=r;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function Ja(e){Qe(e);let n=e.length,r=-1,i=0,s=-1,o=0,l;for(;n--;){const a=e.codePointAt(n);if(a===47){if(l){i=n+1;break}continue}r<0&&(l=!0,r=n+1),a===46?s<0?s=n:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||r<0||o===0||o===1&&s===r-1&&s===i+1?"":e.slice(s,r)}function Xa(...e){let n=-1,r;for(;++n<e.length;)Qe(e[n]),e[n]&&(r=r===void 0?e[n]:r+"/"+e[n]);return r===void 0?".":Ya(r)}function Ya(e){Qe(e);const n=e.codePointAt(0)===47;let r=Za(e,!n);return r.length===0&&!n&&(r="."),r.length>0&&e.codePointAt(e.length-1)===47&&(r+="/"),n?"/"+r:r}function Za(e,n){let r="",i=0,s=-1,o=0,l=-1,a,u;for(;++l<=e.length;){if(l<e.length)a=e.codePointAt(l);else{if(a===47)break;a=47}if(a===47){if(!(s===l-1||o===1))if(s!==l-1&&o===2){if(r.length<2||i!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(u=r.lastIndexOf("/"),u!==r.length-1){u<0?(r="",i=0):(r=r.slice(0,u),i=r.length-1-r.lastIndexOf("/")),s=l,o=0;continue}}else if(r.length>0){r="",i=0,s=l,o=0;continue}}n&&(r=r.length>0?r+"/..":"..",i=2)}else r.length>0?r+="/"+e.slice(s+1,l):r=e.slice(s+1,l),i=l-s-1;s=l,o=0}else a===46&&o>-1?o++:o=-1}return r}function Qe(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const eu={cwd:tu};function tu(){return"/"}function qt(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function nu(e){if(typeof e=="string")e=new URL(e);else if(!qt(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return ru(e)}function ru(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let r=-1;for(;++r<n.length;)if(n.codePointAt(r)===37&&n.codePointAt(r+1)===50){const i=n.codePointAt(r+2);if(i===70||i===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(n)}const wt=["history","path","basename","stem","extname","dirname"];class Qr{constructor(n){let r;n?qt(n)?r={path:n}:typeof n=="string"||iu(n)?r={value:n}:r=n:r={},this.cwd=eu.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<wt.length;){const o=wt[i];o in r&&r[o]!==void 0&&r[o]!==null&&(this[o]=o==="history"?[...r[o]]:r[o])}let s;for(s in r)wt.includes(s)||(this[s]=r[s])}get basename(){return typeof this.path=="string"?ye.basename(this.path):void 0}set basename(n){Nt(n,"basename"),vt(n,"basename"),this.path=ye.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ye.dirname(this.path):void 0}set dirname(n){Qn(this.basename,"dirname"),this.path=ye.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ye.extname(this.path):void 0}set extname(n){if(vt(n,"extname"),Qn(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ye.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){qt(n)&&(n=nu(n)),Nt(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ye.basename(this.path,this.extname):void 0}set stem(n){Nt(n,"stem"),vt(n,"stem"),this.path=ye.join(this.dirname||"",n+(this.extname||""))}fail(n,r,i){const s=this.message(n,r,i);throw s.fatal=!0,s}info(n,r,i){const s=this.message(n,r,i);return s.fatal=void 0,s}message(n,r,i){const s=new ie(n,r,i);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function vt(e,n){if(e&&e.includes(ye.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ye.sep+"`")}function Nt(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function Qn(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function iu(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const su=function(e){const i=this.constructor.prototype,s=i[e],o=function(){return s.apply(o,arguments)};Object.setPrototypeOf(o,i);const l=Object.getOwnPropertyNames(s);for(const a of l){const u=Object.getOwnPropertyDescriptor(s,a);u&&Object.defineProperty(o,a,u)}return o},ou={}.hasOwnProperty;class ln extends su{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ka()}copy(){const n=new ln;let r=-1;for(;++r<this.attachers.length;){const i=this.attachers[r];n.use(...i)}return n.data(Ct(!0,{},this.namespace)),n}data(n,r){return typeof n=="string"?arguments.length===2?(Tt("data",this.frozen),this.namespace[n]=r,this):ou.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Tt("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const s=r.call(n,...i);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const r=rt(n),i=this.parser||this.Parser;return It("parse",i),i(String(r),r)}process(n,r){const i=this;return this.freeze(),It("process",this.parser||this.Parser),At("process",this.compiler||this.Compiler),r?s(void 0,r):new Promise(s);function s(o,l){const a=rt(n),u=i.parse(a);i.run(u,a,function(x,p,m){if(x||!p||!m)return c(x);const d=p,j=i.stringify(d,m);uu(j)?m.value=j:m.result=j,c(x,m)});function c(x,p){x||!p?l(x):o?o(p):r(void 0,p)}}}processSync(n){let r=!1,i;return this.freeze(),It("processSync",this.parser||this.Parser),At("processSync",this.compiler||this.Compiler),this.process(n,s),Xn("processSync","process",r),i;function s(o,l){r=!0,Hn(o),i=l}}run(n,r,i){Jn(n),this.freeze();const s=this.transformers;return!i&&typeof r=="function"&&(i=r,r=void 0),i?o(void 0,i):new Promise(o);function o(l,a){const u=rt(r);s.run(n,u,c);function c(x,p,m){const d=p||n;x?a(x):l?l(d):i(void 0,d,m)}}}runSync(n,r){let i=!1,s;return this.run(n,r,o),Xn("runSync","run",i),s;function o(l,a){Hn(l),s=a,i=!0}}stringify(n,r){this.freeze();const i=rt(r),s=this.compiler||this.Compiler;return At("stringify",s),Jn(n),s(n,i)}use(n,...r){const i=this.attachers,s=this.namespace;if(Tt("use",this.frozen),n!=null)if(typeof n=="function")u(n,r);else if(typeof n=="object")Array.isArray(n)?a(n):l(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function o(c){if(typeof c=="function")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[x,...p]=c;u(x,p)}else l(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function l(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(s.settings=Ct(!0,s.settings,c.settings))}function a(c){let x=-1;if(c!=null)if(Array.isArray(c))for(;++x<c.length;){const p=c[x];o(p)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,x){let p=-1,m=-1;for(;++p<i.length;)if(i[p][0]===c){m=p;break}if(m===-1)i.push([c,...x]);else if(x.length>0){let[d,...j]=x;const E=i[m][1];Ht(E)&&Ht(d)&&(d=Ct(!0,E,d)),i[m]=[c,d,...j]}}}}const lu=new ln().freeze();function It(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function At(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Tt(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Jn(e){if(!Ht(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Xn(e,n,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function rt(e){return au(e)?e:new Qr(e)}function au(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function uu(e){return typeof e=="string"||cu(e)}function cu(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const pu="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Yn=[],Zn={allowDangerousHtml:!0},xu=/^(https?|ircs?|mailto|xmpp)$/i,du=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function mu(e){const n=e.allowedElements,r=e.allowElement,i=e.children||"",s=e.className,o=e.components,l=e.disallowedElements,a=e.rehypePlugins||Yn,u=e.remarkPlugins||Yn,c=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Zn}:Zn,x=e.skipHtml,p=e.unwrapDisallowed,m=e.urlTransform||hu,d=lu().use(Ql).use(u).use(Ua,c).use(a),j=new Qr;typeof i=="string"&&(j.value=i);for(const w of du)Object.hasOwn(e,w.from)&&(""+w.from+(w.to?"use `"+w.to+"` instead":"remove it")+pu+w.id,void 0);const E=d.parse(j);let k=d.runSync(E,j);return s&&(k={type:"element",tagName:"div",properties:{className:s},children:k.type==="root"?k.children:[k]}),Wr(k,y),vs(k,{Fragment:t.jsxRuntimeExports.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsxRuntimeExports.jsx,jsxs:t.jsxRuntimeExports.jsxs,passKeys:!0,passNode:!0});function y(w,R,O){if(w.type==="raw"&&O&&typeof R=="number")return x?O.children.splice(R,1):O.children[R]={type:"text",value:w.value},R;if(w.type==="element"){let D;for(D in kt)if(Object.hasOwn(kt,D)&&Object.hasOwn(w.properties,D)){const b=w.properties[D],M=kt[D];(M===null||M.includes(w.tagName))&&(w.properties[D]=m(String(b||""),D,w))}}if(w.type==="element"){let D=n?!n.includes(w.tagName):l?l.includes(w.tagName):!1;if(!D&&r&&typeof R=="number"&&(D=!r(w,R,O)),D&&O&&typeof R=="number")return p&&w.children?O.children.splice(R,1,...w.children):O.children.splice(R,1),R}}}function hu(e){const n=e.indexOf(":"),r=e.indexOf("?"),i=e.indexOf("#"),s=e.indexOf("/");return n<0||s>-1&&n>s||r>-1&&n>r||i>-1&&n>i||xu.test(e.slice(0,n))?e:""}const fu=`
|
|
174
|
+
`},s),o}function Ua(e,n){return e&&"run"in e?async function(r,i){const s=Vn(r,{file:i,...n});await e.run(s,i)}:function(r,i){return Vn(r,{file:i,...n||e})}}function Hn(e){if(e)throw e}var st=Object.prototype.hasOwnProperty,Gr=Object.prototype.toString,qn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,$n=function(n){return typeof Array.isArray=="function"?Array.isArray(n):Gr.call(n)==="[object Array]"},Kn=function(n){if(!n||Gr.call(n)!=="[object Object]")return!1;var r=st.call(n,"constructor"),i=n.constructor&&n.constructor.prototype&&st.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!r&&!i)return!1;var s;for(s in n);return typeof s>"u"||st.call(n,s)},Wn=function(n,r){qn&&r.name==="__proto__"?qn(n,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0}):n[r.name]=r.newValue},Gn=function(n,r){if(r==="__proto__")if(st.call(n,r)){if(Un)return Un(n,r).value}else return;return n[r]},$a=function e(){var n,r,i,s,o,l,a=arguments[0],u=1,c=arguments.length,x=!1;for(typeof a=="boolean"&&(x=a,a=arguments[1]||{},u=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});u<c;++u)if(n=arguments[u],n!=null)for(r in n)i=Gn(a,r),s=Gn(n,r),a!==s&&(x&&s&&(Kn(s)||(o=$n(s)))?(o?(o=!1,l=i&&$n(i)?i:[]):l=i&&Kn(i)?i:{},Wn(a,{name:r,newValue:e(x,l,s)})):typeof s<"u"&&Wn(a,{name:r,newValue:s}));return a};const Ct=t.getDefaultExportFromCjs($a);function Ht(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ka(){const e=[],n={run:r,use:i};return n;function r(...s){let o=-1;const l=s.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);a(null,...s);function a(u,...c){const x=e[++o];let p=-1;if(u){l(u);return}for(;++p<s.length;)(c[p]===null||c[p]===void 0)&&(c[p]=s[p]);s=c,x?Wa(x,a)(...c):l(null,...c)}}function i(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),n}}function Wa(e,n){let r;return i;function i(...l){const a=e.length>l.length;let u;a&&l.push(s);try{u=e.apply(this,l)}catch(c){const x=c;if(a&&r)throw x;return s(x)}a||(u instanceof Promise?u.then(o,s):u instanceof Error?s(u):o(u))}function s(l,...a){r||(r=!0,n(l,...a))}function o(l){s(null,l)}}const ye={basename:Ga,dirname:Qa,extname:Ja,join:Xa,sep:"/"};function Ga(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Qe(e);let r=0,i=-1,s=e.length,o;if(n===void 0||n.length===0||n.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){r=s+1;break}}else i<0&&(o=!0,i=s+1);return i<0?"":e.slice(r,i)}if(n===e)return"";let l=-1,a=n.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){r=s+1;break}}else l<0&&(o=!0,l=s+1),a>-1&&(e.codePointAt(s)===n.codePointAt(a--)?a<0&&(i=s):(a=-1,i=l));return r===i?i=l:i<0&&(i=e.length),e.slice(r,i)}function Qa(e){if(Qe(e),e.length===0)return".";let n=-1,r=e.length,i;for(;--r;)if(e.codePointAt(r)===47){if(i){n=r;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function Ja(e){Qe(e);let n=e.length,r=-1,i=0,s=-1,o=0,l;for(;n--;){const a=e.codePointAt(n);if(a===47){if(l){i=n+1;break}continue}r<0&&(l=!0,r=n+1),a===46?s<0?s=n:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||r<0||o===0||o===1&&s===r-1&&s===i+1?"":e.slice(s,r)}function Xa(...e){let n=-1,r;for(;++n<e.length;)Qe(e[n]),e[n]&&(r=r===void 0?e[n]:r+"/"+e[n]);return r===void 0?".":Ya(r)}function Ya(e){Qe(e);const n=e.codePointAt(0)===47;let r=Za(e,!n);return r.length===0&&!n&&(r="."),r.length>0&&e.codePointAt(e.length-1)===47&&(r+="/"),n?"/"+r:r}function Za(e,n){let r="",i=0,s=-1,o=0,l=-1,a,u;for(;++l<=e.length;){if(l<e.length)a=e.codePointAt(l);else{if(a===47)break;a=47}if(a===47){if(!(s===l-1||o===1))if(s!==l-1&&o===2){if(r.length<2||i!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(u=r.lastIndexOf("/"),u!==r.length-1){u<0?(r="",i=0):(r=r.slice(0,u),i=r.length-1-r.lastIndexOf("/")),s=l,o=0;continue}}else if(r.length>0){r="",i=0,s=l,o=0;continue}}n&&(r=r.length>0?r+"/..":"..",i=2)}else r.length>0?r+="/"+e.slice(s+1,l):r=e.slice(s+1,l),i=l-s-1;s=l,o=0}else a===46&&o>-1?o++:o=-1}return r}function Qe(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const eu={cwd:tu};function tu(){return"/"}function qt(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function nu(e){if(typeof e=="string")e=new URL(e);else if(!qt(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return ru(e)}function ru(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let r=-1;for(;++r<n.length;)if(n.codePointAt(r)===37&&n.codePointAt(r+1)===50){const i=n.codePointAt(r+2);if(i===70||i===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(n)}const wt=["history","path","basename","stem","extname","dirname"];class Qr{constructor(n){let r;n?qt(n)?r={path:n}:typeof n=="string"||iu(n)?r={value:n}:r=n:r={},this.cwd=eu.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<wt.length;){const o=wt[i];o in r&&r[o]!==void 0&&r[o]!==null&&(this[o]=o==="history"?[...r[o]]:r[o])}let s;for(s in r)wt.includes(s)||(this[s]=r[s])}get basename(){return typeof this.path=="string"?ye.basename(this.path):void 0}set basename(n){Nt(n,"basename"),vt(n,"basename"),this.path=ye.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ye.dirname(this.path):void 0}set dirname(n){Qn(this.basename,"dirname"),this.path=ye.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ye.extname(this.path):void 0}set extname(n){if(vt(n,"extname"),Qn(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ye.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){qt(n)&&(n=nu(n)),Nt(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ye.basename(this.path,this.extname):void 0}set stem(n){Nt(n,"stem"),vt(n,"stem"),this.path=ye.join(this.dirname||"",n+(this.extname||""))}fail(n,r,i){const s=this.message(n,r,i);throw s.fatal=!0,s}info(n,r,i){const s=this.message(n,r,i);return s.fatal=void 0,s}message(n,r,i){const s=new ie(n,r,i);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function vt(e,n){if(e&&e.includes(ye.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ye.sep+"`")}function Nt(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function Qn(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function iu(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const su=function(e){const i=this.constructor.prototype,s=i[e],o=function(){return s.apply(o,arguments)};Object.setPrototypeOf(o,i);const l=Object.getOwnPropertyNames(s);for(const a of l){const u=Object.getOwnPropertyDescriptor(s,a);u&&Object.defineProperty(o,a,u)}return o},ou={}.hasOwnProperty;class ln extends su{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ka()}copy(){const n=new ln;let r=-1;for(;++r<this.attachers.length;){const i=this.attachers[r];n.use(...i)}return n.data(Ct(!0,{},this.namespace)),n}data(n,r){return typeof n=="string"?arguments.length===2?(Tt("data",this.frozen),this.namespace[n]=r,this):ou.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Tt("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const s=r.call(n,...i);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const r=rt(n),i=this.parser||this.Parser;return It("parse",i),i(String(r),r)}process(n,r){const i=this;return this.freeze(),It("process",this.parser||this.Parser),At("process",this.compiler||this.Compiler),r?s(void 0,r):new Promise(s);function s(o,l){const a=rt(n),u=i.parse(a);i.run(u,a,function(x,p,m){if(x||!p||!m)return c(x);const d=p,j=i.stringify(d,m);uu(j)?m.value=j:m.result=j,c(x,m)});function c(x,p){x||!p?l(x):o?o(p):r(void 0,p)}}}processSync(n){let r=!1,i;return this.freeze(),It("processSync",this.parser||this.Parser),At("processSync",this.compiler||this.Compiler),this.process(n,s),Xn("processSync","process",r),i;function s(o,l){r=!0,Hn(o),i=l}}run(n,r,i){Jn(n),this.freeze();const s=this.transformers;return!i&&typeof r=="function"&&(i=r,r=void 0),i?o(void 0,i):new Promise(o);function o(l,a){const u=rt(r);s.run(n,u,c);function c(x,p,m){const d=p||n;x?a(x):l?l(d):i(void 0,d,m)}}}runSync(n,r){let i=!1,s;return this.run(n,r,o),Xn("runSync","run",i),s;function o(l,a){Hn(l),s=a,i=!0}}stringify(n,r){this.freeze();const i=rt(r),s=this.compiler||this.Compiler;return At("stringify",s),Jn(n),s(n,i)}use(n,...r){const i=this.attachers,s=this.namespace;if(Tt("use",this.frozen),n!=null)if(typeof n=="function")u(n,r);else if(typeof n=="object")Array.isArray(n)?a(n):l(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function o(c){if(typeof c=="function")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[x,...p]=c;u(x,p)}else l(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function l(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(s.settings=Ct(!0,s.settings,c.settings))}function a(c){let x=-1;if(c!=null)if(Array.isArray(c))for(;++x<c.length;){const p=c[x];o(p)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,x){let p=-1,m=-1;for(;++p<i.length;)if(i[p][0]===c){m=p;break}if(m===-1)i.push([c,...x]);else if(x.length>0){let[d,...j]=x;const E=i[m][1];Ht(E)&&Ht(d)&&(d=Ct(!0,E,d)),i[m]=[c,d,...j]}}}}const lu=new ln().freeze();function It(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function At(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Tt(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Jn(e){if(!Ht(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Xn(e,n,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function rt(e){return au(e)?e:new Qr(e)}function au(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function uu(e){return typeof e=="string"||cu(e)}function cu(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const pu="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Yn=[],Zn={allowDangerousHtml:!0},xu=/^(https?|ircs?|mailto|xmpp)$/i,du=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function mu(e){const n=e.allowedElements,r=e.allowElement,i=e.children||"",s=e.className,o=e.components,l=e.disallowedElements,a=e.rehypePlugins||Yn,u=e.remarkPlugins||Yn,c=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Zn}:Zn,x=e.skipHtml,p=e.unwrapDisallowed,m=e.urlTransform||hu,d=lu().use(Ql).use(u).use(Ua,c).use(a),j=new Qr;typeof i=="string"&&(j.value=i);for(const w of du)Object.hasOwn(e,w.from)&&(""+w.from+(w.to?"use `"+w.to+"` instead":"remove it")+pu+w.id,void 0);const E=d.parse(j);let k=d.runSync(E,j);return s&&(k={type:"element",tagName:"div",properties:{className:s},children:k.type==="root"?k.children:[k]}),Wr(k,y),vs(k,{Fragment:t.jsxRuntimeExports.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsxRuntimeExports.jsx,jsxs:t.jsxRuntimeExports.jsxs,passKeys:!0,passNode:!0});function y(w,S,D){if(w.type==="raw"&&D&&typeof S=="number")return x?D.children.splice(S,1):D.children[S]={type:"text",value:w.value},S;if(w.type==="element"){let O;for(O in kt)if(Object.hasOwn(kt,O)&&Object.hasOwn(w.properties,O)){const b=w.properties[O],M=kt[O];(M===null||M.includes(w.tagName))&&(w.properties[O]=m(String(b||""),O,w))}}if(w.type==="element"){let O=n?!n.includes(w.tagName):l?l.includes(w.tagName):!1;if(!O&&r&&typeof S=="number"&&(O=!r(w,S,D)),O&&D&&typeof S=="number")return p&&w.children?D.children.splice(S,1,...w.children):D.children.splice(S,1),S}}}function hu(e){const n=e.indexOf(":"),r=e.indexOf("?"),i=e.indexOf("#"),s=e.indexOf("/");return n<0||s>-1&&n>s||r>-1&&n>r||i>-1&&n>i||xu.test(e.slice(0,n))?e:""}const fu=`
|
|
175
175
|
|
|
176
176
|
Use the following syntax to create a chart query. Please replace the x-axis, y-axis, stack-by, label, and measure with the actual column names of the table.
|
|
177
177
|
|
|
@@ -217,12 +217,12 @@ SELECT label, measure FROM table
|
|
|
217
217
|
|
|
218
218
|
- Label - Category
|
|
219
219
|
- Measure - Number
|
|
220
|
-
`;function gu({open:e,setOpen:n,userInput:r,setUserInput:i,triggerAIRun:s,setTriggerAIRun:o}){const l=A.useRef(null),a=A.useRef(null),{authToken:u}=t.useSemaphorContext(),[c,x]=A.useState(!1),p=t.useEditorStore(N=>N.actions.setCardSql),m=t.useDashboardStore(N=>N.dashboard.baseQueries),d=t.useEditorStore(N=>N.actions.setRunSql),j=t.useEditorStore(N=>N.actions.setCardType),[E,k]=A.useState([]),y=t.useEditorStore(N=>N.currentColumns),w=t.useEditorStore(N=>N.card.sql),
|
|
220
|
+
`;function gu({open:e,setOpen:n,userInput:r,setUserInput:i,triggerAIRun:s,setTriggerAIRun:o}){const l=A.useRef(null),a=A.useRef(null),{authToken:u}=t.useSemaphorContext(),[c,x]=A.useState(!1),p=t.useEditorStore(N=>N.actions.setCardSql),m=t.useDashboardStore(N=>N.dashboard.baseQueries),d=t.useEditorStore(N=>N.actions.setRunSql),j=t.useEditorStore(N=>N.actions.setCardType),[E,k]=A.useState([]),y=t.useEditorStore(N=>N.currentColumns),w=t.useEditorStore(N=>N.card.sql),S=t.useEditorStore(N=>N.selectedTableName),D=`
|
|
221
221
|
${r}
|
|
222
222
|
|
|
223
|
-
Database Query Dialect: ${
|
|
224
|
-
Table Name: ${
|
|
223
|
+
Database Query Dialect: ${S==="api"||S==="s3"?"DuckDb":""}
|
|
224
|
+
Table Name: ${S}
|
|
225
225
|
Table Columns: ${y==null?void 0:y.map(N=>`${N.column_name} | ${N.data_type}`).join(", ")}
|
|
226
226
|
User SQL: ${w}
|
|
227
|
-
${m&&`Base Queries: ${JSON.stringify(m)} `}`,
|
|
228
|
-
Visual Query Syntax: ${fu}`,{data:b,isLoading:M,isFetching:T,isError:z,refetch:H}=t.useQuery({queryKey:["ai-query"],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/ai",(u==null?void 0:u.accessToken)||"",{user_content:`userContent: ${O} ${c?D:""}`}),enabled:!1});function I(N){if(N.toLowerCase().includes("bar"))j("bar");else if(N.toLowerCase().includes("line"))j("line");else if(N.toLowerCase().includes("bubble"))j("bubble");else if(N.toLowerCase().includes("scatter"))j("scatter");else if(N.toLowerCase().includes("stacked"))j("stackedBar");else if(N.toLowerCase().includes("pie"))j("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))j("doughnut");else if(N.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}A.useEffect(()=>{b&&k(N=>[...N,{role:"ai",content:b.response}])},[b]),A.useEffect(()=>{const N=setTimeout(()=>{var h;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(h=l.current)==null||h.focus())},100);return()=>clearTimeout(N)},[E]);function v(){r&&(k(N=>[...N,{role:"user",content:r}]),I(r)&&x(!0),i(""),H())}A.useEffect(()=>{s&&(v(),o(!1))},[s,o]);const q={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},$={fontFamily:"monospace",fontSize:14,lineHeight:1.6},V={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},G={p:({node:N,...h})=>t.jsxRuntimeExports.jsx("p",{style:q,...h}),code:({node:N,...h})=>t.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...h}),pre:({node:N,...h})=>t.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:$,children:[t.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:h.children}),t.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:Q,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.ClipboardCopyIcon,{})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:J=>{const te=Q(J);te&&(n(!1),p(te),d(!0))},size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.PlayIcon,{})})]})]}),li:({node:N,...h})=>t.jsxRuntimeExports.jsx("li",{style:V,...h})};function Q(N){const h=N.currentTarget.closest("pre");if(!h)return;const J=h.textContent||h.innerText;return navigator.clipboard.writeText(J).then(()=>console.log("Text copied to clipboard")).catch(te=>console.error("Error in copying text: ",te)),J}function re(){return E==null?void 0:E.map((N,h)=>N.role==="user"?t.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[t.jsxRuntimeExports.jsx(Ti,{className:"mr-2 h-5 w-5"}),t.jsxRuntimeExports.jsx("div",{children:N.content})]},h):N.role==="ai"?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(mu,{className:"w-full overflow-auto py-1",components:G,children:b==null?void 0:b.response},h)}):t.jsxRuntimeExports.jsx("div",{},h))}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Assistant"}),t.jsxRuntimeExports.jsx(t.DialogDescription,{children:"What can I help you with?"})]}),t.jsxRuntimeExports.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:t.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:re()})}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[t.jsxRuntimeExports.jsx(t.Textarea,{autoFocus:!0,ref:l,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),i(""),v())},placeholder:"Type your question here...",onFocus:N=>{const h=N.target,J=h.value.length;h.setSelectionRange(J,J)},className:t.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:M||T,value:r,onChange:N=>i(N.target.value)})," ",t.jsxRuntimeExports.jsx(t.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:v,children:!M&&!T?t.jsxRuntimeExports.jsx(t.PaperPlaneIcon,{}):t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Jr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},er=A.createContext&&A.createContext(Jr),ju=["attr","size","title"];function yu(e,n){if(e==null)return{};var r=Eu(e,n),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(n.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Eu(e,n){if(e==null)return{};var r={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(n.indexOf(s)>=0)&&(r[s]=e[s]);return r}function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ut.apply(this,arguments)}function tr(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function ct(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?tr(Object(r),!0).forEach(function(i){bu(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tr(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function bu(e,n,r){return n=ku(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function ku(e){var n=Su(e,"string");return typeof n=="symbol"?n:String(n)}function Su(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Xr(e){return e&&e.map((n,r)=>A.createElement(n.tag,ct({key:r},n.attr),Xr(n.child)))}function ze(e){return n=>A.createElement(Ru,ut({attr:ct({},e.attr)},n),Xr(e.child))}function Ru(e){var n=r=>{var{attr:i,size:s,title:o}=e,l=yu(e,ju),a=s||r.size||"1em",u;return r.className&&(u=r.className),e.className&&(u=(u?u+" ":"")+e.className),A.createElement("svg",ut({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,l,{className:u,style:ct(ct({color:e.color||r.color},r.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&A.createElement("title",null,o),e.children)};return er!==void 0?A.createElement(er.Consumer,null,r=>n(r)):n(Jr)}function Cu(e){return ze({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(e)}function wu(){const{theme:e}=t.useTheme(),n=A.useRef(),r=A.useRef(),[i,s]=A.useState(!1),[o,l]=A.useState(!1),[a,u]=A.useState(!1),[c,x]=A.useState(""),[p,m]=A.useState(!1),{authToken:d}=t.useSemaphorContext();t.useDashboardStore(g=>g.selectedSheetId);const j=t.useDashboardStore(g=>g.dashboard.baseQueries),E=t.useEditorStore(g=>g.card),k=t.useDashboardStore(g=>g.theme),y=t.useEditorStore(g=>g.isShowingVisual),w=t.useEditorStore(g=>g.selectedConnectionId),R=t.useEditorStore(g=>g.selectedDatabaseName),O=t.useEditorStore(g=>g.selectedSchemaName);t.useDashboardStore(g=>g.actions.updateFrameCard);const D=t.useEditorStore(g=>g.selectedTableName),b=t.useEditorStore(g=>g.card.sql),M=t.useEditorStore(g=>g.card.python),T=t.resolveBaseQuery(b,j),z=t.useEditorStore(g=>g.selectedConnectionId),H=t.useEditorStore(g=>g.frame),I=t.useEditorStore(g=>g.filterValues),v=t.useEditorStore(g=>g.applyFilters),{setCardCustomCfg:q,setQueryResultColumns:$,setFilterValues:V,setCardSql:G,setCardPython:Q,setQueryError:re,setPythonStdOut:N}=t.useEditorStore(g=>g.actions),h=t.useEditorStore(g=>g.onSave),J=t.useEditorStore(g=>g.actions.setApplyFilters),te=t.useEditorStore(g=>g.onClose),f=t.useEditorStore(g=>g.actions.setCardData),ae=t.useEditorStore(g=>g.actions.setSqlGen),ge=t.useEditorStore(g=>g.runSql),X=t.useEditorStore(g=>g.actions.setRunSql),ke=t.useEditorStore(g=>g.actions.setIsSqlRunning),{data:ne,isLoading:he,isFetching:xe,isSuccess:Le,isError:Oe,error:He,status:mt,refetch:Ie}=t.useQuery({queryKey:[T,M],queryFn:()=>t.postRequest("https://semaphor.cloud/api/v1/query",(d==null?void 0:d.accessToken)||"",{connection_id:z,sql:T,python:M===t.PYTHON_DEFAULT_CODE?"":M,active_filters:v?I:[]}),enabled:!1,retry:!1});A.useEffect(()=>{if(ne&&(f(ne.records),N((ne==null?void 0:ne.output)||""),ne.records.length>0)){const{dimensionKeys:g}=t.getKeys(ne.records);$(g)}},[ne,f,$,N]),A.useEffect(()=>{ge&&(Ie(),X(!1))},[ge,Ie,X]),A.useEffect(()=>{(he||xe)&&ke(!0),(Oe||Le)&&ke(!1),Oe?(re(He.message),f([]),$([]),N("")):re("")},[he,xe,ne,N,Oe,Le,ke,f,$,re,He]);function Je(){G(""),f([]),ae({}),q("")}const Xe=g=>{r.current=g};function Ye(){let g=b;b&&!b.includes("{{")&&(g=Pi(b),G(g));const C={...E,lastSelectedSchema:O,lastSelectedDatabase:R,lastSelectedTable:D,connectionId:w,type:y?E.type:"table",sql:g,customCfg:y?E.customCfg:null},L=H.cards.map(P=>P.id===E.id?C:P);h==null||h({...H,cards:L})}function Ze(){te==null||te()}function ht(g){const C=getComputedStyle(document.documentElement).getPropertyValue(g);return ft(C)}function ft(g){const[C,L,P]=g.split(" "),B=parseFloat(C),ue=parseFloat(L),Se=parseFloat(P),fe=ue/100,we=Se/100,se=(1-Math.abs(2*we-1))*fe,Y=se*(1-Math.abs(B/60%2-1)),je=we-se/2;let ee=0,Re=0,Ce=0;0<=B&&B<60?(ee=se,Re=Y,Ce=0):60<=B&&B<120?(ee=Y,Re=se,Ce=0):120<=B&&B<180?(ee=0,Re=se,Ce=Y):180<=B&&B<240?(ee=0,Re=Y,Ce=se):240<=B&&B<300?(ee=Y,Re=0,Ce=se):300<=B&&B<360&&(ee=se,Re=0,Ce=Y),ee=Math.round((ee+je)*255),Re=Math.round((Re+je)*255),Ce=Math.round((Ce+je)*255);const yt=li=>{const Et=li.toString(16);return Et.length==1?"0"+Et:Et};return`#${yt(ee)}${yt(Re)}${yt(Ce)}`}A.useEffect(()=>{const g=n.current,C=r.current;if(g){const L=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",P=k==="system"?L:k;g.editor.defineTheme("default",{base:P==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":P==="light"?"#ffffff":ht("--background")}}),g.editor.setTheme("default")}return C&&g&&C.addCommand(g.KeyMod.Shift|g.KeyCode.Enter,function(){return console.log("Executing query..."),Ie(),!1}),()=>{}},[e,k,n.current]);function et(g){n.current=g}function gt(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[o&&t.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:t.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[t.jsxRuntimeExports.jsx(_i,{checked:v,onCheckedChange:()=>J(!v),text:"Apply Filters"}),t.jsxRuntimeExports.jsx(Vi,{}),I&&o&&t.jsxRuntimeExports.jsx(t.Cross2Icon,{onClick:()=>l(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",onChange:g=>{if(g)try{JSON.parse(g),V(JSON.parse(g))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(I,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),I&&!o&&t.jsxRuntimeExports.jsx(ir,{onClick:()=>l(!0),className:t.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":v})})]})}function jt(){return t.jsxRuntimeExports.jsxs(Lt,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[t.jsxRuntimeExports.jsxs(Fe,{id:"1",order:1,defaultSize:i?20:100,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:g=>{G(g)},value:b,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:et,onMount:Xe})}),i&&t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),i&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border"}),t.jsxRuntimeExports.jsxs(Fe,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:t.jsxRuntimeExports.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:g=>{Q(g&&g.trim()||"")},value:M||t.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:et,onMount:Xe})}),t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return t.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[t.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[jt(),gt()]}),t.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{disabled:he||xe,onClick:()=>{Ie()},className:"shrink-0",size:"sm",variant:"outline",children:[he||xe?t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):t.jsxRuntimeExports.jsx(Si,{className:"mr-2 h-4 w-4"}),"Run"]}),Oe&&t.jsxRuntimeExports.jsx(Bi,{error:He.message,setShowAIDialog:u,setTriggerAIRun:m,setUserInputforAI:x}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Je,className:"",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(xi,{className:"mr-2 size-4"}),"Clear"]}),t.jsxRuntimeExports.jsx(t.Toggle,{pressed:i,onPressedChange:g=>s(g),className:"",size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Cu,{className:"size-4 text-foreground/70"})}),t.jsxRuntimeExports.jsx(gu,{open:a,setOpen:u,userInput:c,triggerAIRun:p,setTriggerAIRun:m,setUserInput:g=>x(g)})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ye,size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ze,className:"w-full",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function vu({data:e}){var l;const[n,r]=A.useState([]),s=Object.keys(e[0]).map(a=>({accessorKey:a,header:({column:u})=>{const c=u.getIsSorted();return t.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>u.toggleSorting(u.getIsSorted()==="asc"),children:[a,c==="asc"?t.jsxRuntimeExports.jsx(t.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):c==="desc"?t.jsxRuntimeExports.jsx(t.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),o=t.useReactTable({data:e,columns:s,getCoreRowModel:t.getCoreRowModel(),getPaginationRowModel:t.getPaginationRowModel(),onSortingChange:r,getSortedRowModel:t.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return t.jsxRuntimeExports.jsxs(t.Table,{children:[t.jsxRuntimeExports.jsx(t.TableHeader,{children:o.getHeaderGroups().map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{children:a.headers.map(u=>t.jsxRuntimeExports.jsx(t.TableHead,{className:"sticky top-0 bg-muted",children:u.isPlaceholder?null:t.flexRender(u.column.columnDef.header,u.getContext())},u.id))},a.id))}),t.jsxRuntimeExports.jsx(t.TableBody,{children:(l=o.getRowModel().rows)!=null&&l.length?o.getRowModel().rows.map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{className:"whitespace-nowrap py-2","data-state":a.getIsSelected()&&"selected",children:a.getVisibleCells().map(u=>t.jsxRuntimeExports.jsx(t.TableCell,{children:t.flexRender(u.column.columnDef.cell,u.getContext())},u.id))},a.id)):t.jsxRuntimeExports.jsx(t.TableRow,{children:t.jsxRuntimeExports.jsx(t.TableCell,{colSpan:s.length,className:"h-24 text-center",children:"No results."})})})]})}function Yr({className:e,...n}){A.useState(0);const r=t.useDashboardStore(l=>l.themeStyle),i=t.useEditorStore(l=>l.card),s=t.useEditorStore(l=>l.actions.setCard);if(A.useEffect(()=>{},[i.data,i.type,i.cfg,i.customCfg,r,i.preferences]),!i.id)return null;let o;return i.data&&i.data.length>0&&(o=t.createChartConfig({data:i.data,cardType:i.type,cfg:i.cfg,customCfg:i.customCfg,preferences:i.preferences})),t.jsxRuntimeExports.jsxs(t.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none",e),...n,children:[t.jsxRuntimeExports.jsxs(t.CardHeader,{className:"py-4",children:[t.jsxRuntimeExports.jsx(t.Editable,{text:i.title,onSave:l=>s({...i,title:l}),children:t.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:t.jsxRuntimeExports.jsx(t.CardTitle,{className:"text-base",children:i.title})})},i.title),t.jsxRuntimeExports.jsx(t.Editable,{text:i.description||"",onSave:l=>s({...i,description:l}),children:t.jsxRuntimeExports.jsxs(t.CardDescription,{children:[" ",i.description]})},i.description)]}),t.jsxRuntimeExports.jsxs(t.CardContent,{className:"flex grow flex-col pb-3",children:[i.type!=="table"&&o&&t.jsxRuntimeExports.jsx(t.ChartJsVisual,{cfg:o},JSON.stringify(o)),i.type==="table"&&i.data&&i.data.length>0&&t.jsxRuntimeExports.jsx(t.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:t.jsxRuntimeExports.jsx(t.TableVisual,{card:i,data:i==null?void 0:i.data})})]})]})}function Nu(){const[e,n]=A.useState(!1),[r,i]=A.useState(""),[s,o]=A.useState(""),[l,a]=A.useState(""),u=t.useEditorStore(k=>k.card),c=t.useEditorStore(k=>k.card.customCfg),x=t.useEditorStore(k=>k.actions.setCardCustomCfg);function p(k){var R,O;const y={...k,data:{...k==null?void 0:k.data,datasets:(O=(R=k==null?void 0:k.data)==null?void 0:R.datasets)==null?void 0:O.map(D=>({...D,data:[]}))}};return JSON.stringify(y,null,1)}function m(){if(!u.data||u.data.length===0)return;const k=t.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});k&&(i(JSON.stringify(k,null,1)),c&&o(JSON.stringify(c,null,1)))}function d(){if(s)try{const k=JSON.parse(s);return k?(x(k),a(""),o(""),k):void 0}catch(k){console.log(k),a("Invalid JSON")}}function j(){o(""),x(null)}function E(){let k;if(c){const y=t._.cloneDeep(u.cfg),w=t._.merge(y,c);return k=p(w),k}return r?(k=p(JSON.parse(r)),k):""}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{onClick:m,className:` ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.Settings,{className:"h-4 w-4"})})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"max-h-[70vh] min-h-[70vh] min-w-[900px] overflow-auto",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{className:"",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Customize Card"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(gi,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{side:"right",align:"center",children:t.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogDescription,{children:["See the configuration options and documentation",t.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[t.jsxRuntimeExports.jsx(Yr,{className:"w-1/2 rounded shadow-none"}),t.jsxRuntimeExports.jsxs(t.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[t.jsxRuntimeExports.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[t.jsxRuntimeExports.jsxs(t.TabsTrigger,{value:"custom-config",children:[c&&t.jsxRuntimeExports.jsx(t.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),c?"Custom Config":"Default Config"]}),t.jsxRuntimeExports.jsx(t.TabsTrigger,{className:"",value:"output",children:"Output"})]}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:t.jsxRuntimeExports.jsx(t.Textarea,{disabled:!0,value:r,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:t.jsxRuntimeExports.jsx(t.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:E(),onChange:k=>o(k)})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogFooter,{className:"flex items-center",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"mr-2 text-red-500",children:l}),t.jsxRuntimeExports.jsx(t.Button,{disabled:!c,onClick:j,variant:"outline",children:"Reset"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:d,variant:"outline",children:"Apply"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Zr(e){return ze({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(e)}function ei(e){return ze({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(e)}function ti(e){return ze({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(e)}function ni(e){return ze({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(e)}function ri(e){return ze({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(e)}function ii(e){return ze({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(e)}function Iu(){const[e,n]=A.useState(!1),r=t.useEditorStore(l=>l.card.type),i=t.useEditorStore(l=>l.actions.setCardType),s=t.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){i(l),s(null),n(!1)}return t.jsxRuntimeExports.jsxs(t.Popover,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Au,{className:"h-4 w-4",chartType:r})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-50",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:t.jsxRuntimeExports.jsx(Ut,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("line"),variant:"ghost",children:t.jsxRuntimeExports.jsx($t,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ri,{className:"size-5 ",strokeWidth:0})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("scatter"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ar,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bubble"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ni,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("pie"),variant:"ghost",children:t.jsxRuntimeExports.jsx(or,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ei,{className:"size-5 ",strokeWidth:1})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("radar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Zr,{className:"size-5 font-extralight",strokeWidth:.5})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ti,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("table"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Kt,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("kpi"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ii,{className:"size-6 "})})]})})]})}function Au({chartType:e,className:n}){switch(e){case"bar":return t.jsxRuntimeExports.jsx(Ut,{className:n});case"line":return t.jsxRuntimeExports.jsx($t,{className:n});case"pie":return t.jsxRuntimeExports.jsx(or,{className:n});case"radar":return t.jsxRuntimeExports.jsx(Zr,{className:n});case"scatter":return t.jsxRuntimeExports.jsx(ar,{className:n});case"bubble":return t.jsxRuntimeExports.jsx(ni,{className:n});case"doughnut":return t.jsxRuntimeExports.jsx(ei,{className:n});case"stackedBar":return t.jsxRuntimeExports.jsx(ri,{className:"size-4 text-foreground/70 "});case"polarArea":return t.jsxRuntimeExports.jsx(ti,{className:n});case"kpi":return t.jsxRuntimeExports.jsx(ii,{className:n});default:return t.jsxRuntimeExports.jsx(Kt,{className:n})}}function Tu(){const e=t.useEditorStore(r=>r.card.refreshInterval),n=t.useEditorStore(r=>r.actions.setCardRefreshInterval);return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(ai,{className:"w-4 h-4"})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-[200px]",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),t.jsxRuntimeExports.jsx(t.Input,{value:e||"",onChange:r=>n(r.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function nr(){t.useEditorStore(l=>l.frame);const e=t.useEditorStore(l=>l.card),n=t.useEditorStore(l=>l.card.data),r=t.useEditorStore(l=>l.isShowingVisual),i=t.useEditorStore(l=>l.isSqlRunning),s=t.useEditorStore(l=>l.queryError),o=t.useEditorStore(l=>l.pythonStdOut);return t.useEditorStore(l=>l.onSave),t.useEditorStore(l=>l.onClose),t.useEditorStore(l=>l.actions.setCardSql),t.useEditorStore(l=>l.actions.setCardType),t.useEditorStore(l=>l.actions.setSqlGen),e?t.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[i&&t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),t.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsx(Iu,{}),t.jsxRuntimeExports.jsx(Nu,{}),t.jsxRuntimeExports.jsx(Tu,{})]}),t.jsxRuntimeExports.jsx(Lu,{})]}),r?e.type==="kpi"?t.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:t.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:t.jsxRuntimeExports.jsx(t.KPICard,{isLoading:i,card:e})})}):t.jsxRuntimeExports.jsx(Yr,{className:"grow border-none shadow-none"}):t.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[o&&t.jsxRuntimeExports.jsx(zu,{}),e.data&&e.data.length>0&&t.jsxRuntimeExports.jsx(vu,{data:n||[]}),s&&t.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:s})]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:"No Active Card"})}function zu(){const e=t.useEditorStore(r=>r.pythonStdOut);if(!e)return null;const n=e.replace(/\n/g,"<br>");return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),t.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),t.jsxRuntimeExports.jsx(t.Separator,{className:"mb-2"})]})}function Lu(){const e=t.useEditorStore(r=>r.isShowingVisual),n=t.useEditorStore(r=>r.actions.setIsShowingVisual);return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),t.jsxRuntimeExports.jsx(t.Switch$1,{checked:e,onCheckedChange:()=>n(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Ve(){const[e,n]=A.useState([]);t.useEditorStore(x=>x.card.cfg);const r=t.useEditorStore(x=>x.card.preferences),{setCardCfg:i,setFilterOnClickColumnIndex:s,setCardPreferences:o}=t.useEditorStore(x=>x.actions),l=t.useEditorStore(x=>x.queryResultColumns);t.useEditorStore(x=>{var p;return(p=x.card.preferences)==null?void 0:p.filterOnClickColumnIndex}),A.useEffect(()=>{l&&n(new Array(l.length).fill(!1))},[l]);function a(x,p){var m,d;p?r!=null&&r.onClickFilter&&((m=r==null?void 0:r.onClickFilter)==null?void 0:m.length)>0?o({...r,onClickFilter:[...r.onClickFilter,{columnIndex:x,expression:""}]}):o({...r,onClickFilter:[{columnIndex:x,expression:""}]}):(o({...r,onClickFilter:(d=r==null?void 0:r.onClickFilter)==null?void 0:d.filter(j=>j.columnIndex!==x)}),n(j=>{const E=[...j];return E[x]=!1,E}))}function u(x,p){var d;const m=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.map(j=>j.columnIndex===x?{...j,expression:p.target.value}:j);o({...r,onClickFilter:m})}function c(x){var p,m,d,j;if(e!=null&&e[x]||(m=(p=r==null?void 0:r.onClickFilter)==null?void 0:p.find(E=>E.columnIndex===x))!=null&&m.expression)return t.jsxRuntimeExports.jsx(t.Input,{value:(j=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(E=>E.columnIndex===x))==null?void 0:j.expression,onChange:E=>u(x,E),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:l==null?void 0:l.map((x,p)=>{var m,d;return t.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:t.jsxRuntimeExports.jsxs("div",{className:" grow",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((m=r==null?void 0:r.onClickFilter)!=null&&m.find(j=>j.columnIndex===p)),onCheckedChange:j=>a(p,j)}),t.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),t.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===p))&&t.jsxRuntimeExports.jsx(sr,{onClick:()=>{n(j=>{const E=[...j];return E[p]=!j[p],E})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(p)]})},x)})})}function an(){var o,l;const e=t.useEditorStore(a=>a.card.preferences),n=t.useEditorStore(a=>a.card.cfg),{setCardCfg:r,setCardPreferences:i}=t.useEditorStore(a=>a.actions);(o=n==null?void 0:n.options)!=null&&o.indexAxis;function s(a){var x,p,m,d,j,E;let u={};(x=e==null?void 0:e.chartOptions)!=null&&x.scales&&(u={x:(m=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:m.y,y:(j=(d=e==null?void 0:e.chartOptions)==null?void 0:d.scales)==null?void 0:j.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(E=e==null?void 0:e.chartOptions)==null?void 0:E.scales,...u},indexAxis:a}};i(c)}return t.jsxRuntimeExports.jsxs(t.RadioGroup,{value:((l=e==null?void 0:e.chartOptions)==null?void 0:l.indexAxis)||"x",onValueChange:s,className:"flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"x",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"y",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const zt="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function si(e){var r,i;return(r=e==null?void 0:e.chartOptions)!=null&&r.indexAxis?((i=e==null?void 0:e.chartOptions)==null?void 0:i.indexAxis)==="x"?"y":"x":"y"}function rr(e){var r,i,s;const n=si(e);return((s=(i=(r=e==null?void 0:e.chartOptions)==null?void 0:r.scales)==null?void 0:i[n])==null?void 0:s.type)||"linear"}function Ou(){var w,R,O,D,b,M;const[e,n]=A.useState(!1),r=t.useEditorStore(T=>{var z;return(z=T.card)==null?void 0:z.preferences}),i=si(r),[s,o]=A.useState(rr(r)),[l,a]=A.useState(((O=(R=(w=r==null?void 0:r.chartOptions)==null?void 0:w.scales)==null?void 0:R[i])==null?void 0:O.min)||""),[u,c]=A.useState(((M=(b=(D=r==null?void 0:r.chartOptions)==null?void 0:D.scales)==null?void 0:b[i])==null?void 0:M.max)||""),[x,p]=A.useState(l||u?"custom":"auto"),[m,d]=A.useState(""),j=t.useEditorStore(T=>T.actions.setCardPreferences);A.useEffect(()=>{var T,z,H,I,v,q,$,V,G,Q;o(rr(r)),a(((H=(z=(T=r==null?void 0:r.chartOptions)==null?void 0:T.scales)==null?void 0:z[i])==null?void 0:H.min)===0?0:""),c(((q=(v=(I=r==null?void 0:r.chartOptions)==null?void 0:I.scales)==null?void 0:v[i])==null?void 0:q.max)||""),d(((Q=(G=(V=($=r==null?void 0:r.chartOptions)==null?void 0:$.scales)==null?void 0:V[i])==null?void 0:G.ticks)==null?void 0:Q.stepSize)||"")},[e,r,i]);function E(T,z){return z===""||/^[0-9\b]+$/.test(z)?Number(z):Number(T)}function k(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"range",children:"Range"}),t.jsxRuntimeExports.jsx(t.Input,{id:"min",value:l,onChange:T=>a(z=>E(z,T.target.value)),className:`col-span-1 h-8 w-full ${zt}`}),t.jsxRuntimeExports.jsx(t.Input,{value:u,onChange:T=>c(z=>E(z,T.target.value)),id:"max",className:`col-span-1 h-8 w-full ${zt}`})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"step-size",children:"Step Size"}),t.jsxRuntimeExports.jsx(t.Input,{value:m,onChange:T=>d(z=>E(z,T.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${zt}`})]})]})}function y(){var H;let T={};x==="custom"&&(T={min:l,max:u,ticks:{stepSize:m}});const z={...r||{},chartOptions:{...r==null?void 0:r.chartOptions,scales:{...(H=r==null?void 0:r.chartOptions)==null?void 0:H.scales,[i]:{type:s,...s==="linear"?T:{}}}}};j(z)}return t.jsxRuntimeExports.jsxs(t.Popover,{onOpenChange:T=>n(T),children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{align:"center",className:"max-w-65",children:t.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),t.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale",children:"Type"}),t.jsxRuntimeExports.jsxs(t.Select,{value:s,onValueChange:T=>o(T),children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{})}),t.jsxRuntimeExports.jsx(t.SelectContent,{id:"type",children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Option"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"linear",children:"Linear"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),s=="linear"&&t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale-option",children:"Setup"}),t.jsxRuntimeExports.jsxs(t.RadioGroup,{id:"scale-option",value:x,onValueChange:T=>p(T),className:"col-span-2 flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"auto",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"custom",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),x==="custom"&&s=="linear"&&k(),t.jsxRuntimeExports.jsx(t.SelectSeparator,{}),t.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:t.jsxRuntimeExports.jsx(t.Button,{onClick:y,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Du({idx:e}){var a;const n=t.useEditorStore(u=>{var c;return(c=u.card)==null?void 0:c.preferences}),r=t.useEditorStore(u=>{var c;return(c=u.card.preferences)==null?void 0:c.datasetOptions}),i=t.useEditorStore(u=>u.actions.setCardPreferences),s=(a=n==null?void 0:n.chartOptions)==null?void 0:a.indexAxis,o=r==null?void 0:r.find(u=>u.idx===e);function l(u,c){(u==="end"||u==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const x={display:u!=="none",align:u,anchor:u,clamp:!0};if(!o)i({...n,datasetOptions:[...r||[],{idx:c,datalabels:x}]});else{const p={...o};p.datalabels=x;const m=r==null?void 0:r.map(d=>d.idx===c?p:d);i({...n,datasetOptions:m})}}return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{children:t.jsxRuntimeExports.jsx(Ni,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),t.jsxRuntimeExports.jsxs(t.PopoverContent,{className:"flex w-fit gap-1 p-1",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("none",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(t.X,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("start",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(ji,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("center",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(Ei,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("end",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(yi,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})})]})]})}function oi(){const e=t.useEditorStore(u=>u.card),n=t.useEditorStore(u=>{var c,x,p;return(p=(x=(c=u==null?void 0:u.card)==null?void 0:c.preferences)==null?void 0:x.chartOptions)==null?void 0:p.indexAxis}),r=n==="y"?"Y axis":"X axis",i=n==="y"?"X axis":"Y axis",{keys:s,metricKeys:o,dimensionKeys:l}=t.getKeys(e.data||[]);let a=o;if(e.type==="stackedBar"){const u=t.pivotData({dataArray:e.data||[],groupKey:l[0],pivotKey:l[1],valueKey:a[0]}),{metricKeys:c}=t.getKeys(u);a=c}return s.length===0?null:t.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx(t.Label,{children:r}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:t.jsxRuntimeExports.jsx("p",{children:l[0]})})})]}),t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[t.jsxRuntimeExports.jsx(t.Label,{children:i}),t.jsxRuntimeExports.jsx(Ou,{})]}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:a.map((u,c)=>t.jsxRuntimeExports.jsx(Fu,{col:u,idx:c},u))})]})]})}function Fu({col:e,idx:n}){const r=t.useEditorStore(a=>{var u;return(u=a.card)==null?void 0:u.preferences}),i=t.useEditorStore(a=>{var u;return(u=a.card.preferences)==null?void 0:u.datasetOptions}),s=i==null?void 0:i.find(a=>a.idx===n),{setCardPreferences:o}=t.useEditorStore(a=>a.actions);function l(a){if(!s)o({...r,datasetOptions:[...i||[],{idx:n,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const u={...s};u.type=a==="area"?"line":a,u.fill=a==="area"?"origin":"";const c=i==null?void 0:i.map(x=>x.idx===n?u:x);o({...r,datasetOptions:c})}}return t.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[t.jsxRuntimeExports.jsx("p",{children:e}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t.jsxRuntimeExports.jsx(Ut,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx($t,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(ui,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(t.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(Du,{idx:n})]})]})}function Mu({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function un(){var i,s,o;const e=t.useEditorStore(l=>l.card.cfg),n=t.useEditorStore(l=>l.actions.setCardCfg);function r(l){var c;const a={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},u={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};n(u),console.log(l)}return t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),t.jsxRuntimeExports.jsxs(t.Select,{value:(o=(s=(i=e==null?void 0:e.options)==null?void 0:i.plugins)==null?void 0:s.datalabels)==null?void 0:o.anchor,onValueChange:r,defaultValue:"none",children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{placeholder:"Select position"})}),t.jsxRuntimeExports.jsx(t.SelectContent,{children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Data Labels"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"none",children:"None"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"start",children:"Start"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"center",children:"Center"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Pu({cardType:e}){function n(r){const i="SELECT label, [group], x-axis, y-axis, radius FROM table",s="SELECT label, [group], x-axis, y-axis FROM table";return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:r==="bubble"?i:s}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"group - category"}),t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),r==="bubble"&&t.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(e)})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}const Bu={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},_u={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Vu(){const e=t.useEditorStore(n=>n.card.type);return t.jsxRuntimeExports.jsxs("div",{className:"p-6 space-y-6",children:[t.jsxRuntimeExports.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:Hu(e)}),t.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(e)&&t.jsxRuntimeExports.jsx(an,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(un,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(Ve,{})})]})}function Hu(e){if(["line","bar"].includes(e))return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Mixed Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(Bu,null,2)})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Area Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",t.jsxRuntimeExports.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(_u,null,2)})]})]})]});if(e==="bubble")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),t.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:[t.jsxRuntimeExports.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function qu(){var l,a,u;const e=t.useEditorStore(c=>c.card.preferences),n=t.useEditorStore(c=>c.actions.setCardPreferences),r=t.useEditorStore(c=>c.actions.setNumberFormat),i=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.format}),s=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.currency});return t.useEditorStore(c=>c.actions.setFilterOnClickField),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((l=e==null?void 0:e.formatNumber)!=null&&l.enabled),onCheckedChange:c=>{n({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),t.jsxRuntimeExports.jsx(t.Label,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Currency"}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Input,{value:o||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",c.target.value,((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}}),t.jsxRuntimeExports.jsx(t.Input,{value:s||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",c.target.value,((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})]})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Format"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(t.InfoCircledIcon,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{children:t.jsxRuntimeExports.jsxs("div",{className:"max-w-[200px]",children:["Format number",t.jsxRuntimeExports.jsx("div",{className:"mt-1 font-mono text-xs",children:"#.## for 123.43"})]})})]})]}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsx(t.Input,{value:i||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var x,p,m;return r(c.target.value,((x=e==null?void 0:e.formatNumber)==null?void 0:x.currency)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Suffix"}),t.jsxRuntimeExports.jsx(t.Input,{value:((u=e==null?void 0:e.formatNumber)==null?void 0:u.suffix)||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.locale)||"",c.target.value)}})]})]})]})}function Uu(){return t.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[t.jsxRuntimeExports.jsx(t.Accordion,{type:"single",collapsible:!0,children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"font-mono",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"current - number"}),t.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),t.jsxRuntimeExports.jsx("section",{className:"",children:t.jsxRuntimeExports.jsx(qu,{})}),t.jsxRuntimeExports.jsx("div",{}),t.jsxRuntimeExports.jsx("div",{})]})}function $u({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Ku(){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Wu({cardType:e}){return console.log("TableVisualSettings",e),t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsx(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})})})}function Gu(){const e=t.useEditorStore(r=>r.card.type);function n(r){switch(r){case"stackedBar":return t.jsxRuntimeExports.jsx(Ku,{});case"kpi":return t.jsxRuntimeExports.jsx(Uu,{});case"line":case"bar":return t.jsxRuntimeExports.jsx(Mu,{cardType:r});case"pie":case"doughnut":case"polarArea":case"radar":return t.jsxRuntimeExports.jsx($u,{cardType:r});case"bubble":case"scatter":return t.jsxRuntimeExports.jsx(Pu,{cardType:r});case"table":return t.jsxRuntimeExports.jsx(Wu,{cardType:r});default:return t.jsxRuntimeExports.jsx(Vu,{})}}return t.jsxRuntimeExports.jsx(t.ScrollArea,{className:"h-full w-full text-sm",children:n(e)})}function Qu(){const e=t.useEditorStore(n=>n.isShowingVisual);return t.jsxRuntimeExports.jsxs(Lt,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[t.jsxRuntimeExports.jsx(Fe,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:t.jsxRuntimeExports.jsx(wu,{})}),t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border "}),t.jsxRuntimeExports.jsx(Fe,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?t.jsxRuntimeExports.jsxs(Lt,{direction:"horizontal",children:[t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(Fe,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:t.jsxRuntimeExports.jsx(Gu,{})})}),t.jsxRuntimeExports.jsx(Ot,{className:"border "}),t.jsxRuntimeExports.jsx(Fe,{minSize:40,defaultSize:75,maxSize:100,children:t.jsxRuntimeExports.jsx(nr,{})})]}):t.jsxRuntimeExports.jsx(nr,{})})]})}function Ju({authToken:e,onSave:n,onClose:r}){const i=t.useEditorStore(l=>l.actions.setOnSave),s=t.useEditorStore(l=>l.actions.setOnClose),o=t.useDashboardStore(l=>l.actions.setAuthToken);return A.useEffect(()=>{n&&i(n),r&&s(r)},[n,i,r,s]),A.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),t.jsxRuntimeExports.jsxs(t.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[t.jsxRuntimeExports.jsx(t.EditorAside,{className:"rounded-none border-r-[1.5px]",children:t.jsxRuntimeExports.jsx(cr,{})}),t.jsxRuntimeExports.jsx(t.EditorMain,{children:t.jsxRuntimeExports.jsx(Qu,{})})]})}function Xu(){t.useDashboardStore(l=>l.selectedCardId);const e=t.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardStore(l=>l.actions),r=t.useDashboardStore(l=>l.isVisualEditing),i=t.useDashboardStore(l=>l.actions.updateFrame);function s(l){e&&(i(e,l),n(!1))}function o(){n(!1)}return t.jsxRuntimeExports.jsx("div",{role:"editor-container",className:t.cn("flex grow",{block:r,hidden:!r}),children:t.jsxRuntimeExports.jsx(Ju,{onSave:s,onClose:o})})}function Yu({columns:e,tableName:n}){const r=t.useEditorStore(p=>p.selectedConnectionId),i=t.useEditorStore(p=>p.selectedDatabaseName),s=t.useEditorStore(p=>p.selectedSchemaName),o=t.useEditorStore(p=>p.selectedTableName),l=t.useDashboardStore(p=>p.dashboard.filters)||[],a=t.useDashboardStore(p=>p.actions.addFilter),u=t.useDashboardStore(p=>p.actions.removeFilter),c=t.useDashboardStore(p=>p.actions.removeFilterValue);function x(p){const m=t.fmt(p.column_name),d=t.fmt(i||""),j=t.fmt(s||""),E=t.fmt(n),k=t.getQualifiedTableName(j,E),y=`${k}.${m}`;console.log("find",y,E,d);const w=l==null?void 0:l.find(R=>R.column===y&&R.table===E&&(R.database===d||R.database===i));if(w)c(w.id),u(w.id);else{if(n==="api"&&r){a({id:t.v4(),column:y,title:p.column_name,dataType:p.data_type,table:"api",database:"NA",connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)});return}if(!r||!i||!o)throw new Error("missing connectionId, database, or table");a({id:t.v4(),column:`${k}.${m}`,title:p.column_name,dataType:p.data_type,table:o,database:i,connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)})}}return t.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:e==null?void 0:e.map(p=>{const m=l==null?void 0:l.find(d=>d.column===t.fmt(p.column_name)&&d.table===o&&d.database===i);return t.jsxRuntimeExports.jsx("div",{onClick:()=>x(p),className:t.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(ur,{column:p}),t.jsxRuntimeExports.jsx("span",{children:p.column_name})]})},p.column_name)})})}function Zu(){t.useDashboardStore(n=>n.showFilters);const e=t.useDashboardStore(n=>n.actions.setShowFilters);return t.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-lg",children:"Filters"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>e(!1),className:"h-7 w-7 p-0",variant:"ghost",children:t.jsxRuntimeExports.jsx(t.Cross2Icon,{})})]}),t.jsxRuntimeExports.jsx("div",{className:"flex grow",children:t.jsxRuntimeExports.jsx(cr,{ColumnsComponent:(n,r,i)=>t.jsxRuntimeExports.jsx(Yu,{schemaName:n,tableName:r,columns:i})})})]})}function ec(){t.useDashboardStore(r=>r.dashboard);const e=t.useDashboardStore(r=>r.showFilters),n=t.useDashboardStore(r=>r.isVisualEditing);return t.useDashboardStore(r=>r.bookmarkKey),t.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:t.cn("grow",{hidden:n,flex:!n}),children:[t.jsxRuntimeExports.jsx(t.DashboardTabs,{}),e&&t.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:t.jsxRuntimeExports.jsx(Zu,{})})]})}function tc(){const e=t.useDashboardStore(i=>i.dashboard),n=t.useDashboardStore(i=>i.actions.setDashboard),r=t.useDashboardStore(i=>i.showDashboardJSON);return t.useDashboardStore(i=>i.actions.setShowDashboardJSON),t.jsxRuntimeExports.jsx("div",{className:t.cn(" p-2",{hidden:!r}),children:t.jsxRuntimeExports.jsx(t.de,{onChange:i=>{if(i)try{JSON.parse(i),n(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function nc({showControls:e=!1,showFooter:n=!0,...r}){return t.jsxRuntimeExports.jsx(t.SemaphorContextProvider,{dashboardProps:r,children:t.jsxRuntimeExports.jsxs(t.UXProvider,{children:[t.jsxRuntimeExports.jsx(tc,{}),t.jsxRuntimeExports.jsxs(t.DashboardPanel,{...r,children:[e&&t.jsxRuntimeExports.jsx(Di,{}),t.jsxRuntimeExports.jsx(Xu,{}),t.jsxRuntimeExports.jsx(ec,{})]})]})})}exports.DashboardPlus=nc;exports.SelectComponent=Ue;
|
|
227
|
+
${m&&`Base Queries: ${JSON.stringify(m)} `}`,O=` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
|
|
228
|
+
Visual Query Syntax: ${fu}`,{data:b,isLoading:M,isFetching:T,isError:z,refetch:H}=t.useQuery({queryKey:["ai-query"],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/ai",(u==null?void 0:u.accessToken)||"",{user_content:`userContent: ${D} ${c?O:""}`}),enabled:!1});function I(N){if(N.toLowerCase().includes("bar"))j("bar");else if(N.toLowerCase().includes("line"))j("line");else if(N.toLowerCase().includes("bubble"))j("bubble");else if(N.toLowerCase().includes("scatter"))j("scatter");else if(N.toLowerCase().includes("stacked"))j("stackedBar");else if(N.toLowerCase().includes("pie"))j("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))j("doughnut");else if(N.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}A.useEffect(()=>{b&&k(N=>[...N,{role:"ai",content:b.response}])},[b]),A.useEffect(()=>{const N=setTimeout(()=>{var h;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(h=l.current)==null||h.focus())},100);return()=>clearTimeout(N)},[E]);function v(){r&&(k(N=>[...N,{role:"user",content:r}]),I(r)&&x(!0),i(""),H())}A.useEffect(()=>{s&&(v(),o(!1))},[s,o]);const U={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},$={fontFamily:"monospace",fontSize:14,lineHeight:1.6},P={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},q={p:({node:N,...h})=>t.jsxRuntimeExports.jsx("p",{style:U,...h}),code:({node:N,...h})=>t.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...h}),pre:({node:N,...h})=>t.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:$,children:[t.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:h.children}),t.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:Q,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.ClipboardCopyIcon,{})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:J=>{const te=Q(J);te&&(n(!1),p(te),d(!0))},size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.PlayIcon,{})})]})]}),li:({node:N,...h})=>t.jsxRuntimeExports.jsx("li",{style:P,...h})};function Q(N){const h=N.currentTarget.closest("pre");if(!h)return;const J=h.textContent||h.innerText;return navigator.clipboard.writeText(J).then(()=>console.log("Text copied to clipboard")).catch(te=>console.error("Error in copying text: ",te)),J}function re(){return E==null?void 0:E.map((N,h)=>N.role==="user"?t.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[t.jsxRuntimeExports.jsx(Ti,{className:"mr-2 h-5 w-5"}),t.jsxRuntimeExports.jsx("div",{children:N.content})]},h):N.role==="ai"?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(mu,{className:"w-full overflow-auto py-1",components:q,children:b==null?void 0:b.response},h)}):t.jsxRuntimeExports.jsx("div",{},h))}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Assistant"}),t.jsxRuntimeExports.jsx(t.DialogDescription,{children:"What can I help you with?"})]}),t.jsxRuntimeExports.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:t.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:re()})}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[t.jsxRuntimeExports.jsx(t.Textarea,{autoFocus:!0,ref:l,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),i(""),v())},placeholder:"Type your question here...",onFocus:N=>{const h=N.target,J=h.value.length;h.setSelectionRange(J,J)},className:t.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:M||T,value:r,onChange:N=>i(N.target.value)})," ",t.jsxRuntimeExports.jsx(t.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:v,children:!M&&!T?t.jsxRuntimeExports.jsx(t.PaperPlaneIcon,{}):t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Jr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},er=A.createContext&&A.createContext(Jr),ju=["attr","size","title"];function yu(e,n){if(e==null)return{};var r=Eu(e,n),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(n.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Eu(e,n){if(e==null)return{};var r={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(n.indexOf(s)>=0)&&(r[s]=e[s]);return r}function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ut.apply(this,arguments)}function tr(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function ct(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?tr(Object(r),!0).forEach(function(i){bu(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tr(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function bu(e,n,r){return n=ku(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function ku(e){var n=Su(e,"string");return typeof n=="symbol"?n:String(n)}function Su(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Xr(e){return e&&e.map((n,r)=>A.createElement(n.tag,ct({key:r},n.attr),Xr(n.child)))}function ze(e){return n=>A.createElement(Ru,ut({attr:ct({},e.attr)},n),Xr(e.child))}function Ru(e){var n=r=>{var{attr:i,size:s,title:o}=e,l=yu(e,ju),a=s||r.size||"1em",u;return r.className&&(u=r.className),e.className&&(u=(u?u+" ":"")+e.className),A.createElement("svg",ut({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,l,{className:u,style:ct(ct({color:e.color||r.color},r.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&A.createElement("title",null,o),e.children)};return er!==void 0?A.createElement(er.Consumer,null,r=>n(r)):n(Jr)}function Cu(e){return ze({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(e)}function wu(){const{theme:e}=t.useTheme(),n=A.useRef(),r=A.useRef(),[i,s]=A.useState(!1),[o,l]=A.useState(!1),[a,u]=A.useState(!1),[c,x]=A.useState(""),[p,m]=A.useState(!1),{authToken:d}=t.useSemaphorContext();t.useDashboardStore(g=>g.selectedSheetId);const j=t.useDashboardStore(g=>g.dashboard.baseQueries),E=t.useEditorStore(g=>g.card),k=t.useDashboardStore(g=>g.theme),y=t.useEditorStore(g=>g.isShowingVisual),w=t.useEditorStore(g=>g.selectedConnectionId),S=t.useEditorStore(g=>g.selectedDatabaseName),D=t.useEditorStore(g=>g.selectedSchemaName);t.useDashboardStore(g=>g.actions.updateFrameCard);const O=t.useEditorStore(g=>g.selectedTableName),b=t.useEditorStore(g=>g.card.sql),M=t.useEditorStore(g=>g.card.python),T=t.resolveBaseQuery(b,j),z=t.useEditorStore(g=>g.selectedConnectionId),H=t.useEditorStore(g=>g.frame),I=t.useEditorStore(g=>g.filterValues),v=t.useEditorStore(g=>g.applyFilters),{setCardCustomCfg:U,setQueryResultColumns:$,setFilterValues:P,setCardSql:q,setCardPython:Q,setQueryError:re,setPythonStdOut:N}=t.useEditorStore(g=>g.actions),h=t.useEditorStore(g=>g.onSave),J=t.useEditorStore(g=>g.actions.setApplyFilters),te=t.useEditorStore(g=>g.onClose),f=t.useEditorStore(g=>g.actions.setCardData),ae=t.useEditorStore(g=>g.actions.setSqlGen),ge=t.useEditorStore(g=>g.runSql),X=t.useEditorStore(g=>g.actions.setRunSql),ke=t.useEditorStore(g=>g.actions.setIsSqlRunning),{data:ne,isLoading:he,isFetching:xe,isSuccess:Le,isError:Oe,error:He,status:mt,refetch:Ie}=t.useQuery({queryKey:[T,M],queryFn:()=>t.postRequest("https://semaphor.cloud/api/v1/query",(d==null?void 0:d.accessToken)||"",{connection_id:z,sql:T,python:M===t.PYTHON_DEFAULT_CODE?"":M,active_filters:v?I:[]}),enabled:!1,retry:!1});A.useEffect(()=>{if(ne&&(f(ne.records),N((ne==null?void 0:ne.output)||""),ne.records.length>0)){const{dimensionKeys:g}=t.getKeys(ne.records);$(g)}},[ne,f,$,N]),A.useEffect(()=>{ge&&(Ie(),X(!1))},[ge,Ie,X]),A.useEffect(()=>{(he||xe)&&ke(!0),(Oe||Le)&&ke(!1),Oe?(re(He.message),f([]),$([]),N("")):re("")},[he,xe,ne,N,Oe,Le,ke,f,$,re,He]);function Je(){q(""),f([]),ae({}),U("")}const Xe=g=>{r.current=g};function Ye(){let g=b;b&&!b.includes("{{")&&(g=Pi(b),q(g));const C={...E,lastSelectedSchema:D,lastSelectedDatabase:S,lastSelectedTable:O,connectionId:w,type:y?E.type:"table",sql:g,customCfg:y?E.customCfg:null},L=H.cards.map(B=>B.id===E.id?C:B);h==null||h({...H,cards:L})}function Ze(){te==null||te()}function ht(g){const C=getComputedStyle(document.documentElement).getPropertyValue(g);return ft(C)}function ft(g){const[C,L,B]=g.split(" "),_=parseFloat(C),ue=parseFloat(L),Se=parseFloat(B),fe=ue/100,we=Se/100,se=(1-Math.abs(2*we-1))*fe,Y=se*(1-Math.abs(_/60%2-1)),je=we-se/2;let ee=0,Re=0,Ce=0;0<=_&&_<60?(ee=se,Re=Y,Ce=0):60<=_&&_<120?(ee=Y,Re=se,Ce=0):120<=_&&_<180?(ee=0,Re=se,Ce=Y):180<=_&&_<240?(ee=0,Re=Y,Ce=se):240<=_&&_<300?(ee=Y,Re=0,Ce=se):300<=_&&_<360&&(ee=se,Re=0,Ce=Y),ee=Math.round((ee+je)*255),Re=Math.round((Re+je)*255),Ce=Math.round((Ce+je)*255);const yt=li=>{const Et=li.toString(16);return Et.length==1?"0"+Et:Et};return`#${yt(ee)}${yt(Re)}${yt(Ce)}`}A.useEffect(()=>{const g=n.current,C=r.current;if(g){const L=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",B=k==="system"?L:k;g.editor.defineTheme("default",{base:B==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":B==="light"?"#ffffff":ht("--background")}}),g.editor.setTheme("default")}return C&&g&&C.addCommand(g.KeyMod.Shift|g.KeyCode.Enter,function(){return console.log("Executing query..."),Ie(),!1}),()=>{}},[e,k,n.current]);function et(g){n.current=g}function gt(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[o&&t.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:t.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[t.jsxRuntimeExports.jsx(_i,{checked:v,onCheckedChange:()=>J(!v),text:"Apply Filters"}),t.jsxRuntimeExports.jsx(Vi,{}),I&&o&&t.jsxRuntimeExports.jsx(t.Cross2Icon,{onClick:()=>l(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",onChange:g=>{if(g)try{JSON.parse(g),P(JSON.parse(g))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(I,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),I&&!o&&t.jsxRuntimeExports.jsx(ir,{onClick:()=>l(!0),className:t.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":v})})]})}function jt(){return t.jsxRuntimeExports.jsxs(Lt,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[t.jsxRuntimeExports.jsxs(Fe,{id:"1",order:1,defaultSize:i?20:100,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:t.jsxRuntimeExports.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:g=>{q(g)},value:b,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:et,onMount:Xe})}),i&&t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),i&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border"}),t.jsxRuntimeExports.jsxs(Fe,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[t.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:t.jsxRuntimeExports.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:g=>{Q(g&&g.trim()||"")},value:M||t.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:et,onMount:Xe})}),t.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return t.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[t.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[jt(),gt()]}),t.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{disabled:he||xe,onClick:()=>{Ie()},className:"shrink-0",size:"sm",variant:"outline",children:[he||xe?t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):t.jsxRuntimeExports.jsx(Si,{className:"mr-2 h-4 w-4"}),"Run"]}),Oe&&t.jsxRuntimeExports.jsx(Bi,{error:He.message,setShowAIDialog:u,setTriggerAIRun:m,setUserInputforAI:x}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Je,className:"",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(xi,{className:"mr-2 size-4"}),"Clear"]}),t.jsxRuntimeExports.jsx(t.Toggle,{pressed:i,onPressedChange:g=>s(g),className:"",size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Cu,{className:"size-4 text-foreground/70"})}),t.jsxRuntimeExports.jsx(gu,{open:a,setOpen:u,userInput:c,triggerAIRun:p,setTriggerAIRun:m,setUserInput:g=>x(g)})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ye,size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),t.jsxRuntimeExports.jsxs(t.Button,{onClick:Ze,className:"w-full",size:"sm",variant:"outline",children:[t.jsxRuntimeExports.jsx(t.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function vu({data:e}){var l;const[n,r]=A.useState([]),s=Object.keys(e[0]).map(a=>({accessorKey:a,header:({column:u})=>{const c=u.getIsSorted();return t.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>u.toggleSorting(u.getIsSorted()==="asc"),children:[a,c==="asc"?t.jsxRuntimeExports.jsx(t.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):c==="desc"?t.jsxRuntimeExports.jsx(t.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),o=t.useReactTable({data:e,columns:s,getCoreRowModel:t.getCoreRowModel(),getPaginationRowModel:t.getPaginationRowModel(),onSortingChange:r,getSortedRowModel:t.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return t.jsxRuntimeExports.jsxs(t.Table,{children:[t.jsxRuntimeExports.jsx(t.TableHeader,{children:o.getHeaderGroups().map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{children:a.headers.map(u=>t.jsxRuntimeExports.jsx(t.TableHead,{className:"sticky top-0 bg-muted",children:u.isPlaceholder?null:t.flexRender(u.column.columnDef.header,u.getContext())},u.id))},a.id))}),t.jsxRuntimeExports.jsx(t.TableBody,{children:(l=o.getRowModel().rows)!=null&&l.length?o.getRowModel().rows.map(a=>t.jsxRuntimeExports.jsx(t.TableRow,{className:"whitespace-nowrap py-2","data-state":a.getIsSelected()&&"selected",children:a.getVisibleCells().map(u=>t.jsxRuntimeExports.jsx(t.TableCell,{children:t.flexRender(u.column.columnDef.cell,u.getContext())},u.id))},a.id)):t.jsxRuntimeExports.jsx(t.TableRow,{children:t.jsxRuntimeExports.jsx(t.TableCell,{colSpan:s.length,className:"h-24 text-center",children:"No results."})})})]})}function Yr({className:e,...n}){A.useState(0);const r=t.useDashboardStore(l=>l.themeStyle),i=t.useEditorStore(l=>l.card),s=t.useEditorStore(l=>l.actions.setCard);if(A.useEffect(()=>{},[i.data,i.type,i.cfg,i.customCfg,r,i.preferences]),!i.id)return null;let o;return i.data&&i.data.length>0&&(o=t.createChartConfig({data:i.data,cardType:i.type,cfg:i.cfg,customCfg:i.customCfg,preferences:i.preferences})),t.jsxRuntimeExports.jsxs(t.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none",e),...n,children:[t.jsxRuntimeExports.jsxs(t.CardHeader,{className:"py-4",children:[t.jsxRuntimeExports.jsx(t.Editable,{text:i.title,onSave:l=>s({...i,title:l}),children:t.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:t.jsxRuntimeExports.jsx(t.CardTitle,{className:"text-base",children:i.title})})},i.title),t.jsxRuntimeExports.jsx(t.Editable,{text:i.description||"",onSave:l=>s({...i,description:l}),children:t.jsxRuntimeExports.jsxs(t.CardDescription,{children:[" ",i.description]})},i.description)]}),t.jsxRuntimeExports.jsxs(t.CardContent,{className:"flex grow flex-col pb-3",children:[i.type!=="table"&&o&&t.jsxRuntimeExports.jsx(t.ChartJsVisual,{cfg:o},JSON.stringify(o)),i.type==="table"&&i.data&&i.data.length>0&&t.jsxRuntimeExports.jsx(t.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:t.jsxRuntimeExports.jsx(t.TableVisual,{card:i,data:i==null?void 0:i.data})})]})]})}function Nu(){const[e,n]=A.useState(!1),[r,i]=A.useState(""),[s,o]=A.useState(""),[l,a]=A.useState(""),u=t.useEditorStore(k=>k.card),c=t.useEditorStore(k=>k.card.customCfg),x=t.useEditorStore(k=>k.actions.setCardCustomCfg);function p(k){var S,D;const y={...k,data:{...k==null?void 0:k.data,datasets:(D=(S=k==null?void 0:k.data)==null?void 0:S.datasets)==null?void 0:D.map(O=>({...O,data:[]}))}};return JSON.stringify(y,null,1)}function m(){if(!u.data||u.data.length===0)return;const k=t.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});k&&(i(JSON.stringify(k,null,1)),c&&o(JSON.stringify(c,null,1)))}function d(){if(s)try{const k=JSON.parse(s);return k?(x(k),a(""),o(""),k):void 0}catch(k){console.log(k),a("Invalid JSON")}}function j(){o(""),x(null)}function E(){let k;if(c){const y=t._.cloneDeep(u.cfg),w=t._.merge(y,c);return k=p(w),k}return r?(k=p(JSON.parse(r)),k):""}return t.jsxRuntimeExports.jsxs(t.Dialog,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.DialogTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{onClick:m,className:` ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(t.Settings,{className:"h-4 w-4"})})}),t.jsxRuntimeExports.jsxs(t.DialogContent,{className:"max-h-[70vh] min-h-[70vh] min-w-[900px] overflow-auto",children:[t.jsxRuntimeExports.jsxs(t.DialogHeader,{className:"",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.DialogTitle,{children:"Customize Card"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(gi,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{side:"right",align:"center",children:t.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogDescription,{children:["See the configuration options and documentation",t.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[t.jsxRuntimeExports.jsx(Yr,{className:"w-1/2 rounded shadow-none"}),t.jsxRuntimeExports.jsxs(t.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[t.jsxRuntimeExports.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[t.jsxRuntimeExports.jsxs(t.TabsTrigger,{value:"custom-config",children:[c&&t.jsxRuntimeExports.jsx(t.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),c?"Custom Config":"Default Config"]}),t.jsxRuntimeExports.jsx(t.TabsTrigger,{className:"",value:"output",children:"Output"})]}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:t.jsxRuntimeExports.jsx(t.Textarea,{disabled:!0,value:r,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),t.jsxRuntimeExports.jsx(t.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:t.jsxRuntimeExports.jsx(t.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:E(),onChange:k=>o(k)})})]})]}),t.jsxRuntimeExports.jsxs(t.DialogFooter,{className:"flex items-center",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"mr-2 text-red-500",children:l}),t.jsxRuntimeExports.jsx(t.Button,{disabled:!c,onClick:j,variant:"outline",children:"Reset"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:d,variant:"outline",children:"Apply"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Zr(e){return ze({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(e)}function ei(e){return ze({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(e)}function ti(e){return ze({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(e)}function ni(e){return ze({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(e)}function ri(e){return ze({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(e)}function ii(e){return ze({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(e)}function Iu(){const[e,n]=A.useState(!1),r=t.useEditorStore(l=>l.card.type),i=t.useEditorStore(l=>l.actions.setCardType),s=t.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){i(l),s(null),n(!1)}return t.jsxRuntimeExports.jsxs(t.Popover,{open:e,onOpenChange:n,children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(Au,{className:"h-4 w-4",chartType:r})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-50",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:t.jsxRuntimeExports.jsx(Ut,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("line"),variant:"ghost",children:t.jsxRuntimeExports.jsx($t,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ri,{className:"size-5 ",strokeWidth:0})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("scatter"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ar,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("bubble"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ni,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("pie"),variant:"ghost",children:t.jsxRuntimeExports.jsx(or,{className:"size-5"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ei,{className:"size-5 ",strokeWidth:1})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("radar"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Zr,{className:"size-5 font-extralight",strokeWidth:.5})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ti,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("table"),variant:"ghost",children:t.jsxRuntimeExports.jsx(Kt,{className:"size-5 "})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>o("kpi"),variant:"ghost",children:t.jsxRuntimeExports.jsx(ii,{className:"size-6 "})})]})})]})}function Au({chartType:e,className:n}){switch(e){case"bar":return t.jsxRuntimeExports.jsx(Ut,{className:n});case"line":return t.jsxRuntimeExports.jsx($t,{className:n});case"pie":return t.jsxRuntimeExports.jsx(or,{className:n});case"radar":return t.jsxRuntimeExports.jsx(Zr,{className:n});case"scatter":return t.jsxRuntimeExports.jsx(ar,{className:n});case"bubble":return t.jsxRuntimeExports.jsx(ni,{className:n});case"doughnut":return t.jsxRuntimeExports.jsx(ei,{className:n});case"stackedBar":return t.jsxRuntimeExports.jsx(ri,{className:"size-4 text-foreground/70 "});case"polarArea":return t.jsxRuntimeExports.jsx(ti,{className:n});case"kpi":return t.jsxRuntimeExports.jsx(ii,{className:n});default:return t.jsxRuntimeExports.jsx(Kt,{className:n})}}function Tu(){const e=t.useEditorStore(r=>r.card.refreshInterval),n=t.useEditorStore(r=>r.actions.setCardRefreshInterval);return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.Button,{size:"sm",variant:"outline",children:t.jsxRuntimeExports.jsx(ai,{className:"w-4 h-4"})})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{className:"w-[200px]",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:t.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),t.jsxRuntimeExports.jsx(t.Input,{value:e||"",onChange:r=>n(r.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function nr(){t.useEditorStore(l=>l.frame);const e=t.useEditorStore(l=>l.card),n=t.useEditorStore(l=>l.card.data),r=t.useEditorStore(l=>l.isShowingVisual),i=t.useEditorStore(l=>l.isSqlRunning),s=t.useEditorStore(l=>l.queryError),o=t.useEditorStore(l=>l.pythonStdOut);return t.useEditorStore(l=>l.onSave),t.useEditorStore(l=>l.onClose),t.useEditorStore(l=>l.actions.setCardSql),t.useEditorStore(l=>l.actions.setCardType),t.useEditorStore(l=>l.actions.setSqlGen),e?t.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[i&&t.jsxRuntimeExports.jsx(t.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),t.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&t.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[t.jsxRuntimeExports.jsx(Iu,{}),t.jsxRuntimeExports.jsx(Nu,{}),t.jsxRuntimeExports.jsx(Tu,{})]}),t.jsxRuntimeExports.jsx(Lu,{})]}),r?e.type==="kpi"?t.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:t.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:t.jsxRuntimeExports.jsx(t.KPICard,{isLoading:i,card:e})})}):t.jsxRuntimeExports.jsx(Yr,{className:"grow border-none shadow-none"}):t.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[o&&t.jsxRuntimeExports.jsx(zu,{}),e.data&&e.data.length>0&&t.jsxRuntimeExports.jsx(vu,{data:n||[]}),s&&t.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:s})]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:"No Active Card"})}function zu(){const e=t.useEditorStore(r=>r.pythonStdOut);if(!e)return null;const n=e.replace(/\n/g,"<br>");return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),t.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),t.jsxRuntimeExports.jsx(t.Separator,{className:"mb-2"})]})}function Lu(){const e=t.useEditorStore(r=>r.isShowingVisual),n=t.useEditorStore(r=>r.actions.setIsShowingVisual);return t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),t.jsxRuntimeExports.jsx(t.Switch,{checked:e,onCheckedChange:()=>n(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Ve(){const[e,n]=A.useState([]);t.useEditorStore(x=>x.card.cfg);const r=t.useEditorStore(x=>x.card.preferences),{setCardCfg:i,setFilterOnClickColumnIndex:s,setCardPreferences:o}=t.useEditorStore(x=>x.actions),l=t.useEditorStore(x=>x.queryResultColumns);t.useEditorStore(x=>{var p;return(p=x.card.preferences)==null?void 0:p.filterOnClickColumnIndex}),A.useEffect(()=>{l&&n(new Array(l.length).fill(!1))},[l]);function a(x,p){var m,d;p?r!=null&&r.onClickFilter&&((m=r==null?void 0:r.onClickFilter)==null?void 0:m.length)>0?o({...r,onClickFilter:[...r.onClickFilter,{columnIndex:x,expression:""}]}):o({...r,onClickFilter:[{columnIndex:x,expression:""}]}):(o({...r,onClickFilter:(d=r==null?void 0:r.onClickFilter)==null?void 0:d.filter(j=>j.columnIndex!==x)}),n(j=>{const E=[...j];return E[x]=!1,E}))}function u(x,p){var d;const m=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.map(j=>j.columnIndex===x?{...j,expression:p.target.value}:j);o({...r,onClickFilter:m})}function c(x){var p,m,d,j;if(e!=null&&e[x]||(m=(p=r==null?void 0:r.onClickFilter)==null?void 0:p.find(E=>E.columnIndex===x))!=null&&m.expression)return t.jsxRuntimeExports.jsx(t.Input,{value:(j=(d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(E=>E.columnIndex===x))==null?void 0:j.expression,onChange:E=>u(x,E),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:l==null?void 0:l.map((x,p)=>{var m,d;return t.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:t.jsxRuntimeExports.jsxs("div",{className:" grow",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((m=r==null?void 0:r.onClickFilter)!=null&&m.find(j=>j.columnIndex===p)),onCheckedChange:j=>a(p,j)}),t.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),t.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((d=r==null?void 0:r.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===p))&&t.jsxRuntimeExports.jsx(sr,{onClick:()=>{n(j=>{const E=[...j];return E[p]=!j[p],E})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(p)]})},x)})})}function an(){var o,l;const e=t.useEditorStore(a=>a.card.preferences),n=t.useEditorStore(a=>a.card.cfg),{setCardCfg:r,setCardPreferences:i}=t.useEditorStore(a=>a.actions);(o=n==null?void 0:n.options)!=null&&o.indexAxis;function s(a){var x,p,m,d,j,E;let u={};(x=e==null?void 0:e.chartOptions)!=null&&x.scales&&(u={x:(m=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:m.y,y:(j=(d=e==null?void 0:e.chartOptions)==null?void 0:d.scales)==null?void 0:j.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(E=e==null?void 0:e.chartOptions)==null?void 0:E.scales,...u},indexAxis:a}};i(c)}return t.jsxRuntimeExports.jsxs(t.RadioGroup,{value:((l=e==null?void 0:e.chartOptions)==null?void 0:l.indexAxis)||"x",onValueChange:s,className:"flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"x",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"y",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const zt="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function si(e){var r,i;return(r=e==null?void 0:e.chartOptions)!=null&&r.indexAxis?((i=e==null?void 0:e.chartOptions)==null?void 0:i.indexAxis)==="x"?"y":"x":"y"}function rr(e){var r,i,s;const n=si(e);return((s=(i=(r=e==null?void 0:e.chartOptions)==null?void 0:r.scales)==null?void 0:i[n])==null?void 0:s.type)||"linear"}function Ou(){var w,S,D,O,b,M;const[e,n]=A.useState(!1),r=t.useEditorStore(T=>{var z;return(z=T.card)==null?void 0:z.preferences}),i=si(r),[s,o]=A.useState(rr(r)),[l,a]=A.useState(((D=(S=(w=r==null?void 0:r.chartOptions)==null?void 0:w.scales)==null?void 0:S[i])==null?void 0:D.min)||""),[u,c]=A.useState(((M=(b=(O=r==null?void 0:r.chartOptions)==null?void 0:O.scales)==null?void 0:b[i])==null?void 0:M.max)||""),[x,p]=A.useState(l||u?"custom":"auto"),[m,d]=A.useState(""),j=t.useEditorStore(T=>T.actions.setCardPreferences);A.useEffect(()=>{var T,z,H,I,v,U,$,P,q,Q;o(rr(r)),a(((H=(z=(T=r==null?void 0:r.chartOptions)==null?void 0:T.scales)==null?void 0:z[i])==null?void 0:H.min)===0?0:""),c(((U=(v=(I=r==null?void 0:r.chartOptions)==null?void 0:I.scales)==null?void 0:v[i])==null?void 0:U.max)||""),d(((Q=(q=(P=($=r==null?void 0:r.chartOptions)==null?void 0:$.scales)==null?void 0:P[i])==null?void 0:q.ticks)==null?void 0:Q.stepSize)||"")},[e,r,i]);function E(T,z){return z===""||/^[0-9\b]+$/.test(z)?Number(z):Number(T)}function k(){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"range",children:"Range"}),t.jsxRuntimeExports.jsx(t.Input,{id:"min",value:l,onChange:T=>a(z=>E(z,T.target.value)),className:`col-span-1 h-8 w-full ${zt}`}),t.jsxRuntimeExports.jsx(t.Input,{value:u,onChange:T=>c(z=>E(z,T.target.value)),id:"max",className:`col-span-1 h-8 w-full ${zt}`})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"step-size",children:"Step Size"}),t.jsxRuntimeExports.jsx(t.Input,{value:m,onChange:T=>d(z=>E(z,T.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${zt}`})]})]})}function y(){var H;let T={};x==="custom"&&(T={min:l,max:u,ticks:{stepSize:m}});const z={...r||{},chartOptions:{...r==null?void 0:r.chartOptions,scales:{...(H=r==null?void 0:r.chartOptions)==null?void 0:H.scales,[i]:{type:s,...s==="linear"?T:{}}}}};j(z)}return t.jsxRuntimeExports.jsxs(t.Popover,{onOpenChange:T=>n(T),children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{asChild:!0,children:t.jsxRuntimeExports.jsx(t.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),t.jsxRuntimeExports.jsx(t.PopoverContent,{align:"center",className:"max-w-65",children:t.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),t.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),t.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale",children:"Type"}),t.jsxRuntimeExports.jsxs(t.Select,{value:s,onValueChange:T=>o(T),children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{})}),t.jsxRuntimeExports.jsx(t.SelectContent,{id:"type",children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Option"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"linear",children:"Linear"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),s=="linear"&&t.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[t.jsxRuntimeExports.jsx(t.Label,{htmlFor:"scale-option",children:"Setup"}),t.jsxRuntimeExports.jsxs(t.RadioGroup,{id:"scale-option",value:x,onValueChange:T=>p(T),className:"col-span-2 flex gap-3",defaultValue:"x",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"auto",id:"r1"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxRuntimeExports.jsx(t.RadioGroupItem,{value:"custom",id:"r2"}),t.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),x==="custom"&&s=="linear"&&k(),t.jsxRuntimeExports.jsx(t.SelectSeparator,{}),t.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:t.jsxRuntimeExports.jsx(t.Button,{onClick:y,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Du({idx:e}){var a;const n=t.useEditorStore(u=>{var c;return(c=u.card)==null?void 0:c.preferences}),r=t.useEditorStore(u=>{var c;return(c=u.card.preferences)==null?void 0:c.datasetOptions}),i=t.useEditorStore(u=>u.actions.setCardPreferences),s=(a=n==null?void 0:n.chartOptions)==null?void 0:a.indexAxis,o=r==null?void 0:r.find(u=>u.idx===e);function l(u,c){(u==="end"||u==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const x={display:u!=="none",align:u,anchor:u,clamp:!0};if(!o)i({...n,datasetOptions:[...r||[],{idx:c,datalabels:x}]});else{const p={...o};p.datalabels=x;const m=r==null?void 0:r.map(d=>d.idx===c?p:d);i({...n,datasetOptions:m})}}return t.jsxRuntimeExports.jsxs(t.Popover,{children:[t.jsxRuntimeExports.jsx(t.PopoverTrigger,{children:t.jsxRuntimeExports.jsx(Ni,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),t.jsxRuntimeExports.jsxs(t.PopoverContent,{className:"flex w-fit gap-1 p-1",children:[t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("none",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(t.X,{className:"size-4"})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("start",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(ji,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("center",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(Ei,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>l("end",e),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:t.jsxRuntimeExports.jsx(yi,{className:t.cn("h-4 w-4",{"rotate-90":s==="y"})})})]})]})}function oi(){const e=t.useEditorStore(u=>u.card),n=t.useEditorStore(u=>{var c,x,p;return(p=(x=(c=u==null?void 0:u.card)==null?void 0:c.preferences)==null?void 0:x.chartOptions)==null?void 0:p.indexAxis}),r=n==="y"?"Y axis":"X axis",i=n==="y"?"X axis":"Y axis",{keys:s,metricKeys:o,dimensionKeys:l}=t.getKeys(e.data||[]);let a=o;if(e.type==="stackedBar"){const u=t.pivotData({dataArray:e.data||[],groupKey:l[0],pivotKey:l[1],valueKey:a[0]}),{metricKeys:c}=t.getKeys(u);a=c}return s.length===0?null:t.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx(t.Label,{children:r}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:t.jsxRuntimeExports.jsx("p",{children:l[0]})})})]}),t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[t.jsxRuntimeExports.jsx(t.Label,{children:i}),t.jsxRuntimeExports.jsx(Ou,{})]}),t.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:a.map((u,c)=>t.jsxRuntimeExports.jsx(Fu,{col:u,idx:c},u))})]})]})}function Fu({col:e,idx:n}){const r=t.useEditorStore(a=>{var u;return(u=a.card)==null?void 0:u.preferences}),i=t.useEditorStore(a=>{var u;return(u=a.card.preferences)==null?void 0:u.datasetOptions}),s=i==null?void 0:i.find(a=>a.idx===n),{setCardPreferences:o}=t.useEditorStore(a=>a.actions);function l(a){if(!s)o({...r,datasetOptions:[...i||[],{idx:n,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const u={...s};u.type=a==="area"?"line":a,u.fill=a==="area"?"origin":"";const c=i==null?void 0:i.map(x=>x.idx===n?u:x);o({...r,datasetOptions:c})}}return t.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[t.jsxRuntimeExports.jsx("p",{children:e}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t.jsxRuntimeExports.jsx(Ut,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx($t,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(ui,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(t.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),t.jsxRuntimeExports.jsx(Du,{idx:n})]})]})}function Mu({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function un(){var i,s,o;const e=t.useEditorStore(l=>l.card.cfg),n=t.useEditorStore(l=>l.actions.setCardCfg);function r(l){var c;const a={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},u={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};n(u),console.log(l)}return t.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[t.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),t.jsxRuntimeExports.jsxs(t.Select,{value:(o=(s=(i=e==null?void 0:e.options)==null?void 0:i.plugins)==null?void 0:s.datalabels)==null?void 0:o.anchor,onValueChange:r,defaultValue:"none",children:[t.jsxRuntimeExports.jsx(t.SelectTrigger,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:t.jsxRuntimeExports.jsx(t.SelectValue,{placeholder:"Select position"})}),t.jsxRuntimeExports.jsx(t.SelectContent,{children:t.jsxRuntimeExports.jsxs(t.SelectGroup,{children:[t.jsxRuntimeExports.jsx(t.SelectLabel,{children:"Data Labels"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"none",children:"None"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"start",children:"Start"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"center",children:"Center"}),t.jsxRuntimeExports.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Pu({cardType:e}){function n(r){const i="SELECT label, [group], x-axis, y-axis, radius FROM table",s="SELECT label, [group], x-axis, y-axis FROM table";return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:r==="bubble"?i:s}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"group - category"}),t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),r==="bubble"&&t.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(e)})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}const Bu={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},_u={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Vu(){const e=t.useEditorStore(n=>n.card.type);return t.jsxRuntimeExports.jsxs("div",{className:"p-6 space-y-6",children:[t.jsxRuntimeExports.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:Hu(e)}),t.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(e)&&t.jsxRuntimeExports.jsx(an,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(un,{})}),t.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(e)&&t.jsxRuntimeExports.jsx(Ve,{})})]})}function Hu(e){if(["line","bar"].includes(e))return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Mixed Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(Bu,null,2)})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:"Area Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" text-xs space-y-2",children:[t.jsxRuntimeExports.jsxs("p",{children:["Click ",t.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",t.jsxRuntimeExports.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),t.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(_u,null,2)})]})]})]});if(e==="bubble")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),t.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:["How to create a ",t.jsxRuntimeExports.jsx("span",{children:e})," chart query?"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),t.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),t.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:" font-normal",children:t.jsxRuntimeExports.jsxs("p",{children:[t.jsxRuntimeExports.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),t.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function qu(){var l,a,u;const e=t.useEditorStore(c=>c.card.preferences),n=t.useEditorStore(c=>c.actions.setCardPreferences),r=t.useEditorStore(c=>c.actions.setNumberFormat),i=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.format}),s=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(c=>{var x,p;return(p=(x=c.card.preferences)==null?void 0:x.formatNumber)==null?void 0:p.currency});return t.useEditorStore(c=>c.actions.setFilterOnClickField),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(t.Checkbox,{checked:!!((l=e==null?void 0:e.formatNumber)!=null&&l.enabled),onCheckedChange:c=>{n({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),t.jsxRuntimeExports.jsx(t.Label,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Currency"}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Input,{value:o||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",c.target.value,((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}}),t.jsxRuntimeExports.jsx(t.Input,{value:s||"",className:"h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",c.target.value,((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})]})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Format"}),t.jsxRuntimeExports.jsxs(t.Tooltip,{children:[t.jsxRuntimeExports.jsx(t.TooltipTrigger,{children:t.jsxRuntimeExports.jsx(t.InfoCircledIcon,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),t.jsxRuntimeExports.jsx(t.TooltipContent,{children:t.jsxRuntimeExports.jsxs("div",{className:"max-w-[200px]",children:["Format number",t.jsxRuntimeExports.jsx("div",{className:"mt-1 font-mono text-xs",children:"#.## for 123.43"})]})})]})]}),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsx(t.Input,{value:i||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var x,p,m;return r(c.target.value,((x=e==null?void 0:e.formatNumber)==null?void 0:x.currency)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.locale)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.suffix)||"")}})})]}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-xs",children:"Suffix"}),t.jsxRuntimeExports.jsx(t.Input,{value:((u=e==null?void 0:e.formatNumber)==null?void 0:u.suffix)||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var x,p,m;return r(((x=e==null?void 0:e.formatNumber)==null?void 0:x.format)||"",((p=e==null?void 0:e.formatNumber)==null?void 0:p.currency)||"",((m=e==null?void 0:e.formatNumber)==null?void 0:m.locale)||"",c.target.value)}})]})]})]})}function Uu(){return t.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[t.jsxRuntimeExports.jsx(t.Accordion,{type:"single",collapsible:!0,children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"font-mono",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"current - number"}),t.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),t.jsxRuntimeExports.jsx("section",{className:"",children:t.jsxRuntimeExports.jsx(qu,{})}),t.jsxRuntimeExports.jsx("div",{}),t.jsxRuntimeExports.jsx("div",{})]})}function $u({cardType:e}){return t.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:`${t.titleCase(e)} Chart`}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:[t.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[t.jsxRuntimeExports.jsx("li",{children:"label - category"}),t.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(un,{})})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Ku(){return t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-1",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[t.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),t.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[t.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),t.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),t.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),t.jsxRuntimeExports.jsxs("div",{children:["See ",t.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-2",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Settings"}),t.jsxRuntimeExports.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[t.jsxRuntimeExports.jsx(an,{}),t.jsxRuntimeExports.jsx(oi,{})]})]}),t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})]})})}function Wu({cardType:e}){return console.log("TableVisualSettings",e),t.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:t.jsxRuntimeExports.jsx(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:t.jsxRuntimeExports.jsxs(t.AccordionItem,{value:"item-3",children:[t.jsxRuntimeExports.jsx(t.AccordionTrigger,{children:"Filter on click"}),t.jsxRuntimeExports.jsx(t.AccordionContent,{className:"px-2",children:t.jsxRuntimeExports.jsx(Ve,{})})]})})})}function Gu(){const e=t.useEditorStore(r=>r.card.type);function n(r){switch(r){case"stackedBar":return t.jsxRuntimeExports.jsx(Ku,{});case"kpi":return t.jsxRuntimeExports.jsx(Uu,{});case"line":case"bar":return t.jsxRuntimeExports.jsx(Mu,{cardType:r});case"pie":case"doughnut":case"polarArea":case"radar":return t.jsxRuntimeExports.jsx($u,{cardType:r});case"bubble":case"scatter":return t.jsxRuntimeExports.jsx(Pu,{cardType:r});case"table":return t.jsxRuntimeExports.jsx(Wu,{cardType:r});default:return t.jsxRuntimeExports.jsx(Vu,{})}}return t.jsxRuntimeExports.jsx(t.ScrollArea,{className:"h-full w-full text-sm",children:n(e)})}function Qu(){const e=t.useEditorStore(n=>n.isShowingVisual);return t.jsxRuntimeExports.jsxs(Lt,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[t.jsxRuntimeExports.jsx(Fe,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:t.jsxRuntimeExports.jsx(wu,{})}),t.jsxRuntimeExports.jsx(Ot,{withHandle:!0,className:"border "}),t.jsxRuntimeExports.jsx(Fe,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?t.jsxRuntimeExports.jsxs(Lt,{direction:"horizontal",children:[t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(Fe,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:t.jsxRuntimeExports.jsx(Gu,{})})}),t.jsxRuntimeExports.jsx(Ot,{className:"border "}),t.jsxRuntimeExports.jsx(Fe,{minSize:40,defaultSize:75,maxSize:100,children:t.jsxRuntimeExports.jsx(nr,{})})]}):t.jsxRuntimeExports.jsx(nr,{})})]})}function Ju({authToken:e,onSave:n,onClose:r}){const i=t.useEditorStore(l=>l.actions.setOnSave),s=t.useEditorStore(l=>l.actions.setOnClose),o=t.useDashboardStore(l=>l.actions.setAuthToken);return A.useEffect(()=>{n&&i(n),r&&s(r)},[n,i,r,s]),A.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),t.jsxRuntimeExports.jsxs(t.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[t.jsxRuntimeExports.jsx(t.EditorAside,{className:"rounded-none border-r-[1.5px]",children:t.jsxRuntimeExports.jsx(cr,{})}),t.jsxRuntimeExports.jsx(t.EditorMain,{children:t.jsxRuntimeExports.jsx(Qu,{})})]})}function Xu(){t.useDashboardStore(l=>l.selectedCardId);const e=t.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardStore(l=>l.actions),r=t.useDashboardStore(l=>l.isVisualEditing),i=t.useDashboardStore(l=>l.actions.updateFrame);function s(l){e&&(i(e,l),n(!1))}function o(){n(!1)}return t.jsxRuntimeExports.jsx("div",{role:"editor-container",className:t.cn("flex grow",{block:r,hidden:!r}),children:t.jsxRuntimeExports.jsx(Ju,{onSave:s,onClose:o})})}function Yu({columns:e,tableName:n}){const r=t.useEditorStore(p=>p.selectedConnectionId),i=t.useEditorStore(p=>p.selectedDatabaseName),s=t.useEditorStore(p=>p.selectedSchemaName),o=t.useEditorStore(p=>p.selectedTableName),l=t.useDashboardStore(p=>p.dashboard.filters)||[],a=t.useDashboardStore(p=>p.actions.addFilter),u=t.useDashboardStore(p=>p.actions.removeFilter),c=t.useDashboardStore(p=>p.actions.removeFilterValue);function x(p){const m=t.fmt(p.column_name),d=t.fmt(i||""),j=t.fmt(s||""),E=t.fmt(n),k=t.getQualifiedTableName(j,E),y=`${k}.${m}`;console.log("find",y,E,d);const w=l==null?void 0:l.find(S=>S.column===y&&S.table===E&&(S.database===d||S.database===i));if(w)c(w.id),u(w.id);else{if(n==="api"&&r){a({id:t.v4(),column:y,title:p.column_name,dataType:p.data_type,table:"api",database:"NA",connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)});return}if(!r||!i||!o)throw new Error("missing connectionId, database, or table");a({id:t.v4(),column:`${k}.${m}`,title:p.column_name,dataType:p.data_type,table:o,database:i,connectionId:r,operation:"in",sql:t.getDefaultFilterSql(p.data_type,k,m)})}}return t.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:e==null?void 0:e.map(p=>{const m=l==null?void 0:l.find(d=>d.column===t.fmt(p.column_name)&&d.table===o&&d.database===i);return t.jsxRuntimeExports.jsx("div",{onClick:()=>x(p),className:t.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxRuntimeExports.jsx(ur,{column:p}),t.jsxRuntimeExports.jsx("span",{children:p.column_name})]})},p.column_name)})})}function Zu(){t.useDashboardStore(n=>n.showFilters);const e=t.useDashboardStore(n=>n.actions.setShowFilters);return t.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[t.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[t.jsxRuntimeExports.jsx(t.Label,{className:"text-lg",children:"Filters"}),t.jsxRuntimeExports.jsx(t.Button,{onClick:()=>e(!1),className:"h-7 w-7 p-0",variant:"ghost",children:t.jsxRuntimeExports.jsx(t.Cross2Icon,{})})]}),t.jsxRuntimeExports.jsx("div",{className:"flex grow",children:t.jsxRuntimeExports.jsx(cr,{ColumnsComponent:(n,r,i)=>t.jsxRuntimeExports.jsx(Yu,{schemaName:n,tableName:r,columns:i})})})]})}function ec(){t.useDashboardStore(r=>r.dashboard);const e=t.useDashboardStore(r=>r.showFilters),n=t.useDashboardStore(r=>r.isVisualEditing);return t.useDashboardStore(r=>r.bookmarkKey),t.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:t.cn("grow",{hidden:n,flex:!n}),children:[t.jsxRuntimeExports.jsx(t.DashboardTabs,{}),e&&t.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:t.jsxRuntimeExports.jsx(Zu,{})})]})}function tc(){const e=t.useDashboardStore(i=>i.dashboard),n=t.useDashboardStore(i=>i.actions.setDashboard),r=t.useDashboardStore(i=>i.showDashboardJSON);return t.useDashboardStore(i=>i.actions.setShowDashboardJSON),t.jsxRuntimeExports.jsx("div",{className:t.cn(" p-2",{hidden:!r}),children:t.jsxRuntimeExports.jsx(t.de,{onChange:i=>{if(i)try{JSON.parse(i),n(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function nc({showControls:e=!1,showFooter:n=!0,...r}){return t.jsxRuntimeExports.jsx(t.SemaphorContextProvider,{dashboardProps:r,children:t.jsxRuntimeExports.jsxs(t.UXProvider,{children:[t.jsxRuntimeExports.jsx(tc,{}),t.jsxRuntimeExports.jsxs(t.DashboardPanel,{...r,children:[e&&t.jsxRuntimeExports.jsx(Di,{}),t.jsxRuntimeExports.jsx(Xu,{}),t.jsxRuntimeExports.jsx(ec,{})]})]})})}exports.DashboardPlus=nc;exports.SelectComponent=Ue;
|