wicked-studio 0.16.6 → 0.16.8
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/apps-standalone/fixture.js +3 -3
- package/dist/apps-standalone/runtime.css +38 -5
- package/dist/apps-standalone/runtime.js +1 -1
- package/dist/assets/{KnowledgeGraph-B2NelLEg.js → KnowledgeGraph-BgXDoH6k.js} +1 -1
- package/dist/assets/index-CrcZTJjG.css +32 -0
- package/dist/assets/{index-BeEB56KG.js → index-rMZ47jUD.js} +306 -305
- package/dist/editors/wicked-apps/editor.json +1 -1
- package/dist/editors/wicked-apps/index.html +40 -7
- package/dist/editors/wicked-deck/editor.json +1 -1
- package/dist/editors/wicked-deck/index.html +1 -1
- package/dist/editors/wicked-doc/editor.json +1 -1
- package/dist/editors/wicked-doc/index.html +1 -1
- package/dist/editors/wicked-insights/editor.json +1 -1
- package/dist/editors/wicked-insights/index.html +1 -1
- package/dist/editors/wicked-page/editor.json +1 -1
- package/dist/editors/wicked-page/index.html +1 -1
- package/dist/editors/wicked-video/editor.json +1 -1
- package/dist/editors/wicked-video/index.html +1 -1
- package/dist/index.html +2 -2
- package/dist/testid-inventory.json +113 -5
- package/package.json +2 -2
- package/dist/assets/index-CnfeJvlM.css +0 -32
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var De=Object.defineProperty;var Me=(H,F,z)=>F in H?De(H,F,{enumerable:!0,configurable:!0,writable:!0,value:z}):H[F]=z;var Q=(H,F,z)=>Me(H,typeof F!="symbol"?F+"":F,z);(function(){"use strict";const H=new Set(["security_review_on_non_code_plan","writes_nothing_on_code"]);function F(e){const t=e.split(": ");for(const r of t.slice(0,-1)){const s=r.trim();if(/^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(s))return s}return null}function z(e){return/\(rule (.+?) requires it\)/.exec(e)?.[1]??null}function Se(e){const t=F(e),r=t!==null&&H.has(t)?t:null;if(r==="security_review_on_non_code_plan"){const s=z(e);return`a security review was asked for on a run that writes no code${s!==null?` (rule ${s} requires it)`:""} — its code-evidence check could never pass`}return r==="writes_nothing_on_code"?"a step marked “writes nothing” is on a phase that changes code":null}const ie={gh_account_mismatch:"That account isn’t the one the GitHub CLI is signed in as: choose another, or check again. Nothing was saved.",gh_not_installed:"The GitHub CLI isn’t installed where crew runs. Nothing was saved.",gh_signed_out:"The GitHub CLI is signed out where crew runs. Nothing was saved.",gh_token_unavailable:"The GitHub CLI couldn’t supply a login for that account. Nothing was saved.",gh_cli_not_allowed:"This source can’t use the GitHub CLI login. Nothing was saved."};function ae(e,t,r){const s=t.trim();if(r!=null&&Object.hasOwn(ie,r)){const h=ie[r];return s===""?h:`${h} — ${s}`}if(s==="")return`the daemon refused this — it answered HTTP ${e} with no detail`;const l=Se(s);return l!==null?`the daemon refused this plan: ${l} — ${s}`:`the daemon refused this — ${s}`}class ee extends Error{constructor(r,s,l){const h=typeof l=="object"&&l!==null?l.code:void 0;super(ae(r,s,typeof h=="string"?h:null));Q(this,"status");Q(this,"wire");Q(this,"body");this.name="ApiError",this.status=r,this.wire=s,this.body=l}}function ce(e){return e instanceof ee?e.status:null}const ue=e=>{let t;const r=new Set,s=(f,g)=>{const d=typeof f=="function"?f(t):f;if(!Object.is(d,t)){const _=t;t=g??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(N=>N(t,_))}},l=()=>t,P={setState:s,getState:l,getInitialState:()=>y,subscribe:f=>(r.add(f),()=>r.delete(f))},y=t=e(s,l,P);return P},be=(e=>e?ue(e):ue);function $e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var te={exports:{}},m={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react.production.min.js
|
|
4
4
|
*
|
|
@@ -6,5 +6,5 @@ var Le=Object.defineProperty;var De=(V,F,z)=>F in V?Le(V,F,{enumerable:!0,config
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var ue;function $e(){if(ue)return m;ue=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),x=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),l=Symbol.iterator;function E(n){return n===null||typeof n!="object"?null:(n=l&&n[l]||n["@@iterator"],typeof n=="function"?n:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,J={};function q(n,i,b){this.props=n,this.context=i,this.refs=J,this.updater=b||A}q.prototype.isReactComponent={},q.prototype.setState=function(n,i){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,i,"setState")},q.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function N(){}N.prototype=q.prototype;function L(n,i,b){this.props=n,this.context=i,this.refs=J,this.updater=b||A}var $=L.prototype=new N;$.constructor=L,C($,q.prototype),$.isPureReactComponent=!0;var a=Array.isArray,c=Object.prototype.hasOwnProperty,u={current:null},d={key:!0,ref:!0,__self:!0,__source:!0};function k(n,i,b){var R,v={},T=null,j=null;if(i!=null)for(R in i.ref!==void 0&&(j=i.ref),i.key!==void 0&&(T=""+i.key),i)c.call(i,R)&&!d.hasOwnProperty(R)&&(v[R]=i[R]);var U=arguments.length-2;if(U===1)v.children=b;else if(1<U){for(var P=Array(U),M=0;M<U;M++)P[M]=arguments[M+2];v.children=P}if(n&&n.defaultProps)for(R in U=n.defaultProps,U)v[R]===void 0&&(v[R]=U[R]);return{$$typeof:e,type:n,key:T,ref:j,props:v,_owner:u.current}}function w(n,i){return{$$typeof:e,type:n.type,key:i,ref:n.ref,props:n.props,_owner:n._owner}}function O(n){return typeof n=="object"&&n!==null&&n.$$typeof===e}function S(n){var i={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(b){return i[b]})}var D=/\/+/g;function Z(n,i){return typeof n=="object"&&n!==null&&n.key!=null?S(""+n.key):i.toString(36)}function W(n,i,b,R,v){var T=typeof n;(T==="undefined"||T==="boolean")&&(n=null);var j=!1;if(n===null)j=!0;else switch(T){case"string":case"number":j=!0;break;case"object":switch(n.$$typeof){case e:case t:j=!0}}if(j)return j=n,v=v(j),n=R===""?"."+Z(j,0):R,a(v)?(b="",n!=null&&(b=n.replace(D,"$&/")+"/"),W(v,i,b,"",function(M){return M})):v!=null&&(O(v)&&(v=w(v,b+(!v.key||j&&j.key===v.key?"":(""+v.key).replace(D,"$&/")+"/")+n)),i.push(v)),1;if(j=0,R=R===""?".":R+":",a(n))for(var U=0;U<n.length;U++){T=n[U];var P=R+Z(T,U);j+=W(T,i,b,P,v)}else if(P=E(n),typeof P=="function")for(n=P.call(n),U=0;!(T=n.next()).done;)T=T.value,P=R+Z(T,U++),j+=W(T,i,b,P,v);else if(T==="object")throw i=String(n),Error("Objects are not valid as a React child (found: "+(i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.");return j}function G(n,i,b){if(n==null)return n;var R=[],v=0;return W(n,R,"","",function(T){return i.call(b,T,v++)}),R}function B(n){if(n._status===-1){var i=n._result;i=i(),i.then(function(b){(n._status===0||n._status===-1)&&(n._status=1,n._result=b)},function(b){(n._status===0||n._status===-1)&&(n._status=2,n._result=b)}),n._status===-1&&(n._status=0,n._result=i)}if(n._status===1)return n._result.default;throw n._result}var _={current:null},H={transition:null},Je={ReactCurrentDispatcher:_,ReactCurrentBatchConfig:H,ReactCurrentOwner:u};function ge(){throw Error("act(...) is not supported in production builds of React.")}return m.Children={map:G,forEach:function(n,i,b){G(n,function(){i.apply(this,arguments)},b)},count:function(n){var i=0;return G(n,function(){i++}),i},toArray:function(n){return G(n,function(i){return i})||[]},only:function(n){if(!O(n))throw Error("React.Children.only expected to receive a single React element child.");return n}},m.Component=q,m.Fragment=o,m.Profiler=p,m.PureComponent=L,m.StrictMode=s,m.Suspense=y,m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Je,m.act=ge,m.cloneElement=function(n,i,b){if(n==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+n+".");var R=C({},n.props),v=n.key,T=n.ref,j=n._owner;if(i!=null){if(i.ref!==void 0&&(T=i.ref,j=u.current),i.key!==void 0&&(v=""+i.key),n.type&&n.type.defaultProps)var U=n.type.defaultProps;for(P in i)c.call(i,P)&&!d.hasOwnProperty(P)&&(R[P]=i[P]===void 0&&U!==void 0?U[P]:i[P])}var P=arguments.length-2;if(P===1)R.children=b;else if(1<P){U=Array(P);for(var M=0;M<P;M++)U[M]=arguments[M+2];R.children=U}return{$$typeof:e,type:n.type,key:v,ref:T,props:R,_owner:j}},m.createContext=function(n){return n={$$typeof:x,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},n.Provider={$$typeof:g,_context:n},n.Consumer=n},m.createElement=k,m.createFactory=function(n){var i=k.bind(null,n);return i.type=n,i},m.createRef=function(){return{current:null}},m.forwardRef=function(n){return{$$typeof:I,render:n}},m.isValidElement=O,m.lazy=function(n){return{$$typeof:h,_payload:{_status:-1,_result:n},_init:B}},m.memo=function(n,i){return{$$typeof:f,type:n,compare:i===void 0?null:i}},m.startTransition=function(n){var i=H.transition;H.transition={};try{n()}finally{H.transition=i}},m.unstable_act=ge,m.useCallback=function(n,i){return _.current.useCallback(n,i)},m.useContext=function(n){return _.current.useContext(n)},m.useDebugValue=function(){},m.useDeferredValue=function(n){return _.current.useDeferredValue(n)},m.useEffect=function(n,i){return _.current.useEffect(n,i)},m.useId=function(){return _.current.useId()},m.useImperativeHandle=function(n,i,b){return _.current.useImperativeHandle(n,i,b)},m.useInsertionEffect=function(n,i){return _.current.useInsertionEffect(n,i)},m.useLayoutEffect=function(n,i){return _.current.useLayoutEffect(n,i)},m.useMemo=function(n,i){return _.current.useMemo(n,i)},m.useReducer=function(n,i,b){return _.current.useReducer(n,i,b)},m.useRef=function(n){return _.current.useRef(n)},m.useState=function(n){return _.current.useState(n)},m.useSyncExternalStore=function(n,i,b){return _.current.useSyncExternalStore(n,i,b)},m.useTransition=function(){return _.current.useTransition()},m.version="18.3.1",m}var le;function ve(){return le||(le=1,te.exports=$e()),te.exports}var Re=ve();const K=be(Re),Ce=e=>e;function Oe(e,t=Ce){const o=K.useSyncExternalStore(e.subscribe,K.useCallback(()=>t(e.getState()),[e,t]),K.useCallback(()=>t(e.getInitialState()),[e,t]));return K.useDebugValue(o),o}const de=e=>{const t=Se(e),o=s=>Oe(t,s);return Object.assign(o,t),o},Pe=(e=>e?de(e):de);let ne=null;const Ie=Pe((e,t)=>({loaded:!1,runChatId:!1,walkthroughRoots:!1,askPath:!1,chatIdOnLaunch:!1,deliverGate:!1,reducedAssurance:!1,launchPrimary:!1,chatList:!1,chatAttachments:!1,chatWorkflows:[],powerMode:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatOnboard:!1,chatArtifactsStubOps:null,dataSources:!1,planGateNote:!1,chatJobProposals:!1,reshapeRun:!1,chatJobPower:!1,workflowCatalogV2:!1,trackerLinks:!1,load:()=>t().loaded?Promise.resolve():(ne??(ne=Promise.resolve().then(()=>Ee).then(({api:o})=>o.getHealth()).then(o=>{const s=o.capabilities??{};e({loaded:!0,runChatId:s.runChatId===!0,walkthroughRoots:s.walkthroughRoots===!0,askPath:s.askPath===!0,chatIdOnLaunch:s.chatIdOnLaunch===!0,deliverGate:s.deliverGate===!0,reducedAssurance:s.reducedAssurance===!0,launchPrimary:s.launchPrimary===!0,chatList:s.chatList===!0,chatAttachments:s.chatAttachments===!0,chatWorkflows:Array.isArray(s.chatWorkflows)?s.chatWorkflows.filter(p=>typeof p=="string"):[],powerMode:s.powerMode===!0,voice:s.voice===!0,chatContext:s.chatArtifacts?.context===!0,chatProposals:s.chatArtifacts?.proposals===!0,chatArtifactsStub:s.chatArtifacts?.stub===!0,chatOnboard:s.chatArtifacts?.onboard===!0,chatArtifactsStubOps:ke(s.chatArtifacts),dataSources:s.apps?.uploads===!0,trackerLinks:s.trackerLinks===!0,planGateNote:s.planGateNote===!0,chatJobProposals:s.chatJobProposals===!0,reshapeRun:s.reshapeRun===!0,chatJobPower:s.chatJobPower===!0,workflowCatalogV2:s.workflowCatalogV2===!0})}).catch(()=>{e({loaded:!0,runChatId:!1,walkthroughRoots:!1,askPath:!1,chatIdOnLaunch:!1,deliverGate:!1,reducedAssurance:!1,launchPrimary:!1,chatList:!1,chatAttachments:!1,chatWorkflows:[],powerMode:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatOnboard:!1,chatArtifactsStubOps:null,dataSources:!1,trackerLinks:!1,planGateNote:!1,chatJobProposals:!1,reshapeRun:!1,chatJobPower:!1,workflowCatalogV2:!1})}).finally(()=>{ne=null})),ne)}));function ke(e){const t=e?.stubOps;return Array.isArray(t)?t.filter(o=>typeof o=="string"):null}const Te={};function pe(){const e=Ie.getState(),t=[...e.chatJobProposals?["job"]:[],...e.chatOnboard?["onboard"]:[]];return t.length>0?{accepts:t}:{}}function Ue(){const e=Te?.VITE_API_HOST;return typeof e=="string"&&e.length>0?e:void 0}function fe(){const e=Ue();return e?`http://${e}/api/v1`:`${window.location.origin}/api/v1`}const me=48*1024,oe="/workflows/catalog";async function r(e,t){const o=t?.body!==void 0&&t?.body!==null&&!(typeof FormData<"u"&&t.body instanceof FormData)?{"Content-Type":"application/json",...t?.headers}:{...t?.headers},s=await fetch(`${fe()}${e}`,{...t,headers:o});if(!s.ok){const p=await s.text();let g,x;try{const I=JSON.parse(p);x=I;const y=I.error??I.message??p;g=typeof y=="string"?y:JSON.stringify(y)}catch{g=p}throw g||(g=s.statusText),new ee(s.status,g,x)}if(s.status!==204)return s.json()}const Ee=Object.freeze(Object.defineProperty({__proto__:null,ApiError:ee,KEEPALIVE_MAX_BYTES:me,WORKFLOW_CATALOG_PATH:oe,api:{search:(e,t={})=>{const o=new URLSearchParams({q:e});return t.types!==void 0&&t.types.length>0&&o.set("types",t.types.join(",")),t.limit!==void 0&&o.set("limit",String(t.limit)),t.cursor!==void 0&&t.cursor!==null&&o.set("cursor",t.cursor),r(`/search?${o.toString()}`,t.signal!==void 0?{signal:t.signal}:void 0)},listRuns:e=>r(e?"/runs?include=archived":"/runs"),listRunsForDoc:e=>r(`/runs?doc=${encodeURIComponent(e)}`),archiveRun:(e,t,o)=>r(`/runs/${encodeURIComponent(e)}/archive`,{method:"POST",body:JSON.stringify(o===void 0?{archived:t}:{archived:t,note:o})}),resolveRun:(e,t)=>r(`/runs/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify(t)}),getRun:e=>r(`/runs/${encodeURIComponent(e)}`),getAudit:e=>r(`/audit?runId=${encodeURIComponent(e)}`),getAuditByAction:(e,t)=>r(`/audit?action=${encodeURIComponent(e)}${t!==void 0?`&limit=${Math.max(1,Math.floor(t))}`:""}`),getAuditSince:(e,t=200)=>r(`/audit?since=${Math.max(0,Math.floor(e))}&limit=${t}`),getRunEvents:(e,t)=>r(`/runs/${encodeURIComponent(e)}/events${t!==void 0&&t.length>0?`?type=${t.map(encodeURIComponent).join(",")}`:""}`),getRunAcceptance:e=>r(`/runs/${encodeURIComponent(e)}/acceptance`),getRunInventory:e=>r(`/runs/${encodeURIComponent(e)}/inventory`),launchRun:e=>r("/runs",{method:"POST",body:JSON.stringify(e)}),previewLinkedIssues:e=>r("/linked-issues/preview",{method:"POST",body:JSON.stringify(e)}),deliverRun:e=>r(`/runs/${encodeURIComponent(e)}/deliver`,{method:"POST"}),confirmGate:(e,t)=>{const o=JSON.stringify(t);return r(`/runs/${encodeURIComponent(e)}/gate`,{method:"POST",body:o,...new TextEncoder().encode(o).length<=me?{keepalive:!0}:{}})},cancelRun:(e,t)=>r(`/runs/${encodeURIComponent(e)}/cancel`,t!==void 0&&(t.reason!==void 0||t.input!==void 0)?{method:"POST",body:JSON.stringify(t)}:{method:"POST"}),putGuidance:(e,t)=>r(`/runs/${encodeURIComponent(e)}/guidance`,{method:"PUT",body:JSON.stringify({text:t})}),resumeRun:e=>r(`/runs/${encodeURIComponent(e)}/resume`,{method:"POST"}),openChat:e=>r("/chats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,...pe()})}),sendChatMessage:(e,t,o,s,p)=>r(`/chats/${encodeURIComponent(e)}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,...o!==void 0?{targets:o}:{},...s!==void 0&&s.length>0?{attachments:s}:{},...p!==void 0&&Object.keys(p).length>0?{context:p}:{},...pe()})}),reseatChat:(e,t)=>r(`/chats/${encodeURIComponent(e)}/seats`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clis:t})}),closeChat:e=>r(`/chats/${encodeURIComponent(e)}`,{method:"DELETE"}),getChat:e=>r(`/chats/${encodeURIComponent(e)}`),listChats:()=>r("/chats"),listChatHistory:(e={})=>{const t=new URLSearchParams({limit:String(e.limit??20),status:e.status??"all"});return e.cursor!==void 0&&e.cursor!==null&&e.cursor!==""&&t.set("cursor",e.cursor),r(`/chats?${t.toString()}`)},getChatMessages:e=>r(`/chats/${encodeURIComponent(e)}/messages`),decideChatProposal:(e,t,o)=>r(`/chats/${encodeURIComponent(e)}/proposals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify(o)}),proposeInChat:(e,t)=>r(`/chats/${encodeURIComponent(e)}/proposals`,{method:"POST",body:JSON.stringify(t)}),reviseChatProposal:(e,t)=>r(`/chats/${encodeURIComponent(e)}/proposals`,{method:"POST",body:JSON.stringify(t)}),reshapeRun:(e,t)=>r(`/runs/${encodeURIComponent(e)}/reshape`,{method:"POST",body:JSON.stringify(t)}),endChat:e=>r(`/chats/${encodeURIComponent(e)}/close`,{method:"POST"}),uploadChatAttachments:(e,t)=>{const o=new FormData;for(const s of t)o.append("file",s,s.name);return r(`/chats/${encodeURIComponent(e)}/attachments`,{method:"POST",body:o})},getUnitOutput:(e,t)=>r(`/runs/${encodeURIComponent(e)}/units/${encodeURIComponent(t)}/output`),getGate:(e,t)=>r(`/runs/${encodeURIComponent(e)}/gate`,t!==void 0?{signal:t}:void 0),getElicitation:async e=>{try{return await r(`/runs/${encodeURIComponent(e)}/elicitation`)}catch(t){if(ae(t)===404)return null;throw t}},respondToElicitation:(e,t)=>r(`/runs/${encodeURIComponent(e)}/elicitation`,{method:"POST",body:JSON.stringify(t)}),getRoster:e=>r(e===void 0?"/roster":`/roster?refresh=${encodeURIComponent(e)}`),getWatch:(e={})=>{const t=new URLSearchParams;for(const[s,p]of Object.entries(e))p!==void 0&&p!==""&&t.set(s,String(p));const o=t.toString();return r(`/watch${o===""?"":`?${o}`}`)},getSeatRecord:(e=7,t)=>r(`/roster/record?days=${e}${t!==void 0?`&project=${encodeURIComponent(t)}`:""}`),listRepos:()=>r("/repos"),registerRepo:(e,t,o)=>r("/repos",{method:"POST",body:JSON.stringify({name:e,rootPath:t,...o!==void 0?{projectId:o}:{}})}),cloneAndRegisterRepo:(e,t,o,s)=>r("/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,...o?{rootPath:o}:{},...s!==void 0?{projectId:s}:{}})}),getOnboardRun:e=>r(`/repos/${encodeURIComponent(e)}/onboard`),rerunOnboarding:e=>r(`/repos/${encodeURIComponent(e)}/onboard`,{method:"POST"}),getHealth:()=>r("/health"),openTerminal:e=>r("/terminals",{method:"POST",body:JSON.stringify(e)}),seatLogout:(e,t)=>r(`/seats/${encodeURIComponent(e)}/logout`,{method:"POST",body:JSON.stringify(t)}),seatContainerLogin:(e,t)=>r(`/seats/${encodeURIComponent(e)}/container-login`,{method:"POST",body:JSON.stringify(t)}),closeSeatContainerLogin:e=>r(`/seats/${encodeURIComponent(e)}/container-login`,{method:"DELETE"}),seatContainerLoginOutcome:(e,t)=>r(`/seats/${encodeURIComponent(e)}/container-login`,t===void 0?void 0:{signal:t}),seatContainerLogout:e=>r(`/seats/${encodeURIComponent(e)}/container-logout`,{method:"POST"}),resizeTerminal:(e,t,o)=>r(`/terminals/${encodeURIComponent(e)}/resize`,{method:"POST",body:JSON.stringify({cols:t,rows:o})}),closeTerminal:e=>r(`/terminals/${encodeURIComponent(e)}/close`,{method:"POST"}),openPath:(e,t)=>r("/open",{method:"POST",body:JSON.stringify(t===void 0?{path:e}:{path:e,runId:t})}),getRunFile:(e,t)=>r(`/runs/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}`),getRunDiff:(e,t,o)=>{const s=new URLSearchParams;t!==void 0&&s.set("path",t),o!==void 0&&s.set("base",o);const p=s.toString();return r(`/runs/${encodeURIComponent(e)}/diff${p===""?"":`?${p}`}`)},inspectUnit:(e,t)=>r(`/runs/${encodeURIComponent(e)}/units/${t}/inspect`,{method:"POST",body:"{}"}),getInspections:(e,t)=>r(`/runs/${encodeURIComponent(e)}/units/${t}/inspections`),injectMessage:(e,t,o,s)=>r(`/runs/${encodeURIComponent(e)}/inject`,{method:"POST",body:JSON.stringify(s?.input!==void 0?{message:t,target:o,input:s.input}:{message:t,target:o})}),listWorkflows:()=>r("/workflows"),getWorkflowCatalog:e=>r(e!=null&&e!==""?`${oe}?projectId=${encodeURIComponent(e)}`:oe).catch(t=>{if(t instanceof SyntaxError)return null;throw t}),getWorkflow:e=>r(`/workflows/${encodeURIComponent(e)}`),saveScript:(e,t,o)=>r("/scripts",{method:"POST",body:JSON.stringify({name:e,content:t,lang:o})}),listRequirements:(e,t,o={})=>{const s=new URLSearchParams;return t.q&&s.set("q",t.q),t.mismatch&&s.set("mismatch",t.mismatch),t.risk&&s.set("risk",t.risk),t.category&&s.set("category",t.category),t.domain&&s.set("domain",t.domain),s.set("offset",String(t.offset??0)),s.set("limit",String(t.limit??50)),r(`/repos/${encodeURIComponent(e)}/requirements?${s.toString()}`,o.signal!==void 0?{signal:o.signal}:void 0)},setRequirementsMinimum:(e,t)=>r(`/repos/${encodeURIComponent(e)}/requirements/minimum`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({minPct:t})}),getRequirement:(e,t)=>r(`/repos/${encodeURIComponent(e)}/requirements/${encodeURIComponent(t)}`),patchRequirement:(e,t,o)=>r(`/repos/${encodeURIComponent(e)}/requirements/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),getDomainGraph:()=>r("/domain-graph"),getRepoGraph:(e,t)=>{const o=new URLSearchParams;t?.focus&&o.set("focus",t.focus),t?.limit&&o.set("limit",String(t.limit));const s=o.size>0?`?${o.toString()}`:"";return r(`/repos/${encodeURIComponent(e)}/graph${s}`)},getBlastRadius:(e,t)=>r(`/repos/${encodeURIComponent(e)}/graph/blast-radius?name=${encodeURIComponent(t)}`),getRepoGitHistory:(e,t)=>r(`/repos/${encodeURIComponent(e)}/git-history${t===void 0?"":`?limit=${t}`}`),getDeliverTarget:async e=>{try{return await r(`/repos/${encodeURIComponent(e)}/deliver-target`)}catch{return null}},getRepoContributors:e=>r(`/repos/${encodeURIComponent(e)}/contributors`),getRepoDomainGraph:e=>r(`/repos/${encodeURIComponent(e)}/domain-graph`),listPolicies:()=>r("/governance/policies"),listConformanceRules:()=>r("/governance/rules"),getCoverageReport:()=>r("/governance/coverage"),getCoverageReportForRepo:e=>r(`/governance/coverage?repo=${encodeURIComponent(e)}`),getGraphKindsForRepo:(e,t={})=>r(`/governance/graph?repo=${encodeURIComponent(e)}`,t.signal!==void 0?{signal:t.signal}:void 0),listClaims:()=>r("/governance/claims"),upsertPolicy:e=>r("/governance/policies",{method:"POST",body:JSON.stringify(e)}),upsertConformanceRule:e=>r("/governance/rules",{method:"POST",body:JSON.stringify(e)}),retirePolicy:e=>r(`/governance/policies/${encodeURIComponent(e)}`,{method:"DELETE"}),retireConformanceRule:e=>r(`/governance/rules/${encodeURIComponent(e)}`,{method:"DELETE"}),recallRulesPreview:e=>{const t=new URLSearchParams;for(const[p,g]of Object.entries(e))g&&t.set(p,g);const o=t.toString(),s=o?`?${o}`:"";return r(`/governance/rules/preview${s}`)},getSettings:()=>r("/settings"),updateSettings:e=>r("/settings",{method:"PUT",body:JSON.stringify(e)}),getAppearanceSettings:()=>r("/settings"),putAppearanceSettings:e=>r("/settings",{method:"PUT",body:JSON.stringify({"studio.appearance":e})}),putNotifSettings:e=>r("/settings",{method:"PUT",body:JSON.stringify({"studio.notifications":e})}),putComposerSettings:e=>r("/settings",{method:"PUT",body:JSON.stringify({"studio.composer":e})}),putSetupSettings:e=>r("/settings",{method:"PUT",body:JSON.stringify({"studio.setup":e})}),putViewSettings:e=>r("/settings",{method:"PUT",body:JSON.stringify({"studio.view":e})}),putReportShown:e=>r("/settings",{method:"PUT",body:JSON.stringify({"studio.report":{shown:e}})}),listApps:()=>r("/apps"),listProjects:e=>{const t=e?`?status=${e}`:"";return r(`/projects${t}`)},getProject:e=>r(`/projects/${encodeURIComponent(e)}`),createProject:e=>r("/projects",{method:"POST",body:JSON.stringify(e)}),updateProject:(e,t)=>r(`/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),listProjectMembers:e=>r(`/projects/${encodeURIComponent(e)}/members`),listProjectPrompts:e=>r(`/projects/${encodeURIComponent(e)}/prompts`),attachProjectMember:(e,t)=>r(`/projects/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)}),detachProjectMember:(e,t)=>r(`/projects/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"DELETE"}),getProjectActivity:(e,t)=>{const o=t?`?cursor=${encodeURIComponent(t)}`:"";return r(`/projects/${encodeURIComponent(e)}/activity${o}`)},reassignRun:(e,t)=>r(`/runs/${encodeURIComponent(e)}/reassign`,{method:"POST",body:JSON.stringify(t===void 0?{}:{cli:t})}),getProjectGraph:e=>r(`/projects/${encodeURIComponent(e)}/graph`),refreshProjectGraph:(e,t)=>r(`/projects/${encodeURIComponent(e)}/graph/refresh`,{method:"POST",body:JSON.stringify(t??{})})},apiBase:fe,apiFetch:r,apiStatus:ae,translateWireError:ie},Symbol.toStringTag,{value:"Module"})),Y=e=>e==null?"null":typeof e=="string"?e:JSON.stringify(e);function _e(e,t){switch(e.type){case"number":return Math.round((t+1)*13.7*10)/10;case"integer":return(t+1)*7;case"boolean":return t%2===0;case"date":return`2026-10-${String(10+t).padStart(2,"0")}`;case"datetime":return`2026-10-${String(10+t).padStart(2,"0")}T09:30:00Z`;default:return`${e.name.replace(/_/g," ")} ${t+1}`}}function je(e,t){const o=Object.assign(Object.create(null),structuredClone(t?.rows??{})),s=null,p="you",g=new Map;let x=0;const I=(y,f)=>y.kind==="param"?{value:f[y.name]??null,from:"from the app"}:y.kind==="literal"?{value:y.value,from:"fixed by the app"}:y.kind==="viewer"?{value:y.claim==="name"?p.split("@")[0]:p,from:"your sign-in"}:{value:y.value==="now"?new Date().toISOString():"a new uuid",from:`filled by studio: ${y.value}`};return{kind:{queries:"sample",actions:"sample"},async query(y,f,h){const l=e().queries.find(C=>C.id===f);if(l===void 0)return{error:"refused",message:`this version has no query ${f}`};Object.hasOwn(o,f)||(o[f]=[0,1,2].map(C=>l.output.map(J=>_e(J,C))));let E=o[f];const A=Object.values(h).filter(C=>typeof C=="string"&&C.trim()!==""&&C!=="all");return A.length>0&&(E=E.filter(C=>A.every(J=>C.some(q=>typeof q=="string"&&q.toLowerCase().includes(J.toLowerCase()))))),{columns:l.output,rows:structuredClone(E),truncated:!1,hasMore:!1,ms:1,cachedAt:null,sample:!0}},async prepare(y,f,h){const l=e().actions.find($=>$.id===f);if(l===void 0)return{error:"refused",message:`this version has no action ${f}`};const E=[];let A,C,J=null,q=null;if(l.kind==="row-write"){const $=Object.entries(l.set??{});for(const[u,d]of $){const k=I(d,h);E.push({label:u,value:Y(k.value),from:k.from})}J=`${Object.entries(l.key).map(([u,d])=>`${u} = ${Y(h[d.name])}`).join(", ")} (exactly 1 row)`,q="Sample: no table was checked. A real run checks a plain table (no triggers, rules, inheritance or row security) just before it writes.",A=`${l.op.toUpperCase()} ${l.table}`;const c=$.length;C=l.op==="update"?`UPDATE ONLY ${l.table} AS w SET ${$.map(([u],d)=>`${u} = $${d+1}`).join(", ")} WHERE ${Object.keys(l.key).map((u,d)=>`w.${u} = $${c+d+1}`).join(" AND ")}`:l.op==="delete"?`DELETE FROM ONLY ${l.table} AS w WHERE ${Object.keys(l.key).map((u,d)=>`w.${u} = $${d+1}`).join(" AND ")}`:`INSERT INTO ${l.table} (${$.map(([u])=>u).join(", ")}) VALUES (${$.map((u,d)=>`$${d+1}`).join(", ")})`}else{for(const[$,a]of Object.entries(l.args)){const c=I(a,h);E.push({label:$,value:Y(c.value),from:c.from})}A=l.call.kind==="tool"?l.call.tool:`mutation ${l.call.mutation.slice(0,60)}`,C=`${A}
|
|
10
|
-
${JSON.stringify(Object.fromEntries(E.map($=>[$.label,$.value])),null,1)}`}x+=1;const N=`sample-${x}`,L=Date.now()+12e4;return g.set(N,{action:l,params:h,expiresAt:L}),{record:N,expiresAt:L,card:{action:l.id,kind:l.kind,source:`${l.source} (sample)`,operation:A,rows:E,key:J,checks:q,request:C,says:l.description??null,sample:!0}}},async run(y,f){const h=g.get(f);if(g.delete(f),h===void 0||h.action.id!==y)return{state:"failed",reason:"this card was not prepared here",sample:!0};if(Date.now()>h.expiresAt)return{state:"failed",reason:"the card expired; nothing was written",sample:!0};if(h.action.kind==="row-write"&&h.action.op==="update"){const E=h.action;for(const A of e().queries){const C=A.output.map(N=>N.name),J=Object.entries(E.key),q=Object.hasOwn(o,A.id)?o[A.id]:void 0;if(!(q===void 0||!J.every(([N])=>C.includes(N)))){for(const N of q)if(J.every(([L,$])=>Y(N[C.indexOf(L)])===Y(h.params[$.name])))for(const[L,$]of Object.entries(E.set??{}))C.includes(L)&&(N[C.indexOf(L)]=I($,h.params).value)}}}return{state:"succeeded",reason:h.action.kind==="row-write"&&h.action.op==="update"?"Sample data: the sample rows in this tab changed; no source was touched":"Sample data: nothing was written and no rows changed",sample:!0}},viewer:()=>({email:s,sample:!0})}}const re="wicked.editor",se=1,Ae=/^[A-Z]{3}$/u;function Ne(e,t,o){if(e==null)return"";if(typeof e=="boolean")return e?"yes":"no";const s=void 0,p=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))?Number(e):null;try{switch(t?.kind){case"currency":if(p===null||!Ae.test(t.currency))break;return new Intl.NumberFormat(o,{style:"currency",currency:t.currency,...s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}}).format(p);case"percent":if(p===null)break;return new Intl.NumberFormat(o,{style:"percent",maximumFractionDigits:s??1}).format(p);case"number":if(p===null)break;return new Intl.NumberFormat(o,s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}).format(p);case"date":case"datetime":{const g=new Date(typeof e=="number"?e:String(e));if(Number.isNaN(g.getTime()))break;return new Intl.DateTimeFormat(o,t.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(g)}case"duration":{if(p===null)break;const g=Math.abs(Math.round(p)),x=Math.floor(g/86400),I=Math.floor(g%86400/3600),y=Math.floor(g%3600/60);return x>0?`${x}d ${I}h`:I>0?`${I}h ${y}m`:`${y}m`}default:break}}catch{}return typeof e=="number"?Number.isInteger(e)?String(e):new Intl.NumberFormat(o,{maximumFractionDigits:6}).format(e):String(e)}function xe(e,t){if(e===void 0||t===null||t===void 0)return t;if((e.type==="number"||e.type==="integer")&&typeof t=="string"&&t.trim()!==""){const o=Number(t);return Number.isFinite(o)&&(e.type==="number"||Number.isInteger(o))?o:t}return e.type==="boolean"&&typeof t=="string"&&(t==="true"||t==="false")?t==="true":e.type==="string"&&(typeof t=="number"||typeof t=="boolean")?String(t):t}const X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),he=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function ye(e,t,o){const s=Object.entries(o).sort(([f],[h])=>f.localeCompare(h)),p=JSON.stringify([t,s]);let g=0;for(const f of p)g=Math.imul(g,31)+f.charCodeAt(0)>>>0;const x=e.queries.find(f=>f.id===t),I=s.map(([,f])=>f).filter(f=>typeof f=="string").join(" "),y=[0,1,2].map(f=>(x?.output??[]).map(h=>{const l=g%1e3+f+1;switch(h.type){case"number":return l/10;case"integer":return l;case"boolean":return l%2===0;case"date":return`2026-10-${String(10+f).padStart(2,"0")}`;case"datetime":return`2026-10-${String(10+f).padStart(2,"0")}T09:30:00Z`;default:return`${I} ${h.name} ${l}`.trim()}}));return je(()=>e,{rows:{[t]:y}}).query(1,t,o)}async function qe(){const e=Date.parse("2026-10-15T12:00:00Z");window.Date=new Proxy(Date,{construct:(a,c)=>Reflect.construct(a,c.length===0?[e]:c),apply:a=>new a(e).toString(),get:(a,c,u)=>c==="now"?()=>e:Reflect.get(a,c,u)});let t;const o=new Map,s=new Map;let p,g=0,x=0,I=0,y=null;const f=new Map,h=a=>{const c=a instanceof Error?a.message:String(a);$.errors.includes(c)||$.errors.push(c)},l=async a=>{try{await a()}catch(c){throw h(c),c}},E=a=>{const c=t.spec.pages.find(u=>u.id===a);if(c===void 0)throw new Error(`This app has no page ${a}`);return c},A=a=>{const c=[...document.querySelectorAll("[data-component]")].find(u=>u.dataset.component===a);if(c===void 0)throw new Error(`This page has no filter ${a}`);return c},C=a=>a.filter==="search"?["fixture"]:a.filter==="date-range"?["2026-10-01/2026-10-31"]:a.options?.kind==="values"?a.options.values.map(c=>c.value):[...s.get(a.id)??[]],J=async()=>{for(const a of t.spec.pages)for(const c of a.components){if(c.type!=="filter"||c.options?.kind!=="query")continue;const u=c.options,d=t.spec.queries.find(S=>S.id===u.query.query),k={};for(const[S,D]of Object.entries(u.query.params??{})){const[Z,W,G]=D.split("."),B=Z==="filter"&&W!==void 0?o.get(W):void 0,_=typeof B=="string"?G===void 0?B:void 0:G==="from"?B?.from:G==="to"?B?.to:void 0,H=d?.params?.properties??{};_!==void 0&&_!==""&&(k[S]=xe(Object.hasOwn(H,S)?H[S]:void 0,_))}const w=await ye(t.spec,u.query.query,k);if("error"in w)throw new Error(w.message);const O=w.columns.findIndex(S=>S.name===u.value);s.set(c.id,w.rows.slice(0,200).map(S=>Ne(S[O],void 0,"en")).filter(S=>S!==""))}},q=()=>new Promise((a,c)=>{const u=`fixture-${++I}`,d=setTimeout(()=>{f.delete(u),c(new Error("The runtime did not answer"))},5e3);f.set(u,()=>{clearTimeout(d),a()}),p.postMessage({p:re,v:se,type:"host.ping",id:u,payload:{}})}),N=async()=>{const a=performance.now()+5e3;let c=0;for(;c<2;){const u=g;if(await q(),await he(),await he(),c=x===0&&u===g?c+1:0,performance.now()>a)throw new Error("The fixture did not finish rendering")}for(const u of document.querySelectorAll(".wk-error"))u.textContent&&h(u.textContent)},L=a=>{if(!t.spec.actions.some(O=>O.id===a))throw new Error(`This app has no action ${a}`);const c=Array.isArray(t.cards)?t.cards.find(O=>O.action===a):Object.hasOwn(t.cards,a)?t.cards[a]:void 0;if(c===void 0)throw new Error(`The fixture has no card for ${a}`);y?.remove(),y=document.createElement("div"),y.className="wk-fixture-card";const u=document.createElement("section");u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-label",`Prepare ${a}`),u.setAttribute("data-testid","apps-card");const d=document.createElement("h2");d.textContent=`Prepare ${a}`;const k=document.createElement("pre");k.textContent=typeof c=="string"?c:JSON.stringify(c,null,2);const w=document.createElement("button");w.type="button",w.textContent="Close",w.addEventListener("click",()=>{$.closeCard()}),u.append(d,k,w),y.append(u),document.body.append(y),w.focus()},$={ready:!1,errors:[],pages:()=>t.spec.pages.map(a=>a.id),filters:a=>E(a).components.filter(c=>c.type==="filter").map(c=>({id:c.id,values:C(c)})),actions:a=>[...new Set(E(a).components.flatMap(c=>c.type==="button"?[c.action.action]:c.type==="form"?[c.submit.action]:c.type==="table"?(c.rowActions??[]).map(u=>u.action):[]))],show:a=>l(async()=>{const c=t.spec.pages.indexOf(E(a)),u=document.querySelectorAll(".wk-page")[c];if(u===void 0)throw new Error(`The runtime did not draw page ${a}`);u.click(),await N()}),setFilter:(a,c)=>l(async()=>{const u=t.spec.pages.find(w=>w.components.some(O=>O.id===a&&O.type==="filter"));if(u===void 0)throw new Error(`This app has no filter ${a}`);await $.show(u.id);const d=A(a),k=d.querySelector("select");if(k!==null){if(![...k.options].some(w=>w.value===c))throw new Error(`This filter has no value ${c}`);k.value=c,o.set(a,c),k.dispatchEvent(new Event("change",{bubbles:!0}))}else{const w=[...d.querySelectorAll("input")],O=w.length===2?c.split("/"):[c];if(w.length===0||O.length!==w.length)throw new Error("A date range needs from/to");for(const[S,D]of w.entries())D.value=O[S],D.dispatchEvent(new Event(D.type==="search"?"input":"change",{bubbles:!0}));o.set(a,w.length===2?{from:w[0].value,to:w[1].value}:w[0].value),w[0]?.type==="search"&&await new Promise(S=>setTimeout(S,310))}await J(),await N()}),prepare:a=>l(async()=>{L(a),await N()}),closeCard:()=>l(async()=>{y?.remove(),y=null,await N()})};window.__wkFixture=$,window.addEventListener("error",a=>h(a.message)),window.addEventListener("unhandledrejection",a=>h(a.reason));try{const a=await fetch("./fixture.json",{credentials:"omit",redirect:"error"});if(!a.ok)throw new Error("The fixture could not be read");t=await a.json();for(const u of t.spec.pages)for(const d of u.components)if(d.type==="filter")if(d.filter==="date-range"){const k=X(d.default)&&Number.isInteger(d.default.lastDays)?Math.min(3650,Math.max(1,d.default.lastDays)):30;o.set(d.id,{from:new Date(e-k*864e5).toISOString().slice(0,10),to:new Date(e).toISOString().slice(0,10)})}else o.set(d.id,typeof d.default=="string"?d.default:"");await J();const c=new MessageChannel;if(p=c.port1,p.onmessage=u=>{const d=u.data;if(!X(d)||d.p!==re||d.v!==se)return;if(typeof d.re=="string"){f.get(d.re)?.(),f.delete(d.re);return}if(typeof d.id!="string")return;const k=d.id,w=X(d.payload)?d.payload:{},O=(S,D)=>{p.postMessage({p:re,v:se,re:k,ok:D===void 0,payload:S,...D===void 0?{}:{error:D}})};switch(g+=1,d.type){case"artifact.read":O({version:1,content:{type:"app",spec:t.spec,readonly:!0}});return;case"data.query":{x+=1,ye(t.spec,String(w.query),X(w.params)?w.params:{}).then(S=>{"error"in S?(h(S.message),O({},{code:S.error,message:S.message})):O(S)}).catch(S=>{h(S),O({},{code:"unavailable",message:"The fixture query failed"})}).finally(()=>{x-=1,g+=1});return}case"data.action":try{L(String(w.action)),O({state:"cancelled"})}catch(S){h(S),O({},{code:"refused",message:String(S)})}return;default:O({},{code:"unsupported",message:"The fixture only reads and prepares"});return}},window.wickedAppsStandalone.boot(c.port2,{protocol:2,surface:"full",size:"full",grants:["artifact.read","data.read","data.write"],app:{framed:!1,mode:"preview",url:{}},prefs:{locale:"en"},theme:{}}),await N(),document.querySelector(".wk-page")===null)throw new Error("The runtime did not draw a page");$.ready=$.errors.length===0}catch(a){h(a)}}qe()})();
|
|
9
|
+
*/var le;function ve(){if(le)return m;le=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),x=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),d=Symbol.iterator;function _(n){return n===null||typeof n!="object"?null:(n=d&&n[d]||n["@@iterator"],typeof n=="function"?n:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,L={};function q(n,i,b){this.props=n,this.context=i,this.refs=L,this.updater=b||N}q.prototype.isReactComponent={},q.prototype.setState=function(n,i){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,i,"setState")},q.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function A(){}A.prototype=q.prototype;function J(n,i,b){this.props=n,this.context=i,this.refs=L,this.updater=b||N}var $=J.prototype=new A;$.constructor=J,C($,q.prototype),$.isPureReactComponent=!0;var a=Array.isArray,c=Object.prototype.hasOwnProperty,u={current:null},p={key:!0,ref:!0,__self:!0,__source:!0};function k(n,i,b){var R,v={},T=null,j=null;if(i!=null)for(R in i.ref!==void 0&&(j=i.ref),i.key!==void 0&&(T=""+i.key),i)c.call(i,R)&&!p.hasOwnProperty(R)&&(v[R]=i[R]);var U=arguments.length-2;if(U===1)v.children=b;else if(1<U){for(var I=Array(U),M=0;M<U;M++)I[M]=arguments[M+2];v.children=I}if(n&&n.defaultProps)for(R in U=n.defaultProps,U)v[R]===void 0&&(v[R]=U[R]);return{$$typeof:e,type:n,key:T,ref:j,props:v,_owner:u.current}}function w(n,i){return{$$typeof:e,type:n.type,key:i,ref:n.ref,props:n.props,_owner:n._owner}}function O(n){return typeof n=="object"&&n!==null&&n.$$typeof===e}function S(n){var i={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(b){return i[b]})}var D=/\/+/g;function Z(n,i){return typeof n=="object"&&n!==null&&n.key!=null?S(""+n.key):i.toString(36)}function V(n,i,b,R,v){var T=typeof n;(T==="undefined"||T==="boolean")&&(n=null);var j=!1;if(n===null)j=!0;else switch(T){case"string":case"number":j=!0;break;case"object":switch(n.$$typeof){case e:case t:j=!0}}if(j)return j=n,v=v(j),n=R===""?"."+Z(j,0):R,a(v)?(b="",n!=null&&(b=n.replace(D,"$&/")+"/"),V(v,i,b,"",function(M){return M})):v!=null&&(O(v)&&(v=w(v,b+(!v.key||j&&j.key===v.key?"":(""+v.key).replace(D,"$&/")+"/")+n)),i.push(v)),1;if(j=0,R=R===""?".":R+":",a(n))for(var U=0;U<n.length;U++){T=n[U];var I=R+Z(T,U);j+=V(T,i,b,I,v)}else if(I=_(n),typeof I=="function")for(n=I.call(n),U=0;!(T=n.next()).done;)T=T.value,I=R+Z(T,U++),j+=V(T,i,b,I,v);else if(T==="object")throw i=String(n),Error("Objects are not valid as a React child (found: "+(i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.");return j}function G(n,i,b){if(n==null)return n;var R=[],v=0;return V(n,R,"","",function(T){return i.call(b,T,v++)}),R}function B(n){if(n._status===-1){var i=n._result;i=i(),i.then(function(b){(n._status===0||n._status===-1)&&(n._status=1,n._result=b)},function(b){(n._status===0||n._status===-1)&&(n._status=2,n._result=b)}),n._status===-1&&(n._status=0,n._result=i)}if(n._status===1)return n._result.default;throw n._result}var E={current:null},W={transition:null},Je={ReactCurrentDispatcher:E,ReactCurrentBatchConfig:W,ReactCurrentOwner:u};function we(){throw Error("act(...) is not supported in production builds of React.")}return m.Children={map:G,forEach:function(n,i,b){G(n,function(){i.apply(this,arguments)},b)},count:function(n){var i=0;return G(n,function(){i++}),i},toArray:function(n){return G(n,function(i){return i})||[]},only:function(n){if(!O(n))throw Error("React.Children.only expected to receive a single React element child.");return n}},m.Component=q,m.Fragment=r,m.Profiler=l,m.PureComponent=J,m.StrictMode=s,m.Suspense=y,m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Je,m.act=we,m.cloneElement=function(n,i,b){if(n==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+n+".");var R=C({},n.props),v=n.key,T=n.ref,j=n._owner;if(i!=null){if(i.ref!==void 0&&(T=i.ref,j=u.current),i.key!==void 0&&(v=""+i.key),n.type&&n.type.defaultProps)var U=n.type.defaultProps;for(I in i)c.call(i,I)&&!p.hasOwnProperty(I)&&(R[I]=i[I]===void 0&&U!==void 0?U[I]:i[I])}var I=arguments.length-2;if(I===1)R.children=b;else if(1<I){U=Array(I);for(var M=0;M<I;M++)U[M]=arguments[M+2];R.children=U}return{$$typeof:e,type:n.type,key:v,ref:T,props:R,_owner:j}},m.createContext=function(n){return n={$$typeof:x,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},n.Provider={$$typeof:h,_context:n},n.Consumer=n},m.createElement=k,m.createFactory=function(n){var i=k.bind(null,n);return i.type=n,i},m.createRef=function(){return{current:null}},m.forwardRef=function(n){return{$$typeof:P,render:n}},m.isValidElement=O,m.lazy=function(n){return{$$typeof:g,_payload:{_status:-1,_result:n},_init:B}},m.memo=function(n,i){return{$$typeof:f,type:n,compare:i===void 0?null:i}},m.startTransition=function(n){var i=W.transition;W.transition={};try{n()}finally{W.transition=i}},m.unstable_act=we,m.useCallback=function(n,i){return E.current.useCallback(n,i)},m.useContext=function(n){return E.current.useContext(n)},m.useDebugValue=function(){},m.useDeferredValue=function(n){return E.current.useDeferredValue(n)},m.useEffect=function(n,i){return E.current.useEffect(n,i)},m.useId=function(){return E.current.useId()},m.useImperativeHandle=function(n,i,b){return E.current.useImperativeHandle(n,i,b)},m.useInsertionEffect=function(n,i){return E.current.useInsertionEffect(n,i)},m.useLayoutEffect=function(n,i){return E.current.useLayoutEffect(n,i)},m.useMemo=function(n,i){return E.current.useMemo(n,i)},m.useReducer=function(n,i,b){return E.current.useReducer(n,i,b)},m.useRef=function(n){return E.current.useRef(n)},m.useState=function(n){return E.current.useState(n)},m.useSyncExternalStore=function(n,i,b){return E.current.useSyncExternalStore(n,i,b)},m.useTransition=function(){return E.current.useTransition()},m.version="18.3.1",m}var de;function Re(){return de||(de=1,te.exports=ve()),te.exports}var Ce=Re();const K=$e(Ce),Oe=e=>e;function Ie(e,t=Oe){const r=K.useSyncExternalStore(e.subscribe,K.useCallback(()=>t(e.getState()),[e,t]),K.useCallback(()=>t(e.getInitialState()),[e,t]));return K.useDebugValue(r),r}const pe=e=>{const t=be(e),r=s=>Ie(t,s);return Object.assign(r,t),r},Pe=(e=>e?pe(e):pe);let ne=null;const ke=Pe((e,t)=>({loaded:!1,runChatId:!1,walkthroughRoots:!1,askPath:!1,chatIdOnLaunch:!1,deliverGate:!1,reducedAssurance:!1,launchPrimary:!1,chatList:!1,chatAttachments:!1,chatWorkflows:[],powerMode:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatOnboard:!1,chatArtifactsStubOps:null,dataSources:!1,planGateNote:!1,chatJobProposals:!1,reshapeRun:!1,chatJobPower:!1,workflowCatalogV2:!1,trackerLinks:!1,load:()=>t().loaded?Promise.resolve():(ne??(ne=Promise.resolve().then(()=>Ee).then(({api:r})=>r.getHealth()).then(r=>{const s=r.capabilities??{};e({loaded:!0,runChatId:s.runChatId===!0,walkthroughRoots:s.walkthroughRoots===!0,askPath:s.askPath===!0,chatIdOnLaunch:s.chatIdOnLaunch===!0,deliverGate:s.deliverGate===!0,reducedAssurance:s.reducedAssurance===!0,launchPrimary:s.launchPrimary===!0,chatList:s.chatList===!0,chatAttachments:s.chatAttachments===!0,chatWorkflows:Array.isArray(s.chatWorkflows)?s.chatWorkflows.filter(l=>typeof l=="string"):[],powerMode:s.powerMode===!0,voice:s.voice===!0,chatContext:s.chatArtifacts?.context===!0,chatProposals:s.chatArtifacts?.proposals===!0,chatArtifactsStub:s.chatArtifacts?.stub===!0,chatOnboard:s.chatArtifacts?.onboard===!0,chatArtifactsStubOps:Te(s.chatArtifacts),dataSources:s.apps?.uploads===!0,trackerLinks:s.trackerLinks===!0,planGateNote:s.planGateNote===!0,chatJobProposals:s.chatJobProposals===!0,reshapeRun:s.reshapeRun===!0,chatJobPower:s.chatJobPower===!0,workflowCatalogV2:s.workflowCatalogV2===!0})}).catch(()=>{e({loaded:!0,runChatId:!1,walkthroughRoots:!1,askPath:!1,chatIdOnLaunch:!1,deliverGate:!1,reducedAssurance:!1,launchPrimary:!1,chatList:!1,chatAttachments:!1,chatWorkflows:[],powerMode:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatOnboard:!1,chatArtifactsStubOps:null,dataSources:!1,trackerLinks:!1,planGateNote:!1,chatJobProposals:!1,reshapeRun:!1,chatJobPower:!1,workflowCatalogV2:!1})}).finally(()=>{ne=null})),ne)}));function Te(e){const t=e?.stubOps;return Array.isArray(t)?t.filter(r=>typeof r=="string"):null}const Ue={};function fe(){const e=ke.getState(),t=[...e.chatJobProposals?["job"]:[],...e.chatOnboard?["onboard"]:[]];return t.length>0?{accepts:t}:{}}function _e(){const e=Ue?.VITE_API_HOST;return typeof e=="string"&&e.length>0?e:void 0}function me(){const e=_e();return e?`http://${e}/api/v1`:`${window.location.origin}/api/v1`}const he=48*1024,oe="/workflows/catalog";async function o(e,t){const r=t?.body!==void 0&&t?.body!==null&&!(typeof FormData<"u"&&t.body instanceof FormData)?{"Content-Type":"application/json",...t?.headers}:{...t?.headers},s=await fetch(`${me()}${e}`,{...t,headers:r});if(!s.ok){const l=await s.text();let h,x;try{const P=JSON.parse(l);x=P;const y=P.error??P.message??l;h=typeof y=="string"?y:JSON.stringify(y)}catch{h=l}throw h||(h=s.statusText),new ee(s.status,h,x)}if(s.status!==204)return s.json()}const Ee=Object.freeze(Object.defineProperty({__proto__:null,ApiError:ee,KEEPALIVE_MAX_BYTES:he,WORKFLOW_CATALOG_PATH:oe,api:{search:(e,t={})=>{const r=new URLSearchParams({q:e});return t.types!==void 0&&t.types.length>0&&r.set("types",t.types.join(",")),t.limit!==void 0&&r.set("limit",String(t.limit)),t.cursor!==void 0&&t.cursor!==null&&r.set("cursor",t.cursor),o(`/search?${r.toString()}`,t.signal!==void 0?{signal:t.signal}:void 0)},listRuns:e=>o(e?"/runs?include=archived":"/runs"),listRunsForDoc:e=>o(`/runs?doc=${encodeURIComponent(e)}`),archiveRun:(e,t,r)=>o(`/runs/${encodeURIComponent(e)}/archive`,{method:"POST",body:JSON.stringify(r===void 0?{archived:t}:{archived:t,note:r})}),resolveRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify(t)}),getRun:e=>o(`/runs/${encodeURIComponent(e)}`),getAudit:e=>o(`/audit?runId=${encodeURIComponent(e)}`),getAuditByAction:(e,t)=>o(`/audit?action=${encodeURIComponent(e)}${t!==void 0?`&limit=${Math.max(1,Math.floor(t))}`:""}`),getAuditSince:(e,t=200)=>o(`/audit?since=${Math.max(0,Math.floor(e))}&limit=${t}`),getRunEvents:(e,t)=>o(`/runs/${encodeURIComponent(e)}/events${t!==void 0&&t.length>0?`?type=${t.map(encodeURIComponent).join(",")}`:""}`),getRunAcceptance:e=>o(`/runs/${encodeURIComponent(e)}/acceptance`),getRunInventory:e=>o(`/runs/${encodeURIComponent(e)}/inventory`),launchRun:e=>o("/runs",{method:"POST",body:JSON.stringify(e)}),previewLinkedIssues:e=>o("/linked-issues/preview",{method:"POST",body:JSON.stringify(e)}),deliverRun:e=>o(`/runs/${encodeURIComponent(e)}/deliver`,{method:"POST"}),confirmGate:(e,t)=>{const r=JSON.stringify(t);return o(`/runs/${encodeURIComponent(e)}/gate`,{method:"POST",body:r,...new TextEncoder().encode(r).length<=he?{keepalive:!0}:{}})},cancelRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/cancel`,t!==void 0&&(t.reason!==void 0||t.input!==void 0)?{method:"POST",body:JSON.stringify(t)}:{method:"POST"}),putGuidance:(e,t)=>o(`/runs/${encodeURIComponent(e)}/guidance`,{method:"PUT",body:JSON.stringify({text:t})}),resumeRun:e=>o(`/runs/${encodeURIComponent(e)}/resume`,{method:"POST"}),openChat:e=>o("/chats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,...fe()})}),sendChatMessage:(e,t,r,s,l)=>o(`/chats/${encodeURIComponent(e)}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,...r!==void 0?{targets:r}:{},...s!==void 0&&s.length>0?{attachments:s}:{},...l!==void 0&&Object.keys(l).length>0?{context:l}:{},...fe()})}),reseatChat:(e,t)=>o(`/chats/${encodeURIComponent(e)}/seats`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clis:t})}),closeChat:e=>o(`/chats/${encodeURIComponent(e)}`,{method:"DELETE"}),getChat:e=>o(`/chats/${encodeURIComponent(e)}`),listChats:()=>o("/chats"),listChatHistory:(e={})=>{const t=new URLSearchParams({limit:String(e.limit??20),status:e.status??"all"});return e.cursor!==void 0&&e.cursor!==null&&e.cursor!==""&&t.set("cursor",e.cursor),o(`/chats?${t.toString()}`)},getChatMessages:e=>o(`/chats/${encodeURIComponent(e)}/messages`),decideChatProposal:(e,t,r)=>o(`/chats/${encodeURIComponent(e)}/proposals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify(r)}),proposeInChat:(e,t)=>o(`/chats/${encodeURIComponent(e)}/proposals`,{method:"POST",body:JSON.stringify(t)}),reviseChatProposal:(e,t)=>o(`/chats/${encodeURIComponent(e)}/proposals`,{method:"POST",body:JSON.stringify(t)}),reshapeRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/reshape`,{method:"POST",body:JSON.stringify(t)}),endChat:e=>o(`/chats/${encodeURIComponent(e)}/close`,{method:"POST"}),uploadChatAttachments:(e,t)=>{const r=new FormData;for(const s of t)r.append("file",s,s.name);return o(`/chats/${encodeURIComponent(e)}/attachments`,{method:"POST",body:r})},getUnitOutput:(e,t)=>o(`/runs/${encodeURIComponent(e)}/units/${encodeURIComponent(t)}/output`),getGate:(e,t)=>o(`/runs/${encodeURIComponent(e)}/gate`,t!==void 0?{signal:t}:void 0),getElicitation:async e=>{try{return await o(`/runs/${encodeURIComponent(e)}/elicitation`)}catch(t){if(ce(t)===404)return null;throw t}},respondToElicitation:(e,t)=>o(`/runs/${encodeURIComponent(e)}/elicitation`,{method:"POST",body:JSON.stringify(t)}),getRoster:e=>o(e===void 0?"/roster":`/roster?refresh=${encodeURIComponent(e)}`),getWatch:(e={})=>{const t=new URLSearchParams;for(const[s,l]of Object.entries(e))l!==void 0&&l!==""&&t.set(s,String(l));const r=t.toString();return o(`/watch${r===""?"":`?${r}`}`)},getSeatRecord:(e=7,t)=>o(`/roster/record?days=${e}${t!==void 0?`&project=${encodeURIComponent(t)}`:""}`),listRepos:()=>o("/repos"),registerRepo:(e,t,r)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,rootPath:t,...r!==void 0?{projectId:r}:{}})}),cloneAndRegisterRepo:(e,t,r,s)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,...r?{rootPath:r}:{},...s!==void 0?{projectId:s}:{}})}),getOnboardRun:e=>o(`/repos/${encodeURIComponent(e)}/onboard`),rerunOnboarding:e=>o(`/repos/${encodeURIComponent(e)}/onboard`,{method:"POST"}),getHealth:()=>o("/health"),openTerminal:e=>o("/terminals",{method:"POST",body:JSON.stringify(e)}),seatLogout:(e,t)=>o(`/seats/${encodeURIComponent(e)}/logout`,{method:"POST",body:JSON.stringify(t)}),seatContainerLogin:(e,t)=>o(`/seats/${encodeURIComponent(e)}/container-login`,{method:"POST",body:JSON.stringify(t)}),closeSeatContainerLogin:e=>o(`/seats/${encodeURIComponent(e)}/container-login`,{method:"DELETE"}),seatContainerLoginOutcome:(e,t)=>o(`/seats/${encodeURIComponent(e)}/container-login`,t===void 0?void 0:{signal:t}),seatContainerLogout:e=>o(`/seats/${encodeURIComponent(e)}/container-logout`,{method:"POST"}),resizeTerminal:(e,t,r)=>o(`/terminals/${encodeURIComponent(e)}/resize`,{method:"POST",body:JSON.stringify({cols:t,rows:r})}),closeTerminal:e=>o(`/terminals/${encodeURIComponent(e)}/close`,{method:"POST"}),openPath:(e,t)=>o("/open",{method:"POST",body:JSON.stringify(t===void 0?{path:e}:{path:e,runId:t})}),getRunFile:(e,t)=>o(`/runs/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}`),getRunDiff:(e,t,r)=>{const s=new URLSearchParams;t!==void 0&&s.set("path",t),r!==void 0&&s.set("base",r);const l=s.toString();return o(`/runs/${encodeURIComponent(e)}/diff${l===""?"":`?${l}`}`)},inspectUnit:(e,t)=>o(`/runs/${encodeURIComponent(e)}/units/${t}/inspect`,{method:"POST",body:"{}"}),getInspections:(e,t)=>o(`/runs/${encodeURIComponent(e)}/units/${t}/inspections`),injectMessage:(e,t,r,s)=>o(`/runs/${encodeURIComponent(e)}/inject`,{method:"POST",body:JSON.stringify(s?.input!==void 0?{message:t,target:r,input:s.input}:{message:t,target:r})}),listWorkflows:()=>o("/workflows"),getWorkflowCatalog:e=>o(e!=null&&e!==""?`${oe}?projectId=${encodeURIComponent(e)}`:oe).catch(t=>{if(t instanceof SyntaxError)return null;throw t}),getWorkflow:e=>o(`/workflows/${encodeURIComponent(e)}`),saveScript:(e,t,r)=>o("/scripts",{method:"POST",body:JSON.stringify({name:e,content:t,lang:r})}),listRequirements:(e,t,r={})=>{const s=new URLSearchParams;return t.q&&s.set("q",t.q),t.mismatch&&s.set("mismatch",t.mismatch),t.risk&&s.set("risk",t.risk),t.category&&s.set("category",t.category),t.domain&&s.set("domain",t.domain),s.set("offset",String(t.offset??0)),s.set("limit",String(t.limit??50)),o(`/repos/${encodeURIComponent(e)}/requirements?${s.toString()}`,r.signal!==void 0?{signal:r.signal}:void 0)},setRequirementsMinimum:(e,t)=>o(`/repos/${encodeURIComponent(e)}/requirements/minimum`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({minPct:t})}),getRequirement:(e,t)=>o(`/repos/${encodeURIComponent(e)}/requirements/${encodeURIComponent(t)}`),patchRequirement:(e,t,r)=>o(`/repos/${encodeURIComponent(e)}/requirements/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),getDomainGraph:()=>o("/domain-graph"),getRepoGraph:(e,t)=>{const r=new URLSearchParams;t?.focus&&r.set("focus",t.focus),t?.limit&&r.set("limit",String(t.limit));const s=r.size>0?`?${r.toString()}`:"";return o(`/repos/${encodeURIComponent(e)}/graph${s}`)},getBlastRadius:(e,t)=>o(`/repos/${encodeURIComponent(e)}/graph/blast-radius?name=${encodeURIComponent(t)}`),getRepoGitHistory:(e,t)=>o(`/repos/${encodeURIComponent(e)}/git-history${t===void 0?"":`?limit=${t}`}`),getDeliverTarget:async e=>{try{return await o(`/repos/${encodeURIComponent(e)}/deliver-target`)}catch{return null}},getRepoContributors:e=>o(`/repos/${encodeURIComponent(e)}/contributors`),getRepoDomainGraph:e=>o(`/repos/${encodeURIComponent(e)}/domain-graph`),listPolicies:()=>o("/governance/policies"),listConformanceRules:()=>o("/governance/rules"),getCoverageReport:()=>o("/governance/coverage"),getCoverageReportForRepo:e=>o(`/governance/coverage?repo=${encodeURIComponent(e)}`),getGraphKindsForRepo:(e,t={})=>o(`/governance/graph?repo=${encodeURIComponent(e)}`,t.signal!==void 0?{signal:t.signal}:void 0),listClaims:()=>o("/governance/claims"),upsertPolicy:e=>o("/governance/policies",{method:"POST",body:JSON.stringify(e)}),upsertConformanceRule:e=>o("/governance/rules",{method:"POST",body:JSON.stringify(e)}),retirePolicy:e=>o(`/governance/policies/${encodeURIComponent(e)}`,{method:"DELETE"}),retireConformanceRule:e=>o(`/governance/rules/${encodeURIComponent(e)}`,{method:"DELETE"}),recallRulesPreview:e=>{const t=new URLSearchParams;for(const[l,h]of Object.entries(e))h&&t.set(l,h);const r=t.toString(),s=r?`?${r}`:"";return o(`/governance/rules/preview${s}`)},getSettings:()=>o("/settings"),updateSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify(e)}),getAppearanceSettings:()=>o("/settings"),putAppearanceSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.appearance":e})}),putNotifSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.notifications":e})}),putComposerSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.composer":e})}),putSetupSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.setup":e})}),putViewSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.view":e})}),putReportShown:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.report":{shown:e}})}),listApps:()=>o("/apps"),listProjects:e=>{const t=e?`?status=${e}`:"";return o(`/projects${t}`)},getProject:e=>o(`/projects/${encodeURIComponent(e)}`),createProject:e=>o("/projects",{method:"POST",body:JSON.stringify(e)}),updateProject:(e,t)=>o(`/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),listProjectMembers:e=>o(`/projects/${encodeURIComponent(e)}/members`),listProjectPrompts:e=>o(`/projects/${encodeURIComponent(e)}/prompts`),attachProjectMember:(e,t)=>o(`/projects/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)}),detachProjectMember:(e,t)=>o(`/projects/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"DELETE"}),getProjectActivity:(e,t)=>{const r=t?`?cursor=${encodeURIComponent(t)}`:"";return o(`/projects/${encodeURIComponent(e)}/activity${r}`)},reassignRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/reassign`,{method:"POST",body:JSON.stringify(t===void 0?{}:{cli:t})}),getProjectGraph:e=>o(`/projects/${encodeURIComponent(e)}/graph`),refreshProjectGraph:(e,t)=>o(`/projects/${encodeURIComponent(e)}/graph/refresh`,{method:"POST",body:JSON.stringify(t??{})})},apiBase:me,apiFetch:o,apiStatus:ce,translateWireError:ae},Symbol.toStringTag,{value:"Module"})),Y=e=>e==null?"null":typeof e=="string"?e:JSON.stringify(e);function je(e,t){switch(e.type){case"number":return Math.round((t+1)*13.7*10)/10;case"integer":return(t+1)*7;case"boolean":return t%2===0;case"date":return`2026-10-${String(10+t).padStart(2,"0")}`;case"datetime":return`2026-10-${String(10+t).padStart(2,"0")}T09:30:00Z`;default:return`${e.name.replace(/_/g," ")} ${t+1}`}}function Ne(e,t){const r=Object.assign(Object.create(null),structuredClone(t?.rows??{})),s=null,l="you",h=new Map;let x=0;const P=(y,f)=>y.kind==="param"?{value:f[y.name]??null,from:"from the app"}:y.kind==="literal"?{value:y.value,from:"fixed by the app"}:y.kind==="viewer"?{value:y.claim==="name"?l.split("@")[0]:l,from:"your sign-in"}:{value:y.value==="now"?new Date().toISOString():"a new uuid",from:`filled by studio: ${y.value}`};return{kind:{queries:"sample",actions:"sample"},async query(y,f,g){const d=e().queries.find(C=>C.id===f);if(d===void 0)return{error:"refused",message:`this version has no query ${f}`};Object.hasOwn(r,f)||(r[f]=[0,1,2].map(C=>d.output.map(L=>je(L,C))));let _=r[f];const N=Object.values(g).filter(C=>typeof C=="string"&&C.trim()!==""&&C!=="all");return N.length>0&&(_=_.filter(C=>N.every(L=>C.some(q=>typeof q=="string"&&q.toLowerCase().includes(L.toLowerCase()))))),{columns:d.output,rows:structuredClone(_),truncated:!1,hasMore:!1,ms:1,cachedAt:null,sample:!0}},async prepare(y,f,g){const d=e().actions.find($=>$.id===f);if(d===void 0)return{error:"refused",message:`this version has no action ${f}`};const _=[];let N,C,L=null,q=null;if(d.kind==="row-write"){const $=Object.entries(d.set??{});for(const[u,p]of $){const k=P(p,g);_.push({label:u,value:Y(k.value),from:k.from})}L=`${Object.entries(d.key).map(([u,p])=>`${u} = ${Y(g[p.name])}`).join(", ")} (exactly 1 row)`,q="Sample: no table was checked. A real run checks a plain table (no triggers, rules, inheritance or row security) just before it writes.",N=`${d.op.toUpperCase()} ${d.table}`;const c=$.length;C=d.op==="update"?`UPDATE ONLY ${d.table} AS w SET ${$.map(([u],p)=>`${u} = $${p+1}`).join(", ")} WHERE ${Object.keys(d.key).map((u,p)=>`w.${u} = $${c+p+1}`).join(" AND ")}`:d.op==="delete"?`DELETE FROM ONLY ${d.table} AS w WHERE ${Object.keys(d.key).map((u,p)=>`w.${u} = $${p+1}`).join(" AND ")}`:`INSERT INTO ${d.table} (${$.map(([u])=>u).join(", ")}) VALUES (${$.map((u,p)=>`$${p+1}`).join(", ")})`}else{for(const[$,a]of Object.entries(d.args)){const c=P(a,g);_.push({label:$,value:Y(c.value),from:c.from})}N=d.call.kind==="tool"?d.call.tool:`mutation ${d.call.mutation.slice(0,60)}`,C=`${N}
|
|
10
|
+
${JSON.stringify(Object.fromEntries(_.map($=>[$.label,$.value])),null,1)}`}x+=1;const A=`sample-${x}`,J=Date.now()+12e4;return h.set(A,{action:d,params:g,expiresAt:J}),{record:A,expiresAt:J,card:{action:d.id,kind:d.kind,source:`${d.source} (sample)`,operation:N,rows:_,key:L,checks:q,request:C,says:d.description??null,sample:!0}}},async run(y,f){const g=h.get(f);if(h.delete(f),g===void 0||g.action.id!==y)return{state:"failed",reason:"this card was not prepared here",sample:!0};if(Date.now()>g.expiresAt)return{state:"failed",reason:"the card expired; nothing was written",sample:!0};if(g.action.kind==="row-write"&&g.action.op==="update"){const _=g.action;for(const N of e().queries){const C=N.output.map(A=>A.name),L=Object.entries(_.key),q=Object.hasOwn(r,N.id)?r[N.id]:void 0;if(!(q===void 0||!L.every(([A])=>C.includes(A)))){for(const A of q)if(L.every(([J,$])=>Y(A[C.indexOf(J)])===Y(g.params[$.name])))for(const[J,$]of Object.entries(_.set??{}))C.includes(J)&&(A[C.indexOf(J)]=P($,g.params).value)}}}return{state:"succeeded",reason:g.action.kind==="row-write"&&g.action.op==="update"?"Sample data: the sample rows in this tab changed; no source was touched":"Sample data: nothing was written and no rows changed",sample:!0}},viewer:()=>({email:s,sample:!0})}}const re="wicked.editor",se=1,Ae=/^[A-Z]{3}$/u;function xe(e,t,r){if(e==null)return"";if(typeof e=="boolean")return e?"yes":"no";const s=void 0,l=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))?Number(e):null;try{switch(t?.kind){case"currency":if(l===null||!Ae.test(t.currency))break;return new Intl.NumberFormat(r,{style:"currency",currency:t.currency,...s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}}).format(l);case"percent":if(l===null)break;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:s??1}).format(l);case"number":if(l===null)break;return new Intl.NumberFormat(r,s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}).format(l);case"date":case"datetime":{const h=new Date(typeof e=="number"?e:String(e));if(Number.isNaN(h.getTime()))break;return new Intl.DateTimeFormat(r,t.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(h)}case"duration":{if(l===null)break;const h=Math.abs(Math.round(l)),x=Math.floor(h/86400),P=Math.floor(h%86400/3600),y=Math.floor(h%3600/60);return x>0?`${x}d ${P}h`:P>0?`${P}h ${y}m`:`${y}m`}default:break}}catch{}return typeof e=="number"?Number.isInteger(e)?String(e):new Intl.NumberFormat(r,{maximumFractionDigits:6}).format(e):String(e)}function qe(e,t){if(e===void 0||t===null||t===void 0)return t;if((e.type==="number"||e.type==="integer")&&typeof t=="string"&&t.trim()!==""){const r=Number(t);return Number.isFinite(r)&&(e.type==="number"||Number.isInteger(r))?r:t}return e.type==="boolean"&&typeof t=="string"&&(t==="true"||t==="false")?t==="true":e.type==="string"&&(typeof t=="number"||typeof t=="boolean")?String(t):t}const X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ge=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function ye(e,t,r){const s=Object.entries(r).sort(([f],[g])=>f.localeCompare(g)),l=JSON.stringify([t,s]);let h=0;for(const f of l)h=Math.imul(h,31)+f.charCodeAt(0)>>>0;const x=e.queries.find(f=>f.id===t),P=s.map(([,f])=>f).filter(f=>typeof f=="string").join(" "),y=[0,1,2].map(f=>(x?.output??[]).map(g=>{const d=h%1e3+f+1;switch(g.type){case"number":return d/10;case"integer":return d;case"boolean":return d%2===0;case"date":return`2026-10-${String(10+f).padStart(2,"0")}`;case"datetime":return`2026-10-${String(10+f).padStart(2,"0")}T09:30:00Z`;default:return`${P} ${g.name} ${d}`.trim()}}));return Ne(()=>e,{rows:{[t]:y}}).query(1,t,r)}async function Le(){const e=Date.parse("2026-10-15T12:00:00Z");window.Date=new Proxy(Date,{construct:(a,c)=>Reflect.construct(a,c.length===0?[e]:c),apply:a=>new a(e).toString(),get:(a,c,u)=>c==="now"?()=>e:Reflect.get(a,c,u)});let t;const r=new Map,s=new Map;let l,h=0,x=0,P=0,y=null;const f=new Map,g=a=>{const c=a instanceof Error?a.message:String(a);$.errors.includes(c)||$.errors.push(c)},d=async a=>{try{await a()}catch(c){throw g(c),c}},_=a=>{const c=t.spec.pages.find(u=>u.id===a);if(c===void 0)throw new Error(`This app has no page ${a}`);return c},N=a=>{const c=[...document.querySelectorAll("[data-component]")].find(u=>u.dataset.component===a);if(c===void 0)throw new Error(`This page has no filter ${a}`);return c},C=a=>a.filter==="search"?["fixture"]:a.filter==="date-range"?["2026-10-01/2026-10-31"]:a.options?.kind==="values"?a.options.values.map(c=>c.value):[...s.get(a.id)??[]],L=async()=>{for(const a of t.spec.pages)for(const c of a.components){if(c.type!=="filter"||c.options?.kind!=="query")continue;const u=c.options,p=t.spec.queries.find(S=>S.id===u.query.query),k={};for(const[S,D]of Object.entries(u.query.params??{})){const[Z,V,G]=D.split("."),B=Z==="filter"&&V!==void 0?r.get(V):void 0,E=typeof B=="string"?G===void 0?B:void 0:G==="from"?B?.from:G==="to"?B?.to:void 0,W=p?.params?.properties??{};E!==void 0&&E!==""&&(k[S]=qe(Object.hasOwn(W,S)?W[S]:void 0,E))}const w=await ye(t.spec,u.query.query,k);if("error"in w)throw new Error(w.message);const O=w.columns.findIndex(S=>S.name===u.value);s.set(c.id,w.rows.slice(0,200).map(S=>xe(S[O],void 0,"en")).filter(S=>S!==""))}},q=()=>new Promise((a,c)=>{const u=`fixture-${++P}`,p=setTimeout(()=>{f.delete(u),c(new Error("The runtime did not answer"))},5e3);f.set(u,()=>{clearTimeout(p),a()}),l.postMessage({p:re,v:se,type:"host.ping",id:u,payload:{}})}),A=async()=>{const a=performance.now()+5e3;let c=0;for(;c<2;){const u=h;if(await q(),await ge(),await ge(),c=x===0&&u===h?c+1:0,performance.now()>a)throw new Error("The fixture did not finish rendering")}for(const u of document.querySelectorAll(".wk-error"))u.textContent&&g(u.textContent)},J=a=>{if(!t.spec.actions.some(O=>O.id===a))throw new Error(`This app has no action ${a}`);const c=Array.isArray(t.cards)?t.cards.find(O=>O.action===a):Object.hasOwn(t.cards,a)?t.cards[a]:void 0;if(c===void 0)throw new Error(`The fixture has no card for ${a}`);y?.remove(),y=document.createElement("div"),y.className="wk-fixture-card";const u=document.createElement("section");u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-label",`Prepare ${a}`),u.setAttribute("data-testid","apps-card");const p=document.createElement("h2");p.textContent=`Prepare ${a}`;const k=document.createElement("pre");k.textContent=typeof c=="string"?c:JSON.stringify(c,null,2);const w=document.createElement("button");w.type="button",w.textContent="Close",w.addEventListener("click",()=>{$.closeCard()}),u.append(p,k,w),y.append(u),document.body.append(y),w.focus()},$={ready:!1,errors:[],pages:()=>t.spec.pages.map(a=>a.id),filters:a=>_(a).components.filter(c=>c.type==="filter").map(c=>({id:c.id,values:C(c)})),actions:a=>[...new Set(_(a).components.flatMap(c=>c.type==="button"?[c.action.action]:c.type==="form"?[c.submit.action]:c.type==="table"?(c.rowActions??[]).map(u=>u.action):[]))],show:a=>d(async()=>{const c=t.spec.pages.indexOf(_(a)),u=document.querySelectorAll(".wk-page")[c];if(u===void 0)throw new Error(`The runtime did not draw page ${a}`);u.click(),await A()}),setFilter:(a,c)=>d(async()=>{const u=t.spec.pages.find(w=>w.components.some(O=>O.id===a&&O.type==="filter"));if(u===void 0)throw new Error(`This app has no filter ${a}`);await $.show(u.id);const p=N(a),k=p.querySelector("select");if(k!==null){if(![...k.options].some(w=>w.value===c))throw new Error(`This filter has no value ${c}`);k.value=c,r.set(a,c),k.dispatchEvent(new Event("change",{bubbles:!0}))}else{const w=[...p.querySelectorAll("input")],O=w.length===2?c.split("/"):[c];if(w.length===0||O.length!==w.length)throw new Error("A date range needs from/to");for(const[S,D]of w.entries())D.value=O[S],D.dispatchEvent(new Event(D.type==="search"?"input":"change",{bubbles:!0}));r.set(a,w.length===2?{from:w[0].value,to:w[1].value}:w[0].value),w[0]?.type==="search"&&await new Promise(S=>setTimeout(S,310))}await L(),await A()}),prepare:a=>d(async()=>{J(a),await A()}),closeCard:()=>d(async()=>{y?.remove(),y=null,await A()})};window.__wkFixture=$,window.addEventListener("error",a=>g(a.message)),window.addEventListener("unhandledrejection",a=>g(a.reason));try{const a=await fetch("./fixture.json",{credentials:"omit",redirect:"error"});if(!a.ok)throw new Error("The fixture could not be read");t=await a.json();for(const u of t.spec.pages)for(const p of u.components)if(p.type==="filter")if(p.filter==="date-range"){const k=X(p.default)&&Number.isInteger(p.default.lastDays)?Math.min(3650,Math.max(1,p.default.lastDays)):30;r.set(p.id,{from:new Date(e-k*864e5).toISOString().slice(0,10),to:new Date(e).toISOString().slice(0,10)})}else r.set(p.id,typeof p.default=="string"?p.default:"");await L();const c=new MessageChannel;if(l=c.port1,l.onmessage=u=>{const p=u.data;if(!X(p)||p.p!==re||p.v!==se)return;if(typeof p.re=="string"){f.get(p.re)?.(),f.delete(p.re);return}if(typeof p.id!="string")return;const k=p.id,w=X(p.payload)?p.payload:{},O=(S,D)=>{l.postMessage({p:re,v:se,re:k,ok:D===void 0,payload:S,...D===void 0?{}:{error:D}})};switch(h+=1,p.type){case"artifact.read":O({version:1,content:{type:"app",spec:t.spec,readonly:!0}});return;case"data.query":{x+=1,ye(t.spec,String(w.query),X(w.params)?w.params:{}).then(S=>{"error"in S?(g(S.message),O({},{code:S.error,message:S.message})):O(S)}).catch(S=>{g(S),O({},{code:"unavailable",message:"The fixture query failed"})}).finally(()=>{x-=1,h+=1});return}case"data.action":try{J(String(w.action)),O({state:"cancelled"})}catch(S){g(S),O({},{code:"refused",message:String(S)})}return;default:O({},{code:"unsupported",message:"The fixture only reads and prepares"});return}},window.wickedAppsStandalone.boot(c.port2,{protocol:2,surface:"full",size:"full",grants:["artifact.read","data.read","data.write"],app:{framed:!1,mode:"preview",url:{}},prefs:{locale:"en"},theme:{}}),await A(),document.querySelector(".wk-page")===null)throw new Error("The runtime did not draw a page");$.ready=$.errors.length===0}catch(a){g(a)}}Le()})();
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
html, body { height: 100%; margin: 0; }
|
|
15
15
|
body { font: 13px/1.4 var(--font-sans); color: var(--ink-high); background: var(--surface-base); overflow: hidden; }
|
|
16
16
|
.wk-app { display: flex; height: 100%; min-width: 0; }
|
|
17
|
-
.wk-main { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 14px 18px 24px; }
|
|
17
|
+
.wk-main { flex: 1 1 auto; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 14px 18px 24px; }
|
|
18
18
|
.wk-app[data-mode="edit"] .wk-main {
|
|
19
19
|
background-image: radial-gradient(circle, color-mix(in srgb, var(--ink-muted) 28%, transparent) 1px, transparent 1px);
|
|
20
20
|
background-size: 16px 16px;
|
|
21
21
|
}
|
|
22
|
-
.wk-pages { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
|
|
23
|
-
.wk-page { font: inherit; font-size: 14px; padding: 6px 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-muted); cursor: pointer; }
|
|
22
|
+
.wk-pages { display: flex; min-width: 0; max-width: 100%; overflow-x: auto; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
|
|
23
|
+
.wk-page { flex: 0 0 auto; white-space: nowrap; font: inherit; font-size: 14px; padding: 6px 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-muted); cursor: pointer; }
|
|
24
24
|
.wk-page.is-on { color: var(--ink-high); border-bottom-color: var(--ink-high); font-weight: 600; }
|
|
25
25
|
.wk-page:focus-visible, .wk-btn:focus-visible, .wk-tile:focus-visible, .wk-link:focus-visible, .wk-cell:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
|
|
26
26
|
.wk-grid { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: var(--row); gap: var(--gap); }
|
|
@@ -43,9 +43,14 @@
|
|
|
43
43
|
.wk-kpi-caption { margin-top: 4px; font-size: 12px; color: var(--ink-muted); }
|
|
44
44
|
.wk-delta--up { color: var(--status-fail); }
|
|
45
45
|
.wk-delta--down { color: var(--status-ok); }
|
|
46
|
+
.wk-table-scroll { min-width: 0; max-width: 100%; overflow-x: auto; }
|
|
46
47
|
.wk-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
47
48
|
.wk-table th { text-align: left; font-weight: 500; color: var(--ink-muted); padding: 4px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
|
|
48
|
-
.wk-table td { padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); color: var(--ink-high); overflow-wrap:
|
|
49
|
+
.wk-table td { padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); color: var(--ink-high); overflow-wrap: normal; word-break: normal; vertical-align: top; }
|
|
50
|
+
.wk-table td.wk-token { white-space: nowrap; }
|
|
51
|
+
.wk-table td.wk-token--long { max-width: 48ch; overflow: hidden; text-overflow: ellipsis; }
|
|
52
|
+
.wk-table-scroll:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
|
|
53
|
+
.wk-table td.wk-prose { min-width: 16ch; max-width: 60ch; white-space: normal; }
|
|
49
54
|
.wk-table td.wk-num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
|
|
50
55
|
.wk-td-actions { white-space: nowrap; text-align: right; }
|
|
51
56
|
.wk-td-actions .wk-btn + .wk-btn { margin-left: 4px; }
|
|
@@ -63,6 +68,32 @@
|
|
|
63
68
|
.wk-text--heading { font-size: 18px; font-weight: 650; }
|
|
64
69
|
.wk-text--caption { font-size: 12px; color: var(--ink-muted); }
|
|
65
70
|
.wk-filter { display: flex; align-items: center; gap: 6px; height: 100%; }
|
|
71
|
+
.wk-filter-select { display: flex; align-items: center; gap: 6px; min-width: 0; height: 100%; container: wkfilter / inline-size; }
|
|
72
|
+
/* A select with an option search shares its one row: the label gives way first (an ellipsis, its full words in its
|
|
73
|
+
title), the select and the search each keep 6ch, so nothing overlaps; in a narrow filter (the default three
|
|
74
|
+
columns) the count leaves the row (it stays in the select's last option and for screen readers). A select without
|
|
75
|
+
a search keeps its layout and its label. */
|
|
76
|
+
.wk-filter-select--search .wk-filter-label { flex: 0 1 auto; min-width: 3ch; overflow: hidden; text-overflow: ellipsis; }
|
|
77
|
+
.wk-filter-select--search .wk-filter .wk-input { flex: 1 1 0; width: 0; min-width: 6ch; }
|
|
78
|
+
/* (specificity over the shorthand below) The select's group takes 3/5 of the row; neither group draws over the other. */
|
|
79
|
+
.wk-filter-select.wk-filter-select--search > .wk-filter { flex-grow: 3; overflow: clip; overflow-clip-margin: 4px; }
|
|
80
|
+
.wk-filter-select.wk-filter-select--search > .wk-filter-options { flex-grow: 2; overflow: clip; overflow-clip-margin: 4px; }
|
|
81
|
+
.wk-filter-select--search .wk-filter-options .wk-input { flex: 1 1 0; min-width: 6ch; }
|
|
82
|
+
@container wkfilter (max-width: 300px) {
|
|
83
|
+
.wk-filter-select--search .wk-filter-options .wk-muted { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
84
|
+
}
|
|
85
|
+
/* A narrow searchable filter (200px or less: the default three columns): the label leaves the row (it still names the
|
|
86
|
+
select), and the select and the search split the row 1:1 with no ch floors, so neither can overflow the cell
|
|
87
|
+
whatever the font's ch (WebKit's is wider: the floors pushed a control out of a three-column filter there). */
|
|
88
|
+
@container wkfilter (max-width: 200px) {
|
|
89
|
+
.wk-filter-select--search .wk-filter-label { position: absolute; width: 1px; height: 1px; min-width: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
90
|
+
.wk-filter-select.wk-filter-select--search > .wk-filter, .wk-filter-select.wk-filter-select--search > .wk-filter-options { flex-grow: 1; }
|
|
91
|
+
.wk-filter-select--search .wk-filter .wk-input, .wk-filter-select--search .wk-filter-options .wk-input { min-width: 0; }
|
|
92
|
+
}
|
|
93
|
+
.wk-filter-select .wk-filter { height: auto; flex: 1 1 0; min-width: 0; }
|
|
94
|
+
.wk-filter-options { display: flex; flex: 1 1 0; min-width: 0; align-items: center; gap: 6px; }
|
|
95
|
+
.wk-filter-options .wk-muted { flex: 0 0 auto; white-space: nowrap; }
|
|
96
|
+
.wk-filter-options .wk-input { width: 0; flex: 1 1 100px; }
|
|
66
97
|
.wk-filter-label { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }
|
|
67
98
|
.wk-input { font: inherit; min-width: 0; flex: 1 1 auto; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-raised); color: var(--ink-high); }
|
|
68
99
|
.wk-input--date { flex: 0 1 140px; }
|
|
@@ -108,7 +139,7 @@
|
|
|
108
139
|
.wk-prop-label { font-size: 12px; color: var(--ink-muted); }
|
|
109
140
|
.wk-prop-box { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
|
110
141
|
.wk-check { align-self: flex-start; }
|
|
111
|
-
.wk-cell, .wk-handle { touch-action: none; }
|
|
142
|
+
.wk-app[data-mode="edit"] .wk-cell, .wk-handle { touch-action: none; }
|
|
112
143
|
/* Edit in place: a component's own words show they can be edited (an outline and a pencil on hover). */
|
|
113
144
|
.wk-app[data-mode="edit"] .wk-editable { cursor: text; border-radius: 3px; }
|
|
114
145
|
.wk-app[data-mode="edit"] .wk-editable:hover { outline: 1px dashed var(--ui-accent); outline-offset: 2px; }
|
|
@@ -130,6 +161,8 @@
|
|
|
130
161
|
.wk-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
|
|
131
162
|
.wk-grid > .wk-cell { grid-column: 1 !important; grid-row: auto !important; min-height: var(--row); }
|
|
132
163
|
.wk-cell--chart, .wk-cell--table { min-height: 220px; }
|
|
164
|
+
.wk-filter-select { flex-wrap: wrap; height: auto; }
|
|
165
|
+
.wk-filter-select .wk-filter, .wk-filter-options { flex-basis: 100%; }
|
|
133
166
|
.wk-palette, .wk-props { display: none; }
|
|
134
167
|
}
|
|
135
168
|
/* The fixture's card sits outside the app, as the site host's card does. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var wickedAppsStandalone=(function(le){"use strict";var Zt=Object.defineProperty;var Wt=(le,Q,Pe)=>Q in le?Zt(le,Q,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):le[Q]=Pe;var Ne=(le,Q,Pe)=>Wt(le,typeof Q!="symbol"?Q+"":Q,Pe);const Q="wicked.editor";function mt(c,u,h){return{editor:c,version:u,protocol:[1,2],surfaces:h}}function wt(c,u){const h=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:Q,v:1,type:"plugin.ready",payload:mt(c,h,u)},"*")}const yt=/^[A-Z]{3}$/u;function ue(c,u,h){if(c==null)return"";if(typeof c=="boolean")return c?"yes":"no";const w=typeof u?.decimals=="number"&&Number.isInteger(u.decimals)?Math.min(10,Math.max(0,u.decimals)):void 0,m=typeof c=="number"?c:typeof c=="string"&&c.trim()!==""&&Number.isFinite(Number(c))?Number(c):null;try{switch(u?.kind){case"currency":if(m===null||!yt.test(u.currency))break;return new Intl.NumberFormat(h,{style:"currency",currency:u.currency,...w!==void 0?{minimumFractionDigits:w,maximumFractionDigits:w}:{}}).format(m);case"percent":if(m===null)break;return new Intl.NumberFormat(h,{style:"percent",maximumFractionDigits:w??1}).format(m);case"number":if(m===null)break;return new Intl.NumberFormat(h,w!==void 0?{minimumFractionDigits:w,maximumFractionDigits:w}:{}).format(m);case"date":case"datetime":{const O=new Date(typeof c=="number"?c:String(c));if(Number.isNaN(O.getTime()))break;return new Intl.DateTimeFormat(h,u.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(O)}case"duration":{if(m===null)break;const O=Math.abs(Math.round(m)),b=Math.floor(O/86400),x=Math.floor(O%86400/3600),Z=Math.floor(O%3600/60);return b>0?`${b}d ${x}h`:x>0?`${x}h ${Z}m`:`${Z}m`}default:break}}catch{}return typeof c=="number"?Number.isInteger(c)?String(c):new Intl.NumberFormat(h,{maximumFractionDigits:6}).format(c):String(c)}function T(c,u=200){return typeof c=="string"?c.replace(/[\u0000-\u001f\u007f]+/gu," ").slice(0,u):""}const bt="http://www.w3.org/2000/svg";function G(c,u,h){const w=document.createElementNS(bt,c);for(const[m,O]of Object.entries(u))w.setAttribute(m,String(O));return h!==void 0&&w.setAttribute("class",h),w}function Re(c,u,h,w,m="start"){const O=G("text",{x:c,y:u,"text-anchor":m},w);return O.textContent=h,O}function ge(c){return typeof c=="number"?Number.isFinite(c)?c:0:typeof c=="string"&&c.trim()!==""&&Number.isFinite(Number(c))?Number(c):0}const _=c=>Math.round(c*10)/10;function _e(c,u){const h=document.createElement("ul");h.className="wk-legend",u.forEach((w,m)=>{const O=document.createElement("li"),b=document.createElement("span");b.className=`wk-swatch wk-series-${m%12}`,O.append(b,document.createTextNode(w)),h.append(O)}),c.append(h)}function gt(c,u,h,w){const m=y=>h.columns.findIndex(g=>g.name===y),O=m(u.x),b=u.series.slice(0,u.chart==="pie"?1:12).map(y=>({label:T(y.label??y.column,60),i:m(y.column)})).filter(y=>y.i>=0),x=h.rows.slice(0,500);if(O<0||b.length===0||x.length===0){const y=document.createElement("p");y.className="wk-empty",y.textContent=x.length===0?"No rows":"This chart’s columns are not in its query’s rows",c.append(y);return}const Z=x.map(y=>ue(y[O],void 0,w));if(u.chart==="bar"){const y=u.stacked===!0&&b.length>1,g=x.map(I=>b.map(P=>ge(I[P.i])));let v=0,E=0;for(const I of g)if(y)E=Math.max(E,I.filter(P=>P>0).reduce((P,H)=>P+H,0)),v=Math.min(v,I.filter(P=>P<0).reduce((P,H)=>P+H,0));else for(const P of I)E=Math.max(E,P),v=Math.min(v,P);E===v&&(E=v+1);const q=130,A=b.length>1?250:220,L=I=>q+(I-v)/(E-v)*A,R=L(0),S=y||b.length===1?26:Math.max(26,b.length*10+10),N=G("svg",{viewBox:`0 0 400 ${x.length*S+4}`,role:"img","aria-label":T(u.title??"bar chart",120)},"wk-chart wk-chart--bar");v<0&&N.append(G("line",{x1:_(R),x2:_(R),y1:0,y2:x.length*S+4},"wk-grid-line")),x.forEach((I,P)=>{const H=P*S+2;if(N.append(Re(0,_(H+S/2+4),Z[P].slice(0,22),"wk-axis")),y){let me=0,oe=0;b.forEach((we,de)=>{const se=g[P][de],U=se>=0?me:oe+se,He=se>=0?me+se:oe;se>=0?me+=se:oe+=se,N.append(G("rect",{x:_(L(U)),y:H+4,width:_(Math.max(1,L(He)-L(U))),height:S-10},`wk-series-${de%12}`))});return}const re=(S-8)/b.length;b.forEach((me,oe)=>{const we=g[P][oe],de=Math.min(L(we),R),se=Math.max(1,Math.abs(L(we)-R));N.append(G("rect",{x:_(de),y:_(H+4+oe*re),width:_(se),height:_(Math.max(2,re-2)),rx:2},`wk-series-${oe%12}`)),b.length===1&&N.append(Re(_(we<0?de-6:de+se+6),_(H+S/2+4),ue(I[me.i],void 0,w),"wk-value",we<0?"end":"start"))})}),c.append(N),b.length>1&&_e(c,b.map(I=>I.label));return}if(u.chart==="pie"){const y=b[0],g=x.reduce((q,A)=>q+Math.max(0,ge(A[y.i])),0)||1,v=G("svg",{viewBox:"0 0 240 240",role:"img","aria-label":T(u.title??"pie chart",120)},"wk-chart wk-chart--pie");let E=-Math.PI/2;x.forEach((q,A)=>{const L=Math.max(0,ge(q[y.i]))/g,R=E+L*Math.PI*2,S=R-E>Math.PI?1:0,N=P=>`${_(120+100*Math.cos(P))} ${_(120+100*Math.sin(P))}`,I=L>=.9999?"M 120 20 A 100 100 0 1 1 119.9 20 Z":`M 120 120 L ${N(E)} A 100 100 0 ${S} 1 ${N(R)} Z`;v.append(G("path",{d:I},`wk-series-${A%12}`)),E=R}),c.append(v),_e(c,Z.slice(0,12));return}const ve=600,ce=220,W=36,ke=24,ee=u.chart==="area"&&u.stacked===!0&&b.length>1,X=[],D=new Map;x.forEach((y,g)=>{if(X.push(g),!ee||g+1>=x.length)return;const v=new Map;b.forEach((E,q)=>{const A=ge(x[g][E.i]),L=ge(x[g+1][E.i]);if(A>0&&L<0||A<0&&L>0){const R=A/(A-L);v.set(R,[...v.get(R)??[],q])}});for(const E of[...v.keys()].sort((q,A)=>q-A))D.set(X.length,new Set(v.get(E))),X.push(g+E)});const xe=(y,g)=>{if(D.get(g)?.has(y)===!0)return 0;const v=X[g],E=Math.floor(v),q=v-E,A=ge(x[E][b[y].i]);return q===0||E+1>=x.length?A:A+(ge(x[E+1][b[y].i])-A)*q},B=b.map(()=>[]),C=b.map(()=>[]);let Y=0,fe=1;const Ee=y=>{y<Y&&(Y=y),y>fe&&(fe=y)};X.forEach((y,g)=>{let v=0,E=0;b.forEach((q,A)=>{const L=xe(A,g);if(!ee){B[A][g]=[0,L],C[A][g]=[0,0],Ee(L);return}const R=Math.max(0,L),S=Math.min(0,L);B[A][g]=[v,v+R],C[A][g]=[E+S,E],v+=R,E+=S,Ee(v),Ee(E)})});const te=fe,pe=Y,qe=y=>W+(x.length===1?0:y/(x.length-1)*(ve-W-8)),he=y=>ce-ke-(y-pe)/(te-pe||1)*(ce-ke-10),ne=G("svg",{viewBox:`0 0 ${ve} ${ce}`,role:"img","aria-label":T(u.title??`${u.chart} chart`,120)},`wk-chart wk-chart--${u.chart}`);for(let y=0;y<=3;y+=1){const g=pe+(te-pe)*y/3;ne.append(G("line",{x1:W,x2:ve-8,y1:_(he(g)),y2:_(he(g))},"wk-grid-line")),ne.append(Re(W-6,_(he(g)+4),ue(Math.round(g*10)/10,void 0,w),"wk-axis","end"))}const Te=x.length<=4?x.map((y,g)=>g):[0,Math.floor((x.length-1)/3),Math.floor((x.length-1)*2/3),x.length-1];for(const y of Te)ne.append(Re(_(qe(y)),ce-6,Z[y].slice(0,14),"wk-axis",y===0?"start":y===x.length-1?"end":"middle"));b.forEach((y,g)=>{const v=(S,N)=>`${_(qe(X[S]))},${_(he(N))}`;if(u.chart==="area"){const S=N=>{const I=X.map((H,re)=>v(re,N[re][1])),P=X.map((H,re)=>v(re,N[re][0])).reverse();return`M ${I.join(" L ")} L ${P.join(" L ")} Z`};ne.append(G("path",{d:S(B[g])},`wk-area wk-series-${g}`)),ee&&C[g].some(([N,I])=>N!==I)&&ne.append(G("path",{d:S(C[g])},`wk-area wk-area--neg wk-series-${g}`))}if(!ee){ne.append(G("polyline",{points:X.map((S,N)=>v(N,xe(g,N))).join(" "),fill:"none"},`wk-stroke wk-series-${g}`));return}const E=[];let q=null,A=0,L=[];const R=(S,N)=>S<0?v(N,C[g][N][0]):v(N,B[g][N][1]);X.forEach((S,N)=>{const I=xe(g,N);if(D.get(N)?.has(g)===!0||I===0){q!==null&&q.push(R(A,N)),L.push(N);return}const P=I>0?1:-1;if(q===null)q=L.map(H=>R(P,H)),E.push(q),A=P;else if(P!==A){const H=L[L.length-1];q=H!==void 0?[R(P,H)]:[],E.push(q),A=P}q.push(R(P,N)),L=[]}),q===null&&L.length>1&&E.push(L.map(S=>R(1,S)));for(const S of E)S.length>1&&ne.append(G("polyline",{points:S.join(" "),fill:"none"},`wk-stroke wk-series-${g}`))}),c.append(ne),b.length>1&&_e(c,b.map(y=>y.label))}const vt=/^#[0-9a-fA-F]{6}$/u,Ve=/^(?::root|\.wk-c\d{1,4}(?: \.wk-[a-z]+)?)$/u,kt=/^(?:--[a-z0-9-]{1,40}|[a-z-]{1,40})$/u,xt="(max-width: 639px)";function Be(c){return typeof c=="string"&&vt.test(c)?c.toLowerCase():null}function $e(c,u,h,w){return Number.isInteger(c)?Math.min(h,Math.max(u,c)):w}function Et(c){return typeof c=="string"&&c.length<=200&&!/url\(|[;{}]|\/\*|\\/iu.test(c)?c:null}class Mt{constructor(u){Ne(this,"sheet");Ne(this,"base");Ne(this,"rules",new Map);Ne(this,"phone",null);Ne(this,"phoneRules",new Map);if(u.sheet===null)throw new Error("the runtime stylesheet did not load");this.sheet=u.sheet,this.base=this.sheet.cssRules.length}reset(){for(;this.sheet.cssRules.length>this.base;)this.sheet.deleteRule(this.sheet.cssRules.length-1);this.rules.clear(),this.phoneRules.clear(),this.phone=null}rule(u){if(!Ve.test(u))throw new Error("a selector outside the runtime’s vocabulary");const h=this.rules.get(u);if(h!==void 0)return h;const w=this.sheet.insertRule(`${u} {}`,this.sheet.cssRules.length),m=this.sheet.cssRules[w];return this.rules.set(u,m),m}phoneRule(u){if(!Ve.test(u))throw new Error("a selector outside the runtime’s vocabulary");const h=this.phoneRules.get(u);if(h!==void 0)return h;if(this.phone===null){const O=this.sheet.insertRule(`@media ${xt} {}`,this.sheet.cssRules.length);this.phone=this.sheet.cssRules[O]}const w=this.phone.insertRule(`${u} {}`,this.phone.cssRules.length),m=this.phone.cssRules[w];return this.phoneRules.set(u,m),m}set(u,h,w){kt.test(h)&&u.style.setProperty(h,w)}theme(u,h){const w=this.rule(":root");for(const[b,x]of Object.entries(u)){const Z=Et(x);/^--[a-z0-9-]{1,40}$/u.test(b)&&Z!==null&&this.set(w,b,Z)}const m=Be(h.accent);m!==null&&this.set(w,"--app-accent",m),h.density==="compact"&&(this.set(w,"--row","36px"),this.set(w,"--gap","8px"));const O=Array.isArray(h.palette)?h.palette:[];for(let b=0;b<12;b+=1){const x=Be(O[b]);x!==null&&this.set(w,`--s${b}`,x)}}place(u,h){const w=this.rule(`.wk-c${u}`),m=$e(h.x,0,11,0),O=$e(h.w,1,12-m,1),b=$e(h.y,0,999,0),x=$e(h.h,1,50,1);this.set(w,"grid-column",`${m+1} / span ${O}`),this.set(w,"grid-row",`${b+1} / span ${x}`)}phoneOrder(u,h,w){const m=this.phoneRule(`.wk-c${u}`);this.set(m,"order",String($e(h,0,9999,0))),w?this.set(m,"display","none"):m.style.removeProperty("display")}seriesColour(u,h,w){const m=Be(w);m!==null&&this.set(this.rule(`.wk-c${u}`),`--c${$e(h,0,11,0)}`,m)}}const At={comfortable:44,compact:36},Ge={comfortable:12,compact:8},$t=450,Je=500,Lt=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/u,Oe=()=>Object.create(null);function St(c,u){if(c===void 0||u===null||u===void 0)return u;if((c.type==="number"||c.type==="integer")&&typeof u=="string"&&u.trim()!==""){const h=Number(u);return Number.isFinite(h)&&(c.type==="number"||Number.isInteger(h))?h:u}return c.type==="boolean"&&typeof u=="string"&&(u==="true"||u==="false")?u==="true":c.type==="string"&&(typeof u=="number"||typeof u=="boolean")?String(u):u}const V=c=>typeof c=="object"&&c!==null&&!Array.isArray(c),Nt=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/u,Qe={table:{w:12,h:5},chart:{w:6,h:5},kpi:{w:3,h:2},text:{w:6,h:1},filter:{w:3,h:1},form:{w:4,h:6},button:{w:2,h:1},image:{w:3,h:3},link:{w:2,h:1}},Pt=[{type:"table",label:"Table"},{type:"chart",label:"Chart"},{type:"kpi",label:"KPI"},{type:"filter",label:"Filter"},{type:"form",label:"Form"},{type:"button",label:"Button"},{type:"text",label:"Text"},{type:"link",label:"Link"}];function d(c,u,h){const w=document.createElement(c);return u!==void 0&&(w.className=u),h!==void 0&&(w.textContent=h),w}function et(c){return c.toISOString().slice(0,10)}function Ot(c,u){qt({editor:"wicked-apps",surfaces:{}},{port:c,hello:u})}function qt(c,u){const h=document.getElementById("wk-apps-sheet")??(u===void 0?null:document.querySelector('link[rel="stylesheet"], style'));if(!(h instanceof HTMLStyleElement)&&!(h instanceof HTMLLinkElement))return;const w=new Mt(h),m=d("div","wk-app");m.setAttribute("data-testid","apps-runtime"),document.body.append(m);let O=null,b=new Set,x=!0,Z=!1,ve=!1,ce=!1,W="preview",ke="full",ee="en",X=0,D=null,xe=!1,B=null,C=null;const Y=Oe(),fe=Oe(),Ee=Oe(),te=new Map,pe=new Map,qe=new Map,he=new Map,ne=new Map;let Te=0,y=0;const g=new Map;let v=null;const E=new Map;let q=!1,A=null,L=null;const R=e=>{O?.postMessage({p:Q,v:1,...e})},S=(e,t)=>{y+=1;const n=`a${y}`;return R({type:e,id:n,payload:t}),new Promise(s=>g.set(n,s))},N=(e,t)=>R({type:e,payload:t}),I=e=>{const t=e.data;if(!V(t)||t.p!==Q||t.v!==1)return;const n=V(t.payload)?t.payload:{};if(typeof t.re=="string"){const s=g.get(t.re);if(s===void 0)return;g.delete(t.re);const o=V(t.error)?t.error:{};s(t.ok===!0?{ok:!0,payload:n}:{ok:!1,code:String(o.code??"unavailable"),message:T(o.message,300),payload:n});return}if(!q)switch(t.type){case"host.ping":typeof t.id=="string"&&R({re:t.id,ok:!0,payload:{}});return;case"host.theme":V(n.theme)&&(P=n.theme),j();return;case"artifact.changed":oe();return;case"app.mode":(n.mode==="edit"||n.mode==="preview")&&(W=n.mode,W==="preview"&&(C=null),j());return;case"data.invalidate":Me();return;case"host.surface":(n.surface==="card"||n.surface==="full")&&(ke=n.surface,j());return;case"selection.cleared":C=null,j();return;case"host.teardown":q=!0;for(const s of E.values())clearInterval(s);E.clear(),document.removeEventListener("keydown",ht),O?.close(),O=null,m.replaceChildren(d("p","wk-empty","Closed"));return;default:return}};let P={};const H=e=>{V(e)&&(P=e),w.theme(P,{accent:D?.theme?.accent,palette:D?.theme?.palette,density:D?.theme?.density})},re=()=>D?.theme?.density==="compact"?"compact":"comfortable",me=(e,t)=>{O=e,O.onmessage=I,b=new Set(Array.isArray(t.grants)?t.grants.filter(o=>typeof o=="string"):[]);const n=V(t.app)?t.app:{};if(x=n.framed!==!1,Z=n.tile===!0,ve=Z&&n.rows===!0,ce=n.propsHost===!0,W=n.mode==="edit"?"edit":"preview",ke=t.surface==="card"||t.size==="inline"?"card":"full",V(n.url))for(const[o,l]of Object.entries(n.url).slice(0,30))Lt.test(o)&&typeof l=="string"&&l.length<=1e3&&(Ee[o]=l);const s=V(t.prefs)?t.prefs:{};ee=typeof s.locale=="string"&&/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(s.locale)?s.locale:"en",H(t.theme),oe()};u===void 0&&window.addEventListener("message",e=>{const t=e.data;O!==null||e.source!==parent||!V(t)||t.p!==Q||t.type!=="host.hello"||e.ports[0]===void 0||me(e.ports[0],V(t.payload)?t.payload:{})});const oe=async()=>{const e=await S("artifact.read",{});if(!e.ok){v=e.message,j();return}const t=V(e.payload.content)?e.payload.content:{};if(t.type!=="app"||!V(t.spec)){v="This is not an app",j();return}const n=X;X=typeof e.payload.version=="number"?e.payload.version:0,D=t.spec,xe=t.readonly===!0,(B===null||!D.pages.some(o=>o.id===B))&&(B=D.pages[0]?.id??null),C!==null&&!U().some(o=>o.id===C)&&(C=null),v=null,Ke();const s=we();j(),(n!==X||s||te.size===0)&&Me()},we=()=>{const e=new Map;for(const n of D?.pages??[])for(const s of n.components){const o=Ze(s);o!==null&&e.set(s.id,de(o))}let t=!1;for(const n of[...te.keys()])pe.get(n)!==e.get(n)&&(te.delete(n),pe.delete(n),t=!0);return t},de=e=>`${e.query}\0${JSON.stringify(e.params)}`,se=()=>D?.pages.find(e=>e.id===B)??null,U=()=>se()?.components??[],He=(e,t)=>{const n=Y[e];if(n!==void 0)return typeof n=="string"?t===void 0?n:void 0:t==="from"?n.from:t==="to"?n.to:void 0},Ie=(e,t,n)=>{const s={},o=n?.properties??{};for(const[l,a]of Object.entries(e??{})){const[p,i,r]=a.split(".");let f;if(p==="filter"&&i!==void 0)f=He(i,r);else if(p==="row"&&i!==void 0&&t.row!==void 0&&Object.hasOwn(t.row,i))f=t.row[i];else if(p==="form"&&i!==void 0&&t.form!==void 0){const k=fe[t.form];f=k!==void 0&&Object.hasOwn(k,i)?k[i]:void 0}else p==="url"&&i!==void 0&&(f=Ee[i]);f!==void 0&&f!==""&&(s[l]=St(Object.hasOwn(o,l)?o[l]:void 0,f))}return s},Ke=()=>{for(const e of D?.pages??[])for(const t of e.components)if(!(t.type!=="filter"||Y[t.id]!==void 0))if(t.filter==="date-range"){const n=V(t.default)&&Number.isInteger(t.default.lastDays)?Math.min(3650,Math.max(1,t.default.lastDays)):30,s=new Date;Y[t.id]={from:et(new Date(s.getTime()-n*864e5)),to:et(s)}}else Y[t.id]=typeof t.default=="string"?t.default:""},tt=e=>D?.queries.find(t=>t.id===e)?.params,Ze=e=>e.type==="table"||e.type==="chart"||e.type==="kpi"?{query:e.data.query,params:Ie(e.data.params,{},tt(e.data.query))}:e.type==="filter"&&e.filter==="select"&&e.options?.kind==="query"?{query:e.options.query.query,params:Ie(e.options.query.params,{},tt(e.options.query.query))}:null,Me=(e,t=!1)=>{if(q||!b.has("data.read")||D===null||Z&&!ve)return;Ke(),Te+=1;const n=Te,s=new Map;for(const o of U()){const l=Ze(o);if(l===null||e!==void 0&&l.query!==e||t&&te.has(o.id))continue;const a=de(l);let p=s.get(a);p===void 0&&(p=S("data.query",{query:l.query,params:l.params}).then(i=>{if(!i.ok)return{state:"error",message:i.message};const r=Array.isArray(i.payload.columns)?i.payload.columns:[],f=Array.isArray(i.payload.rows)?i.payload.rows.filter(Array.isArray):[];return{state:"rows",rows:{columns:r,rows:f,sample:i.payload.sample===!0,hasMore:i.payload.hasMore===!0,truncated:i.payload.truncated===!0}}}),s.set(a,p)),te.has(o.id)||(te.set(o.id,{state:"loading"}),pe.set(o.id,a)),qe.set(o.id,n),p.then(i=>{!q&&qe.get(o.id)===n&&(te.set(o.id,i),pe.set(o.id,a),Fe(o.id))})}e===void 0&&Dt()},Dt=()=>{const e=new Map;for(const t of U()){const n=Ze(t),s=n===null?void 0:D?.queries.find(o=>o.id===n.query);s?.refresh?.mode==="every"&&e.set(s.id,Math.max(15,s.refresh.seconds))}for(const[t,n]of[...E]){const[s,o]=t.split("\0");e.get(s)!==Number(o)&&(clearInterval(n),E.delete(t))}for(const[t,n]of e){const s=`${t}\0${n}`;E.has(s)||E.set(s,setInterval(()=>{document.visibilityState==="visible"&&Me(t)},n*1e3))}},Ct=async(e,t,n)=>{if(x||W!=="preview"||!b.has("data.write"))return;const s=U().find(i=>i.id===e)?.type!=="button",o=i=>{s?(he.set(e,i),Fe(e)):ot(`${T(t.label,60)}: ${i}`)};o("Waiting for you in studio…");const l=await S("data.action",{action:t.action,params:Ie(t.params,n,D?.actions.find(i=>i.id===t.action)?.params)}),a=l.ok?String(l.payload.state):"refused",p=l.ok?T(l.payload.reason,200):l.message;o(a==="succeeded"?`Done${p!==""?`: ${p}`:""}`:a==="cancelled"?"Not run":a==="unknown"?`Not known whether it ran: ${p}`:`Not run: ${p}`)},We=(e,t,n,s="wk-btn wk-btn--sm")=>{if(x)return d("span","wk-muted","Open to make changes");const o=d("button",s,T(t.label,60));return o.type="button",o.setAttribute("data-action",t.action),Z||W!=="preview"||!b.has("data.write")?(o.setAttribute("aria-disabled","true"),o.title=Z?"":W==="edit"?"Actions run in Preview":"This app may not ask to run actions here"):o.addEventListener("click",l=>{l.stopPropagation(),Ct(e,t,n)}),o},Xe=new Map;let J=null,Ye=null;const Ue=new Map,nt=(e,t)=>{Tt(e,t),Rt(e,t)},Rt=(e,t)=>{if(!z())return;const n=(s,o)=>{s!==null&&(s.setAttribute("data-inline",o),s.classList.add("wk-editable"),s.setAttribute("title","Double-click to edit"))};e.type==="text"&&n(t.querySelector(".wk-text"),"text"),e.type==="button"&&n(t.querySelector("button[data-action]"),"label"),e.type==="link"&&n(t.querySelector(".wk-link"),"label"),e.type==="filter"&&n(t.querySelector(".wk-filter-label"),"label")},Tt=(e,t)=>{t.replaceChildren();const n=te.get(e.id);if(e.type==="table"||e.type==="chart"||e.type==="kpi"){if(Z&&!ve){t.append(d("div",`wk-skeleton wk-skeleton--${e.type}`));return}if(!b.has("data.read")){t.append(d("p","wk-muted","Live rows are not shown here"));return}if(n===void 0||n.state==="loading"){t.append(d("p","wk-muted","Loading…"));return}if(n.state==="error"){t.append(d("p","wk-error",`${"data"in e?e.data.query:""}: ${n.message}`));return}}const o=n?.state==="rows"?n.rows:null;switch(e.type){case"kpi":{const l=i=>i===void 0?-1:o.columns.findIndex(r=>r.name===i),a=o.rows[0];t.append(d("div","wk-kpi-value",a===void 0?"—":ue(a[l(e.value)],e.format,ee)));const p=d("div","wk-kpi-caption");if(a!==void 0&&e.delta!==void 0&&l(e.delta)>=0){const i=a[l(e.delta)],r=typeof i=="number"&&i<0||typeof i=="string"&&i.trim().startsWith("-");p.append(d("span",r?"wk-delta wk-delta--down":"wk-delta wk-delta--up",`${r?"▼":"▲"} ${ue(i,void 0,ee).replace(/^\s*-/u,"")}`)),p.append(document.createTextNode(" "))}e.caption!==void 0&&p.append(document.createTextNode(T(e.caption,120))),t.append(p);return}case"chart":gt(t,e,o,ee),(o.truncated||o.rows.length>Je)&&t.append(d("p","wk-muted",o.truncated?"Only part of the source’s rows: the answer was cut at the app’s limit":`The first ${Je} of ${o.rows.length} rows`));return;case"table":{It(e,t,o);return}case"text":t.append(d(e.style==="heading"?"h2":"p",`wk-text wk-text--${e.style??"body"}`,e.text.slice(0,4e3)));return;case"filter":{Ft(e,t);return}case"form":{zt(e,t);return}case"button":t.append(We(e.id,e.action,{},"wk-btn"));return;case"image":{if(!Nt.test(e.src)){t.append(d("p","wk-muted","This image is not one the app can show"));return}const l=d("img","wk-image");l.alt=T(e.alt,300),l.src=e.src,t.append(l);return}case"link":{const l=d("button","wk-link",T(e.label,120));if(l.type="button",e.to.kind==="page"){const a=e.to;l.addEventListener("click",()=>{if(W==="preview"){v=null;for(const[p,i]of Object.entries(Ie(a.params,{})))Ee[p]=String(i);D?.pages.some(p=>p.id===a.page)&&(B=a.page,C=null,j(),Me())}})}else{const a=e.to.href;l.title=a.slice(0,300),l.addEventListener("click",async()=>{if(W!=="preview")return;const p=await S("link.open",{href:a});p.ok||ot(`${T(e.label,60)} not opened: ${p.message}`)})}t.append(l);return}}},It=(e,t,n)=>{const s=M=>n.columns.findIndex($=>$.name===M),o=(e.columns??n.columns.map(M=>({column:M.name}))).filter(M=>s(M.column)>=0),l=Math.min(500,Math.max(5,e.pageSize??10)),a=Math.max(1,Math.ceil(n.rows.length/l)),p=Math.min(ne.get(e.id)??0,a-1),i=d("table","wk-table"),r=d("tr");for(const M of o)r.append(d("th",void 0,T(M.label??M.column,80)));(e.rowActions??[]).length>0&&r.append(d("th","wk-th-actions","")),i.append(d("thead")),i.tHead.append(r);const f=d("tbody");for(const M of n.rows.slice(p*l,p*l+l)){const $=d("tr"),K=Oe();n.columns.forEach((ae,Se)=>{K[ae.name]=M[Se]??null});for(const ae of o){const Se=M[s(ae.column)];$.append(d("td",typeof Se=="number"?"wk-num":void 0,ue(Se,ae.format,ee)))}if((e.rowActions??[]).length>0){const ae=d("td","wk-td-actions");for(const Se of(e.rowActions??[]).slice(0,4))ae.append(We(e.id,Se,{row:K}));$.append(ae)}f.append($)}i.append(f),t.append(i),n.rows.length===0&&t.append(d("p","wk-muted","No rows"));const k=d("div","wk-table-foot");if(a>1){const M=d("button","wk-btn wk-btn--sm","Previous"),$=d("button","wk-btn wk-btn--sm","Next");M.type="button",$.type="button",M.disabled=p===0,$.disabled=p>=a-1,M.addEventListener("click",()=>{ne.set(e.id,p-1),Fe(e.id)}),$.addEventListener("click",()=>{ne.set(e.id,p+1),Fe(e.id)}),k.append(M,d("span","wk-muted",`${p+1} of ${a}`),$)}n.truncated?k.append(d("span","wk-muted",`Only the first ${n.rows.length} rows: the answer was cut at the app’s limit`)):n.hasMore&&k.append(d("span","wk-muted","First page of the source’s rows"));const F=he.get(e.id);F!==void 0&&k.append(d("span","wk-status",F)),k.childNodes.length>0&&t.append(k)},Ft=(e,t)=>{const n=d("label","wk-filter");n.append(d("span","wk-filter-label",T(e.label??(e.filter==="search"?"Search":e.filter==="date-range"?"Dates":"Filter"),60)));const s=()=>{Me()};if(e.filter==="search"){const o=d("input","wk-input");o.type="search",o.value=typeof Y[e.id]=="string"?Y[e.id]:"";let l=null;o.addEventListener("input",()=>{Y[e.id]=o.value.slice(0,200),l!==null&&clearTimeout(l),l=setTimeout(s,300)}),n.append(o)}else if(e.filter==="select"){const o=d("select","wk-input"),l=[{value:"",label:"All"}];if(e.options?.kind==="values")for(const a of e.options.values.slice(0,200))l.push({value:T(a.value,200),label:T(a.label??a.value,200)});if(e.options?.kind==="query"){const a=te.get(e.id);if(a?.state==="rows"){const p=a.rows.columns.findIndex(r=>r.name===e.options.value),i=a.rows.columns.findIndex(r=>r.name===(e.options.label??""));for(const r of a.rows.rows.slice(0,200))p>=0&&l.push({value:ue(r[p],void 0,ee),label:ue(r[i>=0?i:p],void 0,ee)})}}for(const a of l){const p=d("option",void 0,a.label);p.value=a.value,o.append(p)}o.value=typeof Y[e.id]=="string"?Y[e.id]:"",o.addEventListener("change",()=>{Y[e.id]=o.value,s()}),n.append(o)}else{const o=Y[e.id]??{from:"",to:""},l=d("input","wk-input wk-input--date"),a=d("input","wk-input wk-input--date");l.type="date",a.type="date",l.value=o.from,a.value=o.to;const p=()=>{Y[e.id]={from:l.value,to:a.value},s()};l.addEventListener("change",p),a.addEventListener("change",p),n.append(l,d("span","wk-muted","–"),a)}t.append(n)},zt=(e,t)=>{var p;const n=fe[p=e.id]??(fe[p]=Oe()),s=D?.actions.find(i=>i.id===e.submit.action)?.params?.properties??{};for(const i of e.fields){if(Object.hasOwn(n,i.name))continue;const r=e.submit.params===void 0?void 0:Object.entries(e.submit.params).find(([,k])=>k===`form.${i.name}`)?.[0],f=r!==void 0&&Object.hasOwn(s,r)?s[r].default:void 0;i.input==="checkbox"?n[i.name]=f===!0:f!==void 0&&(n[i.name]=String(f))}const o=d("div","wk-form");for(const i of e.fields.slice(0,30)){const r=d("label","wk-field");r.append(d("span","wk-filter-label",T(i.label??i.name,80)));let f;if(i.input==="textarea")f=d("textarea","wk-input");else if(i.input==="select"){f=d("select","wk-input");for(const k of i.options??[]){const F=d("option",void 0,T(k.label??k.value,200));F.value=T(k.value,200),f.append(F)}}else f=d("input","wk-input"),f.type=i.input==="number"?"number":i.input==="date"?"date":i.input==="checkbox"?"checkbox":"text";f instanceof HTMLInputElement&&f.type==="checkbox"?(f.checked=n[i.name]===!0,f.addEventListener("change",()=>{n[i.name]=f.checked})):(f.value=typeof n[i.name]=="string"?n[i.name]:"",f.addEventListener("input",()=>{n[i.name]=f.value.slice(0,1e3)})),f.disabled=W!=="preview",r.append(f),o.append(r)}const l=d("div","wk-form-foot");l.append(We(e.id,e.submit,{form:e.id},"wk-btn"));const a=he.get(e.id);l.append(d("span","wk-muted",a??(x?"":"Studio asks before it writes"))),o.append(l),t.append(o)};let ye=null;const ot=e=>{v=e,ye!==null?(ye.textContent=e,ye.hidden=!1):j()},Fe=e=>{if(A!==null&&A.id===e)return;const t=U().find(s=>s.id===e),n=Ue.get(e);t!==void 0&&n!==void 0&&nt(t,n)},z=()=>W==="edit"&&ke==="full"&&!xe&&b.has("artifact.write");let be=null;const st=()=>{const e=be.getBoundingClientRect(),t=re();return{col:(e.width+Ge[t])/12,row:At[t]+Ge[t],left:e.left,top:e.top}},_t=(e,t)=>{const n=st();return{x:Math.min(11,Math.max(0,Math.floor((e-n.left)/n.col))),y:Math.min(999,Math.max(0,Math.floor((t-n.top)/n.row)))}},ie=async(e,t={})=>{const n=await S("spec.edit",{base:X,ops:e});if(!n.ok)return v=n.code==="head_moved"?"The app changed meanwhile: showing the newest version":`Not changed: ${n.message}`,n.code==="head_moved"?await oe():j(),null;V(n.payload.spec)&&(D=n.payload.spec),v=null,Ke(),we();const s=Array.isArray(n.payload.added)?n.payload.added.filter(o=>typeof o=="string"):[];return s[0]!==void 0&&Le(s[0]),j({keepProps:t.typed===!0&&s.length===0}),Me(void 0,!0),s},Le=e=>{const t=C;C=e,e!==null&&b.has("selection.chip")?N("selection.set",{anchors:[{kind:"element",id:e}]}):e===null&&t!==null&&b.has("selection.chip")&&N("selection.set",{anchors:[]})},it=(e,t,n,s)=>{if(!z()||e.button!==0)return;e.preventDefault(),e.stopPropagation(),(s.closest(".wk-cell")??s).focus({preventScroll:!0});const o=Xe.get(t.id),l=st(),a={x:e.clientX,y:e.clientY};let p={...t.box},i=!1;const r=n==="move"?e.target?.closest?.("[data-inline]"):null;s.setPointerCapture(e.pointerId),s.classList.add("is-dragging");const f=F=>{const M=Math.round((F.clientX-a.x)/l.col),$=Math.round((F.clientY-a.y)/l.row);M===0&&$===0&&!i||(i=!0,p=n==="move"?{...t.box,x:Math.min(12-t.box.w,Math.max(0,t.box.x+M)),y:Math.max(0,t.box.y+$)}:{...t.box,w:Math.min(12-t.box.x,Math.max(1,t.box.w+M)),h:Math.min(50,Math.max(1,t.box.h+$))},w.place(o,p))},k=()=>{s.removeEventListener("pointermove",f),s.removeEventListener("pointerup",k),s.removeEventListener("pointercancel",k),s.classList.remove("is-dragging");const F=n==="move"?p.x!==t.box.x||p.y!==t.box.y:p.w!==t.box.w||p.h!==t.box.h;if(!i||!F){w.place(o,t.box),i||(Le(t.id),dt(),ut(t.id,r));return}ie([n==="move"?{op:"component-move",id:t.id,x:p.x,y:p.y}:{op:"component-resize",id:t.id,w:p.w,h:p.h}])};s.addEventListener("pointermove",f),s.addEventListener("pointerup",k),s.addEventListener("pointercancel",k)},at=()=>U().reduce((e,t)=>Math.max(e,t.box.y+t.box.h),0),Bt=(e,t,n)=>{if(!z()||e.button!==0||be===null||B===null)return;e.preventDefault(),n.focus({preventScroll:!0});const s=Qe[t],o=d("div","wk-drop wk-c9999");o.setAttribute("data-testid","apps-drop-target");let l=null;n.setPointerCapture(e.pointerId);const a=i=>{const r=be.getBoundingClientRect();if(i.clientX<r.left||i.clientX>r.right||i.clientY<r.top){o.remove(),l=null;return}l=_t(i.clientX,i.clientY),l.x=Math.min(l.x,12-s.w),w.place(9999,{x:l.x,y:l.y,w:s.w,h:s.h}),o.parentNode===null&&be.append(o)},p=i=>{if(n.removeEventListener("pointermove",a),n.removeEventListener("pointerup",p),n.removeEventListener("pointercancel",p),o.remove(),Math.abs(i.clientX-e.clientX)+Math.abs(i.clientY-e.clientY)>6&&l===null)return;const f=l??{x:0,y:at()};ie([{op:"component-add",page:B,type:t,box:{x:f.x,y:f.y,w:Math.min(s.w,12-f.x),h:s.h}}])};n.addEventListener("pointermove",a),n.addEventListener("pointerup",p),n.addEventListener("pointercancel",p)},je=(e,t,n=!1,s)=>{let o=e.value,l=null;const a=()=>{if(e.value===o)return;o=e.value;const i=t();if(i===void 0)return;const r=Promise.resolve(i);l=r,r.finally(()=>{l===r&&(l=null)})};let p=!1;e.addEventListener("compositionstart",()=>{p=!0}),e.addEventListener("compositionend",()=>{p=!1,a()}),e.addEventListener("input",i=>{!p&&i.isComposing!==!0&&a()}),s!==void 0&&e.addEventListener("blur",()=>{const i=()=>{if(document.activeElement===e)return;const r=s();e.value!==r&&(e.value=r,o=r)};l!==null?l.then(i,i):i()}),e.addEventListener("change",()=>{p||a()}),e.addEventListener("keydown",i=>{const r=i;p||r.isComposing||r.keyCode===229||r.key==="Enter"&&(!n||r.metaKey||r.ctrlKey)&&(r.preventDefault(),a())})},De=(e,t)=>{const n=d("label","wk-prop");return n.append(d("span","wk-prop-label",e),t),n},Ae=(e,t,n,s,o,l=!1)=>{const a=d(l?"textarea":"input","wk-input");return a.value=s??"",a.maxLength=o,a.setAttribute("data-prop",n),je(a,()=>ie([{op:"component-set",id:e.id,prop:n,value:a.value}],{typed:!0}),l,()=>{const p=U().find(r=>r.id===e.id),i=n==="label"&&p?.type==="button"?p.action?.label:p?.[n];return typeof i=="string"?i:""}),De(t,a)},Ce=(e,t,n,s,o,l="set")=>{const a=d("select","wk-input");for(const p of o){const i=d("option",void 0,p);i.value=p,a.append(i)}return a.value=s,a.setAttribute("data-prop",n),a.addEventListener("change",()=>{ie([l==="bind"?{op:"bind",id:e.id,query:a.value}:{op:"component-set",id:e.id,prop:n,value:a.value}])}),De(t,a)},rt=(e,t,n,s)=>{const o=d("input","wk-check");return o.type="checkbox",o.checked=s,o.setAttribute("data-prop",n),o.addEventListener("change",()=>{ie([{op:"component-set",id:e.id,prop:n,value:o.checked}])}),De(t,o)},ze=(e,t,n,s,o)=>{const l=d("input","wk-input wk-input--num");l.type="number",l.min=String(s),l.max=String(o),l.value=String(n==="x"?e.box.x+1:n==="y"?e.box.y+1:e.box[n]),l.setAttribute("data-prop",`box-${n}`);const a=()=>U().find(i=>i.id===e.id)?.box??e.box,p=i=>String(n==="x"?i.x+1:n==="y"?i.y+1:i[n]);return je(l,()=>{if(l.value.trim()==="")return;const i=Math.round(Number(l.value));if(!Number.isFinite(i))return;const r=a();if(n==="x"||n==="y"){const F=n==="x"?Math.min(12-r.w,Math.max(0,i-1)):r.x,M=n==="y"?Math.max(0,i-1):r.y;return ie([{op:"component-move",id:e.id,x:F,y:M}],{typed:!0})}const f=n==="w"?Math.min(12-r.x,Math.max(1,i)):r.w,k=n==="h"?Math.min(50,Math.max(1,i)):r.h;return ie([{op:"component-resize",id:e.id,w:f,h:k}],{typed:!0})},!1,()=>p(a())),De(t,l)},lt=e=>{const t=d("aside","wk-props");t.setAttribute("aria-label","Properties"),t.setAttribute("data-testid","apps-properties"),t.append(d("h3","wk-props-title","Properties")),t.append(d("p","wk-muted",`${e.type==="chart"?`${e.chart} chart`:e.type} · ${e.id}`)),t.append(Ae(e,"Title","title",e.title,120));const n=(D?.queries??[]).map(a=>a.id),s=a=>D?.queries.find(p=>p.id===a)?.output.map(p=>p.name)??[];if((e.type==="table"||e.type==="chart"||e.type==="kpi")&&t.append(Ce(e,"Data","query",e.data.query,n,"bind")),e.type==="table"){const a=d("input","wk-input wk-input--num");a.type="number",a.min="5",a.max="500",a.value=String(e.pageSize??10),a.setAttribute("data-prop","pageSize"),je(a,()=>{if(a.value.trim()==="")return;const p=Math.round(Number(a.value));return Number.isFinite(p)?ie([{op:"component-set",id:e.id,prop:"pageSize",value:Math.min(500,Math.max(5,p))}],{typed:!0}):void 0},!1,()=>String(U().find(p=>p.id===e.id)?.pageSize??10)),t.append(De("Rows per page",a))}e.type==="chart"&&(t.append(Ce(e,"Chart","chart",e.chart,["bar","line","area","pie"])),t.append(Ce(e,"Category","x",e.x,s(e.data.query))),(e.chart==="bar"||e.chart==="area")&&t.append(rt(e,"Stacked","stacked",e.stacked===!0))),e.type==="kpi"&&(t.append(Ce(e,"Figure","value",e.value,s(e.data.query))),t.append(Ae(e,"Caption","caption",e.caption,120))),e.type==="text"&&(t.append(Ae(e,"Text","text",e.text,4e3,!0)),t.append(Ce(e,"Style","style",e.style??"body",["heading","body","caption"]))),e.type==="filter"&&t.append(Ae(e,"Label","label",e.label,120)),e.type==="button"&&t.append(Ae(e,"Label","label",e.action.label,60)),e.type==="link"&&t.append(Ae(e,"Label","label",e.label,120)),e.type==="image"&&t.append(Ae(e,"Description","alt",e.alt,300));const o=d("div","wk-prop-box");o.append(ze(e,"Column","x",1,12),ze(e,"Row","y",1,1e3),ze(e,"Width","w",1,12),ze(e,"Height","h",1,50)),t.append(o),t.append(rt(e,"Hide on phones","hideOnPhone",e.hideOnPhone===!0));const l=d("button","wk-btn wk-btn--danger","Delete this component");return l.type="button",l.setAttribute("data-testid","apps-remove"),l.addEventListener("click",()=>{const a=e.id;C=null,ie([{op:"component-remove",id:a}])}),t.append(l),t},pt=()=>{const e=d("aside","wk-props wk-props--empty");return e.setAttribute("aria-label","Properties"),e.setAttribute("data-testid","apps-properties-empty"),e.append(d("h3","wk-props-title","Properties")),e.append(d("p","wk-muted","Select a component to change it here. Double-click its words to edit them in place.")),e},Ht=()=>{const e=d("aside","wk-palette");e.setAttribute("aria-label","Components"),e.append(d("h3","wk-props-title","Components")),e.append(d("p","wk-muted","Drag onto the canvas, or click to add"));const t=d("div","wk-tiles");for(const n of Pt){const s=d("button","wk-tile",n.label);s.type="button",s.setAttribute("data-palette",n.type),s.addEventListener("pointerdown",o=>Bt(o,n.type,s)),s.addEventListener("click",o=>{if(o.detail!==0||!z()||B===null)return;const l=Qe[n.type];ie([{op:"component-add",page:B,type:n.type,box:{x:0,y:at(),w:l.w,h:l.h}}])}),t.append(s)}return e.append(t),e},j=(e={})=>{const t=A;let n=!1;if(t!==null){const s=z()?U().find(o=>o.id===t.id):void 0;if(n=s!==void 0&&ct(s,t.prop)===t.before,n&&t.composing()){t.defer();return}n?t.hold():t.drop()}Kt(e),n&&t!==null&&A===t&&t.place()},Kt=e=>{const t=document.activeElement instanceof HTMLElement&&m.contains(document.activeElement)?document.activeElement.getAttribute("data-prop"):null;if(Ue.clear(),Xe.clear(),w.reset(),H(void 0),m.setAttribute("data-mode",z()?"edit":"preview"),m.setAttribute("data-tile",Z?"true":"false"),m.setAttribute("data-surface",ke),D===null){m.replaceChildren(d("p","wk-empty",v??"Loading the app…")),J=null;return}const n=[];z()&&n.push(Ht());const s=d("main","wk-main"),o=d("nav","wk-pages");o.setAttribute("aria-label","Pages");for(const r of D.pages){const f=d("button",r.id===B?"wk-page is-on":"wk-page",T(r.title,80));f.type="button",f.setAttribute("aria-current",r.id===B?"page":"false"),f.addEventListener("click",()=>{B!==r.id&&(B=r.id,Le(null),j(),Me())}),o.append(f)}s.append(o),ye=d("p","wk-notice",v??""),ye.setAttribute("data-testid","apps-notice"),ye.setAttribute("aria-live","polite"),ye.hidden=v===null,s.append(ye),xe&&W==="edit"&&s.append(d("p","wk-notice","A chat turn is changing this app: it is read-only until the turn ends")),be=d("div","wk-grid");const l=U(),a=[...l].sort((r,f)=>r.box.y-f.box.y||r.box.x-f.box.x);l.forEach((r,f)=>{Xe.set(r.id,f),w.place(f,r.box),w.phoneOrder(f,a.indexOf(r),r.hideOnPhone===!0),r.type==="chart"&&r.series.slice(0,12).forEach((M,$)=>w.seriesColour(f,$,M.color));const k=d("section",`wk-cell wk-cell--${r.type} wk-c${f}${r.id===C&&z()?" is-selected":""}`);if(k.setAttribute("data-component",r.id),r.title!==void 0&&r.type!=="text"){const M=d("h3","wk-cell-title",T(r.title,120));z()&&(M.setAttribute("data-inline","title"),M.classList.add("wk-editable"),M.setAttribute("title","Double-click to edit")),k.append(M)}const F=d("div","wk-cell-body");if(Ue.set(r.id,F),nt(r,F),k.append(F),z()){k.classList.add("is-editable"),k.tabIndex=0,k.setAttribute("aria-label",`${r.type==="chart"?`${r.chart} chart`:r.type} ${T(r.title??r.id,80)}: Enter to select`),k.append(d("span","wk-tag",`${r.type==="chart"?`${r.chart} chart`:r.type}${"data"in r&&r.data!==void 0?` · ${r.data.query}`:""}`));const M=d("span","wk-handle");M.setAttribute("aria-hidden","true"),M.addEventListener("pointerdown",$=>it($,r,"resize",M)),k.append(M),k.addEventListener("pointerdown",$=>{$.target.closest("input, select, textarea, button, .wk-handle")===null&&it($,r,"move",k)}),k.addEventListener("pointerup",$=>{const K=$.target.closest?.("button[data-inline]");K!==null&&$.button===0&&ut(r.id,K)})}be.append(k)}),l.length===0&&be.append(d("p","wk-empty",z()?"Drag a component here from the palette":"This page is empty")),s.append(be),n.push(s);const p=z()&&C!==null?l.find(r=>r.id===C):void 0;if(e.keepProps===!0&&p!==void 0&&J!==null&&Ye===p.id&&J.parentNode===m){for(const r of[...m.childNodes])r!==J&&r.remove();for(const r of n)m.insertBefore(r,J);return}J=ce?null:p!==void 0?lt(p):z()?pt():null,Ye=p?.id??null,m.replaceChildren(...n,...J!==null?[J]:[]),t!==null&&[...m.querySelectorAll("[data-prop]")].find(r=>r.getAttribute("data-prop")===t)?.focus({preventScroll:!0})},dt=()=>{for(const n of m.querySelectorAll("[data-component]"))n.classList.toggle("is-selected",z()&&n.getAttribute("data-component")===C);const e=z()&&C!==null?U().find(n=>n.id===C):void 0,t=ce?null:e!==void 0?lt(e):z()?pt():null;J!==null&&t!==null&&J.parentNode===m?J.replaceWith(t):(J?.remove(),t!==null&&m.append(t)),J=t,Ye=e?.id??null},ut=(e,t)=>{const n=t?.getAttribute("data-inline")??null,s=Date.now();n!==null&&t!==null&&L!==null&&L.id===e&&L.prop===n&&s-L.at<$t?(L=null,t.isConnected&&ft(e,t)):L=n!==null?{id:e,prop:n,at:s}:null},ct=(e,t)=>{if(t==="title")return e.title??"";if(t==="text"&&e.type==="text")return e.text;if(t==="label"){if(e.type==="button")return e.action.label;if(e.type==="link")return e.label;if(e.type==="filter")return e.label??""}return""},ft=(e,t)=>{const n=U().find($=>$.id===e),s=t.getAttribute("data-inline");if(n===void 0||s===null||!z()||A!==null)return;const o=ct(n,s),l=s==="text",a=l?d("textarea","wk-inline-input wk-inline-input--multi"):d("input","wk-inline-input");a.value=o,a.maxLength=l?4e3:n.type==="button"?60:120,a.setAttribute("data-testid","apps-inline"),a.setAttribute("aria-label",`Edit the ${s==="text"?"text":s}`),t.replaceWith(a),a.closest("[data-component]")?.classList.add("is-inline"),a.focus(),a.select();let p=!1,i=!1,r=!1,f=!1,k=[null,null,"none"];const F={id:e,prop:s,before:o,drop:()=>{p=!0,r=!1,A===F&&(A=null)},hold:()=>{r=!0,k=[a.selectionStart,a.selectionEnd,a.selectionDirection??"none"]},composing:()=>i,defer:()=>{f=!0},place:()=>{const $=[...m.querySelectorAll("[data-component]")].find(ae=>ae.getAttribute("data-component")===e),K=$===void 0?void 0:[...$.querySelectorAll("[data-inline]")].find(ae=>ae.getAttribute("data-inline")===s);if(K===void 0){F.drop();return}K.replaceWith(a),$.classList.add("is-inline"),a.focus(),k[0]!==null&&k[1]!==null&&a.setSelectionRange(k[0],k[1],k[2]),r=!1}};A=F;const M=$=>{p||(F.drop(),$&&a.value!==o?ie([{op:"component-set",id:e,prop:s,value:a.value}]):j())};a.addEventListener("compositionstart",()=>{i=!0}),a.addEventListener("compositionend",()=>{i=!1,f&&(f=!1,p||j())}),a.addEventListener("keydown",$=>{const K=$;if(!(i||K.isComposing||K.keyCode===229)){if(K.key==="Escape"){K.preventDefault(),K.stopPropagation(),M(!1);return}K.key==="Enter"&&!(l&&K.shiftKey)&&(K.preventDefault(),K.stopPropagation(),M(!0))}}),a.addEventListener("blur",()=>{r||(a.isConnected?M(!0):F.drop())})};m.addEventListener("dblclick",e=>{if(!z()||A!==null)return;const n=((typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):null)??e.target)?.closest("[data-inline]"),s=n?.closest("[data-component]");n==null||s===null||s===void 0||(e.preventDefault(),ft(s.getAttribute("data-component"),n))});function ht(e){if(O===null||D===null)return;const t=e.target?.closest?.(".wk-cell.is-editable");if(t!==null&&(e.key==="Enter"||e.key===" ")&&e.target===t){e.preventDefault();const o=t.getAttribute("data-component");o!==null&&(Le(o),dt(),m.querySelector(".wk-props input, .wk-props select")?.focus());return}const n=e.target?.closest("input, textarea, select")!=null;if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="z"&&!n&&z()){e.preventDefault(),S("app.history",{move:e.shiftKey?"redo":"undo",base:X}).then(o=>{o.ok||(v=o.message,o.code==="head_moved"?oe():j())});return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&z()&&C!==null){e.preventDefault();const o=C;Le(null),ie([{op:"component-remove",id:o}]);return}e.key==="Escape"&&C!==null&&!n&&(Le(null),j())}document.addEventListener("keydown",ht),m.append(d("p","wk-empty","Loading the app…")),u===void 0?wt(c.editor,c.surfaces):me(u.port,u.hello)}return le.boot=Ot,Object.defineProperty(le,Symbol.toStringTag,{value:"Module"}),le})({});
|
|
1
|
+
var wickedAppsStandalone=(function(he){"use strict";var on=Object.defineProperty;var sn=(he,ie,Re)=>ie in he?on(he,ie,{enumerable:!0,configurable:!0,writable:!0,value:Re}):he[ie]=Re;var Te=(he,ie,Re)=>sn(he,typeof ie!="symbol"?ie+"":ie,Re);const ie="wicked.editor";function $t(u,d,m){return{editor:u,version:d,protocol:[1,2],surfaces:m}}function Lt(u,d){const m=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:ie,v:1,type:"plugin.ready",payload:$t(u,m,d)},"*")}const St=/^[A-Z]{3}$/u;function ye(u,d,m){if(u==null)return"";if(typeof u=="boolean")return u?"yes":"no";const y=typeof d?.decimals=="number"&&Number.isInteger(d.decimals)?Math.min(10,Math.max(0,d.decimals)):void 0,h=typeof u=="number"?u:typeof u=="string"&&u.trim()!==""&&Number.isFinite(Number(u))?Number(u):null;try{switch(d?.kind){case"currency":if(h===null||!St.test(d.currency))break;return new Intl.NumberFormat(m,{style:"currency",currency:d.currency,...y!==void 0?{minimumFractionDigits:y,maximumFractionDigits:y}:{}}).format(h);case"percent":if(h===null)break;return new Intl.NumberFormat(m,{style:"percent",maximumFractionDigits:y??1}).format(h);case"number":if(h===null)break;return new Intl.NumberFormat(m,y!==void 0?{minimumFractionDigits:y,maximumFractionDigits:y}:{}).format(h);case"date":case"datetime":{const N=new Date(typeof u=="number"?u:String(u));if(Number.isNaN(N.getTime()))break;return new Intl.DateTimeFormat(m,d.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(N)}case"duration":{if(h===null)break;const N=Math.abs(Math.round(h)),k=Math.floor(N/86400),M=Math.floor(N%86400/3600),Y=Math.floor(N%3600/60);return k>0?`${k}d ${M}h`:M>0?`${M}h ${Y}m`:`${Y}m`}default:break}}catch{}return typeof u=="number"?Number.isInteger(u)?String(u):new Intl.NumberFormat(m,{maximumFractionDigits:6}).format(u):String(u)}function F(u,d=200){return typeof u=="string"?u.replace(/[\u0000-\u001f\u007f]+/gu," ").slice(0,d):""}const Nt="http://www.w3.org/2000/svg";function ne(u,d,m){const y=document.createElementNS(Nt,u);for(const[h,N]of Object.entries(d))y.setAttribute(h,String(N));return m!==void 0&&y.setAttribute("class",m),y}function He(u,d,m,y,h="start"){const N=ne("text",{x:u,y:d,"text-anchor":h},y);return N.textContent=m,N}function xe(u){return typeof u=="number"?Number.isFinite(u)?u:0:typeof u=="string"&&u.trim()!==""&&Number.isFinite(Number(u))?Number(u):0}const W=u=>Math.round(u*10)/10;function Ve(u,d){const m=document.createElement("ul");m.className="wk-legend",d.forEach((y,h)=>{const N=document.createElement("li"),k=document.createElement("span");k.className=`wk-swatch wk-series-${h%12}`,N.append(k,document.createTextNode(y)),m.append(N)}),u.append(m)}function Pt(u,d,m,y){const h=g=>m.columns.findIndex(x=>x.name===g),N=h(d.x),k=d.series.slice(0,d.chart==="pie"?1:12).map(g=>({label:F(g.label??g.column,60),i:h(g.column)})).filter(g=>g.i>=0),M=m.rows.slice(0,500);if(N<0||k.length===0||M.length===0){const g=document.createElement("p");g.className="wk-empty",g.textContent=M.length===0?"No rows":"This chart’s columns are not in its query’s rows",u.append(g);return}const Y=M.map(g=>ye(g[N],void 0,y));if(d.chart==="bar"){const g=d.stacked===!0&&k.length>1,x=M.map(_=>k.map(P=>xe(_[P.i])));let L=0,E=0;for(const _ of x)if(g)E=Math.max(E,_.filter(P=>P>0).reduce((P,K)=>P+K,0)),L=Math.min(L,_.filter(P=>P<0).reduce((P,K)=>P+K,0));else for(const P of _)E=Math.max(E,P),L=Math.min(L,P);E===L&&(E=L+1);const O=130,S=k.length>1?250:220,$=_=>O+(_-L)/(E-L)*S,R=$(0),D=g||k.length===1?26:Math.max(26,k.length*10+10),A=ne("svg",{viewBox:`0 0 400 ${M.length*D+4}`,role:"img","aria-label":F(d.title??"bar chart",120)},"wk-chart wk-chart--bar");L<0&&A.append(ne("line",{x1:W(R),x2:W(R),y1:0,y2:M.length*D+4},"wk-grid-line")),M.forEach((_,P)=>{const K=P*D+2;if(A.append(He(0,W(K+D/2+4),Y[P].slice(0,22),"wk-axis")),g){let Se=0,ce=0;k.forEach((ue,we)=>{const oe=x[P][we],We=oe>=0?Se:ce+oe,Q=oe>=0?Se+oe:ce;oe>=0?Se+=oe:ce+=oe,A.append(ne("rect",{x:W($(We)),y:K+4,width:W(Math.max(1,$(Q)-$(We))),height:D-10},`wk-series-${we%12}`))});return}const de=(D-8)/k.length;k.forEach((Se,ce)=>{const ue=x[P][ce],we=Math.min($(ue),R),oe=Math.max(1,Math.abs($(ue)-R));A.append(ne("rect",{x:W(we),y:W(K+4+ce*de),width:W(oe),height:W(Math.max(2,de-2)),rx:2},`wk-series-${ce%12}`)),k.length===1&&A.append(He(W(ue<0?we-6:we+oe+6),W(K+D/2+4),ye(_[Se.i],void 0,y),"wk-value",ue<0?"end":"start"))})}),u.append(A),k.length>1&&Ve(u,k.map(_=>_.label));return}if(d.chart==="pie"){const g=k[0],x=M.reduce((O,S)=>O+Math.max(0,xe(S[g.i])),0)||1,L=ne("svg",{viewBox:"0 0 240 240",role:"img","aria-label":F(d.title??"pie chart",120)},"wk-chart wk-chart--pie");let E=-Math.PI/2;M.forEach((O,S)=>{const $=Math.max(0,xe(O[g.i]))/x,R=E+$*Math.PI*2,D=R-E>Math.PI?1:0,A=P=>`${W(120+100*Math.cos(P))} ${W(120+100*Math.sin(P))}`,_=$>=.9999?"M 120 20 A 100 100 0 1 1 119.9 20 Z":`M 120 120 L ${A(E)} A 100 100 0 ${D} 1 ${A(R)} Z`;L.append(ne("path",{d:_},`wk-series-${S%12}`)),E=R}),u.append(L),Ve(u,Y.slice(0,12));return}const Ee=600,ge=220,V=36,Me=24,ae=d.chart==="area"&&d.stacked===!0&&k.length>1,j=[],I=new Map;M.forEach((g,x)=>{if(j.push(x),!ae||x+1>=M.length)return;const L=new Map;k.forEach((E,O)=>{const S=xe(M[x][E.i]),$=xe(M[x+1][E.i]);if(S>0&&$<0||S<0&&$>0){const R=S/(S-$);L.set(R,[...L.get(R)??[],O])}});for(const E of[...L.keys()].sort((O,S)=>O-S))I.set(j.length,new Set(L.get(E))),j.push(x+E)});const Ae=(g,x)=>{if(I.get(x)?.has(g)===!0)return 0;const L=j[x],E=Math.floor(L),O=L-E,S=xe(M[E][k[g].i]);return O===0||E+1>=M.length?S:S+(xe(M[E+1][k[g].i])-S)*O},X=k.map(()=>[]),z=k.map(()=>[]);let G=0,me=1;const be=g=>{g<G&&(G=g),g>me&&(me=g)};j.forEach((g,x)=>{let L=0,E=0;k.forEach((O,S)=>{const $=Ae(S,x);if(!ae){X[S][x]=[0,$],z[S][x]=[0,0],be($);return}const R=Math.max(0,$),D=Math.min(0,$);X[S][x]=[L,L+R],z[S][x]=[E+D,E],L+=R,E+=D,be(L),be(E)})});const Oe=me,te=G,$e=g=>V+(M.length===1?0:g/(M.length-1)*(Ee-V-8)),Le=g=>ge-Me-(g-te)/(Oe-te||1)*(ge-Me-10),re=ne("svg",{viewBox:`0 0 ${Ee} ${ge}`,role:"img","aria-label":F(d.title??`${d.chart} chart`,120)},`wk-chart wk-chart--${d.chart}`);for(let g=0;g<=3;g+=1){const x=te+(Oe-te)*g/3;re.append(ne("line",{x1:V,x2:Ee-8,y1:W(Le(x)),y2:W(Le(x))},"wk-grid-line")),re.append(He(V-6,W(Le(x)+4),ye(Math.round(x*10)/10,void 0,y),"wk-axis","end"))}const Fe=M.length<=4?M.map((g,x)=>x):[0,Math.floor((M.length-1)/3),Math.floor((M.length-1)*2/3),M.length-1];for(const g of Fe)re.append(He(W($e(g)),ge-6,Y[g].slice(0,14),"wk-axis",g===0?"start":g===M.length-1?"end":"middle"));k.forEach((g,x)=>{const L=(D,A)=>`${W($e(j[D]))},${W(Le(A))}`;if(d.chart==="area"){const D=A=>{const _=j.map((K,de)=>L(de,A[de][1])),P=j.map((K,de)=>L(de,A[de][0])).reverse();return`M ${_.join(" L ")} L ${P.join(" L ")} Z`};re.append(ne("path",{d:D(X[x])},`wk-area wk-series-${x}`)),ae&&z[x].some(([A,_])=>A!==_)&&re.append(ne("path",{d:D(z[x])},`wk-area wk-area--neg wk-series-${x}`))}if(!ae){re.append(ne("polyline",{points:j.map((D,A)=>L(A,Ae(x,A))).join(" "),fill:"none"},`wk-stroke wk-series-${x}`));return}const E=[];let O=null,S=0,$=[];const R=(D,A)=>D<0?L(A,z[x][A][0]):L(A,X[x][A][1]);j.forEach((D,A)=>{const _=Ae(x,A);if(I.get(A)?.has(x)===!0||_===0){O!==null&&O.push(R(S,A)),$.push(A);return}const P=_>0?1:-1;if(O===null)O=$.map(K=>R(P,K)),E.push(O),S=P;else if(P!==S){const K=$[$.length-1];O=K!==void 0?[R(P,K)]:[],E.push(O),S=P}O.push(R(P,A)),$=[]}),O===null&&$.length>1&&E.push($.map(D=>R(1,D)));for(const D of E)D.length>1&&re.append(ne("polyline",{points:D.join(" "),fill:"none"},`wk-stroke wk-series-${x}`))}),u.append(re),k.length>1&&Ve(u,k.map(g=>g.label))}const qt=/^#[0-9a-fA-F]{6}$/u,it=/^(?::root|\.wk-c\d{1,4}(?: \.wk-[a-z]+)?)$/u,Ot=/^(?:--[a-z0-9-]{1,40}|[a-z-]{1,40})$/u,Dt="(max-width: 639px)";function je(u){return typeof u=="string"&&qt.test(u)?u.toLowerCase():null}function qe(u,d,m,y){return Number.isInteger(u)?Math.min(m,Math.max(d,u)):y}function Ct(u){return typeof u=="string"&&u.length<=200&&!/url\(|[;{}]|\/\*|\\/iu.test(u)?u:null}class Tt{constructor(d){Te(this,"sheet");Te(this,"base");Te(this,"rules",new Map);Te(this,"phone",null);Te(this,"phoneRules",new Map);if(d.sheet===null)throw new Error("the runtime stylesheet did not load");this.sheet=d.sheet,this.base=this.sheet.cssRules.length}reset(){for(;this.sheet.cssRules.length>this.base;)this.sheet.deleteRule(this.sheet.cssRules.length-1);this.rules.clear(),this.phoneRules.clear(),this.phone=null}rule(d){if(!it.test(d))throw new Error("a selector outside the runtime’s vocabulary");const m=this.rules.get(d);if(m!==void 0)return m;const y=this.sheet.insertRule(`${d} {}`,this.sheet.cssRules.length),h=this.sheet.cssRules[y];return this.rules.set(d,h),h}phoneRule(d){if(!it.test(d))throw new Error("a selector outside the runtime’s vocabulary");const m=this.phoneRules.get(d);if(m!==void 0)return m;if(this.phone===null){const N=this.sheet.insertRule(`@media ${Dt} {}`,this.sheet.cssRules.length);this.phone=this.sheet.cssRules[N]}const y=this.phone.insertRule(`${d} {}`,this.phone.cssRules.length),h=this.phone.cssRules[y];return this.phoneRules.set(d,h),h}set(d,m,y){Ot.test(m)&&d.style.setProperty(m,y)}theme(d,m){const y=this.rule(":root");for(const[k,M]of Object.entries(d)){const Y=Ct(M);/^--[a-z0-9-]{1,40}$/u.test(k)&&Y!==null&&this.set(y,k,Y)}const h=je(m.accent);h!==null&&this.set(y,"--app-accent",h),m.density==="compact"&&(this.set(y,"--row","36px"),this.set(y,"--gap","8px"));const N=Array.isArray(m.palette)?m.palette:[];for(let k=0;k<12;k+=1){const M=je(N[k]);M!==null&&this.set(y,`--s${k}`,M)}}place(d,m){const y=this.rule(`.wk-c${d}`),h=qe(m.x,0,11,0),N=qe(m.w,1,12-h,1),k=qe(m.y,0,999,0),M=qe(m.h,1,50,1);this.set(y,"grid-column",`${h+1} / span ${N}`),this.set(y,"grid-row",`${k+1} / span ${M}`)}phoneOrder(d,m,y){const h=this.phoneRule(`.wk-c${d}`);this.set(h,"order",String(qe(m,0,9999,0))),y?this.set(h,"display","none"):h.style.removeProperty("display")}seriesColour(d,m,y){const h=je(y);h!==null&&this.set(this.rule(`.wk-c${d}`),`--c${qe(m,0,11,0)}`,h)}}const Rt={comfortable:44,compact:36},at={comfortable:12,compact:8},It=450,rt=500,Ft=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/u,Ie=()=>Object.create(null);function zt(u,d){if(u===void 0||d===null||d===void 0)return d;if((u.type==="number"||u.type==="integer")&&typeof d=="string"&&d.trim()!==""){const m=Number(d);return Number.isFinite(m)&&(u.type==="number"||Number.isInteger(m))?m:d}return u.type==="boolean"&&typeof d=="string"&&(d==="true"||d==="false")?d==="true":u.type==="string"&&(typeof d=="number"||typeof d=="boolean")?String(d):d}const ee=u=>typeof u=="object"&&u!==null&&!Array.isArray(u),_t=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/u,lt={table:{w:12,h:5},chart:{w:6,h:5},kpi:{w:3,h:2},text:{w:6,h:1},filter:{w:3,h:1},form:{w:4,h:6},button:{w:2,h:1},image:{w:3,h:3},link:{w:2,h:1}},Bt=[{type:"table",label:"Table"},{type:"chart",label:"Chart"},{type:"kpi",label:"KPI"},{type:"filter",label:"Filter"},{type:"form",label:"Form"},{type:"button",label:"Button"},{type:"text",label:"Text"},{type:"link",label:"Link"}];function p(u,d,m){const y=document.createElement(u);return d!==void 0&&(y.className=d),m!==void 0&&(y.textContent=m),y}function pt(u){return u.toISOString().slice(0,10)}function Ht(u,d){Wt({editor:"wicked-apps",surfaces:{}},{port:u,hello:d})}function Wt(u,d){const m=document.getElementById("wk-apps-sheet")??(d===void 0?null:document.querySelector('link[rel="stylesheet"], style'));if(!(m instanceof HTMLStyleElement)&&!(m instanceof HTMLLinkElement))return;const y=new Tt(m),h=p("div","wk-app");h.setAttribute("data-testid","apps-runtime"),document.body.append(h);let N=null,k=new Set,M=!0,Y=!1,Ee=!1,ge=!1,V="preview",Me="full",ae="en",j=0,I=null,Ae=!1,X=null,z=null;const G=Ie(),me=new Map,be=Ie(),Oe=Ie(),te=new Map,$e=new Map,Le=new Map,re=new Map,Fe=new Map;let g=0,x=0;const L=new Map;let E=null;const O=new Map;let S=!1,$=null,R=null;const D=e=>{N?.postMessage({p:ie,v:1,...e})},A=(e,t)=>{x+=1;const n=`a${x}`;return D({type:e,id:n,payload:t}),new Promise(i=>L.set(n,i))},_=(e,t)=>D({type:e,payload:t}),P=e=>{const t=e.data;if(!ee(t)||t.p!==ie||t.v!==1)return;const n=ee(t.payload)?t.payload:{};if(typeof t.re=="string"){const i=L.get(t.re);if(i===void 0)return;L.delete(t.re);const s=ee(t.error)?t.error:{};i(t.ok===!0?{ok:!0,payload:n}:{ok:!1,code:String(s.code??"unavailable"),message:F(s.message,300),payload:n});return}if(!S)switch(t.type){case"host.ping":typeof t.id=="string"&&D({re:t.id,ok:!0,payload:{}});return;case"host.theme":ee(n.theme)&&(K=n.theme),U();return;case"artifact.changed":ue();return;case"app.mode":(n.mode==="edit"||n.mode==="preview")&&(V=n.mode,V==="preview"&&(z=null),U());return;case"data.invalidate":Ne();return;case"host.surface":(n.surface==="card"||n.surface==="full")&&(Me=n.surface,U());return;case"selection.cleared":z=null,U();return;case"host.teardown":S=!0;for(const i of O.values())clearInterval(i);O.clear(),document.removeEventListener("keydown",Mt),N?.close(),N=null,h.replaceChildren(p("p","wk-empty","Closed"));return;default:return}};let K={};const de=e=>{ee(e)&&(K=e),y.theme(K,{accent:I?.theme?.accent,palette:I?.theme?.palette,density:I?.theme?.density})},Se=()=>I?.theme?.density==="compact"?"compact":"comfortable",ce=(e,t)=>{N=e,N.onmessage=P,k=new Set(Array.isArray(t.grants)?t.grants.filter(s=>typeof s=="string"):[]);const n=ee(t.app)?t.app:{};if(M=n.framed!==!1,Y=n.tile===!0,Ee=Y&&n.rows===!0,ge=n.propsHost===!0,V=n.mode==="edit"?"edit":"preview",Me=t.surface==="card"||t.size==="inline"?"card":"full",ee(n.url))for(const[s,l]of Object.entries(n.url).slice(0,30))Ft.test(s)&&typeof l=="string"&&l.length<=1e3&&(Oe[s]=l);const i=ee(t.prefs)?t.prefs:{};ae=typeof i.locale=="string"&&/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(i.locale)?i.locale:"en",de(t.theme),ue()};d===void 0&&window.addEventListener("message",e=>{const t=e.data;N!==null||e.source!==parent||!ee(t)||t.p!==ie||t.type!=="host.hello"||e.ports[0]===void 0||ce(e.ports[0],ee(t.payload)?t.payload:{})});const ue=async()=>{const e=await A("artifact.read",{});if(!e.ok){E=e.message,U();return}const t=ee(e.payload.content)?e.payload.content:{};if(t.type!=="app"||!ee(t.spec)){E="This is not an app",U();return}const n=j;j=typeof e.payload.version=="number"?e.payload.version:0,I=t.spec,Ae=t.readonly===!0,(X===null||!I.pages.some(s=>s.id===X))&&(X=I.pages[0]?.id??null),z!==null&&!Q().some(s=>s.id===z)&&(z=null),E=null,Ge();const i=we();U(),(n!==j||i||te.size===0)&&Ne()},we=()=>{const e=new Map;for(const n of I?.pages??[])for(const i of n.components){const s=Je(i);s!==null&&e.set(i.id,oe(s))}let t=!1;for(const n of[...te.keys()])$e.get(n)!==e.get(n)&&(te.delete(n),$e.delete(n),t=!0);return t},oe=e=>`${e.query}\0${JSON.stringify(e.params)}`,We=()=>I?.pages.find(e=>e.id===X)??null,Q=()=>We()?.components??[],Kt=(e,t)=>{const n=G[e];if(n!==void 0)return typeof n=="string"?t===void 0?n:void 0:t==="from"?n.from:t==="to"?n.to:void 0},Ke=(e,t,n)=>{const i={},s=n?.properties??{};for(const[l,a]of Object.entries(e??{})){const[r,o,f]=a.split(".");let v;if(r==="filter"&&o!==void 0)v=Kt(o,f);else if(r==="row"&&o!==void 0&&t.row!==void 0&&Object.hasOwn(t.row,o))v=t.row[o];else if(r==="form"&&o!==void 0&&t.form!==void 0){const b=be[t.form];v=b!==void 0&&Object.hasOwn(b,o)?b[o]:void 0}else r==="url"&&o!==void 0&&(v=Oe[o]);v!==void 0&&v!==""&&(i[l]=zt(Object.hasOwn(s,l)?s[l]:void 0,v))}return i},Ge=()=>{for(const e of I?.pages??[])for(const t of e.components)if(!(t.type!=="filter"||G[t.id]!==void 0))if(t.filter==="date-range"){const n=ee(t.default)&&Number.isInteger(t.default.lastDays)?Math.min(3650,Math.max(1,t.default.lastDays)):30,i=new Date;G[t.id]={from:pt(new Date(i.getTime()-n*864e5)),to:pt(i)}}else G[t.id]=typeof t.default=="string"?t.default:""},dt=e=>I?.queries.find(t=>t.id===e)?.params,Je=e=>e.type==="table"||e.type==="chart"||e.type==="kpi"?{query:e.data.query,params:Ke(e.data.params,{},dt(e.data.query))}:e.type==="filter"&&e.filter==="select"&&e.options?.kind==="query"?{query:e.options.query.query,params:Ke(e.options.query.params,{},dt(e.options.query.query))}:null,Ne=(e,t=!1)=>{if(S||!k.has("data.read")||I===null||Y&&!Ee)return;Ge(),g+=1;const n=g,i=new Map;for(const s of Q()){const l=Je(s);if(l===null||e!==void 0&&l.query!==e||t&&te.has(s.id))continue;const a=oe(l);let r=i.get(a);r===void 0&&(r=A("data.query",{query:l.query,params:l.params}).then(o=>{if(!o.ok)return{state:"error",message:o.message};const f=Array.isArray(o.payload.columns)?o.payload.columns:[],v=Array.isArray(o.payload.rows)?o.payload.rows.filter(Array.isArray):[];return{state:"rows",rows:{columns:f,rows:v,sample:o.payload.sample===!0,hasMore:o.payload.hasMore===!0,truncated:o.payload.truncated===!0}}}),i.set(a,r)),te.has(s.id)||(te.set(s.id,{state:"loading"}),$e.set(s.id,a)),Le.set(s.id,n),r.then(o=>{!S&&Le.get(s.id)===n&&(te.set(s.id,o),$e.set(s.id,a),ze(s.id))})}e===void 0&&Zt()},Zt=()=>{const e=new Map;for(const t of Q()){const n=Je(t),i=n===null?void 0:I?.queries.find(s=>s.id===n.query);i?.refresh?.mode==="every"&&e.set(i.id,Math.max(15,i.refresh.seconds))}for(const[t,n]of[...O]){const[i,s]=t.split("\0");e.get(i)!==Number(s)&&(clearInterval(n),O.delete(t))}for(const[t,n]of e){const i=`${t}\0${n}`;O.has(i)||O.set(i,setInterval(()=>{document.visibilityState==="visible"&&Ne(t)},n*1e3))}},Xt=async(e,t,n)=>{if(M||V!=="preview"||!k.has("data.write"))return;const i=Q().find(o=>o.id===e)?.type!=="button",s=o=>{i?(re.set(e,o),ze(e)):ft(`${F(t.label,60)}: ${o}`)};s("Waiting for you in studio…");const l=await A("data.action",{action:t.action,params:Ke(t.params,n,I?.actions.find(o=>o.id===t.action)?.params)}),a=l.ok?String(l.payload.state):"refused",r=l.ok?F(l.payload.reason,200):l.message;s(a==="succeeded"?`Done${r!==""?`: ${r}`:""}`:a==="cancelled"?"Not run":a==="unknown"?`Not known whether it ran: ${r}`:`Not run: ${r}`)},Qe=(e,t,n,i="wk-btn wk-btn--sm")=>{if(M)return p("span","wk-muted","Open to make changes");const s=p("button",i,F(t.label,60));return s.type="button",s.setAttribute("data-action",t.action),Y||V!=="preview"||!k.has("data.write")?(s.setAttribute("aria-disabled","true"),s.title=Y?"":V==="edit"?"Actions run in Preview":"This app may not ask to run actions here"):s.addEventListener("click",l=>{l.stopPropagation(),Xt(e,t,n)}),s},et=new Map;let se=null,tt=null;const nt=new Map,Ze=new WeakSet,ot=new WeakSet;let Xe=null;const Yt=()=>{const e=document.activeElement;if(!(e instanceof HTMLInputElement)||e.type!=="search"||e.closest(".wk-filter-options")===null)return null;const t=e.closest("[data-component]")?.getAttribute("data-component");return t==null?null:{id:t,el:e,range:[e.selectionStart,e.selectionEnd,e.selectionDirection]}},ct=e=>{if(e===null)return;const t=[...h.querySelectorAll("[data-component]")].find(n=>n.getAttribute("data-component")===e.id)?.querySelector('.wk-filter-options input[type="search"]');t==null||t===e.el||(t.focus({preventScroll:!0}),t.setSelectionRange(e.range[0],e.range[1],e.range[2]??void 0))},ut=(e,t)=>{const n=t.querySelector('.wk-filter-options input[type="search"]'),i=n!==null&&document.activeElement===n;if(i&&Ze.has(n)){ot.add(n);return}const s=i?[n.selectionStart,n.selectionEnd,n.selectionDirection]:null;if(i&&me.set(e.id,n.value),Vt(e,t),Ut(e,t),s!==null){const l=t.querySelector('.wk-filter-options input[type="search"]');l?.focus({preventScroll:!0}),l?.setSelectionRange(s[0],s[1],s[2]??void 0)}},Ut=(e,t)=>{if(!H())return;const n=(i,s)=>{i!==null&&(i.setAttribute("data-inline",s),i.classList.add("wk-editable"),i.setAttribute("title","Double-click to edit"))};e.type==="text"&&n(t.querySelector(".wk-text"),"text"),e.type==="button"&&n(t.querySelector("button[data-action]"),"label"),e.type==="link"&&n(t.querySelector(".wk-link"),"label"),e.type==="filter"&&n(t.querySelector(".wk-filter-label"),"label")},Vt=(e,t)=>{t.replaceChildren();const n=te.get(e.id);if(e.type==="table"||e.type==="chart"||e.type==="kpi"){if(Y&&!Ee){t.append(p("div",`wk-skeleton wk-skeleton--${e.type}`));return}if(!k.has("data.read")){t.append(p("p","wk-muted","Live rows are not shown here"));return}if(n===void 0||n.state==="loading"){t.append(p("p","wk-muted","Loading…"));return}if(n.state==="error"){t.append(p("p","wk-error",`${"data"in e?e.data.query:""}: ${n.message}`));return}}const s=n?.state==="rows"?n.rows:null;switch(e.type){case"kpi":{const l=o=>o===void 0?-1:s.columns.findIndex(f=>f.name===o),a=s.rows[0];t.append(p("div","wk-kpi-value",a===void 0?"—":ye(a[l(e.value)],e.format,ae)));const r=p("div","wk-kpi-caption");if(a!==void 0&&e.delta!==void 0&&l(e.delta)>=0){const o=a[l(e.delta)],f=typeof o=="number"&&o<0||typeof o=="string"&&o.trim().startsWith("-");r.append(p("span",f?"wk-delta wk-delta--down":"wk-delta wk-delta--up",`${f?"▼":"▲"} ${ye(o,void 0,ae).replace(/^\s*-/u,"")}`)),r.append(document.createTextNode(" "))}e.caption!==void 0&&r.append(document.createTextNode(F(e.caption,120))),t.append(r);return}case"chart":Pt(t,e,s,ae),(s.truncated||s.rows.length>rt)&&t.append(p("p","wk-muted",s.truncated?"Only part of the source’s rows: the answer was cut at the app’s limit":`The first ${rt} of ${s.rows.length} rows`));return;case"table":{jt(e,t,s);return}case"text":t.append(p(e.style==="heading"?"h2":"p",`wk-text wk-text--${e.style??"body"}`,e.text.slice(0,4e3)));return;case"filter":{Gt(e,t);return}case"form":{Jt(e,t);return}case"button":t.append(Qe(e.id,e.action,{},"wk-btn"));return;case"image":{if(!_t.test(e.src)){t.append(p("p","wk-muted","This image is not one the app can show"));return}const l=p("img","wk-image");l.alt=F(e.alt,300),l.src=e.src,t.append(l);return}case"link":{const l=p("button","wk-link",F(e.label,120));if(l.type="button",e.to.kind==="page"){const a=e.to;l.addEventListener("click",()=>{if(V==="preview"){E=null;for(const[r,o]of Object.entries(Ke(a.params,{})))Oe[r]=String(o);I?.pages.some(r=>r.id===a.page)&&(X=a.page,z=null,U(),Ne())}})}else{const a=e.to.href;l.title=a.slice(0,300),l.addEventListener("click",async()=>{if(V!=="preview")return;const r=await A("link.open",{href:a});r.ok||ft(`${F(e.label,60)} not opened: ${r.message}`)})}t.append(l);return}}},jt=(e,t,n)=>{const i=c=>n.columns.findIndex(w=>w.name===c),s=(e.columns??n.columns.map(c=>({column:c.name}))).filter(c=>i(c.column)>=0),l=Math.min(500,Math.max(5,e.pageSize??10)),a=Math.max(1,Math.ceil(n.rows.length/l)),r=Math.min(Fe.get(e.id)??0,a-1),o=p("table","wk-table"),f=p("tr");for(const c of s)f.append(p("th",void 0,F(c.label??c.column,80)));(e.rowActions??[]).length>0&&f.append(p("th","wk-th-actions","")),o.append(p("thead")),o.tHead.append(f);const v=p("tbody");for(const c of n.rows.slice(r*l,r*l+l)){const w=p("tr"),C=Ie();n.columns.forEach((B,T)=>{C[B.name]=c[T]??null});for(const B of s){const T=c[i(B.column)],Z=ye(T,B.format,ae),fe=/^\S+$/u.test(Z),Ue=typeof T=="number"?"wk-num":fe?Z.length>64?"wk-token wk-token--long":"wk-token":"wk-prose",Ce=p("td",Ue,Z);fe&&Z.length>64&&(Ce.title=Z),w.append(Ce)}if((e.rowActions??[]).length>0){const B=p("td","wk-td-actions");for(const T of(e.rowActions??[]).slice(0,4))B.append(Qe(e.id,T,{row:C}));w.append(B)}v.append(w)}o.append(v);const b=p("div","wk-table-scroll");b.tabIndex=0,b.setAttribute("role","region"),b.setAttribute("aria-label",`${F(e.title??"Table",80)}, scrolls sideways`),b.append(o),t.append(b),n.rows.length===0&&t.append(p("p","wk-muted","No rows"));const q=p("div","wk-table-foot");if(a>1){const c=p("button","wk-btn wk-btn--sm","Previous"),w=p("button","wk-btn wk-btn--sm","Next");c.type="button",w.type="button",c.disabled=r===0,w.disabled=r>=a-1,c.addEventListener("click",()=>{Fe.set(e.id,r-1),ze(e.id)}),w.addEventListener("click",()=>{Fe.set(e.id,r+1),ze(e.id)}),q.append(c,p("span","wk-muted",`${r+1} of ${a}`),w)}n.truncated?q.append(p("span","wk-muted",`Only the first ${n.rows.length} rows: the answer was cut at the app’s limit`)):n.hasMore&&q.append(p("span","wk-muted","First page of the source’s rows"));const J=re.get(e.id);J!==void 0&&q.append(p("span","wk-status",J)),q.childNodes.length>0&&t.append(q)},Gt=(e,t)=>{const n=p("label","wk-filter"),i=F(e.label??(e.filter==="search"?"Search":e.filter==="date-range"?"Dates":"Filter"),60),s=p("span","wk-filter-label",i);s.title=i,n.append(s);const l=()=>{Ne()};if(e.filter==="search"){const a=p("input","wk-input");a.type="search",a.value=typeof G[e.id]=="string"?G[e.id]:"";let r=null;a.addEventListener("input",()=>{G[e.id]=a.value.slice(0,200),r!==null&&clearTimeout(r),r=setTimeout(l,300)}),n.append(a)}else if(e.filter==="select"){const a=p("select","wk-input"),r=[];let o=!1;if(e.options?.kind==="values")for(const w of e.options.values)r.push({value:F(w.value,200),label:F(w.label??w.value,200)});if(e.options?.kind==="query"){const w=te.get(e.id);if(w?.state==="rows"){o=w.rows.hasMore||w.rows.truncated;const C=w.rows.columns.findIndex(T=>T.name===e.options.value),B=w.rows.columns.findIndex(T=>T.name===(e.options.label??""));for(const T of w.rows.rows)C>=0&&r.push({value:ye(T[C],void 0,ae),label:ye(T[B>=0?B:C],void 0,ae)})}}const f=p("div","wk-filter-select"),v=p("div","wk-filter-options"),b=p("input","wk-input");b.type="search",b.placeholder="Search",b.setAttribute("aria-label",`Search ${F(e.label??"Filter",60)} options`),b.value=me.get(e.id)??"";const q=p("span","wk-muted");q.setAttribute("aria-live","polite");const J=r.length>200||o,c=()=>{const w=J?b.value.toLowerCase():"",C=r.filter(pe=>pe.label.toLowerCase().includes(w)),B=C.slice(0,200),T=typeof G[e.id]=="string"?G[e.id]:"",Z=T===""?void 0:r.find(pe=>pe.value===T);Z!==void 0&&!B.includes(Z)&&(B.length===200&&B.pop(),B.push(Z)),a.replaceChildren();for(const pe of[{value:"",label:"All"},...B]){const At=p("option",void 0,pe.label);At.value=pe.value,a.append(At)}const fe=B.filter(pe=>C.includes(pe)).length,Ue=w===""?`${fe} of ${r.length}${o?"+":""}`:`${fe}${fe<C.length?` of ${C.length}`:""} matches`,Ce=`Showing ${Ue}${w!==""&&o?" in fetched rows":""}`;if(q.textContent=Ue,q.title=Ce,q.setAttribute("aria-label",Ce),fe<C.length||o){const pe=p("option",void 0,`${Ce}: search to narrow`);pe.disabled=!0,pe.value="",a.append(pe)}a.value=T};b.addEventListener("input",()=>{me.set(e.id,b.value),c()}),b.addEventListener("compositionstart",()=>{Ze.add(b)}),b.addEventListener("compositionend",()=>{if(Ze.delete(b),me.set(e.id,b.value),Xe!==null){const w=Xe;Xe=null,ot.delete(b),U(w)}else ot.delete(b)&&ze(e.id)}),c(),a.addEventListener("change",()=>{G[e.id]=a.value,c(),l()}),n.append(a),f.append(n),J&&(f.classList.add("wk-filter-select--search"),v.append(b,q),f.append(v)),t.append(f);return}else{const a=G[e.id]??{from:"",to:""},r=p("input","wk-input wk-input--date"),o=p("input","wk-input wk-input--date");r.type="date",o.type="date",r.value=a.from,o.value=a.to;const f=()=>{G[e.id]={from:r.value,to:o.value},l()};r.addEventListener("change",f),o.addEventListener("change",f),n.append(r,p("span","wk-muted","–"),o)}t.append(n)},Jt=(e,t)=>{var r;const n=be[r=e.id]??(be[r]=Ie()),i=I?.actions.find(o=>o.id===e.submit.action)?.params?.properties??{};for(const o of e.fields){if(Object.hasOwn(n,o.name))continue;const f=e.submit.params===void 0?void 0:Object.entries(e.submit.params).find(([,b])=>b===`form.${o.name}`)?.[0],v=f!==void 0&&Object.hasOwn(i,f)?i[f].default:void 0;o.input==="checkbox"?n[o.name]=v===!0:v!==void 0&&(n[o.name]=String(v))}const s=p("div","wk-form");for(const o of e.fields.slice(0,30)){const f=p("label","wk-field");f.append(p("span","wk-filter-label",F(o.label??o.name,80)));let v;if(o.input==="textarea")v=p("textarea","wk-input");else if(o.input==="select"){v=p("select","wk-input");for(const b of o.options??[]){const q=p("option",void 0,F(b.label??b.value,200));q.value=F(b.value,200),v.append(q)}}else v=p("input","wk-input"),v.type=o.input==="number"?"number":o.input==="date"?"date":o.input==="checkbox"?"checkbox":"text";v instanceof HTMLInputElement&&v.type==="checkbox"?(v.checked=n[o.name]===!0,v.addEventListener("change",()=>{n[o.name]=v.checked})):(v.value=typeof n[o.name]=="string"?n[o.name]:"",v.addEventListener("input",()=>{n[o.name]=v.value.slice(0,1e3)})),v.disabled=V!=="preview",f.append(v),s.append(f)}const l=p("div","wk-form-foot");l.append(Qe(e.id,e.submit,{form:e.id},"wk-btn"));const a=re.get(e.id);l.append(p("span","wk-muted",a??(M?"":"Studio asks before it writes"))),s.append(l),t.append(s)};let ve=null;const ft=e=>{E=e,ve!==null?(ve.textContent=e,ve.hidden=!1):U()},ze=e=>{if($!==null&&$.id===e)return;const t=Q().find(i=>i.id===e),n=nt.get(e);t!==void 0&&n!==void 0&&ut(t,n)},H=()=>V==="edit"&&Me==="full"&&!Ae&&k.has("artifact.write");let ke=null;const ht=()=>{const e=ke.getBoundingClientRect(),t=Se();return{col:(e.width+at[t])/12,row:Rt[t]+at[t],left:e.left,top:e.top}},Qt=(e,t)=>{const n=ht();return{x:Math.min(11,Math.max(0,Math.floor((e-n.left)/n.col))),y:Math.min(999,Math.max(0,Math.floor((t-n.top)/n.row)))}},le=async(e,t={})=>{const n=await A("spec.edit",{base:j,ops:e});if(!n.ok)return E=n.code==="head_moved"?"The app changed meanwhile: showing the newest version":`Not changed: ${n.message}`,n.code==="head_moved"?await ue():U(),null;ee(n.payload.spec)&&(I=n.payload.spec),E=null,Ge(),we();const i=Array.isArray(n.payload.added)?n.payload.added.filter(s=>typeof s=="string"):[];return i[0]!==void 0&&De(i[0]),U({keepProps:t.typed===!0&&i.length===0}),Ne(void 0,!0),i},De=e=>{const t=z;z=e,e!==null&&k.has("selection.chip")?_("selection.set",{anchors:[{kind:"element",id:e}]}):e===null&&t!==null&&k.has("selection.chip")&&_("selection.set",{anchors:[]})},mt=(e,t,n,i)=>{if(!H()||e.button!==0)return;e.preventDefault(),e.stopPropagation(),(i.closest(".wk-cell")??i).focus({preventScroll:!0});const s=et.get(t.id),l=ht(),a={x:e.clientX,y:e.clientY};let r={...t.box},o=!1;const f=n==="move"?e.target?.closest?.("[data-inline]"):null;i.setPointerCapture(e.pointerId),i.classList.add("is-dragging");const v=q=>{const J=Math.round((q.clientX-a.x)/l.col),c=Math.round((q.clientY-a.y)/l.row);J===0&&c===0&&!o||(o=!0,r=n==="move"?{...t.box,x:Math.min(12-t.box.w,Math.max(0,t.box.x+J)),y:Math.max(0,t.box.y+c)}:{...t.box,w:Math.min(12-t.box.x,Math.max(1,t.box.w+J)),h:Math.min(50,Math.max(1,t.box.h+c))},y.place(s,r))},b=()=>{i.removeEventListener("pointermove",v),i.removeEventListener("pointerup",b),i.removeEventListener("pointercancel",b),i.classList.remove("is-dragging");const q=n==="move"?r.x!==t.box.x||r.y!==t.box.y:r.w!==t.box.w||r.h!==t.box.h;if(!o||!q){y.place(s,t.box),o||(De(t.id),vt(),kt(t.id,f));return}le([n==="move"?{op:"component-move",id:t.id,x:r.x,y:r.y}:{op:"component-resize",id:t.id,w:r.w,h:r.h}])};i.addEventListener("pointermove",v),i.addEventListener("pointerup",b),i.addEventListener("pointercancel",b)},wt=()=>Q().reduce((e,t)=>Math.max(e,t.box.y+t.box.h),0),en=(e,t,n)=>{if(!H()||e.button!==0||ke===null||X===null)return;e.preventDefault(),n.focus({preventScroll:!0});const i=lt[t],s=p("div","wk-drop wk-c9999");s.setAttribute("data-testid","apps-drop-target");let l=null;n.setPointerCapture(e.pointerId);const a=o=>{const f=ke.getBoundingClientRect();if(o.clientX<f.left||o.clientX>f.right||o.clientY<f.top){s.remove(),l=null;return}l=Qt(o.clientX,o.clientY),l.x=Math.min(l.x,12-i.w),y.place(9999,{x:l.x,y:l.y,w:i.w,h:i.h}),s.parentNode===null&&ke.append(s)},r=o=>{if(n.removeEventListener("pointermove",a),n.removeEventListener("pointerup",r),n.removeEventListener("pointercancel",r),s.remove(),Math.abs(o.clientX-e.clientX)+Math.abs(o.clientY-e.clientY)>6&&l===null)return;const v=l??{x:0,y:wt()};le([{op:"component-add",page:X,type:t,box:{x:v.x,y:v.y,w:Math.min(i.w,12-v.x),h:i.h}}])};n.addEventListener("pointermove",a),n.addEventListener("pointerup",r),n.addEventListener("pointercancel",r)},st=(e,t,n=!1,i)=>{let s=e.value,l=null;const a=()=>{if(e.value===s)return;s=e.value;const o=t();if(o===void 0)return;const f=Promise.resolve(o);l=f,f.finally(()=>{l===f&&(l=null)})};let r=!1;e.addEventListener("compositionstart",()=>{r=!0}),e.addEventListener("compositionend",()=>{r=!1,a()}),e.addEventListener("input",o=>{!r&&o.isComposing!==!0&&a()}),i!==void 0&&e.addEventListener("blur",()=>{const o=()=>{if(document.activeElement===e)return;const f=i();e.value!==f&&(e.value=f,s=f)};l!==null?l.then(o,o):o()}),e.addEventListener("change",()=>{r||a()}),e.addEventListener("keydown",o=>{const f=o;r||f.isComposing||f.keyCode===229||f.key==="Enter"&&(!n||f.metaKey||f.ctrlKey)&&(f.preventDefault(),a())})},_e=(e,t)=>{const n=p("label","wk-prop");return n.append(p("span","wk-prop-label",e),t),n},Pe=(e,t,n,i,s,l=!1)=>{const a=p(l?"textarea":"input","wk-input");return a.value=i??"",a.maxLength=s,a.setAttribute("data-prop",n),st(a,()=>le([{op:"component-set",id:e.id,prop:n,value:a.value}],{typed:!0}),l,()=>{const r=Q().find(f=>f.id===e.id),o=n==="label"&&r?.type==="button"?r.action?.label:r?.[n];return typeof o=="string"?o:""}),_e(t,a)},Be=(e,t,n,i,s,l="set")=>{const a=p("select","wk-input");for(const r of s){const o=p("option",void 0,r);o.value=r,a.append(o)}return a.value=i,a.setAttribute("data-prop",n),a.addEventListener("change",()=>{le([l==="bind"?{op:"bind",id:e.id,query:a.value}:{op:"component-set",id:e.id,prop:n,value:a.value}])}),_e(t,a)},yt=(e,t,n,i)=>{const s=p("input","wk-check");return s.type="checkbox",s.checked=i,s.setAttribute("data-prop",n),s.addEventListener("change",()=>{le([{op:"component-set",id:e.id,prop:n,value:s.checked}])}),_e(t,s)},Ye=(e,t,n,i,s)=>{const l=p("input","wk-input wk-input--num");l.type="number",l.min=String(i),l.max=String(s),l.value=String(n==="x"?e.box.x+1:n==="y"?e.box.y+1:e.box[n]),l.setAttribute("data-prop",`box-${n}`);const a=()=>Q().find(o=>o.id===e.id)?.box??e.box,r=o=>String(n==="x"?o.x+1:n==="y"?o.y+1:o[n]);return st(l,()=>{if(l.value.trim()==="")return;const o=Math.round(Number(l.value));if(!Number.isFinite(o))return;const f=a();if(n==="x"||n==="y"){const q=n==="x"?Math.min(12-f.w,Math.max(0,o-1)):f.x,J=n==="y"?Math.max(0,o-1):f.y;return le([{op:"component-move",id:e.id,x:q,y:J}],{typed:!0})}const v=n==="w"?Math.min(12-f.x,Math.max(1,o)):f.w,b=n==="h"?Math.min(50,Math.max(1,o)):f.h;return le([{op:"component-resize",id:e.id,w:v,h:b}],{typed:!0})},!1,()=>r(a())),_e(t,l)},gt=e=>{const t=p("aside","wk-props");t.setAttribute("aria-label","Properties"),t.setAttribute("data-testid","apps-properties"),t.append(p("h3","wk-props-title","Properties")),t.append(p("p","wk-muted",`${e.type==="chart"?`${e.chart} chart`:e.type} · ${e.id}`)),t.append(Pe(e,"Title","title",e.title,120));const n=(I?.queries??[]).map(a=>a.id),i=a=>I?.queries.find(r=>r.id===a)?.output.map(r=>r.name)??[];if((e.type==="table"||e.type==="chart"||e.type==="kpi")&&t.append(Be(e,"Data","query",e.data.query,n,"bind")),e.type==="table"){const a=p("input","wk-input wk-input--num");a.type="number",a.min="5",a.max="500",a.value=String(e.pageSize??10),a.setAttribute("data-prop","pageSize"),st(a,()=>{if(a.value.trim()==="")return;const r=Math.round(Number(a.value));return Number.isFinite(r)?le([{op:"component-set",id:e.id,prop:"pageSize",value:Math.min(500,Math.max(5,r))}],{typed:!0}):void 0},!1,()=>String(Q().find(r=>r.id===e.id)?.pageSize??10)),t.append(_e("Rows per page",a))}e.type==="chart"&&(t.append(Be(e,"Chart","chart",e.chart,["bar","line","area","pie"])),t.append(Be(e,"Category","x",e.x,i(e.data.query))),(e.chart==="bar"||e.chart==="area")&&t.append(yt(e,"Stacked","stacked",e.stacked===!0))),e.type==="kpi"&&(t.append(Be(e,"Figure","value",e.value,i(e.data.query))),t.append(Pe(e,"Caption","caption",e.caption,120))),e.type==="text"&&(t.append(Pe(e,"Text","text",e.text,4e3,!0)),t.append(Be(e,"Style","style",e.style??"body",["heading","body","caption"]))),e.type==="filter"&&t.append(Pe(e,"Label","label",e.label,120)),e.type==="button"&&t.append(Pe(e,"Label","label",e.action.label,60)),e.type==="link"&&t.append(Pe(e,"Label","label",e.label,120)),e.type==="image"&&t.append(Pe(e,"Description","alt",e.alt,300));const s=p("div","wk-prop-box");s.append(Ye(e,"Column","x",1,12),Ye(e,"Row","y",1,1e3),Ye(e,"Width","w",1,12),Ye(e,"Height","h",1,50)),t.append(s),t.append(yt(e,"Hide on phones","hideOnPhone",e.hideOnPhone===!0));const l=p("button","wk-btn wk-btn--danger","Delete this component");return l.type="button",l.setAttribute("data-testid","apps-remove"),l.addEventListener("click",()=>{const a=e.id;z=null,le([{op:"component-remove",id:a}])}),t.append(l),t},bt=()=>{const e=p("aside","wk-props wk-props--empty");return e.setAttribute("aria-label","Properties"),e.setAttribute("data-testid","apps-properties-empty"),e.append(p("h3","wk-props-title","Properties")),e.append(p("p","wk-muted","Select a component to change it here. Double-click its words to edit them in place.")),e},tn=()=>{const e=p("aside","wk-palette");e.setAttribute("aria-label","Components"),e.append(p("h3","wk-props-title","Components")),e.append(p("p","wk-muted","Drag onto the canvas, or click to add"));const t=p("div","wk-tiles");for(const n of Bt){const i=p("button","wk-tile",n.label);i.type="button",i.setAttribute("data-palette",n.type),i.addEventListener("pointerdown",s=>en(s,n.type,i)),i.addEventListener("click",s=>{if(s.detail!==0||!H()||X===null)return;const l=lt[n.type];le([{op:"component-add",page:X,type:n.type,box:{x:0,y:wt(),w:l.w,h:l.h}}])}),t.append(i)}return e.append(t),e},U=(e={})=>{const t=$;let n=!1;if(t!==null){const i=H()?Q().find(s=>s.id===t.id):void 0;if(n=i!==void 0&&xt(i,t.prop)===t.before,n&&t.composing()){t.defer();return}n?t.hold():t.drop()}nn(e),n&&t!==null&&$===t&&t.place()},nn=e=>{const t=h.querySelector(".wk-pages"),n=t?.scrollLeft??0,i=e.focusPage===!0||(t?.contains(document.activeElement)??!1),s=Yt();if(s!==null&&Ze.has(s.el)){Xe=e;return}s!==null&&me.set(s.id,s.el.value);const l=document.activeElement instanceof HTMLElement&&h.contains(document.activeElement)?document.activeElement.getAttribute("data-prop"):null;if(nt.clear(),et.clear(),y.reset(),de(void 0),h.setAttribute("data-mode",H()?"edit":"preview"),h.setAttribute("data-tile",Y?"true":"false"),h.setAttribute("data-surface",Me),I===null){h.replaceChildren(p("p","wk-empty",E??"Loading the app…")),se=null;return}const a=[];H()&&a.push(tn());const r=p("main","wk-main"),o=p("nav","wk-pages");o.setAttribute("aria-label","Pages");for(const c of I.pages){const w=p("button",c.id===X?"wk-page is-on":"wk-page",F(c.title,80));w.type="button",w.setAttribute("aria-current",c.id===X?"page":"false"),w.addEventListener("click",()=>{X!==c.id&&(X=c.id,De(null),U({focusPage:!0}),Ne())}),o.append(w)}r.append(o),ve=p("p","wk-notice",E??""),ve.setAttribute("data-testid","apps-notice"),ve.setAttribute("aria-live","polite"),ve.hidden=E===null,r.append(ve),Ae&&V==="edit"&&r.append(p("p","wk-notice","A chat turn is changing this app: it is read-only until the turn ends")),ke=p("div","wk-grid");const f=Q(),v=[...f].sort((c,w)=>c.box.y-w.box.y||c.box.x-w.box.x);f.forEach((c,w)=>{et.set(c.id,w),y.place(w,c.box),y.phoneOrder(w,v.indexOf(c),c.hideOnPhone===!0),c.type==="chart"&&c.series.slice(0,12).forEach((T,Z)=>y.seriesColour(w,Z,T.color));const C=p("section",`wk-cell wk-cell--${c.type} wk-c${w}${c.id===z&&H()?" is-selected":""}`);if(C.setAttribute("data-component",c.id),c.title!==void 0&&c.type!=="text"){const T=p("h3","wk-cell-title",F(c.title,120));H()&&(T.setAttribute("data-inline","title"),T.classList.add("wk-editable"),T.setAttribute("title","Double-click to edit")),C.append(T)}const B=p("div","wk-cell-body");if(nt.set(c.id,B),ut(c,B),C.append(B),H()){C.classList.add("is-editable"),C.tabIndex=0,C.setAttribute("aria-label",`${c.type==="chart"?`${c.chart} chart`:c.type} ${F(c.title??c.id,80)}: Enter to select`),C.append(p("span","wk-tag",`${c.type==="chart"?`${c.chart} chart`:c.type}${"data"in c&&c.data!==void 0?` · ${c.data.query}`:""}`));const T=p("span","wk-handle");T.setAttribute("aria-hidden","true"),T.addEventListener("pointerdown",Z=>mt(Z,c,"resize",T)),C.append(T),C.addEventListener("pointerdown",Z=>{Z.target.closest("input, select, textarea, button, .wk-handle")===null&&mt(Z,c,"move",C)}),C.addEventListener("pointerup",Z=>{const fe=Z.target.closest?.("button[data-inline]");fe!==null&&Z.button===0&&kt(c.id,fe)})}ke.append(C)}),f.length===0&&ke.append(p("p","wk-empty",H()?"Drag a component here from the palette":"This page is empty")),r.append(ke),a.push(r);const b=H()&&z!==null?f.find(c=>c.id===z):void 0,q=()=>{o.scrollLeft=n;const c=o.querySelector(".is-on");i&&c?.focus({preventScroll:!0}),c?.scrollIntoView?.({block:"nearest",inline:"nearest"})};if(e.keepProps===!0&&b!==void 0&&se!==null&&tt===b.id&&se.parentNode===h){for(const c of[...h.childNodes])c!==se&&c.remove();for(const c of a)h.insertBefore(c,se);q(),ct(s);return}se=ge?null:b!==void 0?gt(b):H()?bt():null,tt=b?.id??null,h.replaceChildren(...a,...se!==null?[se]:[]),q(),ct(s),l!==null&&[...h.querySelectorAll("[data-prop]")].find(c=>c.getAttribute("data-prop")===l)?.focus({preventScroll:!0})},vt=()=>{for(const n of h.querySelectorAll("[data-component]"))n.classList.toggle("is-selected",H()&&n.getAttribute("data-component")===z);const e=H()&&z!==null?Q().find(n=>n.id===z):void 0,t=ge?null:e!==void 0?gt(e):H()?bt():null;se!==null&&t!==null&&se.parentNode===h?se.replaceWith(t):(se?.remove(),t!==null&&h.append(t)),se=t,tt=e?.id??null},kt=(e,t)=>{const n=t?.getAttribute("data-inline")??null,i=Date.now();n!==null&&t!==null&&R!==null&&R.id===e&&R.prop===n&&i-R.at<It?(R=null,t.isConnected&&Et(e,t)):R=n!==null?{id:e,prop:n,at:i}:null},xt=(e,t)=>{if(t==="title")return e.title??"";if(t==="text"&&e.type==="text")return e.text;if(t==="label"){if(e.type==="button")return e.action.label;if(e.type==="link")return e.label;if(e.type==="filter")return e.label??""}return""},Et=(e,t)=>{const n=Q().find(c=>c.id===e),i=t.getAttribute("data-inline");if(n===void 0||i===null||!H()||$!==null)return;const s=xt(n,i),l=i==="text",a=l?p("textarea","wk-inline-input wk-inline-input--multi"):p("input","wk-inline-input");a.value=s,a.maxLength=l?4e3:n.type==="button"?60:120,a.setAttribute("data-testid","apps-inline"),a.setAttribute("aria-label",`Edit the ${i==="text"?"text":i}`),t.replaceWith(a),a.closest("[data-component]")?.classList.add("is-inline"),a.focus(),a.select();let r=!1,o=!1,f=!1,v=!1,b=[null,null,"none"];const q={id:e,prop:i,before:s,drop:()=>{r=!0,f=!1,$===q&&($=null)},hold:()=>{f=!0,b=[a.selectionStart,a.selectionEnd,a.selectionDirection??"none"]},composing:()=>o,defer:()=>{v=!0},place:()=>{const c=[...h.querySelectorAll("[data-component]")].find(C=>C.getAttribute("data-component")===e),w=c===void 0?void 0:[...c.querySelectorAll("[data-inline]")].find(C=>C.getAttribute("data-inline")===i);if(w===void 0){q.drop();return}w.replaceWith(a),c.classList.add("is-inline"),a.focus(),b[0]!==null&&b[1]!==null&&a.setSelectionRange(b[0],b[1],b[2]),f=!1}};$=q;const J=c=>{r||(q.drop(),c&&a.value!==s?le([{op:"component-set",id:e,prop:i,value:a.value}]):U())};a.addEventListener("compositionstart",()=>{o=!0}),a.addEventListener("compositionend",()=>{o=!1,v&&(v=!1,r||U())}),a.addEventListener("keydown",c=>{const w=c;if(!(o||w.isComposing||w.keyCode===229)){if(w.key==="Escape"){w.preventDefault(),w.stopPropagation(),J(!1);return}w.key==="Enter"&&!(l&&w.shiftKey)&&(w.preventDefault(),w.stopPropagation(),J(!0))}}),a.addEventListener("blur",()=>{f||(a.isConnected?J(!0):q.drop())})};h.addEventListener("dblclick",e=>{if(!H()||$!==null)return;const n=((typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):null)??e.target)?.closest("[data-inline]"),i=n?.closest("[data-component]");n==null||i===null||i===void 0||(e.preventDefault(),Et(i.getAttribute("data-component"),n))});function Mt(e){if(N===null||I===null)return;const t=e.target?.closest?.(".wk-cell.is-editable");if(t!==null&&(e.key==="Enter"||e.key===" ")&&e.target===t){e.preventDefault();const s=t.getAttribute("data-component");s!==null&&(De(s),vt(),h.querySelector(".wk-props input, .wk-props select")?.focus());return}const n=e.target?.closest("input, textarea, select")!=null;if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="z"&&!n&&H()){e.preventDefault(),A("app.history",{move:e.shiftKey?"redo":"undo",base:j}).then(s=>{s.ok||(E=s.message,s.code==="head_moved"?ue():U())});return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&H()&&z!==null){e.preventDefault();const s=z;De(null),le([{op:"component-remove",id:s}]);return}e.key==="Escape"&&z!==null&&!n&&(De(null),U())}document.addEventListener("keydown",Mt),h.append(p("p","wk-empty","Loading the app…")),d===void 0?Lt(u.editor,u.surfaces):ce(d.port,d.hello)}return he.boot=Ht,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"}),he})({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,a as t,c as k,j as y,f as m}from"./index-
|
|
1
|
+
import{r as c,a as t,c as k,j as y,f as m}from"./index-rMZ47jUD.js";k.use(m);const w={source:"--status-gate",table:"--accent-dim",shape:"--accent",code:"--status-run",repo:"--ink-muted",knowledge:"--ink-muted",tracker:"--ink-high",project:"--kn-project",issue:"--kn-issue",run:"--kn-run",pr:"--kn-pr"},b={source:"round-rectangle",table:"rectangle",shape:"diamond",code:"ellipse",repo:"hexagon",knowledge:"triangle",tracker:"tag",project:"barrel",issue:"round-pentagon",run:"cut-rectangle",pr:"rhomboid"},f={source:34,table:24,shape:26,code:22,repo:30,knowledge:18,tracker:30,project:36,issue:22,run:24,pr:24},p=new Set(["describes","joins","governed_by","measures","tracked_in","addresses","closes"]);function E({nodes:l,edges:i,onSelect:d}){const n=c.useRef(null),a=c.useRef(d);return a.current=d,c.useEffect(()=>{if(n.current===null)return;const s=new Map(l.map((e,r)=>[e.key,`n${r}`])),u=t("--ink-high"),g=t("--ink-dim"),h=[...l.map(e=>({group:"nodes",data:{id:s.get(e.key),label:e.label,color:t(w[e.kind]),shape:b[e.kind],size:f[e.kind],kind:e.kind,raw:e}})),...i.filter(e=>s.has(e.from)&&s.has(e.to)).map((e,r)=>({group:"edges",data:{id:`e${r}`,source:s.get(e.from),target:s.get(e.to),rel:e.rel,label:p.has(e.rel)?e.rel.replace("_"," "):""},classes:p.has(e.rel)?`typed rel-${e.rel}`:"quiet"}))],o=k({container:n.current,elements:h,style:[{selector:"node",style:{"background-color":"data(color)",shape:"data(shape)",width:"data(size)",height:"data(size)",label:"data(label)","font-size":11,"font-family":"ui-sans-serif, system-ui, sans-serif",color:u,"text-valign":"bottom","text-halign":"center","text-margin-y":4,"text-max-width":"140px","text-wrap":"ellipsis","text-background-color":t("--surface-base"),"text-background-opacity":.85,"text-background-padding":"2px"}},{selector:"node:selected",style:{"border-width":3,"border-color":t("--accent")}},{selector:"edge",style:{width:1,"curve-style":"bezier","line-color":g,"target-arrow-color":g,"target-arrow-shape":"none",opacity:.45}},{selector:"edge.typed",style:{width:2,opacity:.95,"target-arrow-shape":"triangle","arrow-scale":.8,label:"data(label)","font-size":10,color:u,"text-rotation":"autorotate","text-background-color":t("--surface-base"),"text-background-opacity":.9,"text-background-padding":"2px"}},{selector:"edge.rel-joins",style:{"line-color":t("--accent"),"target-arrow-color":t("--accent"),"line-style":"solid"}},{selector:"edge.rel-describes",style:{"line-color":t("--status-run"),"target-arrow-color":t("--status-run"),"line-style":"dashed"}},{selector:"edge.rel-governed_by",style:{"line-color":t("--status-gate"),"target-arrow-color":t("--status-gate"),"line-style":"dotted",width:3}},{selector:"edge.rel-tracked_in",style:{"line-color":t("--ink-muted"),"target-arrow-color":t("--ink-muted"),"line-style":"solid"}},{selector:"edge.rel-addresses, edge.rel-closes",style:{"line-color":t("--status-warn"),"target-arrow-color":t("--status-warn"),"line-style":"dashed"}}],layout:{name:"fcose",animate:!1,randomize:!0,quality:"default",idealEdgeLength:140,nodeRepulsion:2e4,numIter:2500,nodeSeparation:100},wheelSensitivity:.3,minZoom:.2,maxZoom:3});return o.on("tap","node",e=>{var r;return(r=a.current)==null?void 0:r.call(a,e.target.data("raw"))}),o.on("tap",e=>{var r;e.target===o&&((r=a.current)==null||r.call(a,null))}),o.ready(()=>{o.destroyed()||o.fit(void 0,32)}),()=>o.destroy()},[l,i]),y.jsx("div",{ref:n,className:"wk-know-graph","data-testid":"knowledge-graph-canvas",role:"img","aria-label":"The knowledge map: sources, tables, repositories, code, data shapes, and trackers with the projects and repositories they are tracked in"})}export{E as KnowledgeGraph,p as NAMED_RELS};
|