@surfaces-ui/page 0.5.0 → 0.6.0
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/surfaces-connected.js +20 -19
- package/dist/surfaces-page.css +1 -1
- package/dist/surfaces-page.js +18 -17
- package/package.json +10 -10
|
@@ -15,35 +15,36 @@ var surfaces=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mod
|
|
|
15
15
|
`).trim(),r=e=>{let t=e.indexOf(`{`);if(t!==-1)try{let n=JSON.parse(e.slice(t));if(gE(n)&&(n.success===!1||n.status===`error`))return String(n.error??n.message??``)}catch{}};return e.isError===!0?r(n)??n.replace(/^Error( calling tool '[^']*')?:\s*/i,``)??`The data server reported an error.`:t.length===1&&/^Error:\s/.test(n)?n.replace(/^Error:\s*/,``):r(n)}function CE(e){let t=yE(e.structuredContent);if(t)return t;let n=(Array.isArray(e.content)?e.content.filter(gE):[]).flatMap(e=>typeof e.text==`string`?[e.text]:[]);if(n.length===0)return{columns:[],rows:[],truncated:!1};for(let e of n){let t=xE(e);if(t&&(t.rows.length>0||t.columns.length>0||n.length===1||e.split(/\s/).join(``)===`[]`))return t}let r=[];for(let e of n)try{let t=JSON.parse(e);if(!gE(t))return wE();r.push(t)}catch{return wE()}return vE(r)}function wE(){throw Error(`The data server answered in a form that is not rows. Name its query tool and check that it returns JSON.`)}var TE=[`sql`,`query`,`statement`],EE=[`base_readQuery`,`execute_sql_read_only`,`execute_sql_readonly`,`execute_query`,`execute_sql`,`run_snowflake_query`,`mysql_query`,`read_query`,`query`,`run-sql`];function DE(e,t){let n=e=>{let n=e.inputSchema?.properties??{};return t?.argument??TE.find(e=>e in n)};if(t?.tool){let r=e.find(e=>e.name===t.tool);if(!r)throw new iw(`UNSUPPORTED`,`The data server has no tool named ${t.tool}. It lists: ${e.map(e=>e.name).join(`, `)||`none`}.`);return{tool:r.name,argument:n(r)??`sql`}}let r=e.filter(e=>n(e)!==void 0),i=e=>{let t=EE.indexOf(e.name);return t===-1?/read[_-]?only/i.test(e.name)?EE.length:/(sql|query)/i.test(e.name)?EE.length+1:EE.length+2:t},a=r.sort((e,t)=>i(e)-i(t))[0];if(!a)throw new iw(`UNSUPPORTED`,`The data server lists no tool that takes SQL (an argument named sql, query or statement). Name one with "tool". It lists: ${e.map(e=>e.name).join(`, `)||`none`}.`);return{tool:a.name,argument:n(a)}}function OE(e,t={}){let n,r=()=>(n??=(async()=>{let r;try{r=await e();let n=await r.list();return{caller:r,...DE(n,t),tools:n.map(e=>e.name)}}catch(e){throw await r?.close?.().catch(()=>{}),n=void 0,e instanceof iw?e:new iw(`ENGINE`,`The data server could not be reached. Check that it is running and that its address or command is right.`)}})(),n);return{async query(e,n={}){let{caller:i,tool:a,argument:o}=await r(),s;try{s=await i.call(a,{...t.arguments,[o]:e},{signal:n.signal})}catch(e){throw n.signal?.aborted?new iw(`CANCELLED`,`The query was cancelled.`):e instanceof iw?e:kE(e instanceof Error?e.message:String(e?.message??e))}let c=SE(s);if(c!==void 0)throw kE(c);try{return CE(s)}catch(e){throw new iw(`UNSUPPORTED`,e instanceof Error?e.message:String(e))}},async describe(){let{caller:e,tool:t,argument:n,tools:i}=await r();return{tool:t,argument:n,tools:i,server:e.server??``}},async close(){let e=n;n=void 0,e&&await e.then(({caller:e})=>e.close?.()).catch(()=>{})}}}function kE(e){let t=(e.split(`
|
|
16
16
|
`)[0]??``).replace(/^MCP error -?\d+:\s*/i,``).replace(/^Internal error:\s*/i,``).replace(/^\([\w.]+\)\s*/,``).replace(/^(Error|Binder Error|Catalog Error|Parser Error|Conversion Error):\s*/i,``).trim(),n=e.toLowerCase(),r=(...e)=>e.some(e=>n.includes(e)),i=r(`does not exist`,`not found`,`doesn't exist`);return new iw(r(`timed out`,`timeout`,`time out`)?`TIMEOUT`:r(`syntax error`,`parser error`,`parse error`,`[error 3706]`)?`SYNTAX`:r(`unknown column`,`referenced column`,`[error 3810]`)||r(`column`)&&i?`UNKNOWN_COLUMN`:r(`[error 3807]`)||(r(`relation`,`table`,`object`)||r(`doesn't exist`))&&i?`UNKNOWN_TABLE`:`ENGINE`,t||`The data server reported an error.`)}var L;(function(e){e[e.Canceled=1]=`Canceled`,e[e.Unknown=2]=`Unknown`,e[e.InvalidArgument=3]=`InvalidArgument`,e[e.DeadlineExceeded=4]=`DeadlineExceeded`,e[e.NotFound=5]=`NotFound`,e[e.AlreadyExists=6]=`AlreadyExists`,e[e.PermissionDenied=7]=`PermissionDenied`,e[e.ResourceExhausted=8]=`ResourceExhausted`,e[e.FailedPrecondition=9]=`FailedPrecondition`,e[e.Aborted=10]=`Aborted`,e[e.OutOfRange=11]=`OutOfRange`,e[e.Unimplemented=12]=`Unimplemented`,e[e.Internal=13]=`Internal`,e[e.Unavailable=14]=`Unavailable`,e[e.DataLoss=15]=`DataLoss`,e[e.Unauthenticated=16]=`Unauthenticated`})(L||={});function AE(e){let t=L[e];return typeof t==`string`?t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,e=>`_`+e.toLowerCase()):e.toString()}var jE;function ME(e){if(!jE){jE={};for(let e of Object.values(L))typeof e!=`string`&&(jE[AE(e)]=e)}return jE[e]}zb();var R=class e extends Error{constructor(e,t=L.Unknown,n,r,i){super(NE(e,t)),this.name=`ConnectError`,this.isWireError=!1,Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(n??{}),this.details=r??[],this.cause=i}static from(t,n=L.Unknown){return t instanceof e?t:t instanceof Error?t.name==`AbortError`||t.name==`TimeoutError`?new e(t.message,L.Canceled):new e(t.message,n,void 0,void 0,t):new e(String(t),n,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===e.prototype||t.name===`ConnectError`&&`code`in t&&typeof t.code==`number`&&`metadata`in t&&`details`in t&&Array.isArray(t.details)&&`rawMessage`in t&&typeof t.rawMessage==`string`&&`cause`in t:!1}findDetails(e){let t=e.kind===`message`?{getMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(let e of this.details){if(`desc`in e){t.getMessage(e.desc.typeName)&&n.push(ym(e.desc,e.value));continue}let r=t.getMessage(e.type);if(r)try{n.push(J_(r,e.value))}catch{}}return n}};function NE(e,t){return e.length?`[${AE(t)}] ${e}`:`[${AE(t)}]`}zb(),Sy();function PE(e,t){let n;return n=t===void 0?typeof e==`string`?new TextEncoder().encode(e):e instanceof Uint8Array?e:new Uint8Array(e):bv(t,e),Jh(n,`std_raw`)}function FE(...e){let t=new Headers;for(let n of e)n.forEach((e,n)=>{t.append(n,e)});return t}function IE(e,t){let n={};for(let r of e.methods){let e=t(r);e!=null&&(n[r.localName]=e)}return n}function LE(e,t,n,r){let i=null,a=null,o;if(t!==null&&t!==`identity`){let n=e.find(e=>e.name===t);if(n)i=n;else{let n=e.map(e=>e.name).join(`,`);o=new R(`unknown compression "${t}": supported encodings are ${n}`,L.Unimplemented,{[r]:n})}}if(n===null||n===``)a=i;else{let t=n.split(`,`).map(e=>e.trim());for(let n of t){let t=e.find(e=>e.name===n);if(t){a=t;break}}}return{request:i,response:a,error:o}}var RE=4294967295,zE=RE,BE=1024;function VE(e,t,n){if(t??=zE,e??=RE,n??=BE,t<1||t>zE)throw new R(`writeMaxBytes ${t} must be >= 1 and <= ${zE}`,L.Internal);if(e<1||e>RE)throw new R(`readMaxBytes ${e} must be >= 1 and <= ${RE}`,L.Internal);return{readMaxBytes:e,writeMaxBytes:t,compressMinBytes:n}}function HE(e,t){if(t>e)throw new R(`message size ${t} is larger than configured writeMaxBytes ${e}`,L.ResourceExhausted)}function UE(e,t,n=!1){if(t>e){let r=`message size is larger than configured readMaxBytes ${e}`;throw n&&(r=`message size ${t} is larger than configured readMaxBytes ${e}`),new R(r,L.ResourceExhausted)}}function WE(e){return new GE(e)}var GE=class{constructor(e){this.readMaxBytes=e,this.header=new Uint8Array(5),this.headerView=new DataView(this.header.buffer),this.buf=[]}get byteLength(){return this.buf.reduce((e,t)=>e+t.byteLength,0)}decode(e){this.buf.push(e);let t=[];for(;;){let e=this.pop();if(!e)break;t.push(e)}return t}pop(){if(!(!this.env&&(this.env=this.head(),!this.env))&&this.cons(this.env.data)){let e=this.env;return this.env=void 0,e}}head(){if(!this.cons(this.header))return;let e=this.headerView.getUint8(0),t=this.headerView.getUint32(1);return UE(this.readMaxBytes,t,!0),{flags:e,data:new Uint8Array(t)}}cons(e){let t=e.byteLength;if(this.byteLength<t)return!1;let n=0;for(;n<t;){let r=this.buf.shift();r.byteLength>t-n?(e.set(r.subarray(0,t-n),n),this.buf.unshift(r.subarray(t-n)),n+=t-n):(e.set(r,n),n+=r.byteLength)}return!0}};function KE(e){let t,n=WE(4294967295);return new ReadableStream({start(){t=e.getReader()},async pull(e){let r=!1;for(;!r;){let i=await t.read();if(i.done)n.byteLength>0&&e.error(new R(`protocol error: incomplete envelope`,L.InvalidArgument)),e.close();else for(let t of n.decode(i.value))e.enqueue(t),r=!0}}})}async function qE(e,t,n){let{flags:r,data:i}=e;if((r&1)==1)throw new R(`invalid envelope, already compressed`,L.Internal);return t&&i.byteLength>=n&&(i=await t.compress(i),r|=1),{data:i,flags:r}}async function JE(e,t,n){let{flags:r,data:i}=e;if((r&1)==1){if(!t)throw new R(`received compressed envelope, but do not know how to decompress`,L.Internal);i=await t.decompress(i,n),r^=1}return{data:i,flags:r}}function YE(e,t){let n=new Uint8Array(t.length+5);n.set(t,5);let r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.setUint8(0,e),r.setUint32(1,t.length),n}var XE=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},ZE=function(e){return this instanceof ZE?(this.v=e,this):new ZE(e)},QE=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof ZE?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}},$E=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:ZE(e[r](t)),done:!1}:i?i(t):t}:i}};function eD(e,...t){let[n,r,i]=tD(t),a=e,o;return i?.propagateDownStreamError===!0&&(a=o=gD(a)),a=rD(a,...n,{propagateDownStreamError:!1}),r(a).catch(e=>o?o.abort(e).then(()=>Promise.reject(e)):Promise.reject(e))}function tD(e){let t;return typeof e[e.length-1]!=`function`&&(t=e.pop()),[e,e.pop(),t]}function nD(e,t){return async n=>await pD(n,e,t)}function rD(e,...t){return QE(this,arguments,function*(){var n;let[r,i]=iD(t),a,o=e[Symbol.asyncIterator](),s={[Symbol.asyncIterator](){return o}};i?.propagateDownStreamError===!0&&(s=a=gD(s));for(let e of r)s=e(s);let c=s[Symbol.asyncIterator]();try{for(;;){let e=yield ZE(c.next());if(e.done===!0)break;if(!a)yield yield ZE(e.value);else try{yield yield ZE(e.value)}catch(e){throw yield ZE(a.abort(e)),e}}}finally{i?.propagateDownStreamError===!0&&((n=o.return)==null||n.call(o).catch(()=>{}))}})}function iD(e){let t;return typeof e[e.length-1]!=`function`&&(t=e.pop()),[e,t]}function aD(e){return function(t){return QE(this,arguments,function*(){let n,r=t[Symbol.asyncIterator]();for(;;){let e;try{e=yield ZE(r.next())}catch(e){n=e;break}if(e.done===!0)break;yield yield ZE(e.value)}let i=yield ZE(e(n));i!==void 0&&(yield yield ZE(i))})}}function oD(e){return function(t){return QE(this,arguments,function*(){var n,r,i,a;let o=yield ZE(e());o!==void 0&&(yield yield ZE(o));try{for(var s=!0,c=XE(t),l;l=yield ZE(c.next()),n=l.done,!n;s=!0)a=l.value,s=!1,yield yield ZE(a)}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield ZE(i.call(c)))}finally{if(r)throw r.error}}})}}function sD(e,t,n){return t===void 0||n===void 0?function(t){return QE(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=XE(t),c;c=yield ZE(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a;yield yield ZE({flags:0,data:e.serialize(t)})}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield ZE(i.call(s)))}finally{if(r)throw r.error}}})}:function(r){return QE(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=XE(r),u;u=yield ZE(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let r=s,i,a=0;r.end?(a|=t,i=n.serialize(r.value)):i=e.serialize(r.value),yield yield ZE({flags:a,data:i})}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield ZE(o.call(l)))}finally{if(a)throw a.error}}})}}function cD(e,t,n){return n&&t!==void 0?function(r){return QE(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=XE(r),u;u=yield ZE(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let{flags:r,data:i}=s;(r&t)===t?yield yield ZE({value:n.parse(i),end:!0}):yield yield ZE({value:e.parse(i),end:!1})}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield ZE(o.call(l)))}finally{if(a)throw a.error}}})}:function(r){return QE(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=XE(r),u;u=yield ZE(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let{flags:r,data:i}=s;if(t!==void 0&&(r&t)===t){if(n===null)throw new R(`unexpected end flag`,L.InvalidArgument)}else yield yield ZE(e.parse(i))}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield ZE(o.call(l)))}finally{if(a)throw a.error}}})}}function lD(e,t){return function(n){return QE(this,arguments,function*(){var r,i,a,o;try{for(var s=!0,c=XE(n),l;l=yield ZE(c.next()),r=l.done,!r;s=!0)o=l.value,s=!1,yield yield ZE(yield ZE(qE(o,e,t)))}catch(e){i={error:e}}finally{try{!s&&!r&&(a=c.return)&&(yield ZE(a.call(c)))}finally{if(i)throw i.error}}})}}function uD(e,t){return function(n){return QE(this,arguments,function*(){var r,i,a,o;try{for(var s=!0,c=XE(n),l;l=yield ZE(c.next()),r=l.done,!r;s=!0)o=l.value,s=!1,yield yield ZE(yield ZE(JE(o,e,t)))}catch(e){i={error:e}}finally{try{!s&&!r&&(a=c.return)&&(yield ZE(a.call(c)))}finally{if(i)throw i.error}}})}}function dD(){return function(e){return QE(this,arguments,function*(){var t,n,r,i;try{for(var a=!0,o=XE(e),s;s=yield ZE(o.next()),t=s.done,!t;a=!0){i=s.value,a=!1;let{flags:e,data:t}=i;yield yield ZE(YE(e,t))}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield ZE(r.call(o)))}finally{if(n)throw n.error}}})}}function fD(e){return function(t){return QE(this,arguments,function*(){var n,r,i,a;let o=WE(e);try{for(var s=!0,c=XE(t),l;l=yield ZE(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;for(let t of o.decode(e))yield yield ZE(t)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield ZE(i.call(c)))}finally{if(r)throw r.error}}if(o.byteLength>0)throw new R(`protocol error: incomplete envelope`,L.InvalidArgument)})}}async function pD(e,t,n){var r,i,a,o,s,c,l,u;let[d,f]=mD(n);if(d){f>t&&UE(t,f,!0);let n=new Uint8Array(f),s=0;try{for(var p=!0,m=XE(e),h;h=await m.next(),r=h.done,!r;p=!0){o=h.value,p=!1;let e=o;if(s+e.byteLength>f)throw new R(`protocol error: promised ${f} bytes, received ${s+e.byteLength}`,L.InvalidArgument);n.set(e,s),s+=e.byteLength}}catch(e){i={error:e}}finally{try{!p&&!r&&(a=m.return)&&await a.call(m)}finally{if(i)throw i.error}}if(s<f)throw new R(`protocol error: promised ${f} bytes, received ${s}`,L.InvalidArgument);return n}let g=[],_=0;try{for(var v=!0,y=XE(e),b;b=await y.next(),s=b.done,!s;v=!0){u=b.value,v=!1;let e=u;_+=e.byteLength,UE(t,_),g.push(e)}}catch(e){c={error:e}}finally{try{!v&&!s&&(l=y.return)&&await l.call(y)}finally{if(c)throw c.error}}let x=new Uint8Array(_),S=0;for(let e=g.shift();e;e=g.shift())x.set(e,S),S+=e.byteLength;return x}function mD(e){if(e==null)return[!1,0];let t=typeof e==`string`?parseInt(e,10):e;return!Number.isSafeInteger(t)||t<0?[!1,t]:[!0,t]}async function hD(e){let t=e[Symbol.asyncIterator](),n=await t.next();return{[Symbol.asyncIterator](){let e={async next(){if(n!==null){let e=n;return n=null,e}return await t.next()}};return t.throw!==void 0&&(e.throw=e=>t.throw(e)),t.return!==void 0&&(e.return=e=>t.return(e)),e}}}function gD(e){let t=e[Symbol.asyncIterator]();if(t.throw===void 0)throw Error(`AsyncIterable does not implement throw`);let n=t,r,i,a={next(){return i=n.next().finally(()=>{i=void 0}),i},throw(e){return n.throw(e)}};t.return!==void 0&&(a=Object.assign(Object.assign({},a),{return(e){return n.return(e)}}));let o=!1;return{abort(e){if(r)return r.state;let t=()=>n.throw(e).then(e=>e.done===!0?`completed`:`caught`,()=>`rethrown`);return i?(r={reason:e,state:i.then(t,t)},r.state):(r={reason:e,state:t()},r.state)},[Symbol.asyncIterator](){if(o)throw Error(`AsyncIterable cannot be re-used`);return o=!0,a}}}function _D(e){return QE(this,arguments,function*(){yield ZE(yield*$E(XE(e)))})}var vD=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},yD=function(e){return this instanceof yD?(this.v=e,this):new yD(e)},bD=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:yD(e[r](t)),done:!1}:i?i(t):t}:i}},xD=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof yD?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function SD(e,t){return IE(e,e=>{switch(e.methodKind){case`unary`:return CD(t,e);case`server_streaming`:return wD(t,e);case`client_streaming`:return TD(t,e);case`bidi_streaming`:return ED(t,e);default:return null}})}function CD(e,t){return async(n,r)=>{var i,a;let o=await e.unary(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues);return(i=r?.onHeader)==null||i.call(r,o.header),(a=r?.onTrailer)==null||a.call(r,o.trailer),o.message}}function wD(e,t){return(n,r)=>DD(e.stream(t,r?.signal,r?.timeoutMs,r?.headers,_D([n]),r?.contextValues),r)}function TD(e,t){return async(n,r)=>{var i,a,o,s,c,l;let u=await e.stream(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues);(c=r?.onHeader)==null||c.call(r,u.header);let d,f=0;try{for(var p=!0,m=vD(u.message),h;h=await m.next(),i=h.done,!i;p=!0)s=h.value,p=!1,d=s,f++}catch(e){a={error:e}}finally{try{!p&&!i&&(o=m.return)&&await o.call(m)}finally{if(a)throw a.error}}if(!d)throw new R(`protocol error: missing response message`,L.Unimplemented);if(f>1)throw new R(`protocol error: received extra messages for client streaming method`,L.Unimplemented);return(l=r?.onTrailer)==null||l.call(r,u.trailer),d}}function ED(e,t){return(n,r)=>DD(e.stream(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues),r)}function DD(e,t){return(function(){return xD(this,arguments,function*(){var n,r;let i=yield yD(e);(n=t?.onHeader)==null||n.call(t,i.header),yield yD(yield*bD(vD(i.message))),(r=t?.onTrailer)==null||r.call(t,i.trailer)})})()}function OD(...e){let t=new AbortController,n=e.filter(e=>e!==void 0).concat(t.signal);for(let e of n){if(e.aborted){r.apply(e);break}e.addEventListener(`abort`,r)}function r(){t.signal.aborted||t.abort(AD(this));for(let e of n)e.removeEventListener(`abort`,r)}return t}function kD(e){let t=new AbortController,n=()=>{t.abort(new R(`the operation timed out`,L.DeadlineExceeded))},r;return e!==void 0&&(e<=0?n():r=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}function AD(e){if(!e.aborted)return;if(e.reason!==void 0)return e.reason;let t=Error(`This operation was aborted`);return t.name=`AbortError`,t}function jD(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function MD(e){let t;if(e.timeoutMs!==void 0){let n=new Date(Date.now()+e.timeoutMs);t=()=>n.getTime()-Date.now()}else t=()=>void 0;let n=kD(e.timeoutMs),r=OD(n.signal,e.requestSignal,e.shutdownSignal);return Object.assign(Object.assign({},e),{signal:r.signal,timeoutMs:t,requestHeader:new Headers(e.requestHeader),responseHeader:new Headers(e.responseHeader),responseTrailer:new Headers(e.responseTrailer),abort(e){n.cleanup(),r.abort(e)},values:e.contextValues??jD()})}function ND(e,t){return{kind:e.methodKind,method:e,impl:t}}function PD(e,t){let n={service:e,methods:{}};for(let r of e.methods){let i=t[r.localName];if(typeof i==`function`)i=i.bind(t);else{let t=`${e.typeName}.${r.name} is not implemented`;i=function(){throw new R(t,L.Unimplemented)}}n.methods[r.localName]=ND(r,i)}return n}function FD(e){let t=new Headers,n=new TextDecoder().decode(e).split(`\r
|
|
17
17
|
`);for(let e of n){if(e===``)continue;let n=e.indexOf(`:`);if(n>0){let r=e.substring(0,n).trim(),i=e.substring(n+1).trim();t.append(r,i)}}return t}function ID(e){let t=[];return e.forEach((e,n)=>{t.push(`${n}: ${e}\r\n`)}),new TextEncoder().encode(t.join(``))}function LD(){return{serialize:ID,parse:FD}}var RD=`Content-Type`,zD=`Grpc-Encoding`,BD=`Grpc-Accept-Encoding`,VD=`Grpc-Timeout`,HD=`Grpc-Status`,UD=`Grpc-Message`,WD=`Grpc-Status-Details-Bin`,GD=`Grpc-Status-Details-Bin`,KD=/^application\/grpc-web(-text)?(?:\+(?:(json)(?:; ?charset=utf-?8)?|proto))?$/i,qD=`application/grpc-web+proto`,JD=`application/grpc-web+json`;function YD(e){let t=e?.match(KD);if(t)return{text:!!t[1],binary:!t[2]}}function XD(e,t){if(e===null)return{};let n=/^(\d{1,8})([HMSmun])$/.exec(e);if(n===null)return{error:new R(`protocol error: invalid grpc timeout value: ${e}`,L.InvalidArgument)};let r={H:36e5,M:6e4,S:1e3,m:1,u:.001,n:1e-6}[n[2]]*parseInt(n[1]);return r>t?{timeoutMs:r,error:new R(`timeout ${r}ms must be <= ${t}`,L.InvalidArgument)}:{timeoutMs:r}}Kb(),ly();var ZD=b_(uv(`CgxzdGF0dXMucHJvdG8SCmdvb2dsZS5ycGMiTgoGU3RhdHVzEgwKBGNvZGUYASABKAUSDwoHbWVzc2FnZRgCIAEoCRIlCgdkZXRhaWxzGAMgAygLMhQuZ29vZ2xlLnByb3RvYnVmLkFueUJeCg5jb20uZ29vZ2xlLnJwY0ILU3RhdHVzUHJvdG9QAVo3Z29vZ2xlLmdvbGFuZy5vcmcvZ2VucHJvdG8vZ29vZ2xlYXBpcy9ycGMvc3RhdHVzO3N0YXR1c6ICA1JQQ2IGcHJvdG8z`,[gv]),0),QD=`Content-Type`,$D=`Content-Length`,eO=`Content-Encoding`,tO=`Connect-Content-Encoding`,nO=`Accept-Encoding`,rO=`Connect-Accept-Encoding`,iO=`Connect-Timeout-Ms`,aO=`Connect-Protocol-Version`,oO=`Date`,sO=`Host`,cO=`Trailer`,lO=`User-Agent`,uO=new Set([QD,$D,eO,sO,lO,cO,oO,nO,`Trailer-`,tO,rO,iO,aO,zD,BD,VD,HD,UD,WD].map(e=>e.toLowerCase()));function dO(e,t){t.forEach((t,n)=>{uO.has(n.toLowerCase())||e.append(n,t)})}ly(),zb();function fO(e,t){if(t){if(t.isWireError||dO(e,t.metadata),e.set(HD,t.code.toString(10)),e.set(UD,encodeURIComponent(t.rawMessage)),t.details.length>0){let n=ym(ZD,{code:t.code,message:t.rawMessage,details:t.details.map(e=>`desc`in e?Bv(e.desc,ym(e.desc,e.value)):{typeUrl:`type.googleapis.com/${e.type}`,value:e.value})});e.set(GD,PE(n,ZD))}}else e.set(HD,`0`);return e}var pO=1024;function mO(...e){let t=new Map,n=e.reduce((e,t)=>e.concat(`supported`in t?t.supported:t),[]);function r(e){if(e===null||e.length==0)return!1;let r=t.get(e);if(r!==void 0)return r;let i=n.some(t=>t.test(e));return t.size<pO&&t.set(e,i),i}return r.supported=n,r}function hO(e,t){return e.toString().replace(/\/?$/,`/${t.parent.typeName}/${t.name}`)}zb();function gO(e,t){return ym(e,t)}function _O(e,t){function n(t){return t.done===!0?t:{done:t.done,value:gO(e,t.value)}}return{[Symbol.asyncIterator](){let e=t[Symbol.asyncIterator](),r={next:()=>e.next().then(n)};return e.throw!==void 0&&(r.throw=t=>e.throw(t).then(n)),e.return!==void 0&&(r.return=t=>e.return(t).then(n)),r}}}function vO(e,t){if(!t)return e;for(let n of t.concat().reverse())e=n(e);return e}var yO=function(e){return this instanceof yO?(this.v=e,this):new yO(e)},bO=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof yO?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}},xO=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},SO=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:yO(e[r](t)),done:!1}:i?i(t):t}:i}};async function CO(e,t,n){if(t!==void 0)try{await t(e)}catch(e){return{next:()=>Promise.reject(e)}}return n()[Symbol.asyncIterator]()}async function wO(e,t,n,r){let{message:i,header:a,trailer:o}=await vO(async n=>Object.assign({message:gO(e.method.output,await e.impl(n.message,AO(t,n))),stream:!1,method:e.method},kO(t,e)),r)(Object.assign({stream:!1,message:n,method:e.method},OO(t,e)));return jO(a,t.responseHeader),jO(o,t.responseTrailer),i}function TO(e,t,n){switch(e.kind){case`unary`:return function(r){return bO(this,arguments,function*(){yield yield yO(yield yO(wO(e,t,yield yO(DO(r,`unary`)),n)))})};case`server_streaming`:return function(r){return EO(e,t,r,n,async n=>{let r=_O(e.method.output,e.impl(await DO(n.message,`server-streaming`),AO(t,n)));return Object.assign({stream:!0,message:r,method:e.method},kO(t,e))})};case`client_streaming`:return function(r){return EO(e,t,r,n,async n=>Object.assign({message:_D([gO(e.method.output,await e.impl(n.message,AO(t,n)))]),stream:!0,method:e.method},kO(t,e)))};case`bidi_streaming`:return function(r){return EO(e,t,r,n,n=>Promise.resolve(Object.assign({message:_O(e.method.output,e.impl(n.message,AO(t,n))),stream:!0,method:e.method},kO(t,e))))}}}function EO(e,t,n,r,i){return bO(this,arguments,function*(){let{message:a,header:o,trailer:s}=yield yO(vO(i,r)(Object.assign({stream:!0,message:n,method:e.method},OO(t,e))));jO(o,t.responseHeader),yield yO(yield*SO(xO(a))),jO(s,t.responseTrailer)})}async function DO(e,t){let n=e[Symbol.asyncIterator](),r=await n.next();if(r.done===!0)throw new R(`protocol error: missing input message for ${t} method`,L.Unimplemented);if((await n.next()).done!==!0)throw new R(`protocol error: received extra input message for ${t} method`,L.Unimplemented);return r.value}function OO(e,t){return{requestMethod:e.requestMethod,url:e.url,signal:e.signal,header:e.requestHeader,service:t.method.parent,contextValues:e.values}}function kO(e,t){return{service:t.method.parent,header:e.responseHeader,trailer:e.responseTrailer}}function AO(e,t){return Object.assign(Object.assign({},e),{service:t.service,requestHeader:t.header,signal:t.signal,values:t.contextValues})}function jO(e,t){e!==t&&(t.forEach((e,n)=>{t.delete(n)}),e.forEach((e,n)=>{t.set(n,e)}))}zb();function MO(e){let t=Object.assign({},e);return t.ignoreUnknownFields??=!0,t}function NO(e,t,n,r){let i=FO(IO(e.input,t),r),a=FO(LO(e.input,n),r),o=FO(IO(e.output,t),r),s=FO(LO(e.output,n),r);return{getI(e){return e?i:a},getO(e){return e?o:s}}}function PO(e,t,n,r){let i=t?IO(e.input,r):LO(e.input,n);return{parse:(t?IO(e.output,r):LO(e.output,n)).parse,serialize:i.serialize}}function FO(e,t){return{serialize(n){let r=e.serialize(n);return HE(t.writeMaxBytes,r.byteLength),r},parse(n){return UE(t.readMaxBytes,n.byteLength,!0),e.parse(n)}}}function IO(e,t){return{parse(n){try{return J_(e,n,t)}catch(e){throw new R(`parse binary: ${e instanceof Error?e.message:String(e)}`,L.Internal)}},serialize(n){try{return bv(e,n,t)}catch(e){throw new R(`serialize binary: ${e instanceof Error?e.message:String(e)}`,L.Internal)}}}}function LO(e,t){let n=t?.textEncoder??new TextEncoder,r=t?.textDecoder??new TextDecoder,i=MO(t);return{parse(t){try{return rb(e,r.decode(t),i)}catch(e){throw R.from(e,L.InvalidArgument)}},serialize(t){try{let r=Ty(e,t,i);return n.encode(r)}catch(e){throw R.from(e,L.Internal)}}}}function RO(e){if(!(typeof e.body==`object`&&e.body!==null&&Symbol.asyncIterator in e.body))throw Error(`byte stream required, but received JSON`)}var zO={status:200},BO={status:415},VO={status:405},HO={status:505};function UO(e){e??={};let t=e.acceptCompression?[...e.acceptCompression]:[],n=e.requireConnectProtocolHeader??!1,r=e.maxTimeoutMs??2**53-1;return Object.assign(Object.assign({acceptCompression:t},VE(e.readMaxBytes,e.writeMaxBytes,e.compressMinBytes)),{jsonOptions:e.jsonOptions,binaryOptions:e.binaryOptions,maxTimeoutMs:r,shutdownSignal:e.shutdownSignal,requireConnectProtocolHeader:n,interceptors:e.interceptors??[],requestGate:e.requestGate})}function WO(e,t){return Object.entries(e.methods).map(([,e])=>GO(e,t))}function GO(e,t){return KO(t.map(t=>t(e)))}function KO(e){if(e.length==0)throw new R(`at least one protocol is required`,L.Internal);let t=e[0].service,n=e[0].method,r=e[0].requestPath;if(e.some(e=>e.service!==t||e.method!==n))throw new R(`cannot negotiate protocol for different RPCs`,L.Internal);if(e.some(e=>e.requestPath!==r))throw new R(`cannot negotiate protocol for different requestPaths`,L.Internal);async function i(t){if(n.methodKind==`bidi_streaming`&&t.httpVersion.startsWith(`1.`))return Object.assign(Object.assign({},HO),{header:new Headers({Connection:`close`})});let r=t.header.get(`Content-Type`)??``,i=e.filter(e=>e.allowedMethods.includes(t.method));if(i.length==0)return VO;if(i.length==1&&r===``){let e=i[0];return e(t)}let a=i.filter(e=>e.supportedContentType(r));if(a.length==0)return BO;let o=a[0];return o(t)}return Object.assign(i,{service:t,method:n,requestPath:r,supportedContentType:mO(...e.map(e=>e.supportedContentType)),protocolNames:e.flatMap(e=>e.protocolNames).filter((e,t,n)=>n.indexOf(e)===t),allowedMethods:e.flatMap(e=>e.allowedMethods).filter((e,t,n)=>n.indexOf(e)===t)})}var qO=`grpc-web`,JO=`POST`;function YO(e){let t=UO(e),n=LD();function r(e){let r=XO(t,n,e);return Object.assign(r,{protocolNames:[qO],allowedMethods:[JO],supportedContentType:mO(KD),requestPath:hO(`/`,e.method),service:e.method.parent,method:e.method})}return r.protocolName=qO,r}function XO(e,t,n){let r=NO(n.method,e.binaryOptions,e.jsonOptions,e);return async function(i){RO(i);let a=YD(i.header.get(RD));if(a==null||a.text)return BO;if(i.method!==JO)return VO;let o=XD(i.header.get(VD),e.maxTimeoutMs),s=MD(Object.assign(Object.assign({},n),{service:n.method.parent,requestMethod:i.method,protocolName:qO,timeoutMs:o.timeoutMs,shutdownSignal:e.shutdownSignal,requestSignal:i.signal,requestHeader:i.header,url:i.url,responseHeader:{[RD]:a.binary?qD:JD},responseTrailer:{[HD]:`0`},contextValues:i.contextValues})),c=LE(e.acceptCompression,i.header.get(zD),i.header.get(BD),BD);c.response&&s.responseHeader.set(zD,c.response.name);let l=rD(i.body,oD(()=>{if(c.error)throw c.error;if(o.error)throw o.error}),fD(e.readMaxBytes),uD(c.request,e.readMaxBytes),cD(r.getI(a.binary),128)),u=await CO(s,e.requestGate,()=>TO(n,s,e.interceptors)(l)),d=rD({[Symbol.asyncIterator](){return{next:()=>u.next(),throw:e=>(s.abort(e),u.throw?.call(u,e)??Promise.reject({done:!0})),return:e=>(s.abort(),u.return?.call(u,e)??Promise.resolve({done:!0,value:e}))}}},sD(r.getO(a.binary)),aD(e=>(s.abort(e),e instanceof R?fO(s.responseTrailer,e):e!==void 0&&fO(s.responseTrailer,new R(`internal error`,L.Internal,void 0,void 0,e)),{flags:128,data:t.serialize(s.responseTrailer)})),lD(c.response,e.compressMinBytes),dD(),{propagateDownStreamError:!0});return Object.assign(Object.assign({},zO),{body:await hD(d),header:s.responseHeader})}}var ZO=/^application\/grpc(?:\+(?:(json)(?:; ?charset=utf-?8)?|proto))?$/i,QO=`application/grpc+proto`,$O=`application/grpc+json`;function ek(e){let t=e?.match(ZO);if(t)return{binary:!t[1]}}var tk=`grpc`,nk=`POST`;function rk(e){let t=UO(e);function n(e){let n=ik(t,e);return Object.assign(n,{protocolNames:[tk],allowedMethods:[nk],supportedContentType:mO(ZO),requestPath:hO(`/`,e.method),service:e.method.parent,method:e.method})}return n.protocolName=tk,n}function ik(e,t){let n=NO(t.method,e.binaryOptions,e.jsonOptions,e);return async function(r){RO(r);let i=ek(r.header.get(RD));if(i==null)return BO;if(r.method!==nk)return VO;let a=XD(r.header.get(VD),e.maxTimeoutMs),o=MD(Object.assign(Object.assign({},t),{service:t.method.parent,requestMethod:r.method,protocolName:tk,timeoutMs:a.timeoutMs,shutdownSignal:e.shutdownSignal,requestSignal:r.signal,requestHeader:r.header,url:r.url,responseHeader:{[RD]:i.binary?QO:$O},responseTrailer:{[HD]:`0`},contextValues:r.contextValues})),s=LE(e.acceptCompression,r.header.get(zD),r.header.get(BD),BD);s.response&&o.responseHeader.set(zD,s.response.name);let c=rD(r.body,oD(()=>{if(s.error)throw s.error;if(a.error)throw a.error}),fD(e.readMaxBytes),uD(s.request,e.readMaxBytes),cD(n.getI(i.binary))),l=await CO(o,e.requestGate,()=>TO(t,o,e.interceptors)(c)),u=rD({[Symbol.asyncIterator](){return{next:()=>l.next(),throw:e=>(o.abort(e),l.throw?.call(l,e)??Promise.reject({done:!0})),return:e=>(o.abort(),l.return?.call(l,e)??Promise.resolve({done:!0,value:e}))}}},sD(n.getO(i.binary)),lD(s.response,e.compressMinBytes),dD(),aD(e=>{o.abort(e),e instanceof R?fO(o.responseTrailer,e):e!==void 0&&fO(o.responseTrailer,new R(`internal error`,L.Internal,void 0,void 0,e))}),{propagateDownStreamError:!0});return Object.assign(Object.assign({},zO),{body:await hD(u),header:o.responseHeader,trailer:o.responseTrailer})}}var ak=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i,ok=/^application\/(?:json(?:; ?charset=utf-?8)?|proto)$/i,sk=/^application\/connect\+?(?:json(?:; ?charset=utf-?8)?|proto)$/i,ck=`application/proto`,lk=`application/json`,uk=`application/connect+proto`,dk=`application/connect+json`,fk=`proto`,pk=`json`;function mk(e){let t=e?.match(ak);if(t)return{stream:!!t[1],binary:!!t[3]}}function hk(e){switch(e){case fk:return{stream:!1,binary:!0};case pk:return{stream:!1,binary:!1};default:return}}Sy(),zb();var gk=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function _k(e,t,n){if(t&&new Headers(t).forEach((e,t)=>n.metadata.append(t,e)),typeof e!=`object`||!e||Array.isArray(e))throw n;let r=n.code;`code`in e&&typeof e.code==`string`&&(r=ME(e.code)??r);let i=e.message;if(i!=null&&typeof i!=`string`)throw n;let a=new R(i??``,r,t);if(a.isWireError=!0,`details`in e&&Array.isArray(e.details))for(let t of e.details){if(typeof t!=`object`||!t||Array.isArray(t)||typeof t.type!=`string`||typeof t.value!=`string`)throw n;try{a.details.push({type:t.type,value:Kh(t.value),debug:t.debug})}catch{throw n}}return a}function vk(e,t,n){let r;try{r=JSON.parse(new TextDecoder().decode(e))}catch{throw n}return _k(r,t,n)}function yk(e,t){let n={code:AE(e.code)};return e.rawMessage.length>0&&(n.message=e.rawMessage),e.details.length>0&&(n.details=e.details.map(e=>{if(`desc`in e){let n=ym(e.desc,e.value),r={type:e.desc.typeName,value:bv(e.desc,n)};try{r.debug=wy(e.desc,n,t)}catch{}return r}return e}).map(e=>{var{value:t}=e,n=gk(e,[`value`]);return Object.assign(Object.assign({},n),{value:Jh(t,`std_raw`)})})),n}function bk(e,t){let n=new TextEncoder;try{let r=yk(e,t),i=JSON.stringify(r);return n.encode(i)}catch(e){throw new R(`failed to serialize Connect Error: ${e instanceof Error?e.message:String(e)}`,L.Internal)}}function xk(e){let t=new R(`invalid end stream`,L.Unknown),n;try{n=JSON.parse(typeof e==`string`?e:new TextDecoder().decode(e))}catch{throw t}if(typeof n!=`object`||!n||Array.isArray(n))throw t;let r=new Headers;if(`metadata`in n){if(typeof n.metadata!=`object`||n.metadata==null||Array.isArray(n.metadata))throw t;for(let[e,i]of Object.entries(n.metadata)){if(!Array.isArray(i)||i.some(e=>typeof e!=`string`))throw t;for(let t of i)r.append(e,t)}}return{metadata:r,error:`error`in n&&n.error!=null?_k(n.error,r,t):void 0}}function Sk(e,t,n){let r={};t!==void 0&&(r.error=yk(t,n),t.isWireError||dO(e,t.metadata));let i=!1,a={};return e.forEach((e,t)=>{i=!0,a[t]=[e]}),i&&(r.metadata=a),r}function Ck(e){let t=new TextEncoder;return{serialize(n){try{let r=Sk(n.metadata,n.error,e),i=JSON.stringify(r);return t.encode(i)}catch(e){throw new R(`failed to serialize EndStreamResponse: ${e instanceof Error?e.message:String(e)}`,L.Internal)}},parse(e){try{return xk(e)}catch(e){throw new R(`failed to parse EndStreamResponse: ${e instanceof Error?e.message:String(e)}`,L.InvalidArgument)}}}}function wk(e){switch(e){case 400:return L.Internal;case 401:return L.Unauthenticated;case 403:return L.PermissionDenied;case 404:return L.Unimplemented;case 429:return L.Unavailable;case 502:return L.Unavailable;case 503:return L.Unavailable;case 504:return L.Unavailable;default:return L.Unknown}}function Tk(e){switch(e){case L.Canceled:return 499;case L.Unknown:return 500;case L.InvalidArgument:return 400;case L.DeadlineExceeded:return 504;case L.NotFound:return 404;case L.AlreadyExists:return 409;case L.PermissionDenied:return 403;case L.ResourceExhausted:return 429;case L.FailedPrecondition:return 400;case L.Aborted:return 409;case L.OutOfRange:return 400;case L.Unimplemented:return 501;case L.Internal:return 500;case L.Unavailable:return 503;case L.DataLoss:return 500;case L.Unauthenticated:return 401;default:return 500}}function Ek(e,t){if(e===null)return{};let n=/^\d{1,10}$/.exec(e);if(n===null)return{error:new R(`protocol error: invalid connect timeout value: ${e}`,L.InvalidArgument)};let r=parseInt(n[0]);return r>t?{timeoutMs:r,error:new R(`timeout ${r}ms must be <= ${t}`,L.InvalidArgument)}:{timeoutMs:parseInt(n[0])}}var Dk=`connect`,Ok=`encoding`,kk=`compression`,Ak=`base64`;function jk(e){let t=new Headers,n=new Headers;return e.forEach((e,r)=>{r.toLowerCase().startsWith(`trailer-`)?n.append(r.substring(8),e):t.append(r,e)}),[t,n]}function Mk(e,t){let n=new Headers(e);return t.forEach((e,t)=>{n.append(`trailer-${t}`,e)}),n}function Nk(e){let t=e.get(aO);if(t===null)throw new R(`missing required header: set ${aO} to "1"`,L.InvalidArgument);if(t!==`1`)throw new R(`${aO} must be "1": got "${t}"`,L.InvalidArgument)}function Pk(e){let t=e.get(Dk);if(t===null)throw new R(`missing required parameter: set ${Dk} to "v1"`,L.InvalidArgument);if(t!==`v1`)throw new R(`${Dk} must be "v1": got "${t}"`,L.InvalidArgument)}zb(),Sy(),ly();var Fk=`connect`,Ik=`POST`,Lk=`GET`;function Rk(e){let t=UO(e),n=Ck(t.jsonOptions);function r(e){let r,i,a=NO(e.method,t.binaryOptions,t.jsonOptions,t);switch(e.kind){case`unary`:i=ok,r=zk(t,e,a);break;default:i=sk,r=Uk(t,e,a,n)}let o=[Ik];return e.method.idempotency===N_.NO_SIDE_EFFECTS&&o.push(Lk),Object.assign(r,{protocolNames:[Fk],supportedContentType:mO(i),allowedMethods:o,requestPath:hO(`/`,e.method),service:e.method.parent,method:e.method})}return r.protocolName=Fk,r}function zk(e,t,n){return async function(r){let i=r.method==Lk;if(i&&t.method.idempotency!=N_.NO_SIDE_EFFECTS)return VO;let a=new URL(r.url).searchParams,o=i?a.get(kk):r.header.get(eO),s=i?hk(a.get(Ok)):mk(r.header.get(QD));if(s==null||s.stream)return BO;let c=Ek(r.header.get(iO),e.maxTimeoutMs),l=MD(Object.assign(Object.assign({},t),{service:t.method.parent,requestMethod:r.method,protocolName:Fk,timeoutMs:c.timeoutMs,shutdownSignal:e.shutdownSignal,requestSignal:r.signal,requestHeader:r.header,url:r.url,responseHeader:{[QD]:s.binary?ck:lk},contextValues:r.contextValues})),u=LE(e.acceptCompression,o,r.header.get(nO),nO),d=zO.status,f;try{if(e.requestGate!==void 0&&await e.requestGate(l),e.requireConnectProtocolHeader&&(i?Pk(a):Nk(r.header)),u.error)throw u.error;if(c.error)throw c.error;let o;o=i?await Vk(e.readMaxBytes,u.request,a):await Bk(e.readMaxBytes,u.request,r);let d=await wO(t,l,Hk(t.method,s.binary,n,o),e.interceptors);f=n.getO(s.binary).serialize(d)}catch(t){l.abort(t);let n;n=t instanceof R?t:new R(`internal error`,L.Internal,void 0,void 0,t),d=Tk(n.code),l.responseHeader.set(QD,lk),n.isWireError||dO(l.responseHeader,n.metadata),f=bk(n,e.jsonOptions)}finally{l.abort()}u.response&&f.byteLength>=e.compressMinBytes&&(f=await u.response.compress(f),l.responseHeader.set(eO,u.response.name));let p=Mk(l.responseHeader,l.responseTrailer);return p.set($D,f.byteLength.toString(10)),{status:d,body:_D([f]),header:p}}}async function Bk(e,t,n){if(typeof n.body==`object`&&n.body!==null&&Symbol.asyncIterator in n.body){let r=await pD(n.body,e,n.header.get($D));return t&&(r=await t.decompress(r,e)),r}return n.body}async function Vk(e,t,n){let r=n.get(Ak),i=n.get(`message`)??``,a;return a=r===`1`?Kh(i):new TextEncoder().encode(i),t&&(a=await t.decompress(a,e)),a}function Hk(e,t,n,r){if(r instanceof Uint8Array)return n.getI(t).parse(r);if(t)throw new R(`received parsed JSON request body, but content-type indicates binary format`,L.Internal);try{return ib(e.input,r)}catch(e){throw R.from(e,L.InvalidArgument)}}function Uk(e,t,n,r){return async function(i){RO(i);let a=mk(i.header.get(QD));if(a==null||!a.stream)return BO;if(i.method!==Ik)return VO;let o=Ek(i.header.get(iO),e.maxTimeoutMs),s=MD(Object.assign(Object.assign({},t),{service:t.method.parent,requestMethod:i.method,protocolName:Fk,timeoutMs:o.timeoutMs,shutdownSignal:e.shutdownSignal,requestSignal:i.signal,requestHeader:i.header,url:i.url,responseHeader:{[QD]:a.binary?uk:dk},contextValues:i.contextValues})),c=LE(e.acceptCompression,i.header.get(tO),i.header.get(rO),rO);c.response&&s.responseHeader.set(tO,c.response.name);let l=rD(i.body,oD(()=>{if(e.requireConnectProtocolHeader&&Nk(i.header),c.error)throw c.error;if(o.error)throw o.error}),fD(e.readMaxBytes),uD(c.request,e.readMaxBytes),cD(n.getI(a.binary),2)),u=await CO(s,e.requestGate,()=>TO(t,s,e.interceptors)(l)),d=rD({[Symbol.asyncIterator](){return{next:()=>u.next(),throw:e=>(s.abort(e),u.throw?.call(u,e)??Promise.reject({done:!0})),return:e=>(s.abort(),u.return?.call(u,e)??Promise.resolve({done:!0,value:e}))}}},sD(n.getO(a.binary)),aD(e=>{s.abort(e);let t={metadata:s.responseTrailer};return e instanceof R?t.error=e:e!==void 0&&(t.error=new R(`internal error`,L.Internal,void 0,void 0,e)),{flags:2,data:r.serialize(t)}}),lD(c.response,e.compressMinBytes),dD(),{propagateDownStreamError:!0});return Object.assign(Object.assign({},zO),{body:await hD(d),header:s.responseHeader})}}function Wk(e){let t=Gk(e),n=[],r={handlers:n,service:(e,i,a)=>{let{protocols:o}=Gk(a,t);return n.push(...WO(PD(e,i),o)),r},rpc:(e,i,a)=>{let{protocols:o}=Gk(a,t);return n.push(GO(ND(e,i),o)),r}};return r}function Gk(e,t){if(t&&!e)return t;let n=t?Object.assign(Object.assign({},UO(t.options)),e):Object.assign(Object.assign({},e),UO(e??{})),r=[];if(e?.grpc!==!1&&r.push(rk(n)),e?.grpcWeb!==!1&&r.push(YO(n)),e?.connect!==!1&&r.push(Rk(n)),r.length===0)throw new R(`cannot create handler, all protocols are disabled`,L.InvalidArgument);return{options:n,protocols:r}}function Kk(e,t,n,r,i){let a=new Headers(r??{});return n!==void 0&&a.set(iO,`${n}`),a.set(QD,e==`unary`?t?ck:lk:t?uk:dk),a.set(aO,`1`),!a.has(`User-Agent`)&&i&&a.set(lO,`connect-es/2.3.0`),a}function qk(e,t,n,r,i,a,o){let s=Kk(e,t,n,r,o);if(a!=null){let t=e==`unary`?eO:tO;s.set(t,a.name)}if(i.length>0){let t=e==`unary`?nO:rO;s.set(t,i.map(e=>e.name).join(`,`))}return s}function Jk(e,t,n,r){let i=r.get(QD),a=mk(i);if(n!==200){let t=new R(`HTTP ${n}`,wk(n),r);if(e==`unary`&&a&&!a.binary)return{isUnaryError:!0,unaryError:t};throw t}let o={binary:t,stream:e!==`unary`};if(a?.binary!==o.binary||a.stream!==o.stream)throw new R(`unsupported content type ${i}`,a===void 0?L.Unknown:L.Internal,r);return{isUnaryError:!1}}function Yk(e,t,n,r,i){let a,o=i.get(e==`unary`?eO:tO);if(o!=null&&o.toLowerCase()!==`identity`&&(a=t.find(e=>e.name===o),!a))throw new R(`unsupported response encoding "${o}"`,L.Internal,i);return Object.assign({compression:a},Jk(e,n,r,i))}Sy();var Xk=`application/`;function Zk(e,t){return t?Jh(e,`url`):encodeURIComponent(new TextDecoder().decode(e))}function Qk(e,t,n){let r=`?connect=v1`,i=``,a=e.header.get(eO);a!==null&&a!==`identity`&&(i=`&compression=`+encodeURIComponent(a),n=!0),n&&(r+=`&base64=1`),r+=i;let o=e.header.get(QD);o?.indexOf(Xk)===0&&(r+=`&encoding=`+encodeURIComponent(o.slice(12))),r+=`&message=`+Zk(t,n);let s=e.url+r,c=new Headers(e.header);for(let e of[aO,QD,$D,eO,nO])c.delete(e);return Object.assign(Object.assign({},e),{requestMethod:`GET`,url:s,header:c})}function $k(e){let t=vO(e.next,e.interceptors),[n,r,i]=tA(e);return t(Object.assign(Object.assign({},e.req),{message:gO(e.req.method.input,e.req.message),signal:n})).then(e=>(i(),e),r)}function eA(e){let[t,n,r]=tA(e),i=!1,a=new Promise(e=>{t.aborted?e():t.addEventListener(`abort`,()=>e())});return a.then(()=>{var n,r;let a=e.req.message[Symbol.asyncIterator]();if(!i){let e=R.from(AD(t),L.Canceled);(n=a.throw)==null||n.call(a,e).catch(()=>{})}(r=a.return)==null||r.call(a).catch(()=>{})}),vO(async r=>{let o=await e.next(r),s=o.message[Symbol.asyncIterator]();return a.then(()=>s.return?.call(s).catch(()=>{})),Object.assign(Object.assign({},o),{message:{[Symbol.asyncIterator]:()=>({next:async()=>{let e=t.aborted?void 0:await Promise.race([s.next(),a]);return e===void 0?i?{done:!0,value:void 0}:n(AD(t)):e}})}})},e.interceptors)(Object.assign(Object.assign({},e.req),{message:_O(e.req.method.input,e.req.message),signal:t})).then(e=>{let o=e.message[Symbol.asyncIterator](),s=a.then(async()=>{try{for(;(await o.next()).done!==!0;);}catch{}});return Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator]:()=>({async next(){if(t.aborted)return await s,i?{done:!0,value:void 0}:n(AD(t));try{let e=await o.next();return e.done===!0&&(i=!0,r()),e}catch(e){return n(e)}},async return(e){return t.aborted||(i=!0,r()),await s,{done:!0,value:e}},async throw(e){if(i)throw R.from(e);try{return await n(e)}finally{await s}}})}})},n)}function tA(e){let{signal:t,cleanup:n}=kD(e.timeoutMs),r=OD(e.signal,t);return[r.signal,function(e){let t=r.signal.aborted?R.from(AD(r.signal),L.Canceled):R.from(e);return r.abort(t),n(),Promise.reject(t)},function(){n(),r.abort()}]}ly();var nA=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},rA=function(e){return this instanceof rA?(this.v=e,this):new rA(e)},iA=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof rA?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function aA(e){return{async unary(t,n,r,i,a,o){let s=NO(t,e.binaryOptions,e.jsonOptions,e);return r=r===void 0?e.defaultTimeoutMs:r<=0?void 0:r,await $k({interceptors:e.interceptors,signal:n,timeoutMs:r,req:{stream:!1,service:t.parent,method:t,requestMethod:`POST`,url:hO(e.baseUrl,t),header:qk(t.methodKind,e.useBinaryFormat,r,i,e.acceptCompression,e.sendCompression,!0),contextValues:o??jD(),message:a},next:async n=>{let r=s.getI(e.useBinaryFormat).serialize(n.message);e.sendCompression&&r.byteLength>e.compressMinBytes?(r=await e.sendCompression.compress(r),n.header.set(eO,e.sendCompression.name)):n.header.delete(eO);let i=e.useHttpGet===!0&&t.idempotency===N_.NO_SIDE_EFFECTS,a;i?n=Qk(n,r,e.useBinaryFormat):a=_D([r]);let o=await e.httpClient({url:n.url,method:n.requestMethod,header:n.header,signal:n.signal,body:a}),{compression:c,isUnaryError:l,unaryError:u}=Yk(t.methodKind,e.acceptCompression,e.useBinaryFormat,o.status,o.header),[d,f]=jk(o.header),p=await eD(o.body,nD(e.readMaxBytes,o.header.get($D)),{propagateDownStreamError:!1});if(c&&(p=await c.decompress(p,e.readMaxBytes)),l)throw vk(p,FE(d,f),u);return{stream:!1,service:t.parent,method:t,header:d,message:s.getO(e.useBinaryFormat).parse(p),trailer:f}}})},async stream(t,n,r,i,a,o){let s=NO(t,e.binaryOptions,e.jsonOptions,e),c=Ck(e.jsonOptions);return r=r===void 0?e.defaultTimeoutMs:r<=0?void 0:r,eA({interceptors:e.interceptors,signal:n,timeoutMs:r,req:{stream:!0,service:t.parent,method:t,requestMethod:`POST`,url:hO(e.baseUrl,t),header:qk(t.methodKind,e.useBinaryFormat,r,i,e.acceptCompression,e.sendCompression,!0),contextValues:o??jD(),message:a},next:async n=>{let r=await e.httpClient({url:n.url,method:`POST`,header:n.header,signal:n.signal,body:rD(n.message,sD(s.getI(e.useBinaryFormat)),lD(e.sendCompression,e.compressMinBytes),dD(),{propagateDownStreamError:!0})}),{compression:i}=Yk(t.methodKind,e.acceptCompression,e.useBinaryFormat,r.status,r.header),a=Object.assign(Object.assign({},n),{header:r.header,trailer:new Headers,message:rD(r.body,fD(e.readMaxBytes),uD(i??null,e.readMaxBytes),cD(s.getO(e.useBinaryFormat),2,c),function(e){return iA(this,arguments,function*(){var t,n,i,o;let s=!1;try{for(var c=!0,l=nA(e),u;u=yield rA(l.next()),t=u.done,!t;c=!0){o=u.value,c=!1;let e=o;if(e.end){if(s)throw new R(`protocol error: received extra EndStreamResponse`,L.InvalidArgument);if(s=!0,e.value.error){let t=e.value.error;throw r.header.forEach((e,n)=>{t.metadata.append(n,e)}),t}e.value.metadata.forEach((e,t)=>a.trailer.set(t,e))}else{if(s)throw new R(`protocol error: received extra message after EndStreamResponse`,L.InvalidArgument);yield yield rA(e.value)}}}catch(e){n={error:e}}finally{try{!c&&!t&&(i=l.return)&&(yield rA(i.call(l)))}finally{if(n)throw n.error}}if(!s)throw new R(`protocol error: missing EndStreamResponse`,L.InvalidArgument)})},{propagateDownStreamError:!0})});return a}})}}}function oA(e){let t=new Map;for(let n of e)t.set(n.requestPath,n);return async e=>{let n=new URL(e.url).pathname,r=t.get(n);if(!r)throw new R(`RouterHttpClient: no handler registered for ${n}`,L.Unimplemented);let i=e.signal??new AbortController().signal,a=await sA(i,r({body:e.body??_D([]),httpVersion:`2.0`,method:e.method,url:e.url,header:e.header,signal:i}));return{body:rD(a.body??_D([]),e=>({[Symbol.asyncIterator](){let t=e[Symbol.asyncIterator](),n={next(){return sA(i,t.next())}};return t.throw!==void 0&&(n.throw=e=>t.throw(e)),t.return!==void 0&&(n.return=e=>t.return(e)),n}})),header:new Headers(a.header),status:a.status,trailer:new Headers(a.trailer)}}}function sA(e,t){let n,r=new Promise((t,r)=>{let i=()=>r(AD(e));if(e.aborted)return i();e.addEventListener(`abort`,i),n=()=>e.removeEventListener(`abort`,i)});return Promise.race([r,t]).finally(n)}function cA(e,t){let n=Wk(Object.assign(Object.assign({},t?.router??{}),{connect:!0}));return e(n),aA(Object.assign({httpClient:oA(n.handlers),baseUrl:`https://in-memory`,useBinaryFormat:!0,interceptors:[],acceptCompression:[],sendCompression:null,compressMinBytes:2**53-1,readMaxBytes:2**53-1,writeMaxBytes:2**53-1},t?.transport??{}))}function lA(){try{new Headers}catch{throw Error(`connect-web requires the fetch API. Are you running on an old version of Node.js?`)}}zb(),ly();var uA=function(e){return this instanceof uA?(this.v=e,this):new uA(e)},dA=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof uA?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}},fA={redirect:`error`};function pA(e){lA();let t=e.useBinaryFormat??!1;return{async unary(n,r,i,a,o,s){let{serialize:c,parse:l}=PO(n,t,e.jsonOptions,e.binaryOptions);return i=i===void 0?e.defaultTimeoutMs:i<=0?void 0:i,await $k({interceptors:e.interceptors,signal:r,timeoutMs:i,req:{stream:!1,service:n.parent,method:n,requestMethod:`POST`,url:hO(e.baseUrl,n),header:Kk(n.methodKind,t,i,a,!1),contextValues:s??jD(),message:o},next:async r=>{let i=e.useHttpGet===!0&&n.idempotency===N_.NO_SIDE_EFFECTS,a=null;i?r=Qk(r,c(r.message),t):a=c(r.message);let o=await(e.fetch??globalThis.fetch)(r.url,Object.assign(Object.assign({},fA),{method:r.requestMethod,headers:r.header,signal:r.signal,body:a})),{isUnaryError:s,unaryError:u}=Jk(n.methodKind,t,o.status,o.headers);if(s)throw _k(await o.json(),FE(...jk(o.headers)),u);let[d,f]=jk(o.headers);return{stream:!1,service:n.parent,method:n,header:d,message:t?l(new Uint8Array(await o.arrayBuffer())):ib(n.output,await o.json(),MO(e.jsonOptions)),trailer:f}}})},async stream(n,r,i,a,o,s){let{serialize:c,parse:l}=PO(n,t,e.jsonOptions,e.binaryOptions);function u(e,t,n,r){return dA(this,arguments,function*(){let r=KE(e).getReader(),i=!1;for(;;){let e=yield uA(r.read());if(e.done)break;let{flags:a,data:o}=e.value;if((a&1)==1)throw new R(`protocol error: received unsupported compressed output`,L.Internal);if((a&2)==2){i=!0;let e=xk(o);if(e.error){let t=e.error;throw n.forEach((e,n)=>{t.metadata.append(n,e)}),t}e.metadata.forEach((e,n)=>t.set(n,e))}else yield yield uA(l(o))}if(!i)throw`missing EndStreamResponse`})}async function d(e){if(n.methodKind!=`server_streaming`)throw`The fetch API does not support streaming request bodies`;let t=await e[Symbol.asyncIterator]().next();if(t.done==1)throw`missing request message`;return YE(0,c(t.value))}return i=i===void 0?e.defaultTimeoutMs:i<=0?void 0:i,await eA({interceptors:e.interceptors,timeoutMs:i,signal:r,req:{stream:!0,service:n.parent,method:n,requestMethod:`POST`,url:hO(e.baseUrl,n),header:Kk(n.methodKind,t,i,a,!1),contextValues:s??jD(),message:o},next:async r=>{let i=await(e.fetch??globalThis.fetch)(r.url,Object.assign(Object.assign({},fA),{method:r.requestMethod,headers:r.header,signal:r.signal,body:await d(r.message)}));if(Jk(n.methodKind,t,i.status,i.headers),i.body===null)throw`missing response body`;let a=new Headers;return Object.assign(Object.assign({},r),{header:i.headers,trailer:a,message:u(i.body,a,i.headers,r.signal)})}})}}}rw(),vS();function mA(e){if(!(e instanceof R))return e;let t=e.findDetails(Yb)[0];return new f(e.rawMessage,{code:t?.code,line:t?.line,column:t?.column,engineCode:t?.engineCode})}async function*hA(e){try{yield*e}catch(e){throw mA(e)}}var gA=e=>e.catch(e=>{throw mA(e)});function _A(e){let t=e.transport??pA({baseUrl:e.baseUrl??``}),n=SD(fx,t),r=SD(wx,t),i=SD(Fx,t);return{execute:(e,t)=>hA(n.execute(e,t)),count:(e,t)=>gA(n.count(e,t)),explain:(e,t)=>gA(n.explain(e,t)),cancel:(e,t)=>n.cancel(e,t),listSources:(e,t)=>i.listSources(e,t),testSource:(e,t)=>i.testSource(e,t),listFiles:(e,t)=>i.listFiles(e,t),listCatalogs:(e,t)=>r.listCatalogs(e,t),listSchemas:(e,t)=>r.listSchemas(e,t),listTables:(e,t)=>r.listTables(e,t),describeTable:(e,t)=>r.describeTable(e,t),listSnapshots:(e,t)=>r.listSnapshots(e,t)}}zb(),vS();function vA(e,t){let n=Hh(Xb,e);return n.baseSql=`SELECT * FROM ${t.relation}`,n.parameters=[],n}function yA(e={}){let t=e.maxRows??25e4,n=e.maxEntries??24,r=e.ttlMs??9e5,i=new Map,a=e=>{let t=i.get(e);t&&(i.delete(e),t.held.then(e=>e&&t.engine.dropStored?.(e.relation)).catch(()=>{}))},o=()=>{let e=Date.now();for(let[t,n]of i)e-n.madeAt>r&&a(t);let t=[...i].sort((e,t)=>e[1].usedAt-t[1].usedAt);for(let[e]of t.slice(0,Math.max(0,i.size-n)))a(e)};return{async get(e,n,s,c,l){if(!n.store||!dT(s)||uT(s.baseSql))return;let u=uw(s.baseSql),d=JSON.stringify([e,u,s.parameters.map(e=>[e.kind.case,String(e.kind.value)]),c?Ty(Zb,c):``]),f=Date.now(),p=i.get(d);if(p&&(f-p.madeAt>r||l!==``&&p.madeFor<l&&new Date(p.madeAt).toISOString()<l)&&(a(d),p=void 0),!p){sT(u,n.dialect);let e=s.parameters.map(e=>e.kind.value),r={engine:n,held:n.store(u,e,{maxRows:t,timeTravel:c}).then(async e=>{if(e.complete)return{key:d,relation:e.relation,rowCount:e.rowCount,createdAt:new Date(f).toISOString()};await n.dropStored?.(e.relation).catch(()=>{})}).catch(()=>{i.get(d)===r&&i.delete(d)}),madeAt:f,usedAt:f,madeFor:l};p=r,i.set(d,p),o()}return p.usedAt=f,p.held},forget:a,clear(){for(let e of[...i.keys()])a(e)},async close(){for(let e of[...i.keys()])a(e)}}}zb(),rw(),vS(),_p();function bA(e,t,n,r={}){return new R(n,e,void 0,[{desc:Yb,value:{code:t,message:n,...r}}])}function xA(e,t){let n=e.slice(0,t).split(`
|
|
18
|
-
`);return{line:n.length,column:n.at(-1).length+1}}function SA(e,t={}){return e instanceof R?e:e instanceof aw?bA(L.InvalidArgument,e.code,e.message,{line:e.line,column:e.column}):e instanceof iw?bA(e.code===`CANCELLED`?L.Canceled:e.code===`UNSUPPORTED`?L.Unimplemented:e.code===`UNKNOWN_TABLE`?L.NotFound:L.InvalidArgument,e.code,e.message,{engineCode:e.engineCode,...t}):(console.error(`[surfaces] internal error:`,e),new R(`The server hit an unexpected error.`,L.Internal))}async function CA(e){await ww();let t=new Map(e.sources.map(e=>[e.id,e])),n=e.defaultBatchRows??4096,r=e.maxResultRows??1e6,i=new Map,a=e.storedResults===!1?void 0:yA(e.storedResults),o=e=>{let n=t.get(e)??(e===``&&t.size===1?[...t.values()][0]:void 0);if(!n)throw new R(`Unknown source: ${e||`(none given)`}`,L.NotFound);return n},s=e=>{try{return o(e).engine}catch{return}},c=e=>ym(Dx,{id:e.id,displayName:e.displayName??e.id,kind:e.kind??jx.DUCKDB,engine:e.engine.kind,dialect:e.engine.dialect,readOnly:!0,connections:e.engine.connections??[],capabilities:{...e.engine.capabilities,storedResults:a!==void 0&&e.engine.store!==void 0,maxBatchRows:65536,maxResultRows:BigInt(r)}}),l=e=>e??ym(Xb),u=e=>ym($b,{part:e}),d=async e=>{try{return await e()}catch(e){throw SA(e)}},f=async(e,t,n)=>{if(!t||!(e instanceof iw)||e.code===`CANCELLED`||e.code===`TIMEOUT`)return{};let r=uw(n.baseSql);try{await t.explain(r,n.parameters.map(e=>e.kind.value))}catch(e){if(e instanceof iw&&e.position!==void 0)return xA(n.baseSql,Math.max(0,n.baseSql.indexOf(r))+e.position)}return{}},p=async(e,t,n)=>{let r=l(e.query);try{return await m(e,r,t,n)}catch(i){if(!(i instanceof iw)||i.code!==`UNKNOWN_COLUMN`||r.filters.length===0)throw i;let{engine:a}=o(e.sourceId),s=eT(r,a.dialect),c=await a.execute(s.sql,s.params,{signal:n,timeTravel:e.timeTravel}).catch(()=>void 0);if(!c)throw i;let l=c.schema.fields.map(e=>e.name);await c.batches[Symbol.asyncIterator]().return?.();let u=tT(r,l);if(u.notices.length===0)throw i;let d=await m(e,u.query,t,n);return{...d,notices:[...u.notices,...d.notices]}}},m=async(e,t,n,r)=>{let{id:i,engine:s}=o(e.sourceId),c=n(t,s.dialect),l=await a?.get(i,s,t,e.timeTravel,e.notBefore);if(l){let e=n(vA(t,l),s.dialect);try{return{result:await s.execute(e.sql,e.params,{signal:r}),held:l,sql:c.sql,mode:c.mode,notices:c.notices.filter(e=>e.code!==`UNSTABLE_PAGE_ORDER`)}}catch(e){if(!(e instanceof iw)||e.code!==`UNKNOWN_TABLE`)throw e;a?.forget(l.key),l=void 0}}return{result:await s.execute(c.sql,c.params,{signal:r,timeTravel:e.timeTravel}),held:l,sql:c.sql,mode:c.mode,notices:c.notices}},h=e=>{e.service(fx,{async*execute(e,t){let a=Date.now(),o=new AbortController;t.signal.addEventListener(`abort`,()=>o.abort(),{once:!0}),e.queryId&&i.set(e.queryId,o);try{let{result:t,held:i,sql:s,mode:c,notices:l}=await p(e,$w,o.signal);yield u({case:`header`,value:{arrowSchema:Sp(t.schema),executedSql:s,rewriteMode:c,notices:l,queryId:e.queryId,stored:i?{createdAt:i.createdAt,rowCount:BigInt(i.rowCount)}:void 0,columns:t.schema.fields.map(e=>{let t=!P.isList(e.type)&&!P.isStruct(e.type)&&!P.isMap(e.type);return{name:e.name,nativeType:String(e.type),sortable:t,filterable:t}})}});let d=Math.min(e.batchRows||n,65536),f=0,m=!1,h=[],g=0,_=function*(e){for(;g>=d||e&&g>0;){let e=Math.min(d,g),t=[];for(;e>0;){let n=h[0];n.numRows<=e?(t.push(n),h.shift(),e-=n.numRows,g-=n.numRows):(t.push(n.slice(0,e)),h[0]=n.slice(e),g-=e,e=0)}for(let e of t)yield u({case:`batch`,value:{arrowBatch:xp(e).batch,rowCount:BigInt(e.numRows)}})}};for await(let e of t.batches){let t=r-f,n=e.numRows>t?e.slice(0,t):e;if(n.numRows>0&&(h.push(n),g+=n.numRows,f+=n.numRows),yield*_(!1),e.numRows>t){m=!0,o.abort();break}}yield*_(!0),h=[],yield u({case:`footer`,value:{totalRowsReturned:BigInt(f),nextCursor:``,truncated:m,elapsedMs:BigInt(Date.now()-a)}})}catch(t){throw SA(t,await f(t,s(e.sourceId),l(e.query)))}finally{e.queryId&&i.delete(e.queryId)}},async cancel(e){let t=i.get(e.queryId);return t?.abort(),{cancelled:t!==void 0}},async explain(e){let{engine:t}=o(e.sourceId),n=l(e.query);try{let e=$w(n,t.dialect);return{...await t.explain(e.sql,e.params),executedSql:e.sql}}catch(e){throw SA(e,await f(e,t,n))}},async count(e){let t=l(e.query);try{let{id:n,engine:r}=o(e.sourceId),i=t.groupBy.length>0||t.aggregates.length>0||t.buckets.length>0;if(t.filters.length===0&&!i){let i=await a?.get(n,r,t,e.timeTravel,e.notBefore);if(i)return{rowCount:BigInt(i.rowCount),estimated:!1}}let{result:s}=await p(e,oT),c=0n;for await(let e of s.batches)e.numRows>0&&(c=BigInt(e.getChildAt(0)?.get(0)??0));return{rowCount:c,estimated:!1}}catch(n){throw SA(n,await f(n,s(e.sourceId),t))}}}),e.service(wx,{listCatalogs:e=>d(async()=>({catalogs:await o(e.sourceId).engine.listCatalogs()})),listSchemas:e=>d(async()=>({schemas:await o(e.sourceId).engine.listSchemas(e.catalog)})),listTables:e=>d(async()=>{let{engine:t}=o(e.sourceId),n=Math.max(0,Number(e.pageToken||0)||0);if(t.pagesTables&&e.pageSize>0){let r=await t.listTables({catalog:e.catalog,schema:e.schema,search:e.search,limit:e.pageSize+1,offset:n});return{tables:r.slice(0,e.pageSize),nextPageToken:r.length>e.pageSize?String(n+e.pageSize):``}}let r=await t.listTables({catalog:e.catalog,schema:e.schema,search:e.search}),i=e.pageSize>0?n+e.pageSize:r.length;return{tables:r.slice(n,i),nextPageToken:i<r.length?String(i):``}}),describeTable:e=>d(async()=>{if(!e.ref)throw new R(`A table is required.`,L.InvalidArgument);let{engine:t}=o(e.sourceId),n=e.ref;try{return{table:await t.describeTable(n,e.includeStats)}}catch(r){let i=n.table.split(`.`);if(!(r instanceof iw)||r.code!==`UNKNOWN_TABLE`||n.schema||n.catalog||i.length<2||i.length>3||i.some(e=>!e))throw r;let a=i.length===3?{catalog:i[0],schema:i[1],table:i[2]}:{catalog:``,schema:i[0],table:i[1]};return{table:await t.describeTable({...n,...a},e.includeStats)}}}),listSnapshots:e=>d(async()=>{if(!e.ref)throw new R(`A table is required.`,L.InvalidArgument);return{snapshots:await o(e.sourceId).engine.listSnapshots(e.ref)}})}),e.service(Fx,{listSources:async()=>({sources:[...t.values()].map(c)}),getSource:async e=>({source:c(o(e.id))}),registerSource:async()=>{throw new R(`Sources are set in the server's configuration.`,L.Unimplemented)},removeSource:async()=>{throw new R(`Sources are set in the server's configuration.`,L.Unimplemented)},listFiles:e=>d(async()=>{let{engine:t}=o(e.sourceId);if(!t.listFiles)throw new R(`This source has no storage to list.`,L.Unimplemented);let{entries:n,truncated:r}=await t.listFiles(e.path),i=Math.min(Math.max(e.pageSize||500,1),2e3),a=Math.max(0,Number.parseInt(e.pageToken||`0`,10)||0),s=a+i;return{entries:n.slice(a,s),nextPageToken:s<n.length?String(s):``,truncated:r??!1}}),testSource:e=>d(async()=>{if(e.target.case!==`id`)throw new R(`Only configured sources can be tested.`,L.Unimplemented);let t=Date.now(),{engine:n}=o(e.target.value),r=``,i;try{r=await n.version()}catch(e){i=e instanceof Error?e.message:String(e)}let a=await n.check?.().catch(()=>void 0)??[],s=a.filter(e=>!e.ok);return{ok:!i&&s.length===0,message:i&&s.length===0?`The source could not be reached: ${i}`:s.length===0?`Connected`:`${s.length} of ${a.length} could not be reached`,elapsedMs:BigInt(Date.now()-t),engineVersion:r,checks:a.map(e=>({...e,elapsedMs:BigInt(e.elapsedMs)}))}})})},g=_A({transport:cA(h)});return[...t.values()].some(e=>e.engine.listFiles)||delete g.listFiles,{routes:h,dataSource:g,engineOf:s,clearResults:()=>a?.clear(),async close(){for(let e of i.values())e.abort();await a?.close()}}}vS();var wA=/sql|query|statement/i;function TA(e,t,n){return{server:t,async list(){let r=(await e.listTools(t)).servers?.find(e=>e.server===t)?.tools??[],i=[];for(let{name:a}of r){if(!(n===void 0?wA.test(a):a===n)){i.push({name:a});continue}let r=await e.describeTool(t,a).then(e=>e.inputSchema,()=>void 0);i.push({name:a,inputSchema:r})}return i},async call(n,r,{signal:i}){try{return await e.callTool(t,n,r,{signal:i})}catch(e){throw EA(e,t)}}}}function EA(e,t){let{code:n,message:r}=e??{};if(n===`tool_error`||n===void 0)return Error(r??String(e));let i={needs_reauth:`Reconnect ${t} in Claude's settings, under Connectors, then open this page again.`,server_not_connected:`This page reads from ${t}. Add it in Claude's settings, under Connectors, then open this page again.`,not_granted:`This page was not allowed to use ${t}. Allow it in the page's permissions to see the data.`,not_in_manifest:`This page was not published with permission to use ${t}.`,rate_limited:`${t} is being asked too often. Wait a moment and try again.`,server_unavailable:`${t} did not answer. Try again in a moment.`};return new iw(n===`server_unavailable`?`TIMEOUT`:`ENGINE`,i[n]??`${t} could not be used from this page (${n}).`)}async function DA(e,t){return(await CA({sources:await Promise.all(t.map(async t=>{if(t.id===`page`)throw Error(`A connector source cannot be called "page": that is the page's own rows.`);let n=TA(e,t.server,t.tool),r=await mE(e=>OE(async()=>n,{tool:t.tool,argument:t.argument,arguments:{...e,...t.arguments}}),{dialect:t.dialect,address:t.server,database:t.database,databases:t.databases});return{id:t.id,displayName:t.displayName??t.server,kind:OA[t.dialect],engine:r}})),storedResults:!1})).dataSource}var OA={postgres:jx.POSTGRES,mysql:jx.MYSQL,duckdb:jx.DUCKDB,teradata:jx.TERADATA};function kA(e,t){let n={...e};for(let r of Object.keys(e))typeof e[r]==`function`&&r!==`listSources`&&(n[r]=(n,i)=>{let a=n?.sourceId===`page`?t():e,o=a[r];if(!o)throw Error(`The page's own rows cannot answer this.`);return o.call(a,n,i)});return n}function AA(e){FA=Intl.getCanonicalLocales(e.replaceAll(`_`,`-`))[0]??`en-US`}function jA(e={}){let t=`${FA}|${JSON.stringify(e)}`,n=IA.get(t);return n||(n=new Intl.NumberFormat(FA,e),IA.set(t,n)),n}function MA(e={}){let t=`${FA}|${JSON.stringify(e)}`,n=LA.get(t);return n||(n=new Intl.DateTimeFormat(FA,e),LA.set(t,n)),n}function NA(e){let t={...zA};for(let[n,r]of Object.entries(e))typeof r==`string`&&n in RA&&(t[n]=r);zA=t}function PA(){zA={...RA}}function z(e,t){let n=zA[e];return t?n.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e):n}var FA,IA,LA,RA,zA,BA=n((()=>{FA=`en-US`,IA=new Map,LA=new Map,RA={"cell.null":`null`,"cell.true":`true`,"cell.false":`false`,"grid.label":`Query result`,"grid.sortAscending":`Sort ascending`,"grid.sortDescending":`Sort descending`,"grid.clearSorting":`Clear sorting`,"grid.moveLeft":`Move left`,"grid.moveRight":`Move right`,"grid.hideColumn":`Hide column`,"grid.showAllColumns":`Show all columns`,"grid.showAllColumnsHidden":`Show all columns ({count} hidden)`,"grid.resetWidth":`Reset width`,"grid.resetWidthHint":`Double-click edge`,"grid.resetLayout":`Reset column layout`,"grid.copyColumnName":`Copy column name`,"grid.sqlCountValues":`SQL: count each value`,"grid.sqlRange":`SQL: range and missing values`,"grid.copyValue":`Copy value`,"grid.copyRowJson":`Copy row as JSON`,"grid.filterToValue":`Filter to this value`,"grid.leaveValueOut":`Leave this value out`,"grid.copied":`Copied {what}.`,"grid.copiedCell":`the cell`,"grid.copiedRow":`the row`,"grid.copiedColumnName":`the column name`,"grid.copiedSql":`the SQL`,"grid.copyFailed":`Could not copy: the browser refused access to the clipboard.`,"grid.movedLeft":`Moved {name} left.`,"grid.movedRight":`Moved {name} right.`,"grid.moved":`Moved {name}.`,"grid.columnMenu":`{name} column`,"grid.cellMenu":`{name} cell`,"grid.activeCellMenu":`Cell`,"grid.failed":`Query failed`,"grid.loading":`Loading…`,"grid.rows":`{count} rows`,"grid.rowsOne":`{count} row`,"grid.noRows":`No rows match.`,"grid.showHidden":`Show {count} hidden columns`,"grid.showHiddenOne":`Show {count} hidden column`,"grid.elapsed":`{ms} ms`,"grid.asOf":`As of {time}`,"grid.runAgain":`Run again`,"grid.previous":`Previous`,"grid.next":`Next`,"grid.page":`Page {page} of {pages}`,"pivot.label":`Pivot table`,"pivot.loading":`Loading…`,"pivot.choose":`Choose rows or columns and a measure.`,"pivot.empty":`No rows match.`,"pivot.total":`Total`,"pivot.all":`All`,"pivot.none":`(none)`,"pivot.truncated":`This pivot has more than {limit} cells, so some are missing. Add a filter or choose columns with fewer values.`,"pivot.hiddenColumns":`Showing the first {shown} of {total} column values.`,"chart.empty":`No data to chart.`,"chart.missingX":`Rows with no {x} are not drawn{detail}.`,"chart.description":`{type} chart of {measures} by {x}`,"chart.coloursRepeat":`{count} series share {colours} colours, so some repeat. Filter, or split by a column with fewer values.`,"chart.advice":`{message} Better: {instead}`,"chart.sampleNote":`Showing a random sample of {count} rows.`,"chart.firstNote":`Showing the first {count} points.`,"chart.largestNote":`Showing the largest {count} points.`,"rows.loading":`Loading…`,"rows.empty":`Nothing to show.`,"rows.more":`Show more`,"rows.some":`Showing the first {count}.`,"rows.full":`Showing the first {count}. Filter to find others.`,"metric.loading":`…`,"metric.none":`–`,"sparkline.summary":`{label}: {now} now, from {first}; low {low}, high {high} over {count} {grain}s.`,"sparkline.empty":`{label}: no data.`,"bullet.loading":`{label}: loading.`,"bullet.empty":`{label}: no data.`,"bullet.reading":`{label}: {value}{band}{target}.`,"bullet.targetMet":`; target {target}, met`,"bullet.targetNotMet":`; target {target}, not met`,"bullet.target":`Target {target}`,"filter.active":`Active filters`,"filter.remove":`Remove filter {filter}`,"filter.form":`Add a filter`,"filter.column":`Column`,"filter.comparison":`Comparison`,"filter.value":`Value`,"filter.typeOrPick":`Type or pick a value`,"filter.add":`Add filter`,"filter.quickRange":`Quick date range`,"filter.quickRangeChoose":`Quick range…`,"filter.range7d":`Last 7 days`,"filter.range30d":`Last 30 days`,"filter.range90d":`Last 90 days`,"filter.range12m":`Last 12 months`,"filter.rangeMonth":`This month`,"filter.rangeYear":`This year`,"filter.isEmpty":`is empty`,"filter.isNotEmpty":`is not empty`,"filter.contains":`contains`,"filter.is":`is`,"filter.isNot":`is not`,"filter.startsWith":`starts with`,"filter.endsWith":`ends with`,"filter.enterWholeNumber":`Enter a whole number.`,"filter.enterNumber":`Enter a number.`,"filter.enterTrueFalse":`Enter true or false.`,"filter.enterDate":`Enter a date like 2026-01-31.`,"filter.enterValue":`Enter a value.`,"result.views":`Result view`,"result.tabTable":`Table`,"result.tabChart":`Chart`,"result.tabPivot":`Pivot`,"result.stopExport":`Stop export`,"result.downloadCsv":`Download CSV`,"result.copySql":`Copy SQL`,"result.cancelQuery":`Cancel query`,"result.format":`Format`,"result.formatColumn":`Column to format`,"result.chooseColumn":`Choose a column…`,"result.howToShow":`How to show {column}`,"result.asItIs":`As it is`,"result.formatNumber":`Number`,"result.formatCompact":`Short number (1.2M)`,"result.formatCurrency":`Currency`,"result.formatPercent":`Percent`,"result.formatText":`Plain text`,"result.formatDate":`Date only`,"result.formatDatetime":`Date and time`,"result.preparing":`Preparing the file…`,"result.rowsSoFar":`{count} rows so far…`,"result.saved":`Saved {count} rows.`,"result.savedTruncated":`Saved {count} rows. The server's row limit was reached, so the file is not the whole result.`,"result.exportStopped":`Export stopped.`,"result.sqlCopied":`SQL copied.`,"result.copyNotAllowed":`Copying is not allowed here.`,"result.sqlSent":`SQL sent to the engine`,"result.plan":`How the engine will run it`,"result.stored":`The query ran once and its result was kept, so sorting, filtering and paging read the kept rows instead of running it again.`,"result.chooseChart":`Choose columns to chart.`,"result.choosePivot":`Choose what goes in the rows and the values.`,"result.chartType":`Type`,"result.slices":`Slices`,"result.xAxis":`X axis`,"result.yAxis":`Y axis`,"result.every":`Every`,"result.bins":`Bins`,"result.binsEach":`each value`,"result.binsAbout":`about {count}`,"result.splitBy":`Split by`,"result.nothing":`nothing`,"result.legend":`Legend`,"result.automatic":`automatic`,"result.legendHidden":`hidden`,"result.stack":`Stack`,"result.plotEachRow":`Plot each row`,"result.series":`Series {number}`,"result.of":`of`,"result.drawnAs":`Drawn as`,"result.drawnAsChart":`chart type ({type})`,"result.scale":`Scale`,"result.leftAxis":`left axis`,"result.rightAxis":`right axis`,"result.removeSeries":`Remove series {number}`,"result.remove":`Remove`,"result.addSeries":`Add series`,"result.rows":`Rows`,"result.columns":`Columns`,"result.none":`none`,"result.datesBy":`Dates by`,"result.values":`Values`,"result.sum":`sum`,"result.avg":`average`,"result.median":`median`,"result.count":`count of rows`,"result.countDistinct":`distinct count`,"result.min":`minimum`,"result.max":`maximum`,"result.stddev":`standard deviation`,"result.p90":`90th percentile`,"form.submit":`Submit`,"form.choose":`Choose…`,"form.required":`(required)`,"form.needsAttention":`Nothing was sent. {count} fields need attention.`,"form.needsAttentionOne":`Nothing was sent. One field needs attention.`,"form.sent":`Sent.`,"form.notSaved":`The backend did not save it.`,"form.saved":`Saved.`,"form.couldNotSend":`Could not send: {error}`,"form.sending":`Sending…`,"form.connected":`Saved by the backend this page is connected to.`,"form.notConnected":`Not connected to a backend: what you submit goes only to this page.`,"flow.done":`Done`,"flow.current":`In progress`,"flow.waiting":`Waiting for you`,"flow.pending":`Not started`,"flow.failed":`Failed`,"flow.skipped":`Skipped`,"flow.count":`{done} of {total} done`,"plan.riskLow":`Low risk`,"plan.riskMedium":`Check this`,"plan.riskHigh":`Changes or removes data`,"plan.proposedBy":`Proposed by {who}. Nothing runs until you approve.`,"plan.required":`Required`,"plan.affects":`Affects: {what}`,"plan.whatItWouldRun":`What it would run`,"plan.approved":`Approved {count} of {total} steps.`,"plan.rejected":`Rejected. Nothing was run.`,"plan.decisionNote":` Note: {note}`,"plan.noteLabel":`Note for the record (optional)`,"plan.approve":`Approve {count} steps`,"plan.approveOne":`Approve {count} step`,"plan.reject":`Reject`,"receipt.done":`Done`,"receipt.partial":`Partly done`,"receipt.failed":`Failed`,"receipt.ran":`Ran`,"receipt.by":`by {who}`,"receipt.approved":`Approved`,"receipt.noApproval":`No one approved this.`,"receipt.whatChanged":`What changed`,"receipt.what":`What`,"receipt.before":`Before`,"receipt.after":`After`,"receipt.whatRan":`What ran`,"receipt.cannotUndo":`This cannot be undone from here.`,"receipt.undoClosed":`It could be undone until {time}; that time has passed.`,"receipt.undoUntil":`Can be undone until {time}.`,"receipt.undoRequested":`Undo requested. You will be asked to confirm it.`,"table.selectPage":`Select every row on this page`,"table.selectRow":`Select {name}`,"table.empty":`Nothing to show.`,"table.loading":`Loading…`,"table.rowControls":`{name} actions`,"table.actions":`Actions`,"table.select":`Select`,"selection.label":`With the selected rows`,"selection.count":`{count} selected`,"selection.pageSelected":`All {count} on this page are selected.`,"selection.selectAllMatching":`Select all {total} that match`,"selection.allMatching":`All {total} that match are selected.`,"selection.onlyPage":`Only this page`,"selection.clear":`Clear`,"pages.label":`Pages`,"pages.range":`{from}–{to} of {total}`,"pages.previous":`Previous`,"pages.next":`Next`,"confirm.confirm":`Confirm`,"confirm.cancel":`Cancel`,"combobox.loading":`Looking…`,"combobox.none":`Nothing matches.`,"combobox.count":`{count} suggestions`,"combobox.countOne":`1 suggestion`,"report.untitled":`Untitled`,"report.untitledReport":`Untitled report`,"report.title":`Report title`,"report.tileTitle":`Title of {title}`,"report.tileControls":`{title} controls`,"report.mode":`Mode`,"report.build":`Build`,"report.view":`View`,"report.builder":`Build a view`,"report.body":`Report`,"report.changing":`Changing “{title}”.`,"report.leaveAsItWas":`Leave it as it was`,"report.leftAsItWas":`Left as it was.`,"report.updateView":`Update view`,"report.addToReport":`Add to report`,"report.maxViews":`A report holds at most {max} views.`,"report.needMeasure":`Put a metric on “Measure” first: a view needs something to measure.`,"report.emptyBuild":`Nothing on the report yet. Make a view above and press “Add to report”; each one you add appears here, and they all follow the same filters.`,"report.emptyView":`This report has no views yet. Switch to Build to make one.`},zA={...RA}})),VA=r((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),HA=r(((e,t)=>{t.exports=VA()}));function UA({locale:e,labels:t,children:n}){return AA(e??`en-US`),PA(),t&&NA(t),(0,WA.jsx)(WA.Fragment,{children:n})}var WA,GA=n((()=>{WA=HA(),BA()}));function KA(e){return typeof e==`string`&&lj.test(e)}function qA(e){if(!KA(e))throw Error(`Not a hex colour: ${String(e)}`);let t=e.slice(1);return`#${(t.length===3?t.split(``).map(e=>e+e).join(``):t).toUpperCase()}`}function JA(e){let t=Number.parseInt(qA(e).slice(1),16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function YA({r:e,g:t,b:n}){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`.toUpperCase()}function XA({r:e,g:t,b:n}){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2,l=o-s;if(l===0)return{h:0,s:0,l:c};let u=l/(1-Math.abs(2*c-1)),d;return d=o===r?(i-a)/l%6:o===i?(a-r)/l+2:(r-i)/l+4,{h:(d*60+360)%360,s:u,l:c}}function ZA({h:e,s:t,l:n}){let r=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=r*(1-Math.abs(i%2-1)),o=n-r/2,[s,c,l]=i<1?[r,a,0]:i<2?[a,r,0]:i<3?[0,r,a]:i<4?[0,a,r]:i<5?[a,0,r]:[r,0,a];return{r:(s+o)*255,g:(c+o)*255,b:(l+o)*255}}function QA(e){let{r:t,g:n,b:r}=JA(e),i=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*i(t)+.7152*i(n)+.0722*i(r)}function $A(e,t){let n=QA(e),r=QA(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function ej(e,t,n){let r=JA(e),i=JA(t),a=Math.max(0,Math.min(1,n));return YA({r:r.r+(i.r-r.r)*a,g:r.g+(i.g-r.g)*a,b:r.b+(i.b-r.b)*a})}function tj(e){let{r:t,g:n,b:r}=JA(e),[i,a,o]=[uj(t),uj(n),uj(r)],s=Math.cbrt(.4122214708*i+.5363325363*a+.0514459929*o),c=Math.cbrt(.2119034982*i+.6806995451*a+.1073969566*o),l=Math.cbrt(.0883024619*i+.2817188376*a+.6299787005*o);return[.2104542553*s+.793617785*c-.0040720468*l,1.9779984951*s-2.428592205*c+.4505937099*l,.0259040371*s+.7827717662*c-.808675766*l]}function nj([e,t,n]){let r=(e+.3963377774*t+.2158037573*n)**3,i=(e-.1055613458*t-.0638541728*n)**3,a=(e-.0894841775*t-1.291485548*n)**3;return YA({r:dj(4.0767416621*r-3.3077115913*i+.2309699292*a),g:dj(-1.2684380046*r+2.6097574011*i-.3413193965*a),b:dj(-.0041960863*r-.7034186147*i+1.707614701*a)})}function rj(e,t,n){let r=tj(e),i=tj(t),a=Math.max(0,Math.min(1,n));return nj([r[0]+(i[0]-r[0])*a,r[1]+(i[1]-r[1])*a,r[2]+(i[2]-r[2])*a])}function ij(e,t,n,r){let i=e=>r.every(t=>$A(e,t)>=n);if(!i(e))return qA(e);let a=0,o=1;for(let n=0;n<24;n++){let n=(a+o)/2;i(rj(e,t,n))?a=n:o=n}return rj(e,t,a)}function aj(e){let{r:t,g:n,b:r}=JA(e);return`${t} ${n} ${r}`}function oj(e,t,n){return ej(n,e,t)}function sj(e){return $A(e,`#FFFFFF`)>=$A(e,`#000000`)?`#FFFFFF`:`#000000`}function cj(e,t,n){if($A(e,t)>=n)return qA(e);let r=XA(JA(e)),i=QA(t)<.5,a=qA(e);for(let e=1;e<=50;e++){let o=i?r.l+(1-r.l)*e/50:r.l-r.l*e/50;if(a=YA(ZA({...r,l:o})),$A(a,t)>=n)break}return a}var lj,uj,dj,fj=n((()=>{lj=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,uj=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},dj=e=>255*(e<=.0031308?12.92*e:1.055*Math.max(0,e)**(1/2.4)-.055)}));function pj(e,t){let n=e.map(e=>e.toUpperCase()).join(`,`),r=[Cj,...wj];for(let e of Object.keys(Tj)){let i=[Tj[e],...Ej[e]??[]];for(let a of r)for(let r of i)if(r.map(e=>(a[e]??Cj[e])[t]).join(`,`).toUpperCase()===n)return hj(e,t).series}return e}function mj(e,t){for(let n of wj)for(let[r,i]of Object.entries(n))if(i[t].toUpperCase()===e.toUpperCase()&&Cj[r][t]!==i[t])return Cj[r][t];return e}function hj(e,t){let n=Tj[e],r=n[0]===`blue`||n[0]===`indigo`?n[0]:`blue`;return{series:n.map(e=>Cj[e][t]),sequential:Cj[n[0]][t],diverging:[Cj.red[t],Cj[r][t]]}}function gj(e,t,n){if(e===void 0)return t;if(typeof e!=`object`||!e)throw Error(`${n} must be an object`);let r=e,i=(e,t)=>{if(!KA(e))throw Error(`${t} must be a hex colour like #1A2B3C`);return qA(e)},a=t.series;if(r.series!==void 0){if(!Array.isArray(r.series)||r.series.length<2||r.series.length>12)throw Error(`${n}.series must be a list of 2 to 12 colours`);a=r.series.map((e,t)=>i(e,`${n}.series[${t}]`))}let o=t.diverging;if(r.diverging!==void 0){if(!Array.isArray(r.diverging)||r.diverging.length!==2)throw Error(`${n}.diverging must be two colours`);o=[i(r.diverging[0],`${n}.diverging[0]`),i(r.diverging[1],`${n}.diverging[1]`)]}return{series:a,sequential:r.sequential===void 0?t.sequential:i(r.sequential,`${n}.sequential`),diverging:o}}function _j([e,t,n]){let r=Math.cbrt(.4122214708*e+.5363325363*t+.0514459929*n),i=Math.cbrt(.2119034982*e+.6806995451*t+.1073969566*n),a=Math.cbrt(.0883024619*e+.2817188376*t+.6299787005*n);return[.2104542553*r+.793617785*i-.0040720468*a,1.9779984951*r-2.428592205*i+.4505937099*a,.0259040371*r+.7827717662*i-.808675766*a]}function vj(e,t){let{r:n,g:r,b:i}=JA(e),a=[Oj(n),Oj(r),Oj(i)];return t?kj[t].map(e=>Math.min(1,Math.max(0,e[0]*a[0]+e[1]*a[1]+e[2]*a[2]))):a}function yj(e,t,n){let[r,i,a]=_j(vj(e,n)),[o,s,c]=_j(vj(t,n));return 100*Math.hypot(r-o,i-s,a-c)}function bj(e,t){let n=[];for(let t=0;t+1<e.length;t++){let[r,i]=[e[t],e[t+1]],a=[t+1,t+2],o=yj(r,i),s=Math.min(yj(r,i,`protan`),yj(r,i,`deutan`));o<15?n.push({severity:`error`,slots:a,message:`Colours ${a[0]} and ${a[1]} are too alike to tell apart.`}):s<6?n.push({severity:`error`,slots:a,message:`Colours ${a[0]} and ${a[1]} look the same with red-green colour blindness.`}):s<8&&n.push({severity:`warning`,slots:a,message:`Colours ${a[0]} and ${a[1]} are close with red-green colour blindness; label the series.`})}for(let t=0;t<Math.min(e.length,5);t++)for(let r=t+2;r<Math.min(e.length,5);r++){let[i,a]=[e[t],e[r]];yj(i,a)<13?n.push({severity:`error`,slots:[t+1,r+1],message:`Colours ${t+1} and ${r+1} are too alike to tell apart in a legend.`}):Math.min(yj(i,a,`protan`),yj(i,a,`deutan`))<8&&n.push({severity:`warning`,slots:[t+1,r+1],message:`Colours ${t+1} and ${r+1} are close with red-green colour blindness; make one lighter or darker, or label the series.`})}return e.forEach((e,r)=>{$A(e,t)<3&&n.push({severity:`warning`,slots:[r+1],message:`Colour ${r+1} is faint against the background; charts using it should label values or offer a table.`})}),n}function xj(e,t,n=7){let r=QA(t)<.5,i=ej(t,e,r?.3:.2),a=ej(e,r?`#FFFFFF`:`#000000`,r?.35:.4),o=(n-1)/2;return Array.from({length:n},(t,r)=>r<=o?ej(i,e,o===0?1:r/o):ej(e,a,(r-o)/(n-1-o)))}function Sj(e,t,n=7){let r=QA(t)<.5,i=ej(t,r?`#FFFFFF`:`#000000`,r?.16:.07),a=Math.floor(n/2),o=e=>Array.from({length:a},(t,n)=>ej(i,e,(a-n)/a));return[...o(e[0]),i,...o(e[1]).reverse()]}var Cj,wj,Tj,Ej,Dj,Oj,kj,Aj=n((()=>{fj(),Cj={red:{light:`#C21725`,dark:`#FF605B`},orange:{light:`#DA6600`,dark:`#FE7802`},amber:{light:`#B27805`,dark:`#EC9F00`},yellow:{light:`#DABD0A`,dark:`#F4D40F`},green:{light:`#006A18`,dark:`#65EA71`},mint:{light:`#089772`,dark:`#00D7A4`},teal:{light:`#079390`,dark:`#00CBC6`},cyan:{light:`#078EAD`,dark:`#04C4ED`},blue:{light:`#217BF4`,dark:`#73ACFF`},indigo:{light:`#696BF4`,dark:`#97A1FF`},purple:{light:`#9D57DE`,dark:`#BF82FF`},pink:{light:`#AC0D71`,dark:`#E853A5`},magenta:{light:`#A52DA0`,dark:`#D25BCB`}},wj=[{red:{light:`#DE3B3D`,dark:`#FF726B`},orange:{light:`#C85D02`,dark:`#FE7802`},amber:{light:`#B27805`,dark:`#FCAB05`},green:{light:`#029B29`,dark:`#39C34B`},teal:{light:`#079390`,dark:`#0EBCB8`},blue:{light:`#217BF4`,dark:`#68A5FF`},indigo:{light:`#696BF4`,dark:`#909AFE`},pink:{light:`#D13D91`,dark:`#FC65B6`},magenta:{light:`#BE47B8`,dark:`#E76EDF`}}],Tj={Classic:[`blue`,`red`,`teal`,`amber`,`magenta`,`green`,`indigo`,`orange`],Aurora:[`teal`,`amber`,`magenta`,`red`,`indigo`,`green`,`blue`,`orange`],Sand:[`orange`,`teal`,`purple`,`green`,`pink`,`blue`,`red`,`indigo`],Ink:[`indigo`,`red`,`teal`,`amber`,`magenta`,`green`,`blue`,`orange`],Berry:[`magenta`,`red`,`teal`,`amber`,`indigo`,`green`,`blue`,`orange`],Moss:[`green`,`magenta`,`red`,`blue`,`amber`,`teal`,`orange`,`indigo`]},Ej={Classic:[[`blue`,`red`,`indigo`,`orange`,`teal`,`amber`,`purple`,`green`]],Aurora:[[`teal`,`orange`,`blue`,`red`,`indigo`,`amber`,`purple`,`green`],[`teal`,`orange`,`pink`,`amber`,`purple`,`red`,`indigo`,`green`]],Sand:[[`orange`,`blue`,`green`,`indigo`,`red`,`purple`,`amber`,`magenta`]],Ink:[[`indigo`,`red`,`blue`,`orange`,`teal`,`amber`,`purple`,`green`]],Berry:[[`magenta`,`amber`,`blue`,`orange`,`indigo`,`green`,`purple`,`red`]],Moss:[[`green`,`purple`,`amber`,`blue`,`red`,`indigo`,`orange`,`teal`]]},Dj=Object.keys(Tj),Oj=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},kj={protan:[[.152286,1.052583,-.204868],[.114503,.786281,.099216],[-.003882,-.048116,1.051998]],deutan:[[.367322,.860646,-.227968],[.280085,.672501,.047413],[-.01182,.04294,.968881]]}}));function jj(e,t,n){if(e===void 0)return t;if(typeof e!=`object`||!e)throw Error(`${n} must be an object`);let r=e,i={...t};for(let e of Wj){let t=r[e];if(t!==void 0){if(!KA(t))throw Error(`${n}.${e} must be a hex colour like #1A2B3C`);i[e]=qA(t)}}return i}function Mj(e,t,n){let r=(e,t)=>Object.keys(e).every(n=>e[n].toUpperCase()===t[n].toUpperCase()),i=Gj.find(i=>i.name===e&&i.mode===t&&i.was.some(e=>r(e,n)));return i?{...n,...i.now}:n}function Nj(e,t){if(typeof e!=`object`||!e)throw Error(`theme must be an object`);let n=e,r=n.name===void 0?t.name:n.name;if(typeof r!=`string`||r.trim()===``)throw Error(`theme.name must be a non-empty string`);let i=t.radius;if(n.radius!==void 0){if(typeof n.radius!=`number`||!Number.isFinite(n.radius))throw Error(`theme.radius must be a number`);i=Math.max(0,Math.min(28,Math.round(n.radius)))}let a=n.font===void 0?t.font:n.font;if(!Bj.includes(a))throw Error(`theme.font must be one of ${Bj.join(`, `)}`);let o=n.density===void 0?t.density:n.density;if(!Vj.includes(o))throw Error(`theme.density must be one of ${Vj.join(`, `)}`);let s=n.contrast===void 0?t.contrast:n.contrast;if(s!==void 0&&!Hj.includes(s))throw Error(`theme.contrast must be one of ${Hj.join(`, `)}`);return{name:r.trim().slice(0,60),light:Mj(r.trim(),`light`,jj(n.light,t.light,`theme.light`)),dark:Mj(r.trim(),`dark`,jj(n.dark,t.dark,`theme.dark`)),radius:i,font:a,density:o,charts:Ij(n.charts,t),...n.code===void 0?t.code?{code:t.code}:{}:{code:Fj(n.code)},...s===`more`?{contrast:`more`}:{}}}function Pj(e,t){if(e===void 0)return;if(typeof e!=`object`||!e)throw Error(`${t} must be an object`);let n={};for(let[r,i]of Object.entries(e)){if(!zj.includes(r))throw Error(`${t}.${r} is not a code token; use one of ${zj.join(`, `)}`);if(!KA(i))throw Error(`${t}.${r} must be a hex colour like #1A2B3C`);n[r]=qA(i)}return n}function Fj(e){if(typeof e!=`object`||!e)throw Error(`theme.code must be an object`);let t=e,n=Pj(t.light,`theme.code.light`),r=Pj(t.dark,`theme.code.dark`);return{...n?{light:n}:{},...r?{dark:r}:{}}}function Ij(e,t){let n=t.charts??{light:hj(`Classic`,`light`),dark:hj(`Classic`,`dark`)};if(e===void 0)return n;if(typeof e!=`object`||!e)throw Error(`theme.charts must be an object`);let r=e,i=gj(r.light,n.light,`theme.charts.light`),a=gj(r.dark,n.dark,`theme.charts.dark`),o=(e,t)=>{let n=pj(e.series,t);return n===e.series?e:{series:n,sequential:mj(e.sequential,t),diverging:[mj(e.diverging[0],t),mj(e.diverging[1],t)]}};return{light:o(i,`light`),dark:o(a,`dark`)}}function Lj(e,t){return{...e,name:`Custom`,charts:t}}function Rj(e,t){let n=e=>{let n=cj(t,e.background,3);return{...e,accent:n,onAccent:sj(n)}};return{...e,name:`Custom`,light:n(e.light),dark:n(e.dark)}}var zj,Bj,Vj,Hj,Uj,Wj,Gj,Kj=n((()=>{Aj(),fj(),zj=[`keyword`,`string`,`number`,`literal`,`comment`,`property`,`function`,`type`,`punctuation`],Bj=[`system`,`rounded`,`serif`,`mono`],Vj=[`comfortable`,`compact`],Hj=[`standard`,`more`],Uj=[`system`,`light`,`dark`],Wj=[`background`,`surface`,`text`,`muted`,`accent`,`onAccent`],Gj=[{name:`Ink`,mode:`light`,was:[{background:`#FBFBFE`,surface:`#EFF0F8`,text:`#141633`,muted:`#565A78`,onAccent:`#FFFFFF`},{background:`#FBFBFD`,surface:`#F0F0F4`,text:`#141633`,muted:`#565A78`,onAccent:`#FFFFFF`}],now:{background:`#FBFBFC`,surface:`#F0F0F2`,text:`#141633`,muted:`#565A78`,onAccent:`#FFFFFF`}},{name:`Ink`,mode:`dark`,was:[{background:`#0A0B18`,surface:`#141629`,text:`#ECEDFB`,muted:`#9EA2C2`,onAccent:`#0A0B18`},{background:`#0B0C12`,surface:`#161720`,text:`#ECEDFB`,muted:`#9EA2C2`,onAccent:`#0B0C12`}],now:{background:`#0C0C0F`,surface:`#17181B`,text:`#ECEDFB`,muted:`#9EA2C2`,onAccent:`#0C0C0F`}},{name:`Sand`,mode:`light`,was:[{background:`#F8F9F5`,surface:`#ECEFE6`,text:`#1C1E18`,muted:`#5D6255`,onAccent:`#FFFFFF`},{background:`#F9F9F3`,surface:`#EFEEE2`,text:`#1E1D15`,muted:`#63614F`,onAccent:`#FFFFFF`},{background:`#FAF9F1`,surface:`#F2EEDC`,text:`#201D11`,muted:`#666046`,onAccent:`#FFFFFF`},{background:`#F9F9F4`,surface:`#F0EEE5`,text:`#201D11`,muted:`#666046`,onAccent:`#FFFFFF`}],now:{background:`#F9F9F6`,surface:`#EFEEE9`,text:`#201D11`,muted:`#666046`,onAccent:`#FFFFFF`}},{name:`Sand`,mode:`dark`,was:[{background:`#11130F`,surface:`#1B1E18`,text:`#F1F3EC`,muted:`#A6AB9D`,onAccent:`#11130F`},{background:`#13120D`,surface:`#1E1D15`,text:`#F3F2E9`,muted:`#ACAA97`,onAccent:`#13120D`},{background:`#14120A`,surface:`#201D10`,text:`#F5F2E5`,muted:`#B0A98E`,onAccent:`#14120A`},{background:`#13120D`,surface:`#1E1D17`,text:`#F5F2E5`,muted:`#B0A98E`,onAccent:`#14120A`}],now:{background:`#13120F`,surface:`#1D1D1A`,text:`#F5F2E5`,muted:`#B0A98E`,onAccent:`#14120A`}},{name:`Aurora`,mode:`light`,was:[{background:`#F9FCFC`,surface:`#ECF4F4`,text:`#0E2226`,muted:`#4E6468`,onAccent:`#FFFFFF`}],now:{background:`#FAFCFC`,surface:`#EFF3F3`,text:`#0E2226`,muted:`#4E6468`,onAccent:`#FFFFFF`}},{name:`Aurora`,mode:`dark`,was:[{background:`#050B0D`,surface:`#0D1619`,text:`#E6F4F5`,muted:`#93ABAF`,onAccent:`#050B0D`}],now:{background:`#070B0C`,surface:`#111517`,text:`#E6F4F5`,muted:`#93ABAF`,onAccent:`#050B0D`}},{name:`Berry`,mode:`light`,was:[{background:`#FDFAFC`,surface:`#F4EEF3`,text:`#261725`,muted:`#695767`,onAccent:`#FFFFFF`},{background:`#FCFAFC`,surface:`#F2EFF2`,text:`#261725`,muted:`#695767`,onAccent:`#FFFFFF`}],now:{background:`#FBFAFB`,surface:`#F1F0F1`,text:`#261725`,muted:`#695767`,onAccent:`#FFFFFF`}},{name:`Berry`,mode:`dark`,was:[{background:`#130C10`,surface:`#20161C`,text:`#F7EDF2`,muted:`#BCA2B0`,onAccent:`#130C10`},{background:`#110D0F`,surface:`#1D181B`,text:`#F7EDF2`,muted:`#BCA2B0`,onAccent:`#130C10`}],now:{background:`#100E0F`,surface:`#1B191A`,text:`#F7EDF2`,muted:`#BCA2B0`,onAccent:`#130C10`}},{name:`Harbor`,mode:`light`,was:[{background:`#FAFBFD`,surface:`#ECF1F5`,text:`#0F1F33`,muted:`#4F5F74`,onAccent:`#FFFFFF`}],now:{background:`#FAFBFC`,surface:`#EEF1F3`,text:`#0F1F33`,muted:`#4F5F74`,onAccent:`#FFFFFF`}},{name:`Harbor`,mode:`dark`,was:[{background:`#090C11`,surface:`#12181E`,text:`#EAF1F8`,muted:`#98AABD`,onAccent:`#090C11`}],now:{background:`#0A0C0F`,surface:`#15181B`,text:`#EAF1F8`,muted:`#98AABD`,onAccent:`#090C11`}},{name:`Moss`,mode:`light`,was:[{background:`#F8FCF9`,surface:`#EAF3EC`,text:`#131C15`,muted:`#506254`,onAccent:`#FFFFFF`}],now:{background:`#F9FBFA`,surface:`#EDF2EE`,text:`#131C15`,muted:`#506254`,onAccent:`#FFFFFF`}},{name:`Moss`,mode:`dark`,was:[{background:`#0C0E09`,surface:`#171913`,text:`#EDF0E6`,muted:`#A0A893`,onAccent:`#0C0E09`}],now:{background:`#0C0E0B`,surface:`#171916`,text:`#EDF0E6`,muted:`#A0A893`,onAccent:`#0C0E09`}}]}));function qj(e,t=[]){let n=e.toLowerCase();return Yj.find(e=>e.name.toLowerCase()===n)??t.find(e=>e.name.toLowerCase()===n)}var Jj,Yj,Xj,Zj=n((()=>{Aj(),Jj=e=>({light:hj(e,`light`),dark:hj(e,`dark`)}),Yj=[{name:`Ink`,light:{background:`#FBFBFC`,surface:`#F0F0F2`,text:`#141633`,muted:`#565A78`,accent:`#5B4FE0`,onAccent:`#FFFFFF`},dark:{background:`#0C0C0F`,surface:`#17181B`,text:`#ECEDFB`,muted:`#9EA2C2`,accent:`#909AFE`,onAccent:`#0C0C0F`},radius:10,font:`system`,density:`comfortable`,charts:Jj(`Ink`)},{name:`Aurora`,light:{background:`#FAFCFC`,surface:`#EFF3F3`,text:`#0E2226`,muted:`#4E6468`,accent:`#07796F`,onAccent:`#FFFFFF`},dark:{background:`#070B0C`,surface:`#111517`,text:`#E6F4F5`,muted:`#93ABAF`,accent:`#2FD3B5`,onAccent:`#050B0D`},radius:12,font:`system`,density:`comfortable`,charts:Jj(`Aurora`)},{name:`Sand`,light:{background:`#F9F9F6`,surface:`#EFEEE9`,text:`#201D11`,muted:`#666046`,accent:`#A55200`,onAccent:`#FFFFFF`},dark:{background:`#13120F`,surface:`#1D1D1A`,text:`#F5F2E5`,muted:`#B0A98E`,accent:`#F99532`,onAccent:`#14120A`},radius:10,font:`system`,density:`comfortable`,charts:Jj(`Sand`)},{name:`Berry`,light:{background:`#FBFAFB`,surface:`#F1F0F1`,text:`#261725`,muted:`#695767`,accent:`#9F2294`,onAccent:`#FFFFFF`},dark:{background:`#100E0F`,surface:`#1B191A`,text:`#F7EDF2`,muted:`#BCA2B0`,accent:`#E375D6`,onAccent:`#130C10`},radius:14,font:`rounded`,density:`comfortable`,charts:Jj(`Berry`)},{name:`Harbor`,light:{background:`#FAFBFC`,surface:`#EEF1F3`,text:`#0F1F33`,muted:`#4F5F74`,accent:`#0066D6`,onAccent:`#FFFFFF`},dark:{background:`#0A0C0F`,surface:`#15181B`,text:`#EAF1F8`,muted:`#98AABD`,accent:`#52A9FE`,onAccent:`#090C11`},radius:10,font:`system`,density:`comfortable`,charts:Jj(`Classic`)},{name:`Moss`,light:{background:`#F9FBFA`,surface:`#EDF2EE`,text:`#131C15`,muted:`#506254`,accent:`#15803D`,onAccent:`#FFFFFF`},dark:{background:`#0C0E0B`,surface:`#171916`,text:`#EDF0E6`,muted:`#A0A893`,accent:`#7FD85E`,onAccent:`#0C0E09`},radius:12,font:`system`,density:`comfortable`,charts:Jj(`Moss`)},{name:`Mono`,light:{background:`#FFFFFF`,surface:`#EDEDED`,text:`#000000`,muted:`#2E2E2E`,accent:`#1F1F1F`,onAccent:`#FFFFFF`},dark:{background:`#000000`,surface:`#1A1A1A`,text:`#FFFFFF`,muted:`#D6D6D6`,accent:`#EDEDED`,onAccent:`#000000`},radius:6,font:`system`,density:`compact`,charts:{light:{...hj(`Classic`,`light`),sequential:`#3D3D3D`},dark:{...hj(`Classic`,`dark`),sequential:`#C2C2C2`}}},{name:`High contrast`,light:{background:`#FFFFFF`,surface:`#F2F2F2`,text:`#000000`,muted:`#262626`,accent:`#000000`,onAccent:`#FFFFFF`},dark:{background:`#000000`,surface:`#121212`,text:`#FFFFFF`,muted:`#E6E6E6`,accent:`#FFFFFF`,onAccent:`#000000`},radius:8,font:`system`,density:`comfortable`,charts:{light:{...hj(`Classic`,`light`),sequential:`#333333`},dark:{...hj(`Classic`,`dark`),sequential:`#CCCCCC`}},contrast:`more`}],Xj=Yj[0]}));function Qj(e){return[e.background,e.surface,e.text,e.accent,...e.series]}function $j(e,t,n,r){return n.map(n=>oj(e,t,r?oj(r,iM.dim,n):n))}function eM(e,t={}){let n=QA(e.background)<.5,r=t=>cj(cj(t,e.background,4.5),e.surface,4.5),i={};for(let[e,a]of Object.entries(aM))i[e]=r(t[e]??Cj[a][n?`dark`:`light`]);return i.comment=r(t.comment??e.muted),i.punctuation=r(t.punctuation??ej(e.text,e.background,.2)),i}function tM(e,t,n){let r=e;for(let e=0;e<3;e++)for(let e of n)r=cj(r,e,t);return r}function nM(e,t,n,r=`standard`){let i=r===`more`,{background:a,surface:o,text:s,accent:c}=e,l=QA(a)<.5,u=t??hj(`Classic`,l?`dark`:`light`),d=ej(a,c,l?.24:.12),f=e=>tM(e,4.5,[a,o]),p=ej(o,s,l?.08:.05),m=rj(o,s,l?.14:.09),h=[a,o,p],g=tM(e.muted,4.5,[...h,m]),_=ij(s,a,i?7:4.5,[...h,m]),v=ij(s,a,i?4.5:3,[a,o]),y=ij(a,s,4.5,[g]),b=(l?[.24,.18,.13,.08]:[.16,.12,.08,.05]).map(e=>{let t=rj(a,s,e);return $A(g,t)>=4.5?t:y}),x=ij(s,a,3,[a,o]),S=[x,...[.3,.5,.68,.82,.92].map(e=>rj(x,a,e))],C=[...u.series],w=Qj({background:a,surface:o,text:s,accent:c,series:C}),T=$j(o,iM.regular,w);return{...e,muted:g,surfaceRaised:p,border:i?ij(s,a,3,[a,o]):ej(a,s,l?.2:.14),borderStrong:i?ij(s,a,4.5,[a,o]):ej(a,s,l?.4:.32),accentSoft:d,accentText:tM(c,4.5,[a,o,d]),focus:cj(c,a,3),success:f(oM.success),warning:f(oM.warning),danger:f(oM.danger),info:f(oM.info),series:C,sequential:xj(u.sequential,o),diverging:Sj(u.diverging,o),code:eM(e,n),divider:i?rj(a,s,l?.4:.34):ej(a,s,l?.14:.09),accentHover:rj(c,s,.12),accentPressed:rj(c,s,.24),bg:[a,o,p,m],label:[s,g,_,v],fill:b,gray:S,glass:{tint:o,dim:a,edge:s,muted:tM(g,4.5,T),edgeAlpha:l?.12:.1,highlightAlpha:l?.1:.55,shadow:l?`0 10px 30px rgb(0 0 0 / 0.4)`:`0 10px 30px rgb(0 0 0 / 0.1)`}}}function rM(e){return{name:e.name,light:nM(e.light,e.charts?.light,e.code?.light,e.contrast),dark:nM(e.dark,e.charts?.dark,e.code?.dark,e.contrast),contrast:e.contrast??`standard`,radius:e.radius,fontFamily:sM[e.font],monoFamily:cM,scale:lM[e.density]}}var iM,aM,oM,sM,cM,lM,uM=n((()=>{Aj(),fj(),iM={regular:.8,thick:.88,clear:.65,dim:.35,blur:24,saturate:160,fallback:.96},aM={keyword:`purple`,string:`teal`,number:`orange`,literal:`pink`,property:`blue`,function:`amber`,type:`red`},oM={success:Cj.green.light,warning:Cj.amber.light,danger:Cj.red.light,info:Cj.blue.light},sM={system:`system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,rounded:`ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif`,serif:`ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif`,mono:`ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace`},cM=sM.mono,lM={comfortable:{unit:4,controlHeight:36,rowHeight:36,fontSize:14},compact:{unit:3,controlHeight:28,rowHeight:28,fontSize:13}}}));function dM(e){let t={"color-bg":e.background,"color-surface":e.surface,"color-surface-raised":e.surfaceRaised,"color-text":e.text,"color-muted":e.muted,"color-accent":e.accent,"color-on-accent":e.onAccent,"color-accent-soft":e.accentSoft,"color-accent-text":e.accentText,"color-border":e.border,"color-border-strong":e.borderStrong,"color-focus":e.focus,"color-success":e.success,"color-warning":e.warning,"color-danger":e.danger,"color-info":e.info};e.series.forEach((e,n)=>{t[`series-${n+1}`]=e}),e.sequential.forEach((e,n)=>{t[`sequential-${n+1}`]=e}),e.diverging.forEach((e,n)=>{t[`diverging-${n+1}`]=e});for(let[n,r]of Object.entries(e.code))t[`code-${n}`]=r;t[`color-divider`]=e.divider,t[`color-accent-hover`]=e.accentHover,t[`color-accent-pressed`]=e.accentPressed;let n=(e,n)=>n.forEach((n,r)=>t[`${e}-${r+1}`]=n);return n(`color-bg`,e.bg),n(`color-label`,e.label),n(`color-fill`,e.fill),n(`color-gray`,e.gray),t[`glass-tint`]=aj(e.glass.tint),t[`glass-dim-color`]=aj(e.glass.dim),t[`glass-edge-color`]=aj(e.glass.edge),t[`glass-edge-alpha`]=String(e.glass.edgeAlpha),t[`glass-highlight-alpha`]=String(e.glass.highlightAlpha),t[`glass-muted`]=e.glass.muted,t[`glass-shadow`]=e.glass.shadow,t}function fM(){let e=_M;return{"glass-alpha-regular":String(iM.regular),"glass-alpha-thick":String(iM.thick),"glass-alpha-clear":String(iM.clear),"glass-alpha-dim":String(iM.dim),"glass-blur":`${iM.blur}px`,"glass-saturate":`${iM.saturate}%`,"glass-regular":`rgb(var(${e}-glass-tint) / var(${e}-glass-alpha-regular))`,"glass-thick":`rgb(var(${e}-glass-tint) / var(${e}-glass-alpha-thick))`,"glass-clear":`rgb(var(${e}-glass-tint) / var(${e}-glass-alpha-clear))`,"glass-dim":`rgb(var(${e}-glass-dim-color) / var(${e}-glass-alpha-dim))`,"glass-edge":`rgb(var(${e}-glass-edge-color) / var(${e}-glass-edge-alpha))`,"glass-highlight":`rgb(255 255 255 / var(${e}-glass-highlight-alpha))`,"glass-filter":`blur(var(${e}-glass-blur)) saturate(var(${e}-glass-saturate))`}}function pM(e){let t=yM,n=String(iM.fallback);return[`@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {\n${hM(e,{"glass-alpha-regular":n,"glass-alpha-thick":n,"glass-alpha-clear":n})}\n}`,`@media (prefers-reduced-transparency: reduce) {\n${hM(e,t)}\n}`,`@media (prefers-contrast: more) {\n${hM(e,bM)}\n}`,`@media (forced-colors: active) {\n${hM(e,{...t,"glass-shadow":`none`})}\n}`]}function mM(e){let t=e.scale.unit;return{radius:`${e.radius}px`,"radius-sm":`${Math.round(e.radius/2)}px`,"radius-lg":`${Math.round(e.radius*1.5)}px`,font:e.fontFamily,"font-mono":e.monoFamily,"font-size":`${e.scale.fontSize}px`,"font-size-sm":`${e.scale.fontSize-2}px`,"font-size-lg":`${e.scale.fontSize+4}px`,"font-size-xs":`${e.scale.fontSize-3}px`,"font-size-title-3":`${e.scale.fontSize+3}px`,"font-size-title-2":`${e.scale.fontSize+6}px`,"font-size-title-1":`${e.scale.fontSize+10}px`,"font-size-large-title":`${e.scale.fontSize+18}px`,"font-weight-regular":`400`,"font-weight-medium":`500`,"font-weight-semibold":`600`,"font-weight-bold":`700`,"line-height":`1.45`,"line-height-tight":`1.2`,"letter-spacing-title":`-0.01em`,"duration-fast":`${vM.fast}ms`,duration:`${vM.base}ms`,"duration-slow":`${vM.slow}ms`,ease:vM.ease,"ease-out":vM.easeOut,"ease-spring":vM.spring,"duration-springy":`${vM.springy}ms`,"ease-gummy":vM.gummyFallback,"press-scale":String(vM.pressScale),"radius-xl":`${e.radius*2}px`,"radius-full":`999px`,"space-1":`${t}px`,"space-2":`${t*2}px`,"space-3":`${t*3}px`,"space-4":`${t*4}px`,"space-6":`${t*6}px`,"space-8":`${t*8}px`,"control-height":`${e.scale.controlHeight}px`,"control-size":`${e.scale.controlHeight-4}px`,"row-height":`${e.scale.rowHeight}px`,"target-min":`24px`}}function hM(e,t,n=``){let r=Object.entries(t).map(([e,t])=>` ${_M}-${e}: ${t};`);return n&&r.push(` ${n}`),`${e} {\n${r.join(`
|
|
19
|
-
`)}\n}`}function
|
|
18
|
+
`);return{line:n.length,column:n.at(-1).length+1}}function SA(e,t={}){return e instanceof R?e:e instanceof aw?bA(L.InvalidArgument,e.code,e.message,{line:e.line,column:e.column}):e instanceof iw?bA(e.code===`CANCELLED`?L.Canceled:e.code===`UNSUPPORTED`?L.Unimplemented:e.code===`UNKNOWN_TABLE`?L.NotFound:L.InvalidArgument,e.code,e.message,{engineCode:e.engineCode,...t}):(console.error(`[surfaces] internal error:`,e),new R(`The server hit an unexpected error.`,L.Internal))}async function CA(e){await ww();let t=new Map(e.sources.map(e=>[e.id,e])),n=e.defaultBatchRows??4096,r=e.maxResultRows??1e6,i=new Map,a=e.storedResults===!1?void 0:yA(e.storedResults),o=e=>{let n=t.get(e)??(e===``&&t.size===1?[...t.values()][0]:void 0);if(!n)throw new R(`Unknown source: ${e||`(none given)`}`,L.NotFound);return n},s=e=>{try{return o(e).engine}catch{return}},c=e=>ym(Dx,{id:e.id,displayName:e.displayName??e.id,kind:e.kind??jx.DUCKDB,engine:e.engine.kind,dialect:e.engine.dialect,readOnly:!0,connections:e.engine.connections??[],capabilities:{...e.engine.capabilities,storedResults:a!==void 0&&e.engine.store!==void 0,maxBatchRows:65536,maxResultRows:BigInt(r)}}),l=e=>e??ym(Xb),u=e=>ym($b,{part:e}),d=async e=>{try{return await e()}catch(e){throw SA(e)}},f=async(e,t,n)=>{if(!t||!(e instanceof iw)||e.code===`CANCELLED`||e.code===`TIMEOUT`)return{};let r=uw(n.baseSql);try{await t.explain(r,n.parameters.map(e=>e.kind.value))}catch(e){if(e instanceof iw&&e.position!==void 0)return xA(n.baseSql,Math.max(0,n.baseSql.indexOf(r))+e.position)}return{}},p=async(e,t,n)=>{let r=l(e.query);try{return await m(e,r,t,n)}catch(i){if(!(i instanceof iw)||i.code!==`UNKNOWN_COLUMN`||r.filters.length===0)throw i;let{engine:a}=o(e.sourceId),s=eT(r,a.dialect),c=await a.execute(s.sql,s.params,{signal:n,timeTravel:e.timeTravel}).catch(()=>void 0);if(!c)throw i;let l=c.schema.fields.map(e=>e.name);await c.batches[Symbol.asyncIterator]().return?.();let u=tT(r,l);if(u.notices.length===0)throw i;let d=await m(e,u.query,t,n);return{...d,notices:[...u.notices,...d.notices]}}},m=async(e,t,n,r)=>{let{id:i,engine:s}=o(e.sourceId),c=n(t,s.dialect),l=await a?.get(i,s,t,e.timeTravel,e.notBefore);if(l){let e=n(vA(t,l),s.dialect);try{return{result:await s.execute(e.sql,e.params,{signal:r}),held:l,sql:c.sql,mode:c.mode,notices:c.notices.filter(e=>e.code!==`UNSTABLE_PAGE_ORDER`)}}catch(e){if(!(e instanceof iw)||e.code!==`UNKNOWN_TABLE`)throw e;a?.forget(l.key),l=void 0}}return{result:await s.execute(c.sql,c.params,{signal:r,timeTravel:e.timeTravel}),held:l,sql:c.sql,mode:c.mode,notices:c.notices}},h=e=>{e.service(fx,{async*execute(e,t){let a=Date.now(),o=new AbortController;t.signal.addEventListener(`abort`,()=>o.abort(),{once:!0}),e.queryId&&i.set(e.queryId,o);try{let{result:t,held:i,sql:s,mode:c,notices:l}=await p(e,$w,o.signal);yield u({case:`header`,value:{arrowSchema:Sp(t.schema),executedSql:s,rewriteMode:c,notices:l,queryId:e.queryId,stored:i?{createdAt:i.createdAt,rowCount:BigInt(i.rowCount)}:void 0,columns:t.schema.fields.map(e=>{let t=!P.isList(e.type)&&!P.isStruct(e.type)&&!P.isMap(e.type);return{name:e.name,nativeType:String(e.type),sortable:t,filterable:t}})}});let d=Math.min(e.batchRows||n,65536),f=0,m=!1,h=[],g=0,_=function*(e){for(;g>=d||e&&g>0;){let e=Math.min(d,g),t=[];for(;e>0;){let n=h[0];n.numRows<=e?(t.push(n),h.shift(),e-=n.numRows,g-=n.numRows):(t.push(n.slice(0,e)),h[0]=n.slice(e),g-=e,e=0)}for(let e of t)yield u({case:`batch`,value:{arrowBatch:xp(e).batch,rowCount:BigInt(e.numRows)}})}};for await(let e of t.batches){let t=r-f,n=e.numRows>t?e.slice(0,t):e;if(n.numRows>0&&(h.push(n),g+=n.numRows,f+=n.numRows),yield*_(!1),e.numRows>t){m=!0,o.abort();break}}yield*_(!0),h=[],yield u({case:`footer`,value:{totalRowsReturned:BigInt(f),nextCursor:``,truncated:m,elapsedMs:BigInt(Date.now()-a)}})}catch(t){throw SA(t,await f(t,s(e.sourceId),l(e.query)))}finally{e.queryId&&i.delete(e.queryId)}},async cancel(e){let t=i.get(e.queryId);return t?.abort(),{cancelled:t!==void 0}},async explain(e){let{engine:t}=o(e.sourceId),n=l(e.query);try{let e=$w(n,t.dialect);return{...await t.explain(e.sql,e.params),executedSql:e.sql}}catch(e){throw SA(e,await f(e,t,n))}},async count(e){let t=l(e.query);try{let{id:n,engine:r}=o(e.sourceId),i=t.groupBy.length>0||t.aggregates.length>0||t.buckets.length>0;if(t.filters.length===0&&!i){let i=await a?.get(n,r,t,e.timeTravel,e.notBefore);if(i)return{rowCount:BigInt(i.rowCount),estimated:!1}}let{result:s}=await p(e,oT),c=0n;for await(let e of s.batches)e.numRows>0&&(c=BigInt(e.getChildAt(0)?.get(0)??0));return{rowCount:c,estimated:!1}}catch(n){throw SA(n,await f(n,s(e.sourceId),t))}}}),e.service(wx,{listCatalogs:e=>d(async()=>({catalogs:await o(e.sourceId).engine.listCatalogs()})),listSchemas:e=>d(async()=>({schemas:await o(e.sourceId).engine.listSchemas(e.catalog)})),listTables:e=>d(async()=>{let{engine:t}=o(e.sourceId),n=Math.max(0,Number(e.pageToken||0)||0);if(t.pagesTables&&e.pageSize>0){let r=await t.listTables({catalog:e.catalog,schema:e.schema,search:e.search,limit:e.pageSize+1,offset:n});return{tables:r.slice(0,e.pageSize),nextPageToken:r.length>e.pageSize?String(n+e.pageSize):``}}let r=await t.listTables({catalog:e.catalog,schema:e.schema,search:e.search}),i=e.pageSize>0?n+e.pageSize:r.length;return{tables:r.slice(n,i),nextPageToken:i<r.length?String(i):``}}),describeTable:e=>d(async()=>{if(!e.ref)throw new R(`A table is required.`,L.InvalidArgument);let{engine:t}=o(e.sourceId),n=e.ref;try{return{table:await t.describeTable(n,e.includeStats)}}catch(r){let i=n.table.split(`.`);if(!(r instanceof iw)||r.code!==`UNKNOWN_TABLE`||n.schema||n.catalog||i.length<2||i.length>3||i.some(e=>!e))throw r;let a=i.length===3?{catalog:i[0],schema:i[1],table:i[2]}:{catalog:``,schema:i[0],table:i[1]};return{table:await t.describeTable({...n,...a},e.includeStats)}}}),listSnapshots:e=>d(async()=>{if(!e.ref)throw new R(`A table is required.`,L.InvalidArgument);return{snapshots:await o(e.sourceId).engine.listSnapshots(e.ref)}})}),e.service(Fx,{listSources:async()=>({sources:[...t.values()].map(c)}),getSource:async e=>({source:c(o(e.id))}),registerSource:async()=>{throw new R(`Sources are set in the server's configuration.`,L.Unimplemented)},removeSource:async()=>{throw new R(`Sources are set in the server's configuration.`,L.Unimplemented)},listFiles:e=>d(async()=>{let{engine:t}=o(e.sourceId);if(!t.listFiles)throw new R(`This source has no storage to list.`,L.Unimplemented);let{entries:n,truncated:r}=await t.listFiles(e.path),i=Math.min(Math.max(e.pageSize||500,1),2e3),a=Math.max(0,Number.parseInt(e.pageToken||`0`,10)||0),s=a+i;return{entries:n.slice(a,s),nextPageToken:s<n.length?String(s):``,truncated:r??!1}}),testSource:e=>d(async()=>{if(e.target.case!==`id`)throw new R(`Only configured sources can be tested.`,L.Unimplemented);let t=Date.now(),{engine:n}=o(e.target.value),r=``,i;try{r=await n.version()}catch(e){i=e instanceof Error?e.message:String(e)}let a=await n.check?.().catch(()=>void 0)??[],s=a.filter(e=>!e.ok);return{ok:!i&&s.length===0,message:i&&s.length===0?`The source could not be reached: ${i}`:s.length===0?`Connected`:`${s.length} of ${a.length} could not be reached`,elapsedMs:BigInt(Date.now()-t),engineVersion:r,checks:a.map(e=>({...e,elapsedMs:BigInt(e.elapsedMs)}))}})})},g=_A({transport:cA(h)});return[...t.values()].some(e=>e.engine.listFiles)||delete g.listFiles,{routes:h,dataSource:g,engineOf:s,clearResults:()=>a?.clear(),async close(){for(let e of i.values())e.abort();await a?.close()}}}vS();var wA=/sql|query|statement/i;function TA(e,t,n){let r=DA();return{server:t,async list(){let r=(await e.listTools(t)).servers?.find(e=>e.server===t)?.tools??[],i=[];for(let{name:a}of r){if(!(n===void 0?wA.test(a):a===n)){i.push({name:a});continue}let r=await e.describeTool(t,a).then(e=>e.inputSchema,()=>void 0);i.push({name:a,inputSchema:r})}return i},call(n,i,{signal:a}){return r(async()=>{try{return await e.callTool(t,n,i,{signal:a})}catch(r){let{retryable:o,retryAfterMs:s}=r??{};if(o!==!0||a?.aborted)throw OA(r,t);await EA(Math.min(s??1500+Math.random()*1500,6e4));try{return await e.callTool(t,n,i,{signal:a})}catch(e){throw OA(e,t)}}})}}}var EA=e=>new Promise(t=>setTimeout(t,e));function DA(e=2){let t=0,n=!1,r=!1,i=[],a=()=>{let a=n?e:+!r;for(;t<a&&i.length>0;)t++,n||(r=!0),i.shift()()};return e=>new Promise((o,s)=>{i.push(()=>{let i=!n;e().then(o,s).finally(()=>{t--,i&&(n=!0,r=!1),a()})}),a()})}function OA(e,t){let{code:n,message:r}=e??{};if(n===`tool_error`||n===void 0)return Error(r??String(e));let i={needs_reauth:`Reconnect ${t} in Claude's settings, under Connectors, then open this page again.`,server_not_connected:`This page reads from ${t}. Add it in Claude's settings, under Connectors, then open this page again.`,not_granted:`This page was not allowed to use ${t}. Allow it in the page's permissions to see the data.`,not_in_manifest:`This page was not published with permission to use ${t}.`,rate_limited:`${t} is being asked too often. Wait a moment and try again.`,server_unavailable:`${t} did not answer. Try again in a moment.`};return new iw(n===`server_unavailable`?`TIMEOUT`:`ENGINE`,i[n]??`${t} could not be used from this page (${n}).`)}async function kA(e,t){return(await CA({sources:await Promise.all(t.map(async t=>{if(t.id===`page`)throw Error(`A connector source cannot be called "page": that is the page's own rows.`);let n=TA(e,t.server,t.tool),r=await mE(e=>OE(async()=>n,{tool:t.tool,argument:t.argument,arguments:{...e,...t.arguments}}),{dialect:t.dialect,address:t.server,database:t.database,databases:t.databases});return{id:t.id,displayName:t.displayName??t.server,kind:AA[t.dialect],engine:r}})),storedResults:!1})).dataSource}var AA={postgres:jx.POSTGRES,mysql:jx.MYSQL,duckdb:jx.DUCKDB,teradata:jx.TERADATA};function jA(e,t){let n={...e};for(let r of Object.keys(e))typeof e[r]==`function`&&r!==`listSources`&&(n[r]=(n,i)=>{let a=n?.sourceId===`page`?t():e,o=a[r];if(!o)throw Error(`The page's own rows cannot answer this.`);return o.call(a,n,i)});return n}function MA(e){LA=Intl.getCanonicalLocales(e.replaceAll(`_`,`-`))[0]??`en-US`}function NA(e={}){let t=`${LA}|${JSON.stringify(e)}`,n=RA.get(t);return n||(n=new Intl.NumberFormat(LA,e),RA.set(t,n)),n}function PA(e={}){let t=`${LA}|${JSON.stringify(e)}`,n=zA.get(t);return n||(n=new Intl.DateTimeFormat(LA,e),zA.set(t,n)),n}function FA(e){let t={...VA};for(let[n,r]of Object.entries(e))typeof r==`string`&&n in BA&&(t[n]=r);VA=t}function IA(){VA={...BA}}function z(e,t){let n=VA[e];return t?n.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e):n}var LA,RA,zA,BA,VA,HA=n((()=>{LA=`en-US`,RA=new Map,zA=new Map,BA={"cell.null":`null`,"cell.true":`true`,"cell.false":`false`,"grid.label":`Query result`,"grid.sortAscending":`Sort ascending`,"grid.sortDescending":`Sort descending`,"grid.clearSorting":`Clear sorting`,"grid.moveLeft":`Move left`,"grid.moveRight":`Move right`,"grid.hideColumn":`Hide column`,"grid.showAllColumns":`Show all columns`,"grid.showAllColumnsHidden":`Show all columns ({count} hidden)`,"grid.resetWidth":`Reset width`,"grid.resetWidthHint":`Double-click edge`,"grid.resetLayout":`Reset column layout`,"grid.copyColumnName":`Copy column name`,"grid.sqlCountValues":`SQL: count each value`,"grid.sqlRange":`SQL: range and missing values`,"grid.copyValue":`Copy value`,"grid.copyRowJson":`Copy row as JSON`,"grid.filterToValue":`Filter to this value`,"grid.leaveValueOut":`Leave this value out`,"grid.copied":`Copied {what}.`,"grid.copiedCell":`the cell`,"grid.copiedRow":`the row`,"grid.copiedColumnName":`the column name`,"grid.copiedSql":`the SQL`,"grid.copyFailed":`Could not copy: the browser refused access to the clipboard.`,"grid.movedLeft":`Moved {name} left.`,"grid.movedRight":`Moved {name} right.`,"grid.moved":`Moved {name}.`,"grid.columnMenu":`{name} column`,"grid.cellMenu":`{name} cell`,"grid.activeCellMenu":`Cell`,"grid.failed":`Query failed`,"grid.loading":`Loading…`,"grid.rows":`{count} rows`,"grid.rowsOne":`{count} row`,"grid.noRows":`No rows match.`,"grid.showHidden":`Show {count} hidden columns`,"grid.showHiddenOne":`Show {count} hidden column`,"grid.elapsed":`{ms} ms`,"grid.asOf":`As of {time}`,"grid.runAgain":`Run again`,"grid.previous":`Previous`,"grid.next":`Next`,"grid.page":`Page {page} of {pages}`,"pivot.label":`Pivot table`,"pivot.loading":`Loading…`,"pivot.choose":`Choose rows or columns and a measure.`,"pivot.empty":`No rows match.`,"pivot.total":`Total`,"pivot.all":`All`,"pivot.none":`(none)`,"pivot.truncated":`This pivot has more than {limit} cells, so some are missing. Add a filter or choose columns with fewer values.`,"pivot.hiddenColumns":`Showing the first {shown} of {total} column values.`,"chart.empty":`No data to chart.`,"chart.missingX":`Rows with no {x} are not drawn{detail}.`,"chart.description":`{type} chart of {measures} by {x}`,"chart.coloursRepeat":`{count} series share {colours} colours, so some repeat. Filter, or split by a column with fewer values.`,"chart.advice":`{message} Better: {instead}`,"chart.sampleNote":`Showing a random sample of {count} rows.`,"chart.firstNote":`Showing the first {count} points.`,"chart.largestNote":`Showing the largest {count} points.`,"rows.loading":`Loading…`,"rows.empty":`Nothing to show.`,"rows.more":`Show more`,"rows.some":`Showing the first {count}.`,"rows.full":`Showing the first {count}. Filter to find others.`,"metric.loading":`…`,"metric.none":`–`,"sparkline.summary":`{label}: {now} now, from {first}; low {low}, high {high} over {count} {grain}s.`,"sparkline.empty":`{label}: no data.`,"bullet.loading":`{label}: loading.`,"bullet.empty":`{label}: no data.`,"bullet.reading":`{label}: {value}{band}{target}.`,"bullet.targetMet":`; target {target}, met`,"bullet.targetNotMet":`; target {target}, not met`,"bullet.target":`Target {target}`,"filter.active":`Active filters`,"filter.remove":`Remove filter {filter}`,"filter.form":`Add a filter`,"filter.column":`Column`,"filter.comparison":`Comparison`,"filter.value":`Value`,"filter.typeOrPick":`Type or pick a value`,"filter.add":`Add filter`,"filter.quickRange":`Quick date range`,"filter.quickRangeChoose":`Quick range…`,"filter.range7d":`Last 7 days`,"filter.range30d":`Last 30 days`,"filter.range90d":`Last 90 days`,"filter.range12m":`Last 12 months`,"filter.rangeMonth":`This month`,"filter.rangeYear":`This year`,"filter.isEmpty":`is empty`,"filter.isNotEmpty":`is not empty`,"filter.contains":`contains`,"filter.is":`is`,"filter.isNot":`is not`,"filter.startsWith":`starts with`,"filter.endsWith":`ends with`,"filter.enterWholeNumber":`Enter a whole number.`,"filter.enterNumber":`Enter a number.`,"filter.enterTrueFalse":`Enter true or false.`,"filter.enterDate":`Enter a date like 2026-01-31.`,"filter.enterValue":`Enter a value.`,"result.views":`Result view`,"result.tabTable":`Table`,"result.tabChart":`Chart`,"result.tabPivot":`Pivot`,"result.stopExport":`Stop export`,"result.downloadCsv":`Download CSV`,"result.copySql":`Copy SQL`,"result.cancelQuery":`Cancel query`,"result.format":`Format`,"result.formatColumn":`Column to format`,"result.chooseColumn":`Choose a column…`,"result.howToShow":`How to show {column}`,"result.asItIs":`As it is`,"result.formatNumber":`Number`,"result.formatCompact":`Short number (1.2M)`,"result.formatCurrency":`Currency`,"result.formatPercent":`Percent`,"result.formatText":`Plain text`,"result.formatDate":`Date only`,"result.formatDatetime":`Date and time`,"result.preparing":`Preparing the file…`,"result.rowsSoFar":`{count} rows so far…`,"result.saved":`Saved {count} rows.`,"result.savedTruncated":`Saved {count} rows. The server's row limit was reached, so the file is not the whole result.`,"result.exportStopped":`Export stopped.`,"result.sqlCopied":`SQL copied.`,"result.copyNotAllowed":`Copying is not allowed here.`,"result.sqlSent":`SQL sent to the engine`,"result.plan":`How the engine will run it`,"result.stored":`The query ran once and its result was kept, so sorting, filtering and paging read the kept rows instead of running it again.`,"result.chooseChart":`Choose columns to chart.`,"result.choosePivot":`Choose what goes in the rows and the values.`,"result.chartType":`Type`,"result.slices":`Slices`,"result.xAxis":`X axis`,"result.yAxis":`Y axis`,"result.every":`Every`,"result.bins":`Bins`,"result.binsEach":`each value`,"result.binsAbout":`about {count}`,"result.splitBy":`Split by`,"result.nothing":`nothing`,"result.legend":`Legend`,"result.automatic":`automatic`,"result.legendHidden":`hidden`,"result.stack":`Stack`,"result.plotEachRow":`Plot each row`,"result.series":`Series {number}`,"result.of":`of`,"result.drawnAs":`Drawn as`,"result.drawnAsChart":`chart type ({type})`,"result.scale":`Scale`,"result.leftAxis":`left axis`,"result.rightAxis":`right axis`,"result.removeSeries":`Remove series {number}`,"result.remove":`Remove`,"result.addSeries":`Add series`,"result.rows":`Rows`,"result.columns":`Columns`,"result.none":`none`,"result.datesBy":`Dates by`,"result.values":`Values`,"result.sum":`sum`,"result.avg":`average`,"result.median":`median`,"result.count":`count of rows`,"result.countDistinct":`distinct count`,"result.min":`minimum`,"result.max":`maximum`,"result.stddev":`standard deviation`,"result.p90":`90th percentile`,"form.submit":`Submit`,"form.choose":`Choose…`,"form.required":`(required)`,"form.needsAttention":`Nothing was sent. {count} fields need attention.`,"form.needsAttentionOne":`Nothing was sent. One field needs attention.`,"form.sent":`Sent.`,"form.notSaved":`The backend did not save it.`,"form.saved":`Saved.`,"form.couldNotSend":`Could not send: {error}`,"form.sending":`Sending…`,"form.connected":`Saved by the backend this page is connected to.`,"form.notConnected":`Not connected to a backend: what you submit goes only to this page.`,"flow.done":`Done`,"flow.current":`In progress`,"flow.waiting":`Waiting for you`,"flow.pending":`Not started`,"flow.failed":`Failed`,"flow.skipped":`Skipped`,"flow.count":`{done} of {total} done`,"plan.riskLow":`Low risk`,"plan.riskMedium":`Check this`,"plan.riskHigh":`Changes or removes data`,"plan.proposedBy":`Proposed by {who}. Nothing runs until you approve.`,"plan.required":`Required`,"plan.affects":`Affects: {what}`,"plan.whatItWouldRun":`What it would run`,"plan.approved":`Approved {count} of {total} steps.`,"plan.rejected":`Rejected. Nothing was run.`,"plan.decisionNote":` Note: {note}`,"plan.noteLabel":`Note for the record (optional)`,"plan.approve":`Approve {count} steps`,"plan.approveOne":`Approve {count} step`,"plan.reject":`Reject`,"receipt.done":`Done`,"receipt.partial":`Partly done`,"receipt.failed":`Failed`,"receipt.ran":`Ran`,"receipt.by":`by {who}`,"receipt.approved":`Approved`,"receipt.noApproval":`No one approved this.`,"receipt.whatChanged":`What changed`,"receipt.what":`What`,"receipt.before":`Before`,"receipt.after":`After`,"receipt.whatRan":`What ran`,"receipt.cannotUndo":`This cannot be undone from here.`,"receipt.undoClosed":`It could be undone until {time}; that time has passed.`,"receipt.undoUntil":`Can be undone until {time}.`,"receipt.undoRequested":`Undo requested. You will be asked to confirm it.`,"table.selectPage":`Select every row on this page`,"table.selectRow":`Select {name}`,"table.empty":`Nothing to show.`,"table.loading":`Loading…`,"table.rowControls":`{name} actions`,"table.actions":`Actions`,"table.select":`Select`,"selection.label":`With the selected rows`,"selection.count":`{count} selected`,"selection.pageSelected":`All {count} on this page are selected.`,"selection.selectAllMatching":`Select all {total} that match`,"selection.allMatching":`All {total} that match are selected.`,"selection.onlyPage":`Only this page`,"selection.clear":`Clear`,"pages.label":`Pages`,"pages.range":`{from}–{to} of {total}`,"pages.previous":`Previous`,"pages.next":`Next`,"confirm.confirm":`Confirm`,"confirm.cancel":`Cancel`,"combobox.loading":`Looking…`,"combobox.none":`Nothing matches.`,"combobox.count":`{count} suggestions`,"combobox.countOne":`1 suggestion`,"report.untitled":`Untitled`,"report.untitledReport":`Untitled report`,"report.title":`Report title`,"report.tileTitle":`Title of {title}`,"report.tileControls":`{title} controls`,"report.mode":`Mode`,"report.build":`Build`,"report.view":`View`,"report.builder":`Build a view`,"report.body":`Report`,"report.changing":`Changing “{title}”.`,"report.leaveAsItWas":`Leave it as it was`,"report.leftAsItWas":`Left as it was.`,"report.updateView":`Update view`,"report.addToReport":`Add to report`,"report.maxViews":`A report holds at most {max} views.`,"report.needMeasure":`Put a metric on “Measure” first: a view needs something to measure.`,"report.emptyBuild":`Nothing on the report yet. Make a view above and press “Add to report”; each one you add appears here, and they all follow the same filters.`,"report.emptyView":`This report has no views yet. Switch to Build to make one.`},VA={...BA}})),UA=r((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),WA=r(((e,t)=>{t.exports=UA()}));function GA({locale:e,labels:t,children:n}){return MA(e??`en-US`),IA(),t&&FA(t),(0,KA.jsx)(KA.Fragment,{children:n})}var KA,qA=n((()=>{KA=WA(),HA()}));function JA(e){return typeof e==`string`&&dj.test(e)}function YA(e){if(!JA(e))throw Error(`Not a hex colour: ${String(e)}`);let t=e.slice(1);return`#${(t.length===3?t.split(``).map(e=>e+e).join(``):t).toUpperCase()}`}function XA(e){let t=Number.parseInt(YA(e).slice(1),16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function ZA({r:e,g:t,b:n}){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`.toUpperCase()}function QA({r:e,g:t,b:n}){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2,l=o-s;if(l===0)return{h:0,s:0,l:c};let u=l/(1-Math.abs(2*c-1)),d;return d=o===r?(i-a)/l%6:o===i?(a-r)/l+2:(r-i)/l+4,{h:(d*60+360)%360,s:u,l:c}}function $A({h:e,s:t,l:n}){let r=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=r*(1-Math.abs(i%2-1)),o=n-r/2,[s,c,l]=i<1?[r,a,0]:i<2?[a,r,0]:i<3?[0,r,a]:i<4?[0,a,r]:i<5?[a,0,r]:[r,0,a];return{r:(s+o)*255,g:(c+o)*255,b:(l+o)*255}}function ej(e){let{r:t,g:n,b:r}=XA(e),i=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*i(t)+.7152*i(n)+.0722*i(r)}function tj(e,t){let n=ej(e),r=ej(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function nj(e,t,n){let r=XA(e),i=XA(t),a=Math.max(0,Math.min(1,n));return ZA({r:r.r+(i.r-r.r)*a,g:r.g+(i.g-r.g)*a,b:r.b+(i.b-r.b)*a})}function rj(e){let{r:t,g:n,b:r}=XA(e),[i,a,o]=[fj(t),fj(n),fj(r)],s=Math.cbrt(.4122214708*i+.5363325363*a+.0514459929*o),c=Math.cbrt(.2119034982*i+.6806995451*a+.1073969566*o),l=Math.cbrt(.0883024619*i+.2817188376*a+.6299787005*o);return[.2104542553*s+.793617785*c-.0040720468*l,1.9779984951*s-2.428592205*c+.4505937099*l,.0259040371*s+.7827717662*c-.808675766*l]}function ij([e,t,n]){let r=(e+.3963377774*t+.2158037573*n)**3,i=(e-.1055613458*t-.0638541728*n)**3,a=(e-.0894841775*t-1.291485548*n)**3;return ZA({r:pj(4.0767416621*r-3.3077115913*i+.2309699292*a),g:pj(-1.2684380046*r+2.6097574011*i-.3413193965*a),b:pj(-.0041960863*r-.7034186147*i+1.707614701*a)})}function aj(e,t,n){let r=rj(e),i=rj(t),a=Math.max(0,Math.min(1,n));return ij([r[0]+(i[0]-r[0])*a,r[1]+(i[1]-r[1])*a,r[2]+(i[2]-r[2])*a])}function oj(e,t,n,r){let i=e=>r.every(t=>tj(e,t)>=n);if(!i(e))return YA(e);let a=0,o=1;for(let n=0;n<24;n++){let n=(a+o)/2;i(aj(e,t,n))?a=n:o=n}return aj(e,t,a)}function sj(e){let{r:t,g:n,b:r}=XA(e);return`${t} ${n} ${r}`}function cj(e,t,n){return nj(n,e,t)}function lj(e){return tj(e,`#FFFFFF`)>=tj(e,`#000000`)?`#FFFFFF`:`#000000`}function uj(e,t,n){if(tj(e,t)>=n)return YA(e);let r=QA(XA(e)),i=ej(t)<.5,a=YA(e);for(let e=1;e<=50;e++){let o=i?r.l+(1-r.l)*e/50:r.l-r.l*e/50;if(a=ZA($A({...r,l:o})),tj(a,t)>=n)break}return a}var dj,fj,pj,mj=n((()=>{dj=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,fj=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},pj=e=>255*(e<=.0031308?12.92*e:1.055*Math.max(0,e)**(1/2.4)-.055)}));function hj(e,t){let n=e.map(e=>e.toUpperCase()).join(`,`),r=[Tj,...Ej];for(let e of Object.keys(Dj)){let i=[Dj[e],...Oj[e]??[]];for(let a of r)for(let r of i)if(r.map(e=>(a[e]??Tj[e])[t]).join(`,`).toUpperCase()===n)return _j(e,t).series}return e}function gj(e,t){for(let n of Ej)for(let[r,i]of Object.entries(n))if(i[t].toUpperCase()===e.toUpperCase()&&Tj[r][t]!==i[t])return Tj[r][t];return e}function _j(e,t){let n=Dj[e],r=n[0]===`blue`||n[0]===`indigo`?n[0]:`blue`;return{series:n.map(e=>Tj[e][t]),sequential:Tj[n[0]][t],diverging:[Tj.red[t],Tj[r][t]]}}function vj(e,t,n){if(e===void 0)return t;if(typeof e!=`object`||!e)throw Error(`${n} must be an object`);let r=e,i=(e,t)=>{if(!JA(e))throw Error(`${t} must be a hex colour like #1A2B3C`);return YA(e)},a=t.series;if(r.series!==void 0){if(!Array.isArray(r.series)||r.series.length<2||r.series.length>12)throw Error(`${n}.series must be a list of 2 to 12 colours`);a=r.series.map((e,t)=>i(e,`${n}.series[${t}]`))}let o=t.diverging;if(r.diverging!==void 0){if(!Array.isArray(r.diverging)||r.diverging.length!==2)throw Error(`${n}.diverging must be two colours`);o=[i(r.diverging[0],`${n}.diverging[0]`),i(r.diverging[1],`${n}.diverging[1]`)]}return{series:a,sequential:r.sequential===void 0?t.sequential:i(r.sequential,`${n}.sequential`),diverging:o}}function yj([e,t,n]){let r=Math.cbrt(.4122214708*e+.5363325363*t+.0514459929*n),i=Math.cbrt(.2119034982*e+.6806995451*t+.1073969566*n),a=Math.cbrt(.0883024619*e+.2817188376*t+.6299787005*n);return[.2104542553*r+.793617785*i-.0040720468*a,1.9779984951*r-2.428592205*i+.4505937099*a,.0259040371*r+.7827717662*i-.808675766*a]}function bj(e,t){let{r:n,g:r,b:i}=XA(e),a=[Aj(n),Aj(r),Aj(i)];return t?jj[t].map(e=>Math.min(1,Math.max(0,e[0]*a[0]+e[1]*a[1]+e[2]*a[2]))):a}function xj(e,t,n){let[r,i,a]=yj(bj(e,n)),[o,s,c]=yj(bj(t,n));return 100*Math.hypot(r-o,i-s,a-c)}function Sj(e,t){let n=[];for(let t=0;t+1<e.length;t++){let[r,i]=[e[t],e[t+1]],a=[t+1,t+2],o=xj(r,i),s=Math.min(xj(r,i,`protan`),xj(r,i,`deutan`));o<15?n.push({severity:`error`,slots:a,message:`Colours ${a[0]} and ${a[1]} are too alike to tell apart.`}):s<6?n.push({severity:`error`,slots:a,message:`Colours ${a[0]} and ${a[1]} look the same with red-green colour blindness.`}):s<8&&n.push({severity:`warning`,slots:a,message:`Colours ${a[0]} and ${a[1]} are close with red-green colour blindness; label the series.`})}for(let t=0;t<Math.min(e.length,5);t++)for(let r=t+2;r<Math.min(e.length,5);r++){let[i,a]=[e[t],e[r]];xj(i,a)<13?n.push({severity:`error`,slots:[t+1,r+1],message:`Colours ${t+1} and ${r+1} are too alike to tell apart in a legend.`}):Math.min(xj(i,a,`protan`),xj(i,a,`deutan`))<8&&n.push({severity:`warning`,slots:[t+1,r+1],message:`Colours ${t+1} and ${r+1} are close with red-green colour blindness; make one lighter or darker, or label the series.`})}return e.forEach((e,r)=>{tj(e,t)<3&&n.push({severity:`warning`,slots:[r+1],message:`Colour ${r+1} is faint against the background; charts using it should label values or offer a table.`})}),n}function Cj(e,t,n=7){let r=ej(t)<.5,i=nj(t,e,r?.3:.2),a=nj(e,r?`#FFFFFF`:`#000000`,r?.35:.4),o=(n-1)/2;return Array.from({length:n},(t,r)=>r<=o?nj(i,e,o===0?1:r/o):nj(e,a,(r-o)/(n-1-o)))}function wj(e,t,n=7){let r=ej(t)<.5,i=nj(t,r?`#FFFFFF`:`#000000`,r?.16:.07),a=Math.floor(n/2),o=e=>Array.from({length:a},(t,n)=>nj(i,e,(a-n)/a));return[...o(e[0]),i,...o(e[1]).reverse()]}var Tj,Ej,Dj,Oj,kj,Aj,jj,Mj=n((()=>{mj(),Tj={red:{light:`#C21725`,dark:`#FF605B`},orange:{light:`#DA6600`,dark:`#FE7802`},amber:{light:`#B27805`,dark:`#EC9F00`},yellow:{light:`#DABD0A`,dark:`#F4D40F`},green:{light:`#006A18`,dark:`#65EA71`},mint:{light:`#089772`,dark:`#00D7A4`},teal:{light:`#079390`,dark:`#00CBC6`},cyan:{light:`#078EAD`,dark:`#04C4ED`},blue:{light:`#217BF4`,dark:`#73ACFF`},indigo:{light:`#696BF4`,dark:`#97A1FF`},purple:{light:`#9D57DE`,dark:`#BF82FF`},pink:{light:`#AC0D71`,dark:`#E853A5`},magenta:{light:`#A52DA0`,dark:`#D25BCB`}},Ej=[{red:{light:`#DE3B3D`,dark:`#FF726B`},orange:{light:`#C85D02`,dark:`#FE7802`},amber:{light:`#B27805`,dark:`#FCAB05`},green:{light:`#029B29`,dark:`#39C34B`},teal:{light:`#079390`,dark:`#0EBCB8`},blue:{light:`#217BF4`,dark:`#68A5FF`},indigo:{light:`#696BF4`,dark:`#909AFE`},pink:{light:`#D13D91`,dark:`#FC65B6`},magenta:{light:`#BE47B8`,dark:`#E76EDF`}}],Dj={Classic:[`blue`,`red`,`teal`,`amber`,`magenta`,`green`,`indigo`,`orange`],Aurora:[`teal`,`amber`,`magenta`,`red`,`indigo`,`green`,`blue`,`orange`],Sand:[`orange`,`teal`,`purple`,`green`,`pink`,`blue`,`red`,`indigo`],Ink:[`indigo`,`red`,`teal`,`amber`,`magenta`,`green`,`blue`,`orange`],Berry:[`magenta`,`red`,`teal`,`amber`,`indigo`,`green`,`blue`,`orange`],Moss:[`green`,`magenta`,`red`,`blue`,`amber`,`teal`,`orange`,`indigo`]},Oj={Classic:[[`blue`,`red`,`indigo`,`orange`,`teal`,`amber`,`purple`,`green`]],Aurora:[[`teal`,`orange`,`blue`,`red`,`indigo`,`amber`,`purple`,`green`],[`teal`,`orange`,`pink`,`amber`,`purple`,`red`,`indigo`,`green`]],Sand:[[`orange`,`blue`,`green`,`indigo`,`red`,`purple`,`amber`,`magenta`]],Ink:[[`indigo`,`red`,`blue`,`orange`,`teal`,`amber`,`purple`,`green`]],Berry:[[`magenta`,`amber`,`blue`,`orange`,`indigo`,`green`,`purple`,`red`]],Moss:[[`green`,`purple`,`amber`,`blue`,`red`,`indigo`,`orange`,`teal`]]},kj=Object.keys(Dj),Aj=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},jj={protan:[[.152286,1.052583,-.204868],[.114503,.786281,.099216],[-.003882,-.048116,1.051998]],deutan:[[.367322,.860646,-.227968],[.280085,.672501,.047413],[-.01182,.04294,.968881]]}}));function Nj(e,t,n){if(e===void 0)return t;if(typeof e!=`object`||!e)throw Error(`${n} must be an object`);let r=e,i={...t};for(let e of Kj){let t=r[e];if(t!==void 0){if(!JA(t))throw Error(`${n}.${e} must be a hex colour like #1A2B3C`);i[e]=YA(t)}}return i}function Pj(e,t,n){let r=(e,t)=>Object.keys(e).every(n=>e[n].toUpperCase()===t[n].toUpperCase()),i=qj.find(i=>i.name===e&&i.mode===t&&i.was.some(e=>r(e,n)));return i?{...n,...i.now}:n}function Fj(e,t){if(typeof e!=`object`||!e)throw Error(`theme must be an object`);let n=e,r=n.name===void 0?t.name:n.name;if(typeof r!=`string`||r.trim()===``)throw Error(`theme.name must be a non-empty string`);let i=t.radius;if(n.radius!==void 0){if(typeof n.radius!=`number`||!Number.isFinite(n.radius))throw Error(`theme.radius must be a number`);i=Math.max(0,Math.min(28,Math.round(n.radius)))}let a=n.font===void 0?t.font:n.font;if(!Hj.includes(a))throw Error(`theme.font must be one of ${Hj.join(`, `)}`);let o=n.density===void 0?t.density:n.density;if(!Uj.includes(o))throw Error(`theme.density must be one of ${Uj.join(`, `)}`);let s=n.contrast===void 0?t.contrast:n.contrast;if(s!==void 0&&!Wj.includes(s))throw Error(`theme.contrast must be one of ${Wj.join(`, `)}`);return{name:r.trim().slice(0,60),light:Pj(r.trim(),`light`,Nj(n.light,t.light,`theme.light`)),dark:Pj(r.trim(),`dark`,Nj(n.dark,t.dark,`theme.dark`)),radius:i,font:a,density:o,charts:Rj(n.charts,t),...n.code===void 0?t.code?{code:t.code}:{}:{code:Lj(n.code)},...s===`more`?{contrast:`more`}:{}}}function Ij(e,t){if(e===void 0)return;if(typeof e!=`object`||!e)throw Error(`${t} must be an object`);let n={};for(let[r,i]of Object.entries(e)){if(!Vj.includes(r))throw Error(`${t}.${r} is not a code token; use one of ${Vj.join(`, `)}`);if(!JA(i))throw Error(`${t}.${r} must be a hex colour like #1A2B3C`);n[r]=YA(i)}return n}function Lj(e){if(typeof e!=`object`||!e)throw Error(`theme.code must be an object`);let t=e,n=Ij(t.light,`theme.code.light`),r=Ij(t.dark,`theme.code.dark`);return{...n?{light:n}:{},...r?{dark:r}:{}}}function Rj(e,t){let n=t.charts??{light:_j(`Classic`,`light`),dark:_j(`Classic`,`dark`)};if(e===void 0)return n;if(typeof e!=`object`||!e)throw Error(`theme.charts must be an object`);let r=e,i=vj(r.light,n.light,`theme.charts.light`),a=vj(r.dark,n.dark,`theme.charts.dark`),o=(e,t)=>{let n=hj(e.series,t);return n===e.series?e:{series:n,sequential:gj(e.sequential,t),diverging:[gj(e.diverging[0],t),gj(e.diverging[1],t)]}};return{light:o(i,`light`),dark:o(a,`dark`)}}function zj(e,t){return{...e,name:`Custom`,charts:t}}function Bj(e,t){let n=e=>{let n=uj(t,e.background,3);return{...e,accent:n,onAccent:lj(n)}};return{...e,name:`Custom`,light:n(e.light),dark:n(e.dark)}}var Vj,Hj,Uj,Wj,Gj,Kj,qj,Jj=n((()=>{Mj(),mj(),Vj=[`keyword`,`string`,`number`,`literal`,`comment`,`property`,`function`,`type`,`punctuation`],Hj=[`system`,`rounded`,`serif`,`mono`],Uj=[`comfortable`,`compact`],Wj=[`standard`,`more`],Gj=[`system`,`light`,`dark`],Kj=[`background`,`surface`,`text`,`muted`,`accent`,`onAccent`],qj=[{name:`Ink`,mode:`light`,was:[{background:`#FBFBFE`,surface:`#EFF0F8`,text:`#141633`,muted:`#565A78`,onAccent:`#FFFFFF`},{background:`#FBFBFD`,surface:`#F0F0F4`,text:`#141633`,muted:`#565A78`,onAccent:`#FFFFFF`}],now:{background:`#FBFBFC`,surface:`#F0F0F2`,text:`#141633`,muted:`#565A78`,onAccent:`#FFFFFF`}},{name:`Ink`,mode:`dark`,was:[{background:`#0A0B18`,surface:`#141629`,text:`#ECEDFB`,muted:`#9EA2C2`,onAccent:`#0A0B18`},{background:`#0B0C12`,surface:`#161720`,text:`#ECEDFB`,muted:`#9EA2C2`,onAccent:`#0B0C12`}],now:{background:`#0C0C0F`,surface:`#17181B`,text:`#ECEDFB`,muted:`#9EA2C2`,onAccent:`#0C0C0F`}},{name:`Sand`,mode:`light`,was:[{background:`#F8F9F5`,surface:`#ECEFE6`,text:`#1C1E18`,muted:`#5D6255`,onAccent:`#FFFFFF`},{background:`#F9F9F3`,surface:`#EFEEE2`,text:`#1E1D15`,muted:`#63614F`,onAccent:`#FFFFFF`},{background:`#FAF9F1`,surface:`#F2EEDC`,text:`#201D11`,muted:`#666046`,onAccent:`#FFFFFF`},{background:`#F9F9F4`,surface:`#F0EEE5`,text:`#201D11`,muted:`#666046`,onAccent:`#FFFFFF`}],now:{background:`#F9F9F6`,surface:`#EFEEE9`,text:`#201D11`,muted:`#666046`,onAccent:`#FFFFFF`}},{name:`Sand`,mode:`dark`,was:[{background:`#11130F`,surface:`#1B1E18`,text:`#F1F3EC`,muted:`#A6AB9D`,onAccent:`#11130F`},{background:`#13120D`,surface:`#1E1D15`,text:`#F3F2E9`,muted:`#ACAA97`,onAccent:`#13120D`},{background:`#14120A`,surface:`#201D10`,text:`#F5F2E5`,muted:`#B0A98E`,onAccent:`#14120A`},{background:`#13120D`,surface:`#1E1D17`,text:`#F5F2E5`,muted:`#B0A98E`,onAccent:`#14120A`}],now:{background:`#13120F`,surface:`#1D1D1A`,text:`#F5F2E5`,muted:`#B0A98E`,onAccent:`#14120A`}},{name:`Aurora`,mode:`light`,was:[{background:`#F9FCFC`,surface:`#ECF4F4`,text:`#0E2226`,muted:`#4E6468`,onAccent:`#FFFFFF`}],now:{background:`#FAFCFC`,surface:`#EFF3F3`,text:`#0E2226`,muted:`#4E6468`,onAccent:`#FFFFFF`}},{name:`Aurora`,mode:`dark`,was:[{background:`#050B0D`,surface:`#0D1619`,text:`#E6F4F5`,muted:`#93ABAF`,onAccent:`#050B0D`}],now:{background:`#070B0C`,surface:`#111517`,text:`#E6F4F5`,muted:`#93ABAF`,onAccent:`#050B0D`}},{name:`Berry`,mode:`light`,was:[{background:`#FDFAFC`,surface:`#F4EEF3`,text:`#261725`,muted:`#695767`,onAccent:`#FFFFFF`},{background:`#FCFAFC`,surface:`#F2EFF2`,text:`#261725`,muted:`#695767`,onAccent:`#FFFFFF`}],now:{background:`#FBFAFB`,surface:`#F1F0F1`,text:`#261725`,muted:`#695767`,onAccent:`#FFFFFF`}},{name:`Berry`,mode:`dark`,was:[{background:`#130C10`,surface:`#20161C`,text:`#F7EDF2`,muted:`#BCA2B0`,onAccent:`#130C10`},{background:`#110D0F`,surface:`#1D181B`,text:`#F7EDF2`,muted:`#BCA2B0`,onAccent:`#130C10`}],now:{background:`#100E0F`,surface:`#1B191A`,text:`#F7EDF2`,muted:`#BCA2B0`,onAccent:`#130C10`}},{name:`Harbor`,mode:`light`,was:[{background:`#FAFBFD`,surface:`#ECF1F5`,text:`#0F1F33`,muted:`#4F5F74`,onAccent:`#FFFFFF`}],now:{background:`#FAFBFC`,surface:`#EEF1F3`,text:`#0F1F33`,muted:`#4F5F74`,onAccent:`#FFFFFF`}},{name:`Harbor`,mode:`dark`,was:[{background:`#090C11`,surface:`#12181E`,text:`#EAF1F8`,muted:`#98AABD`,onAccent:`#090C11`}],now:{background:`#0A0C0F`,surface:`#15181B`,text:`#EAF1F8`,muted:`#98AABD`,onAccent:`#090C11`}},{name:`Moss`,mode:`light`,was:[{background:`#F8FCF9`,surface:`#EAF3EC`,text:`#131C15`,muted:`#506254`,onAccent:`#FFFFFF`}],now:{background:`#F9FBFA`,surface:`#EDF2EE`,text:`#131C15`,muted:`#506254`,onAccent:`#FFFFFF`}},{name:`Moss`,mode:`dark`,was:[{background:`#0C0E09`,surface:`#171913`,text:`#EDF0E6`,muted:`#A0A893`,onAccent:`#0C0E09`}],now:{background:`#0C0E0B`,surface:`#171916`,text:`#EDF0E6`,muted:`#A0A893`,onAccent:`#0C0E09`}}]}));function Yj(e,t=[]){let n=e.toLowerCase();return Zj.find(e=>e.name.toLowerCase()===n)??t.find(e=>e.name.toLowerCase()===n)}var Xj,Zj,Qj,$j=n((()=>{Mj(),Xj=e=>({light:_j(e,`light`),dark:_j(e,`dark`)}),Zj=[{name:`Ink`,light:{background:`#FBFBFC`,surface:`#F0F0F2`,text:`#141633`,muted:`#565A78`,accent:`#5B4FE0`,onAccent:`#FFFFFF`},dark:{background:`#0C0C0F`,surface:`#17181B`,text:`#ECEDFB`,muted:`#9EA2C2`,accent:`#909AFE`,onAccent:`#0C0C0F`},radius:10,font:`system`,density:`comfortable`,charts:Xj(`Ink`)},{name:`Aurora`,light:{background:`#FAFCFC`,surface:`#EFF3F3`,text:`#0E2226`,muted:`#4E6468`,accent:`#07796F`,onAccent:`#FFFFFF`},dark:{background:`#070B0C`,surface:`#111517`,text:`#E6F4F5`,muted:`#93ABAF`,accent:`#2FD3B5`,onAccent:`#050B0D`},radius:12,font:`system`,density:`comfortable`,charts:Xj(`Aurora`)},{name:`Sand`,light:{background:`#F9F9F6`,surface:`#EFEEE9`,text:`#201D11`,muted:`#666046`,accent:`#A55200`,onAccent:`#FFFFFF`},dark:{background:`#13120F`,surface:`#1D1D1A`,text:`#F5F2E5`,muted:`#B0A98E`,accent:`#F99532`,onAccent:`#14120A`},radius:10,font:`system`,density:`comfortable`,charts:Xj(`Sand`)},{name:`Berry`,light:{background:`#FBFAFB`,surface:`#F1F0F1`,text:`#261725`,muted:`#695767`,accent:`#9F2294`,onAccent:`#FFFFFF`},dark:{background:`#100E0F`,surface:`#1B191A`,text:`#F7EDF2`,muted:`#BCA2B0`,accent:`#E375D6`,onAccent:`#130C10`},radius:14,font:`rounded`,density:`comfortable`,charts:Xj(`Berry`)},{name:`Harbor`,light:{background:`#FAFBFC`,surface:`#EEF1F3`,text:`#0F1F33`,muted:`#4F5F74`,accent:`#0066D6`,onAccent:`#FFFFFF`},dark:{background:`#0A0C0F`,surface:`#15181B`,text:`#EAF1F8`,muted:`#98AABD`,accent:`#52A9FE`,onAccent:`#090C11`},radius:10,font:`system`,density:`comfortable`,charts:Xj(`Classic`)},{name:`Moss`,light:{background:`#F9FBFA`,surface:`#EDF2EE`,text:`#131C15`,muted:`#506254`,accent:`#15803D`,onAccent:`#FFFFFF`},dark:{background:`#0C0E0B`,surface:`#171916`,text:`#EDF0E6`,muted:`#A0A893`,accent:`#7FD85E`,onAccent:`#0C0E09`},radius:12,font:`system`,density:`comfortable`,charts:Xj(`Moss`)},{name:`Mono`,light:{background:`#FFFFFF`,surface:`#EDEDED`,text:`#000000`,muted:`#2E2E2E`,accent:`#1F1F1F`,onAccent:`#FFFFFF`},dark:{background:`#000000`,surface:`#1A1A1A`,text:`#FFFFFF`,muted:`#D6D6D6`,accent:`#EDEDED`,onAccent:`#000000`},radius:6,font:`system`,density:`compact`,charts:{light:{..._j(`Classic`,`light`),sequential:`#3D3D3D`},dark:{..._j(`Classic`,`dark`),sequential:`#C2C2C2`}}},{name:`High contrast`,light:{background:`#FFFFFF`,surface:`#F2F2F2`,text:`#000000`,muted:`#262626`,accent:`#000000`,onAccent:`#FFFFFF`},dark:{background:`#000000`,surface:`#121212`,text:`#FFFFFF`,muted:`#E6E6E6`,accent:`#FFFFFF`,onAccent:`#000000`},radius:8,font:`system`,density:`comfortable`,charts:{light:{..._j(`Classic`,`light`),sequential:`#333333`},dark:{..._j(`Classic`,`dark`),sequential:`#CCCCCC`}},contrast:`more`}],Qj=Zj[0]}));function eM(e){return[e.background,e.surface,e.text,e.accent,...e.series]}function tM(e,t,n,r){return n.map(n=>cj(e,t,r?cj(r,oM.dim,n):n))}function nM(e,t={}){let n=ej(e.background)<.5,r=t=>uj(uj(t,e.background,4.5),e.surface,4.5),i={};for(let[e,a]of Object.entries(sM))i[e]=r(t[e]??Tj[a][n?`dark`:`light`]);return i.comment=r(t.comment??e.muted),i.punctuation=r(t.punctuation??nj(e.text,e.background,.2)),i}function rM(e,t,n){let r=e;for(let e=0;e<3;e++)for(let e of n)r=uj(r,e,t);return r}function iM(e,t,n,r=`standard`){let i=r===`more`,{background:a,surface:o,text:s,accent:c}=e,l=ej(a)<.5,u=t??_j(`Classic`,l?`dark`:`light`),d=nj(a,c,l?.24:.12),f=e=>rM(e,4.5,[a,o]),p=nj(o,s,l?.08:.05),m=aj(o,s,l?.14:.09),h=[a,o,p],g=rM(e.muted,4.5,[...h,m]),_=oj(s,a,i?7:4.5,[...h,m]),v=oj(s,a,i?4.5:3,[a,o]),y=oj(a,s,4.5,[g]),b=(l?[.24,.18,.13,.08]:[.16,.12,.08,.05]).map(e=>{let t=aj(a,s,e);return tj(g,t)>=4.5?t:y}),x=oj(s,a,3,[a,o]),S=[x,...[.3,.5,.68,.82,.92].map(e=>aj(x,a,e))],C=[...u.series],w=eM({background:a,surface:o,text:s,accent:c,series:C}),T=tM(o,oM.regular,w);return{...e,muted:g,surfaceRaised:p,border:i?oj(s,a,3,[a,o]):nj(a,s,l?.2:.14),borderStrong:i?oj(s,a,4.5,[a,o]):nj(a,s,l?.4:.32),accentSoft:d,accentText:rM(c,4.5,[a,o,d]),focus:uj(c,a,3),success:f(cM.success),warning:f(cM.warning),danger:f(cM.danger),info:f(cM.info),series:C,sequential:Cj(u.sequential,o),diverging:wj(u.diverging,o),code:nM(e,n),divider:i?aj(a,s,l?.4:.34):nj(a,s,l?.14:.09),accentHover:aj(c,s,.12),accentPressed:aj(c,s,.24),bg:[a,o,p,m],label:[s,g,_,v],fill:b,gray:S,glass:{tint:o,dim:a,edge:s,muted:rM(g,4.5,T),edgeAlpha:l?.12:.1,highlightAlpha:l?.1:.55,shadow:l?`0 10px 30px rgb(0 0 0 / 0.4)`:`0 10px 30px rgb(0 0 0 / 0.1)`}}}function aM(e){return{name:e.name,light:iM(e.light,e.charts?.light,e.code?.light,e.contrast),dark:iM(e.dark,e.charts?.dark,e.code?.dark,e.contrast),contrast:e.contrast??`standard`,radius:e.radius,fontFamily:lM[e.font],monoFamily:uM,scale:dM[e.density]}}var oM,sM,cM,lM,uM,dM,fM=n((()=>{Mj(),mj(),oM={regular:.8,thick:.88,clear:.65,dim:.35,blur:24,saturate:160,fallback:.96},sM={keyword:`purple`,string:`teal`,number:`orange`,literal:`pink`,property:`blue`,function:`amber`,type:`red`},cM={success:Tj.green.light,warning:Tj.amber.light,danger:Tj.red.light,info:Tj.blue.light},lM={system:`system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,rounded:`ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif`,serif:`ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif`,mono:`ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace`},uM=lM.mono,dM={comfortable:{unit:4,controlHeight:36,rowHeight:36,fontSize:14},compact:{unit:3,controlHeight:28,rowHeight:28,fontSize:13}}}));function pM(e){let t={"color-bg":e.background,"color-surface":e.surface,"color-surface-raised":e.surfaceRaised,"color-text":e.text,"color-muted":e.muted,"color-accent":e.accent,"color-on-accent":e.onAccent,"color-accent-soft":e.accentSoft,"color-accent-text":e.accentText,"color-border":e.border,"color-border-strong":e.borderStrong,"color-focus":e.focus,"color-success":e.success,"color-warning":e.warning,"color-danger":e.danger,"color-info":e.info};e.series.forEach((e,n)=>{t[`series-${n+1}`]=e}),e.sequential.forEach((e,n)=>{t[`sequential-${n+1}`]=e}),e.diverging.forEach((e,n)=>{t[`diverging-${n+1}`]=e});for(let[n,r]of Object.entries(e.code))t[`code-${n}`]=r;t[`color-divider`]=e.divider,t[`color-accent-hover`]=e.accentHover,t[`color-accent-pressed`]=e.accentPressed;let n=(e,n)=>n.forEach((n,r)=>t[`${e}-${r+1}`]=n);return n(`color-bg`,e.bg),n(`color-label`,e.label),n(`color-fill`,e.fill),n(`color-gray`,e.gray),t[`glass-tint`]=sj(e.glass.tint),t[`glass-dim-color`]=sj(e.glass.dim),t[`glass-edge-color`]=sj(e.glass.edge),t[`glass-edge-alpha`]=String(e.glass.edgeAlpha),t[`glass-highlight-alpha`]=String(e.glass.highlightAlpha),t[`glass-muted`]=e.glass.muted,t[`glass-shadow`]=e.glass.shadow,t}function mM(){let e=yM;return{"glass-alpha-regular":String(oM.regular),"glass-alpha-thick":String(oM.thick),"glass-alpha-clear":String(oM.clear),"glass-alpha-dim":String(oM.dim),"glass-blur":`${oM.blur}px`,"glass-saturate":`${oM.saturate}%`,"glass-regular":`rgb(var(${e}-glass-tint) / var(${e}-glass-alpha-regular))`,"glass-thick":`rgb(var(${e}-glass-tint) / var(${e}-glass-alpha-thick))`,"glass-clear":`rgb(var(${e}-glass-tint) / var(${e}-glass-alpha-clear))`,"glass-dim":`rgb(var(${e}-glass-dim-color) / var(${e}-glass-alpha-dim))`,"glass-edge":`rgb(var(${e}-glass-edge-color) / var(${e}-glass-edge-alpha))`,"glass-highlight":`rgb(255 255 255 / var(${e}-glass-highlight-alpha))`,"glass-filter":`blur(var(${e}-glass-blur)) saturate(var(${e}-glass-saturate))`}}function hM(e){let t=xM,n=String(oM.fallback);return[`@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {\n${_M(e,{"glass-alpha-regular":n,"glass-alpha-thick":n,"glass-alpha-clear":n})}\n}`,`@media (prefers-reduced-transparency: reduce) {\n${_M(e,t)}\n}`,`@media (prefers-contrast: more) {\n${_M(e,SM)}\n}`,`@media (forced-colors: active) {\n${_M(e,{...t,"glass-shadow":`none`})}\n}`]}function gM(e){let t=e.scale.unit;return{radius:`${e.radius}px`,"radius-sm":`${Math.round(e.radius/2)}px`,"radius-lg":`${Math.round(e.radius*1.5)}px`,font:e.fontFamily,"font-mono":e.monoFamily,"font-size":`${e.scale.fontSize}px`,"font-size-sm":`${e.scale.fontSize-2}px`,"font-size-lg":`${e.scale.fontSize+4}px`,"font-size-xs":`${e.scale.fontSize-3}px`,"font-size-title-3":`${e.scale.fontSize+3}px`,"font-size-title-2":`${e.scale.fontSize+6}px`,"font-size-title-1":`${e.scale.fontSize+10}px`,"font-size-large-title":`${e.scale.fontSize+18}px`,"font-weight-regular":`400`,"font-weight-medium":`500`,"font-weight-semibold":`600`,"font-weight-bold":`700`,"line-height":`1.45`,"line-height-tight":`1.2`,"letter-spacing-title":`-0.01em`,"duration-fast":`${bM.fast}ms`,duration:`${bM.base}ms`,"duration-slow":`${bM.slow}ms`,ease:bM.ease,"ease-out":bM.easeOut,"ease-spring":bM.spring,"duration-springy":`${bM.springy}ms`,"ease-gummy":bM.gummyFallback,"press-scale":String(bM.pressScale),"radius-xl":`${e.radius*2}px`,"radius-full":`999px`,"space-1":`${t}px`,"space-2":`${t*2}px`,"space-3":`${t*3}px`,"space-4":`${t*4}px`,"space-6":`${t*6}px`,"space-8":`${t*8}px`,"control-height":`${e.scale.controlHeight}px`,"control-size":`${e.scale.controlHeight-4}px`,"row-height":`${e.scale.rowHeight}px`,"target-min":`24px`}}function _M(e,t,n=``){let r=Object.entries(t).map(([e,t])=>` ${yM}-${e}: ${t};`);return n&&r.push(` ${n}`),`${e} {\n${r.join(`
|
|
19
|
+
`)}\n}`}function vM(e,t={}){let n=t.selector??`:root`,r=aM(e),i=pM(r.light),a=pM(r.dark);return[_M(n,{...gM(r),...mM(),"color-edge":`transparent`,...i},`color-scheme: light;`),`@media (prefers-color-scheme: dark) {\n${_M(`${n}:not([data-theme="light"])`,a,`color-scheme: dark;`)}\n}`,_M(`${n}[data-theme="dark"]`,a,`color-scheme: dark;`),`@media (pointer: coarse) {\n${_M(n,{"target-min":`44px`})}\n}`,...hM(n),...r.contrast===`more`?[_M(n,SM)]:[],`@supports (transition-timing-function: linear(0, 1)) {\n${_M(n,{"ease-gummy":bM.gummy})}\n}`,`@media (prefers-reduced-motion: reduce) {\n${_M(n,{"duration-fast":`0ms`,duration:`0ms`,"duration-slow":`0ms`,"duration-springy":`0ms`,"press-scale":`1`})}\n}`].join(`
|
|
20
20
|
|
|
21
|
-
`)}var _M,vM,yM,bM,xM=n((()=>{fj(),uM(),_M=`--sf`,vM={fast:120,base:200,slow:320,ease:`cubic-bezier(0.2, 0, 0, 1)`,easeOut:`cubic-bezier(0, 0, 0.2, 1)`,spring:`cubic-bezier(0.34, 1.3, 0.64, 1)`,springy:520,gummy:`linear(0, 0.116, 0.366, 0.639, 0.867, 1.021, 1.103, 1.126, 1.113, 1.082, 1.047, 1.018, 0.998, 0.987, 0.984, 0.986, 0.99, 0.994, 0.998, 1, 1)`,gummyFallback:`cubic-bezier(0.34, 1.45, 0.64, 1)`,pressScale:.97},yM={"glass-alpha-regular":`1`,"glass-alpha-thick":`1`,"glass-alpha-clear":`1`,"glass-blur":`0px`,"glass-saturate":`100%`},bM={...yM,"glass-edge-alpha":`0.6`,"glass-highlight-alpha":`0`,"color-edge":`var(${_M}-color-border-strong)`}}));function SM(e,t){let n=rM(e),r=n[t],i={color:r.text,fontFamily:n.fontFamily,fontSize:n.scale.fontSize-2},a={axisLine:{show:!0,lineStyle:{color:r.borderStrong}},axisTick:{show:!1},axisLabel:{color:r.muted,fontFamily:n.fontFamily},splitLine:{show:!0,lineStyle:{color:r.border}},splitArea:{show:!1},nameTextStyle:{color:r.muted}};return{color:r.series,animationDuration:420,animationDurationUpdate:280,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`,backgroundColor:`transparent`,textStyle:i,title:{textStyle:{color:r.text,fontFamily:n.fontFamily,fontWeight:600},subtextStyle:{color:r.muted,fontFamily:n.fontFamily}},legend:{textStyle:{color:r.muted,fontFamily:n.fontFamily},inactiveColor:r.borderStrong},tooltip:{backgroundColor:r.surface,borderColor:r.border,borderWidth:1,textStyle:{color:r.text,fontFamily:n.fontFamily,fontSize:n.scale.fontSize-1},padding:[n.scale.unit*2,n.scale.unit*3],extraCssText:`border-radius: ${Math.min(n.radius,12)}px; box-shadow: none;`,axisPointer:{lineStyle:{color:r.borderStrong},crossStyle:{color:r.borderStrong}}},categoryAxis:{...a,splitLine:{show:!1}},valueAxis:{...a,axisLine:{show:!1}},timeAxis:{...a,splitLine:{show:!1}},logAxis:{...a,axisLine:{show:!1}},line:{symbol:`circle`,symbolSize:6,lineStyle:{width:2},smooth:!1,emphasis:{scale:1.6},endLabel:{color:r.text,fontFamily:n.fontFamily,textBorderWidth:0}},bar:{barMaxWidth:40,itemStyle:{borderRadius:[Math.min(n.radius,4),Math.min(n.radius,4),0,0],borderColor:r.surface,borderWidth:1}},pie:{itemStyle:{borderColor:r.surface,borderWidth:2},label:{color:r.text}},scatter:{symbolSize:8,itemStyle:{borderColor:r.surface,borderWidth:1}},heatmap:{itemStyle:{borderColor:r.surface,borderWidth:2}},visualMap:{textStyle:{color:r.muted},inRange:{color:r.sequential}},dataZoom:{borderColor:r.border,backgroundColor:`transparent`,dataBackground:{lineStyle:{color:r.borderStrong},areaStyle:{color:r.border}},fillerColor:ej(r.background,r.accent,.2),handleStyle:{color:r.accent,borderColor:r.accent},textStyle:{color:r.muted}},toolbox:{iconStyle:{borderColor:r.muted},emphasis:{iconStyle:{borderColor:r.accent}}}}}var CM=n((()=>{fj(),uM()}));function wM(e,t,n={}){let r=[],i=n.themes??[],a=t;if(e.preset!==void 0){let t=typeof e.preset==`string`?qj(e.preset,i):void 0;t?a=t:r.push(`There is no theme called ${String(e.preset)}. Choose from ${TM(i).join(`, `)}.`)}if(e.accent!==void 0){if(!KA(e.accent))r.push(`The accent must be a hex colour like #2F5BEA.`);else{let t=Rj(a,e.accent),n=[`light`,`dark`].filter(e=>$A(nM(t[e]).accent,t[e].background)<3);n.length>0?r.push(`That accent is too close to the ${n.join(` and `)} background to see, so it was not used.`):a=t}}if(e.radius!==void 0&&(typeof e.radius!=`number`||!Number.isFinite(e.radius)?r.push(`The corner radius must be a number.`):a={...a,radius:Math.max(0,Math.min(28,Math.round(e.radius)))}),e.font!==void 0&&(Bj.includes(e.font)?a={...a,font:e.font}:r.push(`The font must be one of ${Bj.join(`, `)}.`)),e.density!==void 0&&(Vj.includes(e.density)?a={...a,density:e.density}:r.push(`The density must be one of ${Vj.join(`, `)}.`)),e.seriesOrder!==void 0){if(!Dj.includes(e.seriesOrder))r.push(`The chart colours must be one of ${Dj.join(`, `)}.`);else{let t={light:hj(e.seriesOrder,`light`),dark:hj(e.seriesOrder,`dark`)};[`light`,`dark`].some(e=>bj(t[e].series,a[e].surface).some(e=>e.severity===`error`))?r.push(`Those chart colours cannot be told apart on this theme, so they were not used.`):a=Lj(a,t)}}let o;return e.mode!==void 0&&(Uj.includes(e.mode)?o=e.mode:r.push(`The mode must be one of ${Uj.join(`, `)}.`)),!Yj.includes(a)&&!i.includes(a)&&a!==t&&(a={...a,name:`Custom`}),{theme:a,...o?{mode:o}:{},problems:r}}function TM(e=[]){let t=Yj.map(e=>e.name);for(let n of e)t.some(e=>e.toLowerCase()===n.name.toLowerCase())||t.push(n.name);return t}var EM,DM=n((()=>{Aj(),fj(),uM(),Zj(),Kj(),EM={presets:Yj.map(e=>e.name),modes:Uj,fonts:Bj,densities:Vj,seriesOrders:Dj,radius:[0,28]}})),OM=n((()=>{})),kM=n((()=>{fj(),Aj(),Kj(),Zj(),uM(),xM(),CM(),DM(),OM()})),AM=r((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,re(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+A(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+A(a,u),c+=re(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+A(a,u++),c+=re(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return re(ne(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ie(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ae(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var oe=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function se(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,oe)}catch(e){oe(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ce(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else se(ce.bind(null,e))}var le={map:ie,forEach:function(e,t,n){ie(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ie(e,function(){t++}),t},toArray:function(e){return ie(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=le,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ce,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ae}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=se,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),jM=r(((e,t)=>{t.exports=AM()}));function MM(e){if(e)try{let t=JSON.parse(e);return!t||typeof t!=`object`?void 0:{theme:Nj(t.theme,Xj),mode:Uj.includes(t.mode)?t.mode:`system`}}catch{return}}function NM(e){let t=globalThis.matchMedia?.(VM);return t?(t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)):()=>{}}function PM(){return(0,RM.useSyncExternalStore)(NM,HM,()=>!1)}function FM({children:e,initialTheme:t=Xj,initialMode:n=`system`,storage:r,storageKey:i=`surfaces.theme`,scope:a=`root`,themes:o}){let s=(0,RM.useContext)(zM),c=o??s?.themes??BM,l=(0,RM.useMemo)(()=>r===void 0?tw():r,[r]),u=(0,RM.useRef)(!1),[d,f]=(0,RM.useState)({theme:t,mode:n}),p=`sf-${(0,RM.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,m=PM();(0,RM.useEffect)(()=>{if(!l)return;let e=!1;return Promise.resolve(l.load(i)).then(t=>{let n=MM(t);n&&!e&&!u.current&&f(n)}).catch(()=>{}),()=>{e=!0}},[l,i]);let h=(0,RM.useCallback)(e=>{u.current=!0,f(t=>{if(Object.entries(e).every(([e,n])=>t[e]===n))return t;let n={...t,...e};return l&&Promise.resolve(l.save(i,JSON.stringify(n))).catch(()=>{}),n})},[l,i]),g=(0,RM.useMemo)(()=>gM(d.theme,a===`root`?{}:{selector:`[data-sf-scope="${p}"]`}),[d.theme,a,p]);(0,RM.useEffect)(()=>{if(a!==`root`)return;let e=document.documentElement;d.mode===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,d.mode)},[a,d.mode]),(0,RM.useEffect)(()=>{if(a!==`root`)return;let e=document.documentElement;d.theme.contrast===`more`?e.setAttribute(`data-contrast`,`more`):e.removeAttribute(`data-contrast`)},[a,d.theme.contrast]);let _=(0,RM.useCallback)(e=>h({theme:e}),[h]),v=(0,RM.useCallback)(e=>h({mode:e}),[h]),y=(0,RM.useMemo)(()=>({...d,setTheme:_,setMode:v,resolvedMode:d.mode===`system`?m?`dark`:`light`:d.mode,themes:c}),[d,_,v,m,c]);return(0,LM.jsxs)(zM.Provider,{value:y,children:[(0,LM.jsx)(`style`,{"data-sf-theme":a===`root`?`root`:p,children:g}),a===`root`?e:(0,LM.jsx)(`div`,{className:`sf-scope`,"data-sf-scope":p,"data-theme":d.mode===`system`?void 0:d.mode,children:e})]})}function IM(){return(0,RM.useContext)(zM)}var LM,RM,zM,BM,VM,HM,UM=n((()=>{LM=HA(),kM(),RM=jM(),rw(),zM=(0,RM.createContext)(void 0),BM=[],VM=`(prefers-color-scheme: dark)`,HM=()=>globalThis.matchMedia?.(VM).matches??!1})),WM=n((()=>{HA(),jM()}));function GM(e,t={},n=0){let{maxString:r=2e4,maxItems:i=500,maxDepth:a=16}=t;if(e==null)return null;switch(typeof e){case`boolean`:return e;case`number`:return Number.isFinite(e)?e:String(e);case`bigint`:return e>=BigInt(-(2**53-1))&&e<=BigInt(2**53-1)?Number(e):e.toString();case`string`:return e.length>r?`${e.slice(0,r)}… [${e.length-r} more characters]`:e;case`function`:case`symbol`:return null}if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return{"@bytes":e.byteLength};if(typeof Blob<`u`&&e instanceof Blob)return{"@bytes":e.size};if(e instanceof Date)return Number.isNaN(e.getTime())?null:e.toISOString();if(e instanceof Error)return KM(e);if(n>=a)return`[deeper than is kept]`;if(e instanceof Map)return GM(Object.fromEntries(e),t,n);if(e instanceof Set)return GM([...e],t,n);if(Array.isArray(e)){let r=e.slice(0,i).map(e=>GM(e,t,n+1));return e.length>i&&r.push(`[${e.length-i} more]`),r}let o={};for(let[r,i]of Object.entries(e))r.startsWith(`$`)||i===void 0||typeof i==`function`||typeof i==`symbol`||(o[r]=$M(r)&&(typeof i==`string`?i!==``:typeof i==`object`&&i)?XM:GM(i,t,n+1));return o}function KM(e){if(!(e instanceof Error))return{message:typeof e==`string`?e:String(e)};let t={message:e.message.slice(0,4e3)};e.name&&e.name!==`Error`&&(t.name=e.name);for(let n of[`code`,`line`,`column`,`engineCode`]){let r=e[n];(typeof r==`string`||typeof r==`number`)&&(t[n]=r)}return t}var qM,JM,YM,XM,ZM,QM,$M,eN=n((()=>{qM=e=>{let t=new Uint8Array(e),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return t.every(e=>e===0)&&(t[e-1]=1),Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)},JM=()=>qM(16),YM=()=>qM(8),XM=`[withheld]`,ZM=/pass(word|wd|phrase)|secret|token|api[-_]?key|authorization|credential|private[-_]?key|cookie|session[-_]?key/i,QM=/^(secret|secretName|tokenBudget|maxTokens|inputTokens|outputTokens|contextTokens|nextPageToken|pageToken)$/,$M=e=>ZM.test(e)&&!QM.test(e)}));function tN(e){if(e&&typeof e==`object`)for(let t of cN){let n=e[t];if(n&&typeof n==`object`)return{kind:t,surfaceId:String(n.surfaceId??``)}}}function nN(e,t,n){let r=tN(t.message??t.raw),i=t.issues??[],a=t.applied!==!1,o=GM(t.raw),s=t.message===void 0?void 0:GM(t.message);return e.record({kind:`message`,name:t.name??r?.kind??t.format,status:!a||t.error?`error`:i.length>0?`warning`:`ok`,surfaceId:t.key,detail:{format:t.format,raw:o,...s!==void 0&&JSON.stringify(s)!==JSON.stringify(o)?{message:s}:{},...typeof t.raw?.version==`string`?{version:t.raw.version}:{},issues:i.map(e=>({path:e.path,message:e.message})),applied:a,...t.error?{error:t.error}:{},...t.snapshot?{snapshot:!0}:{},...t.replay===!1?{replay:!1}:{}}},n)}var rN,iN,aN,oN,sN,cN,lN=n((()=>{eN(),rN=`data-sf-inspect`,iN=`data-sf-component`,aN=`data-sf-pointed`,oN=0,sN=(e=`s`)=>`${e}${++oN}`,cN=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`]}));function uN(e,t=0){if(typeof e!=`object`||!e||ArrayBuffer.isView(e))return{};let n={};for(let[r,i]of Object.entries(e))if(!(r.startsWith(`$`)||i==null||typeof i==`function`)){if(typeof i==`number`||typeof i==`boolean`||typeof i==`bigint`)n[r]=GM(i);else if(typeof i==`string`){if(i===``)continue;n[r]=gN.has(r)?GM(i,{maxString:4e3}):{"@text":i.length}}else if(Array.isArray(i))n[r]=r===`notices`?GM(i,{maxItems:20,maxString:1e3}):{"@count":i.length};else if(ArrayBuffer.isView(i)||i instanceof ArrayBuffer)n[r]={"@bytes":i.byteLength};else if(t<2){let e=uN(i,t+1);Object.keys(e).length>0&&(n[r]=e)}}return n}function dN(e,t,n,r){return{[Symbol.asyncIterator](){let i=e[Symbol.asyncIterator]();return{async next(){try{let e=await i.next();return e.done?t.end({detail:{response:n.result()}}):n.add(e.value),e}catch(e){throw t.end({...yN(e,r),detail:{...yN(e,r).detail,response:n.result()}}),e}},async return(e){return t.end({detail:{response:n.result(),stoppedEarly:!0}}),i.return?i.return(e):{done:!0,value:e}},async throw(e){if(t.end(yN(e)),i.throw)return i.throw(e);throw e}}}}}function fN(e,t,n,r={}){let i=hN(t),a=i&&i.recorder===n?i.target:t,o=i&&i.recorder===n?{...i.options,...r}:r,s=i&&i.recorder===n?i.name:e,c=new Map,l={target:a,recorder:n,name:s,options:o},u=()=>typeof o.scope==`function`?o.scope():o.scope;return new Proxy(a,{get(e,t){if(t===mN)return l;let r=Reflect.get(e,t,e);if(typeof r!=`function`||typeof t!=`string`)return r;let i=c.get(t);if(i&&i.of===r)return i.fn;let a=(...i)=>{let a=n.start({kind:`service`,name:`${s}.${t}`,detail:{service:s,method:t,request:GM(i[0])}},u()),c=i[1]?.signal,l;try{l=r.apply(e,i)}catch(e){throw a.end(yN(e,c)),e}let d=o.responses?.[t]??uN;return _N(l)?dN(l,a,o.streams?.[t]?.()??bN(),c):vN(l)?Promise.resolve(l).then(e=>(a.end({detail:{response:d(e)}}),e),e=>{throw a.end(yN(e,c)),e}):(a.end({detail:{response:d(l)}}),l)};return c.set(t,{fn:a,of:r}),a}})}function pN(){let e={},t=0,n=0,r=0;return{add(i){let{case:a,value:o}=xN(i);o&&(a===`header`?(typeof o.executedSql==`string`&&(e.executedSql=GM(o.executedSql)),typeof o.queryId==`string`&&o.queryId&&(e.queryId=o.queryId),o.rewriteMode!==void 0&&(e.rewriteMode=GM(o.rewriteMode)),Array.isArray(o.notices)&&(e.notices=GM(o.notices,{maxItems:20,maxString:1e3})),Array.isArray(o.columns)&&(e.columns=o.columns.slice(0,200).map(e=>({name:String(e?.name??``),type:String(e?.nativeType??``)}))),o.stored&&typeof o.stored==`object`&&(e.stored=uN(o.stored))):a===`batch`?(t++,n+=Number(o.rowCount??0),r+=ArrayBuffer.isView(o.arrowBatch)?o.arrowBatch.byteLength:0):a===`footer`&&(e.totalRows=GM(o.totalRowsReturned??n),e.truncated=o.truncated===!0,e.elapsedMs=GM(o.elapsedMs??0),o.nextCursor&&(e.more=!0)))},result:()=>({...e,batches:t,rows:n,bytes:r})}}var mN,hN,gN,_N,vN,yN,bN,xN,SN,CN=n((()=>{eN(),mN=Symbol.for(`surfaces-ui.traced`),hN=e=>e&&typeof e==`object`?e[mN]:void 0,gN=new Set(`executedSql.queryId.planText.code.message.name.id.version.generatedBy.sessionId.status.state.kind.format.type.engine.dialect.sourceId.table.schema.catalog.column.nextCursor.nextPageToken.pipelineId.runId.trigger.startedBy`.split(`.`)),_N=e=>!!e&&typeof e==`object`&&Symbol.asyncIterator in e,vN=e=>!!e&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`,yN=(e,t)=>{let n=e instanceof Error&&e.name===`AbortError`||t?.aborted===!0;return{status:n?`warning`:`error`,detail:{error:KM(e),...n?{cancelled:!0}:{}}}},bN=()=>{let e=0;return{add:()=>void e++,result:()=>({items:e})}},xN=e=>e?.part??{},SN={streams:{execute:pN}}}));function wN(e,t,n=200){let r=[],i=(e,t,a)=>{if(!(r.length>=n||e===t)){if(e===void 0)return void r.push({path:a||`/`,change:`added`,after:t});if(t===void 0)return void r.push({path:a||`/`,change:`removed`,before:e});if(TN(e)&&TN(t))for(let n of new Set([...Object.keys(e),...Object.keys(t)]))i(e[n],t[n],EN(a,n));else if(Array.isArray(e)&&Array.isArray(t))for(let n=0;n<Math.max(e.length,t.length);n++)i(e[n],t[n],EN(a,n));else JSON.stringify(e)!==JSON.stringify(t)&&r.push({path:a||`/`,change:`changed`,before:e,after:t})}};return i(e,t,``),r}var TN,EN,DN=n((()=>{TN=e=>typeof e==`object`&&!!e&&!Array.isArray(e),EN=(e,t)=>`${e}/${String(t).replace(/~/g,`~0`).replace(/\//g,`~1`)}`})),ON=n((()=>{})),kN=n((()=>{eN(),lN(),CN(),DN(),ON()}));function AN({scope:e,children:t}){return(0,NN.createElement)(FN.Provider,{value:e},t)}function jN(e,t,n){let r=(0,NN.useContext)(PN),i=(0,NN.useContext)(FN);return(0,NN.useMemo)(()=>r&&t?fN(e,t,r,{...n,...i?{scope:i}:{}}):t,[e,t,r,i,n])}function MN(e,t){let n=(0,NN.useContext)(PN);(0,NN.useEffect)(()=>n&&t?n.provide(e,t):void 0,[n,e,t])}var NN,PN,FN,IN,LN=n((()=>{NN=jM(),CN(),PN=(0,NN.createContext)(void 0),FN=(0,NN.createContext)(void 0),IN=()=>(0,NN.useContext)(PN)}));function RN({dataSource:e,children:t}){return MN(`dataSource`,e),(0,BN.jsx)(HN.Provider,{value:e,children:t})}function zN(e){let t=(0,VN.useContext)(HN),n=jN(`DataSource`,e??t,SN);if(!n)throw Error(`No DataSource: wrap the component in <DataSourceProvider> or pass dataSource.`);return n}var BN,VN,HN,UN=n((()=>{BN=HA(),kN(),LN(),VN=jM(),HN=(0,VN.createContext)(void 0)}));function WN(e,t){if(t<=0)return e;let n=e.startsWith(`-`),r=(n?e.slice(1):e).padStart(t+1,`0`);return`${n?`-`:``}${r.slice(0,-t)}.${r.slice(-t)}`}function GN(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return String(e);let n=`${t.getUTCFullYear()}-${eP(t.getUTCMonth()+1)}-${eP(t.getUTCDate())}`,r=`${eP(t.getUTCHours())}:${eP(t.getUTCMinutes())}:${eP(t.getUTCSeconds())}`,i=t.getUTCMilliseconds();return`${n} ${r}${i?`.${eP(i,3)}`:``}`}function KN(e){return JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)}function qN(e){return P.isInt(e)||P.isFloat(e)||P.isDecimal(e)}function JN(e,t){return e==null?{text:`null`,numeric:!1,isNull:!0}:P.isDecimal(t)?{text:WN(String(e),t.scale),numeric:!0,isNull:!1}:P.isTimestamp(t)?{text:GN(Number(e)),numeric:!1,isNull:!1}:P.isDate(t)?{text:GN(Number(e)).slice(0,10),numeric:!1,isNull:!1}:P.isInt(t)?{text:String(e),numeric:!0,isNull:!1}:P.isFloat(t)?{text:jA({maximumFractionDigits:4}).format(Number(e)),numeric:!0,isNull:!1}:P.isBool(t)?{text:e?`true`:`false`,numeric:!1,isNull:!1}:typeof e==`object`?{text:KN(typeof e.toJSON==`function`?e.toJSON():e),numeric:!1,isNull:!1}:{text:String(e),numeric:typeof e==`number`||typeof e==`bigint`,isNull:!1}}function YN(e,t,n){let r=JN(e,t);if(!n||r.isNull)return r;if(n.kind===`text`)return{...r,numeric:!1};if(n.kind===`date`||n.kind===`datetime`)return!P.isTimestamp(t)&&!P.isDate(t)?r:{...r,text:n.kind===`date`?r.text.slice(0,10):r.text.slice(0,19)};let i=P.isDecimal(t)?Number(r.text):Number(e);if(!Number.isFinite(i))return r;let a=n.decimals===void 0?{}:{minimumFractionDigits:n.decimals,maximumFractionDigits:n.decimals};return{text:jA(n.kind===`currency`?{style:`currency`,currency:n.currency??`USD`,...a}:n.kind===`percent`?{style:`percent`,maximumFractionDigits:1,...a}:n.kind===`compact`?{notation:`compact`,maximumFractionDigits:1,...a}:{maximumFractionDigits:4,...a}).format(i),numeric:!0,isNull:!1}}function XN(e,t,n){let r=YN(e,t,n);return r.isNull?{...r,text:z(`cell.null`)}:P.isBool(t)&&n?.kind!==`text`?{...r,text:z(e?`cell.true`:`cell.false`)}:r}function ZN(e,t){if(e==null)return null;let n=P.isDecimal(t)?Number(WN(String(e),t.scale)):Number(e);return Number.isFinite(n)?n:null}function QN(e,t){return e==null?null:P.isDecimal(t)?Number(WN(String(e),t.scale)):P.isTimestamp(t)?new Date(Number(e)).toISOString():P.isDate(t)?new Date(Number(e)).toISOString().slice(0,10):typeof e==`bigint`?Number(e):typeof e==`number`?e:typeof e==`boolean`?e?`true`:`false`:String(e)}function $N(e,t){return typeof e==`boolean`?e:typeof e==`bigint`&&!P.isDecimal(t)&&!P.isTimestamp(t)&&!P.isDate(t)&&!Number.isSafeInteger(Number(e))?String(e):QN(e,t)}var eP,tP=n((()=>{_p(),BA(),eP=(e,t=2)=>String(e).padStart(t,`0`)}));function nP(e,t,n={}){let r=n.blockSize??200,i=n.maxBlocks??60,a=aP(t),o=(0,iP.useMemo)(()=>t,[a]),s=(0,iP.useRef)(void 0),[,c]=(0,iP.useState)(0),[l,u]=(0,iP.useState)(``),f=l>(o.notBefore??``)?l:o.notBefore??``,[p,m]=(0,iP.useState)({status:`loading`,fields:[],executedSql:``,notices:[]}),h=(0,iP.useCallback)(t=>{let n=s.current;if(!n||n.blocks.has(t)||n.pending.has(t))return;n.pending.add(t);let{controller:a}=n;JS(e.execute({sourceId:o.sourceId,timeTravel:o.timeTravel,notBefore:f,query:{baseSql:o.sql,sorts:o.sorts,filters:o.filters,parameters:o.parameters,page:{limit:r,offset:BigInt(t*r)}}},{signal:a.signal})).then(s=>{if(a.signal.aborted)return;if(n.pending.delete(t),n.blocks.set(t,s.table),n.blocks.size>i){let e=(n.wanted[0]+n.wanted[1])/2/r,t=[...n.blocks.keys()].sort((t,n)=>Math.abs(n-e)-Math.abs(t-e));for(let e of t.slice(0,n.blocks.size-i))n.blocks.delete(e)}let l=s.header.stored,u=l?{createdAt:l.createdAt,rowCount:Number(l.rowCount)}:void 0,d;t===0&&!n.counted&&(n.counted=!0,u&&(o.filters?.length??0)===0?d=u.rowCount:s.table.numRows<r?d=s.table.numRows:e.count({sourceId:o.sourceId,timeTravel:o.timeTravel,notBefore:f,query:{baseSql:o.sql,filters:o.filters,parameters:o.parameters}},{signal:a.signal}).then(e=>{a.signal.aborted||m(t=>({...t,total:Number(e.rowCount)}))}).catch(()=>{})),m(e=>({...e,status:`ready`,stored:u,total:d??e.total,fields:s.table.schema.fields,executedSql:s.header.executedSql,notices:s.header.notices,elapsedMs:Number(s.footer.elapsedMs)})),c(e=>e+1)}).catch(e=>{if(a.signal.aborted)return;n.pending.delete(t);let r=d(e);m(e=>({...e,status:`error`,error:r.message,errorInfo:r,fields:[],executedSql:``,notices:[]}))})},[e,o,r,i,f]);(0,iP.useEffect)(()=>{let e={blocks:new Map,pending:new Set,controller:new AbortController,wanted:[0,r],timer:void 0,counted:!1};return s.current=e,m(e=>({...e,status:`loading`,error:void 0,errorInfo:void 0,total:void 0})),h(0),()=>{e.controller.abort(),e.timer&&clearTimeout(e.timer)}},[e,o,r,h]);let g=(0,iP.useCallback)((e,t)=>{let n=s.current;n&&(n.wanted=[e,t],n.timer||=setTimeout(()=>{n.timer=void 0;let[e,t]=n.wanted,i=Math.max(0,Math.floor(e/r)),a=Math.max(i,Math.floor(Math.max(t-1,e)/r));for(let e=i;e<=a;e++)h(e)},40))},[r,h]),_=(0,iP.useCallback)((e,t)=>{let n=s.current?.blocks.get(Math.floor(e/r));if(!n)return;let i=e%r;if(!(i>=n.numRows))return n.getChildAt(t)?.get(i)??null},[r]),v=(0,iP.useCallback)(e=>{let t=s.current?.blocks.get(Math.floor(e/r));return t!==void 0&&e%r<t.numRows},[r]),y=(0,iP.useCallback)(()=>u(new Date().toISOString()),[]),b=(0,iP.useCallback)(()=>{let e=s.current;e&&e.pending.size!==0&&(e.controller.abort(),e.pending.clear(),m(e=>({...e,status:`error`,error:`Cancelled.`,errorInfo:{message:`Cancelled.`,code:`CANCELLED`,line:0,column:0},fields:[],executedSql:``,notices:[]})))},[]);return{status:p.status,error:p.error,errorInfo:p.errorInfo,stored:p.stored,total:p.total,fields:p.fields,executedSql:p.executedSql,notices:p.notices,elapsedMs:p.elapsedMs,getCell:_,isLoaded:v,ensure:g,refresh:y,cancel:b}}function rP(e){return d(e).message}var iP,aP,oP=n((()=>{rw(),iP=jM(),aP=e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}n`:t)})),sP=n((()=>{}));function cP(e){return[...new Set((e??[]).filter(e=>dP.has(e.code)).map(e=>e.message))]}function lP({notes:e}){return!e||e.length===0?null:(0,uP.jsx)(`span`,{className:`sf-data-note`,role:`note`,children:e.join(` `)})}var uP,dP,fP=n((()=>{uP=HA(),dP=new Set([`FILTER_COLUMN_MISSING`])}));async function pP(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function mP(){let[e,t]=(0,gP.useState)(),n=(0,gP.useRef)(null),r=(0,gP.useCallback)(()=>{t(e=>{e?.from?.focus?.()})},[]),i=(0,gP.useCallback)((e,n,r)=>{if(r.length===0)return;e.preventDefault(),e.stopPropagation();let i=e.currentTarget,a=i.getBoundingClientRect(),o=e.clientX===0&&e.clientY===0;t({x:o?a.left+12:e.clientX,y:o?a.bottom:e.clientY,label:n,items:r,from:document.activeElement instanceof HTMLElement?document.activeElement:i})},[]),a=()=>[...n.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]];return(0,gP.useLayoutEffect)(()=>{let t=n.current;if(!e||!t)return;let r=t.getBoundingClientRect(),i=Math.max(4,Math.min(e.x,window.innerWidth-r.width-4)),o=Math.max(4,Math.min(e.y,window.innerHeight-r.height-4));t.style.left=`${i}px`,t.style.top=`${o}px`,a()[0]?.focus()},[e]),(0,gP.useEffect)(()=>{if(!e)return;let t=e=>{n.current?.contains(e.target)||r()};return document.addEventListener(`pointerdown`,t,!0),window.addEventListener(`blur`,r),window.addEventListener(`resize`,r),()=>{document.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`blur`,r),window.removeEventListener(`resize`,r)}},[e,r]),{open:i,close:r,element:e?(0,hP.jsx)(`div`,{ref:n,className:`sf-menu`,role:`menu`,"aria-label":e.label,style:{left:e.x,top:e.y},onKeyDown:e=>{let t=a(),n=t.indexOf(document.activeElement),i=n=>{e.preventDefault(),e.stopPropagation(),t[(n+t.length)%t.length]?.focus()};if(e.key===`ArrowDown`)return i(n+1);if(e.key===`ArrowUp`)return i(n-1);if(e.key===`Home`)return i(0);if(e.key===`End`)return i(t.length-1);(e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),e.stopPropagation(),r())},onContextMenu:e=>e.preventDefault(),children:e.items.map((e,t)=>e.separator?(0,hP.jsx)(`div`,{className:`sf-menu-separator`,role:`separator`},t):(0,hP.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`sf-menu-item`,disabled:e.disabled,onClick:()=>{r(),e.onSelect?.()},children:[(0,hP.jsx)(`span`,{children:e.label}),e.hint&&(0,hP.jsx)(`span`,{className:`sf-menu-hint`,children:e.hint})]},t))}):null}}var hP,gP,_P=n((()=>{hP=HA(),gP=jM()}));function vP(e,t={}){let n=new Set(t.hidden??[]),r=(t.order??[]).filter((t,n,r)=>e.includes(t)&&r.indexOf(t)===n);return[...r,...e.filter(e=>!r.includes(e))].filter(e=>!n.has(e))}function yP(e,t,n,r){let i=vP(e,t).filter(e=>e!==n),a=r===void 0?i.length:i.indexOf(r);return i.splice(a<0?i.length:a,0,n),{...t,order:i}}function bP(e){let t=e.type,n=P.isBool(t)?90:P.isTimestamp(t)?190:P.isDate(t)||qN(t)?120:180;return Math.max(n,Math.min(320,e.name.length*9+48))}function xP(e){let{sourceId:t,sql:n,filters:r,parameters:i,timeTravel:a,mode:o=`scroll`,pageSize:s=50,height:c=420,label:l}=e,u=zN(e.dataSource),d=IM(),f=e.rowHeight??lM[d?.theme.density??`comfortable`].rowHeight,[p,m]=(0,CP.useState)([]),h=e.sorts??p,g=t=>{e.sorts===void 0&&m(t),e.onSortsChange?.(t)},_=nP(u,{sourceId:t,sql:n,filters:r,parameters:i,timeTravel:a,notBefore:e.notBefore,sorts:h.map(e=>({column:e.column,direction:e.desc?ax.DESC:ax.ASC}))},{blockSize:o===`pages`?s:200}),{fields:v,total:y}=_,b=(0,CP.useRef)(e.onInfo);b.current=e.onInfo,(0,CP.useEffect)(()=>{b.current?.({total:_.total,executedSql:_.executedSql,notices:_.notices,fields:_.fields,error:_.status===`error`?_.error:void 0,errorInfo:_.status===`error`?_.errorInfo:void 0,stored:_.stored,refresh:_.refresh,loading:_.status===`loading`,cancel:_.cancel})},[_.total,_.executedSql,_.notices,_.fields,_.status,_.error,_.errorInfo,_.stored,_.refresh,_.cancel]);let[x,S]=(0,CP.useState)(0),C=(0,CP.useRef)(null),w=`${t}\n${n}\n${JSON.stringify(h)}`;(0,CP.useEffect)(()=>{S(0),C.current&&(C.current.scrollTop=0)},[w]);let[T,E]=(0,CP.useState)({}),D=e.columns??T,O=(0,CP.useRef)(D);O.current=D;let k=t=>{O.current=t,e.columns===void 0&&E(t),e.onColumnsChange?.(t)},ee=v.map(e=>e.name),te=vP(ee,D).map(e=>({field:v[ee.indexOf(e)],source:ee.indexOf(e)})),A=D.widths??{},ne=e=>D.labels?.[e]||e,re=(e,t)=>{let{[e]:n,...r}=O.current.widths??{};k({...O.current,widths:t===void 0?r:{...r,[e]:Math.max(kP,Math.min(AP,Math.round(t)))}})},[ie,ae]=(0,CP.useState)(),[oe,se]=(0,CP.useState)(),[ce,le]=(0,CP.useState)(``),ue=mP(),de=(0,CP.useId)(),fe=te.map(({field:e})=>A[e.name]??bP(e)),pe=[],me=0;for(let e of fe)pe.push(me),me+=e;let he=(e,t)=>n=>{n.preventDefault();let r=n.currentTarget,i=n.clientX;r.setPointerCapture?.(n.pointerId),ae(e);let a=n=>re(e,t+n.clientX-i),o=()=>{r.removeEventListener(`pointermove`,a),r.removeEventListener(`pointerup`,o),r.removeEventListener(`pointercancel`,o),ae(void 0)};r.addEventListener(`pointermove`,a),r.addEventListener(`pointerup`,o),r.addEventListener(`pointercancel`,o)},[ge,j]=(0,CP.useState)({width:0,height:0}),[_e,ve]=(0,CP.useState)({top:0,left:0});(0,CP.useLayoutEffect)(()=>{let e=C.current;if(!e)return;let t=()=>j({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let ye=Math.max(0,(ge.height||(typeof c==`number`?c-40:380))-f),be=ge.width||960,xe=y===void 0?1:Math.max(1,Math.ceil(y/s)),Se=o===`pages`?x*s:0,M=y===void 0?0:o===`pages`?Math.max(0,Math.min(s,y-Se)):y,Ce=M*f,we=Math.min(Ce,EP),Te=Ce>EP,Ee=Math.ceil(ye/f)+1,De,Oe;if(Te){let e=Math.max(1,we-ye),t=Math.round(Math.min(_e.top,e)/e*Math.max(0,M-Ee+1));De=t,Oe=e=>_e.top+(e-t)*f}else De=Math.max(0,Math.floor(_e.top/f)-DP),Oe=e=>e*f;let ke=Math.min(M,De+Ee+(Te?0:12)),{ensure:Ae}=_;(0,CP.useEffect)(()=>{M>0&&Ae(Se+De,Se+ke)},[Ae,Se,De,ke,M]);let je=0;for(;je<fe.length-1&&pe[je]+fe[je]<_e.left-OP;)je++;let Me=je;for(;Me<fe.length&&pe[Me]<_e.left+be+OP;)Me++;let Ne=te.slice(je,Me).map(({field:e,source:t},n)=>({field:e,source:t,index:je+n})),[Pe,Fe]=(0,CP.useState)(),Ie=Pe&&Pe.row<M&&Pe.column<te.length?Pe:void 0,Le=(e,t)=>{let n=C.current;if(!n)return;if(!Te){let t=e*f;t<n.scrollTop?n.scrollTop=t:t+f>n.scrollTop+ye&&(n.scrollTop=t+f-ye)}let r=pe[t]??0,i=fe[t]??0;r<n.scrollLeft?n.scrollLeft=r:r+i>n.scrollLeft+be&&(n.scrollLeft=r+i-be)},Re=(e,t)=>{if(M===0||te.length===0)return;let n={row:Math.max(0,Math.min(M-1,e)),column:Math.max(0,Math.min(te.length-1,t))};Fe(n),Le(n.row,n.column)},ze=e=>le(e),Be=(e,t)=>void pP(e).then(e=>ze(e?z(`grid.copied`,{what:t}):z(`grid.copyFailed`))),Ve=(e,t)=>{let n=te[t];if(!n||!_.isLoaded(Se+e))return``;let r=_.getCell(Se+e,n.source);return r==null?``:YN(r,n.field.type,void 0).text},He=t=>{if(t.target!==t.currentTarget)return;let n=Ie??{row:0,column:0},r=Math.max(1,Math.floor(ye/f)-1),i=t.ctrlKey||t.metaKey,a=(e,n)=>{t.preventDefault(),Re(e,n)};if(t.key===`ArrowDown`)return a(Ie?n.row+1:0,n.column);if(t.key===`ArrowUp`)return a(n.row-1,n.column);if(t.key===`ArrowRight`)return a(n.row,Ie?n.column+1:0);if(t.key===`ArrowLeft`)return a(n.row,n.column-1);if(t.key===`PageDown`)return a(n.row+r,n.column);if(t.key===`PageUp`)return a(n.row-r,n.column);if(t.key===`Home`)return a(i?0:n.row,0);if(t.key===`End`)return a(i?M-1:n.row,te.length-1);if(Ie){if(i&&t.key.toLowerCase()===`c`)return t.preventDefault(),Be(Ve(n.row,n.column),z(`grid.copiedCell`));t.key===`Enter`&&e.onRowClick&&_.isLoaded(Se+n.row)&&(t.preventDefault(),e.onRowClick(Ze(Se+n.row),Se+n.row))}},Ue=e=>/^[A-Za-z_]\w*$/.test(e)?e:`"${e.replace(/"/g,`""`)}"`,We=t=>e.onUseSql?e.onUseSql(t):Be(t,z(`grid.copiedSql`)),Ge=(e,t)=>{let r=vP(ee,{...D,hidden:[]}),i=D.hidden??[],a=`(${n.trim().replace(/;\s*$/,``)}) AS t`;return[{label:z(`grid.sortAscending`),onSelect:()=>g([{column:e,desc:!1}])},{label:z(`grid.sortDescending`),onSelect:()=>g([{column:e,desc:!0}])},{label:z(`grid.clearSorting`),disabled:h.length===0,onSelect:()=>g([])},{separator:!0},{label:z(`grid.moveLeft`),hint:`Alt ←`,disabled:t===0,onSelect:()=>k(yP(ee,D,e,te[t-1]?.field.name))},{label:z(`grid.moveRight`),hint:`Alt →`,disabled:t>=te.length-1,onSelect:()=>k(yP(ee,D,e,te[t+2]?.field.name))},{label:z(`grid.hideColumn`),disabled:te.length<=1,onSelect:()=>k({...D,hidden:[...i,e]})},{label:i.length?z(`grid.showAllColumnsHidden`,{count:jP.format(i.length)}):z(`grid.showAllColumns`),disabled:i.length===0,onSelect:()=>k({...D,hidden:[]})},{label:z(`grid.resetWidth`),hint:z(`grid.resetWidthHint`),disabled:A[e]===void 0,onSelect:()=>re(e,void 0)},{label:z(`grid.resetLayout`),disabled:r.join()===ee.join()&&i.length===0&&Object.keys(A).length===0,onSelect:()=>k({})},{separator:!0},{label:z(`grid.copyColumnName`),onSelect:()=>Be(e,z(`grid.copiedColumnName`))},{label:z(`grid.sqlCountValues`),onSelect:()=>We(`SELECT ${Ue(e)}, COUNT(*) AS row_count\nFROM ${a}\nGROUP BY ${Ue(e)}\nORDER BY row_count DESC`)},{label:z(`grid.sqlRange`),onSelect:()=>We(`SELECT MIN(${Ue(e)}) AS lowest, MAX(${Ue(e)}) AS highest, COUNT(*) - COUNT(${Ue(e)}) AS missing\nFROM ${a}`)}]},Ke=(t,n)=>{let r=te[n];if(!r||!_.isLoaded(Se+t))return[];let i=_.getCell(Se+t,r.source),a=()=>JSON.stringify(Ze(Se+t),(e,t)=>typeof t==`bigint`?t.toString():t,2);return[{label:z(`grid.copyValue`),hint:`Ctrl/⌘ C`,onSelect:()=>Be(Ve(t,n),z(`grid.copiedCell`))},{label:z(`grid.copyRowJson`),onSelect:()=>Be(a(),z(`grid.copiedRow`))},...e.onCellFilter?[{separator:!0},{label:z(`grid.filterToValue`),onSelect:()=>e.onCellFilter?.(r.field.name,i,!1)},{label:z(`grid.leaveValueOut`),onSelect:()=>e.onCellFilter?.(r.field.name,i,!0)}]:[]]},qe=(e,t)=>n=>{let r=n.key===`ArrowLeft`?-1:+(n.key===`ArrowRight`);if(r!==0){if(n.altKey){n.preventDefault();let i=t+r;if(i<0||i>=te.length)return;k(yP(ee,D,e,te[r<0?i:i+1]?.field.name)),ze(z(r<0?`grid.movedLeft`:`grid.movedRight`,{name:e}))}else n.shiftKey&&(n.preventDefault(),re(e,(fe[t]??kP)+r*TP))}},Je=(e,t)=>n=>{let r=n.dataTransfer.getData(wP);if(se(void 0),!r||r===e)return;n.preventDefault();let i=n.currentTarget.getBoundingClientRect(),a=n.clientX>i.left+i.width/2;k(yP(ee,D,r,a?te[t+1]?.field.name:e)),ze(z(`grid.moved`,{name:r}))},Ye=(e,t)=>{let n=h.find(t=>t.column===e),r=n?n.desc?void 0:{column:e,desc:!0}:{column:e,desc:!1};if(t.shiftKey){let t=h.filter(t=>t.column!==e);g(r?[...t,r]:t)}else g(r?[r]:[])},Xe=e=>({left:pe[e],width:fe[e]}),Ze=e=>Object.fromEntries(v.map((t,n)=>[t.name,_.getCell(e,n)])),Qe=[];for(let t=De;t<ke;t++){let n=Se+t,r=_.isLoaded(n);Qe.push((0,SP.jsx)(`div`,{role:`row`,"aria-rowindex":n+2,className:`sf-grid-row`,"data-odd":n%2==1||void 0,"data-clickable":e.onRowClick?!0:void 0,style:{top:Oe(t),height:f,width:me},onClick:e.onRowClick&&r?()=>e.onRowClick?.(Ze(n),n):void 0,children:Ne.map(({field:i,source:a,index:o})=>{if(!r)return(0,SP.jsx)(`div`,{role:`gridcell`,"aria-colindex":o+1,className:`sf-grid-cell`,style:Xe(o),children:(0,SP.jsx)(`span`,{className:`sf-grid-skeleton`})},i.name);let s=XN(_.getCell(n,a),i.type,e.formats?.[i.name]),c=Ie?.row===t&&Ie.column===o;return(0,SP.jsx)(`div`,{role:`gridcell`,"aria-colindex":o+1,className:`sf-grid-cell`,"data-numeric":s.numeric||void 0,"data-null":s.isNull||void 0,"data-active":c||void 0,id:c?`${de}-active`:void 0,"aria-selected":c||void 0,style:Xe(o),onMouseDown:()=>Fe({row:t,column:o}),onContextMenu:e=>{Fe({row:t,column:o}),ue.open(e,z(`grid.cellMenu`,{name:ne(i.name)}),Ke(t,o))},children:s.text},i.name)})},n))}let $e=_.status===`error`?z(`grid.failed`):y===void 0?z(`grid.loading`):z(y===1?`grid.rowsOne`:`grid.rows`,{count:jP.format(y)});return(0,SP.jsxs)(`div`,{className:[`sf-grid`,e.className].filter(Boolean).join(` `),style:{height:typeof c==`number`?`${c}px`:c},children:[(0,SP.jsxs)(`div`,{ref:C,className:`sf-grid-scroll`,role:`grid`,"aria-label":l??z(`grid.label`),"aria-rowcount":y===void 0?-1:y+1,"aria-colcount":te.length,"aria-activedescendant":Ie?`${de}-active`:void 0,onKeyDown:He,onContextMenu:e=>{e.target===e.currentTarget&&Ie&&ue.open(e,z(`grid.activeCellMenu`),Ke(Ie.row,Ie.column))},"aria-busy":_.status===`loading`,tabIndex:0,onScroll:e=>ve({top:e.currentTarget.scrollTop,left:e.currentTarget.scrollLeft}),children:[(0,SP.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`sf-grid-header`,style:{width:me,height:f},children:Ne.map(({field:e,index:t})=>{let n=h.find(t=>t.column===e.name),r=h.length>1&&n?h.indexOf(n)+1:void 0;return(0,SP.jsxs)(`div`,{role:`columnheader`,"aria-colindex":t+1,"aria-sort":n?n.desc?`descending`:`ascending`:`none`,className:`sf-grid-head`,"data-numeric":qN(e.type)||void 0,"data-drop":oe===e.name||void 0,style:Xe(t),draggable:!0,onDragStart:t=>{if(ie)return t.preventDefault();t.dataTransfer.setData(wP,e.name),t.dataTransfer.effectAllowed=`move`},onDragOver:t=>{t.dataTransfer.types.includes(wP)&&(t.preventDefault(),se(e.name))},onDragLeave:()=>se(void 0),onDragEnd:()=>se(void 0),onDrop:Je(e.name,t),onContextMenu:n=>ue.open(n,z(`grid.columnMenu`,{name:ne(e.name)}),Ge(e.name,t)),children:[(0,SP.jsxs)(`button`,{type:`button`,className:`sf-grid-sort`,title:`${ne(e.name)===e.name?``:`${e.name} · `}${String(e.type)}`,"aria-keyshortcuts":`Alt+ArrowLeft Alt+ArrowRight Shift+ArrowLeft Shift+ArrowRight Shift+F10`,onClick:t=>Ye(e.name,t),onKeyDown:qe(e.name,t),children:[(0,SP.jsx)(`span`,{className:`sf-grid-name`,children:ne(e.name)}),n&&(0,SP.jsxs)(`span`,{className:`sf-grid-arrow`,"aria-hidden":`true`,children:[n.desc?`↓`:`↑`,r]})]}),(0,SP.jsx)(`span`,{className:`sf-grid-resize`,"data-resizing":ie===e.name||void 0,onPointerDown:he(e.name,fe[t]),onDoubleClick:()=>re(e.name,void 0),"aria-hidden":`true`})]},e.name)})}),(0,SP.jsx)(`div`,{className:`sf-grid-body`,style:{height:we,width:me},children:Qe}),_.status===`error`&&(0,SP.jsx)(`p`,{className:`sf-grid-message`,role:`alert`,"data-error":_.error,children:e.errorMessage??_.error}),_.status===`ready`&&y===0&&(0,SP.jsx)(`p`,{className:`sf-grid-message`,children:e.emptyMessage??z(`grid.noRows`)})]}),e.footer===!1&&o!==`pages`?(0,SP.jsx)(`span`,{className:`sf-visually-hidden`,"aria-live":`polite`,children:$e}):(0,SP.jsxs)(`div`,{className:`sf-grid-footer`,children:[(0,SP.jsx)(`span`,{"aria-live":`polite`,children:$e}),(D.hidden?.length??0)>0&&(0,SP.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>k({...D,hidden:[]}),children:z(D.hidden.length===1?`grid.showHiddenOne`:`grid.showHidden`,{count:jP.format(D.hidden.length)})}),(0,SP.jsx)(`span`,{className:`sf-grid-note`,role:`status`,children:ce}),_.elapsedMs!==void 0&&_.status===`ready`&&(0,SP.jsx)(`span`,{children:z(`grid.elapsed`,{ms:_.elapsedMs})}),_.stored&&_.status===`ready`&&(0,SP.jsxs)(`span`,{className:`sf-grid-asof`,children:[z(`grid.asOf`,{time:MA({hour:`numeric`,minute:`2-digit`,second:`2-digit`}).format(new Date(_.stored.createdAt))}),(0,SP.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:_.refresh,children:z(`grid.runAgain`)})]}),o===`pages`&&y!==void 0&&(0,SP.jsxs)(`span`,{className:`sf-grid-pager`,children:[(0,SP.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:x===0,onClick:()=>S(x-1),children:z(`grid.previous`)}),(0,SP.jsx)(`span`,{children:z(`grid.page`,{page:jP.format(x+1),pages:jP.format(xe)})}),(0,SP.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:x+1>=xe,onClick:()=>S(x+1),children:z(`grid.next`)})]})]}),(0,SP.jsx)(lP,{notes:cP(_.notices)}),ue.element]})}var SP,CP,wP,TP,EP,DP,OP,kP,AP,jP,MP=n((()=>{SP=HA(),vS(),kM(),_p(),CP=jM(),UN(),fP(),tP(),BA(),oP(),_P(),UM(),wP=`application/x-surfaces-grid-column`,TP=16,EP=1e7,DP=6,OP=240,kP=60,AP=1200,jP={format:e=>jA().format(e)}}));function NP(){let e=globalThis.echarts;if(!e)throw Error(`Charts need ECharts: load echarts.js before surfaces-page.js.`);return e}function PP(...e){return NP().init(...e)}var FP=n((()=>{}));function IP(e){let t=[],{type:n,categories:r=0,series:i=1}=e;return n===`pie`&&r>5&&t.push({rule:`pie-slices`,message:`${r} slices are too many to compare by angle.`,instead:`A bar chart sorted by value.`}),e.rightAxis&&t.push({rule:`two-scales`,message:`Two y scales make heights look comparable when they are not.`,instead:`Two charts stacked on the same x axis, or both measures indexed to a common start.`}),n===`bar`&&e.truncatedAxis&&t.push({rule:`bar-baseline`,message:`A bar's length is its value, so the axis must start at zero.`,instead:`Start at zero, or use a dot or line chart if the differences are small.`}),(n===`line`||n===`area`)&&e.orderedX===!1&&t.push({rule:`line-order`,message:`A line implies order between its points; these categories have none.`,instead:`A bar chart.`}),n===`line`&&i>5&&t.push({rule:`too-many-lines`,message:`${i} lines cross too often to follow.`,instead:`Small multiples on one shared scale, or highlight one line and grey the rest.`}),e.stacked&&i>5&&t.push({rule:`stack-depth`,message:`Only the bottom of ${i} stacked segments can be compared across bars.`,instead:`Keep the largest four and fold the rest into Other, or use small multiples.`}),n===`bar`&&!e.stacked&&r*i>40&&t.push({rule:`bar-crowding`,message:`Too many bars to read individually.`,instead:`The top values sorted by size, or a table.`}),n===`area`&&!e.stacked&&i>1&&t.push({rule:`overlapping-areas`,message:`Unstacked areas hide each other.`,instead:`Lines, or a stacked area if the total matters.`}),n===`bar`&&e.orderedX&&!e.binned&&r>24&&t.push({rule:`bars-over-time`,message:`${r} bars in a row hide the trend they make.`,instead:`A line, with a time grain coarse enough for the decision.`}),n===`pie`&&e.orderedX&&t.push({rule:`pie-in-order`,message:`A pie puts its slices round a circle, so the order of these values is lost.`,instead:`A line or bars, in the order of x.`}),n!==`pie`&&i===1&&e.legend&&e.legend!==`none`&&t.push({rule:`one-series-legend`,message:`A legend for one series repeats what the title says.`,instead:`Leave the legend out and name the measure in the title.`}),t}var LP=n((()=>{}));function RP(e){let t=e=>{e.ctrlKey||e.metaKey||e.stopPropagation()};return e.addEventListener(`wheel`,t,{capture:!0}),()=>e.removeEventListener(`wheel`,t,{capture:!0})}var zP=n((()=>{}));function BP(e,t){return t.length>0&&t.every(t=>(t.type??e)===`bar`&&t.axis!==`right`)}function VP(e){return e?P.isTimestamp(e.type)||P.isDate(e.type)||P.isInt(e.type)||P.isFloat(e.type)||P.isDecimal(e.type):!1}function HP(e,t,n){let r=new Map;for(let i of e){let e=String(i[t]??`null`);r.set(e,(r.get(e)??0)+(Number(i[n])||0))}return[...r.entries()].sort((e,t)=>t[1]-e[1]).map(([e])=>e)}function UP(e,t){return e?P.isTimestamp(e.type)||P.isDate(e.type)?`time`:(P.isInt(e.type)||P.isFloat(e.type)||P.isDecimal(e.type))&&t?`value`:`category`:`category`}function WP(e){return e===`none`?{show:!1}:e===`right`?{type:`scroll`,orient:`vertical`,right:0,top:`middle`}:{type:`scroll`,[e]:0}}function GP(e,t,n){let r=Array.isArray(t)?t:void 0,i=[],a=1/0,o=-1/0;for(let t of e){let e=t.encode.y,s=(r?r[t.datasetIndex]?.source??[]:n).map(t=>Number(t[e])).filter(e=>Number.isFinite(e));if(s.length===0)return!1;i.push(s.at(-1)),a=Math.min(a,...s),o=Math.max(o,...s)}let s=(o-Math.min(a,0))*.08,c=[...i].sort((e,t)=>e-t);return c.every((e,t)=>t===0||e-c[t-1]>=s)}function KP(e){if(e.type===`pie`)return[];let t=e.series.map(t=>t.type??e.type);return UP(e.fields.find(t=>t.name===e.x),t.every(e=>e===`scatter`))===`category`?[]:e.rows.filter(t=>t[e.x]==null)}function qP(e){let t=KP(e).length>0?{...e,rows:e.rows.filter(t=>t[e.x]!=null)}:e,{type:n,x:r,splitBy:i}=t,a=t.fields.find(e=>e.name===r),o=n!==`pie`&&VP(a)&&t.sort===`value`,s=n!==`pie`&&t.sort===`value`&&!VP(a)?t.rows.map(e=>e[r]==null?{...e,[r]:`null`}:e):t.rows,c=o?[...t.rows].sort((e,t)=>typeof e[r]==`number`&&typeof t[r]==`number`?e[r]-t[r]:String(e[r]).localeCompare(String(t[r]))):s;if(n===`pie`){let e=t.series[0];return{tooltip:{trigger:`item`,valueFormatter:aF(t.yFormat)},legend:WP(t.legend??`bottom`),series:[{type:`pie`,name:e?.label??``,radius:[`45%`,`72%`],center:[`50%`,`45%`],label:{show:c.length<=8},data:e?c.map(t=>({name:String(t[r]??`null`),value:t[e.column]})):[]}]}}let l=t.series.map(e=>e.type??n),u=UP(a,l.every(e=>e===`scatter`)),d=!!t.horizontal&&BP(n,t.series),f=(e,t)=>d?{x:t,y:e}:{x:e,y:t},p=c.length>2e3?{large:!0,sampling:`lttb`,showSymbol:!1}:{},m=t.series.some(e=>e.axis===`right`),h=e=>{let r=e.type??n,i=e.stack??(t.stacked&&r!==`scatter`?`stack-${e.axis??`left`}-${r}`:void 0);return{type:r===`area`?`line`:r,...r===`area`?{areaStyle:{opacity:.18},showSymbol:!1}:{},...i?{stack:i}:{},...m?{yAxisIndex:+(e.axis===`right`)}:{},tooltip:{valueFormatter:aF(e.axis===`right`?void 0:t.yFormat)},...p}},g=e=>e?{itemStyle:{color:e},lineStyle:{color:e}}:{},_,v;if(i){let e=new Map;for(let t of c){let n=String(t[i]??`null`),r=e.get(n);r?r.push(t):e.set(n,[t])}let n=[...e.keys()];v=n.map(t=>({source:e.get(t)})),_=n.flatMap((e,n)=>t.series.map(i=>({...h(i),...g(t.splitColors?.[e]),name:t.series.length>1?`${e} · ${i.label}`:e,datasetIndex:n,encode:f(r,i.column)})))}else v={source:c},_=t.series.map(e=>({...h(e),...g(e.color),name:e.label,encode:f(r,e.column)}));let y=t.legend===void 0&&_.length>=2&&_.length<=4&&l.every(e=>e===`line`)&&!t.stacked&&!m&&GP(_,v,c);y&&(_=_.map(e=>({...e,endLabel:{show:!0,formatter:`{a}`,distance:6},labelLayout:{moveOverlap:`shiftY`}})));let b=t.legend??(y?`none`:_.length>1?`top`:`none`),x=t.sort===`value`&&!VP(a)&&t.series[0]?HP(c,r,t.series[0].column):void 0,S=new Set(c.map(e=>e[r])).size>60,C=(e,n)=>({type:`value`,name:e,nameLocation:`middle`,...YP,position:n?`right`:`left`,splitLine:{show:!n},axisLabel:{formatter:n?QP:tF(t.yFormat)}});return{useUTC:!0,dataset:v,grid:{left:8,right:b===`right`?140:y?96:16,top:b===`top`?36:16,bottom:(S&&!d?40:8)+(b===`bottom`?28:0),outerBoundsMode:`same`,outerBoundsContain:`all`},tooltip:{trigger:l.every(e=>e===`scatter`)?`item`:`axis`},legend:WP(b),...d?{yAxis:{type:u,...u===`category`&&x?{data:x}:{},inverse:!0,name:t.xTitle,nameLocation:`start`,nameGap:8,axisLabel:{hideOverlap:!0,...u===`category`?{interval:0}:{}}},xAxis:{...C(t.yTitle,!1),position:`bottom`}}:{xAxis:{type:u,...u===`category`&&x?{data:x}:{},name:t.xTitle??(u===`value`?r:void 0),nameLocation:`middle`,...YP,axisLabel:{hideOverlap:!0,...u===`category`?{interval:0}:{}}},yAxis:m?[C(t.yTitle,!1),C(t.yRightTitle,!0)]:C(t.yTitle,!1)},dataZoom:S?d?[{type:`inside`,yAxisIndex:0},{type:`slider`,yAxisIndex:0,width:18,right:8}]:[{type:`inside`},{type:`slider`,height:18,bottom:b===`bottom`?32:8}]:[],series:_}}function JP(e,t,n){let r=t-e;if(!(r>0)||!(n>0))return 1;let i=r/n,a=10**Math.floor(Math.log10(i));return([1,2,2.5,5,10].find(e=>e*a>=i)??10)*a}var YP,XP,ZP,QP,$P,eF,tF,nF,rF,iF,aF,oF=n((()=>{_p(),BA(),YP={nameGap:8,nameMoveOverlap:!0},XP=()=>jA({notation:`compact`,maximumFractionDigits:1}),ZP=()=>jA({maximumSignificantDigits:2}),QP=e=>e!==0&&Math.abs(e)<1?ZP().format(e):XP().format(e),$P=()=>jA({style:`percent`,maximumSignificantDigits:2}),eF=()=>jA({style:`currency`,currency:`USD`,notation:`compact`,maximumSignificantDigits:3}),tF=e=>e===`percent`?e=>$P().format(e):e===`currency`?e=>eF().format(e):QP,nF=()=>jA({style:`percent`,maximumFractionDigits:1}),rF=()=>jA({style:`currency`,currency:`USD`,maximumFractionDigits:2}),iF=()=>jA({maximumFractionDigits:2}),aF=e=>t=>{let n=typeof t==`number`?t:Number(t);return t==null||t===``||!Number.isFinite(n)?t==null?`–`:String(t):e===`percent`?nF().format(n):e===`currency`?rF().format(n):n!==0&&Math.abs(n)<1?ZP().format(n):iF().format(n)}}));function sF(e){return e.map((e,t)=>{if(e.expression)return{column:`calc_${t}`,label:e.label??e.expression,measure:e};if(!e.aggregate)return{column:e.column??``,label:e.label??e.column??``,measure:e};let n=e.column??`rows`,r=e.aggregate===`percentile`?`p${Math.round((e.percentile??.9)*100)}`:e.aggregate.replace(`_`,` `);return{column:`${e.aggregate}_${e.column??`rows`}_${t}`.replace(/\W+/g,`_`),label:e.label??(e.aggregate===`count`&&!e.column?`count`:`${r} of ${n}`),measure:e}})}function cF(e,t){try{return wS(bS(e),{name:e=>`${t}_${e}`,divide:(e,t)=>`(${e} / ${t})`})}catch{return e}}function lF(e){return e.rows.length===0?{type:e.type,categories:0,series:0}:{type:e.type,categories:new Set(e.rows.map(t=>t[e.x])).size,series:e.type===`pie`?1:e.seriesCount,stacked:e.stacked,rightAxis:e.y.some(e=>e.axis===`right`),orderedX:e.binned||VP(e.fields.find(t=>t.name===e.x)),...e.histogram?{binned:!0}:{},...e.legend?{legend:e.legend}:{}}}function uF(e){return e.xGrain||e.binWidth?`x`:e.sort??(e.type===`bar`&&e.y.every(e=>(e.type??`bar`)===`bar`)?`value`:`x`)}function dF(e){let{sql:t,type:n,x:r,y:i,splitBy:a,filters:o,parameters:s,limit:c}=e,l=sF(i),u=l.filter(e=>e.measure.aggregate||e.measure.expression);if(u.length===0)return{baseSql:t,filters:o,parameters:s,columns:[...new Set([r,...a?[a]:[],...l.map(e=>e.column)])],sample:{rows:c}};let d=e.xGrain?{column:r,by:{case:`grain`,value:_F[e.xGrain]}}:e.binWidth?{column:r,by:{case:`binWidth`,value:e.binWidth}}:void 0;return{baseSql:t,filters:o,parameters:s,groupBy:[...d?[]:[r],...a?[a]:[]],buckets:d?[d]:[],aggregates:u.flatMap(e=>e.measure.expression?Object.entries(e.measure.terms??{}).map(([t,n])=>({function:gF[n.aggregate],column:n.column??``,alias:`${e.column}_${t}`,percentile:n.aggregate===`percentile`?n.percentile??.9:0})):[{function:gF[e.measure.aggregate],column:e.measure.column??``,alias:e.column,percentile:e.measure.aggregate===`percentile`?e.measure.percentile??.9:0}]),derived:u.filter(e=>e.measure.expression).map(e=>({alias:e.column,expression:cF(e.measure.expression,e.column)})),sorts:n===`pie`||uF(e)===`value`&&!a?[{column:u[0].column,direction:ax.DESC}]:[{column:r,direction:ax.ASC}],page:{limit:c}}}function fF(e,t){let n=t=>{let n=e.schema.fields.find(e=>e.name===t),r=e.getChild(t)?.get(0);return n?ZN(r,n.type):null},r=n(`lo`),i=n(`hi`);return r===null||i===null?1:JP(r,i,t)}function pF(e){let{sourceId:t,sql:n,type:r,x:i,xGrain:a,xBinWidth:o,xBins:s,y:c,splitBy:l,filters:u,parameters:d,timeTravel:f,notBefore:p,limit:m=5e3,height:h=320}=e,g=zN(e.dataSource),_=IM(),v=(0,hF.useRef)(null),[y,b]=(0,hF.useState)({loading:!0}),x=(0,hF.useMemo)(()=>sF(c),[JSON.stringify(c)]),S=JSON.stringify([t,n,r,i,a,o,s,c,l,u,d,f,p,m,e.sort],(e,t)=>typeof t==`bigint`?`${t}n`:t);(0,hF.useEffect)(()=>{let h=new AbortController,_={signal:h.signal};b(e=>({...e,loading:!0,error:void 0}));let v=x.some(e=>e.measure.aggregate||e.measure.expression);return(async()=>{let h=a?void 0:o;v&&!a&&!h&&s&&(h=fF((await JS(g.execute({sourceId:t,timeTravel:f,notBefore:p,query:{baseSql:n,filters:u,parameters:d,aggregates:[{function:ux.MIN,column:i,alias:`lo`},{function:ux.MAX,column:i,alias:`hi`}]}},_))).table,s));let y=uF({type:r,xGrain:a,binWidth:h,sort:e.sort,y:c}),b=dF({sql:n,type:r,x:i,xGrain:a,binWidth:h,y:c,splitBy:l,filters:u,parameters:d,limit:m,sort:y}),x=await JS(g.execute({sourceId:t,timeTravel:f,notBefore:p,query:b},_)),S=x.table.schema.fields,C=S.map((e,t)=>x.table.getChildAt(t)),w=Array.from({length:x.table.numRows},(e,t)=>Object.fromEntries(S.map((e,n)=>[e.name,QN(C[n].get(t),e.type)])));return{fields:S,rows:w,sort:y,cut:w.length<m?void 0:v?`first`:`sample`,notes:cP(x.header.notices)}})().then(e=>{h.signal.aborted||b({loaded:e,loading:!1})}).catch(e=>{h.signal.aborted||b({error:rP(e),loading:!1})}),()=>h.abort()},[g,S]);let C=(0,hF.useRef)(e.onPointClick);C.current=e.onPointClick;let w=_?.resolvedMode??`light`,T=_?.theme??Xj,{stacked:E,legend:D,xTitle:O,yTitle:k,yRightTitle:ee,yFormat:te,splitSlots:A,horizontal:ne}=e,re=(0,hF.useMemo)(()=>nM(T[w],T.charts?.[w]).series,[T,w]),ie=JSON.stringify(A??null),ae=(0,hF.useMemo)(()=>{if(!y.loaded)return;let t=e=>e===void 0?void 0:re[e-1],n=qP({type:r,x:i,splitBy:l,series:x.map(e=>({column:e.column,label:e.label,type:e.measure.type,axis:e.measure.axis,stack:e.measure.stack,color:t(e.measure.slot)})),splitColors:A?Object.fromEntries(Object.entries(A).map(([e,n])=>[e,t(n)??``]).filter(([,e])=>e!==``)):void 0,fields:y.loaded.fields,rows:y.loaded.rows,sort:y.loaded.sort,stacked:E,legend:D,xTitle:O,yTitle:k,yRightTitle:ee,yFormat:te,horizontal:ne}),a={aria:{enabled:!0},...typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?{animation:!1}:{},...n};return e.option?e.option(a):a},[y.loaded,r,i,l,x,e.option,E,D,O,k,ee,te,ne,re,ie]),oe=r!==`pie`&&Array.isArray(ae?.series)?ae.series.length:0;(0,hF.useEffect)(()=>{if(!v.current||!ae)return;let e=PP(v.current,SM(T,w));e.setOption(ae),e.on(`click`,e=>{let t=e.data!==null&&typeof e.data==`object`?e.data:void 0,n=t&&i in t?t[i]:e.name??null,r=t&&typeof t.value==`number`?t.value:typeof e.value==`number`?e.value:null;C.current?.({x:n,series:e.seriesName??``,value:r})});let t=typeof ResizeObserver>`u`?void 0:new ResizeObserver(()=>e.resize());t?.observe(v.current);let n=RP(v.current);return()=>{n(),t?.disconnect(),e.dispose()}},[ae,T,w]);let se=e.advice===!1||!y.loaded?[]:IP(lF({type:r,x:i,y:c,stacked:E,legend:D,seriesCount:oe,binned:!!(a||o||s),histogram:!!(o||s),fields:y.loaded.fields,rows:y.loaded.rows})),ce=y.loaded?KP({type:r,x:i,series:x.map(e=>({column:e.column,label:e.label,type:e.measure.type})),fields:y.loaded.fields,rows:y.loaded.rows}):[],le=ce.length===1?` (${x.map(e=>`${e.label}: ${typeof ce[0][e.column]==`number`?jA().format(ce[0][e.column]):String(ce[0][e.column]??`–`)}`).join(`, `)})`:``,ue=!!y.loaded&&y.loaded.rows.length===ce.length,de=e.label??z(`chart.description`,{type:r,measures:x.map(e=>e.label).join(`, `),x:i});return(0,mF.jsxs)(`figure`,{className:[`sf-chart`,e.className].filter(Boolean).join(` `),"aria-busy":y.loading,children:[y.error?(0,mF.jsx)(`p`,{className:`sf-chart-message`,role:`alert`,"data-error":y.error,style:{minHeight:h},children:e.errorMessage??y.error}):ue?(0,mF.jsx)(`p`,{className:`sf-chart-message`,style:{minHeight:h},children:e.emptyMessage??z(`chart.empty`)}):(0,mF.jsx)(`div`,{ref:v,className:`sf-chart-canvas`,role:`img`,"aria-label":de,style:{height:h}}),ce.length>0&&(0,mF.jsx)(`figcaption`,{className:`sf-chart-note`,children:z(`chart.missingX`,{x:i,detail:le})}),oe>re.length&&(0,mF.jsx)(`figcaption`,{className:`sf-chart-note`,children:z(`chart.coloursRepeat`,{count:oe,colours:re.length})}),se.map(e=>(0,mF.jsx)(`figcaption`,{className:`sf-chart-note sf-chart-advice`,role:`note`,children:z(`chart.advice`,{message:e.message,instead:e.instead})},e.rule)),y.loaded&&y.loaded.notes.length>0&&(0,mF.jsx)(`figcaption`,{className:`sf-chart-note`,role:`note`,children:y.loaded.notes.join(` `)}),y.loaded?.cut&&(0,mF.jsx)(`figcaption`,{className:`sf-chart-note`,children:y.loaded.cut===`sample`?z(`chart.sampleNote`,{count:jA().format(m)}):z(y.loaded.sort===`value`?`chart.largestNote`:`chart.firstNote`,{count:jA().format(m)})})]})}var mF,hF,gF,_F,vF=n((()=>{mF=HA(),rw(),vS(),kM(),FP(),hF=jM(),UN(),fP(),tP(),BA(),oP(),UM(),LP(),zP(),oF(),gF={sum:ux.SUM,avg:ux.AVG,count:ux.COUNT,count_distinct:ux.COUNT_DISTINCT,min:ux.MIN,max:ux.MAX,median:ux.MEDIAN,stddev:ux.STDDEV,variance:ux.VARIANCE,percentile:ux.PERCENTILE},_F={minute:dx.MINUTE,hour:dx.HOUR,day:dx.DAY,week:dx.WEEK,month:dx.MONTH,quarter:dx.QUARTER,year:dx.YEAR}}));function yF({value:e,onChange:t,onRun:n,readOnly:r,error:i,placeholder:a,minHeight:o=120,maxHeight:s,label:c,className:l}){return(0,bF.jsxs)(`div`,{className:[`sf-sql-editor`,l].filter(Boolean).join(` `),children:[(0,bF.jsx)(`textarea`,{className:`sf-input`,"aria-label":c??`SQL editor`,"aria-invalid":i?!0:void 0,spellCheck:!1,value:e,readOnly:r,placeholder:a,onChange:e=>t(e.target.value),onKeyDown:e=>{if(!n||e.key!==`Enter`||!(e.metaKey||e.ctrlKey))return;e.preventDefault();let t=e.currentTarget;n(t.selectionStart===t.selectionEnd?t.value:t.value.slice(t.selectionStart,t.selectionEnd))},style:{width:`100%`,minHeight:o,maxHeight:s,fontFamily:`var(--sf-font-mono)`,resize:`vertical`}}),i&&(0,bF.jsx)(`p`,{className:`sf-sql-editor-error`,role:`alert`,children:i.message})]})}var bF,xF=n((()=>{bF=HA()})),SF,CF=n((()=>{HA(),vS(),jM(),SF=`application/x-surfaces-ref+json`,Cx.PARQUET,Cx.CSV,Cx.JSON,Cx.ICEBERG,Cx.DELTA}));function wF(e){let t=(0,jF.useContext)(MF),n=jN(`Discovery`,e??t);if(!n)throw Error(`No Discovery backend: wrap the component in <DiscoveryProvider> or pass discovery.`);return n}function TF(e){let t=(0,jF.useContext)(MF);return jN(`Discovery`,e??t)}function EF(e){let t=e.status===Ux.DEPRECATED?`Deprecated`:`Certified`,n=e.setAt?` on ${e.setAt.slice(0,10)}`:``;return`${t} by ${e.setBy||`an unnamed person`}${n}${e.note?`. ${e.note}`:``}`}function DF({certification:e}){if(!e||e.status===Ux.UNSPECIFIED)return null;let t=e.status===Ux.DEPRECATED;return(0,AF.jsxs)(`span`,{className:`sf-cert`,"data-status":t?`deprecated`:`certified`,title:EF(e),children:[(0,AF.jsx)(`span`,{"aria-hidden":`true`,children:t?`!`:`✓`}),t?`Deprecated`:`Certified`]})}function OF(e,t){return{sourceId:e,kind:Bx.TABLE,table:t}}function kF(e){return e?.ref?.kind===Bx.COLUMN?`Column`:`Table`}var AF,jF,MF,NF,PF,FF,IF,LF=n((()=>{AF=HA(),vS(),LN(),jF=jM(),BA(),MF=(0,jF.createContext)(void 0),NF={[Cx.PARQUET]:`Parquet`,[Cx.CSV]:`CSV`,[Cx.JSON]:`JSON`,[Cx.ICEBERG]:`Iceberg`,[Cx.DELTA]:`Delta`},PF={[Hx.SOURCE]:`From the source`,[Hx.HUMAN]:`Written by a person`,[Hx.GENERATED]:`Generated`},FF={format:e=>jA({notation:`compact`,maximumFractionDigits:1}).format(e)},IF={format:e=>jA().format(e)}}));function RF(e){let t=[`bytes`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Number(e),r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${r===0?n:n.toFixed(1)} ${t[r]}`}function zF(e){return[e.catalog,e.schema,e.table,e.column].filter(e=>!!e).map(e=>/^[A-Za-z_]\w*$/.test(e)?e:`"${e.replace(/"/g,`""`)}"`).join(`.`)}function BF(e){let{sourceId:t,catalog:n,schema:r,table:i,onClose:a}=e,o=zN(e.dataSource),[s,c]=(0,HF.useState)(),l=zF({catalog:n,schema:r,table:i});(0,HF.useEffect)(()=>{let e=!0;return c(void 0),(i?o.describeTable({sourceId:t,ref:{catalog:n??``,schema:r??``,table:i}}).then(e=>e.table?{table:e.table}:{error:`The backend returned nothing for this table.`}):o.listTables({sourceId:t,catalog:n??``,schema:r??``,pageSize:50}).then(e=>({tables:e.tables,more:e.nextPageToken!==``}))).then(t=>e&&c(t)).catch(t=>e&&c({error:rP(t)})),()=>{e=!1}},[o,t,n,r,i]);let u=[];if(s&&`table`in s){let{summary:e,rowCount:t,sizeBytes:n,location:r,properties:i}=s.table;u.push([`Kind`,WF[e?.kind??0]??`Table`]),e?.format&&u.push([`Format`,Cx[e.format]?.toLowerCase()??``]),t!==void 0&&u.push([`Rows`,UF.format(t)]),n!==void 0&&u.push([`Size`,RF(n)]),r&&u.push([`Location`,r]),u.push([`Columns`,UF.format(s.table.columns.length)]);for(let[e,t]of Object.entries(i))u.push([e,t])}return(0,VF.jsxs)(`section`,{className:[`sf-info`,e.className].filter(Boolean).join(` `),"aria-label":`Details of ${l||t}`,onKeyDown:e=>{e.key===`Escape`&&a&&(e.stopPropagation(),a())},children:[(0,VF.jsxs)(`header`,{className:`sf-info-head`,children:[(0,VF.jsxs)(`div`,{children:[(0,VF.jsx)(`p`,{className:`sf-info-kind`,children:i?`Table`:r?`Schema`:n?`Database`:`Source`}),(0,VF.jsx)(`p`,{className:`sf-info-name`,children:l||t})]}),a&&(0,VF.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:a,autoFocus:!0,children:`Close`})]}),s===void 0&&(0,VF.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`}),s&&`error`in s&&(0,VF.jsxs)(`p`,{className:`sf-metric-error`,role:`alert`,children:[`Could not read the details: `,s.error]}),s&&`table`in s&&(0,VF.jsxs)(VF.Fragment,{children:[s.table.summary?.comment&&(0,VF.jsx)(`p`,{className:`sf-info-comment`,children:s.table.summary.comment}),(0,VF.jsx)(`dl`,{className:`sf-info-facts`,children:u.map(([e,t])=>(0,VF.jsxs)(`div`,{children:[(0,VF.jsx)(`dt`,{children:e}),(0,VF.jsx)(`dd`,{children:t})]},e))}),(0,VF.jsx)(`div`,{className:`sf-info-scroll`,tabIndex:0,role:`region`,"aria-label":`Columns`,children:(0,VF.jsxs)(`table`,{className:`sf-info-table`,children:[(0,VF.jsx)(`thead`,{children:(0,VF.jsxs)(`tr`,{children:[(0,VF.jsx)(`th`,{scope:`col`,children:`Column`}),(0,VF.jsx)(`th`,{scope:`col`,children:`Type`}),(0,VF.jsx)(`th`,{scope:`col`,children:`Notes`})]})}),(0,VF.jsx)(`tbody`,{children:s.table.columns.map(e=>(0,VF.jsxs)(`tr`,{children:[(0,VF.jsx)(`th`,{scope:`row`,children:e.name}),(0,VF.jsx)(`td`,{children:e.nativeType||e.arrowType}),(0,VF.jsx)(`td`,{children:[e.primaryKey&&`Key`,e.partitionKey&&`Partition`,!e.nullable&&`Required`,e.comment].filter(Boolean).join(` · `)})]},e.name))})]})})]}),s&&`tables`in s&&(0,VF.jsxs)(VF.Fragment,{children:[(0,VF.jsx)(`p`,{className:`sf-object-muted`,children:s.tables.length===0?`No tables found.`:`${s.more?`The first `:``}${s.tables.length} ${s.tables.length===1?`table`:`tables`}${s.more?`; more exist`:``}.`}),(0,VF.jsx)(`div`,{className:`sf-info-scroll`,tabIndex:0,role:`region`,"aria-label":`Tables`,children:(0,VF.jsxs)(`table`,{className:`sf-info-table`,children:[(0,VF.jsx)(`thead`,{children:(0,VF.jsxs)(`tr`,{children:[(0,VF.jsx)(`th`,{scope:`col`,children:`Table`}),(0,VF.jsx)(`th`,{scope:`col`,children:`Kind`}),(0,VF.jsx)(`th`,{scope:`col`,children:`Notes`})]})}),(0,VF.jsx)(`tbody`,{children:s.tables.map(e=>(0,VF.jsxs)(`tr`,{children:[(0,VF.jsx)(`th`,{scope:`row`,children:zF({schema:e.ref?.schema,table:e.ref?.table})}),(0,VF.jsx)(`td`,{children:[WF[e.kind]??`Table`,e.format?Cx[e.format]?.toLowerCase():``].filter(Boolean).join(`, `)}),(0,VF.jsx)(`td`,{children:e.comment})]},zF(e.ref??{})))})]})})]})]})}var VF,HF,UF,WF,GF=n((()=>{VF=HA(),vS(),HF=jM(),UN(),oP(),BA(),UF={format:e=>jA().format(e)},WF={[Sx.TABLE]:`Table`,[Sx.VIEW]:`View`,[Sx.MATERIALIZED_VIEW]:`Materialised view`,[Sx.EXTERNAL]:`External table`}}));function KF(e){return!e.table&&e.path?e.path.replace(/\/+$/,``).split(`/`).slice(-2).join(`/`):[e.schema,e.table,e.column].filter(Boolean).join(`.`)}function qF(e,t,n){if(t.length===0)return;e.setData(JF,JSON.stringify(t));let r=t.find(e=>e.table);r&&e.setData(SF,JSON.stringify({sourceId:r.sourceId,table:r.table,column:r.column})),e.setData(`text/plain`,n??t.map(KF).join(`, `))}var JF,YF=n((()=>{CF(),JF=`application/x-surfaces-refs+json`}));function XF(e,t,n){return`JOIN ${t} ON ${n.map(n=>`${e}.${n.leftColumn} = ${t}.${n.rightColumn}`).join(` AND `)}`}function ZF(e){let{sourceId:t,height:n=480,pageSize:r=200}=e,i=zN(e.dataSource),a=TF(e.discovery),o=IM(),s=lM[o?.theme.density??`comfortable`].rowHeight-4,[c,l]=(0,$F.useState)(``),[u,d]=(0,$F.useState)({}),[f,p]=(0,$F.useState)({}),[m,h]=(0,$F.useState)(new Set),[g,_]=(0,$F.useState)({}),[v,y]=(0,$F.useState)(0),[b,x]=(0,$F.useState)(),[S,C]=(0,$F.useState)(``),w=mP(),[T,E]=(0,$F.useState)(0),D=(0,$F.useRef)(null),O=(0,$F.useCallback)(async(e,n,a,o=``)=>{let{tables:s,nextPageToken:c}=await i.listTables({sourceId:t,...a,pageSize:r,pageToken:o});return{nodes:s.map(r=>{let i=r.ref;return{id:`${e}/t:${i.catalog}.${i.schema}.${i.table}`,parent:e,level:n,kind:`table`,label:i.table,tag:tI[r.format],expandable:!0,table:{catalog:i.catalog,schema:i.schema,table:i.table},trail:[i.table.toLowerCase()],item:{kind:`table`,sourceId:t,table:i.table,catalog:i.catalog,schema:i.schema}}}),more:c?{level:n,where:a,token:c}:void 0}},[i,t,r]),k=(0,$F.useCallback)(async e=>{let n=(e?.level??0)+1,r=e?.id??eI;if(!e){let{catalogs:e}=await i.listCatalogs({sourceId:t});if(e.length!==1)return e.map(e=>({id:`c:${e.name}`,parent:r,level:n,kind:`catalog`,label:e.name,expandable:!0,trail:[],item:{kind:`catalog`,sourceId:t,table:``,catalog:e.name}}));let a=e[0].name,{schemas:o}=await i.listSchemas({sourceId:t,catalog:a});return o.length===1?O(r,n,{catalog:a,schema:o[0].name,search:``}):o.map(e=>({id:`s:${a}.${e.name}`,parent:r,level:n,kind:`schema`,label:e.name,expandable:!0,trail:[],item:{kind:`schema`,sourceId:t,table:``,catalog:a,schema:e.name}}))}if(e.kind===`catalog`){let{schemas:a}=await i.listSchemas({sourceId:t,catalog:e.label});return a.map(i=>({id:`${r}/s:${i.name}`,parent:r,level:n,kind:`schema`,label:i.name,expandable:!0,trail:[],item:{kind:`schema`,sourceId:t,table:``,catalog:e.label,schema:i.name}}))}if(e.kind===`schema`)return O(r,n,{catalog:e.item?.catalog??``,schema:e.label,search:``});if((e.kind===`table`||e.kind===`join`)&&e.table){let o=((await i.describeTable({sourceId:t,ref:e.table})).table?.columns??[]).map(i=>({id:`${r}/col:${i.name}`,parent:r,level:n,kind:`column`,label:i.name,meta:i.nativeType.toLowerCase(),expandable:!1,trail:e.trail,item:{kind:`column`,sourceId:t,table:e.table.table,column:i.name,catalog:e.table.catalog,schema:e.table.schema}}));return a?[...o,{id:`${r}/joins`,parent:r,level:n,kind:`joins`,label:`Joins`,expandable:!0,table:e.table,trail:e.trail}]:o}if(e.kind===`joins`&&e.table&&a){let{relations:i}=await a.getRelated({ref:{sourceId:t,kind:Bx.TABLE,catalog:e.table.catalog,schema:e.table.schema,table:e.table.table},kinds:[Wx.JOIN]}),o=i.filter(t=>t.object?.ref&&!e.trail.includes(t.object.ref.table.toLowerCase()));return o.length===0?[{id:`${r}/none`,parent:r,level:n,kind:`note`,label:i.length===0?`No joins found`:`No further joins`,expandable:!1,trail:e.trail}]:o.map(i=>{let a=i.object.ref,o=i.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn}));return{id:`${r}/j:${a.table}`,parent:r,level:n,kind:`join`,label:a.table,meta:o.map(e=>e.leftColumn===e.rightColumn?`on ${e.leftColumn}`:`on ${e.leftColumn} = ${e.rightColumn}`).join(`, `),tag:i.inferred?`Inferred`:void 0,expandable:!0,table:{catalog:a.catalog,schema:a.schema,table:a.table},trail:[...e.trail,a.table.toLowerCase()],certification:i.object?.certification,item:{kind:`join`,sourceId:t,table:a.table,catalog:a.catalog,schema:a.schema,join:{from:e.table.table,keys:o,inferred:i.inferred}}}})}return[]},[i,a,t,O]),ee=(0,$F.useCallback)((e,t)=>{d(t=>({...t,[e]:`loading`})),t.then(t=>{let n=Array.isArray(t)?{nodes:t}:t;d(t=>({...t,[e]:n.nodes})),p(t=>{let{[e]:r,...i}=t;return n.more?{...i,[e]:{...n.more,loading:!1}}:i})}).catch(t=>d(n=>({...n,[e]:{error:rP(t)}})))},[]);(0,$F.useEffect)(()=>{h(new Set),y(0);let e=c.trim(),t=setTimeout(()=>{d({}),p({}),ee(eI,e?O(eI,1,{catalog:``,schema:``,search:e}):k(void 0))},e?180:0);return()=>clearTimeout(t)},[ee,k,O,c]),(0,$F.useEffect)(()=>{if(!a)return;let e=!0;return a.search({query:``,kinds:[Bx.TABLE],sourceIds:[t],certificationStatuses:[Ux.CERTIFIED,Ux.DEPRECATED],pageSize:1e3}).then(t=>{if(!e)return;let n={};for(let e of t.hits)e.object?.certification&&e.object.ref&&(n[e.object.ref.table.toLowerCase()]=e.object.certification);_(n)}).catch(()=>{}),()=>{e=!1}},[a,t]);let te=e=>{e.expandable&&(h(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),u[e.id]===void 0&&ee(e.id,k(e)))},A=(0,$F.useMemo)(()=>{let e=[],t=(n,r)=>{let i=u[n];if(i!==void 0){if(i===`loading`)return void e.push({id:`${n}/loading`,parent:n,level:r,kind:`note`,label:`Loading…`,expandable:!1,trail:[]});if(!Array.isArray(i))return void e.push({id:`${n}/error`,parent:n,level:r,kind:`note`,label:i.error,expandable:!1,error:!0,trail:[]});for(let n of i)e.push(n),m.has(n.id)&&t(n.id,n.level+1);f[n]&&e.push({id:`${n}/more`,parent:n,level:f[n].level,kind:`more`,label:`Loading more tables…`,expandable:!1,trail:[]})}};return t(eI,1),e},[u,m,f]),ne=Math.max(s,n-44),re=Math.max(0,Math.floor(T/s)-4),ie=Math.min(A.length,re+Math.ceil(ne/s)+8);(0,$F.useEffect)(()=>{for(let e=re;e<ie;e++){let t=A[e];if(t?.kind!==`more`)continue;let n=t.parent,r=f[n];r&&!r.loading&&(p(e=>e[n]?{...e,[n]:{...e[n],loading:!0}}:e),O(n,r.level,r.where,r.token).then(e=>{d(t=>{let r=t[n];return Array.isArray(r)?{...t,[n]:[...r,...e.nodes]}:t}),p(t=>{let{[n]:r,...i}=t;return e.more?{...i,[n]:{...e.more,loading:!1}}:i})}).catch(()=>{p(e=>e[n]?{...e,[n]:{...e[n],loading:!1}}:e)}))}},[re,ie,A,f,O]);let ae=e=>e.kind===`join`&&e.join?XF(e.join.from,e.table,e.join.keys):e.column??(e.table||e.schema||e.catalog||``),[oe,se]=(0,$F.useState)(()=>new Set),ce=A.some(e=>e.kind===`table`&&e.level===1),le=e=>e.kind===`table`||e.kind===`column`?{sourceId:e.sourceId,kind:e.kind,...e.catalog&&!ce?{catalog:e.catalog}:{},...e.schema&&!ce?{schema:e.schema}:{},table:e.table,...e.column?{column:e.column}:{}}:void 0,ue=e=>{let t=A.filter(e=>oe.has(e.id)&&e.item&&le(e.item)).map(e=>e.item);return t.length>1&&t.includes(e)?t:le(e)?[e]:[]},de=t=>{let n=ue(t),r=n.map(e=>le(e));r.length!==0&&e.onAttach&&(e.onAttach(r,n),C(r.length===1?`Added ${r[0].column??r[0].table}.`:`Added ${r.length} items.`))},fe=(e,t)=>{let n=A[e];n?.item&&le(n.item)&&(se(r=>{let i=new Set(r);if(t===`toggle`)i.has(n.id)?i.delete(n.id):i.add(n.id);else{let[t,n]=v<=e?[v,e]:[e,v];for(let e=t;e<=n;e++)A[e]?.item&&le(A[e].item)&&i.add(A[e].id)}return C(i.size===0?``:`${i.size} selected. Drag them, or press Shift+Enter to add them.`),i}),y(e))},pe=(e,t)=>void pP(e).then(e=>C(e?`Copied ${t}.`:`Could not copy: the browser refused access to the clipboard.`)),me=(t,n)=>e.onUseSql?e.onUseSql(t,n):pe(t,`the SQL`),he=t=>e.onShowInfo?e.onShowInfo(t):x(t),ge=n=>{let r=zF({catalog:n.catalog,schema:n.schema,table:n.table}),a=ae(n),o=ue(n).length,s=[...e.onAttach&&o>0?[{separator:!0},{label:o>1?`${e.attachLabel??`Add to chat`}: ${o} items`:e.attachLabel??`Add to chat`,hint:`Shift Enter`,onSelect:()=>de(n)}]:[],{separator:!0},{label:`Copy name`,hint:`Ctrl/⌘ C`,onSelect:()=>pe(n.kind===`join`?a:zF({catalog:n.catalog,schema:n.schema,table:n.table,column:n.column}),`the name`)},...e.onInsert?[{label:n.kind===`join`?`Insert JOIN clause`:`Insert name into the editor`,hint:`Insert`,onSelect:()=>e.onInsert?.(a,n)}]:[]];if(n.kind===`catalog`||n.kind===`schema`)return[{label:`Show ${n.kind===`catalog`?`database`:`schema`} details`,onSelect:()=>he(n)},...s];if(n.kind===`table`)return[{label:`Show table details`,onSelect:()=>he(n)},{separator:!0},{label:`SQL: all rows`,onSelect:()=>me(`SELECT *\nFROM ${r}`,n)},{label:`SQL: every column by name`,onSelect:()=>void i.describeTable({sourceId:t,ref:{catalog:n.catalog??``,schema:n.schema??``,table:n.table}}).then(e=>me(`SELECT\n${(e.table?.columns??[]).map(e=>` ${zF({column:e.name})}`).join(`,
|
|
22
|
-
`)}\nFROM ${r}`,n)).catch(e=>C(`Could not read the columns: ${rP(e)}`))},{label:`SQL: count rows`,onSelect:()=>me(`SELECT COUNT(*) AS row_count\nFROM ${r}`,n)},...s];if(n.kind===`column`&&n.column){let e=zF({column:n.column});return[{label:`SQL: count each value`,onSelect:()=>me(`SELECT ${e}, COUNT(*) AS row_count\nFROM ${r}\nGROUP BY ${e}\nORDER BY row_count DESC`,n)},{label:`SQL: range and missing values`,onSelect:()=>me(`SELECT MIN(${e}) AS lowest, MAX(${e}) AS highest, COUNT(*) - COUNT(${e}) AS missing\nFROM ${r}`,n)},{label:`Show table details`,onSelect:()=>he({...n,kind:`table`,column:void 0})},...s]}return n.kind===`join`&&n.join?[{label:`SQL: both tables joined`,onSelect:()=>me(`SELECT *\nFROM ${zF({table:n.join.from})}\n${a}`,n)},{label:`Show table details`,onSelect:()=>he({...n,kind:`table`,join:void 0})},...s]:[]},j=e=>{let t=Math.max(0,Math.min(A.length-1,e));y(t);let n=D.current;n&&(t*s<n.scrollTop?n.scrollTop=t*s:(t+1)*s>n.scrollTop+ne&&(n.scrollTop=(t+1)*s-ne))},_e=t=>{let n=A[v],r=()=>t.preventDefault();if(t.key===`ArrowDown`)return r(),j(v+1);if(t.key===`ArrowUp`)return r(),j(v-1);if(t.key===`Home`)return r(),j(0);if(t.key===`End`)return r(),j(A.length-1);if(!n)return;let i=m.has(n.id);if(t.key===`ArrowRight`){if(r(),n.expandable&&!i)return te(n);if(i)return j(v+1)}if(t.key===`ArrowLeft`){if(r(),i)return te(n);let e=A.findIndex(e=>e.id===n.parent);if(e>=0)return j(e)}if(t.key===`Enter`&&t.shiftKey&&e.onAttach){let e=A.find(e=>oe.has(e.id)&&e.item)?.item,t=oe.has(n.id)||!e?n.item:e;if(t)return r(),de(t)}if(t.key===` `&&n.item)return r(),fe(v,`toggle`);if(t.key===`Escape`&&oe.size>0)return r(),se(new Set),C(``);if(t.key===`Enter`&&(r(),n.item?e.onSelect?.(n.item):te(n)),t.key===`Insert`&&n.item)return r(),e.onInsert?.(ae(n.item),n.item);if((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()===`c`&&n.item)return r(),pe(ae(n.item),`the name`);if((t.altKey&&t.key===`Enter`||t.key===`i`&&(t.ctrlKey||t.metaKey))&&n.item&&n.item.kind!==`join`)return r(),he(n.item.kind===`column`?{...n.item,kind:`table`,column:void 0}:n.item)},ve=e=>t=>{let n=ue(e).map(e=>le(e));n.length>0?qF(t.dataTransfer,n,n.length===1?ae(e):void 0):t.dataTransfer.setData(`text/plain`,ae(e)),t.dataTransfer.effectAllowed=`copy`},ye=[];for(let t=re;t<ie;t++){let n=A[t],r=m.has(n.id),i=n.item,a=n.certification??(n.kind===`table`?g[n.label.toLowerCase()]:void 0);ye.push((0,QF.jsxs)(`div`,{id:`sf-browser-${t}`,className:`sf-schema-row sf-browser-row`,"data-kind":n.kind===`more`?`note`:n.kind,"data-active":t===v||void 0,"data-error":n.error||void 0,style:{top:t*s,height:s,paddingInlineStart:`calc(var(--sf-space-2) + ${n.level-1} * var(--sf-space-4))`},role:`treeitem`,"aria-level":n.level,"aria-expanded":n.expandable?r:void 0,"aria-selected":oe.size>0?oe.has(n.id):t===v,"data-picked":oe.has(n.id)||void 0,draggable:i!==void 0,onDragStart:i?ve(i):void 0,onClick:r=>{if(r.ctrlKey||r.metaKey)return fe(t,`toggle`);if(r.shiftKey)return fe(t,`range`);oe.size>0&&(se(new Set),C(``)),y(t),te(n),i&&e.onSelect?.(i)},onDoubleClick:()=>i&&e.onInsert?.(ae(i),i),onContextMenu:i?e=>{y(t),w.open(e,`${n.label} actions`,ge(i))}:void 0,children:[(0,QF.jsx)(`span`,{className:`sf-schema-caret`,"aria-hidden":`true`,"data-open":r||void 0,children:n.expandable?`▸`:``}),(0,QF.jsx)(`span`,{className:`sf-schema-name`,children:n.label}),(0,QF.jsx)(DF,{certification:a}),n.meta&&(0,QF.jsx)(`span`,{className:`sf-schema-meta`,children:n.meta}),n.tag&&(0,QF.jsx)(`span`,{className:`sf-schema-tag`,children:n.tag}),(n.kind===`table`||n.kind===`join`)&&i&&e.renderActions&&(0,QF.jsx)(`span`,{className:`sf-schema-actions`,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:e.renderActions(i)})]},n.id))}let be=u[eI];return(0,QF.jsxs)(`div`,{className:[`sf-schema`,e.className].filter(Boolean).join(` `),style:{height:n},children:[(0,QF.jsx)(`input`,{className:`sf-input sf-schema-search`,type:`search`,placeholder:`Search tables`,"aria-label":`Search tables`,value:c,onChange:e=>l(e.target.value)}),(0,QF.jsxs)(`div`,{ref:D,className:`sf-schema-list`,role:`tree`,"aria-label":e.label??`Data objects`,"aria-busy":be===void 0||be===`loading`,"aria-activedescendant":A.length>0?`sf-browser-${v}`:void 0,tabIndex:0,"aria-multiselectable":`true`,"aria-keyshortcuts":`Shift+F10 Alt+Enter Insert Control+C Space Shift+Enter`,onKeyDown:_e,onContextMenu:e=>{let t=A[v]?.item;e.target===e.currentTarget&&t&&w.open(e,`${A[v].label} actions`,ge(t))},onScroll:e=>E(e.currentTarget.scrollTop),children:[(0,QF.jsx)(`div`,{style:{height:A.length*s,position:`relative`},children:ye}),Array.isArray(be)&&be.length===0&&(0,QF.jsx)(`p`,{className:`sf-schema-empty`,children:c.trim()?`No tables match “${c.trim()}”.`:`This source has nothing to show.`})]}),(0,QF.jsx)(`p`,{className:`sf-schema-note`,role:`status`,children:S}),b&&(0,QF.jsx)(`div`,{className:`sf-schema-info`,children:(0,QF.jsx)(BF,{dataSource:i,sourceId:t,catalog:b.catalog,schema:b.schema,table:b.kind===`table`?b.table:void 0,onClose:()=>{x(void 0),D.current?.focus()}})}),w.element]})}var QF,$F,eI,tI,nI=n((()=>{QF=HA(),vS(),kM(),$F=jM(),UN(),oP(),LF(),_P(),UM(),GF(),YF(),eI=``,tI={[Cx.PARQUET]:`Parquet`,[Cx.CSV]:`CSV`,[Cx.JSON]:`JSON`,[Cx.ICEBERG]:`Iceberg`,[Cx.DELTA]:`Delta`}}));function rI({icon:e}){return typeof e==`string`&&e in cI?(0,oI.jsx)(`svg`,{className:`sf-item-control-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,oI.jsx)(`path`,{d:cI[e]})}):(0,oI.jsx)(`span`,{className:`sf-item-control-icon`,children:e})}function iI({label:e,controls:t,show:n=`hover`,quietable:r=!0,className:i}){let a=(0,sI.useRef)(null),[o,s]=(0,sI.useState)(0),[c,l]=(0,sI.useState)(),u=Math.min(o,Math.max(0,t.length-1)),d=e=>{let n=(e+t.length)%t.length;s(n),a.current?.querySelectorAll(`button`)[n]?.focus()};return t.length===0?null:(0,oI.jsx)(`div`,{ref:a,className:[`sf-item-controls`,i].filter(Boolean).join(` `),role:`toolbar`,"aria-label":e,"data-show":n,"data-quietable":r||void 0,onKeyDown:e=>{if(e.key===`ArrowRight`||e.key===`ArrowDown`)d(u+1);else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)d(u-1);else if(e.key===`Home`)d(0);else if(e.key===`End`)d(t.length-1);else if(e.key===`Escape`&&c!==void 0)l(void 0);else return;e.preventDefault(),e.stopPropagation()},children:t.map((e,t)=>(0,oI.jsxs)(`button`,{type:`button`,className:`sf-item-control`,"data-control":e.id,"data-danger":e.danger||void 0,"data-pinned":e.pinned&&!e.disabled||void 0,"aria-label":e.label,"aria-pressed":e.pressed,"aria-disabled":e.disabled||void 0,tabIndex:t===u?0:-1,onClick:()=>!e.disabled&&e.onSelect(),onFocus:()=>{s(t),l(t)},onBlur:()=>l(e=>e===t?void 0:e),onPointerEnter:()=>l(t),onPointerLeave:()=>l(e=>e===t?void 0:e),children:[(0,oI.jsx)(rI,{icon:e.icon}),c===t&&(0,oI.jsxs)(`span`,{className:`sf-item-tip`,"aria-hidden":`true`,children:[e.label,e.disabled?` (not available here)`:``]})]},e.id))})}function aI(e,t){let n=[],r=(e,t,r,i,a={})=>{i!==void 0&&n.push({id:e,label:t,icon:r,onSelect:i||(()=>void 0),...i===!1?{disabled:!0}:{},...a})};return r(`edit`,`Change ${e}`,`edit`,t.edit),t.view&&r(`view`,t.view.now===`chart`?`Show ${e} as a table`:`Show ${e} as a chart`,t.view.now===`chart`?`table`:`chart`,t.view.toggle),r(`wider`,`Make ${e} wider`,`wider`,t.wider),r(`narrower`,`Make ${e} narrower`,`narrower`,t.narrower),r(`earlier`,`Move ${e} earlier`,`earlier`,t.earlier),r(`later`,`Move ${e} later`,`later`,t.later),r(`up`,`Move ${e} up`,`up`,t.up),r(`down`,`Move ${e} down`,`down`,t.down),r(`duplicate`,`Duplicate ${e}`,`duplicate`,t.duplicate),r(`remove`,`Remove ${e}`,`remove`,t.remove,{danger:!0}),n}var oI,sI,cI,lI,uI=n((()=>{oI=HA(),sI=jM(),cI={edit:`M4 20h4L19 9l-4-4L4 16z M14 6l4 4`,chart:`M4 4v16h16 M8 16v-5 M12 16V8 M16 16v-9`,table:`M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14`,wider:`M3 12h18 M7 8l-4 4 4 4 M17 8l4 4-4 4`,narrower:`M3 12h6 M21 12h-6 M5 8l4 4-4 4 M19 8l-4 4 4 4`,earlier:`M19 12H5 M11 6l-6 6 6 6`,later:`M5 12h14 M13 6l6 6-6 6`,up:`M12 19V5 M6 11l6-6 6 6`,down:`M12 5v14 M6 13l6 6 6-6`,duplicate:`M8 8h11v11H8z M5 16V5h11`,remove:`M5 7h14 M10 7V4h4v3 M7 7l1 13h8l1-13 M10 11v6 M14 11v6`,add:`M12 5v14 M5 12h14`,close:`M6 6l12 12 M18 6L6 18`,menu:`M4 7h16 M4 12h16 M4 17h16`,fold:`M4 4v16 M20 12H9 M14 7l-5 5 5 5`,unfold:`M20 4v16 M4 12h11 M10 7l5 5-5 5`,confirm:`M5 12l5 5 9-10`,power:`M12 3v8 M7 6.5a7 7 0 1 0 10 0`,"sign-out":`M10 4H5v16h5 M15 8l4 4-4 4 M19 12H9`,more:`M4.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0 M10.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0 M16.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0`},Object.keys(cI),lI=`sf-controls-host`}));function dI(e){return P.isUtf8(e)||P.isLargeUtf8(e)||P.isDictionary(e)}function fI(e){return dI(e)?[...xI,...bI]:P.isBool(e)?[yI[0],yI[1],...bI]:[...yI,...bI]}function pI(e,t){let n=e.trim();if(P.isInt(t)){if(!/^-?\d+$/.test(n))throw Error(z(`filter.enterWholeNumber`));return{kind:{case:`intValue`,value:BigInt(n)}}}if(P.isDecimal(t)){if(!/^-?\d+(\.\d+)?$/.test(n))throw Error(z(`filter.enterNumber`));return{kind:{case:`decimalValue`,value:n}}}if(P.isFloat(t)){if(n===``||Number.isNaN(Number(n)))throw Error(z(`filter.enterNumber`));return{kind:{case:`doubleValue`,value:Number(n)}}}if(P.isBool(t)){if(!/^(true|false)$/i.test(n))throw Error(z(`filter.enterTrueFalse`));return{kind:{case:`boolValue`,value:n.toLowerCase()===`true`}}}if(P.isTimestamp(t)||P.isDate(t)){if(Number.isNaN(Date.parse(n)))throw Error(z(`filter.enterDate`));return{kind:{case:`temporalValue`,value:n}}}if(e===``)throw Error(z(`filter.enterValue`));return{kind:{case:`stringValue`,value:e}}}function mI(e){let t=SI.find(t=>t.operator===e.operator)?.label??`?`,n=(e.values??[]).map(e=>String(e.kind?.value??``));return`${e.column} ${t}${n.length>0?` ${n.join(`, `)}`:``}`}function hI({fields:e,filters:t,onChange:n,loadValues:r,now:i,relative:a,onRelativeChange:o,className:s}){let c=(0,_I.useId)(),[l,u]=(0,_I.useState)(``),[d,f]=(0,_I.useState)(),[p,m]=(0,_I.useState)(``),[h,g]=(0,_I.useState)(),[_,v]=(0,_I.useState)({}),y=e.filter(e=>!P.isList(e.type)&&!P.isStruct(e.type)&&!P.isMap(e.type)),b=y.find(e=>e.name===l)??y[0],x=b?fI(b.type):[],S=x.find(e=>e.operator===d)??x[0],C=b!==void 0&&(P.isTimestamp(b.type)||P.isDate(b.type)),w=b!==void 0&&r!==void 0&&(dI(b.type)||P.isBool(b.type)),T=b?.name;(0,_I.useEffect)(()=>{if(!w||!T||!r||_[T])return;let e=!0;return r(T).then(t=>e&&v(e=>({...e,[T]:t}))).catch(()=>e&&v(e=>({...e,[T]:[]}))),()=>{e=!1}},[w,T,r]);let E=w&&T?_[T]??[]:[],D=e=>{let r=vI.find(t=>t.id===e);if(!r||!b)return;if(o)return o({...a??{},[b.name]:r.id});let s=r.start((i??(()=>new Date))()).toISOString().slice(0,10);n([...t.filter(e=>e.column!==b.name||e.operator!==sx.GTE),{column:b.name,operator:sx.GTE,values:[{kind:{case:`temporalValue`,value:s}}]}])};return(0,gI.jsxs)(`div`,{className:[`sf-filters`,s].filter(Boolean).join(` `),children:[(t.length>0||Object.keys(a??{}).length>0)&&(0,gI.jsxs)(`ul`,{className:`sf-filter-chips`,"aria-label":z(`filter.active`),children:[Object.entries(a??{}).map(([e,t])=>(0,gI.jsxs)(`li`,{className:`sf-filter-chip`,"data-relative":`true`,children:[(0,gI.jsxs)(`span`,{children:[e,`: `,FC(t).toLowerCase()]}),(0,gI.jsx)(`button`,{type:`button`,"aria-label":z(`filter.remove`,{filter:`${e}: ${FC(t).toLowerCase()}`}),onClick:()=>o?.(Object.fromEntries(Object.entries(a??{}).filter(([t])=>t!==e))),children:(0,gI.jsx)(rI,{icon:`close`})})]},`relative-${e}`)),t.map((e,r)=>(0,gI.jsxs)(`li`,{className:`sf-filter-chip`,children:[(0,gI.jsx)(`span`,{children:mI(e)}),(0,gI.jsx)(`button`,{type:`button`,"aria-label":z(`filter.remove`,{filter:mI(e)}),onClick:()=>n(t.filter((e,t)=>t!==r)),children:(0,gI.jsx)(rI,{icon:`close`})})]},`${mI(e)}-${r}`))]}),(0,gI.jsxs)(`form`,{className:`sf-filter-form`,onSubmit:e=>{if(e.preventDefault(),b&&S)try{let e=S.value?[pI(p,b.type)]:[];n([...t,{column:b.name,operator:S.operator,values:e}]),m(``),g(void 0)}catch(e){g(e instanceof Error?e.message:String(e))}},"aria-label":z(`filter.form`),children:[(0,gI.jsx)(`select`,{className:`sf-input`,"aria-label":z(`filter.column`),value:b?.name??``,disabled:y.length===0,onChange:e=>{u(e.target.value),f(void 0),g(void 0)},children:y.map(e=>(0,gI.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,gI.jsx)(`select`,{className:`sf-input`,"aria-label":z(`filter.comparison`),value:S?.operator??``,disabled:y.length===0,onChange:e=>f(Number(e.target.value)),children:x.map(e=>(0,gI.jsx)(`option`,{value:e.operator,children:e.label},e.operator))}),S?.value&&(0,gI.jsx)(`input`,{className:`sf-input sf-filter-value`,"aria-label":z(`filter.value`),"aria-invalid":h?!0:void 0,"aria-describedby":h?`${c}-problem`:void 0,placeholder:E.length>0?z(`filter.typeOrPick`):z(`filter.value`),type:C?`date`:`text`,list:E.length>0?`${c}-values`:void 0,value:p,onChange:e=>{m(e.target.value),g(void 0)}}),E.length>0&&(0,gI.jsx)(`datalist`,{id:`${c}-values`,children:E.map(e=>(0,gI.jsx)(`option`,{value:e},e))}),(0,gI.jsx)(`button`,{type:`submit`,className:`sf-button`,disabled:y.length===0,children:z(`filter.add`)}),C&&(0,gI.jsxs)(`select`,{className:`sf-input`,"aria-label":z(`filter.quickRange`),value:``,onChange:e=>D(e.target.value),children:[(0,gI.jsx)(`option`,{value:``,children:z(`filter.quickRangeChoose`)}),vI.map(e=>(0,gI.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),h&&(0,gI.jsx)(`span`,{id:`${c}-problem`,className:`sf-filter-problem`,role:`alert`,children:h})]})]})}var gI,_I,vI,yI,bI,xI,SI,CI=n((()=>{gI=HA(),vS(),_p(),_I=jM(),rw(),BA(),uI(),vI=[{id:`7d`,get label(){return z(`filter.range7d`)},start:e=>new Date(e.getTime()-6048e5)},{id:`30d`,get label(){return z(`filter.range30d`)},start:e=>new Date(e.getTime()-2592e6)},{id:`90d`,get label(){return z(`filter.range90d`)},start:e=>new Date(e.getTime()-7776e6)},{id:`12m`,get label(){return z(`filter.range12m`)},start:e=>new Date(Date.UTC(e.getUTCFullYear()-1,e.getUTCMonth(),e.getUTCDate()))},{id:`month`,get label(){return z(`filter.rangeMonth`)},start:e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1))},{id:`year`,get label(){return z(`filter.rangeYear`)},start:e=>new Date(Date.UTC(e.getUTCFullYear(),0,1))}],yI=[{operator:sx.EQ,label:`=`,value:!0},{operator:sx.NEQ,label:`≠`,value:!0},{operator:sx.GT,label:`>`,value:!0},{operator:sx.GTE,label:`≥`,value:!0},{operator:sx.LT,label:`<`,value:!0},{operator:sx.LTE,label:`≤`,value:!0}],bI=[{operator:sx.IS_NULL,get label(){return z(`filter.isEmpty`)},value:!1},{operator:sx.IS_NOT_NULL,get label(){return z(`filter.isNotEmpty`)},value:!1}],xI=[{operator:sx.CONTAINS,get label(){return z(`filter.contains`)},value:!0},{operator:sx.EQ,get label(){return z(`filter.is`)},value:!0},{operator:sx.NEQ,get label(){return z(`filter.isNot`)},value:!0},{operator:sx.STARTS_WITH,get label(){return z(`filter.startsWith`)},value:!0},{operator:sx.ENDS_WITH,get label(){return z(`filter.endsWith`)},value:!0}],SI=[...xI,...yI,...bI]}));function wI(e,t,n){return{baseSql:n.sql,filters:n.filters,parameters:n.parameters,groupBy:e.filter(e=>!NI(e)).map(MI),buckets:e.filter(NI).map(e=>({column:MI(e),by:{case:`grain`,value:_F[NI(e)]}})),aggregates:sF(t).map(e=>({function:gF[e.measure.aggregate],column:e.measure.column??``,alias:e.column,percentile:e.measure.aggregate===`percentile`?e.measure.percentile??.9:0})),sorts:e.map(e=>({column:MI(e),direction:ax.ASC})),page:e.length>0?{limit:n.limit}:void 0}}function TI(e,t,n){if(e==null)return z(`pivot.none`);let r=t?JN(e,t).text:String(e);return n?n===`quarter`?`${r.slice(0,4)} Q${Math.floor(Number(r.slice(5,7))/3-1/3)+1}`:r.slice(0,FI[n]??r.length):r}function EI(e,t,n){let r=t.map(t=>{let n=e.getChild(MI(t));return{vector:n,type:n?.type,grain:NI(t)}}),i=n.map(t=>{let n=e.getChild(t);return{vector:n,type:n?.type}}),a={values:new Map,keys:[]};for(let t=0;t<e.numRows;t++){let e=r.map(e=>e.vector?.get(t)??null),n=e.map(e=>e==null?`\0`:String(e)).join(II);a.values.has(n)||a.keys.push({id:n,labels:e.map((e,t)=>TI(e,r[t].type,r[t].grain)),order:e}),a.values.set(n,i.map(e=>{let n=e.vector?.get(t);return n==null||!e.type?``:JN(n,e.type).text}))}return a}function DI(e,t){for(let n=0;n<e.length;n++){let[r,i]=[e[n],t[n]];if(r!==i)return r==null?1:i==null?-1:(typeof r==`number`||typeof r==`bigint`)&&(typeof i==`number`||typeof i==`bigint`)?r<i?-1:1:String(r).localeCompare(String(i))}return 0}function OI(e){let{rows:t,columns:n,aliases:r}=e,i=EI(e.cells,[...t,...n],r),a=EI(e.rowTotals??e.cells,t,r),o=EI(e.columnTotals??e.cells,n,r),s=n.length===0?[]:[...o.keys].sort((e,t)=>DI(e.order,t.order)),c=r.map(()=>``),l=(e,r)=>[e,r].filter((e,r)=>r===0?t.length>0:n.length>0).join(II),u=e.grandTotal?EI(e.grandTotal,[],r).values.get(``):void 0;return{rowKeys:t.length===0?[{id:``,labels:[]}]:a.keys,columnKeys:s.slice(0,e.maxColumns),hiddenColumns:Math.max(0,s.length-e.maxColumns),cell:(e,t)=>i.values.get(l(e,t))??c,rowTotal:t=>(e.rowTotals?a.values.get(t):void 0)??c,columnTotal:t=>(e.columnTotals?o.values.get(t):void 0)??c,grandTotal:u??c}}function kI(e){let{sourceId:t,sql:n,rows:r,columns:i=[],measures:a,filters:o,parameters:s,timeTravel:c,notBefore:l,totals:u=!0,maxColumns:d=50,limit:f=2e4,height:p=420}=e,m=zN(e.dataSource),[h,g]=(0,jI.useState)({loading:!0}),_=(0,jI.useMemo)(()=>sF(a),[JSON.stringify(a)]),v=a.every(e=>e.aggregate===`sum`||e.aggregate===`count`||e.aggregate===`count_distinct`)?`pivot.total`:`pivot.all`,y=JSON.stringify([t,n,r,i,a,o,s,c,l,u,d,f],(e,t)=>typeof t==`bigint`?`${t}n`:t);(0,jI.useEffect)(()=>{let e=new AbortController;if(g(e=>({...e,loading:!0,error:void 0})),a.length===0||r.length+i.length===0){g({loading:!1});return}let p={sql:n,filters:o,parameters:s,limit:f+1},h=n=>JS(m.execute({sourceId:t,timeTravel:c,notBefore:l,query:wI(n,a,p)},{signal:e.signal})).then(e=>(v.push(...cP(e.header.notices)),e.table)),v=[],y=i.length>0&&r.length>0;return Promise.all([h([...r,...i]),u&&y?h(r):void 0,u&&y?h(i):void 0,u?h([]):void 0]).then(([t,n,a,o])=>{if(e.signal.aborted)return;let s=OI({rows:r,columns:i,aliases:_.map(e=>e.column),cells:t,rowTotals:n,columnTotals:a,grandTotal:o,maxColumns:d});g({loaded:{model:s,truncated:t.numRows>f,empty:t.numRows===0,notes:[...new Set(v)]},loading:!1})}).catch(t=>{e.signal.aborted||g({error:rP(t),loading:!1})}),()=>e.abort()},[m,y]);let b=[`sf-pivot`,e.className].filter(Boolean).join(` `);if(h.error)return(0,AI.jsx)(`div`,{className:b,children:(0,AI.jsx)(`p`,{className:`sf-chart-message`,role:`alert`,"data-error":h.error,children:e.errorMessage??h.error})});let x=h.loaded?.model;if(!x)return(0,AI.jsx)(`div`,{className:b,"aria-busy":h.loading,children:(0,AI.jsx)(`p`,{className:`sf-chart-message`,children:h.loading?z(`pivot.loading`):z(`pivot.choose`)})});if(h.loaded?.empty)return(0,AI.jsx)(`div`,{className:b,"aria-busy":h.loading,children:(0,AI.jsx)(`p`,{className:`sf-chart-message`,children:e.emptyMessage??z(`pivot.empty`)})});let S=x.columnKeys.length>0,C=S&&_.length>1,w=u&&S&&r.length>0,T=u&&r.length>0,E=(e,t,n=!1)=>e.map((e,r)=>(0,AI.jsx)(`td`,{className:`sf-pivot-value`,"data-total":n||void 0,children:e},`${t}-${r}`));return(0,AI.jsxs)(`div`,{className:b,"aria-busy":h.loading,children:[(0,AI.jsx)(`div`,{className:`sf-pivot-scroll`,style:{maxHeight:p},tabIndex:0,role:`region`,"aria-label":e.label??z(`pivot.label`),children:(0,AI.jsxs)(`table`,{children:[(0,AI.jsxs)(`thead`,{children:[(0,AI.jsxs)(`tr`,{children:[r.map(e=>(0,AI.jsx)(`th`,{scope:`col`,rowSpan:C?2:1,children:PI(e)},MI(e))),S?x.columnKeys.map(e=>(0,AI.jsx)(`th`,{scope:`colgroup`,colSpan:_.length,className:`sf-pivot-value`,children:e.labels.join(` / `)},e.id)):_.map(e=>(0,AI.jsx)(`th`,{scope:`col`,className:`sf-pivot-value`,children:e.label},e.column)),w&&(0,AI.jsx)(`th`,{scope:`colgroup`,colSpan:_.length,className:`sf-pivot-value`,"data-total":!0,children:z(v)})]}),C&&(0,AI.jsx)(`tr`,{children:[...x.columnKeys,...w?[{id:`total`}]:[]].flatMap(e=>_.map(t=>(0,AI.jsx)(`th`,{scope:`col`,className:`sf-pivot-value`,"data-total":e.id===`total`||void 0,children:t.label},`${e.id}-${t.column}`)))})]}),(0,AI.jsx)(`tbody`,{children:x.rowKeys.map(e=>(0,AI.jsxs)(`tr`,{children:[e.labels.map((e,t)=>(0,AI.jsx)(`th`,{scope:`row`,children:e},t)),S?x.columnKeys.flatMap(t=>E(x.cell(e.id,t.id),t.id)):E(x.cell(e.id,``),`value`),w&&E(x.rowTotal(e.id),`total`,!0)]},e.id))}),T&&(0,AI.jsx)(`tfoot`,{children:(0,AI.jsxs)(`tr`,{children:[(0,AI.jsx)(`th`,{scope:`row`,colSpan:r.length,children:z(v)}),S?x.columnKeys.flatMap(e=>E(x.columnTotal(e.id),e.id,!0)):E(x.grandTotal,`value`,!0),w&&E(x.grandTotal,`total`,!0)]})})]})}),h.loaded&&h.loaded.notes.length>0&&(0,AI.jsx)(`p`,{className:`sf-chart-note`,role:`note`,children:h.loaded.notes.join(` `)}),h.loaded?.truncated&&(0,AI.jsx)(`p`,{className:`sf-chart-note`,children:z(`pivot.truncated`,{limit:LI.format(f)})}),x.hiddenColumns>0&&(0,AI.jsx)(`p`,{className:`sf-chart-note`,children:z(`pivot.hiddenColumns`,{shown:LI.format(x.columnKeys.length),total:LI.format(x.columnKeys.length+x.hiddenColumns)})})]})}var AI,jI,MI,NI,PI,FI,II,LI,RI=n((()=>{AI=HA(),rw(),vS(),jI=jM(),vF(),UN(),fP(),tP(),BA(),oP(),MI=e=>typeof e==`string`?e:e.column,NI=e=>typeof e==`string`?void 0:e.grain,PI=e=>typeof e==`string`?e:e.label??e.column,FI={year:4,month:7,day:10,week:10,hour:16,minute:16},II=``,LI={format:e=>jA().format(e)}}));function zI(e,t){let n=t&&/^[=+\-@\t\r]/.test(e)?`'${e}`:e;return/[",\n\r]/.test(n)?`"${n.replace(/"/g,`""`)}"`:n}function BI(e){return`${e.map(e=>zI(e.name,!0)).join(`,`)}\r\n`}function VI(e,t){return`${e.map((e,n)=>{let r=t[n];return r==null?``:zI(P.isFloat(e.type)?String(r):JN(r,e.type).text,WI(e.type))}).join(`,`)}\r\n`}async function HI(e,t,n={}){let r=[],i,a=[],o=0,s=!1;for await(let c of e.execute(t,{signal:n.signal})){let e=c.part;if(e.case===`header`)i=e.value.arrowSchema,a=Cp(i,[]).schema.fields,r.push(BI(a));else if(e.case===`batch`&&i){let t=Cp(i,[e.value.arrowBatch]),s=a.map((e,n)=>t.getChildAt(n)),c=``;for(let e=0;e<t.numRows;e++)c+=VI(a,s.map(t=>t?.get(e)));r.push(c),o+=t.numRows,n.onProgress?.(o)}else e.case===`footer`&&(s=e.value.truncated)}if(!i)throw Error(`The result ended before it began.`);return{blob:new Blob([``,...r],{type:`text/csv;charset=utf-8`}),rows:o,truncated:s}}function UI(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}var WI,GI=n((()=>{rw(),_p(),tP(),WI=e=>!(P.isInt(e)||P.isFloat(e)||P.isDecimal(e)||P.isBool(e)||P.isTimestamp(e)||P.isDate(e))}));function KI(e){if(typeof e!=`object`||!e)return;let t=e,n=String(t.name??t[`Node Type`]??t.operator??``).trim();if(!n)return;let r=[],i=(e,t)=>{t!=null&&t!==``&&typeof t!=`object`&&r.push([e,String(t)])},a=t.extra_info;if(typeof a==`object`&&a)for(let[e,t]of Object.entries(a))i(e,Array.isArray(t)?t.join(`, `):t);for(let e of[`Relation Name`,`Plan Rows`,`Total Cost`,`Filter`,`Join Type`])i(e,t[e]);let o=t.children??t.Plans;return{name:n,details:r,children:Array.isArray(o)?o.map(KI).filter(e=>e!==void 0):[]}}function qI(e){if(!e.trim())return[];try{let t=JSON.parse(e);return(Array.isArray(t)?t:[t]).map(e=>KI(e?.Plan??e)).filter(e=>e!==void 0)}catch{return[]}}function JI({node:e}){return(0,XI.jsxs)(`li`,{children:[(0,XI.jsxs)(`span`,{className:`sf-plan-step`,children:[(0,XI.jsx)(`strong`,{children:e.name.replace(/_/g,` `)}),e.details.map(([e,t])=>(0,XI.jsxs)(`span`,{className:`sf-plan-detail`,children:[e,`: `,t]},e))]}),e.children.length>0&&(0,XI.jsx)(`ul`,{children:e.children.map((e,t)=>(0,XI.jsx)(JI,{node:e},t))})]})}function YI(e){let{sourceId:t,sql:n,filters:r}=e,i=zN(e.dataSource),[a,o]=(0,ZI.useState)({steps:[],text:``,executedSql:``,loading:!0}),s=JSON.stringify([t,n,r],(e,t)=>typeof t==`bigint`?`${t}n`:t);return(0,ZI.useEffect)(()=>{let e=new AbortController;return o(e=>({...e,loading:!0,error:void 0})),i.explain({sourceId:t,query:{baseSql:n,filters:r}},{signal:e.signal}).then(t=>{e.signal.aborted||o({steps:qI(t.planJson),text:t.planText,executedSql:t.executedSql,loading:!1})}).catch(t=>{e.signal.aborted||o({steps:[],text:``,executedSql:``,error:rP(t),loading:!1})}),()=>e.abort()},[i,s]),a.error?(0,XI.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:a.error}):a.loading?(0,XI.jsx)(`p`,{className:`sf-object-muted`,children:`Asking the engine for its plan…`}):(0,XI.jsxs)(`div`,{className:[`sf-plan`,e.className].filter(Boolean).join(` `),children:[a.steps.length>0&&(0,XI.jsx)(`ul`,{className:`sf-plan-tree`,"aria-label":`Plan steps, outermost first`,children:a.steps.map((e,t)=>(0,XI.jsx)(JI,{node:e},t))}),a.text&&(0,XI.jsxs)(`details`,{open:a.steps.length===0,children:[(0,XI.jsx)(`summary`,{children:`The engine's plan text`}),(0,XI.jsx)(`pre`,{tabIndex:0,children:a.text})]}),a.steps.length===0&&!a.text&&(0,XI.jsx)(`p`,{className:`sf-object-muted`,children:`The engine returned no plan.`})]})}var XI,ZI,QI=n((()=>{XI=HA(),ZI=jM(),UN(),oP()}));function $I(e,t,n,r){return[fL,(i,a)=>{let o=r?i[0].toLowerCase():i[0];if(n.has(o))return`literal`;if(e.has(o))return`keyword`;if(t.has(o))return`type`;if(/^\s*\(/.test(a))return`function`}]}function eL(e){let t=(e??``).trim().toLowerCase();if(!t)return;let n=_L[t]??t;return n in gL?n:void 0}function tL(e,t){let n=gL[eL(t)??``];if(!n||e.length>1e5)return[{text:e}];let r=[],i=(e,t)=>{let n=r[r.length-1];n&&n.kind===t?n.text+=e:r.push(t?{text:e,kind:t}:{text:e})},a=0;outer:for(;a<e.length;){for(let[t,r]of n){t.lastIndex=a;let n=t.exec(e);if(!n||n[0].length===0)continue;let o=typeof r==`function`?r(n,e.slice(a+n[0].length,a+n[0].length+4)):r;i(n[0],o),a+=n[0].length;continue outer}i(e[a]),a++}return r}var nL,rL,iL,aL,oL,sL,cL,lL,uL,dL,fL,pL,mL,hL,gL,_L,vL=n((()=>{nL=e=>new Set(e.split(/\s+/).filter(Boolean)),rL=nL(`
|
|
21
|
+
`)}var yM,bM,xM,SM,CM=n((()=>{mj(),fM(),yM=`--sf`,bM={fast:120,base:200,slow:320,ease:`cubic-bezier(0.2, 0, 0, 1)`,easeOut:`cubic-bezier(0, 0, 0.2, 1)`,spring:`cubic-bezier(0.34, 1.3, 0.64, 1)`,springy:520,gummy:`linear(0, 0.116, 0.366, 0.639, 0.867, 1.021, 1.103, 1.126, 1.113, 1.082, 1.047, 1.018, 0.998, 0.987, 0.984, 0.986, 0.99, 0.994, 0.998, 1, 1)`,gummyFallback:`cubic-bezier(0.34, 1.45, 0.64, 1)`,pressScale:.97},xM={"glass-alpha-regular":`1`,"glass-alpha-thick":`1`,"glass-alpha-clear":`1`,"glass-blur":`0px`,"glass-saturate":`100%`},SM={...xM,"glass-edge-alpha":`0.6`,"glass-highlight-alpha":`0`,"color-edge":`var(${yM}-color-border-strong)`}}));function wM(e,t){let n=aM(e),r=n[t],i={color:r.text,fontFamily:n.fontFamily,fontSize:n.scale.fontSize-2},a={axisLine:{show:!0,lineStyle:{color:r.borderStrong}},axisTick:{show:!1},axisLabel:{color:r.muted,fontFamily:n.fontFamily},splitLine:{show:!0,lineStyle:{color:r.border}},splitArea:{show:!1},nameTextStyle:{color:r.muted}};return{color:r.series,animationDuration:420,animationDurationUpdate:280,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`,backgroundColor:`transparent`,textStyle:i,title:{textStyle:{color:r.text,fontFamily:n.fontFamily,fontWeight:600},subtextStyle:{color:r.muted,fontFamily:n.fontFamily}},legend:{textStyle:{color:r.muted,fontFamily:n.fontFamily},inactiveColor:r.borderStrong},tooltip:{backgroundColor:r.surface,borderColor:r.border,borderWidth:1,textStyle:{color:r.text,fontFamily:n.fontFamily,fontSize:n.scale.fontSize-1},padding:[n.scale.unit*2,n.scale.unit*3],extraCssText:`border-radius: ${Math.min(n.radius,12)}px; box-shadow: none;`,axisPointer:{lineStyle:{color:r.borderStrong},crossStyle:{color:r.borderStrong}}},categoryAxis:{...a,splitLine:{show:!1}},valueAxis:{...a,axisLine:{show:!1}},timeAxis:{...a,splitLine:{show:!1}},logAxis:{...a,axisLine:{show:!1}},line:{symbol:`circle`,symbolSize:6,lineStyle:{width:2},smooth:!1,emphasis:{scale:1.6},endLabel:{color:r.text,fontFamily:n.fontFamily,textBorderWidth:0}},bar:{barMaxWidth:40,itemStyle:{borderRadius:[Math.min(n.radius,4),Math.min(n.radius,4),0,0],borderColor:r.surface,borderWidth:1}},pie:{itemStyle:{borderColor:r.surface,borderWidth:2},label:{color:r.text}},scatter:{symbolSize:8,itemStyle:{borderColor:r.surface,borderWidth:1}},heatmap:{itemStyle:{borderColor:r.surface,borderWidth:2}},visualMap:{textStyle:{color:r.muted},inRange:{color:r.sequential}},dataZoom:{borderColor:r.border,backgroundColor:`transparent`,dataBackground:{lineStyle:{color:r.borderStrong},areaStyle:{color:r.border}},fillerColor:nj(r.background,r.accent,.2),handleStyle:{color:r.accent,borderColor:r.accent},textStyle:{color:r.muted}},toolbox:{iconStyle:{borderColor:r.muted},emphasis:{iconStyle:{borderColor:r.accent}}}}}var TM=n((()=>{mj(),fM()}));function EM(e,t,n={}){let r=[],i=n.themes??[],a=t;if(e.preset!==void 0){let t=typeof e.preset==`string`?Yj(e.preset,i):void 0;t?a=t:r.push(`There is no theme called ${String(e.preset)}. Choose from ${DM(i).join(`, `)}.`)}if(e.accent!==void 0){if(!JA(e.accent))r.push(`The accent must be a hex colour like #2F5BEA.`);else{let t=Bj(a,e.accent),n=[`light`,`dark`].filter(e=>tj(iM(t[e]).accent,t[e].background)<3);n.length>0?r.push(`That accent is too close to the ${n.join(` and `)} background to see, so it was not used.`):a=t}}if(e.radius!==void 0&&(typeof e.radius!=`number`||!Number.isFinite(e.radius)?r.push(`The corner radius must be a number.`):a={...a,radius:Math.max(0,Math.min(28,Math.round(e.radius)))}),e.font!==void 0&&(Hj.includes(e.font)?a={...a,font:e.font}:r.push(`The font must be one of ${Hj.join(`, `)}.`)),e.density!==void 0&&(Uj.includes(e.density)?a={...a,density:e.density}:r.push(`The density must be one of ${Uj.join(`, `)}.`)),e.seriesOrder!==void 0){if(!kj.includes(e.seriesOrder))r.push(`The chart colours must be one of ${kj.join(`, `)}.`);else{let t={light:_j(e.seriesOrder,`light`),dark:_j(e.seriesOrder,`dark`)};[`light`,`dark`].some(e=>Sj(t[e].series,a[e].surface).some(e=>e.severity===`error`))?r.push(`Those chart colours cannot be told apart on this theme, so they were not used.`):a=zj(a,t)}}let o;return e.mode!==void 0&&(Gj.includes(e.mode)?o=e.mode:r.push(`The mode must be one of ${Gj.join(`, `)}.`)),!Zj.includes(a)&&!i.includes(a)&&a!==t&&(a={...a,name:`Custom`}),{theme:a,...o?{mode:o}:{},problems:r}}function DM(e=[]){let t=Zj.map(e=>e.name);for(let n of e)t.some(e=>e.toLowerCase()===n.name.toLowerCase())||t.push(n.name);return t}var OM,kM=n((()=>{Mj(),mj(),fM(),$j(),Jj(),OM={presets:Zj.map(e=>e.name),modes:Gj,fonts:Hj,densities:Uj,seriesOrders:kj,radius:[0,28]}})),AM=n((()=>{})),jM=n((()=>{mj(),Mj(),Jj(),$j(),fM(),CM(),TM(),kM(),AM()})),MM=r((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,re(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+A(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+A(a,u),c+=re(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+A(a,u++),c+=re(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return re(ne(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ie(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ae(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var oe=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function se(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,oe)}catch(e){oe(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ce(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else se(ce.bind(null,e))}var le={map:ie,forEach:function(e,t,n){ie(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ie(e,function(){t++}),t},toArray:function(e){return ie(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=le,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ce,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ae}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=se,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),NM=r(((e,t)=>{t.exports=MM()}));function PM(e){if(e)try{let t=JSON.parse(e);return!t||typeof t!=`object`?void 0:{theme:Fj(t.theme,Qj),mode:Gj.includes(t.mode)?t.mode:`system`}}catch{return}}function FM(e){let t=globalThis.matchMedia?.(UM);return t?(t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)):()=>{}}function IM(){return(0,BM.useSyncExternalStore)(FM,WM,()=>!1)}function LM({children:e,initialTheme:t=Qj,initialMode:n=`system`,storage:r,storageKey:i=`surfaces.theme`,scope:a=`root`,themes:o}){let s=(0,BM.useContext)(VM),c=o??s?.themes??HM,l=(0,BM.useMemo)(()=>r===void 0?tw():r,[r]),u=(0,BM.useRef)(!1),[d,f]=(0,BM.useState)({theme:t,mode:n}),p=`sf-${(0,BM.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,m=IM();(0,BM.useEffect)(()=>{if(!l)return;let e=!1;return Promise.resolve(l.load(i)).then(t=>{let n=PM(t);n&&!e&&!u.current&&f(n)}).catch(()=>{}),()=>{e=!0}},[l,i]);let h=(0,BM.useCallback)(e=>{u.current=!0,f(t=>{if(Object.entries(e).every(([e,n])=>t[e]===n))return t;let n={...t,...e};return l&&Promise.resolve(l.save(i,JSON.stringify(n))).catch(()=>{}),n})},[l,i]),g=(0,BM.useMemo)(()=>vM(d.theme,a===`root`?{}:{selector:`[data-sf-scope="${p}"]`}),[d.theme,a,p]);(0,BM.useEffect)(()=>{if(a!==`root`)return;let e=document.documentElement;d.mode===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,d.mode)},[a,d.mode]),(0,BM.useEffect)(()=>{if(a!==`root`)return;let e=document.documentElement;d.theme.contrast===`more`?e.setAttribute(`data-contrast`,`more`):e.removeAttribute(`data-contrast`)},[a,d.theme.contrast]);let _=(0,BM.useCallback)(e=>h({theme:e}),[h]),v=(0,BM.useCallback)(e=>h({mode:e}),[h]),y=(0,BM.useMemo)(()=>({...d,setTheme:_,setMode:v,resolvedMode:d.mode===`system`?m?`dark`:`light`:d.mode,themes:c}),[d,_,v,m,c]);return(0,zM.jsxs)(VM.Provider,{value:y,children:[(0,zM.jsx)(`style`,{"data-sf-theme":a===`root`?`root`:p,children:g}),a===`root`?e:(0,zM.jsx)(`div`,{className:`sf-scope`,"data-sf-scope":p,"data-theme":d.mode===`system`?void 0:d.mode,children:e})]})}function RM(){return(0,BM.useContext)(VM)}var zM,BM,VM,HM,UM,WM,GM=n((()=>{zM=WA(),jM(),BM=NM(),rw(),VM=(0,BM.createContext)(void 0),HM=[],UM=`(prefers-color-scheme: dark)`,WM=()=>globalThis.matchMedia?.(UM).matches??!1})),KM=n((()=>{WA(),NM()}));function qM(e,t={},n=0){let{maxString:r=2e4,maxItems:i=500,maxDepth:a=16}=t;if(e==null)return null;switch(typeof e){case`boolean`:return e;case`number`:return Number.isFinite(e)?e:String(e);case`bigint`:return e>=BigInt(-(2**53-1))&&e<=BigInt(2**53-1)?Number(e):e.toString();case`string`:return e.length>r?`${e.slice(0,r)}… [${e.length-r} more characters]`:e;case`function`:case`symbol`:return null}if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return{"@bytes":e.byteLength};if(typeof Blob<`u`&&e instanceof Blob)return{"@bytes":e.size};if(e instanceof Date)return Number.isNaN(e.getTime())?null:e.toISOString();if(e instanceof Error)return JM(e);if(n>=a)return`[deeper than is kept]`;if(e instanceof Map)return qM(Object.fromEntries(e),t,n);if(e instanceof Set)return qM([...e],t,n);if(Array.isArray(e)){let r=e.slice(0,i).map(e=>qM(e,t,n+1));return e.length>i&&r.push(`[${e.length-i} more]`),r}let o={};for(let[r,i]of Object.entries(e))r.startsWith(`$`)||i===void 0||typeof i==`function`||typeof i==`symbol`||(o[r]=tN(r)&&(typeof i==`string`?i!==``:typeof i==`object`&&i)?QM:qM(i,t,n+1));return o}function JM(e){if(!(e instanceof Error))return{message:typeof e==`string`?e:String(e)};let t={message:e.message.slice(0,4e3)};e.name&&e.name!==`Error`&&(t.name=e.name);for(let n of[`code`,`line`,`column`,`engineCode`]){let r=e[n];(typeof r==`string`||typeof r==`number`)&&(t[n]=r)}return t}var YM,XM,ZM,QM,$M,eN,tN,nN=n((()=>{YM=e=>{let t=new Uint8Array(e),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return t.every(e=>e===0)&&(t[e-1]=1),Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)},XM=()=>YM(16),ZM=()=>YM(8),QM=`[withheld]`,$M=/pass(word|wd|phrase)|secret|token|api[-_]?key|authorization|credential|private[-_]?key|cookie|session[-_]?key/i,eN=/^(secret|secretName|tokenBudget|maxTokens|inputTokens|outputTokens|contextTokens|nextPageToken|pageToken)$/,tN=e=>$M.test(e)&&!eN.test(e)}));function rN(e){if(e&&typeof e==`object`)for(let t of uN){let n=e[t];if(n&&typeof n==`object`)return{kind:t,surfaceId:String(n.surfaceId??``)}}}function iN(e,t,n){let r=rN(t.message??t.raw),i=t.issues??[],a=t.applied!==!1,o=qM(t.raw),s=t.message===void 0?void 0:qM(t.message);return e.record({kind:`message`,name:t.name??r?.kind??t.format,status:!a||t.error?`error`:i.length>0?`warning`:`ok`,surfaceId:t.key,detail:{format:t.format,raw:o,...s!==void 0&&JSON.stringify(s)!==JSON.stringify(o)?{message:s}:{},...typeof t.raw?.version==`string`?{version:t.raw.version}:{},issues:i.map(e=>({path:e.path,message:e.message})),applied:a,...t.error?{error:t.error}:{},...t.snapshot?{snapshot:!0}:{},...t.replay===!1?{replay:!1}:{}}},n)}var aN,oN,sN,cN,lN,uN,dN=n((()=>{nN(),aN=`data-sf-inspect`,oN=`data-sf-component`,sN=`data-sf-pointed`,cN=0,lN=(e=`s`)=>`${e}${++cN}`,uN=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`]}));function fN(e,t=0){if(typeof e!=`object`||!e||ArrayBuffer.isView(e))return{};let n={};for(let[r,i]of Object.entries(e))if(!(r.startsWith(`$`)||i==null||typeof i==`function`)){if(typeof i==`number`||typeof i==`boolean`||typeof i==`bigint`)n[r]=qM(i);else if(typeof i==`string`){if(i===``)continue;n[r]=vN.has(r)?qM(i,{maxString:4e3}):{"@text":i.length}}else if(Array.isArray(i))n[r]=r===`notices`?qM(i,{maxItems:20,maxString:1e3}):{"@count":i.length};else if(ArrayBuffer.isView(i)||i instanceof ArrayBuffer)n[r]={"@bytes":i.byteLength};else if(t<2){let e=fN(i,t+1);Object.keys(e).length>0&&(n[r]=e)}}return n}function pN(e,t,n,r){return{[Symbol.asyncIterator](){let i=e[Symbol.asyncIterator]();return{async next(){try{let e=await i.next();return e.done?t.end({detail:{response:n.result()}}):n.add(e.value),e}catch(e){throw t.end({...xN(e,r),detail:{...xN(e,r).detail,response:n.result()}}),e}},async return(e){return t.end({detail:{response:n.result(),stoppedEarly:!0}}),i.return?i.return(e):{done:!0,value:e}},async throw(e){if(t.end(xN(e)),i.throw)return i.throw(e);throw e}}}}}function mN(e,t,n,r={}){let i=_N(t),a=i&&i.recorder===n?i.target:t,o=i&&i.recorder===n?{...i.options,...r}:r,s=i&&i.recorder===n?i.name:e,c=new Map,l={target:a,recorder:n,name:s,options:o},u=()=>typeof o.scope==`function`?o.scope():o.scope;return new Proxy(a,{get(e,t){if(t===gN)return l;let r=Reflect.get(e,t,e);if(typeof r!=`function`||typeof t!=`string`)return r;let i=c.get(t);if(i&&i.of===r)return i.fn;let a=(...i)=>{let a=n.start({kind:`service`,name:`${s}.${t}`,detail:{service:s,method:t,request:qM(i[0])}},u()),c=i[1]?.signal,l;try{l=r.apply(e,i)}catch(e){throw a.end(xN(e,c)),e}let d=o.responses?.[t]??fN;return yN(l)?pN(l,a,o.streams?.[t]?.()??SN(),c):bN(l)?Promise.resolve(l).then(e=>(a.end({detail:{response:d(e)}}),e),e=>{throw a.end(xN(e,c)),e}):(a.end({detail:{response:d(l)}}),l)};return c.set(t,{fn:a,of:r}),a}})}function hN(){let e={},t=0,n=0,r=0;return{add(i){let{case:a,value:o}=CN(i);o&&(a===`header`?(typeof o.executedSql==`string`&&(e.executedSql=qM(o.executedSql)),typeof o.queryId==`string`&&o.queryId&&(e.queryId=o.queryId),o.rewriteMode!==void 0&&(e.rewriteMode=qM(o.rewriteMode)),Array.isArray(o.notices)&&(e.notices=qM(o.notices,{maxItems:20,maxString:1e3})),Array.isArray(o.columns)&&(e.columns=o.columns.slice(0,200).map(e=>({name:String(e?.name??``),type:String(e?.nativeType??``)}))),o.stored&&typeof o.stored==`object`&&(e.stored=fN(o.stored))):a===`batch`?(t++,n+=Number(o.rowCount??0),r+=ArrayBuffer.isView(o.arrowBatch)?o.arrowBatch.byteLength:0):a===`footer`&&(e.totalRows=qM(o.totalRowsReturned??n),e.truncated=o.truncated===!0,e.elapsedMs=qM(o.elapsedMs??0),o.nextCursor&&(e.more=!0)))},result:()=>({...e,batches:t,rows:n,bytes:r})}}var gN,_N,vN,yN,bN,xN,SN,CN,wN,TN=n((()=>{nN(),gN=Symbol.for(`surfaces-ui.traced`),_N=e=>e&&typeof e==`object`?e[gN]:void 0,vN=new Set(`executedSql.queryId.planText.code.message.name.id.version.generatedBy.sessionId.status.state.kind.format.type.engine.dialect.sourceId.table.schema.catalog.column.nextCursor.nextPageToken.pipelineId.runId.trigger.startedBy`.split(`.`)),yN=e=>!!e&&typeof e==`object`&&Symbol.asyncIterator in e,bN=e=>!!e&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`,xN=(e,t)=>{let n=e instanceof Error&&e.name===`AbortError`||t?.aborted===!0;return{status:n?`warning`:`error`,detail:{error:JM(e),...n?{cancelled:!0}:{}}}},SN=()=>{let e=0;return{add:()=>void e++,result:()=>({items:e})}},CN=e=>e?.part??{},wN={streams:{execute:hN}}}));function EN(e,t,n=200){let r=[],i=(e,t,a)=>{if(!(r.length>=n||e===t)){if(e===void 0)return void r.push({path:a||`/`,change:`added`,after:t});if(t===void 0)return void r.push({path:a||`/`,change:`removed`,before:e});if(DN(e)&&DN(t))for(let n of new Set([...Object.keys(e),...Object.keys(t)]))i(e[n],t[n],ON(a,n));else if(Array.isArray(e)&&Array.isArray(t))for(let n=0;n<Math.max(e.length,t.length);n++)i(e[n],t[n],ON(a,n));else JSON.stringify(e)!==JSON.stringify(t)&&r.push({path:a||`/`,change:`changed`,before:e,after:t})}};return i(e,t,``),r}var DN,ON,kN=n((()=>{DN=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ON=(e,t)=>`${e}/${String(t).replace(/~/g,`~0`).replace(/\//g,`~1`)}`})),AN=n((()=>{})),jN=n((()=>{nN(),dN(),TN(),kN(),AN()}));function MN({scope:e,children:t}){return(0,FN.createElement)(LN.Provider,{value:e},t)}function NN(e,t,n){let r=(0,FN.useContext)(IN),i=(0,FN.useContext)(LN);return(0,FN.useMemo)(()=>r&&t?mN(e,t,r,{...n,...i?{scope:i}:{}}):t,[e,t,r,i,n])}function PN(e,t){let n=(0,FN.useContext)(IN);(0,FN.useEffect)(()=>n&&t?n.provide(e,t):void 0,[n,e,t])}var FN,IN,LN,RN,zN=n((()=>{FN=NM(),TN(),IN=(0,FN.createContext)(void 0),LN=(0,FN.createContext)(void 0),RN=()=>(0,FN.useContext)(IN)}));function BN({dataSource:e,children:t}){return PN(`dataSource`,e),(0,HN.jsx)(WN.Provider,{value:e,children:t})}function VN(e){let t=(0,UN.useContext)(WN),n=NN(`DataSource`,e??t,wN);if(!n)throw Error(`No DataSource: wrap the component in <DataSourceProvider> or pass dataSource.`);return n}var HN,UN,WN,GN=n((()=>{HN=WA(),jN(),zN(),UN=NM(),WN=(0,UN.createContext)(void 0)}));function KN(e,t){if(t<=0)return e;let n=e.startsWith(`-`),r=(n?e.slice(1):e).padStart(t+1,`0`);return`${n?`-`:``}${r.slice(0,-t)}.${r.slice(-t)}`}function qN(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return String(e);let n=`${t.getUTCFullYear()}-${nP(t.getUTCMonth()+1)}-${nP(t.getUTCDate())}`,r=`${nP(t.getUTCHours())}:${nP(t.getUTCMinutes())}:${nP(t.getUTCSeconds())}`,i=t.getUTCMilliseconds();return`${n} ${r}${i?`.${nP(i,3)}`:``}`}function JN(e){return JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)}function YN(e){return P.isInt(e)||P.isFloat(e)||P.isDecimal(e)}function XN(e,t){return e==null?{text:`null`,numeric:!1,isNull:!0}:P.isDecimal(t)?{text:KN(String(e),t.scale),numeric:!0,isNull:!1}:P.isTimestamp(t)?{text:qN(Number(e)),numeric:!1,isNull:!1}:P.isDate(t)?{text:qN(Number(e)).slice(0,10),numeric:!1,isNull:!1}:P.isInt(t)?{text:String(e),numeric:!0,isNull:!1}:P.isFloat(t)?{text:NA({maximumFractionDigits:4}).format(Number(e)),numeric:!0,isNull:!1}:P.isBool(t)?{text:e?`true`:`false`,numeric:!1,isNull:!1}:typeof e==`object`?{text:JN(typeof e.toJSON==`function`?e.toJSON():e),numeric:!1,isNull:!1}:{text:String(e),numeric:typeof e==`number`||typeof e==`bigint`,isNull:!1}}function ZN(e,t,n){let r=XN(e,t);if(!n||r.isNull)return r;if(n.kind===`text`)return{...r,numeric:!1};if(n.kind===`date`||n.kind===`datetime`)return!P.isTimestamp(t)&&!P.isDate(t)?r:{...r,text:n.kind===`date`?r.text.slice(0,10):r.text.slice(0,19)};let i=P.isDecimal(t)?Number(r.text):Number(e);if(!Number.isFinite(i))return r;let a=n.decimals===void 0?{}:{minimumFractionDigits:n.decimals,maximumFractionDigits:n.decimals};return{text:NA(n.kind===`currency`?{style:`currency`,currency:n.currency??`USD`,...a}:n.kind===`percent`?{style:`percent`,maximumFractionDigits:1,...a}:n.kind===`compact`?{notation:`compact`,maximumFractionDigits:1,...a}:{maximumFractionDigits:4,...a}).format(i),numeric:!0,isNull:!1}}function QN(e,t,n){let r=ZN(e,t,n);return r.isNull?{...r,text:z(`cell.null`)}:P.isBool(t)&&n?.kind!==`text`?{...r,text:z(e?`cell.true`:`cell.false`)}:r}function $N(e,t){if(e==null)return null;let n=P.isDecimal(t)?Number(KN(String(e),t.scale)):Number(e);return Number.isFinite(n)?n:null}function eP(e,t){return e==null?null:P.isDecimal(t)?Number(KN(String(e),t.scale)):P.isTimestamp(t)?new Date(Number(e)).toISOString():P.isDate(t)?new Date(Number(e)).toISOString().slice(0,10):typeof e==`bigint`?Number(e):typeof e==`number`?e:typeof e==`boolean`?e?`true`:`false`:String(e)}function tP(e,t){return typeof e==`boolean`?e:typeof e==`bigint`&&!P.isDecimal(t)&&!P.isTimestamp(t)&&!P.isDate(t)&&!Number.isSafeInteger(Number(e))?String(e):eP(e,t)}var nP,rP=n((()=>{_p(),HA(),nP=(e,t=2)=>String(e).padStart(t,`0`)}));function iP(e,t,n={}){let r=n.blockSize??200,i=n.maxBlocks??60,a=sP(t),o=(0,oP.useMemo)(()=>t,[a]),s=(0,oP.useRef)(void 0),[,c]=(0,oP.useState)(0),[l,u]=(0,oP.useState)(``),f=l>(o.notBefore??``)?l:o.notBefore??``,[p,m]=(0,oP.useState)({status:`loading`,fields:[],executedSql:``,notices:[]}),h=(0,oP.useCallback)(t=>{let n=s.current;if(!n||n.blocks.has(t)||n.pending.has(t))return;n.pending.add(t);let{controller:a}=n;JS(e.execute({sourceId:o.sourceId,timeTravel:o.timeTravel,notBefore:f,query:{baseSql:o.sql,sorts:o.sorts,filters:o.filters,parameters:o.parameters,page:{limit:r,offset:BigInt(t*r)}}},{signal:a.signal})).then(s=>{if(a.signal.aborted)return;if(n.pending.delete(t),n.blocks.set(t,s.table),n.blocks.size>i){let e=(n.wanted[0]+n.wanted[1])/2/r,t=[...n.blocks.keys()].sort((t,n)=>Math.abs(n-e)-Math.abs(t-e));for(let e of t.slice(0,n.blocks.size-i))n.blocks.delete(e)}let l=s.header.stored,u=l?{createdAt:l.createdAt,rowCount:Number(l.rowCount)}:void 0,d;t===0&&!n.counted&&(n.counted=!0,u&&(o.filters?.length??0)===0?d=u.rowCount:s.table.numRows<r?d=s.table.numRows:e.count({sourceId:o.sourceId,timeTravel:o.timeTravel,notBefore:f,query:{baseSql:o.sql,filters:o.filters,parameters:o.parameters}},{signal:a.signal}).then(e=>{a.signal.aborted||m(t=>({...t,total:Number(e.rowCount)}))}).catch(()=>{})),m(e=>({...e,status:`ready`,stored:u,total:d??e.total,fields:s.table.schema.fields,executedSql:s.header.executedSql,notices:s.header.notices,elapsedMs:Number(s.footer.elapsedMs)})),c(e=>e+1)}).catch(e=>{if(a.signal.aborted)return;n.pending.delete(t);let r=d(e);m(e=>({...e,status:`error`,error:r.message,errorInfo:r,fields:[],executedSql:``,notices:[]}))})},[e,o,r,i,f]);(0,oP.useEffect)(()=>{let e={blocks:new Map,pending:new Set,controller:new AbortController,wanted:[0,r],timer:void 0,counted:!1};return s.current=e,m(e=>({...e,status:`loading`,error:void 0,errorInfo:void 0,total:void 0})),h(0),()=>{e.controller.abort(),e.timer&&clearTimeout(e.timer)}},[e,o,r,h]);let g=(0,oP.useCallback)((e,t)=>{let n=s.current;n&&(n.wanted=[e,t],n.timer||=setTimeout(()=>{n.timer=void 0;let[e,t]=n.wanted,i=Math.max(0,Math.floor(e/r)),a=Math.max(i,Math.floor(Math.max(t-1,e)/r));for(let e=i;e<=a;e++)h(e)},40))},[r,h]),_=(0,oP.useCallback)((e,t)=>{let n=s.current?.blocks.get(Math.floor(e/r));if(!n)return;let i=e%r;if(!(i>=n.numRows))return n.getChildAt(t)?.get(i)??null},[r]),v=(0,oP.useCallback)(e=>{let t=s.current?.blocks.get(Math.floor(e/r));return t!==void 0&&e%r<t.numRows},[r]),y=(0,oP.useCallback)(()=>u(new Date().toISOString()),[]),b=(0,oP.useCallback)(()=>{let e=s.current;e&&e.pending.size!==0&&(e.controller.abort(),e.pending.clear(),m(e=>({...e,status:`error`,error:`Cancelled.`,errorInfo:{message:`Cancelled.`,code:`CANCELLED`,line:0,column:0},fields:[],executedSql:``,notices:[]})))},[]);return{status:p.status,error:p.error,errorInfo:p.errorInfo,stored:p.stored,total:p.total,fields:p.fields,executedSql:p.executedSql,notices:p.notices,elapsedMs:p.elapsedMs,getCell:_,isLoaded:v,ensure:g,refresh:y,cancel:b}}function aP(e){return d(e).message}var oP,sP,cP=n((()=>{rw(),oP=NM(),sP=e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}n`:t)})),lP=n((()=>{}));function uP(e){return[...new Set((e??[]).filter(e=>pP.has(e.code)).map(e=>e.message))]}function dP({notes:e}){return!e||e.length===0?null:(0,fP.jsx)(`span`,{className:`sf-data-note`,role:`note`,children:e.join(` `)})}var fP,pP,mP=n((()=>{fP=WA(),pP=new Set([`FILTER_COLUMN_MISSING`])}));async function hP(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function gP(){let[e,t]=(0,vP.useState)(),n=(0,vP.useRef)(null),r=(0,vP.useCallback)(()=>{t(e=>{e?.from?.focus?.()})},[]),i=(0,vP.useCallback)((e,n,r)=>{if(r.length===0)return;e.preventDefault(),e.stopPropagation();let i=e.currentTarget,a=i.getBoundingClientRect(),o=e.clientX===0&&e.clientY===0;t({x:o?a.left+12:e.clientX,y:o?a.bottom:e.clientY,label:n,items:r,from:document.activeElement instanceof HTMLElement?document.activeElement:i})},[]),a=()=>[...n.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]];return(0,vP.useLayoutEffect)(()=>{let t=n.current;if(!e||!t)return;let r=t.getBoundingClientRect(),i=Math.max(4,Math.min(e.x,window.innerWidth-r.width-4)),o=Math.max(4,Math.min(e.y,window.innerHeight-r.height-4));t.style.left=`${i}px`,t.style.top=`${o}px`,a()[0]?.focus()},[e]),(0,vP.useEffect)(()=>{if(!e)return;let t=e=>{n.current?.contains(e.target)||r()};return document.addEventListener(`pointerdown`,t,!0),window.addEventListener(`blur`,r),window.addEventListener(`resize`,r),()=>{document.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`blur`,r),window.removeEventListener(`resize`,r)}},[e,r]),{open:i,close:r,element:e?(0,_P.jsx)(`div`,{ref:n,className:`sf-menu`,role:`menu`,"aria-label":e.label,style:{left:e.x,top:e.y},onKeyDown:e=>{let t=a(),n=t.indexOf(document.activeElement),i=n=>{e.preventDefault(),e.stopPropagation(),t[(n+t.length)%t.length]?.focus()};if(e.key===`ArrowDown`)return i(n+1);if(e.key===`ArrowUp`)return i(n-1);if(e.key===`Home`)return i(0);if(e.key===`End`)return i(t.length-1);(e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),e.stopPropagation(),r())},onContextMenu:e=>e.preventDefault(),children:e.items.map((e,t)=>e.separator?(0,_P.jsx)(`div`,{className:`sf-menu-separator`,role:`separator`},t):(0,_P.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`sf-menu-item`,disabled:e.disabled,onClick:()=>{r(),e.onSelect?.()},children:[(0,_P.jsx)(`span`,{children:e.label}),e.hint&&(0,_P.jsx)(`span`,{className:`sf-menu-hint`,children:e.hint})]},t))}):null}}var _P,vP,yP=n((()=>{_P=WA(),vP=NM()}));function bP(e,t={}){let n=new Set(t.hidden??[]),r=(t.order??[]).filter((t,n,r)=>e.includes(t)&&r.indexOf(t)===n);return[...r,...e.filter(e=>!r.includes(e))].filter(e=>!n.has(e))}function xP(e,t,n,r){let i=bP(e,t).filter(e=>e!==n),a=r===void 0?i.length:i.indexOf(r);return i.splice(a<0?i.length:a,0,n),{...t,order:i}}function SP(e){let t=e.type,n=P.isBool(t)?90:P.isTimestamp(t)?190:P.isDate(t)||YN(t)?120:180;return Math.max(n,Math.min(320,e.name.length*9+48))}function CP(e){let{sourceId:t,sql:n,filters:r,parameters:i,timeTravel:a,mode:o=`scroll`,pageSize:s=50,height:c=420,label:l}=e,u=VN(e.dataSource),d=RM(),f=e.rowHeight??dM[d?.theme.density??`comfortable`].rowHeight,[p,m]=(0,TP.useState)([]),h=e.sorts??p,g=t=>{e.sorts===void 0&&m(t),e.onSortsChange?.(t)},_=iP(u,{sourceId:t,sql:n,filters:r,parameters:i,timeTravel:a,notBefore:e.notBefore,sorts:h.map(e=>({column:e.column,direction:e.desc?ax.DESC:ax.ASC}))},{blockSize:o===`pages`?s:200}),{fields:v,total:y}=_,b=(0,TP.useRef)(e.onInfo);b.current=e.onInfo,(0,TP.useEffect)(()=>{b.current?.({total:_.total,executedSql:_.executedSql,notices:_.notices,fields:_.fields,error:_.status===`error`?_.error:void 0,errorInfo:_.status===`error`?_.errorInfo:void 0,stored:_.stored,refresh:_.refresh,loading:_.status===`loading`,cancel:_.cancel})},[_.total,_.executedSql,_.notices,_.fields,_.status,_.error,_.errorInfo,_.stored,_.refresh,_.cancel]);let[x,S]=(0,TP.useState)(0),C=(0,TP.useRef)(null),w=`${t}\n${n}\n${JSON.stringify(h)}`;(0,TP.useEffect)(()=>{S(0),C.current&&(C.current.scrollTop=0)},[w]);let[T,E]=(0,TP.useState)({}),D=e.columns??T,O=(0,TP.useRef)(D);O.current=D;let k=t=>{O.current=t,e.columns===void 0&&E(t),e.onColumnsChange?.(t)},ee=v.map(e=>e.name),te=bP(ee,D).map(e=>({field:v[ee.indexOf(e)],source:ee.indexOf(e)})),A=D.widths??{},ne=e=>D.labels?.[e]||e,re=(e,t)=>{let{[e]:n,...r}=O.current.widths??{};k({...O.current,widths:t===void 0?r:{...r,[e]:Math.max(jP,Math.min(MP,Math.round(t)))}})},[ie,ae]=(0,TP.useState)(),[oe,se]=(0,TP.useState)(),[ce,le]=(0,TP.useState)(``),ue=gP(),de=(0,TP.useId)(),fe=te.map(({field:e})=>A[e.name]??SP(e)),pe=[],me=0;for(let e of fe)pe.push(me),me+=e;let he=(e,t)=>n=>{n.preventDefault();let r=n.currentTarget,i=n.clientX;r.setPointerCapture?.(n.pointerId),ae(e);let a=n=>re(e,t+n.clientX-i),o=()=>{r.removeEventListener(`pointermove`,a),r.removeEventListener(`pointerup`,o),r.removeEventListener(`pointercancel`,o),ae(void 0)};r.addEventListener(`pointermove`,a),r.addEventListener(`pointerup`,o),r.addEventListener(`pointercancel`,o)},[ge,j]=(0,TP.useState)({width:0,height:0}),[_e,ve]=(0,TP.useState)({top:0,left:0});(0,TP.useLayoutEffect)(()=>{let e=C.current;if(!e)return;let t=()=>j({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let ye=Math.max(0,(ge.height||(typeof c==`number`?c-40:380))-f),be=ge.width||960,xe=y===void 0?1:Math.max(1,Math.ceil(y/s)),Se=o===`pages`?x*s:0,M=y===void 0?0:o===`pages`?Math.max(0,Math.min(s,y-Se)):y,Ce=M*f,we=Math.min(Ce,OP),Te=Ce>OP,Ee=Math.ceil(ye/f)+1,De,Oe;if(Te){let e=Math.max(1,we-ye),t=Math.round(Math.min(_e.top,e)/e*Math.max(0,M-Ee+1));De=t,Oe=e=>_e.top+(e-t)*f}else De=Math.max(0,Math.floor(_e.top/f)-kP),Oe=e=>e*f;let ke=Math.min(M,De+Ee+(Te?0:12)),{ensure:Ae}=_;(0,TP.useEffect)(()=>{M>0&&Ae(Se+De,Se+ke)},[Ae,Se,De,ke,M]);let je=0;for(;je<fe.length-1&&pe[je]+fe[je]<_e.left-AP;)je++;let Me=je;for(;Me<fe.length&&pe[Me]<_e.left+be+AP;)Me++;let Ne=te.slice(je,Me).map(({field:e,source:t},n)=>({field:e,source:t,index:je+n})),[Pe,Fe]=(0,TP.useState)(),Ie=Pe&&Pe.row<M&&Pe.column<te.length?Pe:void 0,Le=(e,t)=>{let n=C.current;if(!n)return;if(!Te){let t=e*f;t<n.scrollTop?n.scrollTop=t:t+f>n.scrollTop+ye&&(n.scrollTop=t+f-ye)}let r=pe[t]??0,i=fe[t]??0;r<n.scrollLeft?n.scrollLeft=r:r+i>n.scrollLeft+be&&(n.scrollLeft=r+i-be)},Re=(e,t)=>{if(M===0||te.length===0)return;let n={row:Math.max(0,Math.min(M-1,e)),column:Math.max(0,Math.min(te.length-1,t))};Fe(n),Le(n.row,n.column)},ze=e=>le(e),Be=(e,t)=>void hP(e).then(e=>ze(e?z(`grid.copied`,{what:t}):z(`grid.copyFailed`))),Ve=(e,t)=>{let n=te[t];if(!n||!_.isLoaded(Se+e))return``;let r=_.getCell(Se+e,n.source);return r==null?``:ZN(r,n.field.type,void 0).text},He=t=>{if(t.target!==t.currentTarget)return;let n=Ie??{row:0,column:0},r=Math.max(1,Math.floor(ye/f)-1),i=t.ctrlKey||t.metaKey,a=(e,n)=>{t.preventDefault(),Re(e,n)};if(t.key===`ArrowDown`)return a(Ie?n.row+1:0,n.column);if(t.key===`ArrowUp`)return a(n.row-1,n.column);if(t.key===`ArrowRight`)return a(n.row,Ie?n.column+1:0);if(t.key===`ArrowLeft`)return a(n.row,n.column-1);if(t.key===`PageDown`)return a(n.row+r,n.column);if(t.key===`PageUp`)return a(n.row-r,n.column);if(t.key===`Home`)return a(i?0:n.row,0);if(t.key===`End`)return a(i?M-1:n.row,te.length-1);if(Ie){if(i&&t.key.toLowerCase()===`c`)return t.preventDefault(),Be(Ve(n.row,n.column),z(`grid.copiedCell`));t.key===`Enter`&&e.onRowClick&&_.isLoaded(Se+n.row)&&(t.preventDefault(),e.onRowClick(Ze(Se+n.row),Se+n.row))}},Ue=e=>/^[A-Za-z_]\w*$/.test(e)?e:`"${e.replace(/"/g,`""`)}"`,We=t=>e.onUseSql?e.onUseSql(t):Be(t,z(`grid.copiedSql`)),Ge=(e,t)=>{let r=bP(ee,{...D,hidden:[]}),i=D.hidden??[],a=`(${n.trim().replace(/;\s*$/,``)}) AS t`;return[{label:z(`grid.sortAscending`),onSelect:()=>g([{column:e,desc:!1}])},{label:z(`grid.sortDescending`),onSelect:()=>g([{column:e,desc:!0}])},{label:z(`grid.clearSorting`),disabled:h.length===0,onSelect:()=>g([])},{separator:!0},{label:z(`grid.moveLeft`),hint:`Alt ←`,disabled:t===0,onSelect:()=>k(xP(ee,D,e,te[t-1]?.field.name))},{label:z(`grid.moveRight`),hint:`Alt →`,disabled:t>=te.length-1,onSelect:()=>k(xP(ee,D,e,te[t+2]?.field.name))},{label:z(`grid.hideColumn`),disabled:te.length<=1,onSelect:()=>k({...D,hidden:[...i,e]})},{label:i.length?z(`grid.showAllColumnsHidden`,{count:NP.format(i.length)}):z(`grid.showAllColumns`),disabled:i.length===0,onSelect:()=>k({...D,hidden:[]})},{label:z(`grid.resetWidth`),hint:z(`grid.resetWidthHint`),disabled:A[e]===void 0,onSelect:()=>re(e,void 0)},{label:z(`grid.resetLayout`),disabled:r.join()===ee.join()&&i.length===0&&Object.keys(A).length===0,onSelect:()=>k({})},{separator:!0},{label:z(`grid.copyColumnName`),onSelect:()=>Be(e,z(`grid.copiedColumnName`))},{label:z(`grid.sqlCountValues`),onSelect:()=>We(`SELECT ${Ue(e)}, COUNT(*) AS row_count\nFROM ${a}\nGROUP BY ${Ue(e)}\nORDER BY row_count DESC`)},{label:z(`grid.sqlRange`),onSelect:()=>We(`SELECT MIN(${Ue(e)}) AS lowest, MAX(${Ue(e)}) AS highest, COUNT(*) - COUNT(${Ue(e)}) AS missing\nFROM ${a}`)}]},Ke=(t,n)=>{let r=te[n];if(!r||!_.isLoaded(Se+t))return[];let i=_.getCell(Se+t,r.source),a=()=>JSON.stringify(Ze(Se+t),(e,t)=>typeof t==`bigint`?t.toString():t,2);return[{label:z(`grid.copyValue`),hint:`Ctrl/⌘ C`,onSelect:()=>Be(Ve(t,n),z(`grid.copiedCell`))},{label:z(`grid.copyRowJson`),onSelect:()=>Be(a(),z(`grid.copiedRow`))},...e.onCellFilter?[{separator:!0},{label:z(`grid.filterToValue`),onSelect:()=>e.onCellFilter?.(r.field.name,i,!1)},{label:z(`grid.leaveValueOut`),onSelect:()=>e.onCellFilter?.(r.field.name,i,!0)}]:[]]},qe=(e,t)=>n=>{let r=n.key===`ArrowLeft`?-1:+(n.key===`ArrowRight`);if(r!==0){if(n.altKey){n.preventDefault();let i=t+r;if(i<0||i>=te.length)return;k(xP(ee,D,e,te[r<0?i:i+1]?.field.name)),ze(z(r<0?`grid.movedLeft`:`grid.movedRight`,{name:e}))}else n.shiftKey&&(n.preventDefault(),re(e,(fe[t]??jP)+r*DP))}},Je=(e,t)=>n=>{let r=n.dataTransfer.getData(EP);if(se(void 0),!r||r===e)return;n.preventDefault();let i=n.currentTarget.getBoundingClientRect(),a=n.clientX>i.left+i.width/2;k(xP(ee,D,r,a?te[t+1]?.field.name:e)),ze(z(`grid.moved`,{name:r}))},Ye=(e,t)=>{let n=h.find(t=>t.column===e),r=n?n.desc?void 0:{column:e,desc:!0}:{column:e,desc:!1};if(t.shiftKey){let t=h.filter(t=>t.column!==e);g(r?[...t,r]:t)}else g(r?[r]:[])},Xe=e=>({left:pe[e],width:fe[e]}),Ze=e=>Object.fromEntries(v.map((t,n)=>[t.name,_.getCell(e,n)])),Qe=[];for(let t=De;t<ke;t++){let n=Se+t,r=_.isLoaded(n);Qe.push((0,wP.jsx)(`div`,{role:`row`,"aria-rowindex":n+2,className:`sf-grid-row`,"data-odd":n%2==1||void 0,"data-clickable":e.onRowClick?!0:void 0,style:{top:Oe(t),height:f,width:me},onClick:e.onRowClick&&r?()=>e.onRowClick?.(Ze(n),n):void 0,children:Ne.map(({field:i,source:a,index:o})=>{if(!r)return(0,wP.jsx)(`div`,{role:`gridcell`,"aria-colindex":o+1,className:`sf-grid-cell`,style:Xe(o),children:(0,wP.jsx)(`span`,{className:`sf-grid-skeleton`})},i.name);let s=QN(_.getCell(n,a),i.type,e.formats?.[i.name]),c=Ie?.row===t&&Ie.column===o;return(0,wP.jsx)(`div`,{role:`gridcell`,"aria-colindex":o+1,className:`sf-grid-cell`,"data-numeric":s.numeric||void 0,"data-null":s.isNull||void 0,"data-active":c||void 0,id:c?`${de}-active`:void 0,"aria-selected":c||void 0,style:Xe(o),onMouseDown:()=>Fe({row:t,column:o}),onContextMenu:e=>{Fe({row:t,column:o}),ue.open(e,z(`grid.cellMenu`,{name:ne(i.name)}),Ke(t,o))},children:s.text},i.name)})},n))}let $e=_.status===`error`?z(`grid.failed`):y===void 0?z(`grid.loading`):z(y===1?`grid.rowsOne`:`grid.rows`,{count:NP.format(y)});return(0,wP.jsxs)(`div`,{className:[`sf-grid`,e.className].filter(Boolean).join(` `),style:{height:typeof c==`number`?`${c}px`:c},children:[(0,wP.jsxs)(`div`,{ref:C,className:`sf-grid-scroll`,role:`grid`,"aria-label":l??z(`grid.label`),"aria-rowcount":y===void 0?-1:y+1,"aria-colcount":te.length,"aria-activedescendant":Ie?`${de}-active`:void 0,onKeyDown:He,onContextMenu:e=>{e.target===e.currentTarget&&Ie&&ue.open(e,z(`grid.activeCellMenu`),Ke(Ie.row,Ie.column))},"aria-busy":_.status===`loading`,tabIndex:0,onScroll:e=>ve({top:e.currentTarget.scrollTop,left:e.currentTarget.scrollLeft}),children:[(0,wP.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`sf-grid-header`,style:{width:me,height:f},children:Ne.map(({field:e,index:t})=>{let n=h.find(t=>t.column===e.name),r=h.length>1&&n?h.indexOf(n)+1:void 0;return(0,wP.jsxs)(`div`,{role:`columnheader`,"aria-colindex":t+1,"aria-sort":n?n.desc?`descending`:`ascending`:`none`,className:`sf-grid-head`,"data-numeric":YN(e.type)||void 0,"data-drop":oe===e.name||void 0,style:Xe(t),draggable:!0,onDragStart:t=>{if(ie)return t.preventDefault();t.dataTransfer.setData(EP,e.name),t.dataTransfer.effectAllowed=`move`},onDragOver:t=>{t.dataTransfer.types.includes(EP)&&(t.preventDefault(),se(e.name))},onDragLeave:()=>se(void 0),onDragEnd:()=>se(void 0),onDrop:Je(e.name,t),onContextMenu:n=>ue.open(n,z(`grid.columnMenu`,{name:ne(e.name)}),Ge(e.name,t)),children:[(0,wP.jsxs)(`button`,{type:`button`,className:`sf-grid-sort`,title:`${ne(e.name)===e.name?``:`${e.name} · `}${String(e.type)}`,"aria-keyshortcuts":`Alt+ArrowLeft Alt+ArrowRight Shift+ArrowLeft Shift+ArrowRight Shift+F10`,onClick:t=>Ye(e.name,t),onKeyDown:qe(e.name,t),children:[(0,wP.jsx)(`span`,{className:`sf-grid-name`,children:ne(e.name)}),n&&(0,wP.jsxs)(`span`,{className:`sf-grid-arrow`,"aria-hidden":`true`,children:[n.desc?`↓`:`↑`,r]})]}),(0,wP.jsx)(`span`,{className:`sf-grid-resize`,"data-resizing":ie===e.name||void 0,onPointerDown:he(e.name,fe[t]),onDoubleClick:()=>re(e.name,void 0),"aria-hidden":`true`})]},e.name)})}),(0,wP.jsx)(`div`,{className:`sf-grid-body`,style:{height:we,width:me},children:Qe}),_.status===`error`&&(0,wP.jsx)(`p`,{className:`sf-grid-message`,role:`alert`,"data-error":_.error,children:e.errorMessage??_.error}),_.status===`ready`&&y===0&&(0,wP.jsx)(`p`,{className:`sf-grid-message`,children:e.emptyMessage??z(`grid.noRows`)})]}),e.footer===!1&&o!==`pages`?(0,wP.jsx)(`span`,{className:`sf-visually-hidden`,"aria-live":`polite`,children:$e}):(0,wP.jsxs)(`div`,{className:`sf-grid-footer`,children:[(0,wP.jsx)(`span`,{"aria-live":`polite`,children:$e}),(D.hidden?.length??0)>0&&(0,wP.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>k({...D,hidden:[]}),children:z(D.hidden.length===1?`grid.showHiddenOne`:`grid.showHidden`,{count:NP.format(D.hidden.length)})}),(0,wP.jsx)(`span`,{className:`sf-grid-note`,role:`status`,children:ce}),_.elapsedMs!==void 0&&_.status===`ready`&&(0,wP.jsx)(`span`,{children:z(`grid.elapsed`,{ms:_.elapsedMs})}),_.stored&&_.status===`ready`&&(0,wP.jsxs)(`span`,{className:`sf-grid-asof`,children:[z(`grid.asOf`,{time:PA({hour:`numeric`,minute:`2-digit`,second:`2-digit`}).format(new Date(_.stored.createdAt))}),(0,wP.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:_.refresh,children:z(`grid.runAgain`)})]}),o===`pages`&&y!==void 0&&(0,wP.jsxs)(`span`,{className:`sf-grid-pager`,children:[(0,wP.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:x===0,onClick:()=>S(x-1),children:z(`grid.previous`)}),(0,wP.jsx)(`span`,{children:z(`grid.page`,{page:NP.format(x+1),pages:NP.format(xe)})}),(0,wP.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:x+1>=xe,onClick:()=>S(x+1),children:z(`grid.next`)})]})]}),(0,wP.jsx)(dP,{notes:uP(_.notices)}),ue.element]})}var wP,TP,EP,DP,OP,kP,AP,jP,MP,NP,PP=n((()=>{wP=WA(),vS(),jM(),_p(),TP=NM(),GN(),mP(),rP(),HA(),cP(),yP(),GM(),EP=`application/x-surfaces-grid-column`,DP=16,OP=1e7,kP=6,AP=240,jP=60,MP=1200,NP={format:e=>NA().format(e)}}));function FP(){let e=globalThis.echarts;if(!e)throw Error(`Charts need ECharts: load echarts.js before surfaces-page.js.`);return e}function IP(...e){return FP().init(...e)}var LP=n((()=>{}));function RP(e){let t=[],{type:n,categories:r=0,series:i=1}=e;return n===`pie`&&r>5&&t.push({rule:`pie-slices`,message:`${r} slices are too many to compare by angle.`,instead:`A bar chart sorted by value.`}),e.rightAxis&&t.push({rule:`two-scales`,message:`Two y scales make heights look comparable when they are not.`,instead:`Two charts stacked on the same x axis, or both measures indexed to a common start.`}),n===`bar`&&e.truncatedAxis&&t.push({rule:`bar-baseline`,message:`A bar's length is its value, so the axis must start at zero.`,instead:`Start at zero, or use a dot or line chart if the differences are small.`}),(n===`line`||n===`area`)&&e.orderedX===!1&&t.push({rule:`line-order`,message:`A line implies order between its points; these categories have none.`,instead:`A bar chart.`}),n===`line`&&i>5&&t.push({rule:`too-many-lines`,message:`${i} lines cross too often to follow.`,instead:`Small multiples on one shared scale, or highlight one line and grey the rest.`}),e.stacked&&i>5&&t.push({rule:`stack-depth`,message:`Only the bottom of ${i} stacked segments can be compared across bars.`,instead:`Keep the largest four and fold the rest into Other, or use small multiples.`}),n===`bar`&&!e.stacked&&r*i>40&&t.push({rule:`bar-crowding`,message:`Too many bars to read individually.`,instead:`The top values sorted by size, or a table.`}),n===`area`&&!e.stacked&&i>1&&t.push({rule:`overlapping-areas`,message:`Unstacked areas hide each other.`,instead:`Lines, or a stacked area if the total matters.`}),n===`bar`&&e.orderedX&&!e.binned&&r>24&&t.push({rule:`bars-over-time`,message:`${r} bars in a row hide the trend they make.`,instead:`A line, with a time grain coarse enough for the decision.`}),n===`pie`&&e.orderedX&&t.push({rule:`pie-in-order`,message:`A pie puts its slices round a circle, so the order of these values is lost.`,instead:`A line or bars, in the order of x.`}),n!==`pie`&&i===1&&e.legend&&e.legend!==`none`&&t.push({rule:`one-series-legend`,message:`A legend for one series repeats what the title says.`,instead:`Leave the legend out and name the measure in the title.`}),t}var zP=n((()=>{}));function BP(e){let t=e=>{e.ctrlKey||e.metaKey||e.stopPropagation()};return e.addEventListener(`wheel`,t,{capture:!0}),()=>e.removeEventListener(`wheel`,t,{capture:!0})}var VP=n((()=>{}));function HP(e,t){return t.length>0&&t.every(t=>(t.type??e)===`bar`&&t.axis!==`right`)}function UP(e){return e?P.isTimestamp(e.type)||P.isDate(e.type)||P.isInt(e.type)||P.isFloat(e.type)||P.isDecimal(e.type):!1}function WP(e,t,n){let r=new Map;for(let i of e){let e=String(i[t]??`null`);r.set(e,(r.get(e)??0)+(Number(i[n])||0))}return[...r.entries()].sort((e,t)=>t[1]-e[1]).map(([e])=>e)}function GP(e,t){return e?P.isTimestamp(e.type)||P.isDate(e.type)?`time`:(P.isInt(e.type)||P.isFloat(e.type)||P.isDecimal(e.type))&&t?`value`:`category`:`category`}function KP(e){return e===`none`?{show:!1}:e===`right`?{type:`scroll`,orient:`vertical`,right:0,top:`middle`}:{type:`scroll`,[e]:0}}function qP(e,t,n){let r=Array.isArray(t)?t:void 0,i=[],a=1/0,o=-1/0;for(let t of e){let e=t.encode.y,s=(r?r[t.datasetIndex]?.source??[]:n).map(t=>Number(t[e])).filter(e=>Number.isFinite(e));if(s.length===0)return!1;i.push(s.at(-1)),a=Math.min(a,...s),o=Math.max(o,...s)}let s=(o-Math.min(a,0))*.08,c=[...i].sort((e,t)=>e-t);return c.every((e,t)=>t===0||e-c[t-1]>=s)}function JP(e){if(e.type===`pie`)return[];let t=e.series.map(t=>t.type??e.type);return GP(e.fields.find(t=>t.name===e.x),t.every(e=>e===`scatter`))===`category`?[]:e.rows.filter(t=>t[e.x]==null)}function YP(e){let t=JP(e).length>0?{...e,rows:e.rows.filter(t=>t[e.x]!=null)}:e,{type:n,x:r,splitBy:i}=t,a=t.fields.find(e=>e.name===r),o=n!==`pie`&&UP(a)&&t.sort===`value`,s=n!==`pie`&&t.sort===`value`&&!UP(a)?t.rows.map(e=>e[r]==null?{...e,[r]:`null`}:e):t.rows,c=o?[...t.rows].sort((e,t)=>typeof e[r]==`number`&&typeof t[r]==`number`?e[r]-t[r]:String(e[r]).localeCompare(String(t[r]))):s;if(n===`pie`){let e=t.series[0];return{tooltip:{trigger:`item`,valueFormatter:sF(t.yFormat)},legend:KP(t.legend??`bottom`),series:[{type:`pie`,name:e?.label??``,radius:[`45%`,`72%`],center:[`50%`,`45%`],label:{show:c.length<=8},data:e?c.map(t=>({name:String(t[r]??`null`),value:t[e.column]})):[]}]}}let l=t.series.map(e=>e.type??n),u=GP(a,l.every(e=>e===`scatter`)),d=!!t.horizontal&&HP(n,t.series),f=(e,t)=>d?{x:t,y:e}:{x:e,y:t},p=c.length>2e3?{large:!0,sampling:`lttb`,showSymbol:!1}:{},m=t.series.some(e=>e.axis===`right`),h=e=>{let r=e.type??n,i=e.stack??(t.stacked&&r!==`scatter`?`stack-${e.axis??`left`}-${r}`:void 0);return{type:r===`area`?`line`:r,...r===`area`?{areaStyle:{opacity:.18},showSymbol:!1}:{},...i?{stack:i}:{},...m?{yAxisIndex:+(e.axis===`right`)}:{},tooltip:{valueFormatter:sF(e.axis===`right`?void 0:t.yFormat)},...p}},g=e=>e?{itemStyle:{color:e},lineStyle:{color:e}}:{},_,v;if(i){let e=new Map;for(let t of c){let n=String(t[i]??`null`),r=e.get(n);r?r.push(t):e.set(n,[t])}let n=[...e.keys()];v=n.map(t=>({source:e.get(t)})),_=n.flatMap((e,n)=>t.series.map(i=>({...h(i),...g(t.splitColors?.[e]),name:t.series.length>1?`${e} · ${i.label}`:e,datasetIndex:n,encode:f(r,i.column)})))}else v={source:c},_=t.series.map(e=>({...h(e),...g(e.color),name:e.label,encode:f(r,e.column)}));let y=t.legend===void 0&&_.length>=2&&_.length<=4&&l.every(e=>e===`line`)&&!t.stacked&&!m&&qP(_,v,c);y&&(_=_.map(e=>({...e,endLabel:{show:!0,formatter:`{a}`,distance:6},labelLayout:{moveOverlap:`shiftY`}})));let b=t.legend??(y?`none`:_.length>1?`top`:`none`),x=t.sort===`value`&&!UP(a)&&t.series[0]?WP(c,r,t.series[0].column):void 0,S=new Set(c.map(e=>e[r])).size>60,C=(e,n)=>({type:`value`,name:e,nameLocation:`middle`,...ZP,position:n?`right`:`left`,splitLine:{show:!n},axisLabel:{formatter:n?eF:rF(t.yFormat)}});return{useUTC:!0,dataset:v,grid:{left:8,right:b===`right`?140:y?96:16,top:b===`top`?36:16,bottom:(S&&!d?40:8)+(b===`bottom`?28:0),outerBoundsMode:`same`,outerBoundsContain:`all`},tooltip:{trigger:l.every(e=>e===`scatter`)?`item`:`axis`},legend:KP(b),...d?{yAxis:{type:u,...u===`category`&&x?{data:x}:{},inverse:!0,name:t.xTitle,nameLocation:`start`,nameGap:8,axisLabel:{hideOverlap:!0,...u===`category`?{interval:0}:{}}},xAxis:{...C(t.yTitle,!1),position:`bottom`}}:{xAxis:{type:u,...u===`category`&&x?{data:x}:{},name:t.xTitle??(u===`value`?r:void 0),nameLocation:`middle`,...ZP,axisLabel:{hideOverlap:!0,...u===`category`?{interval:0}:{}}},yAxis:m?[C(t.yTitle,!1),C(t.yRightTitle,!0)]:C(t.yTitle,!1)},dataZoom:S?d?[{type:`inside`,yAxisIndex:0},{type:`slider`,yAxisIndex:0,width:18,right:8}]:[{type:`inside`},{type:`slider`,height:18,bottom:b===`bottom`?32:8}]:[],series:_}}function XP(e,t,n){let r=t-e;if(!(r>0)||!(n>0))return 1;let i=r/n,a=10**Math.floor(Math.log10(i));return([1,2,2.5,5,10].find(e=>e*a>=i)??10)*a}var ZP,QP,$P,eF,tF,nF,rF,iF,aF,oF,sF,cF=n((()=>{_p(),HA(),ZP={nameGap:8,nameMoveOverlap:!0},QP=()=>NA({notation:`compact`,maximumFractionDigits:1}),$P=()=>NA({maximumSignificantDigits:2}),eF=e=>e!==0&&Math.abs(e)<1?$P().format(e):QP().format(e),tF=()=>NA({style:`percent`,maximumSignificantDigits:2}),nF=()=>NA({style:`currency`,currency:`USD`,notation:`compact`,maximumSignificantDigits:3}),rF=e=>e===`percent`?e=>tF().format(e):e===`currency`?e=>nF().format(e):eF,iF=()=>NA({style:`percent`,maximumFractionDigits:1}),aF=()=>NA({style:`currency`,currency:`USD`,maximumFractionDigits:2}),oF=()=>NA({maximumFractionDigits:2}),sF=e=>t=>{let n=typeof t==`number`?t:Number(t);return t==null||t===``||!Number.isFinite(n)?t==null?`–`:String(t):e===`percent`?iF().format(n):e===`currency`?aF().format(n):n!==0&&Math.abs(n)<1?$P().format(n):oF().format(n)}}));function lF(e,t,n){if(n(e)<=t)return e;let r=e.split(` `).filter(e=>e!==``);if(r.length<2||r.some(e=>n(e)>t))return e;let i=[],a=``;for(let e of r){let r=a===``?e:`${a} ${e}`;a!==``&&n(r)>t?(i.push(a),a=e):a=r}return i.push(a),i.join(`
|
|
22
|
+
`)}function uF(e){if(typeof document>`u`)return;let t=null;try{t=document.createElement(`canvas`).getContext(`2d`)}catch{return}if(!t)return;t.font=e;let n=t;return e=>n.measureText(e).width}function dF(e,t){let n=e.getOption(),r=n?.xAxis?.[0];if(!r||r.type!==`category`||(n?.dataZoom?.length??0)>0)return;let i=r.axisLabel?.formatter;if(i!=null&&!(typeof i==`function`&&pF in i))return;let a=Array.isArray(n?.textStyle)?n.textStyle[0]:n?.textStyle,o=t??uF(`${r.axisLabel?.fontSize??12}px ${r.axisLabel?.fontFamily??a?.fontFamily??`sans-serif`}`);if(!o)return;let s=t=>{let n=e.convertToPixel({xAxisIndex:0},t);return Array.isArray(n)?n[0]:n},c=Math.abs(s(1)-s(0));if(!Number.isFinite(c)||c<=fF)return;let l=c-fF,u=Object.assign(e=>lF(String(e),l,o),{[pF]:!0});e.setOption({xAxis:{axisLabel:{formatter:u}}})}var fF,pF,mF=n((()=>{fF=8,pF=Symbol(`surfaces category label wrap`)}));function hF(e){return e.map((e,t)=>{if(e.expression)return{column:`calc_${t}`,label:e.label??e.expression,measure:e};if(!e.aggregate)return{column:e.column??``,label:e.label??e.column??``,measure:e};let n=e.column??`rows`,r=e.aggregate===`percentile`?`p${Math.round((e.percentile??.9)*100)}`:e.aggregate.replace(`_`,` `);return{column:`${e.aggregate}_${e.column??`rows`}_${t}`.replace(/\W+/g,`_`),label:e.label??(e.aggregate===`count`&&!e.column?`count`:`${r} of ${n}`),measure:e}})}function gF(e,t){try{return wS(bS(e),{name:e=>`${t}_${e}`,divide:(e,t)=>`(${e} / ${t})`})}catch{return e}}function _F(e){return e.rows.length===0?{type:e.type,categories:0,series:0}:{type:e.type,categories:new Set(e.rows.map(t=>t[e.x])).size,series:e.type===`pie`?1:e.seriesCount,stacked:e.stacked,rightAxis:e.y.some(e=>e.axis===`right`),orderedX:e.binned||UP(e.fields.find(t=>t.name===e.x)),...e.histogram?{binned:!0}:{},...e.legend?{legend:e.legend}:{}}}function vF(e){return e.xGrain||e.binWidth?`x`:e.sort??(e.type===`bar`&&e.y.every(e=>(e.type??`bar`)===`bar`)?`value`:`x`)}function yF(e){let{sql:t,type:n,x:r,y:i,splitBy:a,filters:o,parameters:s,limit:c}=e,l=hF(i),u=l.filter(e=>e.measure.aggregate||e.measure.expression);if(u.length===0)return{baseSql:t,filters:o,parameters:s,columns:[...new Set([r,...a?[a]:[],...l.map(e=>e.column)])],sample:{rows:c}};let d=e.xGrain?{column:r,by:{case:`grain`,value:TF[e.xGrain]}}:e.binWidth?{column:r,by:{case:`binWidth`,value:e.binWidth}}:void 0;return{baseSql:t,filters:o,parameters:s,groupBy:[...d?[]:[r],...a?[a]:[]],buckets:d?[d]:[],aggregates:u.flatMap(e=>e.measure.expression?Object.entries(e.measure.terms??{}).map(([t,n])=>({function:wF[n.aggregate],column:n.column??``,alias:`${e.column}_${t}`,percentile:n.aggregate===`percentile`?n.percentile??.9:0})):[{function:wF[e.measure.aggregate],column:e.measure.column??``,alias:e.column,percentile:e.measure.aggregate===`percentile`?e.measure.percentile??.9:0}]),derived:u.filter(e=>e.measure.expression).map(e=>({alias:e.column,expression:gF(e.measure.expression,e.column)})),sorts:n===`pie`||vF(e)===`value`&&!a?[{column:u[0].column,direction:ax.DESC}]:[{column:r,direction:ax.ASC}],page:{limit:c}}}function bF(e,t){let n=t=>{let n=e.schema.fields.find(e=>e.name===t),r=e.getChild(t)?.get(0);return n?$N(r,n.type):null},r=n(`lo`),i=n(`hi`);return r===null||i===null?1:XP(r,i,t)}function xF(e){let{sourceId:t,sql:n,type:r,x:i,xGrain:a,xBinWidth:o,xBins:s,y:c,splitBy:l,filters:u,parameters:d,timeTravel:f,notBefore:p,limit:m=5e3,height:h=320}=e,g=VN(e.dataSource),_=RM(),v=(0,CF.useRef)(null),[y,b]=(0,CF.useState)({loading:!0}),x=(0,CF.useMemo)(()=>hF(c),[JSON.stringify(c)]),S=JSON.stringify([t,n,r,i,a,o,s,c,l,u,d,f,p,m,e.sort],(e,t)=>typeof t==`bigint`?`${t}n`:t);(0,CF.useEffect)(()=>{let h=new AbortController,_={signal:h.signal};b(e=>({...e,loading:!0,error:void 0}));let v=x.some(e=>e.measure.aggregate||e.measure.expression);return(async()=>{let h=a?void 0:o;v&&!a&&!h&&s&&(h=bF((await JS(g.execute({sourceId:t,timeTravel:f,notBefore:p,query:{baseSql:n,filters:u,parameters:d,aggregates:[{function:ux.MIN,column:i,alias:`lo`},{function:ux.MAX,column:i,alias:`hi`}]}},_))).table,s));let y=vF({type:r,xGrain:a,binWidth:h,sort:e.sort,y:c}),b=yF({sql:n,type:r,x:i,xGrain:a,binWidth:h,y:c,splitBy:l,filters:u,parameters:d,limit:m,sort:y}),x=await JS(g.execute({sourceId:t,timeTravel:f,notBefore:p,query:b},_)),S=x.table.schema.fields,C=S.map((e,t)=>x.table.getChildAt(t)),w=Array.from({length:x.table.numRows},(e,t)=>Object.fromEntries(S.map((e,n)=>[e.name,eP(C[n].get(t),e.type)])));return{fields:S,rows:w,sort:y,cut:w.length<m?void 0:v?`first`:`sample`,notes:uP(x.header.notices)}})().then(e=>{h.signal.aborted||b({loaded:e,loading:!1})}).catch(e=>{h.signal.aborted||b({error:aP(e),loading:!1})}),()=>h.abort()},[g,S]);let C=(0,CF.useRef)(e.onPointClick);C.current=e.onPointClick;let w=_?.resolvedMode??`light`,T=_?.theme??Qj,{stacked:E,legend:D,xTitle:O,yTitle:k,yRightTitle:ee,yFormat:te,splitSlots:A,horizontal:ne}=e,re=(0,CF.useMemo)(()=>iM(T[w],T.charts?.[w]).series,[T,w]),ie=JSON.stringify(A??null),ae=(0,CF.useMemo)(()=>{if(!y.loaded)return;let t=e=>e===void 0?void 0:re[e-1],n=YP({type:r,x:i,splitBy:l,series:x.map(e=>({column:e.column,label:e.label,type:e.measure.type,axis:e.measure.axis,stack:e.measure.stack,color:t(e.measure.slot)})),splitColors:A?Object.fromEntries(Object.entries(A).map(([e,n])=>[e,t(n)??``]).filter(([,e])=>e!==``)):void 0,fields:y.loaded.fields,rows:y.loaded.rows,sort:y.loaded.sort,stacked:E,legend:D,xTitle:O,yTitle:k,yRightTitle:ee,yFormat:te,horizontal:ne}),a={aria:{enabled:!0},...typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?{animation:!1}:{},...n};return e.option?e.option(a):a},[y.loaded,r,i,l,x,e.option,E,D,O,k,ee,te,ne,re,ie]),oe=r!==`pie`&&Array.isArray(ae?.series)?ae.series.length:0;(0,CF.useEffect)(()=>{if(!v.current||!ae)return;let e=IP(v.current,wM(T,w));e.setOption(ae),e.on(`click`,e=>{let t=e.data!==null&&typeof e.data==`object`?e.data:void 0,n=t&&i in t?t[i]:e.name??null,r=t&&typeof t.value==`number`?t.value:typeof e.value==`number`?e.value:null;C.current?.({x:n,series:e.seriesName??``,value:r})}),dF(e);let t=typeof ResizeObserver>`u`?void 0:new ResizeObserver(()=>{e.resize(),dF(e)});t?.observe(v.current);let n=BP(v.current);return()=>{n(),t?.disconnect(),e.dispose()}},[ae,T,w]);let se=e.advice===!1||!y.loaded?[]:RP(_F({type:r,x:i,y:c,stacked:E,legend:D,seriesCount:oe,binned:!!(a||o||s),histogram:!!(o||s),fields:y.loaded.fields,rows:y.loaded.rows})),ce=y.loaded?JP({type:r,x:i,series:x.map(e=>({column:e.column,label:e.label,type:e.measure.type})),fields:y.loaded.fields,rows:y.loaded.rows}):[],le=ce.length===1?` (${x.map(e=>`${e.label}: ${typeof ce[0][e.column]==`number`?NA().format(ce[0][e.column]):String(ce[0][e.column]??`–`)}`).join(`, `)})`:``,ue=!!y.loaded&&y.loaded.rows.length===ce.length,de=e.label??z(`chart.description`,{type:r,measures:x.map(e=>e.label).join(`, `),x:i});return(0,SF.jsxs)(`figure`,{className:[`sf-chart`,e.className].filter(Boolean).join(` `),"aria-busy":y.loading,children:[y.error?(0,SF.jsx)(`p`,{className:`sf-chart-message`,role:`alert`,"data-error":y.error,style:{minHeight:h},children:e.errorMessage??y.error}):ue?(0,SF.jsx)(`p`,{className:`sf-chart-message`,style:{minHeight:h},children:e.emptyMessage??z(`chart.empty`)}):(0,SF.jsx)(`div`,{ref:v,className:`sf-chart-canvas`,role:`img`,"aria-label":de,style:{height:h}}),ce.length>0&&(0,SF.jsx)(`figcaption`,{className:`sf-chart-note`,children:z(`chart.missingX`,{x:i,detail:le})}),oe>re.length&&(0,SF.jsx)(`figcaption`,{className:`sf-chart-note`,children:z(`chart.coloursRepeat`,{count:oe,colours:re.length})}),se.map(e=>(0,SF.jsx)(`figcaption`,{className:`sf-chart-note sf-chart-advice`,role:`note`,children:z(`chart.advice`,{message:e.message,instead:e.instead})},e.rule)),y.loaded&&y.loaded.notes.length>0&&(0,SF.jsx)(`figcaption`,{className:`sf-chart-note`,role:`note`,children:y.loaded.notes.join(` `)}),y.loaded?.cut&&(0,SF.jsx)(`figcaption`,{className:`sf-chart-note`,children:y.loaded.cut===`sample`?z(`chart.sampleNote`,{count:NA().format(m)}):z(y.loaded.sort===`value`?`chart.largestNote`:`chart.firstNote`,{count:NA().format(m)})})]})}var SF,CF,wF,TF,EF=n((()=>{SF=WA(),rw(),vS(),jM(),LP(),CF=NM(),GN(),mP(),rP(),HA(),cP(),GM(),zP(),VP(),cF(),mF(),wF={sum:ux.SUM,avg:ux.AVG,count:ux.COUNT,count_distinct:ux.COUNT_DISTINCT,min:ux.MIN,max:ux.MAX,median:ux.MEDIAN,stddev:ux.STDDEV,variance:ux.VARIANCE,percentile:ux.PERCENTILE},TF={minute:dx.MINUTE,hour:dx.HOUR,day:dx.DAY,week:dx.WEEK,month:dx.MONTH,quarter:dx.QUARTER,year:dx.YEAR}}));function DF({value:e,onChange:t,onRun:n,readOnly:r,error:i,placeholder:a,minHeight:o=120,maxHeight:s,label:c,className:l}){return(0,OF.jsxs)(`div`,{className:[`sf-sql-editor`,l].filter(Boolean).join(` `),children:[(0,OF.jsx)(`textarea`,{className:`sf-input`,"aria-label":c??`SQL editor`,"aria-invalid":i?!0:void 0,spellCheck:!1,value:e,readOnly:r,placeholder:a,onChange:e=>t(e.target.value),onKeyDown:e=>{if(!n||e.key!==`Enter`||!(e.metaKey||e.ctrlKey))return;e.preventDefault();let t=e.currentTarget;n(t.selectionStart===t.selectionEnd?t.value:t.value.slice(t.selectionStart,t.selectionEnd))},style:{width:`100%`,minHeight:o,maxHeight:s,fontFamily:`var(--sf-font-mono)`,resize:`vertical`}}),i&&(0,OF.jsx)(`p`,{className:`sf-sql-editor-error`,role:`alert`,children:i.message})]})}var OF,kF=n((()=>{OF=WA()})),AF,jF=n((()=>{WA(),vS(),NM(),AF=`application/x-surfaces-ref+json`,Cx.PARQUET,Cx.CSV,Cx.JSON,Cx.ICEBERG,Cx.DELTA}));function MF(e){let t=(0,zF.useContext)(BF),n=NN(`Discovery`,e??t);if(!n)throw Error(`No Discovery backend: wrap the component in <DiscoveryProvider> or pass discovery.`);return n}function NF(e){let t=(0,zF.useContext)(BF);return NN(`Discovery`,e??t)}function PF(e){let t=e.status===Ux.DEPRECATED?`Deprecated`:`Certified`,n=e.setAt?` on ${e.setAt.slice(0,10)}`:``;return`${t} by ${e.setBy||`an unnamed person`}${n}${e.note?`. ${e.note}`:``}`}function FF({certification:e}){if(!e||e.status===Ux.UNSPECIFIED)return null;let t=e.status===Ux.DEPRECATED;return(0,RF.jsxs)(`span`,{className:`sf-cert`,"data-status":t?`deprecated`:`certified`,title:PF(e),children:[(0,RF.jsx)(`span`,{"aria-hidden":`true`,children:t?`!`:`✓`}),t?`Deprecated`:`Certified`]})}function IF(e,t){return{sourceId:e,kind:Bx.TABLE,table:t}}function LF(e){return e?.ref?.kind===Bx.COLUMN?`Column`:`Table`}var RF,zF,BF,VF,HF,UF,WF,GF=n((()=>{RF=WA(),vS(),zN(),zF=NM(),HA(),BF=(0,zF.createContext)(void 0),VF={[Cx.PARQUET]:`Parquet`,[Cx.CSV]:`CSV`,[Cx.JSON]:`JSON`,[Cx.ICEBERG]:`Iceberg`,[Cx.DELTA]:`Delta`},HF={[Hx.SOURCE]:`From the source`,[Hx.HUMAN]:`Written by a person`,[Hx.GENERATED]:`Generated`},UF={format:e=>NA({notation:`compact`,maximumFractionDigits:1}).format(e)},WF={format:e=>NA().format(e)}}));function KF(e){let t=[`bytes`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Number(e),r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${r===0?n:n.toFixed(1)} ${t[r]}`}function qF(e){return[e.catalog,e.schema,e.table,e.column].filter(e=>!!e).map(e=>/^[A-Za-z_]\w*$/.test(e)?e:`"${e.replace(/"/g,`""`)}"`).join(`.`)}function JF(e){let{sourceId:t,catalog:n,schema:r,table:i,onClose:a}=e,o=VN(e.dataSource),[s,c]=(0,XF.useState)(),l=qF({catalog:n,schema:r,table:i});(0,XF.useEffect)(()=>{let e=!0;return c(void 0),(i?o.describeTable({sourceId:t,ref:{catalog:n??``,schema:r??``,table:i}}).then(e=>e.table?{table:e.table}:{error:`The backend returned nothing for this table.`}):o.listTables({sourceId:t,catalog:n??``,schema:r??``,pageSize:50}).then(e=>({tables:e.tables,more:e.nextPageToken!==``}))).then(t=>e&&c(t)).catch(t=>e&&c({error:aP(t)})),()=>{e=!1}},[o,t,n,r,i]);let u=[];if(s&&`table`in s){let{summary:e,rowCount:t,sizeBytes:n,location:r,properties:i}=s.table;u.push([`Kind`,QF[e?.kind??0]??`Table`]),e?.format&&u.push([`Format`,Cx[e.format]?.toLowerCase()??``]),t!==void 0&&u.push([`Rows`,ZF.format(t)]),n!==void 0&&u.push([`Size`,KF(n)]),r&&u.push([`Location`,r]),u.push([`Columns`,ZF.format(s.table.columns.length)]);for(let[e,t]of Object.entries(i))u.push([e,t])}return(0,YF.jsxs)(`section`,{className:[`sf-info`,e.className].filter(Boolean).join(` `),"aria-label":`Details of ${l||t}`,onKeyDown:e=>{e.key===`Escape`&&a&&(e.stopPropagation(),a())},children:[(0,YF.jsxs)(`header`,{className:`sf-info-head`,children:[(0,YF.jsxs)(`div`,{children:[(0,YF.jsx)(`p`,{className:`sf-info-kind`,children:i?`Table`:r?`Schema`:n?`Database`:`Source`}),(0,YF.jsx)(`p`,{className:`sf-info-name`,children:l||t})]}),a&&(0,YF.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:a,autoFocus:!0,children:`Close`})]}),s===void 0&&(0,YF.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`}),s&&`error`in s&&(0,YF.jsxs)(`p`,{className:`sf-metric-error`,role:`alert`,children:[`Could not read the details: `,s.error]}),s&&`table`in s&&(0,YF.jsxs)(YF.Fragment,{children:[s.table.summary?.comment&&(0,YF.jsx)(`p`,{className:`sf-info-comment`,children:s.table.summary.comment}),(0,YF.jsx)(`dl`,{className:`sf-info-facts`,children:u.map(([e,t])=>(0,YF.jsxs)(`div`,{children:[(0,YF.jsx)(`dt`,{children:e}),(0,YF.jsx)(`dd`,{children:t})]},e))}),(0,YF.jsx)(`div`,{className:`sf-info-scroll`,tabIndex:0,role:`region`,"aria-label":`Columns`,children:(0,YF.jsxs)(`table`,{className:`sf-info-table`,children:[(0,YF.jsx)(`thead`,{children:(0,YF.jsxs)(`tr`,{children:[(0,YF.jsx)(`th`,{scope:`col`,children:`Column`}),(0,YF.jsx)(`th`,{scope:`col`,children:`Type`}),(0,YF.jsx)(`th`,{scope:`col`,children:`Notes`})]})}),(0,YF.jsx)(`tbody`,{children:s.table.columns.map(e=>(0,YF.jsxs)(`tr`,{children:[(0,YF.jsx)(`th`,{scope:`row`,children:e.name}),(0,YF.jsx)(`td`,{children:e.nativeType||e.arrowType}),(0,YF.jsx)(`td`,{children:[e.primaryKey&&`Key`,e.partitionKey&&`Partition`,!e.nullable&&`Required`,e.comment].filter(Boolean).join(` · `)})]},e.name))})]})})]}),s&&`tables`in s&&(0,YF.jsxs)(YF.Fragment,{children:[(0,YF.jsx)(`p`,{className:`sf-object-muted`,children:s.tables.length===0?`No tables found.`:`${s.more?`The first `:``}${s.tables.length} ${s.tables.length===1?`table`:`tables`}${s.more?`; more exist`:``}.`}),(0,YF.jsx)(`div`,{className:`sf-info-scroll`,tabIndex:0,role:`region`,"aria-label":`Tables`,children:(0,YF.jsxs)(`table`,{className:`sf-info-table`,children:[(0,YF.jsx)(`thead`,{children:(0,YF.jsxs)(`tr`,{children:[(0,YF.jsx)(`th`,{scope:`col`,children:`Table`}),(0,YF.jsx)(`th`,{scope:`col`,children:`Kind`}),(0,YF.jsx)(`th`,{scope:`col`,children:`Notes`})]})}),(0,YF.jsx)(`tbody`,{children:s.tables.map(e=>(0,YF.jsxs)(`tr`,{children:[(0,YF.jsx)(`th`,{scope:`row`,children:qF({schema:e.ref?.schema,table:e.ref?.table})}),(0,YF.jsx)(`td`,{children:[QF[e.kind]??`Table`,e.format?Cx[e.format]?.toLowerCase():``].filter(Boolean).join(`, `)}),(0,YF.jsx)(`td`,{children:e.comment})]},qF(e.ref??{})))})]})})]})]})}var YF,XF,ZF,QF,$F=n((()=>{YF=WA(),vS(),XF=NM(),GN(),cP(),HA(),ZF={format:e=>NA().format(e)},QF={[Sx.TABLE]:`Table`,[Sx.VIEW]:`View`,[Sx.MATERIALIZED_VIEW]:`Materialised view`,[Sx.EXTERNAL]:`External table`}}));function eI(e){return!e.table&&e.path?e.path.replace(/\/+$/,``).split(`/`).slice(-2).join(`/`):[e.schema,e.table,e.column].filter(Boolean).join(`.`)}function tI(e,t,n){if(t.length===0)return;e.setData(nI,JSON.stringify(t));let r=t.find(e=>e.table);r&&e.setData(AF,JSON.stringify({sourceId:r.sourceId,table:r.table,column:r.column})),e.setData(`text/plain`,n??t.map(eI).join(`, `))}var nI,rI=n((()=>{jF(),nI=`application/x-surfaces-refs+json`}));function iI(e,t,n){return`JOIN ${t} ON ${n.map(n=>`${e}.${n.leftColumn} = ${t}.${n.rightColumn}`).join(` AND `)}`}function aI(e){let{sourceId:t,height:n=480,pageSize:r=200}=e,i=VN(e.dataSource),a=NF(e.discovery),o=RM(),s=dM[o?.theme.density??`comfortable`].rowHeight-4,[c,l]=(0,sI.useState)(``),[u,d]=(0,sI.useState)({}),[f,p]=(0,sI.useState)({}),[m,h]=(0,sI.useState)(new Set),[g,_]=(0,sI.useState)({}),[v,y]=(0,sI.useState)(0),[b,x]=(0,sI.useState)(),[S,C]=(0,sI.useState)(``),w=gP(),[T,E]=(0,sI.useState)(0),D=(0,sI.useRef)(null),O=(0,sI.useCallback)(async(e,n,a,o=``)=>{let{tables:s,nextPageToken:c}=await i.listTables({sourceId:t,...a,pageSize:r,pageToken:o});return{nodes:s.map(r=>{let i=r.ref;return{id:`${e}/t:${i.catalog}.${i.schema}.${i.table}`,parent:e,level:n,kind:`table`,label:i.table,tag:lI[r.format],expandable:!0,table:{catalog:i.catalog,schema:i.schema,table:i.table},trail:[i.table.toLowerCase()],item:{kind:`table`,sourceId:t,table:i.table,catalog:i.catalog,schema:i.schema}}}),more:c?{level:n,where:a,token:c}:void 0}},[i,t,r]),k=(0,sI.useCallback)(async e=>{let n=(e?.level??0)+1,r=e?.id??cI;if(!e){let{catalogs:e}=await i.listCatalogs({sourceId:t});if(e.length!==1)return e.map(e=>({id:`c:${e.name}`,parent:r,level:n,kind:`catalog`,label:e.name,expandable:!0,trail:[],item:{kind:`catalog`,sourceId:t,table:``,catalog:e.name}}));let a=e[0].name,{schemas:o}=await i.listSchemas({sourceId:t,catalog:a});return o.length===1?O(r,n,{catalog:a,schema:o[0].name,search:``}):o.map(e=>({id:`s:${a}.${e.name}`,parent:r,level:n,kind:`schema`,label:e.name,expandable:!0,trail:[],item:{kind:`schema`,sourceId:t,table:``,catalog:a,schema:e.name}}))}if(e.kind===`catalog`){let{schemas:a}=await i.listSchemas({sourceId:t,catalog:e.label});return a.map(i=>({id:`${r}/s:${i.name}`,parent:r,level:n,kind:`schema`,label:i.name,expandable:!0,trail:[],item:{kind:`schema`,sourceId:t,table:``,catalog:e.label,schema:i.name}}))}if(e.kind===`schema`)return O(r,n,{catalog:e.item?.catalog??``,schema:e.label,search:``});if((e.kind===`table`||e.kind===`join`)&&e.table){let o=((await i.describeTable({sourceId:t,ref:e.table})).table?.columns??[]).map(i=>({id:`${r}/col:${i.name}`,parent:r,level:n,kind:`column`,label:i.name,meta:i.nativeType.toLowerCase(),expandable:!1,trail:e.trail,item:{kind:`column`,sourceId:t,table:e.table.table,column:i.name,catalog:e.table.catalog,schema:e.table.schema}}));return a?[...o,{id:`${r}/joins`,parent:r,level:n,kind:`joins`,label:`Joins`,expandable:!0,table:e.table,trail:e.trail}]:o}if(e.kind===`joins`&&e.table&&a){let{relations:i}=await a.getRelated({ref:{sourceId:t,kind:Bx.TABLE,catalog:e.table.catalog,schema:e.table.schema,table:e.table.table},kinds:[Wx.JOIN]}),o=i.filter(t=>t.object?.ref&&!e.trail.includes(t.object.ref.table.toLowerCase()));return o.length===0?[{id:`${r}/none`,parent:r,level:n,kind:`note`,label:i.length===0?`No joins found`:`No further joins`,expandable:!1,trail:e.trail}]:o.map(i=>{let a=i.object.ref,o=i.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn}));return{id:`${r}/j:${a.table}`,parent:r,level:n,kind:`join`,label:a.table,meta:o.map(e=>e.leftColumn===e.rightColumn?`on ${e.leftColumn}`:`on ${e.leftColumn} = ${e.rightColumn}`).join(`, `),tag:i.inferred?`Inferred`:void 0,expandable:!0,table:{catalog:a.catalog,schema:a.schema,table:a.table},trail:[...e.trail,a.table.toLowerCase()],certification:i.object?.certification,item:{kind:`join`,sourceId:t,table:a.table,catalog:a.catalog,schema:a.schema,join:{from:e.table.table,keys:o,inferred:i.inferred}}}})}return[]},[i,a,t,O]),ee=(0,sI.useCallback)((e,t)=>{d(t=>({...t,[e]:`loading`})),t.then(t=>{let n=Array.isArray(t)?{nodes:t}:t;d(t=>({...t,[e]:n.nodes})),p(t=>{let{[e]:r,...i}=t;return n.more?{...i,[e]:{...n.more,loading:!1}}:i})}).catch(t=>d(n=>({...n,[e]:{error:aP(t)}})))},[]);(0,sI.useEffect)(()=>{h(new Set),y(0);let e=c.trim(),t=setTimeout(()=>{d({}),p({}),ee(cI,e?O(cI,1,{catalog:``,schema:``,search:e}):k(void 0))},e?180:0);return()=>clearTimeout(t)},[ee,k,O,c]),(0,sI.useEffect)(()=>{if(!a)return;let e=!0;return a.search({query:``,kinds:[Bx.TABLE],sourceIds:[t],certificationStatuses:[Ux.CERTIFIED,Ux.DEPRECATED],pageSize:1e3}).then(t=>{if(!e)return;let n={};for(let e of t.hits)e.object?.certification&&e.object.ref&&(n[e.object.ref.table.toLowerCase()]=e.object.certification);_(n)}).catch(()=>{}),()=>{e=!1}},[a,t]);let te=e=>{e.expandable&&(h(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),u[e.id]===void 0&&ee(e.id,k(e)))},A=(0,sI.useMemo)(()=>{let e=[],t=(n,r)=>{let i=u[n];if(i!==void 0){if(i===`loading`)return void e.push({id:`${n}/loading`,parent:n,level:r,kind:`note`,label:`Loading…`,expandable:!1,trail:[]});if(!Array.isArray(i))return void e.push({id:`${n}/error`,parent:n,level:r,kind:`note`,label:i.error,expandable:!1,error:!0,trail:[]});for(let n of i)e.push(n),m.has(n.id)&&t(n.id,n.level+1);f[n]&&e.push({id:`${n}/more`,parent:n,level:f[n].level,kind:`more`,label:`Loading more tables…`,expandable:!1,trail:[]})}};return t(cI,1),e},[u,m,f]),ne=Math.max(s,n-44),re=Math.max(0,Math.floor(T/s)-4),ie=Math.min(A.length,re+Math.ceil(ne/s)+8);(0,sI.useEffect)(()=>{for(let e=re;e<ie;e++){let t=A[e];if(t?.kind!==`more`)continue;let n=t.parent,r=f[n];r&&!r.loading&&(p(e=>e[n]?{...e,[n]:{...e[n],loading:!0}}:e),O(n,r.level,r.where,r.token).then(e=>{d(t=>{let r=t[n];return Array.isArray(r)?{...t,[n]:[...r,...e.nodes]}:t}),p(t=>{let{[n]:r,...i}=t;return e.more?{...i,[n]:{...e.more,loading:!1}}:i})}).catch(()=>{p(e=>e[n]?{...e,[n]:{...e[n],loading:!1}}:e)}))}},[re,ie,A,f,O]);let ae=e=>e.kind===`join`&&e.join?iI(e.join.from,e.table,e.join.keys):e.column??(e.table||e.schema||e.catalog||``),[oe,se]=(0,sI.useState)(()=>new Set),ce=A.some(e=>e.kind===`table`&&e.level===1),le=e=>e.kind===`table`||e.kind===`column`?{sourceId:e.sourceId,kind:e.kind,...e.catalog&&!ce?{catalog:e.catalog}:{},...e.schema&&!ce?{schema:e.schema}:{},table:e.table,...e.column?{column:e.column}:{}}:void 0,ue=e=>{let t=A.filter(e=>oe.has(e.id)&&e.item&&le(e.item)).map(e=>e.item);return t.length>1&&t.includes(e)?t:le(e)?[e]:[]},de=t=>{let n=ue(t),r=n.map(e=>le(e));r.length!==0&&e.onAttach&&(e.onAttach(r,n),C(r.length===1?`Added ${r[0].column??r[0].table}.`:`Added ${r.length} items.`))},fe=(e,t)=>{let n=A[e];n?.item&&le(n.item)&&(se(r=>{let i=new Set(r);if(t===`toggle`)i.has(n.id)?i.delete(n.id):i.add(n.id);else{let[t,n]=v<=e?[v,e]:[e,v];for(let e=t;e<=n;e++)A[e]?.item&&le(A[e].item)&&i.add(A[e].id)}return C(i.size===0?``:`${i.size} selected. Drag them, or press Shift+Enter to add them.`),i}),y(e))},pe=(e,t)=>void hP(e).then(e=>C(e?`Copied ${t}.`:`Could not copy: the browser refused access to the clipboard.`)),me=(t,n)=>e.onUseSql?e.onUseSql(t,n):pe(t,`the SQL`),he=t=>e.onShowInfo?e.onShowInfo(t):x(t),ge=n=>{let r=qF({catalog:n.catalog,schema:n.schema,table:n.table}),a=ae(n),o=ue(n).length,s=[...e.onAttach&&o>0?[{separator:!0},{label:o>1?`${e.attachLabel??`Add to chat`}: ${o} items`:e.attachLabel??`Add to chat`,hint:`Shift Enter`,onSelect:()=>de(n)}]:[],{separator:!0},{label:`Copy name`,hint:`Ctrl/⌘ C`,onSelect:()=>pe(n.kind===`join`?a:qF({catalog:n.catalog,schema:n.schema,table:n.table,column:n.column}),`the name`)},...e.onInsert?[{label:n.kind===`join`?`Insert JOIN clause`:`Insert name into the editor`,hint:`Insert`,onSelect:()=>e.onInsert?.(a,n)}]:[]];if(n.kind===`catalog`||n.kind===`schema`)return[{label:`Show ${n.kind===`catalog`?`database`:`schema`} details`,onSelect:()=>he(n)},...s];if(n.kind===`table`)return[{label:`Show table details`,onSelect:()=>he(n)},{separator:!0},{label:`SQL: all rows`,onSelect:()=>me(`SELECT *\nFROM ${r}`,n)},{label:`SQL: every column by name`,onSelect:()=>void i.describeTable({sourceId:t,ref:{catalog:n.catalog??``,schema:n.schema??``,table:n.table}}).then(e=>me(`SELECT\n${(e.table?.columns??[]).map(e=>` ${qF({column:e.name})}`).join(`,
|
|
23
|
+
`)}\nFROM ${r}`,n)).catch(e=>C(`Could not read the columns: ${aP(e)}`))},{label:`SQL: count rows`,onSelect:()=>me(`SELECT COUNT(*) AS row_count\nFROM ${r}`,n)},...s];if(n.kind===`column`&&n.column){let e=qF({column:n.column});return[{label:`SQL: count each value`,onSelect:()=>me(`SELECT ${e}, COUNT(*) AS row_count\nFROM ${r}\nGROUP BY ${e}\nORDER BY row_count DESC`,n)},{label:`SQL: range and missing values`,onSelect:()=>me(`SELECT MIN(${e}) AS lowest, MAX(${e}) AS highest, COUNT(*) - COUNT(${e}) AS missing\nFROM ${r}`,n)},{label:`Show table details`,onSelect:()=>he({...n,kind:`table`,column:void 0})},...s]}return n.kind===`join`&&n.join?[{label:`SQL: both tables joined`,onSelect:()=>me(`SELECT *\nFROM ${qF({table:n.join.from})}\n${a}`,n)},{label:`Show table details`,onSelect:()=>he({...n,kind:`table`,join:void 0})},...s]:[]},j=e=>{let t=Math.max(0,Math.min(A.length-1,e));y(t);let n=D.current;n&&(t*s<n.scrollTop?n.scrollTop=t*s:(t+1)*s>n.scrollTop+ne&&(n.scrollTop=(t+1)*s-ne))},_e=t=>{let n=A[v],r=()=>t.preventDefault();if(t.key===`ArrowDown`)return r(),j(v+1);if(t.key===`ArrowUp`)return r(),j(v-1);if(t.key===`Home`)return r(),j(0);if(t.key===`End`)return r(),j(A.length-1);if(!n)return;let i=m.has(n.id);if(t.key===`ArrowRight`){if(r(),n.expandable&&!i)return te(n);if(i)return j(v+1)}if(t.key===`ArrowLeft`){if(r(),i)return te(n);let e=A.findIndex(e=>e.id===n.parent);if(e>=0)return j(e)}if(t.key===`Enter`&&t.shiftKey&&e.onAttach){let e=A.find(e=>oe.has(e.id)&&e.item)?.item,t=oe.has(n.id)||!e?n.item:e;if(t)return r(),de(t)}if(t.key===` `&&n.item)return r(),fe(v,`toggle`);if(t.key===`Escape`&&oe.size>0)return r(),se(new Set),C(``);if(t.key===`Enter`&&(r(),n.item?e.onSelect?.(n.item):te(n)),t.key===`Insert`&&n.item)return r(),e.onInsert?.(ae(n.item),n.item);if((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()===`c`&&n.item)return r(),pe(ae(n.item),`the name`);if((t.altKey&&t.key===`Enter`||t.key===`i`&&(t.ctrlKey||t.metaKey))&&n.item&&n.item.kind!==`join`)return r(),he(n.item.kind===`column`?{...n.item,kind:`table`,column:void 0}:n.item)},ve=e=>t=>{let n=ue(e).map(e=>le(e));n.length>0?tI(t.dataTransfer,n,n.length===1?ae(e):void 0):t.dataTransfer.setData(`text/plain`,ae(e)),t.dataTransfer.effectAllowed=`copy`},ye=[];for(let t=re;t<ie;t++){let n=A[t],r=m.has(n.id),i=n.item,a=n.certification??(n.kind===`table`?g[n.label.toLowerCase()]:void 0);ye.push((0,oI.jsxs)(`div`,{id:`sf-browser-${t}`,className:`sf-schema-row sf-browser-row`,"data-kind":n.kind===`more`?`note`:n.kind,"data-active":t===v||void 0,"data-error":n.error||void 0,style:{top:t*s,height:s,paddingInlineStart:`calc(var(--sf-space-2) + ${n.level-1} * var(--sf-space-4))`},role:`treeitem`,"aria-level":n.level,"aria-expanded":n.expandable?r:void 0,"aria-selected":oe.size>0?oe.has(n.id):t===v,"data-picked":oe.has(n.id)||void 0,draggable:i!==void 0,onDragStart:i?ve(i):void 0,onClick:r=>{if(r.ctrlKey||r.metaKey)return fe(t,`toggle`);if(r.shiftKey)return fe(t,`range`);oe.size>0&&(se(new Set),C(``)),y(t),te(n),i&&e.onSelect?.(i)},onDoubleClick:()=>i&&e.onInsert?.(ae(i),i),onContextMenu:i?e=>{y(t),w.open(e,`${n.label} actions`,ge(i))}:void 0,children:[(0,oI.jsx)(`span`,{className:`sf-schema-caret`,"aria-hidden":`true`,"data-open":r||void 0,children:n.expandable?`▸`:``}),(0,oI.jsx)(`span`,{className:`sf-schema-name`,children:n.label}),(0,oI.jsx)(FF,{certification:a}),n.meta&&(0,oI.jsx)(`span`,{className:`sf-schema-meta`,children:n.meta}),n.tag&&(0,oI.jsx)(`span`,{className:`sf-schema-tag`,children:n.tag}),(n.kind===`table`||n.kind===`join`)&&i&&e.renderActions&&(0,oI.jsx)(`span`,{className:`sf-schema-actions`,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:e.renderActions(i)})]},n.id))}let be=u[cI];return(0,oI.jsxs)(`div`,{className:[`sf-schema`,e.className].filter(Boolean).join(` `),style:{height:n},children:[(0,oI.jsx)(`input`,{className:`sf-input sf-schema-search`,type:`search`,placeholder:`Search tables`,"aria-label":`Search tables`,value:c,onChange:e=>l(e.target.value)}),(0,oI.jsxs)(`div`,{ref:D,className:`sf-schema-list`,role:`tree`,"aria-label":e.label??`Data objects`,"aria-busy":be===void 0||be===`loading`,"aria-activedescendant":A.length>0?`sf-browser-${v}`:void 0,tabIndex:0,"aria-multiselectable":`true`,"aria-keyshortcuts":`Shift+F10 Alt+Enter Insert Control+C Space Shift+Enter`,onKeyDown:_e,onContextMenu:e=>{let t=A[v]?.item;e.target===e.currentTarget&&t&&w.open(e,`${A[v].label} actions`,ge(t))},onScroll:e=>E(e.currentTarget.scrollTop),children:[(0,oI.jsx)(`div`,{style:{height:A.length*s,position:`relative`},children:ye}),Array.isArray(be)&&be.length===0&&(0,oI.jsx)(`p`,{className:`sf-schema-empty`,children:c.trim()?`No tables match “${c.trim()}”.`:`This source has nothing to show.`})]}),(0,oI.jsx)(`p`,{className:`sf-schema-note`,role:`status`,children:S}),b&&(0,oI.jsx)(`div`,{className:`sf-schema-info`,children:(0,oI.jsx)(JF,{dataSource:i,sourceId:t,catalog:b.catalog,schema:b.schema,table:b.kind===`table`?b.table:void 0,onClose:()=>{x(void 0),D.current?.focus()}})}),w.element]})}var oI,sI,cI,lI,uI=n((()=>{oI=WA(),vS(),jM(),sI=NM(),GN(),cP(),GF(),yP(),GM(),$F(),rI(),cI=``,lI={[Cx.PARQUET]:`Parquet`,[Cx.CSV]:`CSV`,[Cx.JSON]:`JSON`,[Cx.ICEBERG]:`Iceberg`,[Cx.DELTA]:`Delta`}}));function dI({icon:e}){return typeof e==`string`&&e in gI?(0,mI.jsx)(`svg`,{className:`sf-item-control-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,mI.jsx)(`path`,{d:gI[e]})}):(0,mI.jsx)(`span`,{className:`sf-item-control-icon`,children:e})}function fI({label:e,controls:t,show:n=`hover`,quietable:r=!0,className:i}){let a=(0,hI.useRef)(null),[o,s]=(0,hI.useState)(0),[c,l]=(0,hI.useState)(),u=Math.min(o,Math.max(0,t.length-1)),d=e=>{let n=(e+t.length)%t.length;s(n),a.current?.querySelectorAll(`button`)[n]?.focus()};return t.length===0?null:(0,mI.jsx)(`div`,{ref:a,className:[`sf-item-controls`,i].filter(Boolean).join(` `),role:`toolbar`,"aria-label":e,"data-show":n,"data-quietable":r||void 0,onKeyDown:e=>{if(e.key===`ArrowRight`||e.key===`ArrowDown`)d(u+1);else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)d(u-1);else if(e.key===`Home`)d(0);else if(e.key===`End`)d(t.length-1);else if(e.key===`Escape`&&c!==void 0)l(void 0);else return;e.preventDefault(),e.stopPropagation()},children:t.map((e,t)=>(0,mI.jsxs)(`button`,{type:`button`,className:`sf-item-control`,"data-control":e.id,"data-danger":e.danger||void 0,"data-pinned":e.pinned&&!e.disabled||void 0,"aria-label":e.label,"aria-pressed":e.pressed,"aria-disabled":e.disabled||void 0,tabIndex:t===u?0:-1,onClick:()=>!e.disabled&&e.onSelect(),onFocus:()=>{s(t),l(t)},onBlur:()=>l(e=>e===t?void 0:e),onPointerEnter:()=>l(t),onPointerLeave:()=>l(e=>e===t?void 0:e),children:[(0,mI.jsx)(dI,{icon:e.icon}),c===t&&(0,mI.jsxs)(`span`,{className:`sf-item-tip`,"aria-hidden":`true`,children:[e.label,e.disabled?` (not available here)`:``]})]},e.id))})}function pI(e,t){let n=[],r=(e,t,r,i,a={})=>{i!==void 0&&n.push({id:e,label:t,icon:r,onSelect:i||(()=>void 0),...i===!1?{disabled:!0}:{},...a})};return r(`edit`,`Change ${e}`,`edit`,t.edit),t.view&&r(`view`,t.view.now===`chart`?`Show ${e} as a table`:`Show ${e} as a chart`,t.view.now===`chart`?`table`:`chart`,t.view.toggle),r(`wider`,`Make ${e} wider`,`wider`,t.wider),r(`narrower`,`Make ${e} narrower`,`narrower`,t.narrower),r(`earlier`,`Move ${e} earlier`,`earlier`,t.earlier),r(`later`,`Move ${e} later`,`later`,t.later),r(`up`,`Move ${e} up`,`up`,t.up),r(`down`,`Move ${e} down`,`down`,t.down),r(`duplicate`,`Duplicate ${e}`,`duplicate`,t.duplicate),r(`remove`,`Remove ${e}`,`remove`,t.remove,{danger:!0}),n}var mI,hI,gI,_I,vI=n((()=>{mI=WA(),hI=NM(),gI={edit:`M4 20h4L19 9l-4-4L4 16z M14 6l4 4`,chart:`M4 4v16h16 M8 16v-5 M12 16V8 M16 16v-9`,table:`M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14`,wider:`M3 12h18 M7 8l-4 4 4 4 M17 8l4 4-4 4`,narrower:`M3 12h6 M21 12h-6 M5 8l4 4-4 4 M19 8l-4 4 4 4`,earlier:`M19 12H5 M11 6l-6 6 6 6`,later:`M5 12h14 M13 6l6 6-6 6`,up:`M12 19V5 M6 11l6-6 6 6`,down:`M12 5v14 M6 13l6 6 6-6`,duplicate:`M8 8h11v11H8z M5 16V5h11`,remove:`M5 7h14 M10 7V4h4v3 M7 7l1 13h8l1-13 M10 11v6 M14 11v6`,add:`M12 5v14 M5 12h14`,close:`M6 6l12 12 M18 6L6 18`,menu:`M4 7h16 M4 12h16 M4 17h16`,fold:`M4 4v16 M20 12H9 M14 7l-5 5 5 5`,unfold:`M20 4v16 M4 12h11 M10 7l5 5-5 5`,confirm:`M5 12l5 5 9-10`,power:`M12 3v8 M7 6.5a7 7 0 1 0 10 0`,"sign-out":`M10 4H5v16h5 M15 8l4 4-4 4 M19 12H9`,more:`M4.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0 M10.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0 M16.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0`},Object.keys(gI),_I=`sf-controls-host`}));function yI(e){return P.isUtf8(e)||P.isLargeUtf8(e)||P.isDictionary(e)}function bI(e){return yI(e)?[...kI,...OI]:P.isBool(e)?[DI[0],DI[1],...OI]:[...DI,...OI]}function xI(e,t){let n=e.trim();if(P.isInt(t)){if(!/^-?\d+$/.test(n))throw Error(z(`filter.enterWholeNumber`));return{kind:{case:`intValue`,value:BigInt(n)}}}if(P.isDecimal(t)){if(!/^-?\d+(\.\d+)?$/.test(n))throw Error(z(`filter.enterNumber`));return{kind:{case:`decimalValue`,value:n}}}if(P.isFloat(t)){if(n===``||Number.isNaN(Number(n)))throw Error(z(`filter.enterNumber`));return{kind:{case:`doubleValue`,value:Number(n)}}}if(P.isBool(t)){if(!/^(true|false)$/i.test(n))throw Error(z(`filter.enterTrueFalse`));return{kind:{case:`boolValue`,value:n.toLowerCase()===`true`}}}if(P.isTimestamp(t)||P.isDate(t)){if(Number.isNaN(Date.parse(n)))throw Error(z(`filter.enterDate`));return{kind:{case:`temporalValue`,value:n}}}if(e===``)throw Error(z(`filter.enterValue`));return{kind:{case:`stringValue`,value:e}}}function SI(e){let t=AI.find(t=>t.operator===e.operator)?.label??`?`,n=(e.values??[]).map(e=>String(e.kind?.value??``));return`${e.column} ${t}${n.length>0?` ${n.join(`, `)}`:``}`}function CI({fields:e,filters:t,onChange:n,loadValues:r,now:i,relative:a,onRelativeChange:o,className:s}){let c=(0,TI.useId)(),[l,u]=(0,TI.useState)(``),[d,f]=(0,TI.useState)(),[p,m]=(0,TI.useState)(``),[h,g]=(0,TI.useState)(),[_,v]=(0,TI.useState)({}),y=e.filter(e=>!P.isList(e.type)&&!P.isStruct(e.type)&&!P.isMap(e.type)),b=y.find(e=>e.name===l)??y[0],x=b?bI(b.type):[],S=x.find(e=>e.operator===d)??x[0],C=b!==void 0&&(P.isTimestamp(b.type)||P.isDate(b.type)),w=b!==void 0&&r!==void 0&&(yI(b.type)||P.isBool(b.type)),T=b?.name;(0,TI.useEffect)(()=>{if(!w||!T||!r||_[T])return;let e=!0;return r(T).then(t=>e&&v(e=>({...e,[T]:t}))).catch(()=>e&&v(e=>({...e,[T]:[]}))),()=>{e=!1}},[w,T,r]);let E=w&&T?_[T]??[]:[],D=e=>{let r=EI.find(t=>t.id===e);if(!r||!b)return;if(o)return o({...a??{},[b.name]:r.id});let s=r.start((i??(()=>new Date))()).toISOString().slice(0,10);n([...t.filter(e=>e.column!==b.name||e.operator!==sx.GTE),{column:b.name,operator:sx.GTE,values:[{kind:{case:`temporalValue`,value:s}}]}])};return(0,wI.jsxs)(`div`,{className:[`sf-filters`,s].filter(Boolean).join(` `),children:[(t.length>0||Object.keys(a??{}).length>0)&&(0,wI.jsxs)(`ul`,{className:`sf-filter-chips`,"aria-label":z(`filter.active`),children:[Object.entries(a??{}).map(([e,t])=>(0,wI.jsxs)(`li`,{className:`sf-filter-chip`,"data-relative":`true`,children:[(0,wI.jsxs)(`span`,{children:[e,`: `,FC(t).toLowerCase()]}),(0,wI.jsx)(`button`,{type:`button`,"aria-label":z(`filter.remove`,{filter:`${e}: ${FC(t).toLowerCase()}`}),onClick:()=>o?.(Object.fromEntries(Object.entries(a??{}).filter(([t])=>t!==e))),children:(0,wI.jsx)(dI,{icon:`close`})})]},`relative-${e}`)),t.map((e,r)=>(0,wI.jsxs)(`li`,{className:`sf-filter-chip`,children:[(0,wI.jsx)(`span`,{children:SI(e)}),(0,wI.jsx)(`button`,{type:`button`,"aria-label":z(`filter.remove`,{filter:SI(e)}),onClick:()=>n(t.filter((e,t)=>t!==r)),children:(0,wI.jsx)(dI,{icon:`close`})})]},`${SI(e)}-${r}`))]}),(0,wI.jsxs)(`form`,{className:`sf-filter-form`,onSubmit:e=>{if(e.preventDefault(),b&&S)try{let e=S.value?[xI(p,b.type)]:[];n([...t,{column:b.name,operator:S.operator,values:e}]),m(``),g(void 0)}catch(e){g(e instanceof Error?e.message:String(e))}},"aria-label":z(`filter.form`),children:[(0,wI.jsx)(`select`,{className:`sf-input`,"aria-label":z(`filter.column`),value:b?.name??``,disabled:y.length===0,onChange:e=>{u(e.target.value),f(void 0),g(void 0)},children:y.map(e=>(0,wI.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,wI.jsx)(`select`,{className:`sf-input`,"aria-label":z(`filter.comparison`),value:S?.operator??``,disabled:y.length===0,onChange:e=>f(Number(e.target.value)),children:x.map(e=>(0,wI.jsx)(`option`,{value:e.operator,children:e.label},e.operator))}),S?.value&&(0,wI.jsx)(`input`,{className:`sf-input sf-filter-value`,"aria-label":z(`filter.value`),"aria-invalid":h?!0:void 0,"aria-describedby":h?`${c}-problem`:void 0,placeholder:E.length>0?z(`filter.typeOrPick`):z(`filter.value`),type:C?`date`:`text`,list:E.length>0?`${c}-values`:void 0,value:p,onChange:e=>{m(e.target.value),g(void 0)}}),E.length>0&&(0,wI.jsx)(`datalist`,{id:`${c}-values`,children:E.map(e=>(0,wI.jsx)(`option`,{value:e},e))}),(0,wI.jsx)(`button`,{type:`submit`,className:`sf-button`,disabled:y.length===0,children:z(`filter.add`)}),C&&(0,wI.jsxs)(`select`,{className:`sf-input`,"aria-label":z(`filter.quickRange`),value:``,onChange:e=>D(e.target.value),children:[(0,wI.jsx)(`option`,{value:``,children:z(`filter.quickRangeChoose`)}),EI.map(e=>(0,wI.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),h&&(0,wI.jsx)(`span`,{id:`${c}-problem`,className:`sf-filter-problem`,role:`alert`,children:h})]})]})}var wI,TI,EI,DI,OI,kI,AI,jI=n((()=>{wI=WA(),vS(),_p(),TI=NM(),rw(),HA(),vI(),EI=[{id:`7d`,get label(){return z(`filter.range7d`)},start:e=>new Date(e.getTime()-6048e5)},{id:`30d`,get label(){return z(`filter.range30d`)},start:e=>new Date(e.getTime()-2592e6)},{id:`90d`,get label(){return z(`filter.range90d`)},start:e=>new Date(e.getTime()-7776e6)},{id:`12m`,get label(){return z(`filter.range12m`)},start:e=>new Date(Date.UTC(e.getUTCFullYear()-1,e.getUTCMonth(),e.getUTCDate()))},{id:`month`,get label(){return z(`filter.rangeMonth`)},start:e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1))},{id:`year`,get label(){return z(`filter.rangeYear`)},start:e=>new Date(Date.UTC(e.getUTCFullYear(),0,1))}],DI=[{operator:sx.EQ,label:`=`,value:!0},{operator:sx.NEQ,label:`≠`,value:!0},{operator:sx.GT,label:`>`,value:!0},{operator:sx.GTE,label:`≥`,value:!0},{operator:sx.LT,label:`<`,value:!0},{operator:sx.LTE,label:`≤`,value:!0}],OI=[{operator:sx.IS_NULL,get label(){return z(`filter.isEmpty`)},value:!1},{operator:sx.IS_NOT_NULL,get label(){return z(`filter.isNotEmpty`)},value:!1}],kI=[{operator:sx.CONTAINS,get label(){return z(`filter.contains`)},value:!0},{operator:sx.EQ,get label(){return z(`filter.is`)},value:!0},{operator:sx.NEQ,get label(){return z(`filter.isNot`)},value:!0},{operator:sx.STARTS_WITH,get label(){return z(`filter.startsWith`)},value:!0},{operator:sx.ENDS_WITH,get label(){return z(`filter.endsWith`)},value:!0}],AI=[...kI,...DI,...OI]}));function MI(e,t,n){return{baseSql:n.sql,filters:n.filters,parameters:n.parameters,groupBy:e.filter(e=>!VI(e)).map(BI),buckets:e.filter(VI).map(e=>({column:BI(e),by:{case:`grain`,value:TF[VI(e)]}})),aggregates:hF(t).map(e=>({function:wF[e.measure.aggregate],column:e.measure.column??``,alias:e.column,percentile:e.measure.aggregate===`percentile`?e.measure.percentile??.9:0})),sorts:e.map(e=>({column:BI(e),direction:ax.ASC})),page:e.length>0?{limit:n.limit}:void 0}}function NI(e,t,n){if(e==null)return z(`pivot.none`);let r=t?XN(e,t).text:String(e);return n?n===`quarter`?`${r.slice(0,4)} Q${Math.floor(Number(r.slice(5,7))/3-1/3)+1}`:r.slice(0,UI[n]??r.length):r}function PI(e,t,n){let r=t.map(t=>{let n=e.getChild(BI(t));return{vector:n,type:n?.type,grain:VI(t)}}),i=n.map(t=>{let n=e.getChild(t);return{vector:n,type:n?.type}}),a={values:new Map,keys:[]};for(let t=0;t<e.numRows;t++){let e=r.map(e=>e.vector?.get(t)??null),n=e.map(e=>e==null?`\0`:String(e)).join(WI);a.values.has(n)||a.keys.push({id:n,labels:e.map((e,t)=>NI(e,r[t].type,r[t].grain)),order:e}),a.values.set(n,i.map(e=>{let n=e.vector?.get(t);return n==null||!e.type?``:XN(n,e.type).text}))}return a}function FI(e,t){for(let n=0;n<e.length;n++){let[r,i]=[e[n],t[n]];if(r!==i)return r==null?1:i==null?-1:(typeof r==`number`||typeof r==`bigint`)&&(typeof i==`number`||typeof i==`bigint`)?r<i?-1:1:String(r).localeCompare(String(i))}return 0}function II(e){let{rows:t,columns:n,aliases:r}=e,i=PI(e.cells,[...t,...n],r),a=PI(e.rowTotals??e.cells,t,r),o=PI(e.columnTotals??e.cells,n,r),s=n.length===0?[]:[...o.keys].sort((e,t)=>FI(e.order,t.order)),c=r.map(()=>``),l=(e,r)=>[e,r].filter((e,r)=>r===0?t.length>0:n.length>0).join(WI),u=e.grandTotal?PI(e.grandTotal,[],r).values.get(``):void 0;return{rowKeys:t.length===0?[{id:``,labels:[]}]:a.keys,columnKeys:s.slice(0,e.maxColumns),hiddenColumns:Math.max(0,s.length-e.maxColumns),cell:(e,t)=>i.values.get(l(e,t))??c,rowTotal:t=>(e.rowTotals?a.values.get(t):void 0)??c,columnTotal:t=>(e.columnTotals?o.values.get(t):void 0)??c,grandTotal:u??c}}function LI(e){let{sourceId:t,sql:n,rows:r,columns:i=[],measures:a,filters:o,parameters:s,timeTravel:c,notBefore:l,totals:u=!0,maxColumns:d=50,limit:f=2e4,height:p=420}=e,m=VN(e.dataSource),[h,g]=(0,zI.useState)({loading:!0}),_=(0,zI.useMemo)(()=>hF(a),[JSON.stringify(a)]),v=a.every(e=>e.aggregate===`sum`||e.aggregate===`count`||e.aggregate===`count_distinct`)?`pivot.total`:`pivot.all`,y=JSON.stringify([t,n,r,i,a,o,s,c,l,u,d,f],(e,t)=>typeof t==`bigint`?`${t}n`:t);(0,zI.useEffect)(()=>{let e=new AbortController;if(g(e=>({...e,loading:!0,error:void 0})),a.length===0||r.length+i.length===0){g({loading:!1});return}let p={sql:n,filters:o,parameters:s,limit:f+1},h=n=>JS(m.execute({sourceId:t,timeTravel:c,notBefore:l,query:MI(n,a,p)},{signal:e.signal})).then(e=>(v.push(...uP(e.header.notices)),e.table)),v=[],y=i.length>0&&r.length>0;return Promise.all([h([...r,...i]),u&&y?h(r):void 0,u&&y?h(i):void 0,u?h([]):void 0]).then(([t,n,a,o])=>{if(e.signal.aborted)return;let s=II({rows:r,columns:i,aliases:_.map(e=>e.column),cells:t,rowTotals:n,columnTotals:a,grandTotal:o,maxColumns:d});g({loaded:{model:s,truncated:t.numRows>f,empty:t.numRows===0,notes:[...new Set(v)]},loading:!1})}).catch(t=>{e.signal.aborted||g({error:aP(t),loading:!1})}),()=>e.abort()},[m,y]);let b=[`sf-pivot`,e.className].filter(Boolean).join(` `);if(h.error)return(0,RI.jsx)(`div`,{className:b,children:(0,RI.jsx)(`p`,{className:`sf-chart-message`,role:`alert`,"data-error":h.error,children:e.errorMessage??h.error})});let x=h.loaded?.model;if(!x)return(0,RI.jsx)(`div`,{className:b,"aria-busy":h.loading,children:(0,RI.jsx)(`p`,{className:`sf-chart-message`,children:h.loading?z(`pivot.loading`):z(`pivot.choose`)})});if(h.loaded?.empty)return(0,RI.jsx)(`div`,{className:b,"aria-busy":h.loading,children:(0,RI.jsx)(`p`,{className:`sf-chart-message`,children:e.emptyMessage??z(`pivot.empty`)})});let S=x.columnKeys.length>0,C=S&&_.length>1,w=u&&S&&r.length>0,T=u&&r.length>0,E=(e,t,n=!1)=>e.map((e,r)=>(0,RI.jsx)(`td`,{className:`sf-pivot-value`,"data-total":n||void 0,children:e},`${t}-${r}`));return(0,RI.jsxs)(`div`,{className:b,"aria-busy":h.loading,children:[(0,RI.jsx)(`div`,{className:`sf-pivot-scroll`,style:{maxHeight:p},tabIndex:0,role:`region`,"aria-label":e.label??z(`pivot.label`),children:(0,RI.jsxs)(`table`,{children:[(0,RI.jsxs)(`thead`,{children:[(0,RI.jsxs)(`tr`,{children:[r.map(e=>(0,RI.jsx)(`th`,{scope:`col`,rowSpan:C?2:1,children:HI(e)},BI(e))),S?x.columnKeys.map(e=>(0,RI.jsx)(`th`,{scope:`colgroup`,colSpan:_.length,className:`sf-pivot-value`,children:e.labels.join(` / `)},e.id)):_.map(e=>(0,RI.jsx)(`th`,{scope:`col`,className:`sf-pivot-value`,children:e.label},e.column)),w&&(0,RI.jsx)(`th`,{scope:`colgroup`,colSpan:_.length,className:`sf-pivot-value`,"data-total":!0,children:z(v)})]}),C&&(0,RI.jsx)(`tr`,{children:[...x.columnKeys,...w?[{id:`total`}]:[]].flatMap(e=>_.map(t=>(0,RI.jsx)(`th`,{scope:`col`,className:`sf-pivot-value`,"data-total":e.id===`total`||void 0,children:t.label},`${e.id}-${t.column}`)))})]}),(0,RI.jsx)(`tbody`,{children:x.rowKeys.map(e=>(0,RI.jsxs)(`tr`,{children:[e.labels.map((e,t)=>(0,RI.jsx)(`th`,{scope:`row`,children:e},t)),S?x.columnKeys.flatMap(t=>E(x.cell(e.id,t.id),t.id)):E(x.cell(e.id,``),`value`),w&&E(x.rowTotal(e.id),`total`,!0)]},e.id))}),T&&(0,RI.jsx)(`tfoot`,{children:(0,RI.jsxs)(`tr`,{children:[(0,RI.jsx)(`th`,{scope:`row`,colSpan:r.length,children:z(v)}),S?x.columnKeys.flatMap(e=>E(x.columnTotal(e.id),e.id,!0)):E(x.grandTotal,`value`,!0),w&&E(x.grandTotal,`total`,!0)]})})]})}),h.loaded&&h.loaded.notes.length>0&&(0,RI.jsx)(`p`,{className:`sf-chart-note`,role:`note`,children:h.loaded.notes.join(` `)}),h.loaded?.truncated&&(0,RI.jsx)(`p`,{className:`sf-chart-note`,children:z(`pivot.truncated`,{limit:GI.format(f)})}),x.hiddenColumns>0&&(0,RI.jsx)(`p`,{className:`sf-chart-note`,children:z(`pivot.hiddenColumns`,{shown:GI.format(x.columnKeys.length),total:GI.format(x.columnKeys.length+x.hiddenColumns)})})]})}var RI,zI,BI,VI,HI,UI,WI,GI,KI=n((()=>{RI=WA(),rw(),vS(),zI=NM(),EF(),GN(),mP(),rP(),HA(),cP(),BI=e=>typeof e==`string`?e:e.column,VI=e=>typeof e==`string`?void 0:e.grain,HI=e=>typeof e==`string`?e:e.label??e.column,UI={year:4,month:7,day:10,week:10,hour:16,minute:16},WI=``,GI={format:e=>NA().format(e)}}));function qI(e,t){let n=t&&/^[=+\-@\t\r]/.test(e)?`'${e}`:e;return/[",\n\r]/.test(n)?`"${n.replace(/"/g,`""`)}"`:n}function JI(e){return`${e.map(e=>qI(e.name,!0)).join(`,`)}\r\n`}function YI(e,t){return`${e.map((e,n)=>{let r=t[n];return r==null?``:qI(P.isFloat(e.type)?String(r):XN(r,e.type).text,QI(e.type))}).join(`,`)}\r\n`}async function XI(e,t,n={}){let r=[],i,a=[],o=0,s=!1;for await(let c of e.execute(t,{signal:n.signal})){let e=c.part;if(e.case===`header`)i=e.value.arrowSchema,a=Cp(i,[]).schema.fields,r.push(JI(a));else if(e.case===`batch`&&i){let t=Cp(i,[e.value.arrowBatch]),s=a.map((e,n)=>t.getChildAt(n)),c=``;for(let e=0;e<t.numRows;e++)c+=YI(a,s.map(t=>t?.get(e)));r.push(c),o+=t.numRows,n.onProgress?.(o)}else e.case===`footer`&&(s=e.value.truncated)}if(!i)throw Error(`The result ended before it began.`);return{blob:new Blob([``,...r],{type:`text/csv;charset=utf-8`}),rows:o,truncated:s}}function ZI(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}var QI,$I=n((()=>{rw(),_p(),rP(),QI=e=>!(P.isInt(e)||P.isFloat(e)||P.isDecimal(e)||P.isBool(e)||P.isTimestamp(e)||P.isDate(e))}));function eL(e){if(typeof e!=`object`||!e)return;let t=e,n=String(t.name??t[`Node Type`]??t.operator??``).trim();if(!n)return;let r=[],i=(e,t)=>{t!=null&&t!==``&&typeof t!=`object`&&r.push([e,String(t)])},a=t.extra_info;if(typeof a==`object`&&a)for(let[e,t]of Object.entries(a))i(e,Array.isArray(t)?t.join(`, `):t);for(let e of[`Relation Name`,`Plan Rows`,`Total Cost`,`Filter`,`Join Type`])i(e,t[e]);let o=t.children??t.Plans;return{name:n,details:r,children:Array.isArray(o)?o.map(eL).filter(e=>e!==void 0):[]}}function tL(e){if(!e.trim())return[];try{let t=JSON.parse(e);return(Array.isArray(t)?t:[t]).map(e=>eL(e?.Plan??e)).filter(e=>e!==void 0)}catch{return[]}}function nL({node:e}){return(0,iL.jsxs)(`li`,{children:[(0,iL.jsxs)(`span`,{className:`sf-plan-step`,children:[(0,iL.jsx)(`strong`,{children:e.name.replace(/_/g,` `)}),e.details.map(([e,t])=>(0,iL.jsxs)(`span`,{className:`sf-plan-detail`,children:[e,`: `,t]},e))]}),e.children.length>0&&(0,iL.jsx)(`ul`,{children:e.children.map((e,t)=>(0,iL.jsx)(nL,{node:e},t))})]})}function rL(e){let{sourceId:t,sql:n,filters:r}=e,i=VN(e.dataSource),[a,o]=(0,aL.useState)({steps:[],text:``,executedSql:``,loading:!0}),s=JSON.stringify([t,n,r],(e,t)=>typeof t==`bigint`?`${t}n`:t);return(0,aL.useEffect)(()=>{let e=new AbortController;return o(e=>({...e,loading:!0,error:void 0})),i.explain({sourceId:t,query:{baseSql:n,filters:r}},{signal:e.signal}).then(t=>{e.signal.aborted||o({steps:tL(t.planJson),text:t.planText,executedSql:t.executedSql,loading:!1})}).catch(t=>{e.signal.aborted||o({steps:[],text:``,executedSql:``,error:aP(t),loading:!1})}),()=>e.abort()},[i,s]),a.error?(0,iL.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:a.error}):a.loading?(0,iL.jsx)(`p`,{className:`sf-object-muted`,children:`Asking the engine for its plan…`}):(0,iL.jsxs)(`div`,{className:[`sf-plan`,e.className].filter(Boolean).join(` `),children:[a.steps.length>0&&(0,iL.jsx)(`ul`,{className:`sf-plan-tree`,"aria-label":`Plan steps, outermost first`,children:a.steps.map((e,t)=>(0,iL.jsx)(nL,{node:e},t))}),a.text&&(0,iL.jsxs)(`details`,{open:a.steps.length===0,children:[(0,iL.jsx)(`summary`,{children:`The engine's plan text`}),(0,iL.jsx)(`pre`,{tabIndex:0,children:a.text})]}),a.steps.length===0&&!a.text&&(0,iL.jsx)(`p`,{className:`sf-object-muted`,children:`The engine returned no plan.`})]})}var iL,aL,oL=n((()=>{iL=WA(),aL=NM(),GN(),cP()}));function sL(e,t,n,r){return[bL,(i,a)=>{let o=r?i[0].toLowerCase():i[0];if(n.has(o))return`literal`;if(e.has(o))return`keyword`;if(t.has(o))return`type`;if(/^\s*\(/.test(a))return`function`}]}function cL(e){let t=(e??``).trim().toLowerCase();if(!t)return;let n=TL[t]??t;return n in wL?n:void 0}function lL(e,t){let n=wL[cL(t)??``];if(!n||e.length>1e5)return[{text:e}];let r=[],i=(e,t)=>{let n=r[r.length-1];n&&n.kind===t?n.text+=e:r.push(t?{text:e,kind:t}:{text:e})},a=0;outer:for(;a<e.length;){for(let[t,r]of n){t.lastIndex=a;let n=t.exec(e);if(!n||n[0].length===0)continue;let o=typeof r==`function`?r(n,e.slice(a+n[0].length,a+n[0].length+4)):r;i(n[0],o),a+=n[0].length;continue outer}i(e[a]),a++}return r}var uL,dL,fL,pL,mL,hL,gL,_L,vL,yL,bL,xL,SL,CL,wL,TL,EL=n((()=>{uL=e=>new Set(e.split(/\s+/).filter(Boolean)),dL=uL(`
|
|
23
24
|
select from where and or not in is null as on join inner left right full outer cross natural using group by order having limit offset top
|
|
24
25
|
qualify window over partition rows range between unbounded preceding following current row distinct all union intersect except minus with
|
|
25
26
|
recursive case when then else end asc desc nulls first last insert into values update set delete merge create replace table view temporary temp
|
|
26
27
|
drop alter add column primary key foreign references unique check default if exists cast try_cast like ilike similar escape any some sample
|
|
27
28
|
explain describe show filter within lateral pivot unpivot fetch next only interval at time zone collate returning materialized
|
|
28
|
-
`),
|
|
29
|
+
`),fL=uL(`
|
|
29
30
|
integer int smallint bigint tinyint hugeint byteint decimal numeric real float double precision boolean bool varchar char character text string
|
|
30
31
|
date timestamp timestamptz time blob bytea json uuid varbinary struct list map array number clob
|
|
31
|
-
`),
|
|
32
|
+
`),pL=uL(`true false null`),mL=uL(`
|
|
32
33
|
const let var function return if else for while do switch case break continue default new delete typeof instanceof in of try catch finally throw
|
|
33
34
|
class extends super this import export from as async await yield static get set type interface enum implements declare readonly keyof satisfies
|
|
34
35
|
abstract private protected public namespace void
|
|
35
|
-
`),
|
|
36
|
+
`),hL=uL(`true false null undefined NaN Infinity`),gL=uL(`string number boolean bigint symbol object unknown any never`),_L=uL(`if then else elif fi for in do done while until case esac function return export local set unset source alias`),vL=uL(`syntax edition package import public weak option message enum service rpc returns stream repeated optional required oneof map reserved extend to max`),yL=uL(`double float int32 int64 uint32 uint64 sint32 sint64 fixed32 fixed64 sfixed32 sfixed64 bool string bytes`),bL=/[A-Za-z_][\w$]*/y,xL=[/-?(?:0x[\da-fA-F]+|\d[\d_]*(?:\.\d+)?(?:[eE][+-]?\d+)?n?)\b/y,`number`],SL=[/[{}[\]();,.:=<>+\-*/%!&|^~?@]+/y,`punctuation`],CL=[/\s+/y,()=>void 0],wL={json:[CL,[/"(?:[^"\\\n]|\\.)*"(?=\s*:)/y,`property`],[/"(?:[^"\\\n]|\\.)*"?/y,`string`],xL,[/\b(?:true|false|null)\b/y,`literal`],[/[{}[\],:]/y,`punctuation`]],sql:[CL,[/--[^\n]*/y,`comment`],[/\/\*[\s\S]*?(?:\*\/|$)/y,`comment`],[/'(?:[^']|'')*'?/y,`string`],[/"(?:[^"]|"")*"?/y,`property`],[/(?<=\.)[A-Za-z_]\w*/y,`property`],xL,[/[?$]\d*/y,`literal`],sL(dL,fL,pL,!0),SL],ts:[CL,[/\/\/[^\n]*/y,`comment`],[/\/\*[\s\S]*?(?:\*\/|$)/y,`comment`],[/`(?:[^`\\]|\\.)*`?/y,`string`],[/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/y,`string`],xL,[/(?<=\.)[A-Za-z_$][\w$]*(?!\s*\()/y,`property`],[/[A-Za-z_$][\w$]*(?=\s*\??:(?!:))/y,`property`],[/[A-Z][\w$]*/y,`type`],sL(mL,gL,hL,!1),SL],shell:[CL,[/#[^\n]*/y,`comment`],[/"(?:[^"\\]|\\.)*"?|'[^']*'?/y,`string`],[/\$\{?[\w@*#?]+\}?/y,`property`],[/(?<=^|\s)--?[\w-]+/y,`type`],[/(?<=^|[|;&]\s*|\n\s*)[\w./@-]+/y,`function`],xL,sL(_L,new Set,new Set,!1),SL],proto:[CL,[/\/\/[^\n]*/y,`comment`],[/\/\*[\s\S]*?(?:\*\/|$)/y,`comment`],[/"(?:[^"\\\n]|\\.)*"?/y,`string`],xL,[/[A-Z][\w.]*/y,`type`],sL(vL,yL,uL(`true false`),!1),SL],yaml:[CL,[/#[^\n]*/y,`comment`],[/(?<=^|\n)[ \t]*(?:- )?[\w./-]+(?=:(?:\s|$))/y,`property`],[/"(?:[^"\\\n]|\\.)*"?|'[^'\n]*'?/y,`string`],xL,[/\b(?:true|false|null|yes|no|on|off)\b/y,`literal`],[/[:\-[\]{},|>]/y,`punctuation`]],css:[CL,[/\/\*[\s\S]*?(?:\*\/|$)/y,`comment`],[/"[^"\n]*"?|'[^'\n]*'?/y,`string`],[/--[\w-]+/y,`property`],[/[\w-]+(?=\s*:)/y,`property`],[/@[\w-]+/y,`keyword`],[/#[\da-fA-F]{3,8}\b/y,`number`],[/-?\d*\.?\d+(?:px|rem|em|%|s|ms|vh|vw|deg)?/y,`number`],[/[\w-]+(?=\()/y,`function`],[/[.#][\w-]+/y,`type`],SL]},TL={javascript:`ts`,js:`ts`,jsx:`ts`,mjs:`ts`,typescript:`ts`,tsx:`ts`,bash:`shell`,sh:`shell`,zsh:`shell`,console:`shell`,protobuf:`proto`,yml:`yaml`,jsonc:`json`,json5:`json`,a2ui:`json`,duckdb:`sql`,teradata:`sql`,postgres:`sql`,postgresql:`sql`}}));function DL({resolve:e,children:t}){return(0,ML.jsx)(PL.Provider,{value:e,children:t})}function OL(){return(0,NL.useContext)(PL)}function kL(e){if(e){if(/^\/(?![/\\])/.test(e)||FL.test(e))return e;try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`||t.protocol===`blob:`?e:void 0}catch{return}}}function AL(e,t){if(e&&t)try{return kL(e(t))}catch{return}}function jL({src:e,alt:t,caption:n,width:r,height:i,fit:a=`contain`,maxHeight:o,resolveImage:s,className:c}){let l=OL(),u=AL(s??l,e),d={};return r&&(d[`--sf-image-width`]=`${r}px`),i&&(d[`--sf-image-height`]=`${i}px`),o&&(d[`--sf-image-max-height`]=`${o}px`),(0,ML.jsxs)(`figure`,{className:[`sf-image`,c].filter(Boolean).join(` `),"data-fit":a,"data-fixed":i?!0:void 0,style:d,children:[u?(0,ML.jsx)(`img`,{className:`sf-image-body`,src:u,alt:t,loading:`lazy`,decoding:`async`}):(0,ML.jsx)(`div`,{className:`sf-image-missing`,role:t?`img`:void 0,"aria-label":t||void 0,children:(0,ML.jsx)(`span`,{"aria-hidden":`true`,children:t||`Image`})}),n!=null&&n!==``&&(0,ML.jsx)(`figcaption`,{children:n})]})}var ML,NL,PL,FL,IL=n((()=>{ML=WA(),NL=NM(),PL=(0,NL.createContext)(void 0),FL=/^data:image\/(?:png|jpe?g|gif|webp|avif);/i}));function LL(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`||t.protocol===`mailto:`?t.href:void 0}catch{return}}function RL(e,t={}){let n=[],r=0,i=0;for(let a of e.matchAll(GL)){a.index>r&&n.push(e.slice(r,a.index));let o=a[0];if(a[1])n.push((0,UL.jsx)(`code`,{children:o.slice(1,-1)},i++));else if(a[2])n.push((0,UL.jsx)(`strong`,{children:RL(o.slice(2,-2),t)},i++));else if(a[3])n.push((0,UL.jsx)(`em`,{children:RL(o.slice(1,-1),t)},i++));else if(o.startsWith(`!`)){let e=o.indexOf(`](`),r=o.slice(2,e),a=AL(t.image,o.slice(e+2,-1));n.push(a?(0,UL.jsx)(`img`,{className:`sf-markdown-image`,src:a,alt:r,loading:`lazy`,decoding:`async`},i++):r)}else{let e=o.indexOf(`](`),r=o.slice(1,e),a=o.slice(e+2,-1),s=LL(a)??(t.resolve?LL(t.resolve(a)??``):void 0),c=t.open;n.push(s?(0,UL.jsx)(`a`,{href:s,target:`_blank`,rel:`noreferrer noopener`,onClick:c&&(e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||c(s)&&e.preventDefault()}),children:RL(r,t)},i++):r)}r=a.index+o.length}return r<e.length&&n.push(e.slice(r)),n}function zL(e){let t=e.replace(/\r\n?/g,`
|
|
36
37
|
`).split(`
|
|
37
38
|
`),n=[];for(let e=0;e<t.length;){let r=t[e],i=/^\s*```(\S*)\s*$/.exec(r);if(i){let r=[];for(e++;e<t.length&&!/^\s*```\s*$/.test(t[e]);e++)r.push(t[e]);e++,n.push({kind:`code`,language:i[1]??``,code:r.join(`
|
|
38
|
-
`)});continue}if(r.trim()===``){e++;continue}let a=/^(#{1,6})\s+(.*)$/.exec(r);if(a){n.push({kind:`heading`,level:a[1].length,text:a[2]}),e++;continue}if(/^\s*([-*_])\s*\1\s*\1[\s\-*_]*$/.test(r)){n.push({kind:`rule`}),e++;continue}if(r.includes(`|`)&&/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(t[e+1]??``)){let i=RL(r),a=[];for(e+=2;e<t.length&&t[e].includes(`|`)&&t[e].trim()!==``;e++)a.push(RL(t[e]));n.push({kind:`table`,head:i,rows:a});continue}let o=/^\s*(?:[-*+]|(\d+)[.)])\s+(.*)$/.exec(r);if(o){let r=o[1]!==void 0,i=[];for(;e<t.length;e++){let n=/^\s*(?:[-*+]|(\d+)[.)])\s+(.*)$/.exec(t[e]);if(n&&n[1]!==void 0===r)i.push(n[2]);else if(i.length>0&&/^\s{2,}\S/.test(t[e]))i[i.length-1]+=` ${t[e].trim()}`;else break}let a=r?Number(o[1]):void 0;n.push(a!==void 0&&a!==1?{kind:`list`,ordered:r,items:i,start:a}:{kind:`list`,ordered:r,items:i});continue}if(/^\s*>/.test(r)){let r=[];for(;e<t.length&&/^\s*>/.test(t[e]);e++)r.push(t[e].replace(/^\s*>\s?/,``));n.push({kind:`quote`,text:r.join(` `)});continue}let s=[];for(;e<t.length&&t[e].trim()!==``&&!/^\s*(```|#{1,6}\s|>|[-*+]\s|\d+[.)]\s)/.test(t[e]);e++)s.push(t[e].trim());s.length===0&&s.push(t[e++].trim()),n.push({kind:`paragraph`,text:s.join(` `)})}return n}function ML({code:e,language:t}){let n=(0,IL.useMemo)(()=>tL(e,t),[e,t]);return(0,FL.jsx)(`code`,{"data-language":t||void 0,children:n.map((e,t)=>e.kind?(0,FL.jsx)(`span`,{className:`sf-tok-${e.kind}`,children:e.text},t):(0,FL.jsx)(IL.Fragment,{children:e.text},t))})}function NL({code:e,language:t,onRun:n,label:r,bare:i,className:a}){let[o,s]=(0,IL.useState)(!1);return(0,FL.jsxs)(`div`,{className:[`sf-code`,i&&`sf-code-bare`,a].filter(Boolean).join(` `),children:[!i&&(0,FL.jsxs)(`div`,{className:`sf-code-bar`,children:[(0,FL.jsx)(`span`,{children:t||`text`}),(0,FL.jsxs)(`span`,{className:`sf-code-actions`,children:[n&&(0,FL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>n(e),children:`Run`}),(0,FL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>{})},"aria-live":`polite`,children:o?`Copied`:`Copy`})]})]}),(0,FL.jsx)(`pre`,{tabIndex:0,"aria-label":r??(t?`${t} code`:`Code`),children:(0,FL.jsx)(ML,{code:e,language:t})})]})}function PL({text:e,onRunSql:t,inline:n,headingStart:r=3,resolveLink:i,resolveImage:a,openLink:o,className:s}){let c=bL(),l={resolve:i,image:a??c,open:o},u=e=>AL(e,l);return n?(0,FL.jsx)(`span`,{className:[`sf-markdown-inline`,s].filter(Boolean).join(` `),children:u(e)}):(0,FL.jsxs)(`div`,{className:[`sf-markdown`,s].filter(Boolean).join(` `),children:[jL(e).map((e,n)=>{switch(e.kind){case`heading`:{let t=`h${Math.min(6,e.level+Math.max(0,Math.min(5,r-1)))}`;return(0,FL.jsx)(t,{children:u(e.text)},n)}case`code`:return(0,FL.jsx)(NL,{code:e.code,language:e.language,onRun:t&&/^sql$/i.test(e.language)?t:void 0},n);case`list`:{let t=e.ordered?`ol`:`ul`;return(0,FL.jsx)(t,{start:e.start,children:e.items.map((e,t)=>(0,FL.jsx)(`li`,{children:u(e)},t))},n)}case`quote`:return(0,FL.jsx)(`blockquote`,{children:u(e.text)},n);case`rule`:return(0,FL.jsx)(`hr`,{},n);case`table`:return(0,FL.jsx)(`div`,{className:`sf-markdown-table`,tabIndex:0,role:`region`,"aria-label":`Table: ${e.head.slice(0,3).join(`, `)}`,children:(0,FL.jsxs)(`table`,{children:[(0,FL.jsx)(`thead`,{children:(0,FL.jsx)(`tr`,{children:e.head.map((e,t)=>(0,FL.jsx)(`th`,{scope:`col`,children:u(e)},t))})}),(0,FL.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,FL.jsx)(`tr`,{children:e.head.map((e,n)=>(0,FL.jsx)(`td`,{children:u(t[n]??``)},n))},n))})]})},n);default:return(0,FL.jsx)(`p`,{children:u(e.text)},n)}}),(0,FL.jsx)(IL.Fragment,{})]})}var FL,IL,LL,RL,zL=n((()=>{FL=HA(),IL=jM(),vL(),OL(),LL=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(!\[[^\]\n]*\]\([^)\s]+\)|\[[^\]\n]+\]\([^)\s]+\))/g,RL=e=>e.trim().replace(/^\||\|$/g,``).split(`|`).map(e=>e.trim())}));function BL(e,t){return t===`count`?{aggregate:`count`}:t===`p90`?{column:e,aggregate:`percentile`,percentile:.9}:{column:e,aggregate:t}}function VL(e){let[t,n]=(0,WL.useState)(!1);return(0,UL.jsxs)(`details`,{className:`sf-result-sql`,onToggle:e=>n(e.currentTarget.open),children:[(0,UL.jsx)(`summary`,{children:z(`result.plan`)}),t&&(0,UL.jsx)(YI,{...e})]})}function HL(e){let{sourceId:t,sql:n,timeTravel:r,notBefore:i,height:a=420,onError:o}=e,s=zN(e.dataSource),c=(0,WL.useId)(),[l,u]=(0,WL.useState)(e.defaultView??`grid`),[f,p]=(0,WL.useState)(e.filters??[]),[m,h]=(0,WL.useState)(e.sorts??[]),[g,_]=(0,WL.useState)(e.columns??{}),v=e=>JSON.stringify(e??null,(e,t)=>typeof t==`bigint`?`${t}n`:t),y=(0,WL.useRef)({filters:e.filters,sorts:e.sorts,columns:e.columns});y.current={filters:e.filters,sorts:e.sorts,columns:e.columns},(0,WL.useEffect)(()=>{e.filters&&p(e.filters)},[v(e.filters)]),(0,WL.useEffect)(()=>{e.sorts&&h(e.sorts)},[v(e.sorts)]),(0,WL.useEffect)(()=>{e.columns&&_(e.columns)},[v(e.columns)]),(0,WL.useEffect)(()=>{e.view&&u(e.view)},[e.view]);let b=(0,WL.useRef)(e.onControlsChange);b.current=e.onControlsChange;let x=(0,WL.useRef)(!0);(0,WL.useEffect)(()=>{x.current?x.current=!1:b.current?.({view:l,filters:f,sorts:m,columns:g})},[l,f,m,g]);let[S,C]=(0,WL.useState)([]),[w,T]=(0,WL.useState)(),[E,D]=(0,WL.useState)({type:`bar`,x:``,grain:`month`,bins:0,splitBy:``,raw:!1,stacked:!1,legend:``,series:[]}),[O,k]=(0,WL.useState)({row:``,column:``,grain:`month`,measure:``,summary:`sum`}),[ee,te]=(0,WL.useState)(1),[A,ne]=(0,WL.useState)({}),[re,ie]=(0,WL.useState)(``),[ae,oe]=(0,WL.useState)({status:``}),se=(0,WL.useCallback)(async e=>{let a=await JS(s.execute({sourceId:t,timeTravel:r,notBefore:i,query:{baseSql:n,groupBy:[e],aggregates:[{function:ux.COUNT,alias:`sf_count`}],sorts:[{column:`sf_count`,direction:ax.DESC}],page:{limit:50}}})),o=a.table.getChildAt(0),c=a.table.schema.fields[0]?.type;return Array.from({length:a.table.numRows},(e,t)=>o?.get(t)).filter(e=>e!=null).map(e=>c?JN(e,c).text:String(e))},[s,t,n,i,r]),ce=async()=>{let a=new AbortController;oe({status:z(`result.preparing`),exporting:a});try{let o=await HI(s,{sourceId:t,timeTravel:r,notBefore:i,query:{baseSql:n,filters:f}},{signal:a.signal,onProgress:e=>oe({status:z(`result.rowsSoFar`,{count:jA().format(e)}),exporting:a})});UI(o.blob,`${e.exportName??`result`}.csv`),oe({status:z(o.truncated?`result.savedTruncated`:`result.saved`,{count:jA().format(o.rows)})})}catch(e){oe({status:a.signal.aborted?z(`result.exportStopped`):d(e).message})}},le=()=>{navigator.clipboard?.writeText(w?.executedSql||n).then(()=>oe({status:z(`result.sqlCopied`)}),()=>oe({status:z(`result.copyNotAllowed`)}))},ue=A[re]?.kind??``,de=JSON.stringify(r??null,(e,t)=>typeof t==`bigint`?`${t}n`:t);(0,WL.useEffect)(()=>{let e=new AbortController;return p(y.current.filters??[]),h(y.current.sorts??[]),JS(s.execute({sourceId:t,timeTravel:r,notBefore:i,query:{baseSql:n,page:{limit:1}}},{signal:e.signal})).then(t=>{if(e.signal.aborted)return;let n=t.table.schema.fields;C(n);let r=n.find($L)??n.find(e=>!qN(e.type))??n[0],i=n.filter(e=>qN(e.type)&&e!==r&&!/(^|_)id$/i.test(e.name)),a=i.find(e=>!P.isInt(e.type))??i[0]??n.find(e=>qN(e.type)&&e!==r),s=n.find(e=>!qN(e.type)&&!$L(e));D(e=>({...e,type:$L(r)?`line`:`bar`,x:r?.name??``,splitBy:``,series:[{id:0,column:a?.name??``,summary:a?`sum`:`count`,type:``,axis:`left`}]})),k(e=>({...e,row:s?.name??r?.name??``,column:n.find(e=>e!==s&&$L(e))?.name??``,measure:a?.name??``,summary:a?`sum`:`count`})),o?.(void 0)}).catch(t=>{if(e.signal.aborted)return;C([]);let n=d(t);o?.(n.message,n)}),()=>e.abort()},[s,t,n,de,i]);let fe=e=>S.find(t=>t.name===e),pe=S.filter(e=>qN(e.type)),me=fe(E.x),he=$L(me),ge=me!==void 0&&qN(me.type),j=E.series.map(e=>({...E.raw?{column:e.column}:BL(e.column,e.summary),type:e.type||void 0,axis:e.axis})),_e=E.x!==``&&E.series.length>0&&E.series.every(e=>e.column!==``||!E.raw&&e.summary===`count`),ve=(e,t)=>D(n=>({...n,series:n.series.map(n=>n.id===e?{...n,...t}:n)})),ye=E.type!==`pie`,be=O.row!==``&&(O.summary===`count`||O.measure!==``),xe=e=>$L(fe(e))?{column:e,grain:O.grain}:e,Se=(e,t,n,r)=>(0,UL.jsxs)(`label`,{children:[(0,UL.jsx)(`span`,{children:e}),(0,UL.jsx)(`select`,{className:`sf-input`,value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,UL.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),M=e=>e.map(e=>({value:e.name,label:e.name})),Ce=e=>[{value:``,label:e}],we=XL.map(e=>({value:e,label:z(ZL[e])})),Te=JL.map(e=>({value:e,label:e}));return(0,UL.jsxs)(`section`,{className:[`sf-result`,`sf-container`,e.className].filter(Boolean).join(` `),children:[(0,UL.jsxs)(`div`,{className:`sf-result-bar`,children:[(0,UL.jsx)(`div`,{className:`sf-segmented sf-result-views`,role:`tablist`,"aria-label":z(`result.views`),children:GL.map(e=>(0,UL.jsx)(`button`,{type:`button`,role:`tab`,id:`${c}-${e.id}`,"aria-selected":l===e.id,"aria-controls":`${c}-panel`,className:`sf-segment`,"data-checked":l===e.id||void 0,onClick:()=>u(e.id),children:z(e.label)},e.id))}),(0,UL.jsx)(hI,{fields:S,filters:f,onChange:p,loadValues:se})]}),(0,UL.jsxs)(`div`,{className:`sf-result-tools`,children:[ae.exporting?(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>ae.exporting?.abort(),children:z(`result.stopExport`)}):(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:S.length===0,onClick:()=>void ce(),children:z(`result.downloadCsv`)}),(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:le,children:z(`result.copySql`)}),w?.loading&&l===`grid`&&(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:w.cancel,children:z(`result.cancelQuery`)}),l===`grid`&&S.length>0&&(0,UL.jsxs)(UL.Fragment,{children:[(0,UL.jsxs)(`label`,{children:[(0,UL.jsx)(`span`,{children:z(`result.format`)}),(0,UL.jsxs)(`select`,{className:`sf-input`,"aria-label":z(`result.formatColumn`),value:re,onChange:e=>ie(e.target.value),children:[(0,UL.jsx)(`option`,{value:``,children:z(`result.chooseColumn`)}),S.map(e=>(0,UL.jsx)(`option`,{children:e.name},e.name))]})]}),re&&(0,UL.jsxs)(`select`,{className:`sf-input`,"aria-label":z(`result.howToShow`,{column:re}),value:ue,onChange:e=>{let t=e.target.value;ne(e=>{let{[re]:n,...r}=e;return t?{...r,[re]:{kind:t,...t===`currency`?{decimals:2}:{}}}:r})},children:[(0,UL.jsx)(`option`,{value:``,children:z(`result.asItIs`)}),(qN(fe(re)?.type??S[0].type)?[`number`,`compact`,`currency`,`percent`,`text`]:$L(fe(re))?[`date`,`datetime`]:[`text`]).map(e=>(0,UL.jsx)(`option`,{value:e,children:z(QL[e])},e))]})]}),(0,UL.jsx)(`span`,{className:`sf-result-tools-status`,role:`status`,children:ae.status})]}),l===`chart`&&(0,UL.jsxs)(`div`,{className:`sf-result-chart-controls`,children:[(0,UL.jsxs)(`div`,{className:`sf-result-control-row`,children:[Se(z(`result.chartType`),E.type,KL.map(e=>({value:e,label:e})),e=>D({...E,type:e})),Se(z(E.type===`pie`?`result.slices`:`result.xAxis`),E.x,M(S),e=>D({...E,x:e})),!E.raw&&he&&Se(z(`result.every`),E.grain,Te,e=>D({...E,grain:e})),!E.raw&&ge&&Se(z(`result.bins`),String(E.bins),[{value:`0`,label:z(`result.binsEach`)},...[10,20,50].map(e=>({value:String(e),label:z(`result.binsAbout`,{count:e})}))],e=>D({...E,bins:Number(e)})),ye&&Se(z(`result.splitBy`),E.splitBy,[...Ce(z(`result.nothing`)),...M(S.filter(e=>e.name!==E.x))],e=>D({...E,splitBy:e})),ye&&Se(z(`result.legend`),E.legend,[...Ce(z(`result.automatic`)),...YL.map(e=>({value:e,label:e===`none`?z(`result.legendHidden`):e}))],e=>D({...E,legend:e})),ye&&(0,UL.jsxs)(`label`,{className:`sf-result-check`,children:[(0,UL.jsx)(`input`,{type:`checkbox`,checked:E.stacked,onChange:e=>D({...E,stacked:e.target.checked})}),(0,UL.jsx)(`span`,{children:z(`result.stack`)})]}),(0,UL.jsxs)(`label`,{className:`sf-result-check`,children:[(0,UL.jsx)(`input`,{type:`checkbox`,checked:E.raw,onChange:e=>D({...E,raw:e.target.checked})}),(0,UL.jsx)(`span`,{children:z(`result.plotEachRow`)})]})]}),E.series.map((e,t)=>(0,UL.jsxs)(`div`,{className:`sf-result-control-row`,role:`group`,"aria-label":z(`result.series`,{number:t+1}),children:[!E.raw&&Se(t===0?z(`result.yAxis`):z(`result.series`,{number:t+1}),e.summary,we,t=>ve(e.id,{summary:t})),(E.raw||e.summary!==`count`)&&Se(E.raw?t===0?z(`result.yAxis`):z(`result.series`,{number:t+1}):z(`result.of`),e.column,M(E.raw||e.summary===`min`||e.summary===`max`||e.summary===`count_distinct`?S:pe),t=>ve(e.id,{column:t})),ye&&Se(z(`result.drawnAs`),e.type,[...Ce(z(`result.drawnAsChart`,{type:E.type})),...qL.map(e=>({value:e,label:e}))],t=>ve(e.id,{type:t})),ye&&Se(z(`result.scale`),e.axis,[{value:`left`,label:z(`result.leftAxis`)},{value:`right`,label:z(`result.rightAxis`)}],t=>ve(e.id,{axis:t})),E.series.length>1&&(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":z(`result.removeSeries`,{number:t+1}),onClick:()=>D({...E,series:E.series.filter(t=>t.id!==e.id)}),children:z(`result.remove`)})]},e.id)),ye&&E.series.length<6&&(0,UL.jsx)(`div`,{className:`sf-result-control-row`,children:(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{let e=E.series.at(-1);D({...E,series:[...E.series,{id:ee,column:e?.column??pe[0]?.name??``,summary:`avg`,type:`line`,axis:`right`}]}),te(ee+1)},children:z(`result.addSeries`)})})]}),l===`pivot`&&(0,UL.jsx)(`div`,{className:`sf-result-chart-controls`,children:(0,UL.jsxs)(`div`,{className:`sf-result-control-row`,children:[Se(z(`result.rows`),O.row,M(S),e=>k({...O,row:e})),Se(z(`result.columns`),O.column,[...Ce(z(`result.none`)),...M(S.filter(e=>e.name!==O.row))],e=>k({...O,column:e})),($L(fe(O.row))||$L(fe(O.column)))&&Se(z(`result.datesBy`),O.grain,Te,e=>k({...O,grain:e})),Se(z(`result.values`),O.summary,we,e=>k({...O,summary:e})),O.summary!==`count`&&Se(z(`result.of`),O.measure,M(O.summary===`min`||O.summary===`max`||O.summary===`count_distinct`?S:pe),e=>k({...O,measure:e}))]})}),(0,UL.jsx)(`div`,{id:`${c}-panel`,role:`tabpanel`,"aria-labelledby":`${c}-${l}`,children:l===`grid`?(0,UL.jsx)(xP,{dataSource:s,sourceId:t,sql:n,filters:f,timeTravel:r,notBefore:i,formats:A,height:a,sorts:m,onSortsChange:h,columns:g,onColumnsChange:_,onCellFilter:(e,t,n)=>p(r=>[...r,zC(e,t,n)]),emptyMessage:e.emptyMessage,errorMessage:e.errorMessage,onInfo:e=>{T(e),e.error&&o?.(e.error,e.errorInfo)}}):l===`chart`?_e?(0,UL.jsx)(`div`,{className:`sf-result-chart`,children:(0,UL.jsx)(pF,{dataSource:s,sourceId:t,sql:n,filters:f,timeTravel:r,notBefore:i,type:E.type,x:E.x,xGrain:!E.raw&&he?E.grain:void 0,xBins:!E.raw&&ge&&E.bins>0?E.bins:void 0,y:E.type===`pie`?j.slice(0,1):j,splitBy:ye&&E.splitBy?E.splitBy:void 0,stacked:E.stacked,legend:E.legend||void 0,height:a-24,emptyMessage:e.emptyMessage,errorMessage:e.errorMessage})}):(0,UL.jsx)(`p`,{className:`sf-chart-message`,style:{minHeight:a},children:z(`result.chooseChart`)}):be?(0,UL.jsx)(kI,{dataSource:s,sourceId:t,sql:n,filters:f,timeTravel:r,notBefore:i,rows:[xe(O.row)],columns:O.column?[xe(O.column)]:[],measures:[BL(O.measure,O.summary)],height:a,emptyMessage:e.emptyMessage,errorMessage:e.errorMessage}):(0,UL.jsx)(`p`,{className:`sf-chart-message`,style:{minHeight:a},children:z(`result.choosePivot`)})}),l===`grid`&&w?.executedSql&&(0,UL.jsxs)(`details`,{className:`sf-result-sql`,children:[(0,UL.jsx)(`summary`,{children:z(`result.sqlSent`)}),(0,UL.jsx)(NL,{code:w.executedSql,language:`sql`,label:z(`result.sqlSent`)}),w.stored&&(0,UL.jsx)(`p`,{className:`sf-result-notice`,children:z(`result.stored`)}),w.notices.map(e=>(0,UL.jsx)(`p`,{className:`sf-result-notice`,children:e.message},e.code))]}),S.length>0&&(0,UL.jsx)(VL,{sourceId:t,sql:n,filters:f,dataSource:s})]})}var UL,WL,GL,KL,qL,JL,YL,XL,ZL,QL,$L,eR=n((()=>{UL=HA(),rw(),vS(),_p(),WL=jM(),vF(),UN(),GI(),tP(),CI(),MP(),BA(),RI(),QI(),zL(),GL=[{id:`grid`,label:`result.tabTable`},{id:`chart`,label:`result.tabChart`},{id:`pivot`,label:`result.tabPivot`}],KL=[`bar`,`line`,`area`,`scatter`,`pie`],qL=[`bar`,`line`,`area`,`scatter`],JL=[`hour`,`day`,`week`,`month`,`quarter`,`year`],YL=[`top`,`bottom`,`right`,`none`],XL=[`sum`,`avg`,`median`,`count`,`count_distinct`,`min`,`max`,`stddev`,`p90`],ZL={sum:`result.sum`,avg:`result.avg`,median:`result.median`,count:`result.count`,count_distinct:`result.countDistinct`,min:`result.min`,max:`result.max`,stddev:`result.stddev`,p90:`result.p90`},QL={number:`result.formatNumber`,compact:`result.formatCompact`,currency:`result.formatCurrency`,percent:`result.formatPercent`,text:`result.formatText`,date:`result.formatDate`,datetime:`result.formatDatetime`},$L=e=>e!==void 0&&(P.isTimestamp(e.type)||P.isDate(e.type))}));function tR(e){let{pageSize:t=25}=e,n=wF(e.discovery),r=(0,rR.useId)(),[i,a]=(0,rR.useState)(``),[o,s]=(0,rR.useState)(`all`),[c,l]=(0,rR.useState)(Vx.UNSPECIFIED),[u,d]=(0,rR.useState)(!1),[f,p]=(0,rR.useState)({hits:[],next:``,total:0,modeUsed:Vx.UNSPECIFIED,loading:!0}),m=JSON.stringify(e.sourceIds??[]),h=(r,a,s)=>n.search({query:i,mode:c,kinds:iR.find(e=>e.id===o).kinds,sourceIds:e.sourceIds,pageSize:t,pageToken:r,certificationStatuses:u?[Ux.CERTIFIED]:[]}).then(e=>{s.cancelled||p(t=>({hits:a?[...t.hits,...e.hits]:e.hits,next:e.nextPageToken,total:Number(e.total),modeUsed:e.modeUsed,loading:!1}))}).catch(e=>{s.cancelled||p(t=>({...t,loading:!1,error:rP(e)}))});(0,rR.useEffect)(()=>{let e={cancelled:!1};p(e=>({...e,loading:!0,error:void 0}));let t=setTimeout(()=>void h(``,!1,e),i?200:0);return()=>{e.cancelled=!0,clearTimeout(t)}},[n,i,o,c,m,t,u]);let g=c===Vx.SEMANTIC&&f.modeUsed===Vx.KEYWORD&&!f.loading;return(0,nR.jsxs)(`div`,{className:[`sf-search`,e.className].filter(Boolean).join(` `),"data-fixed":e.height!==void 0||void 0,style:e.height===void 0?void 0:{height:e.height},children:[(0,nR.jsxs)(`div`,{className:`sf-search-controls`,role:`search`,children:[(0,nR.jsx)(`input`,{className:`sf-input sf-search-input`,type:`search`,placeholder:`Search tables and columns, e.g. customer revenue`,"aria-label":`Search data`,value:i,onChange:e=>a(e.target.value)}),(0,nR.jsx)(`select`,{className:`sf-input`,"aria-label":`Show`,value:o,onChange:e=>s(e.target.value),children:iR.map(e=>(0,nR.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,nR.jsx)(`select`,{className:`sf-input`,"aria-label":`Match`,value:c,onChange:e=>l(Number(e.target.value)),children:aR.map(e=>(0,nR.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,nR.jsxs)(`label`,{className:`sf-search-check`,children:[(0,nR.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),(0,nR.jsx)(`span`,{children:`Certified only`})]})]}),(0,nR.jsx)(`p`,{className:`sf-search-status`,"aria-live":`polite`,id:`${r}-status`,children:f.error?``:f.loading?`Searching…`:`${f.total} ${f.total===1?`result`:`results`}${g?` · search by meaning is not available here, so these are word matches`:``}`}),f.error&&(0,nR.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:f.error}),(0,nR.jsx)(`ul`,{className:`sf-search-results`,"aria-labelledby":`${r}-status`,"aria-busy":f.loading,tabIndex:e.height===void 0?void 0:0,children:f.hits.map(t=>{let n=t.object;return(0,nR.jsxs)(`li`,{className:`sf-search-hit`,children:[(0,nR.jsxs)(`button`,{type:`button`,className:`sf-search-open`,onClick:()=>e.onOpen?.(n),children:[(0,nR.jsxs)(`span`,{className:`sf-search-title`,children:[(0,nR.jsx)(`span`,{className:`sf-search-name`,children:n.name}),(0,nR.jsx)(DF,{certification:n.certification}),(0,nR.jsx)(`span`,{className:`sf-schema-tag`,children:kF(n)}),n.ref?.kind===Bx.TABLE&&NF[n.format]&&(0,nR.jsx)(`span`,{className:`sf-schema-tag`,children:NF[n.format]}),n.nativeType&&(0,nR.jsx)(`span`,{className:`sf-schema-meta`,children:n.nativeType.toLowerCase()}),n.rowCount!==void 0&&(0,nR.jsxs)(`span`,{className:`sf-schema-meta`,children:[FF.format(Number(n.rowCount)),` rows`]})]}),n.description&&(0,nR.jsx)(`span`,{className:`sf-search-description`,children:n.description}),t.reasons.length>0&&(0,nR.jsx)(`span`,{className:`sf-search-reasons`,children:t.reasons.join(` · `)})]}),i&&(0,nR.jsx)(`span`,{className:`sf-search-score`,"aria-hidden":`true`,style:{inlineSize:`${Math.round(t.score*100)}%`}}),e.renderActions&&(0,nR.jsx)(`span`,{className:`sf-search-actions`,children:e.renderActions(n)})]},`${n.ref?.sourceId}/${n.name}`)})}),!f.loading&&!f.error&&f.hits.length===0&&(0,nR.jsxs)(`p`,{className:`sf-search-empty`,children:[`Nothing matches`,i?` “${i}”`:``,`. Try fewer or different words.`]}),f.next&&(0,nR.jsx)(`button`,{type:`button`,className:`sf-button sf-search-more`,onClick:()=>void h(f.next,!0,{cancelled:!1}),children:`Show more`})]})}var nR,rR,iR,aR,oR=n((()=>{nR=HA(),vS(),rR=jM(),oP(),LF(),iR=[{id:`all`,label:`Everything`,kinds:[]},{id:`tables`,label:`Tables`,kinds:[Bx.TABLE]},{id:`columns`,label:`Columns`,kinds:[Bx.COLUMN]}],aR=[{id:Vx.UNSPECIFIED,label:`Best match`},{id:Vx.KEYWORD,label:`Exact words`},{id:Vx.SEMANTIC,label:`By meaning`}]}));function sR({column:e,rowCount:t}){let n=t&&e.nullCount!==void 0?1-Number(e.nullCount)/t:void 0,r=e.topValues.slice(0,3),i=Math.max(1,...r.map(e=>Number(e.count)));return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`td`,{className:`sf-object-fill`,children:n===void 0?(0,B.jsx)(`span`,{className:`sf-object-muted`,children:`–`}):(0,B.jsxs)(`span`,{className:`sf-meter`,role:`img`,"aria-label":`${Math.round(n*100)}% filled`,children:[(0,B.jsx)(`span`,{style:{inlineSize:`${Math.round(n*100)}%`}}),(0,B.jsxs)(`em`,{children:[Math.round(n*100),`%`]})]})}),(0,B.jsx)(`td`,{className:`sf-object-number`,children:e.distinctCount===void 0?`–`:(0,B.jsxs)(`span`,{title:e.distinctCountEstimated?`An estimate`:void 0,children:[e.distinctCountEstimated?`~`:``,IF.format(Number(e.distinctCount))]})}),(0,B.jsx)(`td`,{className:`sf-object-values`,children:e.sampleValuesWithheld?(0,B.jsx)(`span`,{className:`sf-object-muted`,children:`Withheld`}):r.length>0?(0,B.jsx)(`span`,{className:`sf-top-values`,children:r.map(e=>(0,B.jsxs)(`span`,{className:`sf-top-value`,title:`${e.value}: ${IF.format(Number(e.count))}`,children:[(0,B.jsx)(`span`,{style:{inlineSize:`${Math.round(Number(e.count)/i*100)}%`}}),(0,B.jsx)(`em`,{children:e.value})]},e.value))}):e.min!==void 0&&e.min!==``?(0,B.jsxs)(`span`,{children:[e.min,` → `,e.max]}):(0,B.jsx)(`span`,{className:`sf-object-muted`,children:`–`})})]})}function cR(e){let t=wF(e.discovery),n=JSON.stringify(e.objectRef),[r,i]=(0,lR.useState)(),[a,o]=(0,lR.useState)([]),[s,c]=(0,lR.useState)(),[l,u]=(0,lR.useState)(),[d,f]=(0,lR.useState)(!1),[p,m]=(0,lR.useState)();if((0,lR.useEffect)(()=>{let n=!0;return i(void 0),o([]),c(void 0),u(void 0),m(void 0),t.getObject({ref:e.objectRef}).then(e=>{n&&i(t=>t??e.profile)}).catch(e=>n&&c(rP(e))),t.getObject({ref:e.objectRef,includeProfile:!0}).then(e=>n&&i(e.profile)).catch(()=>{}),t.getRelated({ref:e.objectRef}).then(e=>n&&o(e.relations)).catch(()=>{}),()=>{n=!1}},[t,n]),s)return(0,B.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:s});if(!r?.object)return(0,B.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`});let h=r.object,g=r.rowCount===void 0?void 0:Number(r.rowCount),_=async()=>{f(!0);try{let n=await t.describe({ref:e.objectRef});u({text:n.description,proposed:n.description,by:n.generatedBy})}catch(e){c(rP(e))}finally{f(!1)}},v=async()=>{if(l){f(!0);try{let n=l.text.trim()!==l.proposed.trim()||l.by===``,a=await t.saveDescription({ref:e.objectRef,description:l.text,origin:n?Hx.HUMAN:Hx.GENERATED});a.object&&i({...r,object:a.object}),u(void 0)}catch(e){c(rP(e))}finally{f(!1)}}},y=async(n,a)=>{f(!0);try{let o=await t.setCertification({ref:e.objectRef,status:n,setBy:e.certifier??``,note:a});o.object&&i({...r,object:o.object}),m(void 0)}catch(e){c(rP(e))}finally{f(!1)}},b=h.certification?.status?h.certification:void 0;return(0,B.jsxs)(`article`,{className:[`sf-object`,e.className].filter(Boolean).join(` `),children:[(0,B.jsxs)(`header`,{className:`sf-object-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h3`,{className:`sf-object-title`,children:[h.name,` `,(0,B.jsx)(DF,{certification:h.certification})]}),(0,B.jsx)(`p`,{className:`sf-object-facts`,children:[h.ref?.sourceId,NF[h.format],g===void 0?void 0:`${IF.format(g)} rows`,`${r.columns.length} columns`].filter(Boolean).join(` · `)})]}),e.renderActions&&(0,B.jsx)(`div`,{className:`sf-object-actions`,children:e.renderActions(h)})]}),(b||e.certifier)&&(0,B.jsxs)(`section`,{className:`sf-object-certification`,"aria-label":`Certification`,children:[b&&(0,B.jsx)(`p`,{children:EF(b)}),e.certifier&&(p?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`label`,{className:`sf-object-label`,htmlFor:`sf-object-cert-note`,children:p.status===Ux.DEPRECATED?`What should people use instead?`:`Why is it certified? (optional)`}),(0,B.jsx)(`input`,{id:`sf-object-cert-note`,className:`sf-input`,value:p.note,onChange:e=>m({...p,note:e.target.value})}),(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:d,onClick:()=>void y(p.status,p.note),children:[p.status===Ux.DEPRECATED?`Mark as deprecated`:`Certify`,` as `,e.certifier]}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>m(void 0),children:`Cancel`})]})]}):(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[b?.status!==Ux.CERTIFIED&&(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>m({status:Ux.CERTIFIED,note:``}),children:`Certify…`}),b?.status!==Ux.DEPRECATED&&(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>m({status:Ux.DEPRECATED,note:``}),children:`Deprecate…`}),b&&(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:d,onClick:()=>void y(Ux.UNSPECIFIED,``),children:`Remove mark`})]}))]}),(0,B.jsx)(`section`,{className:`sf-object-description`,"aria-label":`Description`,children:l?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`label`,{className:`sf-object-label`,htmlFor:`sf-object-draft`,children:l.by===`placeholder`?`Proposed description (a summary of the facts; no language model is connected)`:l.by?`Proposed description, generated by ${l.by}`:`Description`}),(0,B.jsx)(`textarea`,{id:`sf-object-draft`,className:`sf-input sf-object-draft`,rows:3,value:l.text,onChange:e=>u({...l,text:e.target.value})}),(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:d||l.text.trim()===``,onClick:()=>void v(),children:`Save description`}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>u(void 0),children:`Discard`})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:h.description?void 0:`sf-object-muted`,children:h.description||`No description yet.`}),(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[h.description&&PF[h.descriptionOrigin]&&(0,B.jsx)(`span`,{className:`sf-schema-tag`,children:PF[h.descriptionOrigin]}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:d,onClick:()=>void _(),children:`Suggest a description`}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>u({text:h.description,proposed:h.description,by:``}),children:h.description?`Edit`:`Write one`})]})]})}),(0,B.jsxs)(`section`,{"aria-label":`Columns`,children:[!r.sampleValuesAllowed&&(0,B.jsx)(`p`,{className:`sf-object-policy`,children:`Data values are withheld for this source, so ranges and common values are not shown.`}),(0,B.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Column statistics`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Column`}),(0,B.jsx)(`th`,{scope:`col`,children:`Type`}),(0,B.jsx)(`th`,{scope:`col`,children:`Filled`}),(0,B.jsx)(`th`,{scope:`col`,className:`sf-object-number`,children:`Distinct`}),(0,B.jsx)(`th`,{scope:`col`,children:`Values`})]})}),(0,B.jsx)(`tbody`,{children:r.columns.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`th`,{scope:`row`,children:[e.name,e.description&&(0,B.jsx)(`span`,{className:`sf-object-column-note`,children:e.description})]}),(0,B.jsx)(`td`,{className:`sf-object-type`,children:e.nativeType.toLowerCase()}),(0,B.jsx)(sR,{column:e,rowCount:g})]},e.name))})]})})]}),a.length>0&&(0,B.jsxs)(`section`,{"aria-label":`Related tables`,children:[(0,B.jsx)(`h4`,{className:`sf-object-label`,children:`Related`}),(0,B.jsx)(`ul`,{className:`sf-object-related`,children:a.map((t,n)=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,className:`sf-object-relation`,onClick:()=>t.object&&e.onOpen?.(t.object),children:[(0,B.jsx)(`span`,{className:`sf-object-muted`,children:uR[t.kind]??`Related to`}),` `,(0,B.jsx)(`strong`,{children:t.object?.name}),` `,(0,B.jsx)(DF,{certification:t.object?.certification}),(0,B.jsxs)(`span`,{className:`sf-object-muted`,children:[` · `,t.reason]}),t.inferred?(0,B.jsx)(`span`,{className:`sf-schema-tag`,children:`Inferred`}):t.kind===Wx.JOIN&&(0,B.jsx)(`span`,{className:`sf-schema-tag`,children:`Declared`})]})},`${t.kind}-${t.object?.name}-${n}`))})]}),e.showSampleRows&&r.sampleValuesAllowed&&h.ref&&(0,B.jsxs)(`section`,{"aria-label":`Sample rows`,children:[(0,B.jsx)(`h4`,{className:`sf-object-label`,children:`Rows`}),(0,B.jsx)(xP,{sourceId:h.ref.sourceId,sql:`SELECT * FROM ${h.ref.table}`,height:260,label:`Rows of ${h.name}`})]})]})}var B,lR,uR,dR=n((()=>{B=HA(),vS(),lR=jM(),oP(),MP(),LF(),uR={[Wx.JOIN]:`Joins with`,[Wx.SIMILAR]:`Similar to`,[Wx.UPSTREAM]:`Built from`,[Wx.DOWNSTREAM]:`Feeds`,[Wx.USED_BY_QUERY]:`Used by`}}));function fR(e,t,n){return e.items.some(e=>e.sourceId===t&&e.table.toLowerCase()===n.toLowerCase())?e:{...e,items:[...e.items,{sourceId:t,table:n,columns:[],note:``,includeSampleRows:!1}]}}function pR(e){return{id:e.id??``,name:e.name,notes:e.notes,items:e.items.map(e=>({ref:OF(e.sourceId,e.table),columns:e.columns,note:e.note,includeSampleRows:e.includeSampleRows})),joins:e.joins.map(e=>({left:OF(e.sourceId,e.left),right:OF(e.sourceId,e.right),keys:e.keys}))}}function mR(e){let{value:t,onChange:n,tokenBudget:r=4e3}=e,i=wF(e.discovery),a=(0,gR.useId)(),[o,s]=(0,gR.useState)(Gx.MARKDOWN),[c,l]=(0,gR.useState)(),[u,d]=(0,gR.useState)({}),[f,p]=(0,gR.useState)([]),[m,h]=(0,gR.useState)(),[g,_]=(0,gR.useState)(!1),v=JSON.stringify(t),y=t.items.map(e=>`${e.sourceId}/${e.table}`).join(`,`);(0,gR.useEffect)(()=>{let e=!0,n=setTimeout(()=>{i.renderContextPack({target:{case:`pack`,value:pR(t)},format:o}).then(t=>{e&&l({text:t.text,tokens:t.tokenEstimate,hasValues:t.containsSampleValues,missing:t.missing.map(e=>e.table)})}).catch(t=>e&&h({message:rP(t),error:!0}))},250);return()=>{e=!1,clearTimeout(n)}},[i,v,o]),(0,gR.useEffect)(()=>{let e=!0;for(let n of t.items){let t=`${n.sourceId}/${n.table}`;u[t]||i.getObject({ref:OF(n.sourceId,n.table)}).then(n=>e&&d(e=>({...e,[t]:n.profile?.columns.map(e=>e.name)??[]}))).catch(()=>{})}return Promise.all(t.items.map(e=>i.getRelated({ref:OF(e.sourceId,e.table),kinds:[Wx.JOIN]}).then(n=>n.relations.filter(n=>t.items.some(t=>t.sourceId===e.sourceId&&t.table===n.object?.ref?.table)).map(t=>({sourceId:e.sourceId,left:e.table,right:t.object.ref.table,keys:t.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn}))}))).catch(()=>[]))).then(t=>{if(!e)return;let n=[];for(let e of t.flat())n.some(t=>vR(t,e))||n.push(e);p(n)}),()=>{e=!1}},[i,y]);let b=(e,r)=>n({...t,items:t.items.map((t,n)=>n===e?{...t,...r}:t)}),x=(e,r)=>{let i=[...t.items],[a]=i.splice(e,1);i.splice(e+r,0,a),n({...t,items:i})},S=e=>{let r=t.items[e];n({...t,items:t.items.filter((t,n)=>n!==e),joins:t.joins.filter(e=>e.sourceId!==r.sourceId||e.left!==r.table&&e.right!==r.table)})},C=e=>{e.preventDefault(),_(!1);try{let r=JSON.parse(e.dataTransfer.getData(SF));r.sourceId&&r.table&&n(fR(t,r.sourceId,r.table))}catch{}},w=async()=>{try{let r=(await i.saveContextPack({pack:pR(t)})).pack;n({...t,id:r.id}),h({message:`Saved version ${r.version}.`}),e.onSaved?.(r.id)}catch(e){h({message:rP(e),error:!0})}},T=async()=>{try{await navigator.clipboard.writeText(c?.text??``),h({message:`Copied.`})}catch{h({message:`Copying is not allowed here. Select the preview text instead.`,error:!0})}},E=f.filter(e=>!t.joins.some(t=>vR(t,e))),D=c?Math.min(1,c.tokens/r):0,O=c!==void 0&&c.tokens>r;return(0,hR.jsxs)(`div`,{className:[`sf-context`,e.className].filter(Boolean).join(` `),"data-drag":g||void 0,onDragOver:e=>{e.dataTransfer.types.includes(`application/x-surfaces-ref+json`)&&(e.preventDefault(),_(!0))},onDragLeave:()=>_(!1),onDrop:C,children:[(0,hR.jsxs)(`label`,{className:`sf-context-field`,children:[(0,hR.jsx)(`span`,{children:`Name`}),(0,hR.jsx)(`input`,{className:`sf-input`,value:t.name,placeholder:`e.g. Order analysis`,onChange:e=>n({...t,name:e.target.value})})]}),(0,hR.jsxs)(`label`,{className:`sf-context-field`,children:[(0,hR.jsx)(`span`,{children:`Notes for the agent`}),(0,hR.jsx)(`textarea`,{className:`sf-input sf-context-notes`,rows:2,value:t.notes,placeholder:`Rules, units, things to avoid`,onChange:e=>n({...t,notes:e.target.value})})]}),(0,hR.jsx)(`ul`,{className:`sf-context-items`,"aria-label":`Tables in this context`,children:t.items.map((e,n)=>{let r=u[`${e.sourceId}/${e.table}`]??[],i=e.columns.length===0?r:e.columns;return(0,hR.jsxs)(`li`,{className:`sf-context-item`,children:[(0,hR.jsxs)(`div`,{className:`sf-context-item-head`,children:[(0,hR.jsx)(`strong`,{children:e.table}),(0,hR.jsx)(`span`,{className:`sf-object-muted`,children:e.columns.length===0?`all columns`:`${e.columns.length} of ${r.length} columns`}),(0,hR.jsxs)(`span`,{className:`sf-context-item-buttons`,children:[(0,hR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Move ${e.table} up`,disabled:n===0,onClick:()=>x(n,-1),children:(0,hR.jsx)(rI,{icon:`up`})}),(0,hR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Move ${e.table} down`,disabled:n===t.items.length-1,onClick:()=>x(n,1),children:(0,hR.jsx)(rI,{icon:`down`})}),(0,hR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Remove ${e.table}`,onClick:()=>S(n),children:(0,hR.jsx)(rI,{icon:`close`})})]})]}),(0,hR.jsx)(`input`,{className:`sf-input`,"aria-label":`Note about ${e.table}`,placeholder:`Note about this table`,value:e.note,onChange:e=>b(n,{note:e.target.value})}),(0,hR.jsxs)(`details`,{className:`sf-context-columns`,children:[(0,hR.jsx)(`summary`,{children:`Choose columns`}),(0,hR.jsx)(`div`,{className:`sf-context-checks`,children:r.map(e=>(0,hR.jsxs)(`label`,{children:[(0,hR.jsx)(`input`,{type:`checkbox`,checked:i.includes(e),onChange:t=>{let a=t.target.checked?[...i,e]:i.filter(t=>t!==e);b(n,{columns:a.length===r.length?[]:r.filter(e=>a.includes(e))})}}),e]},e))}),(0,hR.jsxs)(`label`,{className:`sf-context-sample`,children:[(0,hR.jsx)(`input`,{type:`checkbox`,checked:e.includeSampleRows,onChange:e=>b(n,{includeSampleRows:e.target.checked})}),`Include sample rows (only if this source allows data values)`]})]})]},`${e.sourceId}/${e.table}`)})}),t.items.length===0&&(0,hR.jsx)(`p`,{className:`sf-context-empty`,children:`Add tables from search or the schema tree, or drag them here.`}),(t.joins.length>0||E.length>0)&&(0,hR.jsxs)(`div`,{className:`sf-context-joins`,children:[(0,hR.jsx)(`span`,{className:`sf-object-label`,children:`Joins`}),(0,hR.jsxs)(`ul`,{children:[t.joins.map(e=>(0,hR.jsxs)(`li`,{children:[(0,hR.jsxs)(`span`,{children:[e.left,` ⋈ `,e.right,` on `,e.keys.map(e=>e.leftColumn).join(`, `)]}),(0,hR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Remove join ${e.left} and ${e.right}`,onClick:()=>n({...t,joins:t.joins.filter(t=>!vR(t,e))}),children:(0,hR.jsx)(rI,{icon:`close`})})]},`${e.left}-${e.right}`)),E.map(e=>(0,hR.jsxs)(`li`,{"data-suggested":!0,children:[(0,hR.jsxs)(`span`,{children:[e.left,` ⋈ `,e.right,` on `,e.keys.map(e=>e.leftColumn).join(`, `),` `,(0,hR.jsx)(`span`,{className:`sf-schema-tag`,children:`Inferred`})]}),(0,hR.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>n({...t,joins:[...t.joins,e]}),children:`Add join`})]},`s-${e.left}-${e.right}`))]})]}),(0,hR.jsxs)(`div`,{className:`sf-context-preview-head`,children:[(0,hR.jsx)(`span`,{id:`${a}-preview`,className:`sf-object-label`,children:`What the agent receives`}),(0,hR.jsxs)(`select`,{className:`sf-input`,"aria-label":`Format`,value:o,onChange:e=>s(Number(e.target.value)),children:[(0,hR.jsx)(`option`,{value:Gx.MARKDOWN,children:`Markdown`}),(0,hR.jsx)(`option`,{value:Gx.JSON,children:`JSON`})]})]}),(0,hR.jsxs)(`div`,{className:`sf-context-budget`,"data-over":O||void 0,children:[(0,hR.jsx)(`span`,{className:`sf-meter`,role:`img`,"aria-label":`${c?.tokens??0} of ${r} tokens`,children:(0,hR.jsx)(`span`,{style:{inlineSize:`${Math.round(D*100)}%`}})}),(0,hR.jsxs)(`span`,{children:[`About `,IF.format(c?.tokens??0),` of `,IF.format(r),` tokens`,O?` — over budget`:``]})]}),c?.hasValues&&(0,hR.jsx)(`p`,{className:`sf-context-warning`,role:`status`,children:`This context includes actual data values (sample rows).`}),c&&c.missing.length>0&&(0,hR.jsxs)(`p`,{className:`sf-context-warning`,role:`status`,children:[`Not found and left out: `,c.missing.join(`, `),`.`]}),(0,hR.jsx)(`pre`,{className:`sf-context-preview`,tabIndex:0,"aria-labelledby":`${a}-preview`,children:c?.text??``}),(0,hR.jsxs)(`div`,{className:`sf-context-actions`,children:[(0,hR.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:t.name.trim()===``||t.items.length===0,onClick:()=>void w(),children:t.id?`Save new version`:`Save context`}),(0,hR.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:!c,onClick:()=>void T(),children:`Copy`}),m&&(0,hR.jsx)(`span`,{className:m.error?`sf-filter-problem`:`sf-object-muted`,role:`status`,children:m.message})]})]})}var hR,gR,_R,vR,yR=n((()=>{hR=HA(),vS(),gR=jM(),oP(),CF(),LF(),uI(),_R={name:``,notes:``,items:[],joins:[]},vR=(e,t)=>e.sourceId===t.sourceId&&(e.left===t.left&&e.right===t.right||e.left===t.right&&e.right===t.left)}));function bR(e){let{limit:t=8}=e,n=wF(e.discovery),r=JSON.stringify(e.objectRef),[i,a]=(0,SR.useState)();(0,SR.useEffect)(()=>{let r=!0;return a(void 0),n.getRelated({ref:e.objectRef}).then(e=>{if(!r)return;let n=new Map;for(let t of e.relations){let e=t.object?.name??``;n.has(e)&&t.kind!==Wx.JOIN||n.set(e,t)}a([...n.values()].slice(0,t))}).catch(()=>r&&a([])),()=>{r=!1}},[n,r,t]);let o={x:CR/2,y:wR/2},s=e.objectRef.table??``;if(i===void 0)return(0,xR.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`});if(i.length===0)return(0,xR.jsxs)(`p`,{className:`sf-object-muted`,children:[`No related tables were found for `,s,`.`]});let c=i.map((e,t)=>{let n=2*Math.PI*t/i.length-Math.PI/2;return{relation:e,x:o.x+Math.cos(n)*235,y:o.y+Math.sin(n)*105}});return(0,xR.jsxs)(`figure`,{className:[`sf-graph`,e.className].filter(Boolean).join(` `),children:[(0,xR.jsxs)(`svg`,{viewBox:`0 0 ${CR} ${wR}`,role:`group`,"aria-label":`Tables related to ${s}`,children:[c.map(({relation:e,x:t,y:n})=>{let r=e.kind===Wx.JOIN;return(0,xR.jsxs)(`g`,{children:[(0,xR.jsx)(`line`,{x1:o.x,y1:o.y,x2:t,y2:n,className:`sf-graph-edge`,"data-kind":r?`join`:`similar`}),(0,xR.jsx)(`text`,{x:(o.x+t)/2,y:(o.y+n)/2-5,className:`sf-graph-edge-label`,textAnchor:`middle`,children:r?TR(e.keys.map(e=>e.leftColumn).join(`, `),18):`similar`})]},`edge-${e.object?.name}`)}),(0,xR.jsxs)(`g`,{className:`sf-graph-node`,"data-centre":!0,children:[(0,xR.jsx)(`rect`,{x:o.x-70,y:o.y-17,width:140,height:34,rx:8}),(0,xR.jsx)(`text`,{x:o.x,y:o.y+5,textAnchor:`middle`,children:TR(s,18)})]}),c.map(({relation:t,x:n,y:r})=>(0,xR.jsxs)(`g`,{className:`sf-graph-node`,role:`button`,tabIndex:0,"aria-label":`${t.object?.name}: ${t.reason}`,onClick:()=>t.object&&e.onOpen?.(t.object),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&t.object&&(n.preventDefault(),e.onOpen?.(t.object))},children:[(0,xR.jsx)(`rect`,{x:n-66,y:r-16,width:132,height:32,rx:8}),(0,xR.jsx)(`text`,{x:n,y:r+5,textAnchor:`middle`,children:TR(t.object?.name??``,17)})]},t.object?.name))]}),(0,xR.jsxs)(`figcaption`,{className:`sf-graph-legend`,children:[(0,xR.jsx)(`span`,{"data-kind":`join`,children:`Join on shared key`}),(0,xR.jsx)(`span`,{"data-kind":`similar`,children:`Similar columns`}),(0,xR.jsx)(`span`,{children:i.every(e=>e.inferred)?`Relationships are inferred from names and types.`:i.every(e=>!e.inferred)?`Joins are the source's declared keys.`:`Joins on declared keys are facts; the rest are inferred from names and types.`})]})]})}var xR,SR,CR,wR,TR,ER=n((()=>{xR=HA(),vS(),SR=jM(),LF(),CR=640,wR=300,TR=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e}));function DR(e){let t=new Map;for(let n of e)t.set(n.source,(t.get(n.source)??0)+1),n.target!==n.source&&t.set(n.target,(t.get(n.target)??0)+1);return t}function OR(e,t){return t.flatMap(t=>t.source===e?[{id:t.target,label:t.label??``}]:t.target===e?[{id:t.source,label:t.label??``}]:[])}function kR(e,t,n,r=300){let i=new Set(e.map(e=>e.id)),a=t.filter(e=>i.has(e.source)&&i.has(e.target));if(e.length<=r)return{nodes:e,links:a,hidden:0};let o=DR(a),s=n&&i.has(n)?n:[...e].sort((e,t)=>(o.get(t.id)??0)-(o.get(e.id)??0))[0]?.id,c=new Set(s?[s]:[]);for(let e=0;e<2&&c.size<r;e++)for(let e of[...c])for(let t of OR(e,a))c.size<r&&c.add(t.id);let l=e.filter(e=>c.has(e.id));return{nodes:l,links:a.filter(e=>c.has(e.source)&&c.has(e.target)),hidden:e.length-l.length}}function AR(e,t=[]){let n=new Set(e.map(e=>e.group??``));return[...t.filter(e=>n.has(e)),...[...n].filter(e=>e!==``&&!t.includes(e))]}function jR(e){let{nodes:t,links:n,selected:r,colors:i,animate:a,text:o}=e,s=AR(t,e.groups),c=DR(n),l=Math.max(1,...t.map(e=>c.get(e.id)??0)),u=e=>i[Math.min(Math.max(0,s.indexOf(e??``)),Math.max(0,i.length-1))]??i[0],d=e=>{let t=u(e.group);return e.level===`half`?{color:t,opacity:.5}:e.level===`outline`?{color:`rgba(0, 0, 0, 0)`,borderColor:t,borderWidth:2}:{color:t}},f={...o?.color?{color:o.color}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},fontSize:12,textBorderWidth:0,textBorderColor:`transparent`,textShadowBlur:0};return{aria:{enabled:!0},animation:a,animationDuration:700,animationEasing:`backOut`,animationDurationUpdate:600,animationEasingUpdate:`cubicOut`,tooltip:{trigger:`item`,formatter:e=>e.dataType===`edge`?e.data.label??``:`${e.data.name??``}${e.data.description?`: ${e.data.description}`:``}`},...s.length>1?{legend:[{data:s,bottom:4,icon:`circle`,itemWidth:10,itemHeight:10,itemGap:16}]}:{},series:[{id:MR,type:`graph`,layout:`force`,roam:!0,draggable:!0,top:24,bottom:s.length>1?56:24,force:{repulsion:420,edgeLength:[80,150],gravity:.1,friction:.5,layoutAnimation:a},label:{show:t.length<=80,position:`right`,distance:8,...f},labelLayout:{hideOverlap:!0},lineStyle:{...o?.muted?{color:o.muted}:{},width:1.25,opacity:.55,curveness:.12},edgeLabel:{...f,...o?.muted?{color:o.muted}:{},fontSize:11},emphasis:{focus:`adjacency`,scale:1.15,label:{show:!0,fontWeight:`bold`},lineStyle:{width:2.5,opacity:1}},blur:{itemStyle:{opacity:.25},lineStyle:{opacity:.12},label:{opacity:.35}},categories:s.map(e=>({name:e,itemStyle:{color:u(e)}})),data:t.map(e=>{let t=14+Math.round(22*(c.get(e.id)??0)/l),n=e.id===r;return{id:e.id,name:e.label,...e.description?{description:e.description}:{},...s.length>0&&e.group!==void 0?{category:s.indexOf(e.group)}:{},symbolSize:(n?t+6:t)+(e.fresh?4:0),itemStyle:{...d(e),...n?{borderColor:u(e.group),borderWidth:4}:{},...e.fresh?{shadowBlur:28,shadowColor:u(e.group)}:{}},...n||e.level===`half`?{label:{...e.level===`half`?{opacity:1}:{},...n?{show:!0,fontWeight:`bold`}:{}}}:{}}}),links:n.map(e=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.fresh?{lineStyle:{width:2.5,opacity:1,...i[0]?{color:i[0],shadowBlur:12,shadowColor:i[0]}:{}}}:{}}))}]}}var MR,NR=n((()=>{MR=`graph`}));function PR({label:e,nodes:t,links:n,selected:r,onSelect:i,groups:a,levels:o,noun:s=`node`,height:c=420,limit:l=300,onContext:u}){let d=IM(),f=d?.theme??Xj,p=d?.resolvedMode??`light`,m=(0,IR.useMemo)(()=>kR(t,n,r,l),[t,n,r,l]),h=(0,IR.useMemo)(()=>DR(m.links),[m]),g=(0,IR.useMemo)(()=>AR(m.nodes,a),[m,a]),_=(0,IR.useMemo)(()=>SM(f,p),[f,p]),v=(0,IR.useMemo)(()=>_.color??[],[_]),y=(0,IR.useMemo)(()=>{let e=_.textStyle?.color,t=_.legend?.textStyle?.color,n=_.textStyle?.fontFamily;return{...e?{color:e}:{},...t?{muted:t}:{},...n?{fontFamily:n}:{}}},[_]),b=(0,IR.useRef)(null),x=(0,IR.useRef)(void 0),S=(0,IR.useId)(),C=(0,IR.useRef)(()=>{});C.current=e=>{let t=m.nodes.find(t=>t.id===e);i?.(e),u?.({kind:`node.opened`,summary:`Opened ${t?.label??e} on the graph.`,subject:{node:e}})},(0,IR.useEffect)(()=>{let e=b.current;if(!e)return;let t;try{t=PP(e,SM(f,p))}catch{return}x.current=t,t.on(`click`,e=>{let t=e.data?.id;e.dataType===`node`&&t&&C.current(t)});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(()=>t.resize());n?.observe(e);let r=RP(e);return()=>{r(),n?.disconnect(),t.dispose(),x.current=void 0}},[f,p]),(0,IR.useEffect)(()=>{let e=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;try{x.current?.setOption(jR({nodes:m.nodes,links:m.links,...r?{selected:r}:{},...a?{groups:a}:{},colors:v,text:y,animate:!e}),{replaceMerge:[`legend`,`series`]})}catch{}},[m,r,a,v,y]);let w=m.nodes.find(e=>e.id===r),T=w?OR(w.id,m.links):[],E=e=>m.nodes.find(t=>t.id===e)?.label??e,D=(e,t)=>`${e} ${t}${e===1?``:`s`}`,O=g.length>v.length&&v.length>0;return(0,FR.jsx)(`section`,{className:`sf-nodegraph`,"aria-label":e,children:(0,FR.jsxs)(`div`,{className:`sf-nodegraph-frame`,children:[(0,FR.jsx)(`div`,{ref:b,className:`sf-nodegraph-canvas`,style:{height:c},role:`img`,"aria-label":`${e}: ${D(m.nodes.length,s)} and ${D(m.links.length,`link`)}, drawn as a graph.`,"aria-describedby":S}),(0,FR.jsxs)(`div`,{className:`sf-nodegraph-side`,style:{maxHeight:c},children:[(0,FR.jsxs)(`p`,{id:S,className:`sf-nodegraph-note`,role:`status`,children:[D(m.nodes.length,s),`, `,D(m.links.length,`link`),`, also listed here.`,m.hidden>0?` ${m.hidden} more are not drawn: open one to see what is around it.`:``,O?` There are more groups than colours, so the last ${g.length-v.length+1} share one.`:``]}),w&&(0,FR.jsxs)(`div`,{className:`sf-nodegraph-current`,children:[(0,FR.jsxs)(`p`,{children:[(0,FR.jsx)(`strong`,{children:w.label}),T.length===0?` has no links.`:` is linked to:`]}),T.length>0&&(0,FR.jsx)(`ul`,{children:T.map((e,t)=>(0,FR.jsxs)(`li`,{children:[(0,FR.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>C.current(e.id),children:E(e.id)}),e.label&&(0,FR.jsx)(`span`,{className:`sf-nodegraph-kind`,children:e.label})]},`${e.id}:${t}`))})]}),(0,FR.jsx)(`ul`,{className:`sf-nodegraph-list`,children:m.nodes.map(e=>(0,FR.jsx)(`li`,{children:(0,FR.jsxs)(`button`,{type:`button`,className:`sf-nodegraph-row`,"aria-current":e.id===r?`true`:void 0,onClick:()=>C.current(e.id),children:[(0,FR.jsx)(`span`,{className:`sf-nodegraph-name`,children:e.label}),e.level&&(0,FR.jsxs)(`span`,{className:`sf-nodegraph-level`,children:[(0,FR.jsx)(`span`,{"aria-hidden":`true`,children:LR[e.level]}),` `,o?.[e.level]??``]}),(0,FR.jsx)(`span`,{className:`sf-nodegraph-kind`,children:[e.group,D(h.get(e.id)??0,`link`)].filter(Boolean).join(`, `)})]})},e.id))})]})]})})}var FR,IR,LR,RR=n((()=>{FR=HA(),kM(),FP(),IR=jM(),UM(),NR(),zP(),LR={full:`●`,half:`◐`,outline:`○`}}));function zR(e){let t=wF(e.discovery),[n,r]=(0,VR.useState)(``),[i,a]=(0,VR.useState)(),o=(0,VR.useRef)(void 0);return(0,BR.jsxs)(`div`,{className:[`sf-ask`,e.className].filter(Boolean).join(` `),children:[(0,BR.jsxs)(`form`,{className:`sf-ask-form`,onSubmit:async r=>{r.preventDefault();let i=n.trim();if(i===``)return;o.current?.abort();let s=new AbortController;o.current=s;let c={question:i,text:``,citations:[],streaming:!0};a(c);let l=e=>{c={...c,...e},s.signal.aborted||a(c)};try{for await(let n of t.ask({question:i,contextPackId:e.contextPackId,sourceIds:e.sourceIds},{signal:s.signal})){let e=n.part;e.case===`textDelta`?l({text:c.text+e.value}):e.case===`citation`&&e.value.object?l({citations:[...c.citations,{object:e.value.object,reason:e.value.reason}]}):e.case===`done`&&l({by:e.value.generatedBy,sql:e.value.suggestedSql})}l({streaming:!1})}catch(e){l({streaming:!1,error:rP(e)})}},children:[(0,BR.jsx)(`input`,{className:`sf-input sf-ask-input`,"aria-label":`Ask a question about the data`,placeholder:`Ask about the data, e.g. which table has revenue by region?`,value:n,onChange:e=>r(e.target.value)}),(0,BR.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:n.trim()===``||i?.streaming,children:`Ask`})]}),i&&(0,BR.jsxs)(`div`,{className:`sf-ask-answer`,"aria-live":`polite`,"aria-busy":i.streaming,children:[(0,BR.jsx)(`p`,{className:`sf-ask-question`,children:i.question}),i.error?(0,BR.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:i.error}):(0,BR.jsx)(`p`,{className:`sf-ask-text`,children:i.text||(i.streaming?`Thinking…`:``)}),i.citations.length>0&&(0,BR.jsx)(`ul`,{className:`sf-ask-citations`,"aria-label":`Tables used`,children:i.citations.map(t=>(0,BR.jsxs)(`li`,{children:[(0,BR.jsx)(`button`,{type:`button`,className:`sf-button`,title:t.reason,onClick:()=>e.onOpen?.(t.object),children:t.object.name}),e.renderActions?.(t.object)]},t.object.name))}),i.sql&&(0,BR.jsxs)(`div`,{className:`sf-ask-sql`,children:[(0,BR.jsx)(NL,{code:i.sql,language:`sql`,label:`Proposed SQL`}),e.onUseSql&&(0,BR.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onUseSql?.(i.sql),children:`Use this SQL`})]}),i.by&&(0,BR.jsx)(`p`,{className:`sf-ask-by`,"data-placeholder":i.by===`placeholder`||void 0,children:i.by===`placeholder`?`Search results only — no language model is connected.`:`Answered by ${i.by}. Check it against the data.`})]})]})}var BR,VR,HR=n((()=>{BR=HA(),VR=jM(),oP(),LF(),zL()}));function UR(e,t={}){let n=t.min??.2,r=t.max??2.5;return Number.isFinite(e)?Math.min(r,Math.max(n,e)):1}function WR(e,t){return{x:(t.x-e.x)/e.k,y:(t.y-e.y)/e.k}}function GR(e,t,n,r){let i=UR(e.k*t,r),a=i/e.k;return{k:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a}}function KR(e,t,n,r=48){if(n.width<=0||n.height<=0)return e;let i=t.width*e.k,a=t.height*e.k,o=Math.min(r,i),s=Math.min(r,a);return{k:e.k,x:Math.min(n.width-o,Math.max(o-i,e.x)),y:Math.min(n.height-s,Math.max(s-a,e.y))}}function qR(e,t,n,r=16){if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return nz;let i={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)},a=UR(Math.min(1,i.width/e.width,i.height/e.height),n);return{k:a,x:(t.width-e.width*a)/2,y:(t.height-e.height*a)/2}}function JR(e,t=0){let n=t===1?e*16:t===2?e*400:e;return Math.exp(-Math.max(-100,Math.min(100,n))*.0022)}function YR(e,t,n,r=16){let i=(e,t,n)=>t+r*2>n||e<r?r-e:e+t>n-r?n-r-(e+t):0,a=i(t.left,t.width,n.width),o=i(t.top,t.height,n.height);return a===0&&o===0?e:{...e,x:e.x+a,y:e.y+o}}function XR(e){try{return e.matches(`:focus-visible`)}catch{return!0}}function ZR(e){let t={min:e.min??.2,max:e.max??2.5},[n,r]=(0,ez.useState)(nz),[i,a]=(0,ez.useState)(!1),[o,s]=(0,ez.useState)(!1),[c,l]=(0,ez.useState)(null),[u,d]=(0,ez.useState)({width:0,height:0}),f=(0,ez.useRef)(n);f.current=n;let p=(0,ez.useRef)(e.content);p.current=e.content;let m=(0,ez.useRef)(t);m.current=t;let h=(0,ez.useRef)(u);h.current=u;let g=(0,ez.useRef)(!0),_=(0,ez.useRef)(new Map),v=(0,ez.useRef)(void 0),y=(0,ez.useRef)(void 0),b=(0,ez.useCallback)((e,t=!1)=>{let n=KR({...e,k:UR(e.k,m.current)},p.current,h.current);a(t),f.current=n,r(n)},[]);(0,ez.useLayoutEffect)(()=>{if(!c)return;let e=()=>d(e=>e.width===c.clientWidth&&e.height===c.clientHeight?e:{width:c.clientWidth,height:c.clientHeight});if(e(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e);return t.observe(c),()=>t.disconnect()},[c]);let{width:x,height:S}=e.content;(0,ez.useLayoutEffect)(()=>{if(!g.current||u.width<=0||x<=0||S<=0)return;let e=qR({width:x,height:S},u,m.current);f.current=e,r(e),a(!1)},[x,S,u]);let C=(0,ez.useCallback)(e=>{let t=c?.getBoundingClientRect();return{x:e.clientX-(t?.left??0),y:e.clientY-(t?.top??0)}},[c]),w=()=>({x:h.current.width/2,y:h.current.height/2}),T=()=>{g.current=!1},E=(e,t=w(),n=!0)=>{T(),b(GR(f.current,e,t,m.current),n)},D=(e,t,n=!1)=>{T(),b({...f.current,x:f.current.x+e,y:f.current.y+t},n)},O=()=>{g.current=!0;let e=qR(p.current,h.current,m.current);b(e,!0)},k=()=>{T(),b(nz,!0)};(0,ez.useEffect)(()=>{if(!c)return;let e=e=>{let t=C(e);if(e.ctrlKey||e.metaKey){e.preventDefault(),g.current=!1,b(GR(f.current,JR(e.deltaY,e.deltaMode),t,m.current));return}let n=e.deltaMode===1?16:e.deltaMode===2?h.current.height:1,[r,i]=e.shiftKey&&e.deltaX===0?[e.deltaY*n,0]:[e.deltaX*n,e.deltaY*n],a=f.current,o=KR({...a,x:a.x-r,y:a.y-i},p.current,h.current);(o.x!==a.x||o.y!==a.y)&&(e.preventDefault(),g.current=!1,b(o))};return c.addEventListener(`wheel`,e,{passive:!1}),()=>c.removeEventListener(`wheel`,e)},[c,C,b]);let ee={tabIndex:0,"data-panning":o?``:void 0,onPointerDown(e){let t=C(e);if(T(),(e.pointerType!==`mouse`||e.button===0)&&!(e.target.closest?.(rz)&&_.current.size===0)){if(_.current.set(e.pointerId,t),e.currentTarget.setPointerCapture?.(e.pointerId),_.current.size===2){let[e,t]=[..._.current.values()];v.current=void 0,y.current={distance:Math.hypot(e.x-t.x,e.y-t.y)||1,view:f.current,mid:{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}}else _.current.size===1&&(v.current={id:e.pointerId,x:t.x,y:t.y,view:f.current},s(!0))}},onPointerMove(e){if(!_.current.has(e.pointerId))return;let t=C(e);_.current.set(e.pointerId,t);let n=y.current;if(n&&_.current.size>=2){let[e,t]=[..._.current.values()],r={x:(e.x+t.x)/2,y:(e.y+t.y)/2},i=GR(n.view,Math.hypot(e.x-t.x,e.y-t.y)/n.distance,n.mid,m.current);b({...i,x:i.x+r.x-n.mid.x,y:i.y+r.y-n.mid.y});return}let r=v.current;r&&r.id===e.pointerId&&b({...r.view,x:r.view.x+t.x-r.x,y:r.view.y+t.y-r.y})},onPointerUp(e){if(!_.current.delete(e.pointerId))return;e.currentTarget.releasePointerCapture?.(e.pointerId),y.current=void 0;let[t]=[..._.current.entries()];v.current=t?{id:t[0],x:t[1].x,y:t[1].y,view:f.current}:void 0,t||s(!1)},onPointerCancel(e){ee.onPointerUp(e)},onKeyDown(e){if(e.target!==e.currentTarget||e.altKey||e.ctrlKey||e.metaKey)return;let t={"+":()=>E(tz),"=":()=>E(tz),"-":()=>E(1/tz),_:()=>E(1/tz),0:O,ArrowLeft:()=>D(48,0,!0),ArrowRight:()=>D(-48,0,!0),ArrowUp:()=>D(0,48,!0),ArrowDown:()=>D(0,-48,!0)}[e.key];t&&(e.preventDefault(),t())},onFocus(e){if(!c||e.target===e.currentTarget||!XR(e.target))return;let t=c.getBoundingClientRect(),n=e.target.getBoundingClientRect(),r=YR(f.current,{left:n.left-t.left,top:n.top-t.top,width:n.width,height:n.height},h.current);r!==f.current&&b(r,!0),c.scrollLeft=0,c.scrollTop=0}};return{view:n,viewport:u,viewportRef:l,viewportProps:ee,planeStyle:{transform:`translate(${n.x}px, ${n.y}px) scale(${n.k})`,transformOrigin:`0 0`},animate:i,pointToWorld:e=>WR(f.current,C(e)),zoomIn:()=>E(tz),zoomOut:()=>E(1/tz),fit:O,reset:k,min:t.min,max:t.max}}function QR({panZoom:e,label:t=`Zoom`}){let n=Math.round(e.view.k*100);return(0,$R.jsxs)(`div`,{className:`sf-panzoom-controls`,role:`group`,"aria-label":t,children:[(0,$R.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Zoom out`,title:`Zoom out (−)`,"aria-keyshortcuts":`-`,disabled:e.view.k<=e.min+1e-6,onClick:e.zoomOut,children:`−`}),(0,$R.jsxs)(`output`,{className:`sf-panzoom-level`,"aria-live":`polite`,"aria-label":`Zoom ${n}%`,children:[n,`%`]}),(0,$R.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Zoom in`,title:`Zoom in (+)`,"aria-keyshortcuts":`+`,disabled:e.view.k>=e.max-1e-6,onClick:e.zoomIn,children:`+`}),(0,$R.jsx)(`button`,{type:`button`,className:`sf-button`,title:`Fit to view (0)`,"aria-keyshortcuts":`0`,onClick:e.fit,children:`Fit to view`}),(0,$R.jsx)(`button`,{type:`button`,className:`sf-button`,title:`Reset to 100%`,"aria-label":`Reset zoom to 100%`,onClick:e.reset,children:`100%`})]})}var $R,ez,tz,nz,rz,iz=n((()=>{$R=HA(),ez=jM(),tz=1.25,nz={x:0,y:0,k:1},rz=`button, a, input, select, textarea, label, [data-pan-ignore]`}));function az(e){let t=wz(e.left)<=wz(e.right),[n,r]=t?[e.left,e.right]:[e.right,e.left],i=e.keys.map(e=>t?`${e.leftColumn}=${e.rightColumn}`:`${e.rightColumn}=${e.leftColumn}`).sort();return wz(`${n}|${r}|${i.join(`&`)}`)}function oz(e){return e.keys.map(t=>`${Dz(e.left)}.${Ez(t.leftColumn)} = ${Dz(e.right)}.${Ez(t.rightColumn)}`).join(` AND `)}function sz(e,t){return t===`inner`?`Only rows that match`:t===`left`?`Every ${e.left} row`:t===`right`?`Every ${e.right} row`:`Every row of both`}function cz(e){return{...e,left:e.right,right:e.left,keys:e.keys.map(e=>({leftColumn:e.rightColumn,rightColumn:e.leftColumn})),...e.type?{type:kz[e.type]}:{}}}function lz(e,t){return Tz(e.left,t)?e:cz(e)}function uz(e,t){let n=new Map,r=new Set,i=[];for(let a of e)for(let e of t(a)){let t=n.get(wz(e))??0,o=t===0?e:`${e}_${t}`;for(;r.has(wz(o));)o=`${e}_${++t}`;n.set(wz(e),t+1),r.add(wz(o)),i.push({table:a,column:e,name:o})}return i}function dz(e,t){let[n,...r]=e.tables;if(!n)return{sql:``,unjoined:[],order:[]};let i=[n],a=new Set(r.map(wz)),o=[`FROM ${Dz(n)}`];for(let t=!0;t&&a.size>0;){t=!1;for(let n of e.joins){let r=i.some(e=>Tz(e,n.left));if(r===i.some(e=>Tz(e,n.right)))continue;let s=r?n.right:n.left;if(!a.has(wz(s)))continue;let c=e.joins.filter(e=>Tz(e.left,s)&&i.some(t=>Tz(t,e.right))||Tz(e.right,s)&&i.some(t=>Tz(t,e.left))).map(oz),l=lz(n,r?n.left:n.right).type??`inner`;o.push(`${Oz[l]} ${Dz(s)} ON ${c.join(` AND `)}`),i.push(s),a.delete(wz(s)),t=!0}}let s=e.tables.filter(e=>a.has(wz(e))),c=t?i.map(e=>t(e)):[];if(!t||c.some(e=>!e||e.length===0))return{sql:[`SELECT *`,...o].join(`
|
|
39
|
-
`),unjoined:s,order:i};let l=
|
|
40
|
-
`),unjoined:s,order:i,columns:l}:{sql:[`SELECT ${l.map(e=>`${
|
|
39
|
+
`)});continue}if(r.trim()===``){e++;continue}let a=/^(#{1,6})\s+(.*)$/.exec(r);if(a){n.push({kind:`heading`,level:a[1].length,text:a[2]}),e++;continue}if(/^\s*([-*_])\s*\1\s*\1[\s\-*_]*$/.test(r)){n.push({kind:`rule`}),e++;continue}if(r.includes(`|`)&&/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(t[e+1]??``)){let i=KL(r),a=[];for(e+=2;e<t.length&&t[e].includes(`|`)&&t[e].trim()!==``;e++)a.push(KL(t[e]));n.push({kind:`table`,head:i,rows:a});continue}let o=/^\s*(?:[-*+]|(\d+)[.)])\s+(.*)$/.exec(r);if(o){let r=o[1]!==void 0,i=[];for(;e<t.length;e++){let n=/^\s*(?:[-*+]|(\d+)[.)])\s+(.*)$/.exec(t[e]);if(n&&n[1]!==void 0===r)i.push(n[2]);else if(i.length>0&&/^\s{2,}\S/.test(t[e]))i[i.length-1]+=` ${t[e].trim()}`;else break}let a=r?Number(o[1]):void 0;n.push(a!==void 0&&a!==1?{kind:`list`,ordered:r,items:i,start:a}:{kind:`list`,ordered:r,items:i});continue}if(/^\s*>/.test(r)){let r=[];for(;e<t.length&&/^\s*>/.test(t[e]);e++)r.push(t[e].replace(/^\s*>\s?/,``));n.push({kind:`quote`,text:r.join(` `)});continue}let s=[];for(;e<t.length&&t[e].trim()!==``&&!/^\s*(```|#{1,6}\s|>|[-*+]\s|\d+[.)]\s)/.test(t[e]);e++)s.push(t[e].trim());s.length===0&&s.push(t[e++].trim()),n.push({kind:`paragraph`,text:s.join(` `)})}return n}function BL({code:e,language:t}){let n=(0,WL.useMemo)(()=>lL(e,t),[e,t]);return(0,UL.jsx)(`code`,{"data-language":t||void 0,children:n.map((e,t)=>e.kind?(0,UL.jsx)(`span`,{className:`sf-tok-${e.kind}`,children:e.text},t):(0,UL.jsx)(WL.Fragment,{children:e.text},t))})}function VL({code:e,language:t,onRun:n,label:r,bare:i,className:a}){let[o,s]=(0,WL.useState)(!1);return(0,UL.jsxs)(`div`,{className:[`sf-code`,i&&`sf-code-bare`,a].filter(Boolean).join(` `),children:[!i&&(0,UL.jsxs)(`div`,{className:`sf-code-bar`,children:[(0,UL.jsx)(`span`,{children:t||`text`}),(0,UL.jsxs)(`span`,{className:`sf-code-actions`,children:[n&&(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>n(e),children:`Run`}),(0,UL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>{})},"aria-live":`polite`,children:o?`Copied`:`Copy`})]})]}),(0,UL.jsx)(`pre`,{tabIndex:0,"aria-label":r??(t?`${t} code`:`Code`),children:(0,UL.jsx)(BL,{code:e,language:t})})]})}function HL({text:e,onRunSql:t,inline:n,headingStart:r=3,resolveLink:i,resolveImage:a,openLink:o,className:s}){let c=OL(),l={resolve:i,image:a??c,open:o},u=e=>RL(e,l);return n?(0,UL.jsx)(`span`,{className:[`sf-markdown-inline`,s].filter(Boolean).join(` `),children:u(e)}):(0,UL.jsxs)(`div`,{className:[`sf-markdown`,s].filter(Boolean).join(` `),children:[zL(e).map((e,n)=>{switch(e.kind){case`heading`:{let t=`h${Math.min(6,e.level+Math.max(0,Math.min(5,r-1)))}`;return(0,UL.jsx)(t,{children:u(e.text)},n)}case`code`:return(0,UL.jsx)(VL,{code:e.code,language:e.language,onRun:t&&/^sql$/i.test(e.language)?t:void 0},n);case`list`:{let t=e.ordered?`ol`:`ul`;return(0,UL.jsx)(t,{start:e.start,children:e.items.map((e,t)=>(0,UL.jsx)(`li`,{children:u(e)},t))},n)}case`quote`:return(0,UL.jsx)(`blockquote`,{children:u(e.text)},n);case`rule`:return(0,UL.jsx)(`hr`,{},n);case`table`:return(0,UL.jsx)(`div`,{className:`sf-markdown-table`,tabIndex:0,role:`region`,"aria-label":`Table: ${e.head.slice(0,3).join(`, `)}`,children:(0,UL.jsxs)(`table`,{children:[(0,UL.jsx)(`thead`,{children:(0,UL.jsx)(`tr`,{children:e.head.map((e,t)=>(0,UL.jsx)(`th`,{scope:`col`,children:u(e)},t))})}),(0,UL.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,UL.jsx)(`tr`,{children:e.head.map((e,n)=>(0,UL.jsx)(`td`,{children:u(t[n]??``)},n))},n))})]})},n);default:return(0,UL.jsx)(`p`,{children:u(e.text)},n)}}),(0,UL.jsx)(WL.Fragment,{})]})}var UL,WL,GL,KL,qL=n((()=>{UL=WA(),WL=NM(),EL(),IL(),GL=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(!\[[^\]\n]*\]\([^)\s]+\)|\[[^\]\n]+\]\([^)\s]+\))/g,KL=e=>e.trim().replace(/^\||\|$/g,``).split(`|`).map(e=>e.trim())}));function JL(e,t){return t===`count`?{aggregate:`count`}:t===`p90`?{column:e,aggregate:`percentile`,percentile:.9}:{column:e,aggregate:t}}function YL(e){let[t,n]=(0,QL.useState)(!1);return(0,ZL.jsxs)(`details`,{className:`sf-result-sql`,onToggle:e=>n(e.currentTarget.open),children:[(0,ZL.jsx)(`summary`,{children:z(`result.plan`)}),t&&(0,ZL.jsx)(rL,{...e})]})}function XL(e){let{sourceId:t,sql:n,timeTravel:r,notBefore:i,height:a=420,onError:o}=e,s=VN(e.dataSource),c=(0,QL.useId)(),[l,u]=(0,QL.useState)(e.defaultView??`grid`),[f,p]=(0,QL.useState)(e.filters??[]),[m,h]=(0,QL.useState)(e.sorts??[]),[g,_]=(0,QL.useState)(e.columns??{}),v=e=>JSON.stringify(e??null,(e,t)=>typeof t==`bigint`?`${t}n`:t),y=(0,QL.useRef)({filters:e.filters,sorts:e.sorts,columns:e.columns});y.current={filters:e.filters,sorts:e.sorts,columns:e.columns},(0,QL.useEffect)(()=>{e.filters&&p(e.filters)},[v(e.filters)]),(0,QL.useEffect)(()=>{e.sorts&&h(e.sorts)},[v(e.sorts)]),(0,QL.useEffect)(()=>{e.columns&&_(e.columns)},[v(e.columns)]),(0,QL.useEffect)(()=>{e.view&&u(e.view)},[e.view]);let b=(0,QL.useRef)(e.onControlsChange);b.current=e.onControlsChange;let x=(0,QL.useRef)(!0);(0,QL.useEffect)(()=>{x.current?x.current=!1:b.current?.({view:l,filters:f,sorts:m,columns:g})},[l,f,m,g]);let[S,C]=(0,QL.useState)([]),[w,T]=(0,QL.useState)(),[E,D]=(0,QL.useState)({type:`bar`,x:``,grain:`month`,bins:0,splitBy:``,raw:!1,stacked:!1,legend:``,series:[]}),[O,k]=(0,QL.useState)({row:``,column:``,grain:`month`,measure:``,summary:`sum`}),[ee,te]=(0,QL.useState)(1),[A,ne]=(0,QL.useState)({}),[re,ie]=(0,QL.useState)(``),[ae,oe]=(0,QL.useState)({status:``}),se=(0,QL.useCallback)(async e=>{let a=await JS(s.execute({sourceId:t,timeTravel:r,notBefore:i,query:{baseSql:n,groupBy:[e],aggregates:[{function:ux.COUNT,alias:`sf_count`}],sorts:[{column:`sf_count`,direction:ax.DESC}],page:{limit:50}}})),o=a.table.getChildAt(0),c=a.table.schema.fields[0]?.type;return Array.from({length:a.table.numRows},(e,t)=>o?.get(t)).filter(e=>e!=null).map(e=>c?XN(e,c).text:String(e))},[s,t,n,i,r]),ce=async()=>{let a=new AbortController;oe({status:z(`result.preparing`),exporting:a});try{let o=await XI(s,{sourceId:t,timeTravel:r,notBefore:i,query:{baseSql:n,filters:f}},{signal:a.signal,onProgress:e=>oe({status:z(`result.rowsSoFar`,{count:NA().format(e)}),exporting:a})});ZI(o.blob,`${e.exportName??`result`}.csv`),oe({status:z(o.truncated?`result.savedTruncated`:`result.saved`,{count:NA().format(o.rows)})})}catch(e){oe({status:a.signal.aborted?z(`result.exportStopped`):d(e).message})}},le=()=>{navigator.clipboard?.writeText(w?.executedSql||n).then(()=>oe({status:z(`result.sqlCopied`)}),()=>oe({status:z(`result.copyNotAllowed`)}))},ue=A[re]?.kind??``,de=JSON.stringify(r??null,(e,t)=>typeof t==`bigint`?`${t}n`:t);(0,QL.useEffect)(()=>{let e=new AbortController;return p(y.current.filters??[]),h(y.current.sorts??[]),JS(s.execute({sourceId:t,timeTravel:r,notBefore:i,query:{baseSql:n,page:{limit:1}}},{signal:e.signal})).then(t=>{if(e.signal.aborted)return;let n=t.table.schema.fields;C(n);let r=n.find(sR)??n.find(e=>!YN(e.type))??n[0],i=n.filter(e=>YN(e.type)&&e!==r&&!/(^|_)id$/i.test(e.name)),a=i.find(e=>!P.isInt(e.type))??i[0]??n.find(e=>YN(e.type)&&e!==r),s=n.find(e=>!YN(e.type)&&!sR(e));D(e=>({...e,type:sR(r)?`line`:`bar`,x:r?.name??``,splitBy:``,series:[{id:0,column:a?.name??``,summary:a?`sum`:`count`,type:``,axis:`left`}]})),k(e=>({...e,row:s?.name??r?.name??``,column:n.find(e=>e!==s&&sR(e))?.name??``,measure:a?.name??``,summary:a?`sum`:`count`})),o?.(void 0)}).catch(t=>{if(e.signal.aborted)return;C([]);let n=d(t);o?.(n.message,n)}),()=>e.abort()},[s,t,n,de,i]);let fe=e=>S.find(t=>t.name===e),pe=S.filter(e=>YN(e.type)),me=fe(E.x),he=sR(me),ge=me!==void 0&&YN(me.type),j=E.series.map(e=>({...E.raw?{column:e.column}:JL(e.column,e.summary),type:e.type||void 0,axis:e.axis})),_e=E.x!==``&&E.series.length>0&&E.series.every(e=>e.column!==``||!E.raw&&e.summary===`count`),ve=(e,t)=>D(n=>({...n,series:n.series.map(n=>n.id===e?{...n,...t}:n)})),ye=E.type!==`pie`,be=O.row!==``&&(O.summary===`count`||O.measure!==``),xe=e=>sR(fe(e))?{column:e,grain:O.grain}:e,Se=(e,t,n,r)=>(0,ZL.jsxs)(`label`,{children:[(0,ZL.jsx)(`span`,{children:e}),(0,ZL.jsx)(`select`,{className:`sf-input`,value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,ZL.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),M=e=>e.map(e=>({value:e.name,label:e.name})),Ce=e=>[{value:``,label:e}],we=iR.map(e=>({value:e,label:z(aR[e])})),Te=nR.map(e=>({value:e,label:e}));return(0,ZL.jsxs)(`section`,{className:[`sf-result`,`sf-container`,e.className].filter(Boolean).join(` `),children:[(0,ZL.jsxs)(`div`,{className:`sf-result-bar`,children:[(0,ZL.jsx)(`div`,{className:`sf-segmented sf-result-views`,role:`tablist`,"aria-label":z(`result.views`),children:$L.map(e=>(0,ZL.jsx)(`button`,{type:`button`,role:`tab`,id:`${c}-${e.id}`,"aria-selected":l===e.id,"aria-controls":`${c}-panel`,className:`sf-segment`,"data-checked":l===e.id||void 0,onClick:()=>u(e.id),children:z(e.label)},e.id))}),(0,ZL.jsx)(CI,{fields:S,filters:f,onChange:p,loadValues:se})]}),(0,ZL.jsxs)(`div`,{className:`sf-result-tools`,children:[ae.exporting?(0,ZL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>ae.exporting?.abort(),children:z(`result.stopExport`)}):(0,ZL.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:S.length===0,onClick:()=>void ce(),children:z(`result.downloadCsv`)}),(0,ZL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:le,children:z(`result.copySql`)}),w?.loading&&l===`grid`&&(0,ZL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:w.cancel,children:z(`result.cancelQuery`)}),l===`grid`&&S.length>0&&(0,ZL.jsxs)(ZL.Fragment,{children:[(0,ZL.jsxs)(`label`,{children:[(0,ZL.jsx)(`span`,{children:z(`result.format`)}),(0,ZL.jsxs)(`select`,{className:`sf-input`,"aria-label":z(`result.formatColumn`),value:re,onChange:e=>ie(e.target.value),children:[(0,ZL.jsx)(`option`,{value:``,children:z(`result.chooseColumn`)}),S.map(e=>(0,ZL.jsx)(`option`,{children:e.name},e.name))]})]}),re&&(0,ZL.jsxs)(`select`,{className:`sf-input`,"aria-label":z(`result.howToShow`,{column:re}),value:ue,onChange:e=>{let t=e.target.value;ne(e=>{let{[re]:n,...r}=e;return t?{...r,[re]:{kind:t,...t===`currency`?{decimals:2}:{}}}:r})},children:[(0,ZL.jsx)(`option`,{value:``,children:z(`result.asItIs`)}),(YN(fe(re)?.type??S[0].type)?[`number`,`compact`,`currency`,`percent`,`text`]:sR(fe(re))?[`date`,`datetime`]:[`text`]).map(e=>(0,ZL.jsx)(`option`,{value:e,children:z(oR[e])},e))]})]}),(0,ZL.jsx)(`span`,{className:`sf-result-tools-status`,role:`status`,children:ae.status})]}),l===`chart`&&(0,ZL.jsxs)(`div`,{className:`sf-result-chart-controls`,children:[(0,ZL.jsxs)(`div`,{className:`sf-result-control-row`,children:[Se(z(`result.chartType`),E.type,eR.map(e=>({value:e,label:e})),e=>D({...E,type:e})),Se(z(E.type===`pie`?`result.slices`:`result.xAxis`),E.x,M(S),e=>D({...E,x:e})),!E.raw&&he&&Se(z(`result.every`),E.grain,Te,e=>D({...E,grain:e})),!E.raw&&ge&&Se(z(`result.bins`),String(E.bins),[{value:`0`,label:z(`result.binsEach`)},...[10,20,50].map(e=>({value:String(e),label:z(`result.binsAbout`,{count:e})}))],e=>D({...E,bins:Number(e)})),ye&&Se(z(`result.splitBy`),E.splitBy,[...Ce(z(`result.nothing`)),...M(S.filter(e=>e.name!==E.x))],e=>D({...E,splitBy:e})),ye&&Se(z(`result.legend`),E.legend,[...Ce(z(`result.automatic`)),...rR.map(e=>({value:e,label:e===`none`?z(`result.legendHidden`):e}))],e=>D({...E,legend:e})),ye&&(0,ZL.jsxs)(`label`,{className:`sf-result-check`,children:[(0,ZL.jsx)(`input`,{type:`checkbox`,checked:E.stacked,onChange:e=>D({...E,stacked:e.target.checked})}),(0,ZL.jsx)(`span`,{children:z(`result.stack`)})]}),(0,ZL.jsxs)(`label`,{className:`sf-result-check`,children:[(0,ZL.jsx)(`input`,{type:`checkbox`,checked:E.raw,onChange:e=>D({...E,raw:e.target.checked})}),(0,ZL.jsx)(`span`,{children:z(`result.plotEachRow`)})]})]}),E.series.map((e,t)=>(0,ZL.jsxs)(`div`,{className:`sf-result-control-row`,role:`group`,"aria-label":z(`result.series`,{number:t+1}),children:[!E.raw&&Se(t===0?z(`result.yAxis`):z(`result.series`,{number:t+1}),e.summary,we,t=>ve(e.id,{summary:t})),(E.raw||e.summary!==`count`)&&Se(E.raw?t===0?z(`result.yAxis`):z(`result.series`,{number:t+1}):z(`result.of`),e.column,M(E.raw||e.summary===`min`||e.summary===`max`||e.summary===`count_distinct`?S:pe),t=>ve(e.id,{column:t})),ye&&Se(z(`result.drawnAs`),e.type,[...Ce(z(`result.drawnAsChart`,{type:E.type})),...tR.map(e=>({value:e,label:e}))],t=>ve(e.id,{type:t})),ye&&Se(z(`result.scale`),e.axis,[{value:`left`,label:z(`result.leftAxis`)},{value:`right`,label:z(`result.rightAxis`)}],t=>ve(e.id,{axis:t})),E.series.length>1&&(0,ZL.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":z(`result.removeSeries`,{number:t+1}),onClick:()=>D({...E,series:E.series.filter(t=>t.id!==e.id)}),children:z(`result.remove`)})]},e.id)),ye&&E.series.length<6&&(0,ZL.jsx)(`div`,{className:`sf-result-control-row`,children:(0,ZL.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{let e=E.series.at(-1);D({...E,series:[...E.series,{id:ee,column:e?.column??pe[0]?.name??``,summary:`avg`,type:`line`,axis:`right`}]}),te(ee+1)},children:z(`result.addSeries`)})})]}),l===`pivot`&&(0,ZL.jsx)(`div`,{className:`sf-result-chart-controls`,children:(0,ZL.jsxs)(`div`,{className:`sf-result-control-row`,children:[Se(z(`result.rows`),O.row,M(S),e=>k({...O,row:e})),Se(z(`result.columns`),O.column,[...Ce(z(`result.none`)),...M(S.filter(e=>e.name!==O.row))],e=>k({...O,column:e})),(sR(fe(O.row))||sR(fe(O.column)))&&Se(z(`result.datesBy`),O.grain,Te,e=>k({...O,grain:e})),Se(z(`result.values`),O.summary,we,e=>k({...O,summary:e})),O.summary!==`count`&&Se(z(`result.of`),O.measure,M(O.summary===`min`||O.summary===`max`||O.summary===`count_distinct`?S:pe),e=>k({...O,measure:e}))]})}),(0,ZL.jsx)(`div`,{id:`${c}-panel`,role:`tabpanel`,"aria-labelledby":`${c}-${l}`,children:l===`grid`?(0,ZL.jsx)(CP,{dataSource:s,sourceId:t,sql:n,filters:f,timeTravel:r,notBefore:i,formats:A,height:a,sorts:m,onSortsChange:h,columns:g,onColumnsChange:_,onCellFilter:(e,t,n)=>p(r=>[...r,zC(e,t,n)]),emptyMessage:e.emptyMessage,errorMessage:e.errorMessage,onInfo:e=>{T(e),e.error&&o?.(e.error,e.errorInfo)}}):l===`chart`?_e?(0,ZL.jsx)(`div`,{className:`sf-result-chart`,children:(0,ZL.jsx)(xF,{dataSource:s,sourceId:t,sql:n,filters:f,timeTravel:r,notBefore:i,type:E.type,x:E.x,xGrain:!E.raw&&he?E.grain:void 0,xBins:!E.raw&&ge&&E.bins>0?E.bins:void 0,y:E.type===`pie`?j.slice(0,1):j,splitBy:ye&&E.splitBy?E.splitBy:void 0,stacked:E.stacked,legend:E.legend||void 0,height:a-24,emptyMessage:e.emptyMessage,errorMessage:e.errorMessage})}):(0,ZL.jsx)(`p`,{className:`sf-chart-message`,style:{minHeight:a},children:z(`result.chooseChart`)}):be?(0,ZL.jsx)(LI,{dataSource:s,sourceId:t,sql:n,filters:f,timeTravel:r,notBefore:i,rows:[xe(O.row)],columns:O.column?[xe(O.column)]:[],measures:[JL(O.measure,O.summary)],height:a,emptyMessage:e.emptyMessage,errorMessage:e.errorMessage}):(0,ZL.jsx)(`p`,{className:`sf-chart-message`,style:{minHeight:a},children:z(`result.choosePivot`)})}),l===`grid`&&w?.executedSql&&(0,ZL.jsxs)(`details`,{className:`sf-result-sql`,children:[(0,ZL.jsx)(`summary`,{children:z(`result.sqlSent`)}),(0,ZL.jsx)(VL,{code:w.executedSql,language:`sql`,label:z(`result.sqlSent`)}),w.stored&&(0,ZL.jsx)(`p`,{className:`sf-result-notice`,children:z(`result.stored`)}),w.notices.map(e=>(0,ZL.jsx)(`p`,{className:`sf-result-notice`,children:e.message},e.code))]}),S.length>0&&(0,ZL.jsx)(YL,{sourceId:t,sql:n,filters:f,dataSource:s})]})}var ZL,QL,$L,eR,tR,nR,rR,iR,aR,oR,sR,cR=n((()=>{ZL=WA(),rw(),vS(),_p(),QL=NM(),EF(),GN(),$I(),rP(),jI(),PP(),HA(),KI(),oL(),qL(),$L=[{id:`grid`,label:`result.tabTable`},{id:`chart`,label:`result.tabChart`},{id:`pivot`,label:`result.tabPivot`}],eR=[`bar`,`line`,`area`,`scatter`,`pie`],tR=[`bar`,`line`,`area`,`scatter`],nR=[`hour`,`day`,`week`,`month`,`quarter`,`year`],rR=[`top`,`bottom`,`right`,`none`],iR=[`sum`,`avg`,`median`,`count`,`count_distinct`,`min`,`max`,`stddev`,`p90`],aR={sum:`result.sum`,avg:`result.avg`,median:`result.median`,count:`result.count`,count_distinct:`result.countDistinct`,min:`result.min`,max:`result.max`,stddev:`result.stddev`,p90:`result.p90`},oR={number:`result.formatNumber`,compact:`result.formatCompact`,currency:`result.formatCurrency`,percent:`result.formatPercent`,text:`result.formatText`,date:`result.formatDate`,datetime:`result.formatDatetime`},sR=e=>e!==void 0&&(P.isTimestamp(e.type)||P.isDate(e.type))}));function lR(e){let{pageSize:t=25}=e,n=MF(e.discovery),r=(0,dR.useId)(),[i,a]=(0,dR.useState)(``),[o,s]=(0,dR.useState)(`all`),[c,l]=(0,dR.useState)(Vx.UNSPECIFIED),[u,d]=(0,dR.useState)(!1),[f,p]=(0,dR.useState)({hits:[],next:``,total:0,modeUsed:Vx.UNSPECIFIED,loading:!0}),m=JSON.stringify(e.sourceIds??[]),h=(r,a,s)=>n.search({query:i,mode:c,kinds:fR.find(e=>e.id===o).kinds,sourceIds:e.sourceIds,pageSize:t,pageToken:r,certificationStatuses:u?[Ux.CERTIFIED]:[]}).then(e=>{s.cancelled||p(t=>({hits:a?[...t.hits,...e.hits]:e.hits,next:e.nextPageToken,total:Number(e.total),modeUsed:e.modeUsed,loading:!1}))}).catch(e=>{s.cancelled||p(t=>({...t,loading:!1,error:aP(e)}))});(0,dR.useEffect)(()=>{let e={cancelled:!1};p(e=>({...e,loading:!0,error:void 0}));let t=setTimeout(()=>void h(``,!1,e),i?200:0);return()=>{e.cancelled=!0,clearTimeout(t)}},[n,i,o,c,m,t,u]);let g=c===Vx.SEMANTIC&&f.modeUsed===Vx.KEYWORD&&!f.loading;return(0,uR.jsxs)(`div`,{className:[`sf-search`,e.className].filter(Boolean).join(` `),"data-fixed":e.height!==void 0||void 0,style:e.height===void 0?void 0:{height:e.height},children:[(0,uR.jsxs)(`div`,{className:`sf-search-controls`,role:`search`,children:[(0,uR.jsx)(`input`,{className:`sf-input sf-search-input`,type:`search`,placeholder:`Search tables and columns, e.g. customer revenue`,"aria-label":`Search data`,value:i,onChange:e=>a(e.target.value)}),(0,uR.jsx)(`select`,{className:`sf-input`,"aria-label":`Show`,value:o,onChange:e=>s(e.target.value),children:fR.map(e=>(0,uR.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,uR.jsx)(`select`,{className:`sf-input`,"aria-label":`Match`,value:c,onChange:e=>l(Number(e.target.value)),children:pR.map(e=>(0,uR.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,uR.jsxs)(`label`,{className:`sf-search-check`,children:[(0,uR.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),(0,uR.jsx)(`span`,{children:`Certified only`})]})]}),(0,uR.jsx)(`p`,{className:`sf-search-status`,"aria-live":`polite`,id:`${r}-status`,children:f.error?``:f.loading?`Searching…`:`${f.total} ${f.total===1?`result`:`results`}${g?` · search by meaning is not available here, so these are word matches`:``}`}),f.error&&(0,uR.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:f.error}),(0,uR.jsx)(`ul`,{className:`sf-search-results`,"aria-labelledby":`${r}-status`,"aria-busy":f.loading,tabIndex:e.height===void 0?void 0:0,children:f.hits.map(t=>{let n=t.object;return(0,uR.jsxs)(`li`,{className:`sf-search-hit`,children:[(0,uR.jsxs)(`button`,{type:`button`,className:`sf-search-open`,onClick:()=>e.onOpen?.(n),children:[(0,uR.jsxs)(`span`,{className:`sf-search-title`,children:[(0,uR.jsx)(`span`,{className:`sf-search-name`,children:n.name}),(0,uR.jsx)(FF,{certification:n.certification}),(0,uR.jsx)(`span`,{className:`sf-schema-tag`,children:LF(n)}),n.ref?.kind===Bx.TABLE&&VF[n.format]&&(0,uR.jsx)(`span`,{className:`sf-schema-tag`,children:VF[n.format]}),n.nativeType&&(0,uR.jsx)(`span`,{className:`sf-schema-meta`,children:n.nativeType.toLowerCase()}),n.rowCount!==void 0&&(0,uR.jsxs)(`span`,{className:`sf-schema-meta`,children:[UF.format(Number(n.rowCount)),` rows`]})]}),n.description&&(0,uR.jsx)(`span`,{className:`sf-search-description`,children:n.description}),t.reasons.length>0&&(0,uR.jsx)(`span`,{className:`sf-search-reasons`,children:t.reasons.join(` · `)})]}),i&&(0,uR.jsx)(`span`,{className:`sf-search-score`,"aria-hidden":`true`,style:{inlineSize:`${Math.round(t.score*100)}%`}}),e.renderActions&&(0,uR.jsx)(`span`,{className:`sf-search-actions`,children:e.renderActions(n)})]},`${n.ref?.sourceId}/${n.name}`)})}),!f.loading&&!f.error&&f.hits.length===0&&(0,uR.jsxs)(`p`,{className:`sf-search-empty`,children:[`Nothing matches`,i?` “${i}”`:``,`. Try fewer or different words.`]}),f.next&&(0,uR.jsx)(`button`,{type:`button`,className:`sf-button sf-search-more`,onClick:()=>void h(f.next,!0,{cancelled:!1}),children:`Show more`})]})}var uR,dR,fR,pR,mR=n((()=>{uR=WA(),vS(),dR=NM(),cP(),GF(),fR=[{id:`all`,label:`Everything`,kinds:[]},{id:`tables`,label:`Tables`,kinds:[Bx.TABLE]},{id:`columns`,label:`Columns`,kinds:[Bx.COLUMN]}],pR=[{id:Vx.UNSPECIFIED,label:`Best match`},{id:Vx.KEYWORD,label:`Exact words`},{id:Vx.SEMANTIC,label:`By meaning`}]}));function hR({column:e,rowCount:t}){let n=t&&e.nullCount!==void 0?1-Number(e.nullCount)/t:void 0,r=e.topValues.slice(0,3),i=Math.max(1,...r.map(e=>Number(e.count)));return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`td`,{className:`sf-object-fill`,children:n===void 0?(0,B.jsx)(`span`,{className:`sf-object-muted`,children:`–`}):(0,B.jsxs)(`span`,{className:`sf-meter`,role:`img`,"aria-label":`${Math.round(n*100)}% filled`,children:[(0,B.jsx)(`span`,{style:{inlineSize:`${Math.round(n*100)}%`}}),(0,B.jsxs)(`em`,{children:[Math.round(n*100),`%`]})]})}),(0,B.jsx)(`td`,{className:`sf-object-number`,children:e.distinctCount===void 0?`–`:(0,B.jsxs)(`span`,{title:e.distinctCountEstimated?`An estimate`:void 0,children:[e.distinctCountEstimated?`~`:``,WF.format(Number(e.distinctCount))]})}),(0,B.jsx)(`td`,{className:`sf-object-values`,children:e.sampleValuesWithheld?(0,B.jsx)(`span`,{className:`sf-object-muted`,children:`Withheld`}):r.length>0?(0,B.jsx)(`span`,{className:`sf-top-values`,children:r.map(e=>(0,B.jsxs)(`span`,{className:`sf-top-value`,title:`${e.value}: ${WF.format(Number(e.count))}`,children:[(0,B.jsx)(`span`,{style:{inlineSize:`${Math.round(Number(e.count)/i*100)}%`}}),(0,B.jsx)(`em`,{children:e.value})]},e.value))}):e.min!==void 0&&e.min!==``?(0,B.jsxs)(`span`,{children:[e.min,` → `,e.max]}):(0,B.jsx)(`span`,{className:`sf-object-muted`,children:`–`})})]})}function gR(e){let t=MF(e.discovery),n=JSON.stringify(e.objectRef),[r,i]=(0,_R.useState)(),[a,o]=(0,_R.useState)([]),[s,c]=(0,_R.useState)(),[l,u]=(0,_R.useState)(),[d,f]=(0,_R.useState)(!1),[p,m]=(0,_R.useState)();if((0,_R.useEffect)(()=>{let n=!0;return i(void 0),o([]),c(void 0),u(void 0),m(void 0),t.getObject({ref:e.objectRef}).then(e=>{n&&i(t=>t??e.profile)}).catch(e=>n&&c(aP(e))),t.getObject({ref:e.objectRef,includeProfile:!0}).then(e=>n&&i(e.profile)).catch(()=>{}),t.getRelated({ref:e.objectRef}).then(e=>n&&o(e.relations)).catch(()=>{}),()=>{n=!1}},[t,n]),s)return(0,B.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:s});if(!r?.object)return(0,B.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`});let h=r.object,g=r.rowCount===void 0?void 0:Number(r.rowCount),_=async()=>{f(!0);try{let n=await t.describe({ref:e.objectRef});u({text:n.description,proposed:n.description,by:n.generatedBy})}catch(e){c(aP(e))}finally{f(!1)}},v=async()=>{if(l){f(!0);try{let n=l.text.trim()!==l.proposed.trim()||l.by===``,a=await t.saveDescription({ref:e.objectRef,description:l.text,origin:n?Hx.HUMAN:Hx.GENERATED});a.object&&i({...r,object:a.object}),u(void 0)}catch(e){c(aP(e))}finally{f(!1)}}},y=async(n,a)=>{f(!0);try{let o=await t.setCertification({ref:e.objectRef,status:n,setBy:e.certifier??``,note:a});o.object&&i({...r,object:o.object}),m(void 0)}catch(e){c(aP(e))}finally{f(!1)}},b=h.certification?.status?h.certification:void 0;return(0,B.jsxs)(`article`,{className:[`sf-object`,e.className].filter(Boolean).join(` `),children:[(0,B.jsxs)(`header`,{className:`sf-object-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h3`,{className:`sf-object-title`,children:[h.name,` `,(0,B.jsx)(FF,{certification:h.certification})]}),(0,B.jsx)(`p`,{className:`sf-object-facts`,children:[h.ref?.sourceId,VF[h.format],g===void 0?void 0:`${WF.format(g)} rows`,`${r.columns.length} columns`].filter(Boolean).join(` · `)})]}),e.renderActions&&(0,B.jsx)(`div`,{className:`sf-object-actions`,children:e.renderActions(h)})]}),(b||e.certifier)&&(0,B.jsxs)(`section`,{className:`sf-object-certification`,"aria-label":`Certification`,children:[b&&(0,B.jsx)(`p`,{children:PF(b)}),e.certifier&&(p?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`label`,{className:`sf-object-label`,htmlFor:`sf-object-cert-note`,children:p.status===Ux.DEPRECATED?`What should people use instead?`:`Why is it certified? (optional)`}),(0,B.jsx)(`input`,{id:`sf-object-cert-note`,className:`sf-input`,value:p.note,onChange:e=>m({...p,note:e.target.value})}),(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:d,onClick:()=>void y(p.status,p.note),children:[p.status===Ux.DEPRECATED?`Mark as deprecated`:`Certify`,` as `,e.certifier]}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>m(void 0),children:`Cancel`})]})]}):(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[b?.status!==Ux.CERTIFIED&&(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>m({status:Ux.CERTIFIED,note:``}),children:`Certify…`}),b?.status!==Ux.DEPRECATED&&(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>m({status:Ux.DEPRECATED,note:``}),children:`Deprecate…`}),b&&(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:d,onClick:()=>void y(Ux.UNSPECIFIED,``),children:`Remove mark`})]}))]}),(0,B.jsx)(`section`,{className:`sf-object-description`,"aria-label":`Description`,children:l?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`label`,{className:`sf-object-label`,htmlFor:`sf-object-draft`,children:l.by===`placeholder`?`Proposed description (a summary of the facts; no language model is connected)`:l.by?`Proposed description, generated by ${l.by}`:`Description`}),(0,B.jsx)(`textarea`,{id:`sf-object-draft`,className:`sf-input sf-object-draft`,rows:3,value:l.text,onChange:e=>u({...l,text:e.target.value})}),(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:d||l.text.trim()===``,onClick:()=>void v(),children:`Save description`}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>u(void 0),children:`Discard`})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:h.description?void 0:`sf-object-muted`,children:h.description||`No description yet.`}),(0,B.jsxs)(`div`,{className:`sf-object-buttons`,children:[h.description&&HF[h.descriptionOrigin]&&(0,B.jsx)(`span`,{className:`sf-schema-tag`,children:HF[h.descriptionOrigin]}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:d,onClick:()=>void _(),children:`Suggest a description`}),(0,B.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>u({text:h.description,proposed:h.description,by:``}),children:h.description?`Edit`:`Write one`})]})]})}),(0,B.jsxs)(`section`,{"aria-label":`Columns`,children:[!r.sampleValuesAllowed&&(0,B.jsx)(`p`,{className:`sf-object-policy`,children:`Data values are withheld for this source, so ranges and common values are not shown.`}),(0,B.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Column statistics`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Column`}),(0,B.jsx)(`th`,{scope:`col`,children:`Type`}),(0,B.jsx)(`th`,{scope:`col`,children:`Filled`}),(0,B.jsx)(`th`,{scope:`col`,className:`sf-object-number`,children:`Distinct`}),(0,B.jsx)(`th`,{scope:`col`,children:`Values`})]})}),(0,B.jsx)(`tbody`,{children:r.columns.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`th`,{scope:`row`,children:[e.name,e.description&&(0,B.jsx)(`span`,{className:`sf-object-column-note`,children:e.description})]}),(0,B.jsx)(`td`,{className:`sf-object-type`,children:e.nativeType.toLowerCase()}),(0,B.jsx)(hR,{column:e,rowCount:g})]},e.name))})]})})]}),a.length>0&&(0,B.jsxs)(`section`,{"aria-label":`Related tables`,children:[(0,B.jsx)(`h4`,{className:`sf-object-label`,children:`Related`}),(0,B.jsx)(`ul`,{className:`sf-object-related`,children:a.map((t,n)=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,className:`sf-object-relation`,onClick:()=>t.object&&e.onOpen?.(t.object),children:[(0,B.jsx)(`span`,{className:`sf-object-muted`,children:vR[t.kind]??`Related to`}),` `,(0,B.jsx)(`strong`,{children:t.object?.name}),` `,(0,B.jsx)(FF,{certification:t.object?.certification}),(0,B.jsxs)(`span`,{className:`sf-object-muted`,children:[` · `,t.reason]}),t.inferred?(0,B.jsx)(`span`,{className:`sf-schema-tag`,children:`Inferred`}):t.kind===Wx.JOIN&&(0,B.jsx)(`span`,{className:`sf-schema-tag`,children:`Declared`})]})},`${t.kind}-${t.object?.name}-${n}`))})]}),e.showSampleRows&&r.sampleValuesAllowed&&h.ref&&(0,B.jsxs)(`section`,{"aria-label":`Sample rows`,children:[(0,B.jsx)(`h4`,{className:`sf-object-label`,children:`Rows`}),(0,B.jsx)(CP,{sourceId:h.ref.sourceId,sql:`SELECT * FROM ${h.ref.table}`,height:260,label:`Rows of ${h.name}`})]})]})}var B,_R,vR,yR=n((()=>{B=WA(),vS(),_R=NM(),cP(),PP(),GF(),vR={[Wx.JOIN]:`Joins with`,[Wx.SIMILAR]:`Similar to`,[Wx.UPSTREAM]:`Built from`,[Wx.DOWNSTREAM]:`Feeds`,[Wx.USED_BY_QUERY]:`Used by`}}));function bR(e,t,n){return e.items.some(e=>e.sourceId===t&&e.table.toLowerCase()===n.toLowerCase())?e:{...e,items:[...e.items,{sourceId:t,table:n,columns:[],note:``,includeSampleRows:!1}]}}function xR(e){return{id:e.id??``,name:e.name,notes:e.notes,items:e.items.map(e=>({ref:IF(e.sourceId,e.table),columns:e.columns,note:e.note,includeSampleRows:e.includeSampleRows})),joins:e.joins.map(e=>({left:IF(e.sourceId,e.left),right:IF(e.sourceId,e.right),keys:e.keys}))}}function SR(e){let{value:t,onChange:n,tokenBudget:r=4e3}=e,i=MF(e.discovery),a=(0,wR.useId)(),[o,s]=(0,wR.useState)(Gx.MARKDOWN),[c,l]=(0,wR.useState)(),[u,d]=(0,wR.useState)({}),[f,p]=(0,wR.useState)([]),[m,h]=(0,wR.useState)(),[g,_]=(0,wR.useState)(!1),v=JSON.stringify(t),y=t.items.map(e=>`${e.sourceId}/${e.table}`).join(`,`);(0,wR.useEffect)(()=>{let e=!0,n=setTimeout(()=>{i.renderContextPack({target:{case:`pack`,value:xR(t)},format:o}).then(t=>{e&&l({text:t.text,tokens:t.tokenEstimate,hasValues:t.containsSampleValues,missing:t.missing.map(e=>e.table)})}).catch(t=>e&&h({message:aP(t),error:!0}))},250);return()=>{e=!1,clearTimeout(n)}},[i,v,o]),(0,wR.useEffect)(()=>{let e=!0;for(let n of t.items){let t=`${n.sourceId}/${n.table}`;u[t]||i.getObject({ref:IF(n.sourceId,n.table)}).then(n=>e&&d(e=>({...e,[t]:n.profile?.columns.map(e=>e.name)??[]}))).catch(()=>{})}return Promise.all(t.items.map(e=>i.getRelated({ref:IF(e.sourceId,e.table),kinds:[Wx.JOIN]}).then(n=>n.relations.filter(n=>t.items.some(t=>t.sourceId===e.sourceId&&t.table===n.object?.ref?.table)).map(t=>({sourceId:e.sourceId,left:e.table,right:t.object.ref.table,keys:t.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn}))}))).catch(()=>[]))).then(t=>{if(!e)return;let n=[];for(let e of t.flat())n.some(t=>ER(t,e))||n.push(e);p(n)}),()=>{e=!1}},[i,y]);let b=(e,r)=>n({...t,items:t.items.map((t,n)=>n===e?{...t,...r}:t)}),x=(e,r)=>{let i=[...t.items],[a]=i.splice(e,1);i.splice(e+r,0,a),n({...t,items:i})},S=e=>{let r=t.items[e];n({...t,items:t.items.filter((t,n)=>n!==e),joins:t.joins.filter(e=>e.sourceId!==r.sourceId||e.left!==r.table&&e.right!==r.table)})},C=e=>{e.preventDefault(),_(!1);try{let r=JSON.parse(e.dataTransfer.getData(AF));r.sourceId&&r.table&&n(bR(t,r.sourceId,r.table))}catch{}},w=async()=>{try{let r=(await i.saveContextPack({pack:xR(t)})).pack;n({...t,id:r.id}),h({message:`Saved version ${r.version}.`}),e.onSaved?.(r.id)}catch(e){h({message:aP(e),error:!0})}},T=async()=>{try{await navigator.clipboard.writeText(c?.text??``),h({message:`Copied.`})}catch{h({message:`Copying is not allowed here. Select the preview text instead.`,error:!0})}},E=f.filter(e=>!t.joins.some(t=>ER(t,e))),D=c?Math.min(1,c.tokens/r):0,O=c!==void 0&&c.tokens>r;return(0,CR.jsxs)(`div`,{className:[`sf-context`,e.className].filter(Boolean).join(` `),"data-drag":g||void 0,onDragOver:e=>{e.dataTransfer.types.includes(`application/x-surfaces-ref+json`)&&(e.preventDefault(),_(!0))},onDragLeave:()=>_(!1),onDrop:C,children:[(0,CR.jsxs)(`label`,{className:`sf-context-field`,children:[(0,CR.jsx)(`span`,{children:`Name`}),(0,CR.jsx)(`input`,{className:`sf-input`,value:t.name,placeholder:`e.g. Order analysis`,onChange:e=>n({...t,name:e.target.value})})]}),(0,CR.jsxs)(`label`,{className:`sf-context-field`,children:[(0,CR.jsx)(`span`,{children:`Notes for the agent`}),(0,CR.jsx)(`textarea`,{className:`sf-input sf-context-notes`,rows:2,value:t.notes,placeholder:`Rules, units, things to avoid`,onChange:e=>n({...t,notes:e.target.value})})]}),(0,CR.jsx)(`ul`,{className:`sf-context-items`,"aria-label":`Tables in this context`,children:t.items.map((e,n)=>{let r=u[`${e.sourceId}/${e.table}`]??[],i=e.columns.length===0?r:e.columns;return(0,CR.jsxs)(`li`,{className:`sf-context-item`,children:[(0,CR.jsxs)(`div`,{className:`sf-context-item-head`,children:[(0,CR.jsx)(`strong`,{children:e.table}),(0,CR.jsx)(`span`,{className:`sf-object-muted`,children:e.columns.length===0?`all columns`:`${e.columns.length} of ${r.length} columns`}),(0,CR.jsxs)(`span`,{className:`sf-context-item-buttons`,children:[(0,CR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Move ${e.table} up`,disabled:n===0,onClick:()=>x(n,-1),children:(0,CR.jsx)(dI,{icon:`up`})}),(0,CR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Move ${e.table} down`,disabled:n===t.items.length-1,onClick:()=>x(n,1),children:(0,CR.jsx)(dI,{icon:`down`})}),(0,CR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Remove ${e.table}`,onClick:()=>S(n),children:(0,CR.jsx)(dI,{icon:`close`})})]})]}),(0,CR.jsx)(`input`,{className:`sf-input`,"aria-label":`Note about ${e.table}`,placeholder:`Note about this table`,value:e.note,onChange:e=>b(n,{note:e.target.value})}),(0,CR.jsxs)(`details`,{className:`sf-context-columns`,children:[(0,CR.jsx)(`summary`,{children:`Choose columns`}),(0,CR.jsx)(`div`,{className:`sf-context-checks`,children:r.map(e=>(0,CR.jsxs)(`label`,{children:[(0,CR.jsx)(`input`,{type:`checkbox`,checked:i.includes(e),onChange:t=>{let a=t.target.checked?[...i,e]:i.filter(t=>t!==e);b(n,{columns:a.length===r.length?[]:r.filter(e=>a.includes(e))})}}),e]},e))}),(0,CR.jsxs)(`label`,{className:`sf-context-sample`,children:[(0,CR.jsx)(`input`,{type:`checkbox`,checked:e.includeSampleRows,onChange:e=>b(n,{includeSampleRows:e.target.checked})}),`Include sample rows (only if this source allows data values)`]})]})]},`${e.sourceId}/${e.table}`)})}),t.items.length===0&&(0,CR.jsx)(`p`,{className:`sf-context-empty`,children:`Add tables from search or the schema tree, or drag them here.`}),(t.joins.length>0||E.length>0)&&(0,CR.jsxs)(`div`,{className:`sf-context-joins`,children:[(0,CR.jsx)(`span`,{className:`sf-object-label`,children:`Joins`}),(0,CR.jsxs)(`ul`,{children:[t.joins.map(e=>(0,CR.jsxs)(`li`,{children:[(0,CR.jsxs)(`span`,{children:[e.left,` ⋈ `,e.right,` on `,e.keys.map(e=>e.leftColumn).join(`, `)]}),(0,CR.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Remove join ${e.left} and ${e.right}`,onClick:()=>n({...t,joins:t.joins.filter(t=>!ER(t,e))}),children:(0,CR.jsx)(dI,{icon:`close`})})]},`${e.left}-${e.right}`)),E.map(e=>(0,CR.jsxs)(`li`,{"data-suggested":!0,children:[(0,CR.jsxs)(`span`,{children:[e.left,` ⋈ `,e.right,` on `,e.keys.map(e=>e.leftColumn).join(`, `),` `,(0,CR.jsx)(`span`,{className:`sf-schema-tag`,children:`Inferred`})]}),(0,CR.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>n({...t,joins:[...t.joins,e]}),children:`Add join`})]},`s-${e.left}-${e.right}`))]})]}),(0,CR.jsxs)(`div`,{className:`sf-context-preview-head`,children:[(0,CR.jsx)(`span`,{id:`${a}-preview`,className:`sf-object-label`,children:`What the agent receives`}),(0,CR.jsxs)(`select`,{className:`sf-input`,"aria-label":`Format`,value:o,onChange:e=>s(Number(e.target.value)),children:[(0,CR.jsx)(`option`,{value:Gx.MARKDOWN,children:`Markdown`}),(0,CR.jsx)(`option`,{value:Gx.JSON,children:`JSON`})]})]}),(0,CR.jsxs)(`div`,{className:`sf-context-budget`,"data-over":O||void 0,children:[(0,CR.jsx)(`span`,{className:`sf-meter`,role:`img`,"aria-label":`${c?.tokens??0} of ${r} tokens`,children:(0,CR.jsx)(`span`,{style:{inlineSize:`${Math.round(D*100)}%`}})}),(0,CR.jsxs)(`span`,{children:[`About `,WF.format(c?.tokens??0),` of `,WF.format(r),` tokens`,O?` — over budget`:``]})]}),c?.hasValues&&(0,CR.jsx)(`p`,{className:`sf-context-warning`,role:`status`,children:`This context includes actual data values (sample rows).`}),c&&c.missing.length>0&&(0,CR.jsxs)(`p`,{className:`sf-context-warning`,role:`status`,children:[`Not found and left out: `,c.missing.join(`, `),`.`]}),(0,CR.jsx)(`pre`,{className:`sf-context-preview`,tabIndex:0,"aria-labelledby":`${a}-preview`,children:c?.text??``}),(0,CR.jsxs)(`div`,{className:`sf-context-actions`,children:[(0,CR.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:t.name.trim()===``||t.items.length===0,onClick:()=>void w(),children:t.id?`Save new version`:`Save context`}),(0,CR.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:!c,onClick:()=>void T(),children:`Copy`}),m&&(0,CR.jsx)(`span`,{className:m.error?`sf-filter-problem`:`sf-object-muted`,role:`status`,children:m.message})]})]})}var CR,wR,TR,ER,DR=n((()=>{CR=WA(),vS(),wR=NM(),cP(),jF(),GF(),vI(),TR={name:``,notes:``,items:[],joins:[]},ER=(e,t)=>e.sourceId===t.sourceId&&(e.left===t.left&&e.right===t.right||e.left===t.right&&e.right===t.left)}));function OR(e){let{limit:t=8}=e,n=MF(e.discovery),r=JSON.stringify(e.objectRef),[i,a]=(0,AR.useState)();(0,AR.useEffect)(()=>{let r=!0;return a(void 0),n.getRelated({ref:e.objectRef}).then(e=>{if(!r)return;let n=new Map;for(let t of e.relations){let e=t.object?.name??``;n.has(e)&&t.kind!==Wx.JOIN||n.set(e,t)}a([...n.values()].slice(0,t))}).catch(()=>r&&a([])),()=>{r=!1}},[n,r,t]);let o={x:jR/2,y:MR/2},s=e.objectRef.table??``;if(i===void 0)return(0,kR.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`});if(i.length===0)return(0,kR.jsxs)(`p`,{className:`sf-object-muted`,children:[`No related tables were found for `,s,`.`]});let c=i.map((e,t)=>{let n=2*Math.PI*t/i.length-Math.PI/2;return{relation:e,x:o.x+Math.cos(n)*235,y:o.y+Math.sin(n)*105}});return(0,kR.jsxs)(`figure`,{className:[`sf-graph`,e.className].filter(Boolean).join(` `),children:[(0,kR.jsxs)(`svg`,{viewBox:`0 0 ${jR} ${MR}`,role:`group`,"aria-label":`Tables related to ${s}`,children:[c.map(({relation:e,x:t,y:n})=>{let r=e.kind===Wx.JOIN;return(0,kR.jsxs)(`g`,{children:[(0,kR.jsx)(`line`,{x1:o.x,y1:o.y,x2:t,y2:n,className:`sf-graph-edge`,"data-kind":r?`join`:`similar`}),(0,kR.jsx)(`text`,{x:(o.x+t)/2,y:(o.y+n)/2-5,className:`sf-graph-edge-label`,textAnchor:`middle`,children:r?NR(e.keys.map(e=>e.leftColumn).join(`, `),18):`similar`})]},`edge-${e.object?.name}`)}),(0,kR.jsxs)(`g`,{className:`sf-graph-node`,"data-centre":!0,children:[(0,kR.jsx)(`rect`,{x:o.x-70,y:o.y-17,width:140,height:34,rx:8}),(0,kR.jsx)(`text`,{x:o.x,y:o.y+5,textAnchor:`middle`,children:NR(s,18)})]}),c.map(({relation:t,x:n,y:r})=>(0,kR.jsxs)(`g`,{className:`sf-graph-node`,role:`button`,tabIndex:0,"aria-label":`${t.object?.name}: ${t.reason}`,onClick:()=>t.object&&e.onOpen?.(t.object),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&t.object&&(n.preventDefault(),e.onOpen?.(t.object))},children:[(0,kR.jsx)(`rect`,{x:n-66,y:r-16,width:132,height:32,rx:8}),(0,kR.jsx)(`text`,{x:n,y:r+5,textAnchor:`middle`,children:NR(t.object?.name??``,17)})]},t.object?.name))]}),(0,kR.jsxs)(`figcaption`,{className:`sf-graph-legend`,children:[(0,kR.jsx)(`span`,{"data-kind":`join`,children:`Join on shared key`}),(0,kR.jsx)(`span`,{"data-kind":`similar`,children:`Similar columns`}),(0,kR.jsx)(`span`,{children:i.every(e=>e.inferred)?`Relationships are inferred from names and types.`:i.every(e=>!e.inferred)?`Joins are the source's declared keys.`:`Joins on declared keys are facts; the rest are inferred from names and types.`})]})]})}var kR,AR,jR,MR,NR,PR=n((()=>{kR=WA(),vS(),AR=NM(),GF(),jR=640,MR=300,NR=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e}));function FR(e){let t=new Map;for(let n of e)t.set(n.source,(t.get(n.source)??0)+1),n.target!==n.source&&t.set(n.target,(t.get(n.target)??0)+1);return t}function IR(e,t){return t.flatMap(t=>t.source===e?[{id:t.target,label:t.label??``}]:t.target===e?[{id:t.source,label:t.label??``}]:[])}function LR(e,t,n,r=300){let i=new Set(e.map(e=>e.id)),a=t.filter(e=>i.has(e.source)&&i.has(e.target));if(e.length<=r)return{nodes:e,links:a,hidden:0};let o=FR(a),s=n&&i.has(n)?n:[...e].sort((e,t)=>(o.get(t.id)??0)-(o.get(e.id)??0))[0]?.id,c=new Set(s?[s]:[]);for(let e=0;e<2&&c.size<r;e++)for(let e of[...c])for(let t of IR(e,a))c.size<r&&c.add(t.id);let l=e.filter(e=>c.has(e.id));return{nodes:l,links:a.filter(e=>c.has(e.source)&&c.has(e.target)),hidden:e.length-l.length}}function RR(e,t=[]){let n=new Set(e.map(e=>e.group??``));return[...t.filter(e=>n.has(e)),...[...n].filter(e=>e!==``&&!t.includes(e))]}function zR(e){let{nodes:t,links:n,selected:r,colors:i,animate:a,text:o}=e,s=RR(t,e.groups),c=FR(n),l=Math.max(1,...t.map(e=>c.get(e.id)??0)),u=e=>i[Math.min(Math.max(0,s.indexOf(e??``)),Math.max(0,i.length-1))]??i[0],d=e=>{let t=u(e.group);return e.level===`half`?{color:t,opacity:.5}:e.level===`outline`?{color:`rgba(0, 0, 0, 0)`,borderColor:t,borderWidth:2}:{color:t}},f={...o?.color?{color:o.color}:{},...o?.fontFamily?{fontFamily:o.fontFamily}:{},fontSize:12,textBorderWidth:0,textBorderColor:`transparent`,textShadowBlur:0};return{aria:{enabled:!0},animation:a,animationDuration:700,animationEasing:`backOut`,animationDurationUpdate:600,animationEasingUpdate:`cubicOut`,tooltip:{trigger:`item`,formatter:e=>e.dataType===`edge`?e.data.label??``:`${e.data.name??``}${e.data.description?`: ${e.data.description}`:``}`},...s.length>1?{legend:[{data:s,bottom:4,icon:`circle`,itemWidth:10,itemHeight:10,itemGap:16}]}:{},series:[{id:BR,type:`graph`,layout:`force`,roam:!0,draggable:!0,top:24,bottom:s.length>1?56:24,force:{repulsion:420,edgeLength:[80,150],gravity:.1,friction:.5,layoutAnimation:a},label:{show:t.length<=80,position:`right`,distance:8,...f},labelLayout:{hideOverlap:!0},lineStyle:{...o?.muted?{color:o.muted}:{},width:1.25,opacity:.55,curveness:.12},edgeLabel:{...f,...o?.muted?{color:o.muted}:{},fontSize:11},emphasis:{focus:`adjacency`,scale:1.15,label:{show:!0,fontWeight:`bold`},lineStyle:{width:2.5,opacity:1}},blur:{itemStyle:{opacity:.25},lineStyle:{opacity:.12},label:{opacity:.35}},categories:s.map(e=>({name:e,itemStyle:{color:u(e)}})),data:t.map(e=>{let t=14+Math.round(22*(c.get(e.id)??0)/l),n=e.id===r;return{id:e.id,name:e.label,...e.description?{description:e.description}:{},...s.length>0&&e.group!==void 0?{category:s.indexOf(e.group)}:{},symbolSize:(n?t+6:t)+(e.fresh?4:0),itemStyle:{...d(e),...n?{borderColor:u(e.group),borderWidth:4}:{},...e.fresh?{shadowBlur:28,shadowColor:u(e.group)}:{}},...n||e.level===`half`?{label:{...e.level===`half`?{opacity:1}:{},...n?{show:!0,fontWeight:`bold`}:{}}}:{}}}),links:n.map(e=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.fresh?{lineStyle:{width:2.5,opacity:1,...i[0]?{color:i[0],shadowBlur:12,shadowColor:i[0]}:{}}}:{}}))}]}}var BR,VR=n((()=>{BR=`graph`}));function HR({label:e,nodes:t,links:n,selected:r,onSelect:i,groups:a,levels:o,noun:s=`node`,height:c=420,limit:l=300,onContext:u}){let d=RM(),f=d?.theme??Qj,p=d?.resolvedMode??`light`,m=(0,WR.useMemo)(()=>LR(t,n,r,l),[t,n,r,l]),h=(0,WR.useMemo)(()=>FR(m.links),[m]),g=(0,WR.useMemo)(()=>RR(m.nodes,a),[m,a]),_=(0,WR.useMemo)(()=>wM(f,p),[f,p]),v=(0,WR.useMemo)(()=>_.color??[],[_]),y=(0,WR.useMemo)(()=>{let e=_.textStyle?.color,t=_.legend?.textStyle?.color,n=_.textStyle?.fontFamily;return{...e?{color:e}:{},...t?{muted:t}:{},...n?{fontFamily:n}:{}}},[_]),b=(0,WR.useRef)(null),x=(0,WR.useRef)(void 0),S=(0,WR.useId)(),C=(0,WR.useRef)(()=>{});C.current=e=>{let t=m.nodes.find(t=>t.id===e);i?.(e),u?.({kind:`node.opened`,summary:`Opened ${t?.label??e} on the graph.`,subject:{node:e}})},(0,WR.useEffect)(()=>{let e=b.current;if(!e)return;let t;try{t=IP(e,wM(f,p))}catch{return}x.current=t,t.on(`click`,e=>{let t=e.data?.id;e.dataType===`node`&&t&&C.current(t)});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(()=>t.resize());n?.observe(e);let r=BP(e);return()=>{r(),n?.disconnect(),t.dispose(),x.current=void 0}},[f,p]),(0,WR.useEffect)(()=>{let e=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;try{x.current?.setOption(zR({nodes:m.nodes,links:m.links,...r?{selected:r}:{},...a?{groups:a}:{},colors:v,text:y,animate:!e}),{replaceMerge:[`legend`,`series`]})}catch{}},[m,r,a,v,y]);let w=m.nodes.find(e=>e.id===r),T=w?IR(w.id,m.links):[],E=e=>m.nodes.find(t=>t.id===e)?.label??e,D=(e,t)=>`${e} ${t}${e===1?``:`s`}`,O=g.length>v.length&&v.length>0;return(0,UR.jsx)(`section`,{className:`sf-nodegraph`,"aria-label":e,children:(0,UR.jsxs)(`div`,{className:`sf-nodegraph-frame`,children:[(0,UR.jsx)(`div`,{ref:b,className:`sf-nodegraph-canvas`,style:{height:c},role:`img`,"aria-label":`${e}: ${D(m.nodes.length,s)} and ${D(m.links.length,`link`)}, drawn as a graph.`,"aria-describedby":S}),(0,UR.jsxs)(`div`,{className:`sf-nodegraph-side`,style:{maxHeight:c},children:[(0,UR.jsxs)(`p`,{id:S,className:`sf-nodegraph-note`,role:`status`,children:[D(m.nodes.length,s),`, `,D(m.links.length,`link`),`, also listed here.`,m.hidden>0?` ${m.hidden} more are not drawn: open one to see what is around it.`:``,O?` There are more groups than colours, so the last ${g.length-v.length+1} share one.`:``]}),w&&(0,UR.jsxs)(`div`,{className:`sf-nodegraph-current`,children:[(0,UR.jsxs)(`p`,{children:[(0,UR.jsx)(`strong`,{children:w.label}),T.length===0?` has no links.`:` is linked to:`]}),T.length>0&&(0,UR.jsx)(`ul`,{children:T.map((e,t)=>(0,UR.jsxs)(`li`,{children:[(0,UR.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>C.current(e.id),children:E(e.id)}),e.label&&(0,UR.jsx)(`span`,{className:`sf-nodegraph-kind`,children:e.label})]},`${e.id}:${t}`))})]}),(0,UR.jsx)(`ul`,{className:`sf-nodegraph-list`,children:m.nodes.map(e=>(0,UR.jsx)(`li`,{children:(0,UR.jsxs)(`button`,{type:`button`,className:`sf-nodegraph-row`,"aria-current":e.id===r?`true`:void 0,onClick:()=>C.current(e.id),children:[(0,UR.jsx)(`span`,{className:`sf-nodegraph-name`,children:e.label}),e.level&&(0,UR.jsxs)(`span`,{className:`sf-nodegraph-level`,children:[(0,UR.jsx)(`span`,{"aria-hidden":`true`,children:GR[e.level]}),` `,o?.[e.level]??``]}),(0,UR.jsx)(`span`,{className:`sf-nodegraph-kind`,children:[e.group,D(h.get(e.id)??0,`link`)].filter(Boolean).join(`, `)})]})},e.id))})]})]})})}var UR,WR,GR,KR=n((()=>{UR=WA(),jM(),LP(),WR=NM(),GM(),VR(),VP(),GR={full:`●`,half:`◐`,outline:`○`}}));function qR(e){let t=MF(e.discovery),[n,r]=(0,YR.useState)(``),[i,a]=(0,YR.useState)(),o=(0,YR.useRef)(void 0);return(0,JR.jsxs)(`div`,{className:[`sf-ask`,e.className].filter(Boolean).join(` `),children:[(0,JR.jsxs)(`form`,{className:`sf-ask-form`,onSubmit:async r=>{r.preventDefault();let i=n.trim();if(i===``)return;o.current?.abort();let s=new AbortController;o.current=s;let c={question:i,text:``,citations:[],streaming:!0};a(c);let l=e=>{c={...c,...e},s.signal.aborted||a(c)};try{for await(let n of t.ask({question:i,contextPackId:e.contextPackId,sourceIds:e.sourceIds},{signal:s.signal})){let e=n.part;e.case===`textDelta`?l({text:c.text+e.value}):e.case===`citation`&&e.value.object?l({citations:[...c.citations,{object:e.value.object,reason:e.value.reason}]}):e.case===`done`&&l({by:e.value.generatedBy,sql:e.value.suggestedSql})}l({streaming:!1})}catch(e){l({streaming:!1,error:aP(e)})}},children:[(0,JR.jsx)(`input`,{className:`sf-input sf-ask-input`,"aria-label":`Ask a question about the data`,placeholder:`Ask about the data, e.g. which table has revenue by region?`,value:n,onChange:e=>r(e.target.value)}),(0,JR.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:n.trim()===``||i?.streaming,children:`Ask`})]}),i&&(0,JR.jsxs)(`div`,{className:`sf-ask-answer`,"aria-live":`polite`,"aria-busy":i.streaming,children:[(0,JR.jsx)(`p`,{className:`sf-ask-question`,children:i.question}),i.error?(0,JR.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:i.error}):(0,JR.jsx)(`p`,{className:`sf-ask-text`,children:i.text||(i.streaming?`Thinking…`:``)}),i.citations.length>0&&(0,JR.jsx)(`ul`,{className:`sf-ask-citations`,"aria-label":`Tables used`,children:i.citations.map(t=>(0,JR.jsxs)(`li`,{children:[(0,JR.jsx)(`button`,{type:`button`,className:`sf-button`,title:t.reason,onClick:()=>e.onOpen?.(t.object),children:t.object.name}),e.renderActions?.(t.object)]},t.object.name))}),i.sql&&(0,JR.jsxs)(`div`,{className:`sf-ask-sql`,children:[(0,JR.jsx)(VL,{code:i.sql,language:`sql`,label:`Proposed SQL`}),e.onUseSql&&(0,JR.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onUseSql?.(i.sql),children:`Use this SQL`})]}),i.by&&(0,JR.jsx)(`p`,{className:`sf-ask-by`,"data-placeholder":i.by===`placeholder`||void 0,children:i.by===`placeholder`?`Search results only — no language model is connected.`:`Answered by ${i.by}. Check it against the data.`})]})]})}var JR,YR,XR=n((()=>{JR=WA(),YR=NM(),cP(),GF(),qL()}));function ZR(e,t={}){let n=t.min??.2,r=t.max??2.5;return Number.isFinite(e)?Math.min(r,Math.max(n,e)):1}function QR(e,t){return{x:(t.x-e.x)/e.k,y:(t.y-e.y)/e.k}}function $R(e,t,n,r){let i=ZR(e.k*t,r),a=i/e.k;return{k:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a}}function ez(e,t,n,r=48){if(n.width<=0||n.height<=0)return e;let i=t.width*e.k,a=t.height*e.k,o=Math.min(r,i),s=Math.min(r,a);return{k:e.k,x:Math.min(n.width-o,Math.max(o-i,e.x)),y:Math.min(n.height-s,Math.max(s-a,e.y))}}function tz(e,t,n,r=16){if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return uz;let i={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)},a=ZR(Math.min(1,i.width/e.width,i.height/e.height),n);return{k:a,x:(t.width-e.width*a)/2,y:(t.height-e.height*a)/2}}function nz(e,t=0){let n=t===1?e*16:t===2?e*400:e;return Math.exp(-Math.max(-100,Math.min(100,n))*.0022)}function rz(e,t,n,r=16){let i=(e,t,n)=>t+r*2>n||e<r?r-e:e+t>n-r?n-r-(e+t):0,a=i(t.left,t.width,n.width),o=i(t.top,t.height,n.height);return a===0&&o===0?e:{...e,x:e.x+a,y:e.y+o}}function iz(e){try{return e.matches(`:focus-visible`)}catch{return!0}}function az(e){let t={min:e.min??.2,max:e.max??2.5},[n,r]=(0,cz.useState)(uz),[i,a]=(0,cz.useState)(!1),[o,s]=(0,cz.useState)(!1),[c,l]=(0,cz.useState)(null),[u,d]=(0,cz.useState)({width:0,height:0}),f=(0,cz.useRef)(n);f.current=n;let p=(0,cz.useRef)(e.content);p.current=e.content;let m=(0,cz.useRef)(t);m.current=t;let h=(0,cz.useRef)(u);h.current=u;let g=(0,cz.useRef)(!0),_=(0,cz.useRef)(new Map),v=(0,cz.useRef)(void 0),y=(0,cz.useRef)(void 0),b=(0,cz.useCallback)((e,t=!1)=>{let n=ez({...e,k:ZR(e.k,m.current)},p.current,h.current);a(t),f.current=n,r(n)},[]);(0,cz.useLayoutEffect)(()=>{if(!c)return;let e=()=>d(e=>e.width===c.clientWidth&&e.height===c.clientHeight?e:{width:c.clientWidth,height:c.clientHeight});if(e(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e);return t.observe(c),()=>t.disconnect()},[c]);let{width:x,height:S}=e.content;(0,cz.useLayoutEffect)(()=>{if(!g.current||u.width<=0||x<=0||S<=0)return;let e=tz({width:x,height:S},u,m.current);f.current=e,r(e),a(!1)},[x,S,u]);let C=(0,cz.useCallback)(e=>{let t=c?.getBoundingClientRect();return{x:e.clientX-(t?.left??0),y:e.clientY-(t?.top??0)}},[c]),w=()=>({x:h.current.width/2,y:h.current.height/2}),T=()=>{g.current=!1},E=(e,t=w(),n=!0)=>{T(),b($R(f.current,e,t,m.current),n)},D=(e,t,n=!1)=>{T(),b({...f.current,x:f.current.x+e,y:f.current.y+t},n)},O=()=>{g.current=!0;let e=tz(p.current,h.current,m.current);b(e,!0)},k=()=>{T(),b(uz,!0)};(0,cz.useEffect)(()=>{if(!c)return;let e=e=>{let t=C(e);if(e.ctrlKey||e.metaKey){e.preventDefault(),g.current=!1,b($R(f.current,nz(e.deltaY,e.deltaMode),t,m.current));return}let n=e.deltaMode===1?16:e.deltaMode===2?h.current.height:1,[r,i]=e.shiftKey&&e.deltaX===0?[e.deltaY*n,0]:[e.deltaX*n,e.deltaY*n],a=f.current,o=ez({...a,x:a.x-r,y:a.y-i},p.current,h.current);(o.x!==a.x||o.y!==a.y)&&(e.preventDefault(),g.current=!1,b(o))};return c.addEventListener(`wheel`,e,{passive:!1}),()=>c.removeEventListener(`wheel`,e)},[c,C,b]);let ee={tabIndex:0,"data-panning":o?``:void 0,onPointerDown(e){let t=C(e);if(T(),(e.pointerType!==`mouse`||e.button===0)&&!(e.target.closest?.(dz)&&_.current.size===0)){if(_.current.set(e.pointerId,t),e.currentTarget.setPointerCapture?.(e.pointerId),_.current.size===2){let[e,t]=[..._.current.values()];v.current=void 0,y.current={distance:Math.hypot(e.x-t.x,e.y-t.y)||1,view:f.current,mid:{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}}else _.current.size===1&&(v.current={id:e.pointerId,x:t.x,y:t.y,view:f.current},s(!0))}},onPointerMove(e){if(!_.current.has(e.pointerId))return;let t=C(e);_.current.set(e.pointerId,t);let n=y.current;if(n&&_.current.size>=2){let[e,t]=[..._.current.values()],r={x:(e.x+t.x)/2,y:(e.y+t.y)/2},i=$R(n.view,Math.hypot(e.x-t.x,e.y-t.y)/n.distance,n.mid,m.current);b({...i,x:i.x+r.x-n.mid.x,y:i.y+r.y-n.mid.y});return}let r=v.current;r&&r.id===e.pointerId&&b({...r.view,x:r.view.x+t.x-r.x,y:r.view.y+t.y-r.y})},onPointerUp(e){if(!_.current.delete(e.pointerId))return;e.currentTarget.releasePointerCapture?.(e.pointerId),y.current=void 0;let[t]=[..._.current.entries()];v.current=t?{id:t[0],x:t[1].x,y:t[1].y,view:f.current}:void 0,t||s(!1)},onPointerCancel(e){ee.onPointerUp(e)},onKeyDown(e){if(e.target!==e.currentTarget||e.altKey||e.ctrlKey||e.metaKey)return;let t={"+":()=>E(lz),"=":()=>E(lz),"-":()=>E(1/lz),_:()=>E(1/lz),0:O,ArrowLeft:()=>D(48,0,!0),ArrowRight:()=>D(-48,0,!0),ArrowUp:()=>D(0,48,!0),ArrowDown:()=>D(0,-48,!0)}[e.key];t&&(e.preventDefault(),t())},onFocus(e){if(!c||e.target===e.currentTarget||!iz(e.target))return;let t=c.getBoundingClientRect(),n=e.target.getBoundingClientRect(),r=rz(f.current,{left:n.left-t.left,top:n.top-t.top,width:n.width,height:n.height},h.current);r!==f.current&&b(r,!0),c.scrollLeft=0,c.scrollTop=0}};return{view:n,viewport:u,viewportRef:l,viewportProps:ee,planeStyle:{transform:`translate(${n.x}px, ${n.y}px) scale(${n.k})`,transformOrigin:`0 0`},animate:i,pointToWorld:e=>QR(f.current,C(e)),zoomIn:()=>E(lz),zoomOut:()=>E(1/lz),fit:O,reset:k,min:t.min,max:t.max}}function oz({panZoom:e,label:t=`Zoom`}){let n=Math.round(e.view.k*100);return(0,sz.jsxs)(`div`,{className:`sf-panzoom-controls`,role:`group`,"aria-label":t,children:[(0,sz.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Zoom out`,title:`Zoom out (−)`,"aria-keyshortcuts":`-`,disabled:e.view.k<=e.min+1e-6,onClick:e.zoomOut,children:`−`}),(0,sz.jsxs)(`output`,{className:`sf-panzoom-level`,"aria-live":`polite`,"aria-label":`Zoom ${n}%`,children:[n,`%`]}),(0,sz.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Zoom in`,title:`Zoom in (+)`,"aria-keyshortcuts":`+`,disabled:e.view.k>=e.max-1e-6,onClick:e.zoomIn,children:`+`}),(0,sz.jsx)(`button`,{type:`button`,className:`sf-button`,title:`Fit to view (0)`,"aria-keyshortcuts":`0`,onClick:e.fit,children:`Fit to view`}),(0,sz.jsx)(`button`,{type:`button`,className:`sf-button`,title:`Reset to 100%`,"aria-label":`Reset zoom to 100%`,onClick:e.reset,children:`100%`})]})}var sz,cz,lz,uz,dz,fz=n((()=>{sz=WA(),cz=NM(),lz=1.25,uz={x:0,y:0,k:1},dz=`button, a, input, select, textarea, label, [data-pan-ignore]`}));function pz(e){let t=Mz(e.left)<=Mz(e.right),[n,r]=t?[e.left,e.right]:[e.right,e.left],i=e.keys.map(e=>t?`${e.leftColumn}=${e.rightColumn}`:`${e.rightColumn}=${e.leftColumn}`).sort();return Mz(`${n}|${r}|${i.join(`&`)}`)}function mz(e){return e.keys.map(t=>`${Fz(e.left)}.${Pz(t.leftColumn)} = ${Fz(e.right)}.${Pz(t.rightColumn)}`).join(` AND `)}function hz(e,t){return t===`inner`?`Only rows that match`:t===`left`?`Every ${e.left} row`:t===`right`?`Every ${e.right} row`:`Every row of both`}function gz(e){return{...e,left:e.right,right:e.left,keys:e.keys.map(e=>({leftColumn:e.rightColumn,rightColumn:e.leftColumn})),...e.type?{type:Lz[e.type]}:{}}}function _z(e,t){return Nz(e.left,t)?e:gz(e)}function vz(e,t){let n=new Map,r=new Set,i=[];for(let a of e)for(let e of t(a)){let t=n.get(Mz(e))??0,o=t===0?e:`${e}_${t}`;for(;r.has(Mz(o));)o=`${e}_${++t}`;n.set(Mz(e),t+1),r.add(Mz(o)),i.push({table:a,column:e,name:o})}return i}function yz(e,t){let[n,...r]=e.tables;if(!n)return{sql:``,unjoined:[],order:[]};let i=[n],a=new Set(r.map(Mz)),o=[`FROM ${Fz(n)}`];for(let t=!0;t&&a.size>0;){t=!1;for(let n of e.joins){let r=i.some(e=>Nz(e,n.left));if(r===i.some(e=>Nz(e,n.right)))continue;let s=r?n.right:n.left;if(!a.has(Mz(s)))continue;let c=e.joins.filter(e=>Nz(e.left,s)&&i.some(t=>Nz(t,e.right))||Nz(e.right,s)&&i.some(t=>Nz(t,e.left))).map(mz),l=_z(n,r?n.left:n.right).type??`inner`;o.push(`${Iz[l]} ${Fz(s)} ON ${c.join(` AND `)}`),i.push(s),a.delete(Mz(s)),t=!0}}let s=e.tables.filter(e=>a.has(Mz(e))),c=t?i.map(e=>t(e)):[];if(!t||c.some(e=>!e||e.length===0))return{sql:[`SELECT *`,...o].join(`
|
|
40
|
+
`),unjoined:s,order:i};let l=vz(i,e=>c[i.indexOf(e)]??[]);return l.every(e=>e.name===e.column)?{sql:[`SELECT *`,...o].join(`
|
|
41
|
+
`),unjoined:s,order:i,columns:l}:{sql:[`SELECT ${l.map(e=>`${Fz(e.table)}.${Rz(e.column)}${e.name===e.column?``:` AS ${Rz(e.name)}`}`).join(`,
|
|
41
42
|
`)}`,...o].join(`
|
|
42
|
-
`),unjoined:s,order:i,columns:l}}function fz(e,t,n,r=()=>void 0){let i=lz(e,t),a=i.keys.map(e=>e.leftColumn),o=i.keys.map(e=>e.rightColumn),s=(n(i.right)??[]).filter(e=>e.primaryKey).map(e=>e.name);return s.length>0&&s.every(e=>o.some(t=>Tz(t,e)))||(r(i.left)??[]).some(e=>Tz(e.references?.table??``,i.right)&&e.columns.length>0&&e.columns.every(e=>a.some(t=>Tz(t,e)))&&e.referencedColumns.every(e=>o.some(t=>Tz(t,e))))?`one`:s.length>0?`many`:`unknown`}function pz(e,t){let n=new Map;e[0]&&n.set(e[0],0);for(let r=!0;r;){r=!1;for(let i of t){let t=e.find(e=>Tz(e,i.left)),a=e.find(e=>Tz(e,i.right));if(!t||!a)continue;let[o,s]=n.has(t)&&!n.has(a)?[t,a]:n.has(a)&&!n.has(t)?[a,t]:[];o&&s&&(n.set(s,n.get(o)+1),r=!0)}}let r=Math.max(0,...n.values())+1;for(let t of e)n.has(t)||n.set(t,r);return n}function mz(e,t){if(Tz(e.left,e.right))return{ok:!1,reason:`A join needs two different tables.`};if(e.keys.length===0)return{ok:!1,reason:`A join needs a column from each table.`};for(let n of e.keys){let r=[{table:e.left,name:n.leftColumn},{table:e.right,name:n.rightColumn}].map(e=>{let n=t(e.table),r=n?.find(t=>Tz(t.name,e.name));return{...e,known:n!==void 0,column:r,family:r?oC(r):`unknown`}});for(let e of r){if(e.known&&!e.column)return{ok:!1,reason:`${e.table} has no column ${e.name}.`};if(e.family===`nested`||e.family===`binary`)return{ok:!1,reason:`${e.table}.${e.name} holds ${jz[e.family]}, which cannot be matched.`}}let[i,a]=r;if(i.family!==`unknown`&&a.family!==`unknown`&&i.family!==a.family)return{ok:!1,reason:`${i.table}.${i.name} is ${jz[i.family]} and ${a.table}.${a.name} is ${jz[a.family]}, so they can never match.`}}return{ok:!0}}function hz(e,t,n){let r=new Set([wz(t)]);for(let t=!0;t;){t=!1;for(let n of e){let[e,i]=[wz(n.left),wz(n.right)];r.has(e)!==r.has(i)&&(r.add(e),r.add(i),t=!0)}}return r.has(wz(n))}function gz(e){return{x:16+e%3*300,y:16+Math.floor(e/3)*346}}function _z(e){let{sourceId:t,height:n=420,suggestJoins:r=!0,rowsFrom:i=!1}=e,a=zN(e.dataSource),o=TF(e.discovery),s=(0,vz.useId)(),c=JSON.stringify([e.tables??[],e.joins??[]]),[l,u]=(0,vz.useState)(e.tables??[]),[d,f]=(0,vz.useState)(e.joins??[]),[p,m]=(0,vz.useState)({}),[h,g]=(0,vz.useState)({}),[_,v]=(0,vz.useState)({}),[y,b]=(0,vz.useState)({}),[x,S]=(0,vz.useState)(new Set),[C,w]=(0,vz.useState)(),[T,E]=(0,vz.useState)(``),[D,O]=(0,vz.useState)([]),[k,ee]=(0,vz.useState)({left:``,leftColumn:``,right:``,rightColumn:``}),[te,A]=(0,vz.useState)(``),[ne,re]=(0,vz.useState)(``),[ie,ae]=(0,vz.useState)(0),[oe,se]=(0,vz.useState)({}),ce=(0,vz.useRef)(null),le=(0,vz.useRef)(void 0),ue=(0,vz.useRef)(new Set),de=(0,vz.useRef)(e.onChange);de.current=e.onChange;let fe=(0,vz.useRef)(c);(0,vz.useEffect)(()=>{fe.current!==c&&(fe.current=c,ue.current=new Set,u(e.tables??[]),f(e.joins??[]),m({}))},[c]);let pe=(0,vz.useMemo)(()=>({tables:l,joins:d}),[l,d]),me=(e,t=pe)=>{let n=dz(t).order,r=e=>{let r=n.findIndex(t=>Tz(t,e));return r>=0?r:n.length+t.tables.findIndex(t=>Tz(t,e))};return r(e.left)<=r(e.right)?e.left:e.right},he=(e,t)=>!i||e.type?e:{...lz(e,me(e,t)),type:`left`},ge=(0,vz.useRef)({sourceId:t,dataSource:a});ge.current={sourceId:t,dataSource:a},(0,vz.useEffect)(()=>{let e=()=>ge.current.sourceId===t&&ge.current.dataSource===a;for(let n of l){if(h[n]!==void 0||(g(e=>({...e,[n]:`loading`})),a.describeTable({sourceId:t,ref:{table:n}}).then(t=>{e()&&(g(e=>({...e,[n]:t.table?.columns??[]})),b(e=>({...e,[n]:{comment:t.table?.summary?.comment??``,foreignKeys:t.table?.foreignKeys??[]}})))}).catch(t=>e()&&g(e=>({...e,[n]:{error:rP(t)}}))),!o))continue;let r={sourceId:t,kind:Bx.TABLE,table:n};o.getObject({ref:r}).then(t=>{let r=t.profile?.object?.certification;e()&&r&&v(e=>({...e,[n]:r}))}).catch(()=>{})}},[l,a,o,t,ie]),(0,vz.useEffect)(()=>{if(!o||!r)return;let e=!0;for(let n of l)o.getRelated({ref:{sourceId:t,kind:Bx.TABLE,table:n},kinds:[Wx.JOIN]}).then(t=>{if(!e)return;let r=[];for(let e of t.relations){let t=e.object?.ref?.table;if(!t||!l.some(e=>Tz(e,t))||e.keys.length===0)continue;let i={left:n,right:t,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),inferred:e.inferred};ue.current.has(az(i))||(ue.current.add(az(i)),r.push(i))}r.length>0&&f(e=>[...e,...r.filter(t=>!e.some(e=>az(e)===az(t))).map(t=>he(t,{tables:l,joins:e}))])}).catch(()=>{});return()=>{e=!1}},[l,o,t,r]),(0,vz.useEffect)(()=>{let e=[];for(let t of l)for(let n of y[t]?.foreignKeys??[]){let r=l.find(e=>Tz(e,n.references?.table??``));if(!r||n.columns.length===0)continue;let i={left:t,right:r,keys:n.columns.map((e,t)=>({leftColumn:e,rightColumn:n.referencedColumns[t]??e})),declared:!0};ue.current.has(az(i))||(ue.current.add(az(i)),e.push(i))}e.length!==0&&f(t=>{let n=t.map(t=>e.find(e=>az(e)===az(t))?{...t,inferred:!1,declared:!0}:t);return[...n,...e.filter(e=>!t.some(t=>az(t)===az(e))).map(e=>he(e,{tables:l,joins:n}))]})},[l,y]),(0,vz.useEffect)(()=>{let e=T.trim();if(!e)return O([]);let n=!0,r=setTimeout(()=>{a.listTables({sourceId:t,search:e,pageSize:8}).then(e=>n&&O(e.tables.map(e=>e.ref?.table??``).filter(e=>e&&!l.some(t=>Tz(t,e))))).catch(e=>{n&&(O([]),re(`Could not search for tables: ${rP(e)}`))})},180);return()=>{n=!1,clearTimeout(r)}},[T,a,t,l]);let j=e=>p[e]??je?.[e]??gz(l.findIndex(t=>t===e)),_e=e=>Array.isArray(h[e])?h[e]:[],ve=e=>x.has(e)?_e(e):_e(e).slice(0,Cz),ye=e=>{let t=_e(e).length,n=ve(e).length;return xz+Math.max(1,n+ +(t>Cz))*Sz+6},be=(e,t)=>{e&&!l.some(t=>Tz(t,e))&&(t&&m(n=>({...n,[e]:t})),u(t=>[...t,e]),A(`Added ${e}.`),E(``))},xe=e=>{u(t=>t.filter(t=>t!==e)),f(t=>t.filter(t=>!Tz(t.left,e)&&!Tz(t.right,e))),A(`Removed ${e}.`)},Se=e=>Array.isArray(h[e])?h[e]:void 0,M=e=>mz(e,Se),Ce=e=>{re(`Not joined. ${e}`),A(``)},we=(e,t)=>{f(n=>n.flatMap(n=>{if(az(n)!==az(e))return[n];let r=n.keys.filter(e=>!(Tz(e.leftColumn,t.leftColumn)&&Tz(e.rightColumn,t.rightColumn)));return r.length>0?[{...n,keys:r}]:[]})),re(``),A(`Removed ${oz({...e,keys:[t]})}.`)},Te=e=>{let t=M(e);if(!t.ok)return Ce(t.reason);let n=!d.some(t=>az(t)===az(e))&&hz(d.filter(Ae).filter(t=>az({...t,keys:[]})!==az({...e,keys:[]})),e.left,e.right);re(``),ue.current.add(az(e)),f(t=>{let n=t.findIndex(t=>az(t)===az(e));return n>=0?t.map((e,t)=>t===n?{...e,inferred:!1}:e):[...t,he(e,{tables:l,joins:t})]}),A(`Joined ${oz(e)}.${n?` ${e.left} and ${e.right} were already connected another way, so rows must now match on both routes.`:``}`)},Ee=(e,t,n)=>{f(r=>r.map(r=>az(r)===az(e)?{...t,type:n}:r)),A(`${oz(t)} now keeps ${sz(t,n).toLowerCase()}.`)},De=e=>{let t=[e,...l.filter(t=>!Tz(t,e))];f(e=>e.map(n=>lz(n,me(n,{tables:l,joins:e})).type===`left`?{...lz(n,me(n,{tables:t,joins:e})),type:`left`}:n)),u(t),A(`The rows now come from ${e}: one row of the result is one ${e} row.`)},Oe=(e,t)=>`${az(e)}>${wz(t)}`,ke=(e,n)=>{let r=lz(e,n),i=Oe(e,r.right);se(e=>({...e,[i]:`checking`})),lC(a,{sourceId:t,sql:`SELECT * FROM ${Dz(r.right)}`,columns:r.keys.map(e=>e.rightColumn)}).then(e=>{se(t=>({...t,[i]:e})),A(e>1?`Up to ${e} ${r.right} rows share one ${r.keys.map(e=>e.rightColumn).join(` and `)}, so this join can repeat ${r.left} rows.`:`Each ${r.left} row finds at most one ${r.right} row.`)}).catch(e=>se(t=>({...t,[i]:{error:rP(e)}})))},Ae=e=>l.some(t=>Tz(t,e.left))&&l.some(t=>Tz(t,e.right)),je=i?(()=>{let e=pz(l,d),t=new Map,n={};for(let r of l){let i=e.get(r)??0,a=t.get(i)??16;n[r]={x:16+i*360,y:a},t.set(i,a+ye(r)+24)}return n})():void 0,Me={width:l.length===0?0:Math.max(...l.map(e=>j(e).x+bz))+16,height:l.length===0?0:Math.max(...l.map(e=>j(e).y+ye(e)))+16},Ne=ZR({content:Me}),Pe=Ne.viewportRef,Fe=(0,vz.useCallback)(e=>{ce.current=e,Pe(e)},[Pe]),Ie=e=>Ne.pointToWorld(e),Le=e=>t=>{if(t.target.closest(`button`))return;let n=Ie(t),r=j(e);le.current={table:e,dx:n.x-r.x,dy:n.y-r.y},t.currentTarget.setPointerCapture?.(t.pointerId)},Re=(e,t)=>n=>{n.stopPropagation(),w({table:e,column:t,to:Ie(n)}),ce.current?.setPointerCapture?.(n.pointerId)},ze=e=>{let t=Ie(e),n=le.current;n?m(e=>({...e,[n.table]:{x:Math.max(0,t.x-n.dx),y:Math.max(0,t.y-n.dy)}})):C&&w({...C,to:t})},Be=e=>{if(le.current=void 0,!C)return;ce.current?.releasePointerCapture?.(e.pointerId);let t=document.elementFromPoint?.(e.clientX,e.clientY)?.closest(`[data-model-column]`),n=t?.dataset.modelTable,r=t?.dataset.modelColumn;n&&r?Te({left:C.table,right:n,keys:[{leftColumn:C.column,rightColumn:r}]}):A(`Drop the column on a column of another table to join them.`),w(void 0)},Ve=e=>{let t=e.dataTransfer.getData(SF);if(t){e.preventDefault();try{let n=JSON.parse(t),r=Ie(e);be(n.table,{x:Math.max(0,r.x-bz/2),y:Math.max(0,r.y-xz/2)})}catch{}}},He=(e,t,n)=>{let r=j(e),i=ve(e).findIndex(e=>Tz(e.name,t)),a=i>=0?i:ve(e).length,o=j(n).x+bz/2>=r.x+bz/2;return{x:r.x+(o?bz:0),y:r.y+xz+a*Sz+Sz/2}},Ue=(e,t)=>{let n=Math.max(40,Math.abs(t.x-e.x)/2),r=t.x>=e.x?1:-1;return`M ${e.x} ${e.y} C ${e.x+n*r} ${e.y}, ${t.x-n*r} ${t.y}, ${t.x} ${t.y}`},We=Math.max(Me.width+16,320),Ge=Math.max(Me.height+16,120),Ke=d.filter(Ae),qe=new Map(Ke.flatMap(e=>{let t=M(e);return t.ok?[]:[[az(e),t.reason]]})),Je=l.filter(e=>typeof h[e]==`object`&&!Array.isArray(h[e])),Ye=dz({tables:l.filter(e=>!Je.includes(e)),joins:Ke.filter(e=>!qe.has(az(e))&&!(i&&e.inferred))},e=>Array.isArray(h[e])?h[e].map(e=>e.name):void 0),Xe=(0,vz.useRef)({model:pe,sql:Ye.sql});(0,vz.useEffect)(()=>{(Xe.current.model!==pe||Xe.current.sql!==Ye.sql)&&(Xe.current={model:pe,sql:Ye.sql},de.current?.(pe,Ye))});let Ze=new Map((Ye.columns??[]).map(e=>[wz(`${e.table}.${e.column}`),e.name])),Qe=e.usedColumns?new Set(e.usedColumns.map(wz)):void 0,$e=l[0]??``,et=e=>{let t=i?me(e):e.left,n=lz(e,t),r=n.right,a=oe[Oe(e,r)],o=typeof a==`number`?a>1?`many`:`one`:a===`checking`?`checking`:fz(e,t,Se,e=>y[e]?.foreignKeys),s=o===`one`?`One ${r} row for each ${t} row${typeof a==`number`?`, checked by the engine`:``}.`:o===`many`?typeof a==`number`?`Can repeat ${t} rows: up to ${a} ${r} rows share one ${n.keys.map(e=>e.rightColumn).join(` and `)}.`:`Can repeat ${t} rows: ${r} has a key this join does not use, so more than one row may match.`:o===`checking`?`Counting ${r} rows per key…`:`Not known whether ${r} has more than one row per ${t} row.`,c=n.type??`inner`;return{near:t,far:r,read:n,shape:o,shapeText:s,kind:c,kindNote:c===`inner`?`${t} rows with no ${r} row are dropped.`:c===`right`||c===`full`?`Adds ${r} rows that match no ${t} row${i?`, so not every row is a ${$e} row`:``}.`:``,error:typeof a==`object`?a.error:``,chip:o===`one`?`1 per row`:o===`many`?`▲ can repeat`:o===`checking`?`Counting…`:`? not known`}},tt=(e,t,n,r=!1)=>(0,V.jsx)(`select`,{className:n,tabIndex:r?-1:void 0,value:t.type??`inner`,"aria-label":`Rows kept by ${oz(t)}${r?`, on the diagram`:``}`,onPointerDown:e=>e.stopPropagation(),onChange:n=>Ee(e,t,n.target.value),children:yz.map(e=>(0,V.jsx)(`option`,{value:e,children:sz(t,e)},e))}),nt=k.left&&k.leftColumn?oC(_e(k.left).find(e=>e.name===k.leftColumn)??{nativeType:``,arrowType:``}):`unknown`,rt=(e,t)=>_e(e).filter(e=>{let n=oC(e);return n!==`nested`&&n!==`binary`&&(t===`unknown`||n===`unknown`||n===t)}).map(e=>e.name),it=(e,t)=>{let n=y[e]?.foreignKeys.find(e=>e.columns.some(e=>Tz(e,t)));if(!n)return;let r=n.columns.findIndex(e=>Tz(e,t));return`${n.references?.table}.${n.referencedColumns[r]??t}`},at=new Set(d.flatMap(e=>e.keys.flatMap(t=>[wz(`${e.left}.${t.leftColumn}`),wz(`${e.right}.${t.rightColumn}`)]))),ot=(e,t,n,r)=>(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:e}),(0,V.jsxs)(`select`,{className:`sf-input`,value:t,onChange:e=>r(e.target.value),children:[(0,V.jsx)(`option`,{value:``,children:`Choose…`}),n.map(e=>(0,V.jsx)(`option`,{children:e},e))]})]});return(0,V.jsxs)(`div`,{className:[`sf-model`,e.className].filter(Boolean).join(` `),children:[(0,V.jsxs)(`div`,{className:`sf-model-bar`,children:[(0,V.jsx)(`input`,{className:`sf-input`,type:`search`,placeholder:`Add a table`,"aria-label":`Add a table`,"aria-controls":`${s}-matches`,value:T,onChange:e=>E(e.target.value)}),(0,V.jsx)(`span`,{id:`${s}-matches`,className:`sf-model-matches`,children:D.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`sf-button`,onClick:()=>be(e),children:[`Add `,e]},e))}),e.onUseSql&&(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:Ye.sql===``,onClick:()=>e.onUseSql?.(Ye.sql,pe),children:`Use as query`})]}),l.length>0&&(0,V.jsx)(QR,{panZoom:Ne,label:`Zoom the data model`}),(0,V.jsxs)(`div`,{ref:Fe,className:`sf-model-canvas sf-panzoom`,style:{height:n},role:`group`,"aria-label":e.label??`Data model`,"aria-describedby":`${s}-keys`,"data-linking":C?``:void 0,...Ne.viewportProps,onPointerMove:e=>{ze(e),Ne.viewportProps.onPointerMove(e)},onPointerUp:e=>{Be(e),Ne.viewportProps.onPointerUp(e)},onPointerCancel:e=>{Be(e),Ne.viewportProps.onPointerCancel(e)},onDragOver:e=>e.dataTransfer.types.includes(`application/x-surfaces-ref+json`)&&e.preventDefault(),onDrop:Ve,children:[(0,V.jsx)(`span`,{id:`${s}-keys`,className:`sf-a2-visually-hidden`,children:`Drag the background or scroll to move around. Plus and minus zoom, 0 fits the diagram to view, arrow keys move it.`}),(0,V.jsxs)(`div`,{className:`sf-model-plane sf-panzoom-plane`,style:{width:We,height:Ge,...Ne.planeStyle},"data-animate":Ne.animate||void 0,children:[(0,V.jsxs)(`svg`,{className:`sf-model-lines`,width:We,height:Ge,"aria-hidden":`true`,children:[d.filter(Ae).flatMap(e=>e.keys.map(t=>(0,V.jsx)(`path`,{d:Ue(He(e.left,t.leftColumn,e.right),He(e.right,t.rightColumn,e.left)),"data-inferred":e.inferred||void 0,"data-broken":qe.has(az(e))||void 0,"data-fanout":i&&et(e).shape===`many`||void 0},`${az(e)}:${t.leftColumn}:${t.rightColumn}`))),C&&(0,V.jsx)(`path`,{d:Ue(He(C.table,C.column,C.table),C.to),"data-drawing":``})]}),l.map(e=>{let t=j(e),n=h[e],r=_e(e),a=i&&e===$e,o=Ye.order.some(t=>Tz(t,e)),s=Qe?r.filter(t=>Qe.has(wz(Ze.get(wz(`${e}.${t.name}`))??t.name))).length:0;return(0,V.jsxs)(`section`,{className:`sf-model-card`,"data-pan-ignore":``,"data-base":a||void 0,"data-outside":i&&!o||void 0,style:{left:t.x,top:t.y,width:bz},"aria-label":`Table ${e}${a?`, where the rows come from`:``}`,children:[(0,V.jsxs)(`header`,{className:`sf-model-head`,style:{height:xz},onPointerDown:Le(e),children:[(0,V.jsxs)(`span`,{className:`sf-model-name`,title:y[e]?.comment||void 0,children:[e,y[e]?.comment&&(0,V.jsxs)(`span`,{className:`sf-a2-visually-hidden`,children:[`. `,y[e].comment]})]}),a&&(0,V.jsx)(`span`,{className:`sf-schema-tag`,title:`One row of the result is one row of this table`,children:`Rows`}),Qe&&Array.isArray(n)&&(0,V.jsxs)(`span`,{className:`sf-model-used`,title:`${s} of ${r.length} columns are used by a field`,children:[s,`/`,r.length,(0,V.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:` columns used`})]}),(0,V.jsx)(DF,{certification:_[e]}),(0,V.jsx)(`button`,{type:`button`,className:`sf-model-remove`,"aria-label":`Remove ${e} from the diagram`,onClick:()=>xe(e),children:(0,V.jsx)(rI,{icon:`close`})})]}),n===void 0||n===`loading`?(0,V.jsx)(`p`,{className:`sf-model-note`,style:{height:Sz},children:`Loading…`}):Array.isArray(n)?(0,V.jsxs)(`ul`,{className:`sf-model-columns`,children:[ve(e).map(t=>{let n=it(e,t.name),r=[t.primaryKey&&`primary key`,n&&`refers to ${n}`,t.partitionKey&&`partition key`,!t.nullable&&!t.primaryKey&&`never empty`].filter(Boolean),a=Ze.get(wz(`${e}.${t.name}`)),o=i&&a!==void 0&&a!==t.name;return(0,V.jsxs)(`li`,{style:{height:Sz},"data-model-table":e,"data-model-column":t.name,"data-key":at.has(wz(`${e}.${t.name}`))||void 0,"data-unused":Qe&&!Qe.has(wz(a??t.name))||void 0,title:[`${t.name} ${t.nativeType.toLowerCase()}${r.length?` · ${r.join(` · `)}`:``}`,t.comment,`Drag onto a column of another table to join`].filter(Boolean).join(`
|
|
43
|
-
`),onPointerDown:Re(e,t.name),children:[(0,V.jsxs)(`span`,{className:`sf-model-keys`,"aria-hidden":`true`,children:[t.primaryKey&&(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`pk`,children:`PK`}),n&&(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`fk`,children:`FK`})]}),(0,V.jsx)(`span`,{className:`sf-model-column`,children:t.name}),(0,V.jsx)(`span`,{className:`sf-model-type`,children:o?(0,V.jsxs)(`span`,{className:`sf-model-as`,children:[`as `,a]}):t.nativeType.toLowerCase()}),o&&(0,V.jsxs)(`span`,{className:`sf-a2-visually-hidden`,children:[`, named `,a,` in the result because an earlier table has a column of this name`]}),(r.length>0||t.comment)&&(0,V.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:[...r,t.comment].filter(Boolean).join(`. `)})]},t.name)}),r.length>Cz&&(0,V.jsx)(`li`,{style:{height:Sz},children:(0,V.jsx)(`button`,{type:`button`,className:`sf-model-more`,onClick:()=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:x.has(e)?`Show fewer`:`${r.length-Cz} more columns`})})]}):(0,V.jsxs)(`p`,{className:`sf-model-note`,role:`alert`,children:[`Could not read this table: `,n.error,` `,(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{g(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),ae(e=>e+1)},children:`Try again`})]})]},e)}),Ke.flatMap(e=>e.keys.map(t=>{let n=He(e.left,t.leftColumn,e.right),r=He(e.right,t.rightColumn,e.left);return(0,V.jsx)(`button`,{type:`button`,className:`sf-model-cut`,style:{left:(n.x+r.x)/2,top:(n.y+r.y)/2},"aria-label":`Remove the line ${oz({...e,keys:[t]})}`,title:`Remove this join`,onPointerDown:e=>e.stopPropagation(),onClick:()=>we(e,t),children:(0,V.jsx)(rI,{icon:`close`})},`cut:${az(e)}:${t.leftColumn}:${t.rightColumn}`)})),Ke.map(e=>{let t=e.keys[0];if(!t||qe.has(az(e)))return null;let n=He(e.left,t.leftColumn,e.right),r=He(e.right,t.rightColumn,e.left),a=et(e);return(0,V.jsxs)(`div`,{className:`sf-model-joinbox`,"data-pan-ignore":``,"data-shape":i?a.shape:void 0,style:{left:(n.x+r.x)/2,top:(n.y+r.y)/2},onPointerDown:e=>e.stopPropagation(),children:[tt(e,a.read,`sf-model-kind`,!0),i&&(0,V.jsx)(`span`,{className:`sf-model-shape`,title:`${a.shapeText} ${a.kindNote}`.trim(),children:a.chip})]},`box:${az(e)}`)}),l.length===0&&(0,V.jsx)(`p`,{className:`sf-model-empty`,children:`Add a table above, or drag one here from the browser.`})]})]}),l.length>0&&(0,V.jsxs)(`p`,{className:`sf-model-legend`,children:[(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`pk`,children:`PK`}),` primary key `,(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`fk`,children:`FK`}),` refers to another table. Point at a column for its description.`]}),(0,V.jsx)(`p`,{className:`sf-model-status`,"aria-live":`polite`,children:te}),ne&&(0,V.jsxs)(`p`,{className:`sf-model-problem`,role:`alert`,children:[ne,` `,(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>re(``),children:`Dismiss`})]}),(0,V.jsxs)(`section`,{className:`sf-model-joins`,"aria-label":`Joins`,children:[i&&l.length>1&&(0,V.jsxs)(`label`,{className:`sf-model-base`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`Rows come from`}),(0,V.jsx)(`select`,{className:`sf-input`,"aria-label":`Rows come from`,value:$e,onChange:e=>De(e.target.value),children:l.map(e=>(0,V.jsx)(`option`,{children:e},e))}),(0,V.jsxs)(`span`,{className:`sf-object-muted`,children:[`One row of the result is one `,$e,` row; the other tables add detail to it.`]})]}),(0,V.jsx)(`h4`,{className:`sf-object-label`,children:`Joins`}),d.filter(Ae).length===0?(0,V.jsx)(`p`,{className:`sf-object-muted`,children:`None yet. Drag a column onto a column of another table, or add one below.`}):(0,V.jsx)(`ul`,{children:d.filter(Ae).map(e=>{let t=et(e);return(0,V.jsxs)(`li`,{"data-shape":i?t.shape:void 0,children:[(0,V.jsx)(`code`,{children:oz(t.read)}),e.inferred&&(0,V.jsx)(`span`,{className:`sf-schema-tag`,children:`Inferred`}),e.declared&&!e.inferred&&(0,V.jsx)(`span`,{className:`sf-schema-tag`,children:`Declared`}),tt(e,t.read,`sf-input sf-model-kind-field`),i&&!qe.has(az(e))&&(0,V.jsxs)(`span`,{className:`sf-model-effect`,children:[t.shape===`many`&&(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`▲ `}),t.shapeText,` `,t.kindNote,e.inferred&&` Not in the query until confirmed.`,t.error&&(0,V.jsxs)(`span`,{role:`alert`,children:[` The engine could not count: `,t.error]})]}),i&&!qe.has(az(e))&&t.shape!==`checking`&&(t.shape===`unknown`||t.shape===`many`||t.error)&&(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>ke(e,t.near),children:`Check with the engine`}),qe.has(az(e))&&(0,V.jsxs)(`span`,{className:`sf-model-broken`,children:[`▲ Will not work, left out of the SQL. `,qe.get(az(e))]}),e.inferred&&!qe.has(az(e))&&(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>Te(e),children:`Confirm`}),(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Remove join ${oz(e)}`,onClick:()=>{f(t=>t.filter(t=>az(t)!==az(e))),re(``),A(`Removed the join.`)},children:`Remove`})]},az(e))})}),l.length>1&&(0,V.jsxs)(`form`,{className:`sf-model-add`,onSubmit:e=>{if(e.preventDefault(),!k.left||!k.leftColumn||!k.right||!k.rightColumn)return A(`Choose two tables and a column in each.`);Te({left:k.left,right:k.right,keys:[{leftColumn:k.leftColumn,rightColumn:k.rightColumn}]}),ee({left:``,leftColumn:``,right:``,rightColumn:``})},children:[ot(`Table`,k.left,l,e=>ee({...k,left:e,leftColumn:``})),ot(`Column`,k.leftColumn,rt(k.left,`unknown`),e=>ee({...k,leftColumn:e,rightColumn:``})),ot(`Joins table`,k.right,l.filter(e=>e!==k.left),e=>ee({...k,right:e,rightColumn:``})),ot(`On column`,k.rightColumn,rt(k.right,nt),e=>ee({...k,rightColumn:e})),(0,V.jsx)(`button`,{type:`submit`,className:`sf-button`,children:`Add join`})]})]}),Ye.sql&&(0,V.jsxs)(`details`,{className:`sf-result-sql`,children:[(0,V.jsx)(`summary`,{children:`SQL for this model`}),(0,V.jsx)(NL,{code:Ye.sql,language:`sql`,label:`SQL for this model`}),Ye.unjoined.length>0&&(0,V.jsxs)(`p`,{className:`sf-result-notice`,children:[`Not joined to the rest, so left out: `,Ye.unjoined.join(`, `),`.`]}),Je.length>0&&(0,V.jsxs)(`p`,{className:`sf-result-notice`,children:[`Could not be read, so left out: `,Je.join(`, `),`.`]}),qe.size>0&&(0,V.jsxs)(`p`,{className:`sf-result-notice`,children:[qe.size===1?`One join`:`${qe.size} joins`,` cannot work and `,qe.size===1?`is`:`are`,` left out. See the list above.`]})]})]})}var V,vz,yz,bz,xz,Sz,Cz,wz,Tz,Ez,Dz,Oz,kz,Az,jz,Mz=n((()=>{V=HA(),rw(),vS(),vz=jM(),UN(),oP(),LF(),iz(),CF(),uI(),zL(),yz=[`inner`,`left`,`right`,`full`],bz=240,xz=34,Sz=24,Cz=10,wz=e=>e.toLowerCase(),Tz=(e,t)=>wz(e)===wz(t),Ez=e=>/^[A-Za-z_]\w*$/.test(e)?e:`"${e.replace(/"/g,`""`)}"`,Dz=e=>/^[A-Za-z_]\w*(\.[A-Za-z_]\w*){1,2}$/.test(e)?e:Ez(e),Oz={inner:`JOIN`,left:`LEFT OUTER JOIN`,right:`RIGHT OUTER JOIN`,full:`FULL OUTER JOIN`},kz={inner:`inner`,left:`right`,right:`left`,full:`full`},Az=e=>`"${e.replace(/"/g,`""`)}"`,jz={number:`a number`,text:`text`,time:`a date or time`,boolean:`true or false`,binary:`binary data`,nested:`nested data`,unknown:`of an unknown type`}}));function Nz(e){return e.ambientCredentials?`The server's own cloud credentials`:e.credentialsSecret?`Secret ${e.credentialsSecret}`:`None (public)`}function Pz(e){let t=zN(e.dataSource),[n,r]=(0,Iz.useState)(),[i,a]=(0,Iz.useState)(),[o,s]=(0,Iz.useState)({});(0,Iz.useEffect)(()=>{let e=!0;return t.listSources({}).then(t=>e&&r(t.sources)).catch(t=>e&&a(rP(t))),()=>{e=!1}},[t]);let c=e=>{t.testSource&&(s(t=>({...t,[e]:`running`})),t.testSource({target:{case:`id`,value:e}}).then(t=>s(n=>({...n,[e]:t}))).catch(t=>s(n=>({...n,[e]:{error:rP(t)}}))))};return i?(0,Fz.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:i}):n?n.length===0?(0,Fz.jsx)(`p`,{className:`sf-object-muted`,children:`No sources are configured.`}):(0,Fz.jsx)(`ul`,{className:[`sf-sources`,e.className].filter(Boolean).join(` `),children:n.map(n=>{let r=o[n.id],i=r&&r!==`running`&&!(`error`in r)?r:void 0;return(0,Fz.jsxs)(`li`,{className:`sf-source`,children:[(0,Fz.jsxs)(`header`,{className:`sf-source-head`,children:[(0,Fz.jsxs)(`div`,{children:[(0,Fz.jsx)(`h3`,{className:`sf-object-title`,children:n.displayName||n.id}),(0,Fz.jsx)(`p`,{className:`sf-object-facts`,children:[n.id,Lz[n.engine],n.readOnly?`Read only`:void 0,n.capabilities?.timeTravel?`Time travel`:void 0,n.capabilities?.storedResults?`Keeps results`:void 0].filter(Boolean).join(` · `)})]}),(0,Fz.jsxs)(`div`,{className:`sf-object-buttons`,children:[e.onSelect&&(0,Fz.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onSelect?.(n),children:`Open`}),t.testSource&&(0,Fz.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:r===`running`,onClick:()=>c(n.id),children:r===`running`?`Testing…`:`Test connection`})]})]}),n.connections.length>0&&(0,Fz.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Connections of ${n.displayName||n.id}`,children:(0,Fz.jsxs)(`table`,{children:[(0,Fz.jsxs)(`caption`,{className:`sf-a2-visually-hidden`,children:[`Connections of `,n.displayName||n.id]}),(0,Fz.jsx)(`thead`,{children:(0,Fz.jsxs)(`tr`,{children:[(0,Fz.jsx)(`th`,{scope:`col`,children:`Connection`}),(0,Fz.jsx)(`th`,{scope:`col`,children:`Type`}),(0,Fz.jsx)(`th`,{scope:`col`,children:`Covers`}),(0,Fz.jsx)(`th`,{scope:`col`,children:`Signs in with`})]})}),(0,Fz.jsx)(`tbody`,{children:n.connections.map(e=>(0,Fz.jsxs)(`tr`,{children:[(0,Fz.jsx)(`th`,{scope:`row`,children:e.name}),(0,Fz.jsx)(`td`,{children:Rz[e.kind]??`Other`}),(0,Fz.jsx)(`td`,{className:`sf-object-type`,children:e.scope}),(0,Fz.jsx)(`td`,{children:Nz(e)})]},e.name))})]})}),(0,Fz.jsxs)(`div`,{"aria-live":`polite`,children:[r&&r!==`running`&&`error`in r&&(0,Fz.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:r.error}),i&&(0,Fz.jsxs)(Fz.Fragment,{children:[(0,Fz.jsxs)(`p`,{className:`sf-source-result`,"data-ok":i.ok||void 0,children:[(0,Fz.jsx)(`span`,{"aria-hidden":`true`,children:i.ok?`✓`:`!`}),` `,i.message,i.engineVersion?` · ${Lz[n.engine]??`Engine`} ${i.engineVersion}`:``,` · `,Number(i.elapsedMs),` ms`]}),i.checks.length>0&&(0,Fz.jsx)(`ul`,{className:`sf-source-checks`,children:i.checks.map(e=>(0,Fz.jsxs)(`li`,{"data-ok":e.ok||void 0,children:[(0,Fz.jsx)(`span`,{"aria-hidden":`true`,children:e.ok?`✓`:`!`}),(0,Fz.jsx)(`strong`,{children:e.name}),(0,Fz.jsx)(`span`,{children:e.ok?`Reachable`:e.message})]},e.name))})]})]})]},n.id)})}):(0,Fz.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`})}var Fz,Iz,Lz,Rz,zz=n((()=>{Fz=HA(),vS(),Iz=jM(),UN(),oP(),Lz={[Nx.DUCKDB]:`DuckDB`,[Nx.DATAFUSION]:`DataFusion`,[Nx.TERADATA]:`Teradata`,[Nx.POSTGRES]:`Postgres`,[Nx.MYSQL]:`MySQL`,[Nx.SQLSERVER]:`SQL Server`,[Nx.SNOWFLAKE]:`Snowflake`,[Nx.BIGQUERY]:`BigQuery`,[Nx.DATABRICKS]:`Databricks`,[Nx.ORACLE]:`Oracle`},Rz={[Mx.S3]:`Amazon S3`,[Mx.GCS]:`Google Cloud Storage`,[Mx.AZURE]:`Azure Storage`,[Mx.HTTP]:`Web (https)`,[Mx.ICEBERG_REST]:`Iceberg REST catalog`,[Mx.DATABASE_FILE]:`Database file`,[Mx.POSTGRES]:`Postgres database`}})),Bz=n((()=>{HA(),jM()}));function Vz(e,t=`number`,n=`USD`){return jA(t===`currency`?Math.abs(e)>=1e5?{style:`currency`,currency:n,notation:`compact`,maximumFractionDigits:1}:Math.abs(e)>=1e3?{style:`currency`,currency:n,minimumFractionDigits:0,maximumFractionDigits:0}:{style:`currency`,currency:n,maximumFractionDigits:2}:t===`percent`?{style:`percent`,maximumFractionDigits:1}:t===`compact`?{notation:`compact`,maximumFractionDigits:1}:{maximumFractionDigits:2}).format(e)}function Hz(e){let{sourceId:t,sql:n,column:r,aggregate:i,percentile:a,label:o,format:s,currency:c,filters:l,timeTravel:u,notBefore:d}=e,f=zN(e.dataSource),[p,m]=(0,Wz.useState)({loading:!0}),h=JSON.stringify([t,n,r,i,a,l,u,d],(e,t)=>typeof t==`bigint`?`${t}n`:t);return(0,Wz.useEffect)(()=>{let e=new AbortController;return m(e=>({...e,loading:!0,error:void 0})),JS(f.execute({sourceId:t,timeTravel:u,notBefore:d,query:{baseSql:n,filters:l,aggregates:[{function:gF[i],column:r??``,alias:`value`,percentile:i===`percentile`?a??.9:0}]}},{signal:e.signal})).then(t=>{if(e.signal.aborted)return;let n=t.table.schema.fields.find(e=>e.name===`value`),r=t.table.getChild(`value`)?.get(0);m({value:n?ZN(r,n.type):null,loading:!1,notes:cP(t.header.notices)})}).catch(t=>{e.signal.aborted||m({error:rP(t),loading:!1})}),()=>e.abort()},[f,h]),(0,Uz.jsxs)(`div`,{className:[`sf-a2-stat sf-metric`,e.className].filter(Boolean).join(` `),"aria-busy":p.loading,children:[(0,Uz.jsx)(`span`,{className:`sf-a2-stat-label`,children:o}),p.error?(0,Uz.jsx)(`span`,{className:`sf-metric-error`,role:`alert`,"data-error":p.error,children:e.errorMessage??p.error}):(0,Uz.jsx)(`span`,{className:`sf-a2-stat-value`,children:p.value===void 0?z(`metric.loading`):p.value===null?e.emptyMessage??z(`metric.none`):Vz(p.value,s,c)}),(0,Uz.jsx)(lP,{notes:p.notes})]})}var Uz,Wz,Gz=n((()=>{Uz=HA(),rw(),Wz=jM(),vF(),UN(),fP(),tP(),BA(),oP()}));function Kz(e){let{sourceId:t,sql:n,label:r,renderRow:i,filters:a,sorts:o,rowKey:s,layout:c=`list`,timeTravel:l,notBefore:u}=e,d=zN(e.dataSource),f=Math.max(1,Math.min(100,Math.trunc(e.pageSize??20))),[p,m]=(0,Jz.useState)({rows:[],more:!1,loading:!0}),[h,g]=(0,Jz.useState)(1),_=JSON.stringify([t,n,a,o,f,l,u],(e,t)=>typeof t==`bigint`?`${t}n`:t),v=(0,Jz.useRef)(_),y=v.current===_?h:1;(0,Jz.useEffect)(()=>{v.current!==_&&(v.current=_,g(1))},[_]),(0,Jz.useEffect)(()=>{let e=new AbortController,r=y===1;m(e=>({rows:r?[]:e.rows,more:!1,loading:!0}));let i=(y-1)*f,s=Math.min(f,200-i)+1;return JS(d.execute({sourceId:t,timeTravel:l,notBefore:u,query:{baseSql:n,filters:a,sorts:o,page:{limit:s,offset:BigInt(i)}}},{signal:e.signal})).then(t=>{if(e.signal.aborted)return;let n=t.table.schema.fields,i=n.map((e,n)=>t.table.getChildAt(n)),a=Array.from({length:t.table.numRows},(e,t)=>Object.fromEntries(n.map((e,n)=>[e.name,$N(i[n].get(t),e.type)])));m(e=>({rows:[...r?[]:e.rows,...a.slice(0,s-1)],more:a.length>=s,loading:!1,notes:cP(t.header.notices)}))}).catch(t=>{e.signal.aborted||m(e=>({rows:r?[]:e.rows,more:!1,loading:!1,error:rP(t)}))}),()=>e.abort()},[d,_,y]);let{rows:b}=p,x=b.length>=200;return(0,qz.jsxs)(`div`,{className:[`sf-rowlist`,e.className].filter(Boolean).join(` `),"aria-busy":p.loading,children:[b.length>0&&(0,qz.jsx)(`ul`,{className:`sf-rowlist-rows`,"data-layout":c,"aria-label":r,children:b.map((e,t)=>(0,qz.jsx)(`li`,{children:i(e,t)},s&&e[s]!=null?`${String(e[s])}:${t}`:t))}),p.error?(0,qz.jsx)(`p`,{className:`sf-rowlist-note`,role:`alert`,"data-error":p.error,children:e.errorMessage??p.error}):(0,qz.jsx)(`p`,{className:`sf-rowlist-note`,role:`status`,children:p.loading?z(`rows.loading`):b.length===0?e.emptyMessage??z(`rows.empty`):x&&p.more?z(`rows.full`,{count:jA().format(b.length)}):p.more?z(`rows.some`,{count:jA().format(b.length)}):``}),(0,qz.jsx)(lP,{notes:p.notes}),p.more&&!x&&!p.loading&&(0,qz.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{g(y+1),e.onContext?.({kind:`rows.more`,summary:`Asked for more of ${r}, past the first ${b.length}.`,subject:{label:r,shown:b.length}})},children:z(`rows.more`)})]})}var qz,Jz,Yz=n((()=>{qz=HA(),rw(),Jz=jM(),UN(),fP(),tP(),oP(),BA()}));function Xz(e,t){let n=new Set(e.map(e=>e.id)),r=new Map(e.map(e=>[e.id,[]]));for(let e of t)n.has(e.from)&&n.has(e.to)&&r.get(e.to).push(e.from);let i=new Map,a=(e,t)=>{let n=i.get(e);if(n!==void 0)return n;if(t.has(e))return 0;t.add(e);let o=Math.max(-1,...r.get(e).map(e=>a(e,t)))+1;return t.delete(e),i.set(e,o),o};for(let t of e)a(t.id,new Set);let o=new Map,s={};for(let t of e){let e=i.get(t.id),n=o.get(e)??0;o.set(e,n+1),s[t.id]={x:16+e*272,y:16+n*84,column:e}}let c=Math.max(0,...i.values())+1,l=Math.max(1,...o.values());return{positions:s,width:32+c*lB+(c-1)*dB,height:32+l*uB+(l-1)*fB}}function Zz(e,t){let n=new Set([e]),r=(e,r)=>{let i=[e];for(;i.length>0;){let e=i.pop();for(let a of t){let[t,o]=r(a);t===e&&!n.has(o)&&(n.add(o),i.push(o))}}};return r(e,e=>[e.from,e.to]),r(e,e=>[e.to,e.from]),n}function Qz(e){let{nodes:t,edges:n,selected:r,height:i=360}=e,a=(0,oB.useMemo)(()=>Xz(t,n),[t,n]),o=(0,oB.useMemo)(()=>r?Zz(r,n):void 0,[r,n]),s=(0,oB.useId)(),c=ZR({content:{width:a.width,height:a.height}}),l=c.viewport.width>0?qR(a,{width:c.viewport.width,height:i}).k:1,u=Math.min(i,Math.max(Math.ceil(a.height*l)+32,Math.min(i,160))),d=(0,oB.useMemo)(()=>[...t].sort((e,t)=>a.positions[e.id].x-a.positions[t.id].x||a.positions[e.id].y-a.positions[t.id].y),[t,a]),f=(e,t)=>{let n=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;n!==0&&(e.preventDefault(),(e.currentTarget.parentElement?.querySelectorAll(`button.sf-pipeline-node`))?.[Math.max(0,Math.min(d.length-1,t+n))]?.focus())};return t.length===0?(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`This pipeline has no datasets.`}):(0,H.jsxs)(`div`,{className:[`sf-pipeline-graph`,e.className].filter(Boolean).join(` `),children:[(0,H.jsx)(QR,{panZoom:c,label:`Zoom the ${(e.label??`pipeline`).toLowerCase()}`}),(0,H.jsxs)(`div`,{ref:c.viewportRef,className:`sf-pipeline sf-panzoom`,style:{height:u},role:`group`,"aria-label":e.label??`Pipeline`,"aria-describedby":`${s}-keys`,...c.viewportProps,children:[(0,H.jsx)(`span`,{id:`${s}-keys`,className:`sf-a2-visually-hidden`,children:`Drag the background or scroll to move around. Plus and minus zoom, 0 fits the pipeline to view, arrow keys move it.`}),(0,H.jsxs)(`div`,{className:`sf-pipeline-plane sf-panzoom-plane`,style:{width:a.width,height:a.height,...c.planeStyle},"data-animate":c.animate||void 0,children:[(0,H.jsx)(`svg`,{width:a.width,height:a.height,"aria-hidden":`true`,children:n.map(e=>{let t=a.positions[e.from],n=a.positions[e.to];if(!t||!n)return null;let[r,i,s,c]=[t.x+lB,t.y+uB/2,n.x,n.y+uB/2],l=Math.max(24,(s-r)/2),u=!o||o.has(e.from)&&o.has(e.to);return(0,H.jsx)(`path`,{d:`M ${r} ${i} C ${r+l} ${i}, ${s-l} ${c}, ${s} ${c}`,"data-mode":e.mode??`batch`,"data-dim":u?void 0:``},`${e.from}>${e.to}`)})}),d.map((i,s)=>{let c=a.positions[i.id],l=i.status??`idle`,u=n.filter(e=>e.from===i.id).map(e=>t.find(t=>t.id===e.to)?.name).filter(Boolean);return(0,H.jsxs)(`button`,{type:`button`,className:`sf-pipeline-node`,style:{left:c.x,top:c.y,width:lB,height:uB},"data-status":l,"data-kind":i.kind,"data-dim":o&&!o.has(i.id)?``:void 0,"aria-pressed":r===i.id,onClick:()=>e.onSelect?.(i),onKeyDown:e=>f(e,s),children:[(0,H.jsxs)(`span`,{className:`sf-pipeline-name`,children:[(0,H.jsx)(`span`,{className:`sf-pipeline-mark`,"aria-hidden":`true`,children:cB[l]}),i.name,` `,(0,H.jsx)(`span`,{className:`sf-visually-hidden`,children:`(${sB[i.kind]}, ${l}${u.length>0?`, feeds ${u.join(`, `)}`:``})`})]}),(0,H.jsxs)(`span`,{className:`sf-pipeline-meta`,"aria-hidden":`true`,children:[sB[i.kind],i.layer?` · ${i.layer}`:``]}),(0,H.jsxs)(`span`,{className:`sf-pipeline-meta`,"aria-hidden":`true`,children:[i.rowsWritten===void 0?l:`${pB.format(i.rowsWritten)} rows`,i.expectationsFailed?` · ${pB.format(i.expectationsFailed)} records broke rules`:``,i.checksFailed?` · ${i.checksFailed} ${i.checksFailed===1?`check`:`checks`} failed`:``,i.checksWarned?` · ${i.checksWarned} ${i.checksWarned===1?`warning`:`warnings`}`:``]})]},i.id)})]})]})]})}function $z(e){if(!(e>=0))return`–`;let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n} min ${t%60} s`:`${Math.floor(n/60)} h ${n%60} min`}function eB({runs:e,selected:t,onSelect:n,className:r}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`This pipeline has not run yet.`});let i=[...e].sort((e,t)=>t.startTime.localeCompare(e.startTime)),a=Math.max(1,...i.map(e=>e.endTime?Date.parse(e.endTime)-Date.parse(e.startTime):0));return(0,H.jsx)(`div`,{className:[`sf-object-table sf-runs`,r].filter(Boolean).join(` `),tabIndex:0,role:`region`,"aria-label":`Runs`,children:(0,H.jsxs)(`table`,{children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,children:`Run`}),(0,H.jsx)(`th`,{scope:`col`,children:`Result`}),(0,H.jsx)(`th`,{scope:`col`,children:`Started`}),(0,H.jsx)(`th`,{scope:`col`,children:`Took`}),(0,H.jsx)(`th`,{scope:`col`,children:`Kind`}),(0,H.jsx)(`th`,{scope:`col`,children:`Started by`})]})}),(0,H.jsx)(`tbody`,{children:i.map(e=>{let r=e.endTime?Date.parse(e.endTime)-Date.parse(e.startTime):NaN;return(0,H.jsxs)(`tr`,{"data-status":e.state,"aria-selected":t===e.id,children:[(0,H.jsx)(`th`,{scope:`row`,children:n?(0,H.jsx)(`button`,{type:`button`,className:`sf-runs-open`,onClick:()=>n(e),children:e.id}):e.id}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-pipeline-mark`,"aria-hidden":`true`,children:cB[e.state]}),` `,e.state,e.errorMessage&&(0,H.jsx)(`span`,{className:`sf-object-column-note`,children:e.errorMessage})]}),(0,H.jsx)(`td`,{children:e.startTime.replace(`T`,` `).slice(0,19)}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-runs-bar`,style:{inlineSize:`${Number.isNaN(r)?0:Math.max(2,r/a*100)}%`},"aria-hidden":`true`}),Number.isNaN(r)?`In progress`:$z(r)]}),(0,H.jsxs)(`td`,{children:[mB[e.refreshKind??`default`],e.datasets&&e.datasets.length>0?` · ${e.datasets.length} ${e.datasets.length===1?`dataset`:`datasets`}`:``]}),(0,H.jsx)(`td`,{children:e.trigger??`–`})]},e.id)})})]})})}function tB({expectations:e,onOpenFailing:t,className:n}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`No data quality rules are defined.`});let r=e=>e.passedRecords+e.failedRecords===0?0:e.failedRecords/(e.passedRecords+e.failedRecords),i=[...e].sort((e,t)=>r(t)-r(e)||e.name.localeCompare(t.name));return(0,H.jsx)(`div`,{className:[`sf-object-table sf-expectations`,n].filter(Boolean).join(` `),tabIndex:0,role:`region`,"aria-label":`Data quality rules`,children:(0,H.jsxs)(`table`,{children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,children:`Rule`}),(0,H.jsx)(`th`,{scope:`col`,children:`Dataset`}),(0,H.jsx)(`th`,{scope:`col`,children:`A failing record is`}),(0,H.jsx)(`th`,{scope:`col`,className:`sf-object-number`,children:`Failed`}),(0,H.jsx)(`th`,{scope:`col`,children:`Share failing`})]})}),(0,H.jsx)(`tbody`,{children:i.map(e=>(0,H.jsxs)(`tr`,{"data-failing":e.failedRecords>0||void 0,children:[(0,H.jsxs)(`th`,{scope:`row`,children:[e.name,(0,H.jsx)(`span`,{className:`sf-object-column-note sf-object-type`,children:e.constraint})]}),(0,H.jsx)(`td`,{children:e.dataset}),(0,H.jsx)(`td`,{children:hB[e.action]}),(0,H.jsxs)(`td`,{className:`sf-object-number`,children:[gB.format(e.failedRecords),` of `,gB.format(e.passedRecords+e.failedRecords)]}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-meter`,role:`img`,"aria-label":`${(r(e)*100).toFixed(1)}% failing`,children:(0,H.jsx)(`span`,{style:{inlineSize:`${Math.min(100,r(e)*100)}%`},"data-bad":``})}),` `,(r(e)*100).toFixed(1),`%`,t&&e.failedRecords>0&&(0,H.jsx)(`button`,{type:`button`,className:`sf-button sf-expectations-open`,onClick:()=>t(e),children:`See failing rows`})]})]},`${e.dataset}.${e.name}`))})]})})}function nB({checks:e,onOpenFailing:t,className:n}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`No checks on this dataset.`});let r=e=>e.failedRecords===void 0?1:e.failedRecords>0?e.severity===`fail`?0:.5:2,i=[...e].sort((e,t)=>r(e)-r(t)||e.name.localeCompare(t.name));return(0,H.jsx)(`div`,{className:[`sf-object-table sf-checks`,n].filter(Boolean).join(` `),tabIndex:0,role:`region`,"aria-label":`Checks`,children:(0,H.jsxs)(`table`,{children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,children:`Check`}),(0,H.jsx)(`th`,{scope:`col`,children:`Result`}),(0,H.jsx)(`th`,{scope:`col`,children:`On failure`})]})}),(0,H.jsx)(`tbody`,{children:i.map(e=>{let n=(e.failedRecords??0)>0;return(0,H.jsxs)(`tr`,{"data-failing":n||void 0,children:[(0,H.jsxs)(`th`,{scope:`row`,children:[e.name,(0,H.jsxs)(`span`,{className:`sf-object-column-note sf-object-type`,children:[e.description,e.fromKey?` (from the key)`:``]})]}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-check-mark`,"data-state":e.failedRecords===void 0?`unknown`:n?e.severity:`pass`,children:e.failedRecords===void 0?`Not run yet`:n?e.severity===`fail`?`! Failed`:`! Warning`:`✓ Passed`}),e.summary&&e.summary!==`Passed.`&&(0,H.jsx)(`span`,{className:`sf-object-column-note`,children:e.summary}),t&&n&&e.canOpenFailing!==!1&&(0,H.jsx)(`button`,{type:`button`,className:`sf-button sf-expectations-open`,onClick:()=>t(e),children:`See what breaks it`})]}),(0,H.jsx)(`td`,{children:e.severity===`fail`?`Stops what reads it`:`Warns`})]},e.name)})})]})})}function rB({changes:e,rescuedCount:t,mode:n,className:r}){return(0,H.jsxs)(`div`,{className:[`sf-schema-diff`,r].filter(Boolean).join(` `),children:[(n||t!==void 0)&&(0,H.jsx)(`p`,{className:`sf-object-facts`,children:[n?`New columns: ${n}`:void 0,t===void 0?void 0:`${gB.format(t)} records had fields set aside`].filter(Boolean).join(` · `)}),e.length===0?(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`The incoming data matches the table.`}):(0,H.jsx)(`ul`,{children:e.map(e=>(0,H.jsxs)(`li`,{"data-change":e.change,children:[(0,H.jsx)(`span`,{className:`sf-schema-diff-mark`,"aria-hidden":`true`,children:vB[e.change]}),(0,H.jsx)(`strong`,{children:e.column}),(0,H.jsx)(`span`,{children:_B[e.change]}),(0,H.jsx)(`span`,{className:`sf-object-type`,children:e.change===`typeChanged`?`${e.before??`?`} → ${e.after??`?`}`:e.after??e.before??``})]},`${e.change}:${e.column}`))})]})}function iB(e){if(e.length===0)return``;let t=Math.max(...e),n=Math.min(...e),r=t-n||1;return e.map((t,i)=>`${e.length===1?50:i/(e.length-1)*100},${26-(t-n)/r*24}`).join(` `)}function aB({progress:e,className:t}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`No progress has been reported yet.`});let n=e.at(-1),r=n.processedRowsPerSecond<n.inputRowsPerSecond;return(0,H.jsxs)(`div`,{className:[`sf-stream`,t].filter(Boolean).join(` `),children:[(0,H.jsxs)(`p`,{className:`sf-stream-status`,"data-behind":r||void 0,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:r?`!`:`✓`}),` `,r?`Falling behind: rows arrive faster than they are processed.`:`Keeping up with its input.`,` Last report`,` `,n.timestamp.replace(`T`,` `).slice(0,19),`.`]}),(0,H.jsx)(`dl`,{className:`sf-stream-grid`,children:yB.filter(t=>e.some(e=>e[t.key]!==void 0)).map(t=>{let n=e.map(e=>e[t.key]).filter(e=>e!==void 0);return(0,H.jsxs)(`div`,{className:`sf-stream-tile`,children:[(0,H.jsx)(`dt`,{children:t.label}),(0,H.jsxs)(`dd`,{children:[pB.format(n.at(-1)),` `,(0,H.jsx)(`span`,{children:t.unit}),(0,H.jsx)(`svg`,{viewBox:`0 0 100 28`,preserveAspectRatio:`none`,role:`img`,"aria-label":`${t.label} over the last ${n.length} reports, from ${pB.format(Math.min(...n))} to ${pB.format(Math.max(...n))}`,children:(0,H.jsx)(`polyline`,{points:iB(n)})})]})]},t.key)})})]})}var H,oB,sB,cB,lB,uB,dB,fB,pB,mB,hB,gB,_B,vB,yB,bB=n((()=>{H=HA(),oB=jM(),iz(),BA(),sB={source:`Source`,table:`Table`,view:`View`,streamingTable:`Streaming table`,materializedView:`Materialized view`,temporaryView:`Temporary view`,sink:`Sink`},cB={idle:`○`,starting:`…`,running:`…`,completed:`✓`,failed:`!`,cancelled:`×`,skipped:`–`},lB=200,uB=64,dB=72,fB=20,pB={format:e=>jA({notation:`compact`,maximumFractionDigits:1}).format(e)},mB={default:`New data`,refresh:`Refresh`,fullRefresh:`Full refresh`},hB={warn:`Kept, with a warning`,drop:`Dropped`,fail:`Fails the run`},gB={format:e=>jA().format(e)},_B={added:`New column`,removed:`Missing column`,typeChanged:`Type changed`},vB={added:`+`,removed:`−`,typeChanged:`~`},yB=[{key:`inputRowsPerSecond`,label:`Input rate`,unit:`rows/s`},{key:`processedRowsPerSecond`,label:`Processing rate`,unit:`rows/s`},{key:`numInputRows`,label:`Rows per batch`,unit:`rows`},{key:`batchDurationMs`,label:`Batch duration`,unit:`ms`},{key:`stateRows`,label:`Rows in state`,unit:`rows`}]}));function xB(e){let t=e.columns.join(`, `);if(e.kind===nS.UNSPECIFIED&&e.description)return e.description;switch(e.kind){case nS.RELATIONSHIPS:return`${t} is found in ${e.toTable}.${e.toColumn}`;case nS.ACCEPTED_VALUES:return`${t} is one of ${e.values.join(`, `)}`;case nS.ROW_COUNT:return e.minRows!==void 0&&e.maxRows!==void 0?`between ${e.minRows} and ${e.maxRows} rows`:e.minRows===void 0?e.maxRows===void 0?`row count`:`at most ${e.maxRows} rows`:`at least ${e.minRows} rows`;default:return`${t} ${EB[e.kind]??``}`.trim()}}function SB(e,t){if(!e)return[`New dataset`];let n=[],r=(e,t)=>JSON.stringify(e)===JSON.stringify(t);e.sql.trim()!==t.sql.trim()&&n.push(`Query`),e.grain!==t.grain&&n.push(`Grain`),r(e.primaryKey,t.primaryKey)||n.push(`Key`),r(e.inputs,t.inputs)||n.push(`What it reads`),r(e.columns.map(e=>[e.name,e.type,e.description]),t.columns.map(e=>[e.name,e.type,e.description]))||n.push(`Columns`);let i=e=>e.checks.filter(e=>!e.implied).map(e=>[e.kind,e.columns,e.toTable,e.toColumn,e.values,String(e.minRows),String(e.maxRows),e.severity]);return r(i(e),i(t))||n.push(`Checks`),e.description!==t.description&&n.push(`Description`),(e.kind!==t.kind||e.layer!==t.layer)&&n.push(`Kind`),n}function CB(e){let t=OB(e.pipelines),n=(0,TB.useId)(),[r,i]=(0,TB.useState)(()=>ym(Zx,e.pipeline)),[a,o]=(0,TB.useState)(),[s,c]=(0,TB.useState)(e.approver??``),[l,u]=(0,TB.useState)(``),[d,f]=(0,TB.useState)(),[p,m]=(0,TB.useState)(),[h,g]=(0,TB.useState)(!1),[_,v]=(0,TB.useState)(!1);(0,TB.useEffect)(()=>i(ym(Zx,e.pipeline)),[e.pipeline]),(0,TB.useEffect)(()=>{let e=!0;return GS(r).then(t=>e&&f(t)),()=>{e=!1}},[r]),(0,TB.useEffect)(()=>{if(!t||e.expectedVersion===0)return;let n=!0;return t.getPipeline({id:r.id}).then(({pipeline:e})=>n&&o(e),()=>void 0),()=>{n=!1}},[t,r.id,e.expectedVersion]);let y=r.datasets.findIndex(t=>t.name.toLowerCase()===e.dataset.toLowerCase()),b=r.datasets[y],x=a?.datasets.find(t=>t.kind!==Qx.SOURCE&&t.name.toLowerCase()===e.dataset.toLowerCase()),S=(0,TB.useMemo)(()=>b?SB(x,b):[],[x,b]),C=d!==void 0&&e.digest!==void 0&&d!==e.digest,w=!!t?.savePipeline;if(!b)return(0,wB.jsxs)(`p`,{className:`sf-surface-notice`,role:`note`,children:[`The proposal has no dataset called `,e.dataset,`.`]});let T=b.name,E=(t,n)=>{i(e=>ym(Zx,{...e,datasets:e.datasets.map((e,n)=>n===y?{...e,...t}:e)})),e.onContext?.({kind:`field.changed`,summary:n,subject:{pipeline:r.id,dataset:T}})},D=b.checks.filter(e=>!e.implied),O=async n=>{if(!n){v(!0),m({text:`Rejected. Nothing was saved.`}),e.onDecide?.({approved:!1,...l?{note:l}:{}});return}let i=s.trim();if(!i){m({text:`Say who is approving it.`,error:!0});return}let a=await GS(r);if(!w)v(!0),m({text:`Approved. This page cannot save pipelines, so the approval was passed on.`}),e.onDecide?.({approved:!0,digest:a,approvedBy:i,...l?{note:l}:{}});else{g(!0);try{let{pipeline:n}=await t.savePipeline({pipeline:r,expectedVersion:e.expectedVersion,approvedBy:i,approvalDigest:a,note:l});v(!0),m({text:`Saved as version ${n?.version}. Nothing has been built yet; run the pipeline to build it.`}),e.onDecide?.({approved:!0,version:n?.version,digest:a,approvedBy:i,...l?{note:l}:{}})}catch(e){m({text:rP(e),error:!0})}finally{g(!1)}}};return(0,wB.jsxs)(`section`,{className:[`sf-plan-review`,`sf-dataset-review`,e.className].filter(Boolean).join(` `),"aria-labelledby":`${n}-title`,children:[(0,wB.jsxs)(`header`,{children:[(0,wB.jsxs)(`p`,{className:`sf-plan-review-title`,id:`${n}-title`,children:[x?`Change`:`Add`,` `,T,` in `,r.name||r.id]}),(0,wB.jsx)(`p`,{className:`sf-plan-review-summary`,children:[b.description,b.kind===Qx.VIEW?`Built as a view`:`Built as a table`,b.layer?`${b.layer} layer`:void 0,`on ${r.sourceId}`].filter(Boolean).join(` · `)}),e.proposedBy&&(0,wB.jsxs)(`p`,{className:`sf-plan-review-by`,children:[`Proposed by `,e.proposedBy,`. Nothing is saved until you approve, and nothing is built until the pipeline runs.`]}),(0,wB.jsx)(`p`,{className:`sf-dataset-review-changes`,children:S.map(e=>(0,wB.jsx)(`span`,{className:`sf-schema-tag`,children:e===`New dataset`?e:`${e} changed`},e))})]}),(0,wB.jsxs)(`div`,{className:`sf-dataset-review-body`,children:[(0,wB.jsx)(`h4`,{className:`sf-dataset-review-heading`,children:`Query`}),(0,wB.jsx)(NL,{code:b.sql,language:`sql`}),x&&x.sql.trim()!==b.sql.trim()&&(0,wB.jsxs)(`details`,{className:`sf-plan-review-sql`,children:[(0,wB.jsx)(`summary`,{children:`The saved query`}),(0,wB.jsx)(NL,{code:x.sql,language:`sql`})]}),(0,wB.jsx)(`p`,{className:`sf-plan-review-detail`,children:b.inputs.length>0?`Reads ${b.inputs.join(`, `)}.`:`What it reads is worked out from the query when it is saved.`}),(0,wB.jsxs)(`label`,{className:`sf-dataset-review-field`,children:[(0,wB.jsx)(`span`,{children:`Grain: what one row is`}),(0,wB.jsx)(`input`,{className:`sf-input`,value:b.grain,disabled:_,onChange:e=>E({grain:e.target.value},`Changed the grain of ${T} to "${e.target.value}"`)})]}),(0,wB.jsx)(`p`,{className:`sf-plan-review-detail`,children:b.primaryKey.length>0?`Key: ${b.primaryKey.join(`, `)}. After every build it is checked that no two rows share it and that it is never empty.`:`No key, so nothing checks that rows do not repeat.`}),b.columns.length>0&&(0,wB.jsxs)(wB.Fragment,{children:[(0,wB.jsx)(`h4`,{className:`sf-dataset-review-heading`,children:`Columns`}),(0,wB.jsxs)(`table`,{className:`sf-dataset-review-columns`,children:[(0,wB.jsx)(`thead`,{children:(0,wB.jsxs)(`tr`,{children:[(0,wB.jsx)(`th`,{scope:`col`,children:`Column`}),(0,wB.jsx)(`th`,{scope:`col`,children:`Type`}),(0,wB.jsx)(`th`,{scope:`col`,children:`Description`})]})}),(0,wB.jsx)(`tbody`,{children:b.columns.map((e,t)=>(0,wB.jsxs)(`tr`,{children:[(0,wB.jsx)(`th`,{scope:`row`,children:e.name}),(0,wB.jsx)(`td`,{children:e.type}),(0,wB.jsx)(`td`,{children:(0,wB.jsx)(`input`,{className:`sf-input`,"aria-label":`Description of ${e.name}`,value:e.description,disabled:_,onChange:n=>E({columns:b.columns.map((e,r)=>r===t?{...e,description:n.target.value}:e)},`Described ${T}.${e.name}`)})})]},e.name))})]})]}),(0,wB.jsx)(`h4`,{className:`sf-dataset-review-heading`,children:`Checks after each build`}),D.length===0?(0,wB.jsx)(`p`,{className:`sf-plan-review-detail`,children:`No checks beyond the key.`}):(0,wB.jsx)(`ul`,{className:`sf-dataset-review-checks`,children:D.map(e=>{let t=KS(e),n=e.severity===rS.WARN;return(0,wB.jsxs)(`li`,{className:`sf-controls-host`,"data-controls":`corner`,children:[(0,wB.jsxs)(`span`,{className:`sf-dataset-review-check`,children:[(0,wB.jsx)(`code`,{children:t}),` `,xB(e)]}),(0,wB.jsxs)(`label`,{className:`sf-dataset-review-severity`,children:[(0,wB.jsx)(`input`,{type:`checkbox`,checked:!n,disabled:_,onChange:()=>E({checks:b.checks.map(t=>t===e?{...t,severity:n?rS.FAIL:rS.WARN}:t)},n?`${t} now stops what reads ${T}`:`${t} now only warns`)}),`Stops what reads it when it fails`]}),!_&&(0,wB.jsx)(iI,{label:`Check ${t}`,controls:aI(`the check ${t}`,{remove:()=>E({checks:b.checks.filter(t=>t!==e)},`Removed the check ${t} from ${T}`)})})]},t)})})]}),p&&(0,wB.jsx)(`p`,{className:`sf-plan-review-outcome`,role:p.error?`alert`:`status`,children:p.text}),!_&&(0,wB.jsxs)(`footer`,{className:`sf-plan-review-actions`,children:[(0,wB.jsxs)(`label`,{className:`sf-plan-review-note`,children:[`Approved by`,(0,wB.jsx)(`input`,{className:`sf-input`,value:s,onChange:e=>c(e.target.value),autoComplete:`name`})]}),(0,wB.jsxs)(`label`,{className:`sf-plan-review-note`,children:[`Note (optional)`,(0,wB.jsx)(`input`,{className:`sf-input`,value:l,onChange:e=>u(e.target.value)})]}),(0,wB.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:h,onClick:()=>void O(!0),children:w?`Approve and save`:`Approve`}),(0,wB.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:h,onClick:()=>void O(!1),children:`Reject`})]}),!_&&C&&(0,wB.jsx)(`p`,{className:`sf-plan-review-detail`,children:`You changed the proposal; what you approve is what is shown here.`})]})}var wB,TB,EB,DB=n((()=>{wB=HA(),zb(),rw(),vS(),TB=jM(),uI(),oP(),zL(),WB(),EB={[nS.UNIQUE]:`never repeats`,[nS.NOT_NULL]:`is never empty`,[nS.RELATIONSHIPS]:`is found in`,[nS.ACCEPTED_VALUES]:`is one of`,[nS.ROW_COUNT]:`row count`}}));function OB(e){let t=(0,LB.useContext)(RB);return jN(`Pipelines`,e??t)}function kB(e){let t=(0,LB.useContext)(RB),n=jN(`Pipelines`,e??t);if(!n)throw Error(`No Pipelines backend: wrap the component in <PipelinesProvider> or pass pipelines.`);return n}function AB(e,t){let n=new Map(t?.datasetRuns.map(e=>[e.name,e]));return{nodes:e.datasets.map(t=>{let r=n.get(t.name),i=!e.externalRuns||(r?r.rowsWritten>0n:!!t.rowsWritten);return{id:t.name,name:t.name,kind:BB[t.kind]??`table`,layer:t.layer||void 0,status:t.kind===Qx.SOURCE?void 0:zB[r?.state??t.state],rowsWritten:i?r?r.state===$x.COMPLETED&&t.kind!==Qx.VIEW?Number(r.rowsWritten):void 0:t.rowsWritten===void 0||t.kind===Qx.VIEW?void 0:Number(t.rowsWritten):void 0,expectationsFailed:r?.expectations.reduce((e,t)=>e+Number(t.failedRecords),0)||void 0,checksFailed:r?.checks.filter(e=>e.failedRecords>0n&&e.severity!==rS.WARN).length||void 0,checksWarned:r?.checks.filter(e=>e.failedRecords>0n&&e.severity===rS.WARN).length||void 0}}),edges:e.datasets.flatMap(e=>e.inputs.map(t=>({from:t,to:e.name})))}}function jB(e){return{id:e.id,state:zB[e.state],startTime:e.startTime,endTime:e.endTime||void 0,trigger:e.dryRun?`check only`:e.trigger||void 0,refreshKind:HB[e.refreshKind]??`default`,datasets:e.datasets,errorMessage:e.errorMessage||void 0}}function MB(e,t){let n=new Map(t?.datasetRuns.find(t=>t.name===e.name)?.checks.map(e=>[e.name,e]));return e.checks.map(e=>{let t=n.get(e.name);return{name:e.name,description:xB(e),severity:e.severity===rS.WARN?`warn`:`fail`,...t?{failedRecords:Number(t.failedRecords),summary:t.summary,canOpenFailing:!!t.failingRowsSql}:{},...e.implied?{fromKey:!0}:{}}})}function NB(e,t){return{kind:t,runId:e.id,state:UB[e.state]??`running`,...e.dryRun?{dryRun:!0}:{},...t===`finished`?{built:e.datasetRuns.filter(e=>e.state===$x.COMPLETED).length,failed:e.datasetRuns.filter(e=>e.state===$x.FAILED).map(e=>e.name),failedChecks:e.datasetRuns.flatMap(e=>e.checks.filter(e=>e.failedRecords>0n&&e.severity!==rS.WARN).map(t=>`${e.name}.${t.name}`))}:{}}}function PB(e,t){return`SELECT * FROM (${e.sql}) AS d WHERE NOT COALESCE((${t}), FALSE)`}function FB(e){let{pipelineId:t,pollMs:n=1e3}=e,r=kB(e.pipelines),[i,a]=(0,LB.useState)(),[o,s]=(0,LB.useState)([]),[c,l]=(0,LB.useState)(),[u,d]=(0,LB.useState)(),[f,p]=(0,LB.useState)(),[m,h]=(0,LB.useState)(!1),[g,_]=(0,LB.useState)(``),v=(0,LB.useRef)(!0),y=(0,LB.useCallback)(async()=>{try{let[e,n]=await Promise.all([r.getPipeline({id:t}),r.listRuns({pipelineId:t,pageSize:20})]);if(!v.current)return;a(e.pipeline),s(n.runs),l(void 0)}catch(e){v.current&&l(rP(e))}},[r,t]);(0,LB.useEffect)(()=>(v.current=!0,a(void 0),s([]),d(void 0),p(void 0),y(),()=>{v.current=!1}),[y]);let b=o.find(e=>e.state===$x.RUNNING);(0,LB.useEffect)(()=>{if(!b)return;let e=setInterval(()=>void y(),n);return()=>clearInterval(e)},[b?.id,y,n]);let x=(0,LB.useRef)(void 0),{onRun:S,onContext:C}=e;(0,LB.useEffect)(()=>{let e=o.find(e=>e.id===x.current);if(!e||e.state===$x.RUNNING)return;x.current=void 0;let n=NB(e,`finished`);S?.(n);let r=n.failedChecks?.length?`; failed checks: ${n.failedChecks.join(`, `)}`:``;C?.({kind:`run.finished`,summary:`${e.id} ${n.state}: ${n.built} built${n.failed?.length?`, ${n.failed.join(`, `)} failed`:``}${r}.`,subject:{pipeline:t,...n}})},[o,S,C,t]);let w=async e=>{h(!1);try{let{run:n}=await r.startRun({pipelineId:t,trigger:`manual`,...e});if(n){p(n.id),_(e.dryRun?n.state===$x.FAILED?`The check found problems: ${n.errorMessage}`:`The check found no problems. Nothing was built.`:`Started ${n.id}.`);let r=e.dryRun?`Checked`:e.refreshKind===eS.FULL_REFRESH?`Started a full refresh of`:e.datasets?`Started rebuilding ${e.datasets.join(`, `)} and what uses it in`:`Started a run of`;e.dryRun||(x.current=n.id,S?.(NB(n,`started`))),C?.({kind:e.dryRun?`pipeline.checked`:`run.started`,summary:`${r} the pipeline ${t}${e.dryRun?n.state===$x.FAILED?`: problems found`:`: no problems`:``}.`,subject:{pipeline:t,runId:n.id,...e.datasets?{datasets:e.datasets}:{}}})}await y()}catch(e){_(rP(e))}};if(c)return(0,IB.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:c});if(!i?.summary)return(0,IB.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`});let T=o.find(e=>e.id===f)??o.find(e=>!e.dryRun),{nodes:E,edges:D}=AB(i,T),O=i.datasets.find(e=>e.name===u),k=O&&O.kind!==Qx.SOURCE,ee=T?.datasetRuns.find(e=>e.name===u),te=(ee?.expectations??[]).map(e=>({name:e.name,dataset:u??``,constraint:e.constraint,action:VB[e.action]??`warn`,passedRecords:Number(e.passedRecords),failedRecords:Number(e.failedRecords)})),A=i.summary.sourceId,ne=i.canBuild||!i.externalRuns;return(0,IB.jsxs)(`div`,{className:[`sf-pipeline-view`,e.className].filter(Boolean).join(` `),children:[(0,IB.jsxs)(`header`,{className:`sf-source-head`,children:[(0,IB.jsxs)(`div`,{children:[(0,IB.jsx)(`h3`,{className:`sf-object-title`,children:i.summary.name}),(0,IB.jsx)(`p`,{className:`sf-object-facts`,children:[i.summary.description,`${i.summary.datasetCount} datasets`,`Source ${A}`,i.recomputeOnly?`Each run rebuilds whole tables`:void 0].filter(Boolean).join(` · `)})]}),(0,IB.jsx)(`div`,{className:`sf-object-buttons`,children:ne?b?(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void r.cancelRun({pipelineId:t,runId:b.id}).then(()=>_(`Stopping after the table being built.`)),children:`Cancel run`}):(0,IB.jsxs)(IB.Fragment,{children:[(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,onClick:()=>void w({}),children:`Run`}),(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void w({dryRun:!0}),children:`Check only`}),e.fullRefresh!==!1&&(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>h(!0),children:`Full refresh…`})]}):(0,IB.jsx)(`p`,{className:`sf-object-facts`,children:`Built by another tool; its runs are reported here.`})})]}),m&&(0,IB.jsxs)(`div`,{className:`sf-pipeline-confirm`,role:`alertdialog`,"aria-label":`Confirm full refresh`,children:[(0,IB.jsx)(`p`,{children:`A full refresh deletes every table this pipeline built and builds them again. Queries against them will fail until it finishes.`}),(0,IB.jsxs)(`div`,{className:`sf-object-buttons`,children:[(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,onClick:()=>void w({refreshKind:eS.FULL_REFRESH,confirmFullRefresh:!0}),children:`Delete and rebuild`}),(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>h(!1),children:`Keep the tables`})]})]}),(0,IB.jsx)(`p`,{className:`sf-model-status`,role:`status`,children:g}),(0,IB.jsx)(Qz,{nodes:E,edges:D,selected:u,onSelect:e=>{d(e.id),C?.({kind:`dataset.selected`,summary:`Looked at ${e.name} in ${i.summary?.name}.`,subject:{pipeline:t,dataset:e.name}})},label:`${i.summary.name} pipeline`}),O&&(0,IB.jsxs)(`section`,{className:`sf-pipeline-detail`,"aria-label":`Dataset ${O.name}`,children:[(0,IB.jsxs)(`header`,{className:`sf-source-head`,children:[(0,IB.jsxs)(`div`,{children:[(0,IB.jsx)(`h4`,{className:`sf-object-title`,children:O.name}),(0,IB.jsx)(`p`,{className:`sf-object-facts`,children:[O.description,O.inputs.length>0?`Reads ${O.inputs.join(`, `)}${O.inputsDeclared?``:` (worked out from the query)`}`:void 0,O.owner?`Owner ${O.owner}`:void 0,O.tags.length>0?O.tags.join(`, `):void 0,O.builtAt?`Built ${new Date(O.builtAt).toLocaleString()}`:void 0].filter(Boolean).join(` · `)||`A table this pipeline reads.`}),k&&(O.grain||O.primaryKey.length>0)&&(0,IB.jsx)(`p`,{className:`sf-object-facts`,children:[O.grain?`One row: ${O.grain}`:void 0,O.primaryKey.length>0?`Key ${O.primaryKey.join(`, `)}`:void 0].filter(Boolean).join(` · `)}),ee?.errorMessage&&(0,IB.jsx)(`p`,{className:`sf-search-error`,role:`note`,children:ee.errorMessage})]}),(0,IB.jsxs)(`div`,{className:`sf-object-buttons`,children:[e.onOpenTable&&(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onOpenTable?.(O.name,A),children:`Open table`}),k&&!b&&ne&&(0,IB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void w({refreshKind:eS.REFRESH,datasets:[O.name]}),children:`Rebuild this and what uses it`})]})]}),k&&i.externalRuns&&O.sql&&(0,IB.jsx)(`p`,{className:`sf-explore-hint`,children:`The query as the other tool compiled it, shown read-only. That tool builds the dataset from its own definition, never from this text.`}),k&&O.sql&&(0,IB.jsx)(NL,{code:O.sql,language:`sql`,label:i.externalRuns?`Compiled query (read-only preview)`:void 0}),k&&O.columns.length>0&&(0,IB.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Columns of ${O.name}`,children:(0,IB.jsxs)(`table`,{children:[(0,IB.jsxs)(`caption`,{className:`sf-a2-visually-hidden`,children:[`Columns of `,O.name]}),(0,IB.jsx)(`thead`,{children:(0,IB.jsxs)(`tr`,{children:[(0,IB.jsx)(`th`,{scope:`col`,children:`Column`}),(0,IB.jsx)(`th`,{scope:`col`,children:`Type`}),(0,IB.jsx)(`th`,{scope:`col`,children:`Description`})]})}),(0,IB.jsx)(`tbody`,{children:O.columns.map(e=>(0,IB.jsxs)(`tr`,{children:[(0,IB.jsx)(`th`,{scope:`row`,children:e.name}),(0,IB.jsx)(`td`,{className:`sf-object-type`,children:e.type}),(0,IB.jsx)(`td`,{children:e.description})]},e.name))})]})}),k&&O.checks.length>0&&(0,IB.jsx)(nB,{checks:MB(O,T),onOpenFailing:e.onOpenSql?t=>{let n=T?.datasetRuns.find(e=>e.name===O.name)?.checks.find(e=>e.name===t.name)?.failingRowsSql;n&&e.onOpenSql?.(n,A)}:void 0}),k&&(te.length>0?(0,IB.jsx)(tB,{expectations:te,onOpenFailing:e.onOpenSql?t=>e.onOpenSql?.(PB(O,t.constraint),A):void 0}):O.expectations.length>0?(0,IB.jsxs)(`p`,{className:`sf-object-muted`,children:[O.expectations.length,` data quality `,O.expectations.length===1?`rule`:`rules`,`: `,O.expectations.map(e=>e.name).join(`, `),`. Run the pipeline to see results.`]}):(0,IB.jsx)(`p`,{className:`sf-object-muted`,children:`No data quality rules on this dataset.`}))]}),(0,IB.jsx)(eB,{runs:o.map(jB),selected:T?.id,onSelect:e=>p(e.id)})]})}var IB,LB,RB,zB,BB,VB,HB,UB,WB=n((()=>{IB=HA(),vS(),LN(),LB=jM(),oP(),zL(),DB(),bB(),RB=(0,LB.createContext)(void 0),zB={[$x.UNSPECIFIED]:`idle`,[$x.QUEUED]:`starting`,[$x.RUNNING]:`running`,[$x.COMPLETED]:`completed`,[$x.FAILED]:`failed`,[$x.CANCELLED]:`cancelled`,[$x.SKIPPED]:`skipped`},BB={[Qx.SOURCE]:`source`,[Qx.TABLE]:`table`,[Qx.VIEW]:`view`,[Qx.STREAMING_TABLE]:`streamingTable`,[Qx.SINK]:`sink`},VB={[tS.DROP]:`drop`,[tS.FAIL]:`fail`},HB={[eS.REFRESH]:`refresh`,[eS.FULL_REFRESH]:`fullRefresh`},UB={[$x.RUNNING]:`running`,[$x.COMPLETED]:`completed`,[$x.FAILED]:`failed`,[$x.CANCELLED]:`cancelled`}}));function GB(e){let t=[],n=e.columns.filter(e=>e.include);e.location.trim()||t.push(`Say where the files are.`),QB.test(e.rawTable)||t.push(`Name the table using letters, digits and underscores.`),e.targetTable&&!QB.test(e.targetTable)&&t.push(`The cleaned table's name uses letters, digits and underscores.`),e.targetTable&&e.targetTable.toLowerCase()===e.rawTable.toLowerCase()&&t.push(`The cleaned table needs a different name from the raw one.`),e.columns.length>0&&n.length===0&&t.push(`Keep at least one column.`);let r=n.map(e=>e.target.trim().toLowerCase());n.some(e=>!QB.test(e.target.trim()))?t.push(`Column names use letters, digits and underscores.`):new Set(r).size!==r.length&&t.push(`Two columns have the same name.`);let i=`{ name: ${JSON.stringify(e.rawTable)}, format: ${JSON.stringify(e.format)}, path: ${JSON.stringify(e.location.trim())} },`,a=n.map(e=>{let t=e.targetType?`CAST(${$B(e.source)} AS ${e.targetType})`:$B(e.source);return e.target.trim()===e.source&&!e.targetType?` ${t}`:` ${t} AS ${$B(e.target.trim())}`}).join(`,
|
|
44
|
-
`);return{table:i,dataset:e.targetTable?`{\n name: ${JSON.stringify(e.targetTable)},\n layer: "silver",\n sql: ${JSON.stringify(`SELECT\n${a}\nFROM ${$B(e.rawTable)}`)},\n},`:``,problems:t}}function KB({sourceId:e,value:t,onChange:n,className:r,...i}){let a=kB(i.pipelines),[o,s]=(0,JB.useState)({loading:!1}),c=GB(t),l=e=>n({...t,...e}),u=(e,n)=>l({columns:t.columns.map((t,r)=>r===e?{...t,...n}:t)}),d=async()=>{s({loading:!0});try{let n=await a.inspectFiles({sourceId:e,format:XB[t.format],location:t.location});l({columns:n.columns.map(e=>({source:e.name,sourceType:e.nativeType,include:!0,target:e.name.toLowerCase().replace(/\W+/g,`_`),targetType:``}))}),s({loading:!1,rows:n.rowCount===void 0?void 0:Number(n.rowCount)})}catch(e){s({loading:!1,error:rP(e)})}};return(0,qB.jsxs)(`div`,{className:[`sf-connect sf-ingest`,r].filter(Boolean).join(` `),children:[(0,qB.jsxs)(`fieldset`,{className:`sf-connect-group`,children:[(0,qB.jsx)(`legend`,{children:`1. Where the files are`}),(0,qB.jsxs)(`label`,{children:[(0,qB.jsx)(`span`,{children:`Format`}),(0,qB.jsxs)(`select`,{className:`sf-input`,value:t.format,onChange:e=>l({format:e.target.value,columns:[]}),children:[(0,qB.jsx)(`option`,{value:`parquet`,children:`Parquet`}),(0,qB.jsx)(`option`,{value:`delta`,children:`Delta Lake`}),(0,qB.jsx)(`option`,{value:`iceberg`,children:`Iceberg`}),(0,qB.jsx)(`option`,{value:`csv`,children:`CSV`}),(0,qB.jsx)(`option`,{value:`json`,children:`JSON`})]})]}),(0,qB.jsxs)(`label`,{className:`sf-connect-path`,children:[(0,qB.jsx)(`span`,{children:`Location`}),(0,qB.jsx)(`input`,{className:`sf-input`,value:t.location,placeholder:`s3://acme-lake/landing/orders/*.parquet`,onChange:e=>l({location:e.target.value,columns:[]})})]}),(0,qB.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:o.loading||!t.location.trim(),onClick:()=>void d(),children:o.loading?`Looking…`:`Look at the files`}),(0,qB.jsx)(`p`,{className:`sf-connect-note`,children:`The server reads only the schema. The location must be one this source is allowed to reach.`}),o.error&&(0,qB.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:o.error})]}),t.columns.length>0&&(0,qB.jsxs)(qB.Fragment,{children:[(0,qB.jsxs)(`fieldset`,{className:`sf-connect-group sf-connect-tables`,children:[(0,qB.jsx)(`legend`,{children:`2. Columns to keep`}),(0,qB.jsxs)(`p`,{className:`sf-connect-note`,role:`status`,children:[`Found `,t.columns.length,` columns`,o.rows===void 0?``:` and ${jA().format(o.rows)} rows`,`.`]}),(0,qB.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Columns found`,children:(0,qB.jsxs)(`table`,{children:[(0,qB.jsx)(`thead`,{children:(0,qB.jsxs)(`tr`,{children:[(0,qB.jsx)(`th`,{scope:`col`,children:`Keep`}),(0,qB.jsx)(`th`,{scope:`col`,children:`In the files`}),(0,qB.jsx)(`th`,{scope:`col`,children:`Type found`}),(0,qB.jsx)(`th`,{scope:`col`,children:`Name in the table`}),(0,qB.jsx)(`th`,{scope:`col`,children:`Type in the table`})]})}),(0,qB.jsx)(`tbody`,{children:t.columns.map((e,t)=>(0,qB.jsxs)(`tr`,{children:[(0,qB.jsx)(`td`,{children:(0,qB.jsx)(`input`,{type:`checkbox`,checked:e.include,"aria-label":`Keep ${e.source}`,onChange:e=>u(t,{include:e.target.checked})})}),(0,qB.jsx)(`th`,{scope:`row`,children:e.source}),(0,qB.jsx)(`td`,{className:`sf-object-type`,children:e.sourceType.toLowerCase()}),(0,qB.jsx)(`td`,{children:(0,qB.jsx)(`input`,{className:`sf-input`,value:e.target,disabled:!e.include,"aria-label":`Name for ${e.source}`,onChange:e=>u(t,{target:e.target.value})})}),(0,qB.jsx)(`td`,{children:(0,qB.jsx)(`select`,{className:`sf-input`,value:e.targetType,disabled:!e.include,"aria-label":`Type for ${e.source}`,onChange:e=>u(t,{targetType:e.target.value}),children:ZB.map(e=>(0,qB.jsx)(`option`,{value:e,children:e?e.toLowerCase():`as found`},e))})})]},e.source))})]})})]}),(0,qB.jsxs)(`fieldset`,{className:`sf-connect-group`,children:[(0,qB.jsx)(`legend`,{children:`3. What to call it`}),(0,qB.jsxs)(`label`,{children:[(0,qB.jsx)(`span`,{children:`Table for the files as they are`}),(0,qB.jsx)(`input`,{className:`sf-input`,value:t.rawTable,placeholder:`orders_landing`,onChange:e=>l({rawTable:e.target.value})})]}),(0,qB.jsxs)(`label`,{children:[(0,qB.jsx)(`span`,{children:`Cleaned table (optional)`}),(0,qB.jsx)(`input`,{className:`sf-input`,value:t.targetTable,placeholder:`orders_clean`,onChange:e=>l({targetTable:e.target.value})})]})]}),(0,qB.jsx)(`section`,{className:`sf-connect-plan`,"aria-label":`What to add`,"aria-live":`polite`,children:c.problems.length>0?(0,qB.jsx)(`ul`,{className:`sf-connect-problems`,children:c.problems.map(e=>(0,qB.jsx)(`li`,{children:e},e))}):(0,qB.jsxs)(qB.Fragment,{children:[(0,qB.jsx)(`p`,{className:`sf-object-label`,children:`Add this to the source's tables in surfaces.config.ts`}),(0,qB.jsx)(NL,{code:c.table,language:`ts`}),c.dataset&&(0,qB.jsxs)(qB.Fragment,{children:[(0,qB.jsx)(`p`,{className:`sf-object-label`,children:`Add this dataset to a pipeline to build the cleaned table`}),(0,qB.jsx)(NL,{code:c.dataset,language:`ts`})]}),(0,qB.jsx)(`p`,{className:`sf-connect-note`,children:`Nothing has been loaded. Restart the server after adding these, then run the pipeline.`})]})})]})]})}var qB,JB,YB,XB,ZB,QB,$B,eV=n((()=>{qB=HA(),vS(),JB=jM(),oP(),zL(),WB(),BA(),YB={format:`parquet`,location:``,rawTable:``,targetTable:``,columns:[]},XB={parquet:Cx.PARQUET,delta:Cx.DELTA,iceberg:Cx.ICEBERG,csv:Cx.CSV,json:Cx.JSON},ZB=[``,`VARCHAR`,`BIGINT`,`INTEGER`,`DOUBLE`,`DECIMAL(18,2)`,`BOOLEAN`,`DATE`,`TIMESTAMP`],QB=/^[A-Za-z_][A-Za-z0-9_]*$/,$B=e=>QB.test(e)?e:`"${e.replace(/"/g,`""`)}"`}));function tV(e,t){let[n,r]=(0,nV.useState)({loading:!0}),i=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t);return(0,nV.useEffect)(()=>{let n=new AbortController;r(e=>({...e,loading:!0,error:void 0}));let{sourceId:i,sql:a,column:o,aggregate:s,filters:c,notBefore:l,x:u,grain:d,points:f=60}=t,p=u!==void 0&&d!==void 0;return JS(e.execute({sourceId:i,notBefore:l,query:{baseSql:a,filters:c,aggregates:[{function:gF[s],column:o??``,alias:`value`,percentile:s===`percentile`?.9:0}],...p?{buckets:[{column:u,by:{case:`grain`,value:_F[d]}}],sorts:[{column:u,direction:ax.DESC}],page:{limit:f}}:{}}},{signal:n.signal})).then(e=>{if(n.signal.aborted)return;let t=e.table.getChild(`value`),i=e.table.schema.fields.find(e=>e.name===`value`),a=Array.from({length:e.table.numRows},(e,n)=>i?ZN(t?.get(n),i.type):null);r({values:p?a.reverse():a,loading:!1,notes:cP(e.header.notices)})}).catch(e=>{n.signal.aborted||r({error:rP(e),loading:!1})}),()=>n.abort()},[e,i]),n}var nV,rV=n((()=>{rw(),fP(),nV=jM(),vF(),tP(),oP(),vS()}));function iV(e,t=sV,n=cV,r=lV){let i=e.filter(e=>e!==null);if(i.length===0)return[];let a=Math.min(...i),o=Math.max(...i),s=o-a||1,c=e.length>1?(t-r*2)/(e.length-1):0;return e.flatMap((e,t)=>e===null?[]:[{x:r+t*c,y:o===a?n/2:r+(1-(e-a)/s)*(n-r*2),value:e}])}function aV(e){let{sourceId:t,sql:n,x:r,grain:i,column:a,aggregate:o,label:s,format:c,currency:l,points:u=30,filters:d,notBefore:f}=e,p=tV(zN(e.dataSource),{sourceId:t,sql:n,column:a,aggregate:o,filters:d,notBefore:f,x:r,grain:i,points:u}),m=iV(p.values??[]),h=e=>Vz(e,c,l),g=m.at(-1),_=m.reduce((e,t)=>!e||t.value<e.value?t:e,void 0),v=m.reduce((e,t)=>!e||t.value>e.value?t:e,void 0),y=g&&_&&v&&m[0]?z(`sparkline.summary`,{label:s,now:h(g.value),first:h(m[0].value),low:h(_.value),high:h(v.value),count:m.length,grain:i}):e.emptyMessage?`${s}: ${e.emptyMessage}`:z(`sparkline.empty`,{label:s});return(0,oV.jsxs)(`span`,{className:[`sf-spark`,e.className].filter(Boolean).join(` `),"aria-busy":p.loading,children:[(0,oV.jsx)(`span`,{className:`sf-spark-label`,children:s}),p.error?(0,oV.jsx)(`span`,{className:`sf-metric-error`,role:`alert`,"data-error":p.error,children:e.errorMessage??p.error}):(0,oV.jsxs)(oV.Fragment,{children:[(0,oV.jsxs)(`svg`,{className:`sf-spark-line`,viewBox:`0 0 ${sV} ${cV}`,width:sV,height:cV,role:`img`,"aria-label":y,children:[m.length>1&&(0,oV.jsx)(`polyline`,{points:m.map(e=>`${e.x.toFixed(1)},${e.y.toFixed(1)}`).join(` `)}),_&&v&&_!==v&&(0,oV.jsxs)(oV.Fragment,{children:[(0,oV.jsx)(`circle`,{className:`sf-spark-extreme`,cx:_.x,cy:_.y,r:1.8}),(0,oV.jsx)(`circle`,{className:`sf-spark-extreme`,cx:v.x,cy:v.y,r:1.8})]}),g&&(0,oV.jsx)(`circle`,{className:`sf-spark-last`,cx:g.x,cy:g.y,r:2.4})]}),(0,oV.jsx)(`span`,{className:`sf-spark-value`,children:g?h(g.value):p.loading?z(`metric.loading`):e.emptyMessage??z(`metric.none`)})]}),(0,oV.jsx)(lP,{notes:p.notes})]})}var oV,sV,cV,lV,uV=n((()=>{oV=HA(),UN(),fP(),BA(),Gz(),rV(),sV=120,cV=28,lV=3}));function dV(e,t){return t.find(t=>e<=t.to)??t.at(-1)}function fV(e){let{sourceId:t,sql:n,column:r,aggregate:i,label:a,target:o,format:s,currency:c,filters:l,notBefore:u}=e,d=[...e.ranges].sort((e,t)=>e.to-t.to).slice(0,5),f=tV(zN(e.dataSource),{sourceId:t,sql:n,column:r,aggregate:i,filters:l,notBefore:u}),p=f.values?.[0]??void 0,m=e=>Vz(e,s,c),h=Math.max(d.at(-1)?.to??0,o??0,p??0)||1,g=e=>`${Math.max(0,Math.min(100,e/h*100))}%`,_=p==null?void 0:dV(p,d),v=p==null?f.loading?z(`bullet.loading`,{label:a}):e.emptyMessage?`${a}: ${e.emptyMessage}`:z(`bullet.empty`,{label:a}):z(`bullet.reading`,{label:a,value:m(p),band:_?`, ${_.label.toLowerCase()}`:``,target:o===void 0?``:z(p>=o?`bullet.targetMet`:`bullet.targetNotMet`,{target:m(o)})});return(0,pV.jsxs)(`div`,{className:[`sf-bullet`,e.className].filter(Boolean).join(` `),"aria-busy":f.loading,children:[(0,pV.jsxs)(`div`,{className:`sf-bullet-head`,children:[(0,pV.jsx)(`span`,{className:`sf-bullet-label`,children:a}),f.error?(0,pV.jsx)(`span`,{className:`sf-metric-error`,role:`alert`,"data-error":f.error,children:e.errorMessage??f.error}):(0,pV.jsxs)(`span`,{className:`sf-bullet-value`,children:[p==null?f.loading?z(`metric.loading`):e.emptyMessage??z(`metric.none`):m(p),_&&(0,pV.jsxs)(`span`,{className:`sf-bullet-band`,children:[` `,_.label]})]})]}),(0,pV.jsxs)(`div`,{className:`sf-bullet-track`,role:`img`,"aria-label":v,children:[d.map((e,t)=>(0,pV.jsx)(`span`,{className:`sf-bullet-range`,"data-band":t+1,style:{left:g(d[t-1]?.to??0),right:`calc(100% - ${g(e.to)})`}},e.to)),p!=null&&(0,pV.jsx)(`span`,{className:`sf-bullet-bar`,style:{width:g(p)}}),o!==void 0&&(0,pV.jsx)(`span`,{className:`sf-bullet-target`,style:{left:g(o)}})]}),(0,pV.jsxs)(`div`,{className:`sf-bullet-scale`,"aria-hidden":`true`,children:[(0,pV.jsx)(`span`,{children:m(0)}),o!==void 0&&(0,pV.jsx)(`span`,{children:z(`bullet.target`,{target:m(o)})}),(0,pV.jsx)(`span`,{children:m(h)})]}),(0,pV.jsx)(lP,{notes:f.notes})]})}var pV,mV=n((()=>{pV=HA(),UN(),fP(),BA(),Gz(),rV()}));function hV(e){let{title:t,summary:n,steps:r,proposedBy:i,onDecide:a}=e,o=(0,_V.useId)(),[s,c]=(0,_V.useState)(()=>new Set(r.filter(e=>e.required||e.risk!==`high`).map(e=>e.id))),[l,u]=(0,_V.useState)(``),[d,f]=(0,_V.useState)(e.decided),p=e.decided??d,m=r.filter(e=>p?p.stepIds.includes(e.id):s.has(e.id)),h=e=>{let t={approved:e,stepIds:e?m.map(e=>e.id):[],...l.trim()?{note:l.trim()}:{}};f(t),a(t)};return(0,gV.jsxs)(`section`,{className:[`sf-plan-review`,e.className].filter(Boolean).join(` `),"aria-labelledby":`${o}-title`,children:[(0,gV.jsxs)(`header`,{children:[(0,gV.jsx)(`p`,{className:`sf-plan-review-title`,id:`${o}-title`,children:t}),n&&(0,gV.jsx)(`p`,{className:`sf-plan-review-summary`,children:n}),i&&(0,gV.jsx)(`p`,{className:`sf-plan-review-by`,children:z(`plan.proposedBy`,{who:i})})]}),(0,gV.jsx)(`ol`,{className:`sf-plan-review-steps`,children:r.map((e,t)=>{let n=e.risk??`low`;return(0,gV.jsxs)(`li`,{className:`sf-plan-review-step`,"data-risk":n,children:[(0,gV.jsxs)(`label`,{className:`sf-plan-review-pick`,children:[(0,gV.jsx)(`input`,{type:`checkbox`,checked:p?p.stepIds.includes(e.id):s.has(e.id),disabled:p!==void 0||e.required,onChange:t=>c(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}),(0,gV.jsxs)(`span`,{className:`sf-plan-review-name`,children:[t+1,`. `,e.title]})]}),(0,gV.jsxs)(`span`,{className:`sf-plan-review-tags`,children:[e.kind&&(0,gV.jsx)(`span`,{className:`sf-schema-tag`,children:e.kind}),e.required&&(0,gV.jsx)(`span`,{className:`sf-schema-tag`,children:z(`plan.required`)}),n!==`low`&&(0,gV.jsxs)(`span`,{className:`sf-plan-review-risk`,"data-risk":n,children:[n===`high`?`▲ `:`● `,z(vV[n])]})]}),e.detail&&(0,gV.jsx)(`p`,{className:`sf-plan-review-detail`,children:e.detail}),e.affects&&(0,gV.jsx)(`p`,{className:`sf-plan-review-detail`,children:z(`plan.affects`,{what:e.affects})}),e.sql&&(0,gV.jsxs)(`details`,{className:`sf-plan-review-sql`,children:[(0,gV.jsx)(`summary`,{children:z(`plan.whatItWouldRun`)}),(0,gV.jsx)(NL,{code:e.sql,language:`sql`})]})]},e.id)})}),p?(0,gV.jsxs)(`p`,{className:`sf-plan-review-outcome`,role:`status`,children:[p.approved?z(`plan.approved`,{count:p.stepIds.length,total:r.length}):z(`plan.rejected`),p.note?z(`plan.decisionNote`,{note:p.note}):``]}):(0,gV.jsxs)(`footer`,{className:`sf-plan-review-actions`,children:[(0,gV.jsxs)(`label`,{className:`sf-plan-review-note`,children:[(0,gV.jsx)(`span`,{children:z(`plan.noteLabel`)}),(0,gV.jsx)(`input`,{className:`sf-input`,value:l,onChange:e=>u(e.target.value)})]}),(0,gV.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:m.length===0,onClick:()=>h(!0),children:z(m.length===1?`plan.approveOne`:`plan.approve`,{count:m.length})}),(0,gV.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>h(!1),children:z(`plan.reject`)})]})]})}var gV,_V,vV,yV=n((()=>{gV=HA(),_V=jM(),BA(),zL(),vV={low:`plan.riskLow`,medium:`plan.riskMedium`,high:`plan.riskHigh`}}));function bV(e){return e.flatMap(e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/[^A-Za-z0-9]+/g,`_`).toLowerCase(),n=wV.find(([,e])=>e.test(t));return n?[{column:e,category:n[0],basis:`name`}]:[]})}var xV,SV,CV,wV,TV=n((()=>{xV={name:`Person's name`,email:`Email address`,phone:`Phone number`,address:`Postal address`,government_id:`Government ID`,financial:`Card or account number`,date_of_birth:`Date of birth`,network:`IP or device ID`,location:`Precise location`,credential:`Password or key`,health:`Health information`,demographic:`Sensitive personal trait`},SV={keep:`Keep as is`,mask:`Mask (show part)`,hash:`Hash (keep joins working)`,generalize:`Generalise (coarser value)`,drop:`Leave out`},CV={name:`mask`,email:`hash`,phone:`mask`,address:`drop`,government_id:`drop`,financial:`drop`,date_of_birth:`generalize`,network:`hash`,location:`generalize`,credential:`drop`,health:`drop`,demographic:`drop`},wV=[[`credential`,/(^|_)(password|passwd|pwd|secret|api_?key|token|private_?key)(_|$)/],[`government_id`,/(^|_)(ssn|social_security|national_id|nin|passport|drivers?_licen[cs]e|tax_id|tin|ein|aadhaar)(_|$)/],[`financial`,/(^|_)(card_?(number|num|no)|pan|cvv|cvc|iban|swift|routing|account_?(number|num|no)|bank_account)(_|$)/],[`email`,/(^|_)e?_?mail(_address)?(_|$)/],[`phone`,/(^|_)(phone|mobile|cell|msisdn|fax|tel)(_?(number|num|no))?(_|$)/],[`date_of_birth`,/(^|_)(dob|birth_?(date|day)|date_of_birth|birthdate)(_|$)/],[`network`,/(^|_)(ip|ip_?address|ipv4|ipv6|mac_?address|device_id|imei|idfa|user_agent)(_|$)/],[`location`,/(^|_)(lat|latitude|lng|lon|longitude|geo|geohash|gps)(_|$)/],[`address`,/(^|_)(address|addr|street|postcode|post_code|postal_code|zip|zip_code)(_?\d)?(_|$)/],[`health`,/(^|_)(diagnosis|icd|medication|prescription|blood_type|allerg(y|ies)|medical|patient)(_|$)/],[`demographic`,/(^|_)(gender|sex|race|ethnicity|religion|nationality|marital_status|sexual_orientation|disability)(_|$)/],[`name`,/(^|_)((first|last|full|middle|given|family|sur|maiden)_?name|customer_name|contact_name|person_name|username)(_|$)/]]}));function EV(e){let{table:t,columns:n,purpose:r,onDecide:i}=e,a=(0,OV.useId)(),o=e=>e.action??(e.category?CV[e.category]:`keep`),[s,c]=(0,OV.useState)(()=>Object.fromEntries(n.map(e=>[e.name,o(e)]))),[l,u]=(0,OV.useState)(!1),[d,f]=(0,OV.useState)(e.decided),p=e.decided??d,m=e=>p?.columns.find(t=>t.name===e.name)?.action??s[e.name]??`keep`,h=n.filter(e=>e.category),g=h.filter(e=>m(e)===`keep`);return(0,DV.jsxs)(`section`,{className:[`sf-pii`,e.className].filter(Boolean).join(` `),"aria-labelledby":`${a}-title`,children:[(0,DV.jsxs)(`header`,{children:[(0,DV.jsxs)(`p`,{className:`sf-plan-review-title`,id:`${a}-title`,children:[`Personal data in `,t]}),(0,DV.jsxs)(`p`,{className:`sf-plan-review-summary`,children:[h.length===0?`No column was flagged.`:`${h.length} of ${n.length} columns may hold personal data.`,` `,r??``]}),(0,DV.jsx)(`p`,{className:`sf-plan-review-by`,children:`Flags are suggestions and can miss a column. Check the ones left unflagged too.`})]}),(0,DV.jsx)(`div`,{className:`sf-pii-scroll`,children:(0,DV.jsxs)(`table`,{className:`sf-pii-table`,children:[(0,DV.jsx)(`thead`,{children:(0,DV.jsxs)(`tr`,{children:[(0,DV.jsx)(`th`,{scope:`col`,children:`Column`}),(0,DV.jsx)(`th`,{scope:`col`,children:`May hold`}),(0,DV.jsx)(`th`,{scope:`col`,children:`Treatment`})]})}),(0,DV.jsx)(`tbody`,{children:n.map(e=>(0,DV.jsxs)(`tr`,{"data-flagged":e.category?``:void 0,children:[(0,DV.jsxs)(`th`,{scope:`row`,children:[(0,DV.jsx)(`span`,{className:`sf-pii-name`,children:e.name}),e.type&&(0,DV.jsxs)(`span`,{className:`sf-pii-type`,children:[` `,e.type]})]}),(0,DV.jsx)(`td`,{children:e.category?(0,DV.jsxs)(DV.Fragment,{children:[(0,DV.jsxs)(`span`,{className:`sf-pii-flag`,children:[`◆ `,xV[e.category]]}),(0,DV.jsx)(`span`,{className:`sf-pii-basis`,children:kV[e.basis??`name`]})]}):(0,DV.jsx)(`span`,{className:`sf-pii-basis`,children:`Not flagged`})}),(0,DV.jsx)(`td`,{children:(0,DV.jsx)(`select`,{className:`sf-input`,"aria-label":`Treatment for ${e.name}`,value:m(e),disabled:p!==void 0,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),children:AV.map(e=>(0,DV.jsx)(`option`,{value:e,children:SV[e]},e))})})]},e.name))})]})}),g.length>0&&(0,DV.jsxs)(`p`,{className:`sf-pii-warning`,role:`note`,children:[`▲ `,g.length===1?`${g[0].name} is flagged and will be kept as is.`:`${g.length} flagged columns will be kept as is: ${g.map(e=>e.name).join(`, `)}.`]}),p?(0,DV.jsxs)(`p`,{className:`sf-plan-review-outcome`,role:`status`,children:[`Decision recorded for `,p.columns.length,` columns.`]}):(0,DV.jsxs)(`footer`,{className:`sf-plan-review-actions`,children:[(0,DV.jsxs)(`label`,{className:`sf-pii-confirm`,children:[(0,DV.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,DV.jsx)(`span`,{children:`I have checked every column and may decide how this data is handled.`})]}),(0,DV.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:!l,onClick:()=>{let e={table:t,confirmed:!0,columns:n.map(e=>({name:e.name,...e.category?{category:e.category}:{},action:m(e)}))};f(e),i(e)},children:`Record decision`})]})]})}var DV,OV,kV,AV,jV=n((()=>{DV=HA(),OV=jM(),TV(),kV={name:`Guessed from the column name`,values:`Found by scanning values`,person:`Marked by a person`},AV=Object.keys(SV)}));function MV({label:e,steps:t,className:n}){let r=t.filter(e=>e.status===`done`||e.status===`skipped`).length;return(0,NV.jsxs)(`section`,{className:[`sf-flow`,n].filter(Boolean).join(` `),"aria-label":e,children:[(0,NV.jsxs)(`p`,{className:`sf-flow-head`,children:[(0,NV.jsx)(`span`,{className:`sf-flow-label`,children:e}),(0,NV.jsx)(`span`,{className:`sf-flow-count`,children:z(`flow.count`,{done:r,total:t.length})})]}),(0,NV.jsx)(`ol`,{className:`sf-flow-steps`,children:t.map(e=>(0,NV.jsxs)(`li`,{className:`sf-flow-step`,"data-status":e.status,"aria-current":e.status===`current`||e.status===`waiting`?`step`:void 0,children:[(0,NV.jsx)(`span`,{className:`sf-flow-mark`,"aria-hidden":`true`,children:PV[e.status].mark}),(0,NV.jsxs)(`span`,{className:`sf-flow-body`,children:[(0,NV.jsx)(`span`,{className:`sf-flow-title`,children:e.title}),(0,NV.jsx)(`span`,{className:`sf-flow-status`,children:z(PV[e.status].text)}),e.detail&&(0,NV.jsx)(`span`,{className:`sf-flow-detail`,children:e.detail})]})]},e.id))})]})}var NV,PV,FV=n((()=>{NV=HA(),BA(),PV={done:{mark:`✓`,text:`flow.done`},current:{mark:`●`,text:`flow.current`},waiting:{mark:`‖`,text:`flow.waiting`},pending:{mark:`○`,text:`flow.pending`},failed:{mark:`✕`,text:`flow.failed`},skipped:{mark:`–`,text:`flow.skipped`}}}));function IV({title:e,outcome:t,summary:n,ranAt:r,ranBy:i,approvedBy:a=[],sql:o,changes:s=[],undo:c,onUndo:l,now:u=Date.now,className:d}){let[f,p]=(0,RV.useState)(!1),m=c?.until?Date.parse(c.until)<=u():!1,h=zV[t];return(0,LV.jsxs)(`section`,{className:[`sf-receipt`,d].filter(Boolean).join(` `),"aria-label":e,"data-outcome":t,children:[(0,LV.jsxs)(`p`,{className:`sf-receipt-head`,children:[(0,LV.jsx)(`span`,{className:`sf-receipt-mark`,"aria-hidden":`true`,children:h.mark}),(0,LV.jsx)(`span`,{className:`sf-receipt-title`,children:e}),(0,LV.jsx)(`span`,{className:`sf-receipt-status`,children:z(h.text)})]}),n&&(0,LV.jsx)(`p`,{className:`sf-receipt-summary`,children:n}),(0,LV.jsxs)(`dl`,{className:`sf-receipt-facts`,children:[(r||i)&&(0,LV.jsxs)(LV.Fragment,{children:[(0,LV.jsx)(`dt`,{children:z(`receipt.ran`)}),(0,LV.jsx)(`dd`,{children:[BV(r),i?z(`receipt.by`,{who:i}):``].filter(Boolean).join(` `)})]}),(0,LV.jsx)(`dt`,{children:z(`receipt.approved`)}),(0,LV.jsx)(`dd`,{children:a.length===0?z(`receipt.noApproval`):(0,LV.jsx)(`ul`,{children:a.map((e,t)=>(0,LV.jsxs)(`li`,{children:[e.by,e.at?`, ${BV(e.at)}`:``,e.reason?`: “${e.reason}”`:``]},`${e.by}-${t}`))})})]}),s.length>0&&(0,LV.jsxs)(`table`,{className:`sf-receipt-changes`,children:[(0,LV.jsx)(`caption`,{className:`sf-a2-visually-hidden`,children:z(`receipt.whatChanged`)}),(0,LV.jsx)(`thead`,{children:(0,LV.jsxs)(`tr`,{children:[(0,LV.jsx)(`th`,{scope:`col`,children:z(`receipt.what`)}),(0,LV.jsx)(`th`,{scope:`col`,children:z(`receipt.before`)}),(0,LV.jsx)(`th`,{scope:`col`,children:z(`receipt.after`)})]})}),(0,LV.jsx)(`tbody`,{children:s.map(e=>(0,LV.jsxs)(`tr`,{children:[(0,LV.jsx)(`th`,{scope:`row`,children:e.label}),(0,LV.jsx)(`td`,{children:e.before??`–`}),(0,LV.jsx)(`td`,{children:e.after})]},e.label))})]}),o&&(0,LV.jsx)(NL,{code:o,language:`sql`,label:z(`receipt.whatRan`)}),c?m?(0,LV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:z(`receipt.undoClosed`,{time:BV(c.until)})}):(0,LV.jsxs)(`div`,{className:`sf-receipt-undo`,children:[c.description&&(0,LV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:c.description}),c.until&&(0,LV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:z(`receipt.undoUntil`,{time:BV(c.until)})}),f?(0,LV.jsx)(`p`,{className:`sf-receipt-undo-note`,role:`status`,children:z(`receipt.undoRequested`)}):l&&(0,LV.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{p(!0),l()},children:c.label})]}):(0,LV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:z(`receipt.cannotUndo`)})]})}var LV,RV,zV,BV,VV=n((()=>{LV=HA(),RV=jM(),BA(),zL(),zV={done:{mark:`✓`,text:`receipt.done`},partial:{mark:`◐`,text:`receipt.partial`},failed:{mark:`✕`,text:`receipt.failed`}},BV=e=>{if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:MA({dateStyle:`medium`,timeStyle:`short`}).format(new Date(t))}}));function HV(e){let t=(0,qV.useContext)(JV);return e??t}function UV(e,t){return ym(oS,{id:e,fields:t.map(e=>({name:e.name,label:e.label,type:YV[e.type],required:e.required??!1,options:e.options??[],min:e.min,max:e.max,maxLength:e.maxLength,pattern:e.pattern??``,help:e.help??``,visibleWhen:QS(e.visibleWhen)}))})}function WV({field:e,value:t,onChange:n,error:r,disabled:i}){let a=(0,qV.useId)(),o=[e.help?`${a}-help`:``,r?`${a}-error`:``].filter(Boolean).join(` `)||void 0,s={id:a,name:e.name,disabled:i,"aria-invalid":r?!0:void 0,"aria-describedby":o,required:e.required},c=t==null?``:String(t),l;switch(e.type){case`longtext`:l=(0,KV.jsx)(`textarea`,{...s,className:`sf-input sf-form-textarea`,value:c,maxLength:e.maxLength,placeholder:e.placeholder,onChange:e=>n(e.target.value)});break;case`number`:case`integer`:l=(0,KV.jsx)(`input`,{...s,className:`sf-input`,type:`number`,inputMode:e.type===`integer`?`numeric`:`decimal`,value:c,min:e.min,max:e.max,step:e.step??(e.type===`integer`?1:`any`),placeholder:e.placeholder,onChange:e=>n(e.target.value===``?``:Number(e.target.value))});break;case`boolean`:return(0,KV.jsxs)(`div`,{className:`sf-form-field sf-form-check`,children:[(0,KV.jsx)(`input`,{...s,required:void 0,type:`checkbox`,checked:t===!0,onChange:e=>n(e.target.checked)}),(0,KV.jsx)(`label`,{htmlFor:a,children:e.label}),e.help&&(0,KV.jsx)(`p`,{id:`${a}-help`,className:`sf-form-help`,children:e.help}),r&&(0,KV.jsx)(`p`,{id:`${a}-error`,className:`sf-form-error`,role:`alert`,children:r})]});case`date`:l=(0,KV.jsx)(`input`,{...s,className:`sf-input`,type:`date`,value:c,onChange:e=>n(e.target.value)});break;case`datetime`:l=(0,KV.jsx)(`input`,{...s,className:`sf-input`,type:`datetime-local`,value:c.replace(/Z$/,``).slice(0,16),onChange:e=>n(e.target.value?new Date(e.target.value).toISOString():``)});break;case`choice`:l=(e.options?.length??0)<=4?(0,KV.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`${a}-label`,"aria-describedby":o,className:`sf-form-choices`,children:(e.options??[]).map(t=>(0,KV.jsxs)(`label`,{className:`sf-form-choice`,children:[(0,KV.jsx)(`input`,{type:`radio`,name:`${a}-${e.name}`,value:t,checked:c===t,disabled:i,onChange:()=>n(t)}),t]},t))}):(0,KV.jsxs)(`select`,{...s,className:`sf-input`,value:c,onChange:e=>n(e.target.value),children:[(0,KV.jsx)(`option`,{value:``,children:z(`form.choose`)}),(e.options??[]).map(e=>(0,KV.jsx)(`option`,{value:e,children:e},e))]});break;default:l=(0,KV.jsx)(`input`,{...s,className:`sf-input`,type:`text`,value:c,maxLength:e.maxLength,placeholder:e.placeholder,onChange:e=>n(e.target.value)})}return(0,KV.jsxs)(`div`,{className:`sf-form-field`,children:[(0,KV.jsxs)(`label`,{id:`${a}-label`,htmlFor:e.type===`choice`&&(e.options?.length??0)<=4?void 0:a,className:`sf-form-label`,children:[e.label,e.required&&(0,KV.jsxs)(`span`,{className:`sf-form-required`,children:[` `,z(`form.required`)]})]}),l,e.help&&(0,KV.jsx)(`p`,{id:`${a}-help`,className:`sf-form-help`,children:e.help}),r&&(0,KV.jsx)(`p`,{id:`${a}-error`,className:`sf-form-error`,role:`alert`,children:r})]})}function GV(e){let{formId:t,fields:n,title:r,description:i,submitLabel:a=z(`form.submit`),onSubmit:o,children:s}=e,c=HV(e.forms),[l,u]=(0,qV.useState)({}),d=e.values??l,[f,p]=(0,qV.useState)({}),[m,h]=(0,qV.useState)({kind:`idle`}),g=(0,qV.useRef)(0),_=(0,qV.useId)(),v=t=>{e.values===void 0&&u(t),e.onValuesChange?.(t)},y=(e,t)=>{v({...d,[e]:t}),f[e]&&p(({[e]:t,...n})=>n)},b=UV(t,n),x=n.filter((e,t)=>$S(b,b.fields[t],d));return(0,KV.jsxs)(`form`,{className:[`sf-form`,e.className].filter(Boolean).join(` `),onSubmit:async n=>{if(n.preventDefault(),m.kind===`sending`)return;let r=eC(b,d);if(r.errors.length>0)p(Object.fromEntries(r.errors.map(e=>[e.field,e.message]))),h({kind:`rejected`,text:r.errors.length===1?z(`form.needsAttentionOne`):z(`form.needsAttention`,{count:r.errors.length})});else if(p({}),!c)o?.({values:r.values}),h({kind:`saved`,text:z(`form.sent`)}),e.resetOnSubmit!==!1&&v({});else{h({kind:`sending`});try{let n=await c.submit({formId:t,values:r.values,idempotencyKey:`${t}-${Date.now()}-${g.current++}`});if(!n.submission){p(Object.fromEntries(n.fieldErrors.map(e=>[e.field,e.message]))),h({kind:`rejected`,text:n.message||z(`form.notSaved`)});return}h({kind:`saved`,text:n.message||z(`form.saved`)}),o?.({submissionId:n.submission.id,values:n.submission.values??r.values}),e.resetOnSubmit!==!1&&v({})}catch(e){h({kind:`rejected`,text:z(`form.couldNotSend`,{error:e instanceof Error?e.message:String(e)})})}}},noValidate:!0,"aria-labelledby":r?_:void 0,children:[r&&(0,KV.jsx)(`p`,{id:_,className:`sf-form-title`,children:r}),i&&(0,KV.jsx)(`p`,{className:`sf-form-help`,children:i}),s??x.map(e=>(0,KV.jsx)(WV,{field:e,value:d[e.name],error:f[e.name],disabled:m.kind===`sending`,onChange:t=>y(e.name,t)},e.name)),s&&Object.keys(f).length>0&&(0,KV.jsx)(`ul`,{className:`sf-form-error`,role:`alert`,children:Object.entries(f).map(([e,t])=>(0,KV.jsxs)(`li`,{children:[n.find(t=>t.name===e)?.label??e,`: `,t]},e))}),(0,KV.jsxs)(`div`,{className:`sf-form-actions`,children:[(0,KV.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:m.kind===`sending`,"aria-busy":m.kind===`sending`||void 0,children:m.kind===`sending`?z(`form.sending`):a}),(0,KV.jsx)(`p`,{className:m.kind===`rejected`?`sf-form-error`:`sf-form-status`,role:`status`,"aria-live":`polite`,children:m.kind===`saved`||m.kind===`rejected`?m.text:``})]}),(0,KV.jsx)(`p`,{className:`sf-form-help`,children:z(c?`form.connected`:`form.notConnected`)})]})}var KV,qV,JV,YV,XV=n((()=>{KV=HA(),zb(),rw(),vS(),qV=jM(),BA(),JV=(0,qV.createContext)(void 0),YV={text:cS.TEXT,longtext:cS.TEXT,number:cS.NUMBER,integer:cS.INTEGER,boolean:cS.BOOLEAN,date:cS.DATE,datetime:cS.DATETIME,choice:cS.CHOICE}}));function ZV(e,t){if(t===0)return[];if(!e||e.length!==t||e.some(e=>typeof e!=`number`||!Number.isFinite(e)||e<=0))return pH(t);let n=e.map(e=>Math.max(fH,e)),r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)}function QV(e,t){let n=t?new Set(t):void 0,r=[...new Set((Array.isArray(e?.hidden)?e.hidden:[]).filter(e=>typeof e==`string`&&(!n||n.has(e))))],i=new Set(r),a=Array.isArray(e?.columns)?e.columns:[],o=new Map;a.forEach((t,n)=>{Array.isArray(t)&&t.forEach((t,r)=>o.set(String(t),e?.rowHeights?.[n]?.[r]??NaN))});let s=[],c=[];a.forEach((t,r)=>{if(!Array.isArray(t))return;let a=[];for(let e of t)typeof e!=`string`||i.has(e)||n&&!n.has(e)||(i.add(e),a.push(e));a.length!==0&&(s.push(a),c.push(e?.columnWidths?.[r]??NaN))});let l=s.length!==a.length;for(let e of t??[]){if(i.has(e))continue;i.add(e);let t=s[s.length-1];t&&t.length<4?t.push(e):s.length<4?(s.push([e]),l=!0):(t??(s[0]=[])).push(e)}s.length>4&&(s=[...s.slice(0,3),s.slice(3).flat()],l=!0);let u=new Set(s.flat()),d={};for(let[t,n]of Object.entries(e?.places&&typeof e.places==`object`?e.places:{}))r.includes(t)&&n&&Number.isInteger(n.column)&&Number.isInteger(n.row)&&n.column>=0&&n.row>=0&&(d[t]={column:n.column,row:n.row,...n.sole?{sole:!0}:{}});let f=[...new Set((Array.isArray(e?.collapsed)?e.collapsed:[]).filter(e=>typeof e==`string`&&u.has(e)))];for(let e of s)e.every(e=>f.includes(e))&&(f=f.filter(t=>t!==e[0]));return{columns:s,columnWidths:ZV(l?void 0:c,s.length),rowHeights:s.map(e=>ZV(e.map(e=>o.get(e)??NaN),e.length)),hidden:r,collapsed:f,places:d}}function $V(e,t){let n=rH(e,t);if(!n)return e;let r=e.collapsed.filter(e=>e!==t),i=e.columns[n.column].filter(e=>!r.includes(e)),a=i.filter(e=>e!==t).slice(0,Math.max(0,i.length-2));return QV({...e,collapsed:[...r,...a]})}function eH(e,t){return $V(QV(e),t)}function tH(e,t){let n=QV(e),r=rH(n,t);return!r||n.collapsed.includes(t)||n.columns[r.column].filter(e=>!n.collapsed.includes(e)).length<=1?n:QV({...n,collapsed:[...n.collapsed,t]})}function nH(e,t){let n=Math.max(fH,Math.min(.28,1/(e.length+1))),r=e.map(e=>e*(1-n));return r.splice(t,0,n),r}function rH(e,t){for(let n=0;n<e.columns.length;n++){let r=e.columns[n].indexOf(t);if(r!==-1)return{column:n,row:r}}}function iH(e,t,n,r){let i=QV(e),a=rH(i,t);if(!a||n<0||n>=i.columns.length||a.column===n&&(a.row===r||a.row===r-1)||a.column!==n&&i.columns[n].length>=4)return i;let o=i.columns.map(e=>[...e]);o[a.column].splice(a.row,1);let s=a.column===n&&a.row<r?r-1:r;return o[n].splice(Math.max(0,Math.min(s,o[n].length)),0,t),$V(QV({...i,columns:o,rowHeights:void 0}),t)}function aH(e,t,n){let r=QV(e),i=rH(r,t);if(!i)return r;let a=r.columns[i.column].length===1;if(!a&&r.columns.length>=4)return r;let o=r.columns.map(e=>[...e]);o[i.column].splice(i.row,1);let s=o.filter(e=>e.length>0),c=a&&i.column<n?n-1:n;s.splice(Math.max(0,Math.min(c,s.length)),0,[t]);let l=Math.max(0,Math.min(c,s.length-1));return $V(QV({columns:s,hidden:r.hidden,collapsed:r.collapsed,places:r.places,...a?{}:{columnWidths:nH(r.columnWidths,l)}}),t)}function oH(e,t,n){let r=QV(e),i=rH(r,t);if(!i)return r;if(n===`up`)return i.row===0?r:iH(r,t,i.column,i.row-1);if(n===`down`)return i.row>=r.columns[i.column].length-1?r:iH(r,t,i.column,i.row+2);let a=i.column+(n===`left`?-1:1);return a<0?r.columns[i.column].length>1?aH(r,t,0):r:a>=r.columns.length?r.columns[i.column].length>1?aH(r,t,r.columns.length):r:iH(r,t,a,r.columns[a].length)}function sH(e,t){let n=QV(e),r=rH(n,t);return!r||n.columns.flat().length<=1?n:QV({...n,columns:n.columns.map(e=>e.filter(e=>e!==t)),hidden:[...n.hidden,t],places:{...n.places,[t]:{...r,...n.columns[r.column].length===1?{sole:!0}:{}}},rowHeights:void 0})}function cH(e,t){let n=QV(e);if(!n.hidden.includes(t))return n;let r=n.hidden.filter(e=>e!==t),{[t]:i,...a}=n.places,o=n.columns.map(e=>[...e]),s={...n,hidden:r,places:a,rowHeights:void 0};if(i?.sole&&o.length<4){let e=Math.min(i.column,o.length);return o.splice(e,0,[t]),$V(QV({...s,columns:o,columnWidths:nH(n.columnWidths,e)}),t)}let c=i&&!i.sole?o[i.column]:void 0;if(c&&c.length<4)return c.splice(Math.min(i.row,c.length),0,t),$V(QV({...s,columns:o}),t);let l=o[o.length-1];return l&&l.length<2?(l.push(t),$V(QV({...s,columns:o}),t)):o.length<4?$V(QV({...s,columns:[...o,[t]],columnWidths:nH(n.columnWidths,o.length)}),t):((o.filter(e=>e.length<4).sort((e,t)=>e.length-t.length)[0]??l??(o[0]=[])).push(t),$V(QV({...s,columns:o}),t))}function lH(e,t,n){let r=e[t],i=e[t+1];if(r===void 0||i===void 0)return e;let a=Math.max(fH-r,Math.min(i-fH,n));if(r+i<.24)return e;let o=[...e];return o[t]=r+a,o[t+1]=i-a,o}function uH(e,t,n){let r=QV(e);return{...r,columnWidths:lH(r.columnWidths,t,n)}}function dH(e,t,n,r){let i=QV(e),a=i.rowHeights[t];return a?{...i,rowHeights:i.rowHeights.map((e,i)=>i===t?lH(a,n,r):e)}:i}var fH,pH,mH=n((()=>{fH=.12,pH=e=>Array.from({length:e},()=>1/e)}));function hH({icon:e,title:t}){return typeof e==`string`&&e in _H?(0,gH.jsx)(`svg`,{className:`sf-workspace-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,gH.jsx)(`path`,{d:_H[e]})}):e!=null&&typeof e!=`string`?(0,gH.jsx)(`span`,{className:`sf-workspace-icon`,children:e}):(0,gH.jsx)(`span`,{className:`sf-workspace-icon sf-workspace-icon-letter`,"aria-hidden":`true`,children:(t.trim()[0]??`?`).toUpperCase()})}var gH,_H,vH=n((()=>{gH=HA(),_H={surface:`M4 5h16v14H4z M4 10h16 M10 10v9`,agent:`M4 5h16v11H10l-5 4v-4H4z`,components:`M4 5h16v4H4z M4 12h11v3H4z M4 18h14v2H4z`,table:`M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14`,code:`M9 4c-2 0-3 1-3 3v2c0 1.2-.8 2.2-2 3 1.2.8 2 1.8 2 3v2c0 2 1 3 3 3 M15 4c2 0 3 1 3 3v2c0 1.2.8 2.2 2 3-1.2.8-2 1.8-2 3v2c0 2-1 3-3 3`,data:`M5 6c0-1.7 3.1-3 7-3s7 1.3 7 3-3.1 3-7 3-7-1.3-7-3z M5 6v12c0 1.7 3.1 3 7 3s7-1.3 7-3V6 M5 12c0 1.7 3.1 3 7 3s7-1.3 7-3`,history:`M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16z M12 8v4l3 2`,save:`M5 4h11l3 3v13H5z M8 4v5h7V4 M8 20v-6h8v6`,search:`M11 5a6 6 0 1 0 0 12 6 6 0 0 0 0-12z M20 20l-4.6-4.6`,map:`M6 4a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M18 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 16a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M8 6.4l8 1.2 M6.8 7.9l2.6 8.2 M16.8 9.6l-5.6 6.8`,chart:`M4 4v16h16 M8 16v-5 M12 16V8 M16 16v-9`,grid:`M4 4h7v7H4z M13 4h7v7h-7z M4 13h7v7H4z M13 13h7v7h-7z`,settings:`M4 7h9 M19 7h1 M4 17h3 M13 17h7 M16 5a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 15a2 2 0 1 0 0 4 2 2 0 0 0 0-4z`,note:`M7 3h8l4 4v14H7z M15 3v4h4 M10 12h6 M10 16h6`,folder:`M3 6h6l2 2h10v11H3z`,person:`M12 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M5.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5`,bell:`M18 16v-5a6 6 0 0 0-12 0v5l-2 2h16z M10 21a2 2 0 0 0 4 0`,people:`M9 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M2.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5 M16 4.4a3.5 3.5 0 0 1 0 6.2 M18 14c2 .9 3.5 3.2 3.5 6`},Object.keys(_H)}));function yH({label:e,panels:t,layout:n,defaultLayout:r,onLayoutChange:i,rail:a=`right`,railLabels:o,defaultRailLabels:s=!1,onRailLabelsChange:c,height:l=`32rem`,className:u}){let d=(0,xH.useContext)(SH),[f,p]=(0,xH.useState)(s),m=!d&&(o??f),h=(0,xH.useRef)(null),[g,_]=(0,xH.useState)(),v=e=>t=>{let n=h.current?.getBoundingClientRect(),r=t.currentTarget.closest(`.sf-workspace-rail`);if(!n||!r)return;let i=t.currentTarget.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.height>=a.width?r.getAttribute(`data-side`)===`left`?{top:i.top+i.height/2-n.top,left:a.right-n.left,transform:`translate(0, -50%)`}:{top:i.top+i.height/2-n.top,right:n.right-a.left,transform:`translate(0, -50%)`}:{top:i.bottom-n.top,left:i.left+i.width/2-n.left,transform:`translate(-50%, 0)`,marginTop:`var(--sf-space-1)`};_({text:e,style:o})},y=()=>_(void 0),b=e=>({onPointerEnter:v(e),onPointerLeave:y,onFocus:v(e),onBlur:y,onKeyDown:e=>{e.key===`Escape`&&y()}}),x=(0,xH.useMemo)(()=>t.map(e=>e.id),[t]),S=x.join(`\0`),[C,w]=(0,xH.useState)(r),T=(0,xH.useMemo)(()=>QV(n??C,x),[n,C,S]),E=(0,xH.useRef)(T);E.current=T;let D=(0,xH.useCallback)(e=>{JSON.stringify(e)!==JSON.stringify(E.current)&&(w(e),i?.(e))},[i]),O=(0,xH.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),k=(0,xH.useRef)(null),[ee,te]=(0,xH.useState)(),[A,ne]=(0,xH.useState)(),[re,ie]=(0,xH.useState)(``),ae=(0,xH.useRef)(void 0),oe=()=>{ae.current=void 0,te(void 0),ne(void 0)},se=e=>{let t=ae.current;t&&D(e.kind===`row`?iH(E.current,t,e.column,e.row):aH(E.current,t,e.at)),oe()},[ce,le]=(0,xH.useState)(),ue=(0,xH.useRef)(void 0),de=(e,t,n)=>{if(e.button!==0||e.target.closest(`button, select, input, a`))return;let r={x:e.clientX,y:e.clientY},i=!1,a=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),window.removeEventListener(`keydown`,l,!0);let t=ue.current;ue.current=void 0,le(void 0),i&&e&&t?se(t):oe()},o=e=>{if(!i){if(Math.hypot(e.clientX-r.x,e.clientY-r.y)<wH)return;i=!0,ae.current=t,te(t)}e.preventDefault(),le({x:e.clientX,y:e.clientY,title:n});let a=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-drop]`),o=a&&a.closest(`.sf-workspace`)===h.current?JSON.parse(a.dataset.drop??`null`):null;ue.current=o??void 0,ne(e=>o?CH(e,o)?e:o:void 0)},s=()=>a(!0),c=()=>a(!1),l=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(!1))};window.addEventListener(`pointermove`,o,{passive:!1}),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),window.addEventListener(`keydown`,l,!0)},fe=(e,t,n)=>(0,bH.jsx)(`div`,{className:t,"data-drop":JSON.stringify(e),"data-over":CH(A,e)||void 0,"aria-hidden":`true`,children:(0,bH.jsx)(`span`,{children:n})}),pe=(e,t,n,r)=>(0,bH.jsx)(`div`,{className:`sf-workspace-divider`,role:`separator`,tabIndex:0,"aria-orientation":e,"aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n*100),onPointerDown:t=>{let n=(e===`vertical`?k.current:t.currentTarget.closest(`.sf-workspace-column`))?.getBoundingClientRect(),i=e===`vertical`?n?.width:n?.height;if(!i)return;t.preventDefault(),t.currentTarget.setPointerCapture?.(t.pointerId);let a=e===`vertical`?t.clientX:t.clientY,o=t=>{let n=e===`vertical`?t.clientX:t.clientY;r((n-a)/i),a=n},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},onKeyDown:t=>{let n=e===`vertical`?`ArrowLeft`:`ArrowUp`,i=e===`vertical`?`ArrowRight`:`ArrowDown`;(t.key===n||t.key===i)&&(t.preventDefault(),r(t.key===i?TH:-.04))}}),me=(e,t,n)=>{let r=E.current,i=n===`hide`?sH(r,e):n===`new-left`?aH(r,e,0):n===`new-right`?aH(r,e,r.columns.length):oH(r,e,n),a=rH(i,e);ie(JSON.stringify(i)===JSON.stringify(r)?`${t} cannot move that way.`:a?`${t} is now in column ${a.column+1} of ${i.columns.length}, place ${a.row+1}.`:`${t} is hidden. The panels rail brings it back.`),D(i)},he=mP(),ge=(e,t)=>{let n=JSON.stringify(E.current),r=(r,i,a)=>({label:r,disabled:JSON.stringify(a)===n,onSelect:()=>me(e,t,i)}),i=E.current;return[r(`Move left`,`left`,oH(i,e,`left`)),r(`Move right`,`right`,oH(i,e,`right`)),r(`Move up`,`up`,oH(i,e,`up`)),r(`Move down`,`down`,oH(i,e,`down`)),{separator:!0},r(`To a new column on the left`,`new-left`,aH(i,e,0)),r(`To a new column on the right`,`new-right`,aH(i,e,i.columns.length)),{separator:!0},r(`Hide`,`hide`,sH(i,e))]},j=T.columns.length,_e=a&&(0,bH.jsxs)(`div`,{className:`sf-workspace-rail`,role:`toolbar`,"aria-label":`${e}: show or hide panels`,"aria-orientation":`vertical`,"data-side":a,"data-labels":m||void 0,children:[t.map(e=>{let t=!T.hidden.includes(e.id),n=t&&T.columns.flat().length<=1;return(0,bH.jsxs)(`button`,{type:`button`,className:`sf-workspace-rail-button`,"aria-pressed":t,"aria-label":e.title,"aria-disabled":n||void 0,...b(n?`${e.title}: the only panel showing`:t?`Hide ${e.title}`:`Show ${e.title}`),onClick:()=>{n||(_(void 0),ie(t?`${e.title} is hidden.`:`${e.title} is showing.`),D(t?sH(E.current,e.id):cH(E.current,e.id)))},children:[(0,bH.jsx)(hH,{icon:e.icon,title:e.title}),m&&(0,bH.jsx)(`span`,{className:`sf-workspace-rail-label`,children:e.shortTitle??e.title})]},e.id)}),!d&&(0,bH.jsx)(`button`,{type:`button`,className:`sf-workspace-rail-size`,"aria-pressed":m,"aria-label":`Show panel names on the rail`,...b(m?`Icons only`:`Show names`),onClick:()=>{_(void 0),p(!m),c?.(!m)},children:(0,bH.jsx)(`span`,{"aria-hidden":`true`,children:a===`left`===m?`«`:`»`})})]});return(0,bH.jsxs)(`div`,{ref:h,className:`sf-workspace sf-container${u?` ${u}`:``}`,role:`group`,"aria-label":e,style:{"--sf-workspace-height":typeof l==`number`?`${l}px`:l},children:[(0,bH.jsxs)(`div`,{className:`sf-workspace-frame`,children:[a===`left`&&_e,(0,bH.jsxs)(`div`,{className:`sf-workspace-grid`,ref:k,"data-dragging":ee?!0:void 0,children:[ee&&j<4&&fe({kind:`column`,at:0},`sf-workspace-drop-column`,`New column`),T.columns.map((e,t)=>(0,bH.jsxs)(`div`,{className:`sf-workspace-column-wrap`,style:{flexGrow:T.columnWidths[t],flexBasis:0},children:[(0,bH.jsx)(`div`,{className:`sf-workspace-column`,children:e.map((n,r)=>{let i=O.get(n);if(!i)return null;let a=T.collapsed.includes(n),o=T.collapsed.includes(e[r+1]??``),s=ee&&(ae.current===void 0||rH(T,ee)?.column===t||e.length<4);return(0,bH.jsxs)(`div`,{className:`sf-workspace-cell`,"data-folded":a||void 0,style:a?void 0:{flexGrow:T.rowHeights[t]?.[r]??1,flexBasis:0},children:[s&&fe({kind:`row`,column:t,row:r},`sf-workspace-drop-row`,`Drop here`),(0,bH.jsxs)(`section`,{className:`sf-workspace-panel`,"aria-label":i.title,"data-fill":i.fill||void 0,"data-dragging":ee===n||void 0,"data-folded":a||void 0,children:[(0,bH.jsxs)(`header`,{className:`sf-workspace-panel-head`,onPointerDown:e=>de(e,n,i.title),onContextMenu:e=>he.open(e,`Move ${i.title}`,ge(n,i.title)),children:[(0,bH.jsx)(`span`,{className:`sf-workspace-grip`,"aria-hidden":`true`,children:`⠿`}),e.length>1&&(0,bH.jsx)(`button`,{type:`button`,className:`sf-workspace-fold`,"aria-expanded":!a,"aria-label":a?`Open ${i.title}`:`Fold ${i.title} to its heading`,onClick:()=>{ie(a?`${i.title} is open.`:`${i.title} is folded.`),D(a?eH(E.current,n):tH(E.current,n))},children:(0,bH.jsx)(`span`,{"aria-hidden":`true`,children:a?`▸`:`▾`})}),(0,bH.jsx)(`h3`,{className:`sf-workspace-panel-title`,children:i.title}),(0,bH.jsx)(`button`,{type:`button`,className:`sf-workspace-menu-button`,"aria-label":`Move ${i.title}`,"aria-haspopup":`menu`,onClick:e=>he.open(e,`Move ${i.title}`,ge(n,i.title)),children:(0,bH.jsx)(`span`,{"aria-hidden":`true`,children:`⋯`})})]}),(0,bH.jsx)(`div`,{className:`sf-workspace-panel-body`,hidden:a,children:(0,bH.jsx)(SH.Provider,{value:!0,children:i.content})})]}),!ee&&r<e.length-1&&!a&&!o&&pe(`horizontal`,`Resize ${i.title} and the panel below it`,T.rowHeights[t]?.[r]??.5,e=>D(dH(E.current,t,r,e))),ee&&r===e.length-1&&s&&fe({kind:`row`,column:t,row:e.length},`sf-workspace-drop-row`,`Drop here`)]},n)})}),t<j-1&&(ee?j<4&&fe({kind:`column`,at:t+1},`sf-workspace-drop-column`,`New column`):pe(`vertical`,`Resize column ${t+1} and column ${t+2}`,T.columnWidths[t]??.5,e=>D(uH(E.current,t,e))))]},e.join(`\0`))),ee&&j<4&&fe({kind:`column`,at:j},`sf-workspace-drop-column`,`New column`)]}),a===`right`&&_e]}),g&&(0,bH.jsx)(`div`,{className:`sf-workspace-tip`,"aria-hidden":`true`,style:g.style,children:g.text}),ce&&(0,bH.jsx)(`div`,{className:`sf-workspace-ghost`,"aria-hidden":`true`,style:{left:ce.x,top:ce.y},children:ce.title}),he.element,(0,bH.jsx)(`p`,{className:`sf-workspace-said`,role:`status`,children:re})]})}var bH,xH,SH,CH,wH,TH,EH=n((()=>{bH=HA(),xH=jM(),_P(),vH(),mH(),SH=(0,xH.createContext)(!1),CH=(e,t)=>!!e&&e.kind===t.kind&&(e.kind===`row`?e.column===t.column&&e.row===t.row:e.at===t.at),wH=6,TH=.04}));function DH(e,t,n=240){if(!e)return;let r=Math.max(e.top,0),i=Math.max(e.left,0),a=Math.min(e.left+e.width,t.width)-i,o=Math.min(e.top+e.height,t.height)-r;if(a>=n&&o>=n)return{top:r,left:i,width:a,height:o}}function OH(e,t,n){if(!t.top&&!t.left)return e;let r=e??{top:0,left:0,width:n.width,height:n.height};return{top:r.top-t.top,left:r.left-t.left,width:r.width,height:r.height}}function kH(e){if(!e)return{top:0,left:0};let t=e.getBoundingClientRect(),n=getComputedStyle(e),r=t.top-Number.parseFloat(n.top),i=t.left-Number.parseFloat(n.left);return{top:Math.abs(r)>=.5?r:0,left:Math.abs(i)>=.5?i:0}}function AH(e){let[t,n]=(0,NH.useState)(()=>FH()?.matches??!1),[r,i]=(0,NH.useState)(!1);return(0,NH.useEffect)(()=>{let e=FH();if(!e)return;let t=()=>n(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,NH.useEffect)(()=>{let t=LH(e.current);if(!t||typeof ResizeObserver>`u`)return;let n=()=>{let e=t.getBoundingClientRect().width,n=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)||16;i(e>0&&e<IH*n)};n();let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[e]),t||r}function jH({label:e,groups:t,current:n,onSelect:r,pinned:i,defaultPinned:a=!0,onPinnedChange:o,header:s,footer:c,className:l}){let u=(0,NH.useId)(),[d,f]=(0,NH.useState)(a),p=(0,NH.useRef)(null),m=AH(p),h=(i??d)&&!m,[g,_]=(0,NH.useState)(!1),v=(0,NH.useRef)(null),y=(0,NH.useRef)(null),b=()=>document.getElementById(`${u}-open`),x=()=>{_(!1),requestAnimationFrame(()=>b()?.focus())},S=e=>{f(e),_(!1),o?.(e),e||requestAnimationFrame(()=>b()?.focus())},C=!h&&g,[w,T]=(0,NH.useState)(void 0);(0,NH.useLayoutEffect)(()=>{if(!C)return;let e=()=>{let e=LH(p.current)?.getBoundingClientRect(),t={width:window.innerWidth,height:window.innerHeight},n=OH(DH(e?{top:e.top,left:e.left,width:e.width,height:e.height}:void 0,t),kH(y.current),t);T(e=>e&&n&&e.top===n.top&&e.left===n.left&&e.width===n.width&&e.height===n.height?e:n)};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[C]);let E=!h&&w?{"--sf-sidenav-top":`${w.top}px`,"--sf-sidenav-left":`${w.left}px`,"--sf-sidenav-width":`${w.width}px`,"--sf-sidenav-height":`${w.height}px`}:void 0;(0,NH.useEffect)(()=>{C&&v.current?.querySelector(`.sf-sidenav-close`)?.focus()},[C]);let D=e=>{if(C){if(e.key===`Escape`)e.preventDefault(),x();else if(e.key===`Tab`&&v.current){let t=[...v.current.querySelectorAll(zH)],n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}}},O=e=>{r?.(e),C&&x()};return(0,MH.jsxs)(`div`,{ref:p,className:`sf-sidenav${l?` ${l}`:``}`,"data-pinned":h,"data-open":g||void 0,"data-narrow":m||void 0,style:E,onKeyDown:D,children:[!h&&(0,MH.jsx)(`button`,{id:`${u}-open`,type:`button`,className:`sf-sidenav-open`,"aria-expanded":g,"aria-controls":`${u}-panel`,"aria-label":`Show ${RH(e)}`,onClick:()=>_(!0),children:(0,MH.jsx)(rI,{icon:`menu`})}),(0,MH.jsxs)(`div`,{ref:y,className:`sf-sidenav-stage`,children:[C&&(0,MH.jsx)(`div`,{className:`sf-sidenav-backdrop`,"aria-hidden":`true`,onClick:x}),(0,MH.jsxs)(`div`,{id:`${u}-panel`,ref:v,className:`sf-sidenav-panel`,role:h?void 0:`dialog`,"aria-modal":C||void 0,"aria-label":h?void 0:RH(e),children:[(0,MH.jsxs)(`div`,{className:`sf-sidenav-top`,children:[(0,MH.jsx)(`div`,{className:`sf-sidenav-header`,children:s}),!m&&(0,MH.jsxs)(`button`,{type:`button`,className:`sf-sidenav-pin`,"aria-pressed":h,title:h?`Let the navigation fold away`:`Keep the navigation open`,onClick:()=>S(!h),children:[(0,MH.jsx)(rI,{icon:h?`fold`:`unfold`}),(0,MH.jsx)(`span`,{className:`sf-sidenav-pin-label`,children:h?`Fold away`:`Keep open`})]}),!h&&(0,MH.jsx)(`button`,{type:`button`,className:`sf-sidenav-close`,"aria-label":`Close ${RH(e)}`,onClick:x,children:(0,MH.jsx)(rI,{icon:`close`})})]}),(0,MH.jsx)(`nav`,{className:`sf-sidenav-nav`,"aria-label":e,children:t.map((e,t)=>(0,MH.jsxs)(`section`,{className:`sf-sidenav-group`,"aria-labelledby":e.label?`${u}-group-${t}`:void 0,children:[e.label&&(0,MH.jsx)(`h2`,{id:`${u}-group-${t}`,className:`sf-sidenav-group-label`,children:e.label}),(0,MH.jsx)(`ul`,{children:e.items.map(e=>(0,MH.jsx)(`li`,{children:e.href?(0,MH.jsx)(`a`,{href:e.href,"aria-current":e.id===n?`page`:void 0,onClick:()=>O(e.id),children:e.label}):(0,MH.jsx)(`button`,{type:`button`,"aria-current":e.id===n?`page`:void 0,onClick:()=>O(e.id),children:e.label})},e.id))})]},e.label??t))}),c&&(0,MH.jsx)(`div`,{className:`sf-sidenav-footer`,children:c})]})]})]})}var MH,NH,PH,FH,IH,LH,RH,zH,BH=n((()=>{MH=HA(),NH=jM(),uI(),PH=`(max-width: 40rem)`,FH=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(PH):void 0,IH=40,LH=e=>e?.closest(`.sf-container`)??void 0,RH=e=>/\bnavigation\s*$/i.test(e)?e.trim():`${e.trim()} navigation`,zH=`a[href], button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`})),VH=n((()=>{HA(),jM()})),HH=n((()=>{HA(),jM()}));function UH(e){let t=e.toLowerCase().replace(/\.(gz|zst)$/,``);if(t.endsWith(`.parquet`))return`parquet`;if(t.endsWith(`.csv`)||t.endsWith(`.tsv`))return`csv`;if(t.endsWith(`.json`)||t.endsWith(`.ndjson`)||t.endsWith(`.jsonl`))return`json`}function WH(e){if(e===void 0||!Number.isFinite(e))return``;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${r===0||n>=100?Math.round(n):n.toFixed(1)} ${t[r]}`}function GH(e,t,n=t,r=200){let i=e.listFiles?.bind(e);if(i)return{id:t,label:n,origin:`source`,async list(e,n){let a=await i({sourceId:t,path:e,pageSize:r,pageToken:n??``});return{items:a.entries.map(e=>({name:e.name,path:e.path,kind:e.kind===Px.FOLDER?`folder`:`file`,...e.sizeBytes===void 0?{}:{size:Number(e.sizeBytes)},...e.modifiedAt?{modified:e.modifiedAt}:{},...XH[e.format]?{format:XH[e.format]}:{},...e.table?{table:e.table}:{}})),...a.nextPageToken?{next:a.nextPageToken}:{},...a.truncated?{truncated:!0}:{}}}}}function KH(e,t,n){let r=Math.max(0,Number.parseInt(t??`0`,10)||0),i=r+n;return{items:e.slice(r,i),...i<e.length?{next:String(i)}:{}}}function qH(e,t=200){let n=e=>e.webkitRelativePath||e.name,r=e.filter(e=>!n(e).split(`/`).some(e=>e.startsWith(`.`))),i=n(r[0]??e[0]??new File([],`folder`)).split(`/`)[0]??`folder`;return{id:`local:${i}`,label:i,origin:`local`,async list(e,i){let a=e?`${e}/`:``,o=new Map,s=[];for(let e of r){let t=n(e);if(!t.startsWith(a))continue;let r=t.slice(a.length),i=r.indexOf(`/`);if(i>=0){let e=r.slice(0,i);o.has(e)||o.set(e,{name:e,path:`${a}${e}`,kind:`folder`})}else{let n=UH(e.name);s.push({name:e.name,path:t,kind:`file`,size:e.size,modified:new Date(e.lastModified).toISOString(),...n?{format:n}:{},file:e})}}return KH(ZH([...o.values(),...s]),i,t)}}}function JH(e,t=200){let n=e,r=new Map,i=async e=>{let t=n;for(let n of e.split(`/`).slice(1).filter(Boolean))t=await t.getDirectoryHandle(n);return t};return{id:`local:${n.name}`,label:n.name,origin:`local`,async list(e,a){let o=e||n.name,s=a?r.get(o):void 0;if(!s){let e=[];for await(let t of(await i(o)).values())if(!t.name.startsWith(`.`)){if(t.kind===`directory`)e.push({name:t.name,path:`${o}/${t.name}`,kind:`folder`});else{let n=await t.getFile(),r=UH(t.name);e.push({name:t.name,path:`${o}/${t.name}`,kind:`file`,size:n.size,modified:new Date(n.lastModified).toISOString(),...r?{format:r}:{},file:n})}}s=ZH(e),r.set(o,s)}return KH(s,a,t)}}}async function YH(){let e=window.showDirectoryPicker;if(e)try{return JH(await e({mode:`read`}))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;throw e}}var XH,ZH,QH,$H,eU=n((()=>{vS(),XH={[Cx.PARQUET]:`parquet`,[Cx.CSV]:`csv`,[Cx.JSON]:`json`,[Cx.DELTA]:`delta`,[Cx.ICEBERG]:`iceberg`},ZH=e=>[...e].sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name,void 0,{numeric:!0}):e.kind===`folder`?-1:1),QH=()=>typeof window<`u`&&typeof window.showDirectoryPicker==`function`,$H=(e,t)=>({sourceId:e.id,kind:`file`,table:``,path:t.path})}));function tU(e){let t=zN(e.dataSource),n=IM(),r=lM[n?.theme.density??`comfortable`].rowHeight-4,i=e.height??420,a=mP(),o=(0,rU.useMemo)(()=>e.sourceId?GH(t,e.sourceId,e.sourceLabel??e.sourceId):void 0,[t,e.sourceId,e.sourceLabel]),[s,c]=(0,rU.useState)([]),l=(0,rU.useMemo)(()=>[...o?[o]:[],...e.places??[],...s],[o,e.places,s]),[u,d]=(0,rU.useState)({}),[f,p]=(0,rU.useState)(new Set),[m,h]=(0,rU.useState)(0),[g,_]=(0,rU.useState)(new Set),v=(0,rU.useRef)(0),[y,b]=(0,rU.useState)(``),[x,S]=(0,rU.useState)(0),C=(0,rU.useRef)(null),w=(0,rU.useRef)(null),T=(0,rU.useCallback)((e,t,n)=>{let r=iU(e,t);d(e=>n?e:{...e,[r]:`loading`}),e.list(t,n).then(e=>d(t=>{let i=t[r],a=n&&i&&i!==`loading`&&!(`error`in i)?i.items:[];return{...t,[r]:{...e,items:[...a,...e.items]}}})).catch(e=>d(t=>({...t,[r]:{error:e instanceof Error?e.message.replace(/^\[[a-z_]+\]\s*/i,``):String(e)}})))},[]);(0,rU.useEffect)(()=>{for(let e of l){let t=iU(e,``);u[t]===void 0&&(T(e,``),p(e=>new Set(e).add(t)))}},[l,u,T]);let E=(0,rU.useMemo)(()=>{let e=[],t=(n,r,i)=>{let a=u[iU(n,r)];if(a===void 0||a===`loading`)return void e.push({id:`${iU(n,r)}\u0000loading`,kind:`note`,level:i,label:`Loading…`,place:n,path:r});if(`error`in a)return void e.push({id:`${iU(n,r)}\u0000error`,kind:`note`,level:i,label:a.error,place:n,path:r,error:!/no storage to list/i.test(a.error)});a.items.length===0&&e.push({id:`${iU(n,r)}\u0000empty`,kind:`note`,level:i,label:`Nothing here.`,place:n,path:r});for(let r of a.items){let a=iU(n,r.path);e.push({id:a,kind:r.kind,level:i,label:r.name,place:n,path:r.path,item:r,meta:r.kind===`file`?[WH(r.size),aU(r.modified)].filter(Boolean).join(` · `):void 0,tag:r.table?`table ${r.table}`:r.format}),r.kind===`folder`&&f.has(a)&&t(n,r.path,i+1)}a.next?e.push({id:`${iU(n,r)}\u0000more`,kind:`more`,level:i,label:`Show more`,place:n,path:r}):a.truncated&&e.push({id:`${iU(n,r)}\u0000cut`,kind:`note`,level:i,label:`This folder is too large to list whole; the rest is not shown.`,place:n,path:r})};for(let n of l){let r=iU(n,``);e.push({id:r,kind:`place`,level:1,label:n.label,place:n,path:``,tag:n.origin===`local`?`this computer`:`storage`}),f.has(r)&&t(n,``,2)}return e},[l,u,f]),D=e=>{if(e.kind===`more`){let t=u[iU(e.place,e.path)];t&&t!==`loading`&&!(`error`in t)&&t.next&&T(e.place,e.path,t.next);return}if(e.kind!==`place`&&e.kind!==`folder`)return;let t=new Set(f);t.has(e.id)?t.delete(e.id):(t.add(e.id),(u[e.id]===void 0||typeof u[e.id]==`object`&&`error`in u[e.id])&&T(e.place,e.path)),p(t)},O=e=>{let t=E.filter(e=>g.has(e.id)&&e.item);return t.length>0&&g.has(e.id)?t:e.item?[e]:[]},k=e=>e.map(e=>$H(e.place,e.item)),ee=t=>{let n=O(t);n.length!==0&&e.onAttach&&(e.onAttach(k(n),n.map(e=>e.item)),b(`${n.length===1?n[0].label:`${n.length} items`} added.`),e.onContext?.({kind:`files.attached`,summary:`Attached ${n.length===1?n[0].path:`${n.length} files and folders`}.`,subject:{files:n.map(e=>({place:e.place.id,path:e.path,kind:e.kind}))}}))},te=(t,n)=>{let r=E[t];if(!r?.item)return;let i=new Set(n===`range`?[]:g);if(n===`range`){let[e,n]=[Math.min(v.current,t),Math.max(v.current,t)];for(let t=e;t<=n;t++)E[t]?.item&&i.add(E[t].id)}else i.has(r.id)?i.delete(r.id):i.add(r.id),v.current=t;_(i),h(t),b(i.size>0?`${i.size} selected. Shift+Enter ${e.onAttach?`adds them`:`does nothing here`}; Escape clears.`:``)},A=t=>{t.kind===`file`&&t.item?(e.onOpen?.(t.item,t.place),e.onContext?.({kind:`file.opened`,summary:`Opened ${t.path}${t.place.origin===`local`?` (on their own computer)`:``}.`,subject:{place:t.place.id,path:t.path,format:t.item.format??``,table:t.item.table??``}})):D(t)},ne=t=>{let n=O(t).length;return[...t.kind===`folder`?[{label:f.has(t.id)?`Close folder`:`Open folder`,onSelect:()=>D(t),hint:`Enter`}]:[],...t.kind===`file`&&e.onOpen?[{label:`Open`,onSelect:()=>A(t),hint:`Enter`}]:[],...e.onAttach?[{label:n>1?`${e.attachLabel??`Add to chat`}: ${n} items`:e.attachLabel??`Add to chat`,onSelect:()=>ee(t),hint:`Shift+Enter`}]:[],{label:g.has(t.id)?`Remove from selection`:`Select`,onSelect:()=>te(E.indexOf(t),`toggle`),hint:`Space`},{separator:!0},{label:`Copy path`,hint:`Ctrl+C`,onSelect:()=>void pP(t.path).then(e=>b(e?`Path copied.`:`The path could not be copied.`))}]},re=e=>{let t=Math.max(0,Math.min(E.length-1,e));h(t);let n=C.current;n&&(t*r<n.scrollTop?n.scrollTop=t*r:(t+1)*r>n.scrollTop+n.clientHeight&&(n.scrollTop=(t+1)*r-n.clientHeight))},ie=e=>{let t=E[m];if(!t)return;let n=t.kind===`place`||t.kind===`folder`;switch(e.key){case`ArrowDown`:re(m+1);break;case`ArrowUp`:re(m-1);break;case`Home`:re(0);break;case`End`:re(E.length-1);break;case`ArrowRight`:n&&!f.has(t.id)?D(t):n&&re(m+1);break;case`ArrowLeft`:if(n&&f.has(t.id))D(t);else for(let n=m-1;n>=0;n--)if(E[n].level<t.level)return void(e.preventDefault(),re(n));break;case`Enter`:e.shiftKey?ee(t):A(t);break;case` `:te(m,`toggle`);break;case`Escape`:if(g.size===0)return;_(new Set),b(``);break;case`c`:if(!(e.ctrlKey||e.metaKey)||!t.item)return;pP(t.path).then(e=>b(e?`Path copied.`:`The path could not be copied.`));break;default:return}e.preventDefault()},ae=t=>{c(e=>[...e.filter(e=>e.id!==t.id),t]),d(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!e.startsWith(`${t.id}\u0000`)))),e.onPlaceAdded?.(t),b(`Opened ${t.label}. It is read by this browser; nothing is uploaded.`),e.onContext?.({kind:`folder.opened`,summary:`Opened the folder ${t.label} from their own computer. Only its file names are listed; nothing was uploaded.`,subject:{place:t.id}})},oe=async()=>{if(!QH())return w.current?.click();try{let e=await YH();e&&ae(e)}catch(e){b(e instanceof Error?e.message:`The folder could not be opened.`)}},se=e=>{let t=[...e.target.files??[]];e.target.value=``,t.length>0&&ae(qH(t))},ce=e=>t=>{let n=O(e);n.length!==0&&(qF(t.dataTransfer,k(n),n.map(e=>e.path).join(`, `)),t.dataTransfer.effectAllowed=`copy`)},le=Math.max(0,Math.floor(x/r)-4),ue=Math.min(E.length,le+Math.ceil(i/r)+8),de=[];for(let t=le;t<ue;t++){let n=E[t],i=n.kind===`place`||n.kind===`folder`,o=f.has(n.id);de.push((0,nU.jsxs)(`div`,{id:`sf-files-${t}`,className:`sf-schema-row sf-browser-row sf-files-row`,"data-kind":n.kind,"data-active":t===m||void 0,"data-error":n.error||void 0,"data-picked":g.has(n.id)||void 0,style:{top:t*r,height:r,paddingInlineStart:`calc(var(--sf-space-2) + ${n.level-1} * var(--sf-space-4))`},role:`treeitem`,"aria-level":n.level,"aria-expanded":i?o:void 0,"aria-selected":g.size>0?g.has(n.id):t===m,draggable:n.item!==void 0,onDragStart:n.item?ce(n):void 0,onClick:r=>{if(r.ctrlKey||r.metaKey)return te(t,`toggle`);if(r.shiftKey)return te(t,`range`);g.size>0&&(_(new Set),b(``)),h(t),v.current=t,D(n),n.item&&e.onSelect?.(n.item,n.place)},onDoubleClick:()=>n.kind===`file`&&A(n),onContextMenu:n.item?e=>{h(t),a.open(e,`${n.label} actions`,ne(n))}:void 0,children:[(0,nU.jsx)(`span`,{className:`sf-schema-caret`,"aria-hidden":`true`,"data-open":i&&o||void 0,children:i?`▸`:``}),(0,nU.jsx)(`span`,{className:`sf-files-icon`,"data-kind":n.kind,"aria-hidden":`true`}),(0,nU.jsx)(`span`,{className:`sf-schema-name`,children:n.label}),n.meta&&(0,nU.jsx)(`span`,{className:`sf-schema-meta`,children:n.meta}),n.tag&&(0,nU.jsx)(`span`,{className:`sf-schema-tag`,children:n.tag}),n.kind===`file`&&n.item&&e.renderActions&&(0,nU.jsx)(`span`,{className:`sf-schema-actions`,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:e.renderActions(n.item,n.place)})]},n.id))}let fe=l.length===0;return(0,nU.jsxs)(`div`,{className:[`sf-schema sf-files`,e.className].filter(Boolean).join(` `),style:{height:i},children:[e.local&&(0,nU.jsxs)(`div`,{className:`sf-files-bar`,children:[(0,nU.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void oe(),children:`Open a folder on this computer`}),(0,nU.jsx)(`input`,{ref:w,type:`file`,hidden:!0,multiple:!0,onChange:se,webkitdirectory:``,"aria-hidden":`true`,tabIndex:-1})]}),(0,nU.jsxs)(`div`,{ref:C,className:`sf-schema-list`,role:`tree`,"aria-label":e.label??`Folders and files`,"aria-activedescendant":E.length>0?`sf-files-${m}`:void 0,"aria-multiselectable":`true`,"aria-keyshortcuts":`Shift+F10 Space Shift+Enter Control+C`,tabIndex:0,onKeyDown:ie,onContextMenu:e=>{let t=E[m];e.target===e.currentTarget&&t?.item&&a.open(e,`${t.label} actions`,ne(t))},onScroll:e=>S(e.currentTarget.scrollTop),children:[(0,nU.jsx)(`div`,{style:{height:E.length*r,position:`relative`},children:de}),fe&&(0,nU.jsxs)(`p`,{className:`sf-schema-empty`,children:[e.sourceId&&!o?`This backend cannot list a source's storage.`:`No place to list.`,e.local?` Open a folder on this computer to browse it here.`:``]})]}),(0,nU.jsx)(`p`,{className:`sf-schema-note`,role:`status`,children:y}),a.element]})}var nU,rU,iU,aU,oU=n((()=>{nU=HA(),kM(),rU=jM(),UN(),_P(),YF(),UM(),eU(),iU=(e,t)=>`${e.id}\u0000${t}`,aU=e=>e?new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}):``}));function sU({sourceId:e,sql:t,filters:n,onChange:r,columns:i,onContext:a,className:o,...s}){let c=zN(s.dataSource),[l,u]=(0,lU.useState)([]),[d,f]=(0,lU.useState)();(0,lU.useEffect)(()=>{let n=new AbortController;return f(void 0),JS(c.execute({sourceId:e,query:{baseSql:t,page:{limit:1}}},{signal:n.signal})).then(e=>!n.signal.aborted&&u(e.table.schema.fields)).catch(e=>!n.signal.aborted&&(u([]),f(rP(e)))),()=>n.abort()},[c,e,t]);let p=(0,lU.useCallback)(async n=>{let r=await JS(c.execute({sourceId:e,query:{baseSql:t,groupBy:[n],aggregates:[{function:ux.COUNT,alias:`sf_count`}],sorts:[{column:`sf_count`,direction:ax.DESC}],page:{limit:50}}})),i=r.table.getChildAt(0),a=r.table.schema.fields[0]?.type;return Array.from({length:r.table.numRows},(e,t)=>i?.get(t)).filter(e=>e!=null).map(e=>a?JN(e,a).text:String(e))},[c,e,t]),m=(0,lU.useMemo)(()=>i?.length?l.filter(e=>i.includes(e.name)):l,[l,i]),{fixed:h,relative:g}=(0,lU.useMemo)(()=>UC(n),[n]),[_,v]=(0,lU.useMemo)(()=>{try{return[LC(h),void 0]}catch(e){return[[],e instanceof Error?e.message:`The filters could not be read.`]}},[h]),y=e=>{r(e),a?.({kind:`filter.changed`,summary:e.length===0?`Cleared every filter.`:`Filters are now: ${e.map(YC).join(`; `)}.`,subject:{filters:e}})};return(0,cU.jsxs)(`div`,{className:[`sf-query-filters`,o].filter(Boolean).join(` `),children:[(0,cU.jsx)(hI,{fields:m,filters:_,onChange:e=>y(WC(VC(e),g)),loadValues:p,relative:g,onRelativeChange:e=>y(WC(h,e))}),(d??v)&&(0,cU.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:d??v})]})}var cU,lU,uU=n((()=>{cU=HA(),rw(),vS(),lU=jM(),UN(),tP(),oP(),CI()}));function dU(e,t){if(!e||typeof e!=`object`)return;let n=Object.fromEntries(Object.entries(e.measures??{}).filter(([e])=>t.includes(e)).map(([e,t])=>[e,{...t?.type&&kU.includes(t.type)?{type:t.type}:{},...t?.axis===`right`?{axis:`right`}:{}}]).filter(([,e])=>Object.keys(e).length>0)),r={...e.type&&kU.includes(e.type)?{type:e.type}:{},...e.swap?{swap:!0}:{},...Object.keys(n).length>0?{measures:n}:{}};return Object.keys(r).length>0?r:void 0}function fU(e,t,n){let r={...e.chart?.measures??{},[t]:{...e.chart?.measures?.[t]??{},...n}};return{...e,chart:dU({...e.chart,measures:r},e.values)}}function pU(e,t){return{...e,chart:dU({...e.chart,...t},e.values)}}function mU(e,t=[]){let n=new Set(t),r=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^(\d)/,`n$1`).slice(0,40)||`field`,i=r;for(let e=2;n.has(i);e++)i=`${r}_${e}`;return i}function hU(e,t=`the columns`){let n=[],r=()=>n.map(e=>e.id);for(let i of e){let{name:e,type:a}=i;if(!(P.isList(a)||P.isStruct(a)||P.isMap(a)||P.isBinary(a))){if(P.isTimestamp(a)||P.isDate(a))n.push({id:mU(e,r()),kind:`attribute`,label:`${FU(e)} (month)`,column:e,grain:`month`,by:t});else if(qN(a)&&!NU.test(e)){let i=PU.test(e);n.push({id:mU(e,r()),kind:`metric`,label:i?FU(e):`Average ${FU(e).toLowerCase()}`,column:e,aggregate:i?`sum`:`avg`,format:MU.test(e)?`currency`:i?`compact`:`number`,by:t})}else n.push({id:mU(e,r()),kind:`attribute`,label:FU(e),column:e,by:t}),NU.test(e)&&n.push({id:mU(`${e}_count`,r()),kind:`metric`,label:`Distinct ${FU(e).toLowerCase()}`,column:e,aggregate:`count_distinct`,format:`compact`,by:t})}}return n.push({id:mU(`rows`,r()),kind:`metric`,label:`Rows`,aggregate:`count`,format:`compact`,by:t}),n}function gU(e,t=`suggested from the columns`){let n=[],r=()=>[...e,...n].map(e=>e.id),i=t=>[...e,...n].some(e=>e.kind===`derived`&&e.expression?.replace(/\s+/g,``)===t.replace(/\s+/g,``)),a=(e,a,o,s)=>{i(a)||n.push({id:mU(e,r()),kind:`derived`,label:e,expression:a,format:o,description:s,by:t})},o=e.filter(e=>e.kind===`metric`&&e.aggregate===`sum`),s=e.find(e=>e.kind===`metric`&&e.aggregate===`count`&&!e.column);if(s)for(let e of o.slice(0,3))a(`${e.label} per row`,`${e.id} / ${s.id}`,e.format===`currency`?`currency`:`number`,`${e.label} divided by the number of rows.`);let c=o.find(e=>/(revenue|sales|amount|price|total)/i.test(e.column??``)),l=o.find(e=>/cost/i.test(e.column??``));c&&l&&c!==l&&a(`Margin`,`(${c.id} - ${l.id}) / ${c.id}`,`percent`,`What is left of ${c.label.toLowerCase()} after ${l.label.toLowerCase()}, as a share.`);let u=o.filter(e=>e.format===`currency`),d=u.find(e=>/(refund|discount|fee|tax|return)/i.test(e.column??``)),f=u.find(e=>e!==d&&/(revenue|sales|amount|total|price)/i.test(e.column??``));return d&&f&&a(`${d.label} share of ${f.label.toLowerCase()}`,`${d.id} / ${f.id}`,`percent`,`${d.label} divided by ${f.label.toLowerCase()}.`),n}function _U(e,t,n){if(!jU.test(e.id))return`Its name in calculations must start with a letter and use only letters, digits and underscores.`;if(t.filter(t=>t.id===e.id).length>1)return`Another field is already called "${e.id}".`;if(!e.label.trim())return`It needs a label.`;let r=e=>!n||e!==void 0&&n.includes(e);return e.kind===`attribute`?e.column?r(e.column)?void 0:`There is no column "${e.column}" in this query.`:`An attribute needs a column.`:e.kind===`metric`?e.aggregate?e.column?r(e.column)?void 0:`There is no column "${e.column}" in this query.`:e.aggregate===`count`?void 0:`Only a count can do without a column.`:`A metric needs a way to summarise: sum, average, count.`:SS(e.expression??``,t.filter(e=>e.kind===`metric`).map(e=>e.id))}function vU(e){let t=new Map(e.fields.map(e=>[e.id,e.kind])),n=[...new Set(e.rows)].filter(e=>t.get(e)===`attribute`).slice(0,3),r=e.split&&t.get(e.split)===`attribute`&&!n.includes(e.split)?e.split:void 0,i=[...new Set(e.values)].filter(e=>t.get(e)===`metric`||t.get(e)===`derived`).slice(0,6),a=dU(e.chart,i);return{fields:e.fields,rows:n,...r?{split:r}:{},values:i,filters:e.filters,...e.view?{view:e.view}:{},...a?{chart:a}:{}}}function yU(e,t,n,r){let i=e.fields.find(e=>e.id===t);if(!i)return e;let a=n??(i.kind===`attribute`?`rows`:`values`),o=e=>{let n=e.filter(e=>e!==t),i=r===void 0?n.length:Math.max(0,Math.min(n.length,r));return[...n.slice(0,i),t,...n.slice(i)]};return vU(a===`split`?{...e,rows:e.rows.filter(e=>e!==t),split:t}:a===`rows`?{...e,rows:o(e.rows),...e.split===t?{split:void 0}:{}}:{...e,values:o(e.values)})}function bU(e,t,n){let r=e.rows.includes(t)?`rows`:e.values.includes(t)?`values`:void 0;if(!r)return e;let i=e[r].indexOf(t)+n;return i<0||i>=e[r].length?e:yU(e,t,r,i)}function xU(e,t,n){return n===`split`?{...e,split:void 0}:{...e,[n]:e[n].filter(e=>e!==t)}}function SU(e,t,n){let r=e.fields.some(e=>e.id===t),i=n?r?e.fields.map(e=>e.id===t?n:e):[...e.fields,n]:e.fields.filter(e=>e.id!==t),a=n&&n.id!==t?n.id:void 0;a&&(i=i.map(e=>e.kind===`derived`&&e.expression?{...e,expression:e.expression.replace(RegExp(`\\b${t}\\b`,`g`),a)}:e));let o=e=>e===t?a:e,s=e=>e.map(e=>e===t?n?a??t:void 0:e).filter(e=>e!==void 0);return vU({...e,fields:i,rows:s(e.rows),values:s(e.values),split:e.split===t?n?o(t)??t:void 0:e.split})}function CU(e){let t=[];for(let n of e.values){let r=IU(e,n);if(r?.kind===`metric`&&t.push(n),r?.kind===`derived`)try{t.push(...xS(bS(r.expression??``)))}catch{}}return[...new Set(t)].map(t=>IU(e,t)).filter(e=>e?.kind===`metric`)}function wU(e,t,n=200,r){let i=[...e.rows,...e.split?[e.split]:[]].map(t=>IU(e,t)).filter(e=>e?.kind===`attribute`),a=i.filter(e=>!e.grain),o=i.filter(e=>e.grain),s=e.values.map(t=>IU(e,t)).filter(e=>e?.kind===`derived`),c=i[0];return{baseSql:t,filters:LC(e.filters,r),groupBy:a.map(e=>e.column),buckets:o.map(e=>({column:e.column,alias:e.id,by:{case:`grain`,value:_F[e.grain]}})),aggregates:CU(e).map(e=>({function:gF[e.aggregate??`count`],column:e.column??``,alias:e.id})),derived:s.map(e=>({alias:e.id,expression:e.expression??``})),sorts:c?.grain?[{column:c.id,direction:ax.ASC}]:e.values[0]?[{column:e.values[0],direction:ax.DESC}]:[],page:{limit:n}}}function TU(e){let t=EU({...e,chart:{...e.chart,swap:!1}});if(!t)return`There is no chart to turn yet.`;if(!BP(t.type,t.y))return`Only bars on one scale can be turned on their side.`}function EU(e){let t=e.rows.map(t=>IU(e,t)).filter(e=>e?.kind===`attribute`),n=e.values.map(t=>IU(e,t)).filter(e=>!!e&&e.kind!==`attribute`),r=t[0];if(!r||n.length===0)return;let i=(e.split?IU(e,e.split):t[1])??void 0,a=e.chart?.type??(r.grain?`line`:`bar`),o=new Set(n.filter(t=>e.chart?.measures?.[t.id]?.axis===`right`).map(e=>e.id));o.size===n.length&&o.clear();let s=t=>{let n=e.chart?.measures?.[t.id]?.type;return{...n&&n!==a?{type:n}:{},...o.has(t.id)?{axis:`right`}:{}}},c=n.map(t=>{if(t.kind===`metric`)return{...t.column?{column:t.column}:{},aggregate:t.aggregate??`count`,label:t.label,...s(t)};let n=[];try{n=xS(bS(t.expression??``))}catch{}let r=Object.fromEntries(n.map(t=>IU(e,t)).filter(e=>e?.kind===`metric`).map(e=>[e.id,{...e.column?{column:e.column}:{},aggregate:e.aggregate??`count`}]));return{expression:t.expression??``,terms:r,label:t.label,...s(t)}}),l=n.filter(e=>!o.has(e.id)),u=n.filter(e=>o.has(e.id)),d=!!e.chart?.swap&&BP(a,c);return{type:a,x:r.column,...r.grain?{xGrain:r.grain}:{},...i?.column&&!i.grain&&(e.split||n.length===1)?{splitBy:i.column}:{},y:c,xTitle:r.label,...u.length>0?{yTitle:l.map(e=>e.label).join(`, `),yRightTitle:u.map(e=>e.label).join(`, `)}:{},...l[0]?.format&&l.every(e=>e.format===l[0].format)?{yFormat:l[0].format}:{},...d?{horizontal:!0}:{}}}function DU(e,t){if(e==null)return`–`;let n=Number(e);return Number.isFinite(n)?t===`percent`?jA({style:`percent`,maximumFractionDigits:1}).format(n):t===`currency`?jA({style:`currency`,currency:`USD`,notation:Math.abs(n)>=1e5?`compact`:`standard`,maximumFractionDigits:Math.abs(n)>=1e5?1:2}).format(n):t===`compact`?jA({notation:`compact`,maximumFractionDigits:1}).format(n):jA({maximumFractionDigits:2}).format(n):String(e)}function OU(e){let t=e.filter(e=>e.kind===`attribute`),n=t.find(e=>!e.grain&&!NU.test(e.column??``))??t.find(e=>e.grain),r=e.filter(e=>e.kind===`metric`),i=r.find(e=>e.column&&e.aggregate!==`count_distinct`)??r.find(e=>!e.column)??r[0];return n&&i?{rows:[n.id],values:[i.id]}:{rows:[],values:[]}}var kU,AU,jU,MU,NU,PU,FU,IU,LU,RU=n((()=>{rw(),vS(),_p(),vF(),oF(),tP(),BA(),kU=[`bar`,`line`,`area`],AU={fields:[],rows:[],values:[],filters:[]},jU=/^[A-Za-z][A-Za-z0-9_]*$/,MU=/(amount|price|cost|revenue|sales|total|refund|paid|charge|fee|balance|margin|spend|value)/i,NU=/(^id$|_id$|_key$|_no$|_number$|^sku$|code$)/i,PU=/(amount|cost|revenue|sales|total|refund|paid|charge|fee|spend|income|profit|count|qty|quantity|units|orders|items|hours|minutes|seconds|days|kwh|mwh|energy|volume|clicks|views|visits|sessions|downloads|bytes|calls|tickets|^n_|^num_)/i,FU=e=>e.replace(/_/g,` `).replace(/^\w/,e=>e.toUpperCase()),IU=(e,t)=>e.fields.find(e=>e.id===t),LU=e=>e.kind===`attribute`&&!e.grain?e.column:e.id}));function zU(e){let t=t=>t||XU(e),n=[];for(let r of e.dimensions){let i=r.kind===gS.TIME;n.push({id:r.name,kind:`attribute`,label:r.label||r.name,column:r.column,...i?{grain:r.grain||`month`}:{},...r.description?{description:r.description}:{},by:t(r.definedBy),model:e.name})}for(let r of e.measures){let i=_C(r.aggregate);i&&n.push({id:r.name,kind:`metric`,label:r.label||r.name,...r.column?{column:r.column}:{},aggregate:i,...YU(r.format)?{format:YU(r.format)}:{},...r.description?{description:r.description}:{},by:t(r.definedBy),model:e.name})}for(let r of e.metrics)n.push({id:r.name,kind:`derived`,label:r.label||r.name,expression:r.expression,...YU(r.format)?{format:YU(r.format)}:{},...r.description?{description:r.description}:{},by:t(r.definedBy),model:e.name});return n}function BU(e,t){let n=zU(e),r=new Set(n.flatMap(e=>e.column?[e.column]:[])),i=new Set(n.map(e=>e.id)),a=n.some(e=>e.kind===`metric`&&e.aggregate===`count`&&!e.column),o=hU(t.filter(e=>!r.has(e.name))).filter(e=>!i.has(e.id)&&!(a&&e.aggregate===`count`&&!e.column));return[...n,...o]}function VU(e,t){return e.id===t.id&&e.kind===t.kind&&(e.column??``)===(t.column??``)&&(e.aggregate??``)===(t.aggregate??``)&&(e.grain??``)===(t.grain??``)&&(e.expression??``).replace(/\s+/g,``)===(t.expression??``).replace(/\s+/g,``)&&(e.format??``)===(t.format??``)&&e.label===t.label&&(e.description??``)===(t.description??``)}function HU(e,t){let n=zU(t),r=new Map(n.map(e=>[e.id,e])),i=e.flatMap(e=>{let n=r.get(e.id);return n?e.model===t.name||VU(e,n)?[n]:[e]:e.model===t.name?[]:[e]}),a=new Set(i.map(e=>e.id));return[...n.filter(e=>!a.has(e.id)),...i]}function UU(e,t,n,r){let i=ym(pS,e),a=[t];if(t.kind===`derived`){let e=[];try{e=xS(bS(t.expression??``))}catch{e=[]}for(let t of e){let e=n.find(e=>e.id===t&&e.kind===`metric`);e&&!i.measures.some(e=>e.name===t)&&a.unshift(e)}}let o=i;for(let n of a)o=GU(o,n.id,n,n===t||n.model!==e.name?r:WU(e,n.id)?.definedBy??``);return o}function WU(e,t){return e.dimensions.find(e=>e.name===t)??e.measures.find(e=>e.name===t)??e.metrics.find(e=>e.name===t)}function GU(e,t,n,r){let i=Hh(pS,e),a=n&&{name:n.id,label:n.label,description:n.description??``,definedBy:r},o=n?.kind===`attribute`?{$typeName:`surfaces.v1.Dimension`,...a,column:n.column??``,kind:n.grain?gS.TIME:gS.CATEGORY,grain:n.grain??``}:void 0,s=n?.kind===`metric`?{$typeName:`surfaces.v1.Measure`,...a,column:n.column??``,aggregate:vC(n.aggregate??``),format:n.format??``}:void 0,c=n?.kind===`derived`?{$typeName:`surfaces.v1.Metric`,...a,expression:n.expression??``,format:n.format??``}:void 0,l=(e,n)=>{let r=e.findIndex(e=>e.name===t);return r<0?n?[...e,n]:e:n?e.map((e,t)=>t===r?n:e):e.filter((e,t)=>t!==r)};if(i.dimensions=l(i.dimensions,o),i.measures=l(i.measures,s),i.metrics=l(i.metrics,c),n&&n.id!==t){let e=RegExp(`\\b${t}\\b`,`g`);i.metrics=i.metrics.map(t=>({...t,expression:t.expression.replace(e,n.id)}))}return i}function KU(e,t){let n=new Map(zU(e).map(e=>[e.id,e])),r=new Map(zU(t).map(e=>[e.id,e])),i=new Map;for(let[e,t]of r){let r=n.get(e);r?VU(r,t)||i.set(e,`changed`):i.set(e,`added`)}for(let e of n.keys())r.has(e)||i.set(e,`removed`);for(let n of[`name`,`label`,`description`,`sql`,`grain`])e[n]!==t[n]&&i.set(`(${n})`,`changed`);e.primaryKey.join(`|`)!==t.primaryKey.join(`|`)&&i.set(`(primaryKey)`,`changed`);let a=e=>JSON.stringify([e.tables,e.joins.map(e=>[e.left,e.right,e.keys.map(e=>[e.leftColumn,e.rightColumn]),e.definedBy,e.type||1])]);a(e)!==a(t)&&i.set(`(joins)`,`changed`);let o=e=>e.dataset?`${e.dataset.pipelineId}/${e.dataset.dataset}`:``;return o(e)!==o(t)&&i.set(`(dataset)`,`changed`),i}function qU(e){return ym(pS,e)}var JU,YU,XU,ZU,QU=n((()=>{zb(),rw(),vS(),RU(),JU=[`number`,`compact`,`currency`,`percent`],YU=e=>JU.includes(e)?e:void 0,XU=e=>`the ${e.label||e.name} model`,ZU=(e,t)=>!!t&&e.model!==t.name}));function $U(e,t){let n=e.dataset,[r,i]=(0,nW.useState)({});return(0,nW.useEffect)(()=>{if(!n?.pipelineId||!t)return i({});let e=new AbortController,r={signal:e.signal};return(async()=>{let a;try{a=(await t.getPipeline({id:n.pipelineId},r)).pipeline}catch{return!e.signal.aborted&&i({gone:!0})}if(!a)return i({gone:!0});let o=a.datasets.find(e=>e.name===n.dataset)?.lastRunId||a.summary?.latestRun?.id,s=o?(await t.getRun({pipelineId:n.pipelineId,runId:o},r).catch(()=>void 0))?.run:void 0;e.signal.aborted||i({pipeline:a,standing:EC(a,n.dataset,s)})})().catch(t=>!e.signal.aborted&&i({problem:rP(t)})),()=>e.abort()},[t,n?.pipelineId,n?.dataset]),r}function eW(e){let{model:t,compact:n}=e,r=OB(e.pipelines),{pipeline:i,standing:a,problem:o,gone:s}=$U(t,r),c=(0,nW.useId)(),l=t.dataset;if(!l?.pipelineId)return null;let u=a?.pipelineName||l.pipelineId,d=r&&(i||s)?DC(t,i):[],f=s||d.length>0||a?.state===`failed`||(a?.failing??0)>0||a&&!a.built?`warn`:`ok`,p=e.onOpenDataset&&(0,tW.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onOpenDataset?.(l.pipelineId,l.dataset),children:`Open in the pipeline`});return n?(0,tW.jsxs)(`p`,{className:`sf-lineage`,"data-compact":!0,"data-tone":f,role:`note`,children:[(0,tW.jsx)(`span`,{className:`sf-lineage-mark`,"aria-hidden":`true`,children:f===`ok`?`✓`:`!`}),(0,tW.jsxs)(`span`,{children:[`Rows from `,(0,tW.jsx)(`strong`,{children:l.dataset}),`, built by `,AC(u),a?.builtAt?` · ${rW(a.builtAt)}`:a&&!a.built?` · not built yet`:``,a&&a.checks.length>0&&(a.failing>0?` · ${a.failing} of ${a.checks.length} checks failing`:a.warnings>0?` · ${a.warnings} ${a.warnings===1?`warning`:`warnings`}, no check failing`:` · checks passed`),s&&` · the pipeline is not there any more`,d.length>0&&!s&&` · ${d.length===1?`differs`:`${d.length} differences`} from the dataset`]}),p]}):(0,tW.jsxs)(`section`,{className:`sf-lineage`,"data-tone":f,"aria-labelledby":`${c}-title`,children:[(0,tW.jsx)(`h4`,{id:`${c}-title`,className:`sf-explore-heading`,children:`From a pipeline`}),(0,tW.jsxs)(`p`,{children:[`The rows are the dataset `,(0,tW.jsx)(`strong`,{children:l.dataset}),`, which `,AC(u),` builds on `,t.sourceId,`. Its grain and key are checked after every build.`]}),!r&&(0,tW.jsx)(`p`,{className:`sf-explore-hint`,children:`How it was last built is shown where the pipelines can be read.`}),o&&(0,tW.jsxs)(`p`,{className:`sf-filter-problem`,children:[`The pipeline could not be read: `,o]}),a&&(0,tW.jsxs)(`dl`,{className:`sf-lineage-facts`,children:[(0,tW.jsx)(`dt`,{children:`Last built`}),(0,tW.jsx)(`dd`,{children:a.builtAt?rW(a.builtAt):`Not built yet: the query has no table to read until the pipeline runs.`}),a.state===`failed`||a.state===`running`||a.state===`skipped`?(0,tW.jsxs)(tW.Fragment,{children:[(0,tW.jsx)(`dt`,{children:`Latest run`}),(0,tW.jsx)(`dd`,{children:a.state===`failed`?`Failed. The table holds what the last good build left.`:a.state===`running`?`Under way.`:`Skipped, because something it reads failed.`})]}):null,(0,tW.jsx)(`dt`,{children:`Grain`}),(0,tW.jsx)(`dd`,{children:a.grain||`Not declared.`}),(0,tW.jsx)(`dt`,{children:`Key`}),(0,tW.jsx)(`dd`,{children:a.primaryKey.length?`${a.primaryKey.join(`, `)} · ${a.keyChecked?`checked unique and not empty by the latest run`:`not checked by the latest run`}`:`Not declared.`}),(0,tW.jsx)(`dt`,{children:`Reads`}),(0,tW.jsx)(`dd`,{children:a.inputs.length?`${a.inputs.join(`, `)}${a.inputsDeclared?``:` (worked out from its query)`}`:`Nothing named.`}),a.owner&&(0,tW.jsxs)(tW.Fragment,{children:[(0,tW.jsx)(`dt`,{children:`Owner`}),(0,tW.jsx)(`dd`,{children:a.owner})]})]}),a&&a.checks.length>0&&(0,tW.jsx)(`ul`,{className:`sf-lineage-checks`,"aria-label":`Checks from the latest run`,children:a.checks.map(e=>(0,tW.jsxs)(`li`,{"data-failing":e.failedRecords>0||void 0,children:[(0,tW.jsx)(`span`,{"aria-hidden":`true`,children:e.failedRecords>0?e.severity===`warn`?`!`:`✕`:`✓`}),` `,(0,tW.jsx)(`code`,{children:e.name}),` `,e.failedRecords>0?`${e.severity===`warn`?`warns`:`fails`}: ${e.summary}`:`passed`]},e.name))}),s&&(0,tW.jsxs)(`p`,{className:`sf-filter-problem`,children:[AC(l.pipelineId).replace(/^t/,`T`),` is not there any more.`]}),d.length>0&&!s&&(0,tW.jsxs)(`div`,{className:`sf-filter-problem`,role:`alert`,children:[d.map(e=>(0,tW.jsx)(`p`,{children:e},e)),e.onUseDataset&&a&&(0,tW.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onUseDataset?.(a),children:`Use the dataset's grain and key`})]}),p]})}var tW,nW,rW,iW=n((()=>{tW=HA(),rw(),nW=jM(),oP(),BA(),WB(),rW=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:MA({dateStyle:`medium`,timeStyle:`short`}).format(t)}}));function aW(e,t,n,r,i){let a=JSON.stringify([t,n,r.rows,r.split,r.values,r.filters,r.fields,i]),[o,s]=(0,fW.useState)({key:``});return(0,fW.useEffect)(()=>{let o=new AbortController,c;try{c=wU(r,n,i)}catch(e){s({key:a,error:rP(e)});return}return JS(e.execute({sourceId:t,query:c},{signal:o.signal})).then(e=>{if(o.signal.aborted)return;let t=Object.fromEntries(e.table.schema.fields.map(e=>[e.name,e.type]));s({key:a,rows:e.table.toArray().map(e=>e.toJSON()),types:t})}).catch(e=>!o.signal.aborted&&s({key:a,error:rP(e)})),()=>o.abort()},[e,a]),o.key===a?o:{}}function oW({dataSource:e,sourceId:t,sql:n,state:r,limit:i=200}){let a=aW(e,t,n,r,i),o=yW(r);if(a.error)return(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:a.error});if(!a.rows)return(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:`Working it out…`});let s=(e,t)=>{let n=t[LU(e)],r=a.types?.[LU(e)];return e.kind===`attribute`?n==null?`–`:r?JN(n,r).text:String(n):DU(r?ZN(n,r):n,e.format)};return(0,U.jsxs)(`div`,{className:`sf-explore-table`,tabIndex:0,role:`region`,"aria-label":`The numbers behind the view`,children:[(0,U.jsxs)(`table`,{children:[(0,U.jsx)(`thead`,{children:(0,U.jsx)(`tr`,{children:o.map(e=>(0,U.jsx)(`th`,{scope:`col`,"data-number":e.kind!==`attribute`||void 0,children:e.label},e.id))})}),(0,U.jsx)(`tbody`,{children:a.rows.map((e,t)=>(0,U.jsx)(`tr`,{children:o.map(t=>(0,U.jsx)(`td`,{"data-number":t.kind!==`attribute`||void 0,children:s(t,e)},t.id))},t))})]}),a.rows.length>=i&&(0,U.jsxs)(`p`,{className:`sf-explore-hint`,children:[`The first `,i,` rows, in the order shown. Add a filter or a coarser breakdown to see fewer.`]})]})}function sW({dataSource:e,sourceId:t,sql:n,state:r}){let i=aW(e,t,n,{...r,rows:[],split:void 0},1),a=r.values.map(e=>r.fields.find(t=>t.id===e)).filter(e=>!!e);return i.error?(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:i.error}):(0,U.jsx)(`dl`,{className:`sf-explore-numbers`,children:a.map(e=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:e.label}),(0,U.jsx)(`dd`,{children:i.rows?DU(i.types?.[e.id]?ZN(i.rows[0]?.[e.id],i.types[e.id]):i.rows[0]?.[e.id],e.format):`…`})]},e.id))})}function cW(e){let{sourceId:t,sql:n,state:r,height:i=300,label:a,onPointClick:o}=e,s=zN(e.dataSource),c=(0,fW.useMemo)(()=>EU(r),[r]),l=!!o&&!!c&&!c.xGrain,[u,d]=(0,fW.useMemo)(()=>{try{return[LC(l?JC(r.filters,c.x):r.filters),void 0]}catch(e){return[[],rP(e)]}},[r.filters,l,c]);if(r.values.length===0)return null;if(d)return(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:d});let f=e.view??r.view??`chart`;return c?f===`table`?(0,U.jsx)(oW,{dataSource:s,sourceId:t,sql:n,state:r}):(0,U.jsx)(pF,{dataSource:s,sourceId:t,sql:n,filters:u,type:c.type,x:c.x,xGrain:c.xGrain,splitBy:c.splitBy,y:c.y,xTitle:c.xTitle,yTitle:c.yTitle,yRightTitle:c.yRightTitle,yFormat:c.yFormat,horizontal:c.horizontal,height:i,label:a,onPointClick:l?e=>e.x!=null&&o(c.x,e.x):void 0},JSON.stringify(c)):(0,U.jsx)(sW,{dataSource:s,sourceId:t,sql:n,state:r})}function lW(e){let t=t=>e.fields.find(e=>e.id===t)?.label;return[e.values.map(t).filter(Boolean).join(` and `),e.rows.length>0?`by ${e.rows.map(t).filter(Boolean).join(`, then `)}`:``,e.split?`split by ${t(e.split)}`:``].filter(Boolean).join(` `)}function uW({pill:e,all:t,columns:n,isNew:r,modelLabel:i,onSave:a,onCancel:o,onRemove:s,onPromote:c}){let l=(0,fW.useId)(),[u,d]=(0,fW.useState)(e),f=t.filter(t=>t.id!==e.id),p=r?{...u,id:mU(u.label||hW[u.kind],f.map(e=>e.id))}:u,m=_U(p,[...f,p],n.map(e=>e.name)),h=t.filter(e=>e.kind===`metric`),g=n.find(e=>e.name===u.column),_=!!g&&/Timestamp|Date/.test(String(g.type)),v=r||e.kind!==`metric`?[]:t.filter(t=>t.kind===`derived`&&RegExp(`\\b${e.id}\\b`).test(t.expression??``)),y=v.length>0&&(u.aggregate!==e.aggregate||u.column!==e.column);return(0,U.jsxs)(`form`,{className:`sf-explore-editor`,onSubmit:e=>{e.preventDefault(),m||a(p)},"aria-label":r?`New ${hW[u.kind]}`:`Edit ${e.label}`,children:[(0,U.jsxs)(`p`,{className:`sf-explore-editor-title`,children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,"aria-hidden":`true`,children:mW[u.kind]}),r?`New ${hW[u.kind]}`:`Edit ${hW[u.kind]}`,!r&&e.by&&(0,U.jsxs)(`span`,{className:`sf-explore-by`,children:[` · made by `,e.by]})]}),i&&(0,U.jsxs)(`p`,{className:`sf-explore-hint`,children:[`Defined in the `,i,` model. A change here stays in this view until it is added to the model again.`]}),(0,U.jsx)(`label`,{htmlFor:`${l}-label`,children:`Label`}),(0,U.jsx)(`input`,{id:`${l}-label`,className:`sf-input`,value:u.label,autoFocus:!0,onChange:e=>d({...u,label:e.target.value})}),u.kind!==`derived`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-column`,children:`Column`}),(0,U.jsxs)(`select`,{id:`${l}-column`,className:`sf-input`,value:u.column??``,onChange:e=>d({...u,column:e.target.value||void 0}),children:[u.kind===`metric`&&(0,U.jsx)(`option`,{value:``,children:`(rows)`}),n.map(e=>(0,U.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),u.kind===`attribute`&&_&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-grain`,children:`Grouped by`}),(0,U.jsx)(`select`,{id:`${l}-grain`,className:`sf-input`,value:u.grain??`month`,onChange:e=>d({...u,grain:e.target.value}),children:_W.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),u.kind===`metric`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-aggregate`,children:`Summarised as`}),(0,U.jsx)(`select`,{id:`${l}-aggregate`,className:`sf-input`,value:u.aggregate??`sum`,onChange:e=>d({...u,aggregate:e.target.value}),children:gW.map(e=>(0,U.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),u.kind===`derived`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-expression`,children:`Calculation`}),(0,U.jsx)(`textarea`,{id:`${l}-expression`,className:`sf-input sf-explore-expression`,rows:2,spellCheck:!1,value:u.expression??``,"aria-describedby":`${l}-names`,placeholder:`refund_amount / line_amount`,onChange:e=>d({...u,expression:e.target.value})}),(0,U.jsx)(`p`,{id:`${l}-names`,className:`sf-explore-hint`,children:`Metrics, numbers, + − × ÷ and parentheses. Worked out by the database after summarising. Press a metric to add it:`}),(0,U.jsx)(`div`,{className:`sf-explore-names`,children:h.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:`sf-pill`,"data-kind":`metric`,title:e.label,onClick:()=>d({...u,expression:`${u.expression??``}${u.expression&&!/[\s(]$/.test(u.expression)?` `:``}${e.id}`}),children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,"aria-hidden":`true`,children:`Σ`}),e.id]},e.id))})]}),u.kind!==`attribute`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-format`,children:`Shown as`}),(0,U.jsx)(`select`,{id:`${l}-format`,className:`sf-input`,value:u.format??`number`,onChange:e=>d({...u,format:e.target.value}),children:vW.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),(0,U.jsx)(`label`,{htmlFor:`${l}-description`,children:`What it means (optional)`}),(0,U.jsx)(`input`,{id:`${l}-description`,className:`sf-input`,value:u.description??``,onChange:e=>d({...u,description:e.target.value||void 0})}),y&&(0,U.jsxs)(`p`,{className:`sf-explore-warning`,role:`status`,children:[v.length===1?`A calculation uses`:`${v.length} calculations use`,` this metric and will change with it: `,v.map(e=>e.label).join(`, `),`. To keep `,v.length===1?`it`:`them`,` as `,v.length===1?`it is`:`they are`,`, cancel and duplicate this metric instead.`]}),m&&(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:m}),(0,U.jsxs)(`div`,{className:`sf-explore-editor-actions`,children:[(0,U.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:!!m,children:r?`Add`:`Save`}),(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:o,children:`Cancel`}),c&&(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:c,children:`Add to the model`}),s&&(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`danger`,onClick:s,children:`Remove`})]})]})}function dW(e){let{onChange:t,onAsk:n,editor:r=`you`,chartHeight:i=300,model:a}=e,o=e.sourceId??a?.sourceId??``,s=e.sql??a?.sql??``,c=zN(e.dataSource),l=mP(),u=(0,fW.useId)(),[d,f]=(0,fW.useState)(e.defaultValue??AU),p=(0,fW.useMemo)(()=>vU(e.value??d),[e.value,d]),m=(0,fW.useRef)(e.value??d);m.current=e.value??d;let h=(0,fW.useRef)(a);h.current=a;let g=(0,fW.useCallback)(e=>{let n=vU(e);f(n),t?.(n)},[t]),[_,v]=(0,fW.useState)([]),[y,b]=(0,fW.useState)(),[x,S]=(0,fW.useState)(``),[C,w]=(0,fW.useState)(),[T,E]=(0,fW.useState)(``),D=(0,fW.useRef)(e.onContext);D.current=e.onContext;let O=(e,t,n)=>{S(t),D.current?.({kind:e,summary:t,...n?{subject:n}:{}})},[k,ee]=(0,fW.useState)(``),[te,A]=(0,fW.useState)(()=>(e.value??e.defaultValue)?.fields?.some(e=>e.kind===`derived`)??!1),[ne,re]=(0,fW.useState)(()=>((e.value??e.defaultValue)?.filters?.length??0)>0),ie=p.view??`chart`;(0,fW.useEffect)(()=>{let t=new AbortController;return b(void 0),JS(c.execute({sourceId:o,query:{baseSql:s,page:{limit:1}}},{signal:t.signal})).then(n=>{if(t.signal.aborted)return;let r=n.table.schema.fields;if(v(r),m.current.fields.length===0){let t=h.current?BU(h.current,r):hU(r),n=m.current.rows.length===0&&m.current.values.length===0&&!m.current.split;g({...m.current,fields:t,...e.startWithView&&n?OU(t):{}});let i=t.filter(e=>e.model).length;O(`fields.generated`,i>0?`${i} fields from the ${h.current?.label||h.current?.name} model, and ${t.length-i} generated from the other columns.`:`${t.length} fields generated from the columns. Edit any of them, or add your own.`,{fields:t.map(e=>({id:e.id,kind:e.kind,label:e.label,...e.model?{model:e.model}:{}}))})}}).catch(e=>!t.signal.aborted&&b(rP(e))),()=>t.abort()},[c,o,s]),(0,fW.useEffect)(()=>{if(!a||m.current.fields.length===0)return;let e=HU(m.current.fields,a);JSON.stringify(e)!==JSON.stringify(m.current.fields)&&g({...m.current,fields:e})},[a]);let ae=async t=>{if(e.onPromote)try{let n=await e.onPromote(t,p.fields);O(`field.promoted`,n||`${t.label} offered to the model.`,{field:t,...a?{model:a.name}:{}})}catch(e){S(rP(e))}},oe=t=>!!e.onPromote&&ZU(t,a),se=e=>p.fields.find(t=>t.id===e),ce=e=>p.rows.includes(e)?`rows`:p.split===e?`split`:p.values.includes(e)?`values`:void 0,le=(e,t,n)=>{let r=se(e);if(!r)return;let i=t??(r.kind===`attribute`?`rows`:`values`),a=pW.find(e=>e.id===i).label;if(!pW.find(e=>e.id===i).takes.includes(r.kind))return S(`${r.label} is ${r.kind===`attribute`?`an attribute`:`a ${hW[r.kind]}`}, so it cannot go on “${a}”.`);let o=ce(e),s=yU(p,e,i,n);g(s);let c=i===`split`?[]:s[i],l=c.indexOf(e)+1;O(`shelf.changed`,o===i&&c.length>1?`${r.label} moved to place ${l} of ${c.length} on “${a}”.`:`${r.label} added to “${a}”.`,{...o===i?{moved:r.id}:{added:r.id},shelf:i,rows:s.rows,split:s.split??null,values:s.values})},ue=(e,t)=>{let n=ce(e.id);if(n!==`rows`&&n!==`values`)return;let r=bU(p,e.id,t);if(r===p)return S(`${e.label} is already ${t<0?`first`:`last`} on “${pW.find(e=>e.id===n).label}”.`);g(r),O(`shelf.changed`,`${e.label} moved to place ${r[n].indexOf(e.id)+1} of ${r[n].length} on “${pW.find(e=>e.id===n).label}”.`,{moved:e.id,shelf:n,rows:r.rows,split:r.split??null,values:r.values})},de=(e,t)=>{let n=xU(p,e,t);g(n),O(`shelf.changed`,`${se(e)?.label??e} removed from “${pW.find(e=>e.id===t).label}”.`,{removed:e,shelf:t,rows:n.rows,split:n.split??null,values:n.values})},fe=e=>{g(SU(p,e.id,void 0)),O(`field.removed`,`${e.label} removed.`,{field:e})},pe={bar:`bars`,line:`a line`,area:`an area`},me=p.chart?.type??(se(p.rows[0]??``)?.grain?`line`:`bar`),he=e=>{g({...pU(p,{type:e}),view:`chart`}),O(`chart.changed`,`Drawn as ${pe[e]}.`,{chart:{type:e}})},ge=()=>{g({...p,view:`table`}),O(`view.changed`,`Shown as a table.`,{view:`table`})},j=TU(p),_e=!!p.chart?.swap&&!j,ve=()=>{let e=!_e;g(pU(p,{swap:e})),O(`chart.changed`,e?`Axes swapped: the bars run across, the breakdown down the side.`:`Axes back: the bars stand up, the breakdown along the bottom.`,{chart:{swap:e}})},ye=e=>p.chart?.measures?.[e]??{},be=(e,t)=>{g(fU(p,e.id,t));let n=t.type?`${e.label} drawn as ${pe[t.type]}.`:t.axis===`right`?`${e.label} measured on its own scale, at the right.`:`${e.label} measured on the left scale.`;O(`chart.changed`,n,{measure:e.id,...t})},xe=p.values.filter(e=>ye(e).axis===`right`).length,Se=xe>0&&xe<p.values.length,M=e=>Se?ye(e).axis===`right`?`right`:`left`:void 0,Ce={rows:_e?`Y axis`:`X axis`,values:_e?`X axis`:Se?`Y axes`:`Y axis`,split:`Colour`},we=e=>({id:``,kind:e,label:``,by:r,...e===`metric`?{aggregate:`sum`,column:_.find(e=>/Int|Float|Decimal/.test(String(e.type)))?.name}:e===`attribute`?{column:_[0]?.name}:{expression:``,format:`number`}}),Te=e=>[...e.kind===`attribute`?[{label:`Break down by this`,onSelect:()=>le(e.id,`rows`),hint:`Enter`},{label:`Split by this`,onSelect:()=>le(e.id,`split`),hint:`S`}]:[{label:`Measure this`,onSelect:()=>le(e.id,`values`),hint:`Enter`}],...ce(e.id)?[{label:`Take off the shelves`,onSelect:()=>de(e.id,ce(e.id)),hint:`Delete`}]:[],...(ce(e.id)===`rows`||ce(e.id)===`values`)&&p[ce(e.id)].length>1?[{label:`Move earlier`,onSelect:()=>ue(e,-1),hint:`Alt+←`,disabled:p[ce(e.id)][0]===e.id},{label:`Move later`,onSelect:()=>ue(e,1),hint:`Alt+→`,disabled:p[ce(e.id)].at(-1)===e.id}]:[],{separator:!0},{label:`Edit`,onSelect:()=>w({pill:e,isNew:!1}),hint:`E`},{label:`Remove the field`,onSelect:()=>fe(e),hint:`Shift+Delete`},{label:`Duplicate`,onSelect:()=>w({pill:{...e,label:`${e.label} copy`,by:r,model:void 0},isNew:!0}),hint:`D`},...oe(e)?[{label:a&&[...a.dimensions,...a.measures,...a.metrics].some(t=>t.name===e.id)?`Update it in the model`:`Add to the model`,onSelect:()=>void ae(e),hint:`M`}]:[]],[Ee,De]=(0,fW.useState)(),Oe=(e,t)=>n=>{if(n.button!==0)return;let r={x:n.clientX,y:n.clientY},i=!1,a=n.pointerType!==`touch`,o=(e,t)=>document.elementFromPoint(e,t)?.closest(`[data-shelf]`)?.dataset.shelf,s=(t,n,r)=>{if(t===`split`)return;let i=Array.from(document.querySelectorAll(`[data-shelf="${t}"] [data-pill]`)).filter(t=>t.dataset.pill!==e.id),a=i.findIndex(e=>{let t=e.getBoundingClientRect();return r<t.top||r<=t.bottom&&n<t.left+t.width/2});return a<0?i.length:a},c=a?void 0:window.setTimeout(()=>{a=!0,De({label:e.label,kind:e.kind,x:r.x,y:r.y,over:o(r.x,r.y)})},300),l=e=>a&&e.cancelable&&e.preventDefault(),u=t=>{let n=Math.hypot(t.clientX-r.x,t.clientY-r.y)>=6;if(!a)return n?void d(t):void 0;if(!i&&!n)return;i=!0;let c=o(t.clientX,t.clientY);De({label:e.label,kind:e.kind,x:t.clientX,y:t.clientY,over:c,id:e.id,...c?{place:s(c,t.clientX,t.clientY)}:{}})},d=e=>(window.clearTimeout(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,d),window.removeEventListener(`contextmenu`,d),window.removeEventListener(`touchmove`,l),window.removeEventListener(`keydown`,p),De(void 0),e),f=n=>{if(d(n),!i)return;let r=e=>e.stopPropagation();window.addEventListener(`click`,r,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,r,{capture:!0}),0);let a=o(n.clientX,n.clientY);a?le(e.id,a,s(a,n.clientX,n.clientY)):t&&de(e.id,t)},p=e=>e.key===`Escape`&&d(e);window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,d),window.addEventListener(`contextmenu`,d),window.addEventListener(`touchmove`,l,{passive:!1}),window.addEventListener(`keydown`,p)},ke=e=>t=>{if(t.key===`s`&&e.kind===`attribute`)le(e.id,`split`);else if(t.key===`e`)w({pill:e,isNew:!1});else if(t.key===`d`)w({pill:{...e,label:`${e.label} copy`,by:r,model:void 0},isNew:!0});else if(t.key===`m`&&oe(e))ae(e);else if(t.altKey&&(t.key===`ArrowLeft`||t.key===`ArrowUp`))ue(e,-1);else if(t.altKey&&(t.key===`ArrowRight`||t.key===`ArrowDown`))ue(e,1);else if((t.key===`Delete`||t.key===`Backspace`)&&t.shiftKey)fe(e);else if((t.key===`Delete`||t.key===`Backspace`)&&ce(e.id))de(e.id,ce(e.id));else return;t.preventDefault()},Ae=(e,t)=>!Ee||Ee.place===void 0||e===`split`?!1:p[e].filter(e=>e!==Ee.id)[Ee.place]===t,je=(e,t)=>{let n=_U(e,p.fields,_.length>0?_.map(e=>e.name):void 0),r=t===`values`&&Pe&&ie===`chart`?M(e.id):void 0,i=t?void 0:e.model?`model`:e.by&&e.by!==`the columns`?e.by===`suggested from the columns`?`suggested`:e.by:void 0;return(0,U.jsxs)(`span`,{className:`sf-pill-wrap`,"data-pill":t?e.id:void 0,"data-insert":t&&Ee?.over===t&&Ee.id!==e.id&&Ae(t,e.id)?`before`:void 0,"data-kind":e.kind,"data-on":!t&&ce(e.id)||void 0,"data-bad":n?`true`:void 0,children:[(0,U.jsxs)(`button`,{type:`button`,className:`sf-pill`,"data-kind":e.kind,title:[e.description,n,e.kind===`derived`?e.expression:void 0,e.model?`From the ${a?.label||e.model} model`:void 0,e.by?`Made by ${e.by}`:void 0].filter(Boolean).join(` · `),"aria-keyshortcuts":`Enter S E D${oe(e)?` M`:``} Delete Shift+Delete${t===`rows`||t===`values`?` Alt+ArrowLeft Alt+ArrowRight`:``} Shift+F10`,onPointerDown:Oe(e,t),onClick:()=>t?w({pill:e,isNew:!1}):le(e.id),onKeyDown:ke(e),onContextMenu:t=>l.open(t,`${e.label} actions`,Te(e)),children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,"aria-hidden":`true`,children:mW[e.kind]}),(0,U.jsxs)(`span`,{className:`sf-pill-label`,children:[e.label,` `,(0,U.jsx)(`span`,{className:`sf-visually-hidden`,children:`(${hW[e.kind]}${i?`, ${i===`model`?`from the model`:`by ${i}`}`:``}${r?`, ${r} scale`:``}${t?``:ce(e.id)?`, in use`:``}${n?`, problem: ${n}`:``})`})]}),r&&(0,U.jsx)(`span`,{className:`sf-pill-side`,"data-side":r,"aria-hidden":`true`,children:r}),i&&(0,U.jsx)(`span`,{className:`sf-pill-by`,"data-model":e.model?`true`:void 0,"aria-hidden":`true`,children:i})]}),t?(0,U.jsx)(`button`,{type:`button`,className:`sf-pill-x`,"aria-label":`Take ${e.label} off “${pW.find(e=>e.id===t).label}”`,onClick:()=>de(e.id,t),children:(0,U.jsx)(rI,{icon:`close`})}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:`sf-pill-x`,"data-control":`edit`,"aria-label":`Edit ${e.label}`,onClick:()=>w({pill:e,isNew:!1}),children:(0,U.jsx)(rI,{icon:`edit`})}),ce(e.id)&&(0,U.jsx)(`button`,{type:`button`,className:`sf-pill-x`,"aria-label":`Take ${e.label} off “${pW.find(t=>t.id===ce(e.id)).label}”`,onClick:()=>de(e.id,ce(e.id)),children:(0,U.jsx)(rI,{icon:`close`})})]})]},e.id)},Me=T.trim().toLowerCase(),Ne=e=>p.fields.filter(t=>t.kind===e&&(!Me||t.label.toLowerCase().includes(Me)||t.id.includes(Me))),Pe=(0,fW.useMemo)(()=>EU(p),[p]),Fe=lW(p);return(0,U.jsxs)(`div`,{className:[`sf-explore`,e.className].filter(Boolean).join(` `),children:[a?.dataset&&(0,U.jsx)(eW,{model:a,compact:!0}),(0,U.jsxs)(`div`,{className:`sf-explore-frame`,children:[(0,U.jsxs)(`aside`,{className:`sf-explore-fields`,"aria-label":`Fields`,children:[(0,U.jsx)(`input`,{className:`sf-input`,type:`search`,placeholder:`Find a field`,"aria-label":`Find a field`,value:T,onChange:e=>E(e.target.value)}),[`attribute`,`metric`].map(e=>(0,U.jsxs)(`section`,{"aria-label":e===`attribute`?`Attributes`:`Metrics`,children:[(0,U.jsxs)(`h4`,{className:`sf-explore-heading`,children:[e===`attribute`?`Attributes`:e===`metric`?`Metrics`:`Calculations`,(0,U.jsx)(`button`,{type:`button`,className:`sf-explore-add`,"aria-label":`New ${hW[e]}`,onClick:()=>w({pill:we(e),isNew:!0}),children:(0,U.jsx)(rI,{icon:`add`})})]}),(0,U.jsxs)(`div`,{className:`sf-explore-pills`,children:[Ne(e).map(e=>je(e)),Ne(e).length===0&&(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:Me?`None match.`:`None.`})]})]},e)),(0,U.jsxs)(`details`,{className:`sf-explore-more`,open:te||!!Me&&Ne(`derived`).length>0,onToggle:e=>A(e.currentTarget.open),children:[(0,U.jsxs)(`summary`,{children:[`Calculations`,p.fields.some(e=>e.kind===`derived`)&&(0,U.jsx)(`span`,{className:`sf-explore-count`,children:p.fields.filter(e=>e.kind===`derived`).length})]}),(0,U.jsxs)(`section`,{"aria-label":`Calculations`,children:[(0,U.jsxs)(`h4`,{className:`sf-explore-heading`,children:[`Calculations`,(0,U.jsx)(`button`,{type:`button`,className:`sf-explore-add`,"aria-label":`New ${hW.derived}`,onClick:()=>w({pill:we(`derived`),isNew:!0}),children:(0,U.jsx)(rI,{icon:`add`})})]}),(0,U.jsxs)(`div`,{className:`sf-explore-pills`,children:[Ne(`derived`).map(e=>je(e)),Ne(`derived`).length===0&&(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:Me?`None match.`:`None yet. A calculation is arithmetic over metrics: a rate, a margin, an average.`})]})]}),(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{let e=gU(p.fields);if(e.length===0)return S(`Nothing more to suggest from these columns. Make a calculation of your own with “New calculation”.`);g({...p,fields:[...p.fields,...e]}),O(`fields.suggested`,`${e.length} ${e.length===1?`calculation`:`calculations`} suggested from the column names: ${e.map(e=>e.label).join(`, `)}. They are guesses to keep, edit or remove.`,{fields:e})},children:`Suggest calculations`})]}),C&&(0,U.jsx)(uW,{pill:C.pill,all:p.fields,columns:_,isNew:C.isNew,modelLabel:C.pill.model?a?.label||C.pill.model:void 0,onPromote:!C.isNew&&oe(C.pill)?()=>(ae(C.pill),w(void 0)):void 0,onCancel:()=>w(void 0),onSave:e=>{let t={...e,by:r,model:void 0};g(SU(p,C.isNew?t.id:C.pill.id,t)),O(C.isNew?`field.added`:`field.changed`,`${t.label} ${C.isNew?`added`:`saved`}.`,{field:t,...C.isNew?{}:{was:C.pill}}),w(void 0)},onRemove:C.isNew?void 0:()=>{g(SU(p,C.pill.id,void 0)),O(`field.removed`,`${C.pill.label} removed.`,{field:C.pill}),w(void 0)}},`${C.pill.id}-${C.isNew}`)]}),(0,U.jsxs)(`div`,{className:`sf-explore-main`,children:[n&&(0,U.jsxs)(`form`,{className:`sf-explore-ask`,onSubmit:e=>{e.preventDefault(),k.trim()&&(n(k.trim(),p),O(`asked`,`Asked: “${k.trim()}”.`,{text:k.trim()}),ee(``))},children:[(0,U.jsx)(`input`,{className:`sf-input`,"aria-label":`Ask for a field or a view`,placeholder:`Ask for a field or a view: refund rate by region, split by channel`,value:k,onChange:e=>ee(e.target.value)}),(0,U.jsx)(`button`,{type:`submit`,className:`sf-button`,disabled:!k.trim(),children:`Ask`})]}),(0,U.jsx)(`div`,{className:`sf-explore-shelves`,children:pW.map(e=>{let t=e.id===`split`?p.split?[p.split]:[]:p[e.id];return(0,U.jsxs)(`div`,{className:`sf-explore-shelf`,"data-shelf":e.id,"data-over":Ee?.over===e.id||void 0,"data-accepts":Ee?e.takes.includes(Ee.kind):void 0,role:`group`,"aria-label":e.label,children:[(0,U.jsx)(`span`,{className:`sf-explore-shelf-name`,title:e.hint,children:e.label}),Pe&&ie===`chart`&&(e.id!==`split`||p.values.length===1)&&(0,U.jsx)(`span`,{className:`sf-explore-axis`,"data-axis":e.id===`split`?`colour`:Ce[e.id]===`X axis`?`x`:`y`,title:e.id===`values`&&Se?`Each measure's pill says which side's scale it is read against.`:void 0,children:Ce[e.id]}),t.map(e=>se(e)).filter(e=>!!e).map(t=>je(t,e.id)),t.length===0&&(0,U.jsx)(`span`,{className:`sf-explore-hint`,children:Ee?e.takes.includes(Ee.kind)?`Drop here`:`Not for this field`:e.id===`values`?`Press a metric`:e.id===`rows`?`Press an attribute`:`Optional`})]},e.id)})}),Pe&&(0,U.jsxs)(`div`,{className:`sf-explore-chart-settings`,children:[(0,U.jsxs)(`div`,{className:`sf-segmented sf-result-views`,role:`group`,"aria-label":`Draw as`,children:[[`bar`,`line`,`area`].map(e=>{let t=ie===`chart`&&me===e;return(0,U.jsx)(`button`,{type:`button`,className:`sf-segment`,"data-checked":t||void 0,"aria-pressed":t,onClick:()=>he(e),children:e===`bar`?`Bars`:e===`line`?`Line`:`Area`},e)}),(0,U.jsx)(`button`,{type:`button`,className:`sf-segment`,"data-checked":ie===`table`||void 0,"aria-pressed":ie===`table`,onClick:ge,children:`Table`})]}),ie===`chart`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-pressed":_e,"aria-disabled":!!j||void 0,title:j,"aria-describedby":j?`${u}-swap`:void 0,onClick:()=>!j&&ve(),children:`Swap axes`}),j&&(0,U.jsx)(`span`,{id:`${u}-swap`,className:`sf-explore-hint`,children:j}),p.values.length>1&&(0,U.jsx)(`ul`,{className:`sf-explore-measures`,"aria-label":`Each measure`,children:p.values.map(e=>se(e)).filter(e=>!!e).map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`sf-explore-measure-name`,children:e.label}),(0,U.jsxs)(`select`,{className:`sf-input`,"aria-label":`Draw ${e.label} as`,value:ye(e.id).type??me,onChange:t=>be(e,{type:t.target.value}),children:[(0,U.jsx)(`option`,{value:`bar`,children:`Bars`}),(0,U.jsx)(`option`,{value:`line`,children:`Line`}),(0,U.jsx)(`option`,{value:`area`,children:`Area`})]}),(0,U.jsxs)(`select`,{className:`sf-input`,"aria-label":`Scale for ${e.label}`,value:ye(e.id).axis??`left`,onChange:t=>be(e,{axis:t.target.value}),children:[(0,U.jsx)(`option`,{value:`left`,children:`Left scale`}),(0,U.jsx)(`option`,{value:`right`,children:`Right scale`})]})]},e.id))})]})]}),(0,U.jsxs)(`details`,{className:`sf-explore-more`,open:ne,onToggle:e=>re(e.currentTarget.open),children:[(0,U.jsxs)(`summary`,{children:[`Filters`,p.filters.length>0&&(0,U.jsx)(`span`,{className:`sf-explore-count`,children:p.filters.length})]}),(0,U.jsx)(sU,{sourceId:o,sql:s,filters:p.filters,onChange:e=>g({...p,filters:e}),onContext:e.onContext,dataSource:c})]}),y&&(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:y}),p.values.length===0?(0,U.jsx)(`p`,{className:`sf-explore-empty`,children:`Press a metric to measure it, then an attribute to break it down. Each press, drag or edit asks the database again; nothing is worked out in this page.`}):(0,U.jsxs)(`div`,{className:`sf-explore-result sf-controls-host`,"data-controls":`corner`,children:[e.controls?.length?(0,U.jsx)(iI,{label:`${Fe||`View`} controls`,controls:e.controls}):null,(0,U.jsx)(`p`,{className:`sf-explore-reading`,children:Fe}),!Pe&&(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:`With nothing to break down by there is one number each. Press an attribute for a chart.`}),(0,U.jsx)(cW,{dataSource:c,sourceId:o,sql:s,state:p,view:ie,height:i,label:Fe}),e.actions&&(0,U.jsx)(`div`,{className:`sf-explore-actions`,children:e.actions})]}),(0,U.jsx)(`p`,{className:`sf-explore-note`,role:`status`,children:x})]})]}),Ee&&(0,U.jsxs)(`span`,{className:`sf-pill sf-pill-ghost`,"data-kind":Ee.kind,"aria-hidden":`true`,style:{left:Ee.x,top:Ee.y},children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,children:mW[Ee.kind]}),Ee.label]}),l.element]})}var U,fW,pW,mW,hW,gW,_W,vW,yW,bW=n((()=>{U=HA(),rw(),fW=jM(),vF(),uI(),UN(),tP(),oP(),uU(),_P(),RU(),QU(),iW(),pW=[{id:`rows`,label:`Break down by`,takes:[`attribute`],hint:`An attribute: one bar, point or row for each of its values.`},{id:`split`,label:`Split by`,takes:[`attribute`],hint:`An attribute whose values become separate series.`},{id:`values`,label:`Measure`,takes:[`metric`,`derived`],hint:`Metrics and calculations: what is counted or added up.`}],mW={attribute:`Abc`,metric:`Σ`,derived:`ƒ`},hW={attribute:`attribute`,metric:`metric`,derived:`calculation`},gW=[{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`count`,label:`Count`},{value:`count_distinct`,label:`Count of distinct values`},{value:`min`,label:`Smallest`},{value:`max`,label:`Largest`},{value:`median`,label:`Median`}],_W=[`day`,`week`,`month`,`quarter`,`year`],vW=[`number`,`compact`,`currency`,`percent`],yW=e=>[...e.rows,...e.split?[e.split]:[],...e.values].map(t=>e.fields.find(e=>e.id===t)).filter(e=>!!e)}));function xW(e,t){return vU({fields:e.fields,rows:t.rows,...t.split?{split:t.split}:{},values:t.values,filters:e.filters,...t.view?{view:t.view}:{},...t.chart?{chart:t.chart}:{}})}function SW(e){let t=e.draft??{rows:[],values:[]};return{fields:e.fields,rows:t.rows,...t.split?{split:t.split}:{},values:t.values,filters:e.filters,...t.view?{view:t.view}:{},...t.chart?{chart:t.chart}:{}}}function CW(e,t){return{...e,fields:t.fields,filters:t.filters,draft:{rows:t.rows,...t.split?{split:t.split}:{},values:t.values,...t.view?{view:t.view}:{},...t.chart?{chart:t.chart}:{}}}}function wW(e,t){let n=e.draft,r=n?xW(e,n):void 0;if(!n||!r||r.values.length===0)return e;let i={rows:r.rows,...r.split?{split:r.split}:{},values:r.values,...n.view?{view:n.view}:{},chart:r.chart};if(e.editing&&e.tiles.some(t=>t.id===e.editing))return{...e,tiles:e.tiles.map(n=>n.id===e.editing?{...n,...i,...i.split?{}:{split:void 0},...t===void 0?{}:{title:t||void 0}}:n),editing:void 0};if(e.tiles.length>=24)return e;let a=r.rows.length===0?3:1,{chart:o,...s}=i;return{...e,tiles:[...e.tiles,{id:jW(e.tiles),...t?{title:t}:{},...s,...o?{chart:o}:{},span:a}]}}function TW(e,t){let n=e.tiles.find(e=>e.id===t);return n?{...e,editing:t,draft:{rows:n.rows,...n.split?{split:n.split}:{},values:n.values,...n.view?{view:n.view}:{},...n.chart?{chart:n.chart}:{}}}:e}function EW(e,t){return{...e,tiles:e.tiles.filter(e=>e.id!==t),...e.editing===t?{editing:void 0}:{}}}function DW(e,t,n){let r=e.tiles.findIndex(e=>e.id===t),i=r+n;if(r<0||i<0||i>=e.tiles.length)return e;let a=[...e.tiles];return[a[r],a[i]]=[a[i],a[r]],{...e,tiles:a}}function OW(e,t,n){return{...e,tiles:e.tiles.map(e=>e.id===t?{...e,...n}:e)}}function kW(e){if(e.fields.length===0)return e;let t=new Set,n=[];for(let r of e.tiles.slice(0,24)){let i=xW(e,r);if(i.values.length===0)continue;let a=r.id||jW(n);t.has(a)&&(a=jW(n)),t.add(a);let o=r.span===2||r.span===3?r.span:1;n.push({id:a,...r.title?{title:r.title}:{},rows:i.rows,...i.split?{split:i.split}:{},values:i.values,...r.view?{view:r.view}:{},...i.chart?{chart:i.chart}:{},span:o})}return{...e,tiles:n,...e.editing&&!n.some(t=>t.id===e.editing)?{editing:void 0}:{}}}var AW,jW,MW=n((()=>{RU(),AW={fields:[],filters:[],tiles:[]},jW=e=>{for(let t=e.length+1;;t++)if(!e.some(e=>e.id===`tile-${t}`))return`tile-${t}`}}));function NW(e){let{label:t,options:n,value:r,onChange:i,fit:a=`content`,className:o}=e,s=(0,FW.useId)(),c=e.name??s;return(0,PW.jsx)(`div`,{className:[`sf-segmented`,`sf-segmented-control`,o].filter(Boolean).join(` `),"data-fit":a,role:`radiogroup`,"aria-label":t,children:n.map(e=>(0,PW.jsxs)(`label`,{className:`sf-segment`,"data-checked":e.value===r||void 0,"data-disabled":e.disabled||void 0,children:[(0,PW.jsx)(`input`,{type:`radio`,name:c,value:e.value,checked:e.value===r,"aria-disabled":e.disabled||void 0,onChange:()=>{e.disabled||i(e.value)}}),e.label]},e.value))})}var PW,FW,IW=n((()=>{PW=HA(),FW=jM()}));function LW(e){let{onChange:t,onAsk:n,editor:r,model:i}=e,a=e.sourceId??i?.sourceId??``,o=e.sql??i?.sql??``,s=zN(e.dataSource),[c,l]=(0,BW.useState)(e.defaultValue??AW),u=(0,BW.useMemo)(()=>kW(e.value??c),[e.value,c]),d=(0,BW.useCallback)(e=>{let n=kW(e);l(n),t?.(n)},[t]),[f,p]=(0,BW.useState)(`build`),m=e.mode??f,h=t=>{p(t),e.onModeChange?.(t),e.onContext?.({kind:`mode.changed`,summary:t===`view`?`Switched to viewing the report.`:`Switched to building the report.`,subject:{mode:t}})},[g,_]=(0,BW.useState)(``),v=(t,n,r)=>{_(n),e.onContext?.({kind:t,summary:n,...r?{subject:r}:{}})},y=e=>({rows:e.rows,split:e.split??null,values:e.values,view:e.view??`chart`}),b=(0,BW.useMemo)(()=>SW(u),[u]),x=u.tiles.find(e=>e.id===u.editing),S=!x&&u.tiles.length>=24,C=e=>e.title||lW(xW(u,e))||z(`report.untitled`),w=()=>{let e=wW(u);if(e===u)return _(S?z(`report.maxViews`,{max:24}):z(`report.needMeasure`));d(e);let t=x?e.tiles.find(e=>e.id===x.id):e.tiles.at(-1);v(x?`view.changed`:`view.added`,x?`${C(x)} updated: it now shows ${lW(RW(u))}.`:`Added to the report: ${lW(RW(u))||`a view`}. The shelves are as you left them, for the next one.`,t?{tile:t.id,...y(t)}:void 0)},T=(0,zW.jsx)(`div`,{className:`sf-report-tiles`,"data-mode":m,children:u.tiles.map((e,t)=>{let n=xW(u,e),r=C(e);return(0,zW.jsxs)(`section`,{className:`sf-report-tile sf-controls-host`,"data-controls":`corner`,"data-span":e.span??1,"data-editing":u.editing===e.id||void 0,"aria-label":r,children:[(0,zW.jsxs)(`header`,{className:`sf-report-tile-head`,children:[m===`build`?(0,zW.jsx)(`input`,{className:`sf-report-tile-title`,"aria-label":z(`report.tileTitle`,{title:r}),value:e.title??``,placeholder:lW(n),onChange:t=>d(OW(u,e.id,{title:t.target.value||void 0}))}):(0,zW.jsx)(`h4`,{className:`sf-report-tile-title`,children:r}),m===`build`&&(0,zW.jsx)(iI,{label:z(`report.tileControls`,{title:r}),controls:aI(r,{edit:()=>(d(TW(u,e.id)),v(`view.opened`,`${r} is on the shelves. Change it, then press “Update view”.`,{tile:e.id,...y(e)})),...n.rows.length>0?{view:{now:e.view??`chart`,toggle:()=>(d(OW(u,e.id,{view:(e.view??`chart`)===`chart`?`table`:`chart`})),v(`view.changed`,`${r} is shown as a ${(e.view??`chart`)===`chart`?`table`:`chart`}.`,{tile:e.id,view:(e.view??`chart`)===`chart`?`table`:`chart`}))}}:{},wider:(e.span??1)<3?()=>(d(OW(u,e.id,{span:(e.span??1)+1})),v(`view.resized`,`${r} made wider.`,{tile:e.id,span:(e.span??1)+1})):!1,narrower:(e.span??1)>1?()=>(d(OW(u,e.id,{span:(e.span??1)-1})),v(`view.resized`,`${r} made narrower.`,{tile:e.id,span:(e.span??1)-1})):!1,earlier:t>0?()=>(d(DW(u,e.id,-1)),v(`view.moved`,`${r} moved earlier.`,{tile:e.id,order:DW(u,e.id,-1).tiles.map(e=>e.id)})):!1,later:t<u.tiles.length-1?()=>(d(DW(u,e.id,1)),v(`view.moved`,`${r} moved later.`,{tile:e.id,order:DW(u,e.id,1).tiles.map(e=>e.id)})):!1,remove:()=>(d(EW(u,e.id)),v(`view.removed`,`${r} removed from the report.`,{tile:e.id,...y(e)}))})})]}),(0,zW.jsx)(cW,{dataSource:s,sourceId:a,sql:o,state:n,height:240,label:r,onPointClick:(t,n)=>{let i=KC(u.filters,t,n);d({...u,filters:i});let a=GC(i,t),o=a.some(e=>String(e)===String(n));v(`point.selected`,o?`Clicked ${n} in “${r}”: the report is filtered to ${t} ${a.length===1?`is`:`is one of`} ${a.join(`, `)}. Click the bar again to take it out.`:`Clicked ${n} in “${r}” again: ${n} is taken out of the filter on ${t}${a.length===0?`, which is now cleared`:``}.`,{tile:e.id,column:t,value:n,filters:i})}})]},e.id)})});return(0,zW.jsxs)(`div`,{className:[`sf-report`,e.className].filter(Boolean).join(` `),"data-mode":m,children:[(0,zW.jsxs)(`header`,{className:`sf-report-head`,children:[m===`build`?(0,zW.jsx)(`input`,{className:`sf-report-title`,"aria-label":z(`report.title`),placeholder:z(`report.untitledReport`),value:u.title??``,onChange:e=>d({...u,title:e.target.value||void 0})}):(0,zW.jsx)(`h3`,{className:`sf-report-title`,children:u.title||z(`report.untitledReport`)}),(0,zW.jsx)(NW,{label:z(`report.mode`),value:m,onChange:h,options:[{value:`build`,label:z(`report.build`)},{value:`view`,label:z(`report.view`)}]})]}),i?.dataset&&(0,zW.jsx)(eW,{model:i,compact:!0}),m===`build`&&(0,zW.jsxs)(`section`,{className:`sf-report-builder`,"aria-label":z(`report.builder`),children:[x&&(0,zW.jsxs)(`p`,{className:`sf-report-editing`,role:`status`,children:[z(`report.changing`,{title:C(x)}),` `,(0,zW.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>(d({...u,editing:void 0}),_(z(`report.leftAsItWas`))),children:z(`report.leaveAsItWas`)})]}),(0,zW.jsx)(dW,{dataSource:s,sourceId:a,sql:o,model:i,onPromote:e.onPromote,value:b,onChange:e=>d(CW(u,e)),onAsk:n?e=>n(e,u):void 0,editor:r,onContext:e.onContext,chartHeight:240,controls:[{id:`keep`,label:z(x?`report.updateView`:`report.addToReport`),icon:x?`confirm`:`add`,onSelect:w,disabled:S,pinned:!0}]})]}),(0,zW.jsxs)(`section`,{className:`sf-report-body`,"aria-label":z(`report.body`),children:[m===`view`&&u.fields.length>0&&(0,zW.jsx)(sU,{dataSource:s,sourceId:a,sql:o,filters:u.filters,onChange:e=>d({...u,filters:e}),onContext:e.onContext}),u.tiles.length===0?(0,zW.jsx)(`p`,{className:`sf-explore-empty`,children:z(m===`build`?`report.emptyBuild`:`report.emptyView`)}):T]}),(0,zW.jsx)(`p`,{className:`sf-explore-note`,role:`status`,children:g})]})}function RW(e){return xW(e,e.draft??{rows:[],values:[]})}var zW,BW,VW=n((()=>{zW=HA(),BW=jM(),BA(),uI(),IW(),rw(),UN(),uU(),bW(),iW(),MW()}));function HW(e){let t=(0,WW.useContext)(GW);return jN(`Semantics`,e??t)}function UW(e,t={}){let n=HW(t.semantics),r=t.editor??`you`,[i,a]=(0,WW.useState)(),[o,s]=(0,WW.useState)(),[c,l]=(0,WW.useState)(!1),[u,d]=(0,WW.useState)(!1),[f,p]=(0,WW.useState)(0);(0,WW.useEffect)(()=>{if(!e)return a(void 0);if(!n)return s(`There is no store of semantic models here, so "${e}" cannot be read.`);let t=!0;return l(!0),n.getSemanticModel({name:e}).then(e=>t&&(a(e.model),s(void 0),d(!1))).catch(e=>t&&(s(rP(e)),d(/no semantic model|not found/i.test(rP(e))))).finally(()=>t&&l(!1)),()=>{t=!1}},[n,e,f]);let m=(0,WW.useCallback)(async(e,t)=>{if(n)try{let o=await n.saveSemanticModel({model:{...e,savedBy:r},expectedVersion:i?.version??e.version,note:t});return a(o.model),s(void 0),d(!1),o.model}catch(e){(e instanceof hC||/saved by someone else/.test(rP(e)))&&p(e=>e+1),s(rP(e));return}},[n,r,i?.version]);return{model:i,problem:o,missing:u,loading:c,promote:(0,WW.useCallback)(async(e,t)=>{if(!i)return`There is no model to add it to.`;let n=[...i.dimensions,...i.measures,...i.metrics].some(t=>t.name===e.id),a=await m(UU(i,e,t,r),`${n?`Changed`:`Added`} ${e.label}`);return a?`${e.label} ${n?`changed in`:`added to`} the ${a.label||a.name} model (version ${a.version}). Every report on it now uses this definition.`:`${e.label} was not saved to the model.`},[i,m,r]),save:m,reload:()=>p(e=>e+1)}}var WW,GW,KW=n((()=>{HA(),rw(),LN(),WW=jM(),oP(),QU(),GW=(0,WW.createContext)(void 0)}));function qW(e){return e.map(e=>({left:e.left,right:e.right,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),type:iG(e.type),...e.definedBy===`inferred from names`?{inferred:!0}:{},...e.definedBy===`declared by the source`?{declared:!0}:{}}))}function JW(e,t,n,r){let i=new Map(qW(e.joins).map((t,n)=>[az(t),e.joins[n].definedBy])),a=t.joins.map(e=>ym(hS,{left:e.left,right:e.right,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),type:rG(e.type),definedBy:e.inferred?$W:e.declared?eG:(e=>e&&e!==`inferred from names`?e:n)(i.get(az(e)))}));return ym(pS,{...e,tables:t.tables,joins:a,sql:r?.sql??YW(t).sql})}function YW(e){return dz({tables:e.tables,joins:e.joins.filter(e=>!e.inferred)})}function XW(e){let{model:t,columns:n,onChange:r,editor:i,dataSource:a}=e,o=(0,QW.useId)(),s=!!r,c=t.tables.length>0,[l,u]=(0,QW.useState)(),d=l??(!c&&!!t.sql.trim()&&!e.building),[f,p]=(0,QW.useState)(),[m,h]=(0,QW.useState)(!1),g=n.map(e=>e.name),_=c?YW({tables:t.tables,joins:qW(t.joins)}).unjoined:[],v=t.joins.filter(e=>e.definedBy===$W),y=[...t.dimensions.map(e=>e.column),...t.measures.map(e=>e.column)].filter(Boolean),[b,x]=(0,QW.useState)(()=>({tables:t.tables,joins:qW(t.joins)})),[S,C]=(0,QW.useState)(0),w=(0,QW.useRef)(aG(t)),T=aG(t);(0,QW.useEffect)(()=>{w.current!==T&&(w.current=T,x({tables:t.tables,joins:qW(t.joins)}),C(e=>e+1))},[T]);let E=(e,n)=>r?.(ym(pS,{...t,...e}),n),D=e=>{let n=t.primaryKey.includes(e)?t.primaryKey.filter(t=>t!==e):[...t.primaryKey,e];p(void 0),E({primaryKey:n},n.length?`The key is now ${n.join(`, `)}.`:`The model has no key yet.`)},O=async()=>{h(!0);try{let e=await cC(t,a);p(e?{ok:!1,text:e}:{ok:!0,text:`Unique: each ${t.primaryKey.join(` and `)} names one row, so sums count each row once.`})}catch(e){p({ok:!1,text:rP(e)})}finally{h(!1)}};return(0,ZW.jsxs)(`section`,{className:`sf-semantic-section sf-semantic-rows`,"aria-labelledby":`${o}-rows`,children:[(0,ZW.jsx)(`h4`,{id:`${o}-rows`,className:`sf-explore-heading`,children:(0,ZW.jsx)(`span`,{children:`Rows`})}),(0,ZW.jsx)(`p`,{className:`sf-explore-hint`,children:`What one row is, and where the rows come from. Sums are right only when each row is one thing.`}),(0,ZW.jsxs)(`div`,{className:`sf-semantic-grain`,children:[(0,ZW.jsx)(`label`,{htmlFor:`${o}-grain`,children:`One row is`}),s?(0,ZW.jsx)(`input`,{id:`${o}-grain`,className:`sf-input`,placeholder:`One order line.`,value:t.grain,onChange:e=>E({grain:e.target.value}),onBlur:e=>e.target.value.trim()&&E({grain:e.target.value},`One row is now: ${e.target.value.trim()}`)}):(0,ZW.jsx)(`span`,{id:`${o}-grain`,children:t.grain||`not said yet`})]}),(0,ZW.jsxs)(`div`,{className:`sf-semantic-key`,children:[(0,ZW.jsx)(`span`,{id:`${o}-key`,children:`Unique by`}),t.primaryKey.length>0?(0,ZW.jsx)(`span`,{className:`sf-semantic-chips`,"aria-labelledby":`${o}-key`,children:t.primaryKey.map(e=>(0,ZW.jsx)(`code`,{children:e},e))}):(0,ZW.jsx)(`span`,{className:`sf-explore-hint`,children:`no key yet`}),s&&g.length>0&&(0,ZW.jsxs)(`details`,{className:`sf-semantic-pick`,children:[(0,ZW.jsx)(`summary`,{children:`Choose the key`}),(0,ZW.jsxs)(`fieldset`,{children:[(0,ZW.jsx)(`legend`,{className:`sf-a2-visually-hidden`,children:`Columns that make a row unique`}),g.map(e=>(0,ZW.jsxs)(`label`,{className:`sf-semantic-option`,children:[(0,ZW.jsx)(`input`,{type:`checkbox`,checked:t.primaryKey.includes(e),onChange:()=>D(e)}),` `,e]},e))]})]}),t.primaryKey.length>0&&t.sql.trim()&&(0,ZW.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:m,onClick:()=>void O(),children:m?`Checking…`:`Check the key`})]}),f&&(0,ZW.jsx)(`p`,{className:f.ok?`sf-explore-hint`:`sf-filter-problem`,role:f.ok?`status`:`alert`,children:f.text}),s&&!d?(0,ZW.jsxs)(ZW.Fragment,{children:[(0,ZW.jsx)(`p`,{className:`sf-explore-hint`,children:`Tables and joins. The first table is where the rows come from; each join adds detail to it and says whether it keeps every row and whether it can repeat rows.`}),(0,ZW.jsx)(_z,{sourceId:t.sourceId,tables:b.tables,joins:b.joins,height:400,rowsFrom:!0,usedColumns:y,label:`The model's tables and joins`,dataSource:a,onChange:(e,n)=>{let a=JW(t,e,i,n),o=aG(a)===aG(t);if(o&&(a.sql===t.sql||t.version>0))return;w.current=aG(a);let s=e.joins.map(e=>`${oz(e)} keeps ${sz(e,e.type??`inner`).toLowerCase()}`);r?.(a,o?void 0:`The rows now come from ${e.tables.join(`, `)||`no table`}${s.length?`: ${s.join(`; `)}`:``}.`)}},S),v.length>0&&(0,ZW.jsxs)(`p`,{className:`sf-result-notice`,children:[v.length,` inferred `,v.length===1?`join is`:`joins are`,` a guess from names: confirm `,v.length===1?`it`:`them`,` in the joins to use `,v.length===1?`it`:`them`,`.`]})]}):c?(0,ZW.jsxs)(`div`,{className:`sf-semantic-from`,children:[(0,ZW.jsxs)(`p`,{children:[`From `,(0,ZW.jsx)(`code`,{children:t.tables[0]}),t.tables.length>1?(0,ZW.jsxs)(ZW.Fragment,{children:[`, with the detail of`,` `,t.tables.slice(1).map((e,t)=>(0,ZW.jsxs)(`span`,{children:[t>0&&`, `,(0,ZW.jsx)(`code`,{children:e})]},e))]}):` alone`,`. The first table's rows are the model's rows.`]}),t.joins.length>0&&(0,ZW.jsx)(`ul`,{className:`sf-semantic-joins`,children:qW(t.joins).map((e,n)=>(0,ZW.jsxs)(`li`,{"data-inferred":e.inferred||void 0,children:[(0,ZW.jsx)(`code`,{children:oz(e)}),` `,(0,ZW.jsxs)(`span`,{className:`sf-semantic-format`,children:[`· keeps `,sz(e,e.type??`inner`).toLowerCase(),` · `,e.inferred?`Inferred, not in the query until confirmed`:t.joins[n].definedBy||`—`]})]},az(e)))}),_.length>0&&(0,ZW.jsxs)(`p`,{className:`sf-result-notice`,children:[`Not joined to the first table, so left out: `,_.join(`, `),`.`]})]}):(0,ZW.jsx)(`p`,{children:t.sql.trim()?`Written as a query.`:`No rows yet: add a table, or write the query.`}),(0,ZW.jsxs)(`details`,{className:`sf-semantic-query`,children:[(0,ZW.jsx)(`summary`,{children:`The query`}),t.sql.trim()?(0,ZW.jsx)(NL,{code:t.sql,language:`sql`,label:`The model's query`}):(0,ZW.jsx)(`p`,{className:`sf-explore-hint`,children:`No query yet: add a table, or write one.`})]}),s&&(0,ZW.jsx)(`div`,{className:`sf-semantic-actions`,children:(0,ZW.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-expanded":d,onClick:()=>u(!d),children:d?`Build from tables instead`:`Write the query instead`})}),s&&d&&(0,ZW.jsxs)(`div`,{className:`sf-semantic-write`,children:[(0,ZW.jsx)(`p`,{id:`${o}-sql`,children:`The model's query, one read-only SELECT`}),(0,ZW.jsx)(`div`,{onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||E({},`The query was rewritten.`)},children:(0,ZW.jsx)(yF,{value:t.sql,onChange:e=>E({sql:e,tables:[],joins:[]}),label:`The model's query, one read-only SELECT`,minHeight:120,maxHeight:320})})]})]})}var ZW,QW,$W,eG,tG,nG,rG,iG,aG,oG=n((()=>{ZW=HA(),zb(),rw(),vS(),QW=jM(),oP(),Mz(),zL(),xF(),$W=`inferred from names`,eG=`declared by the source`,tG={[Kx.UNSPECIFIED]:`inner`,[Kx.INNER]:`inner`,[Kx.LEFT]:`left`,[Kx.RIGHT]:`right`,[Kx.FULL]:`full`},nG={inner:Kx.INNER,left:Kx.LEFT,right:Kx.RIGHT,full:Kx.FULL},rG=e=>nG[e??`inner`],iG=e=>tG[e]??`inner`,aG=e=>JSON.stringify([e.tables,qW(e.joins).map(e=>[az(e),e.type,e.left,!!e.inferred])])}));function sG(e,t){return t.kind===`attribute`?e.dimensions.find(e=>e.name===t.id)?.kind===gS.TIME?`${t.column}, by ${t.grain??`month`}`:t.column??``:t.kind===`metric`?t.column?`${dG[t.aggregate??``]??t.aggregate} of ${t.column}`:`Count of rows`:t.expression??``}function cG(e){let{model:t,onSave:n,editor:r=`you`}=e,i=t.version===0,a=zN(e.dataSource),o=(0,lG.useId)(),[s,c]=(0,lG.useState)(e.defaultDraft),l=e.draft!==void 0||e.onDraftChange?e.draft:s,u=l??t,d=t=>{c(t),e.onDraftChange?.(t)},f=(0,lG.useRef)(e.onContext);f.current=e.onContext;let[p,m]=(0,lG.useState)(``),h=(e,t,n)=>{m(t),f.current?.({kind:e,summary:t,...n?{subject:n}:{}})},[g,_]=(0,lG.useState)([]),[v,y]=(0,lG.useState)();(0,lG.useEffect)(()=>{if(!u.sql.trim()||!u.sourceId)return _([]),y(void 0);let e=new AbortController;return JS(a.execute({sourceId:u.sourceId,query:{baseSql:u.sql,page:{limit:1}}},{signal:e.signal})).then(t=>!e.signal.aborted&&(_(t.table.schema.fields),y(void 0))).catch(t=>!e.signal.aborted&&y(rP(t))),()=>e.abort()},[a,u.sourceId,u.sql]);let b=OB(e.pipelines),[x,S]=(0,lG.useState)([]),[C,w]=(0,lG.useState)(``);(0,lG.useEffect)(()=>{if(!i||!n||!b)return;let e=new AbortController,r={signal:e.signal};return b.listPipelines({},r).then(e=>Promise.all(e.pipelines.filter(e=>!t.sourceId||e.sourceId===t.sourceId).map(e=>b.getPipeline({id:e.id},r).then(e=>e.pipeline)))).then(t=>!e.signal.aborted&&S(t.filter(e=>!!e&&e.datasets.some(e=>e.kind!==Qx.SOURCE)))).catch(()=>!e.signal.aborted&&S([])),()=>e.abort()},[b,i,!!n,t.sourceId]);let T=()=>{let[e,t]=C.split(`:`).map(Number),n=x[e??-1],r=n?.datasets[t??-1]?.name,i=n?.summary?.id??``;if(!n||!r)return;let a=TC(n,r,{...u.name?{name:u.name}:{},...u.label?{label:u.label}:{}});u.description&&(a.description=u.description),se(a),de(!0),h(`rows.changed`,`Started from the dataset ${r} of ${AC(n.summary?.name||i)}: its grain, key and ${a.dimensions.length+a.measures.length} fields from its columns, for you to check.`,{pipeline:i,dataset:r})},E=(0,lG.useMemo)(()=>zU(u),[u]),D=(0,lG.useMemo)(()=>l?KU(t,l):new Map,[t,l]),O=(0,lG.useMemo)(()=>zU(t).filter(e=>D.get(e.id)===`removed`),[t,D]),k=g.map(e=>e.name),ee=(0,lG.useMemo)(()=>{let e=l?mC(l,{isNew:i}):[];if(g.length>0)for(let t of E)t.column&&!k.includes(t.column)&&e.push(`"${t.id}" names the column "${t.column}", which the query does not return.`);return e},[l,E,g]),[te,A]=(0,lG.useState)(),[ne,re]=(0,lG.useState)(``),[ie,ae]=(0,lG.useState)(!1),oe=e=>({id:``,kind:e,label:``,by:r,...e===`metric`?{aggregate:`sum`,column:g.find(e=>/Int|Float|Decimal/.test(String(e.type)))?.name}:e===`attribute`?{column:g[0]?.name}:{expression:``,format:`number`}}),se=e=>d(!i&&KU(t,e).size===0?void 0:e),ce=(e,t)=>se(GU(u,e,t,r)),le=e=>se(ym(pS,{...u,...e})),[ue,de]=(0,lG.useState)(!i||!!t.name),fe=()=>{let e=new Set(bV(g.map(e=>e.name)).map(e=>e.column)),t=sC(g.map(t=>({name:t.name,type:String(t.type),personal:e.has(t.name)})),{grain:u.grain}),n=Hh(pS,u);n.dimensions=(t.dimensions??[]).map(e=>ym(dS,e)),n.measures=(t.measures??[]).map(e=>ym(fS,e)),se(n),h(`fields.drafted`,`Fields drafted from the query's ${g.length} columns by name and type${e.size?`, leaving out ${e.size} that may hold personal data`:``}. Check them before saving.`)},[pe,me]=(0,lG.useState)(``),he=()=>{let t=pe.trim();t&&e.onAsk&&(e.onAsk(t,u),me(``),m(`Sent to ${e.askLabel??`the agent`}.`))},ge=e=>{let n=zU(t).find(t=>t.id===e);n&&(ce(e,n),h(`field.restored`,`${n.label} put back as it is saved.`,{field:e}))},j=async()=>{if(!(!l||!n||ee.length>0)){ae(!0);try{let e=await n(l,ne.trim()||`${D.size} ${D.size===1?`change`:`changes`}`);e&&(d(void 0),re(``),h(`model.saved`,`Saved as version ${e.version}. Every report and explorer on this model now uses it.`,{model:e.name,version:e.version,changes:Object.fromEntries(D)}))}catch(e){m(rP(e))}finally{ae(!1)}}},_e=e.onAsk&&(0,W.jsxs)(`form`,{className:`sf-semantic-ask`,onSubmit:e=>{e.preventDefault(),he()},children:[(0,W.jsx)(`label`,{htmlFor:`${o}-ask`,children:i?`Tell ${e.askLabel??`the agent`} what this model should measure; it drafts the tables, joins, grain and fields for you to check.`:`Ask ${e.askLabel??`the agent`} to change this model.`}),(0,W.jsxs)(`span`,{className:`sf-semantic-ask-row`,children:[(0,W.jsx)(`input`,{id:`${o}-ask`,className:`sf-input`,placeholder:i?`Order lines with their store and product, to measure revenue and refunds`:`Add margin as a share of revenue`,value:pe,onChange:e=>me(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:!pe.trim(),children:`Ask`})]})]}),ve=e=>{let i=[...E.filter(t=>t.kind===e),...O.filter(t=>t.kind===e)];return(0,W.jsxs)(`section`,{className:`sf-semantic-section`,"aria-labelledby":`${o}-${e}`,children:[(0,W.jsxs)(`h4`,{id:`${o}-${e}`,className:`sf-explore-heading`,children:[(0,W.jsxs)(`span`,{children:[uG[e].title,` `,(0,W.jsx)(`span`,{className:`sf-semantic-count`,children:E.filter(t=>t.kind===e).length})]}),n&&(0,W.jsx)(`button`,{type:`button`,className:`sf-explore-add`,"aria-label":`Add a ${uG[e].one}`,onClick:()=>A({pill:oe(e),isNew:!0}),children:`+`})]}),(0,W.jsx)(`p`,{className:`sf-explore-hint`,children:uG[e].hint}),i.length===0?(0,W.jsx)(`p`,{className:`sf-explore-hint`,children:`None yet.`}):(0,W.jsxs)(`table`,{className:`sf-semantic-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,children:`Label`}),(0,W.jsx)(`th`,{scope:`col`,children:`Name`}),(0,W.jsx)(`th`,{scope:`col`,children:e===`derived`?`Calculation`:`Definition`}),(0,W.jsx)(`th`,{scope:`col`,children:`Defined by`}),n&&(0,W.jsx)(`th`,{scope:`col`,children:(0,W.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:`Controls`})})]})}),(0,W.jsx)(`tbody`,{children:i.map(e=>{let i=D.get(e.id),a=i===`removed`;return(0,W.jsxs)(`tr`,{className:lI,"data-change":i,children:[(0,W.jsxs)(`th`,{scope:`row`,children:[e.label,i&&(0,W.jsx)(`span`,{className:`sf-semantic-change`,children:fG[i]}),e.description&&(0,W.jsx)(`span`,{className:`sf-semantic-description`,children:e.description})]}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`code`,{children:e.id})}),(0,W.jsxs)(`td`,{children:[(0,W.jsx)(`code`,{children:sG(a?t:u,e)}),e.format&&(0,W.jsxs)(`span`,{className:`sf-semantic-format`,children:[` · `,e.format]})]}),(0,W.jsx)(`td`,{children:WU(a?t:u,e.id)?.definedBy||`—`}),n&&(0,W.jsx)(`td`,{children:a?(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>ge(e.id),children:`Put back`}):(0,W.jsx)(iI,{label:`${e.label} controls`,controls:aI(e.label,{edit:()=>A({pill:e,isNew:!1}),duplicate:()=>A({pill:{...e,label:`${e.label} copy`,by:r},isNew:!0}),remove:()=>{ce(e.id,void 0),h(`field.removed`,`${e.label} taken out of the draft. Save to remove it from the model.`,{field:e.id})}})})})]},e.id)})})]})]},e)};return(0,W.jsxs)(`div`,{className:[`sf-semantic`,e.className].filter(Boolean).join(` `),children:[(0,W.jsxs)(`header`,{className:`sf-semantic-header`,children:[i&&n?(0,W.jsxs)(`div`,{className:`sf-semantic-identity`,children:[(0,W.jsx)(`h3`,{className:`sf-semantic-title`,children:`New model`}),(0,W.jsx)(`label`,{htmlFor:`${o}-label`,children:`Name for people`}),(0,W.jsx)(`input`,{id:`${o}-label`,className:`sf-input`,placeholder:`Sales lines`,value:u.label,onChange:e=>le({label:e.target.value,...ue?{}:{name:hG(e.target.value)}})}),(0,W.jsx)(`label`,{htmlFor:`${o}-name`,children:`Name in calculations and files`}),(0,W.jsx)(`input`,{id:`${o}-name`,className:`sf-input`,placeholder:`sales_lines`,value:u.name,onChange:e=>(de(!0),le({name:e.target.value}))}),(0,W.jsx)(`label`,{htmlFor:`${o}-about`,children:`What it is for`}),(0,W.jsx)(`input`,{id:`${o}-about`,className:`sf-input`,placeholder:`Revenue, cost and refunds by store and product.`,value:u.description,onChange:e=>le({description:e.target.value})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`sf-semantic-title`,children:u.label||u.name}),u.description&&(0,W.jsx)(`p`,{className:`sf-semantic-description`,children:u.description})]}),(0,W.jsxs)(`p`,{className:`sf-explore-hint`,children:[u.name?(0,W.jsx)(`code`,{children:u.name}):`Not named yet`,` on `,t.sourceId,i?` · not saved yet`:` · version ${t.version}`,t.savedBy&&` · saved by ${t.savedBy}`,t.updatedAt&&` on ${t.updatedAt.slice(0,10)}`]}),v&&(0,W.jsxs)(`p`,{className:`sf-filter-problem`,role:`alert`,children:[`The query does not run: `,v]})]}),i&&n&&x.length>0&&!u.dataset&&(0,W.jsxs)(`div`,{className:`sf-semantic-actions sf-semantic-from-dataset`,children:[(0,W.jsx)(`label`,{htmlFor:`${o}-dataset`,children:`Start from a pipeline dataset`}),(0,W.jsxs)(`select`,{id:`${o}-dataset`,className:`sf-input`,value:C,onChange:e=>w(e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Choose a dataset…`}),x.map((e,t)=>(0,W.jsx)(`optgroup`,{label:e.summary?.name||e.summary?.id,children:e.datasets.map((e,n)=>e.kind===Qx.SOURCE?null:(0,W.jsxs)(`option`,{value:`${t}:${n}`,children:[e.name,e.grain?` · ${e.grain}`:``,e.builtAt?``:` · not built yet`]},e.name))},e.summary?.id))]}),(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:!C,onClick:T,children:`Use this dataset`}),(0,W.jsx)(`span`,{className:`sf-explore-hint`,children:`Its grain and key are checked by the pipeline after every build; its columns become fields for you to check.`})]}),(0,W.jsx)(eW,{model:u,pipelines:b,onOpenDataset:e.onOpenDataset,onUseDataset:n?e=>{se(ym(pS,{...u,sourceId:u.sourceId,sql:wC({name:e.dataset,relation:e.relation??``}),grain:e.grain||u.grain,primaryKey:e.primaryKey})),h(`rows.changed`,`The grain and key are the dataset's again: ${e.primaryKey.join(`, `)}.`,{grain:e.grain,primaryKey:e.primaryKey})}:void 0}),i&&_e,(0,W.jsx)(XW,{model:u,columns:g,editor:r,dataSource:a,building:e.building&&!u.dataset,onChange:n?(e,t)=>{e.dataset&&(e.tables.length>0||e.sql!==u.sql)&&(e=ym(pS,{...e,dataset:void 0})),se(e),t&&h(`rows.changed`,t,{grain:e.grain,primaryKey:e.primaryKey,tables:e.tables})}:void 0}),n&&g.length>0&&u.dimensions.length===0&&u.measures.length===0&&(0,W.jsxs)(`p`,{className:`sf-semantic-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:fe,children:`Draft fields from the columns`}),(0,W.jsx)(`span`,{className:`sf-explore-hint`,children:`Dimensions and measures from the columns' names and types, marked as generated, for you to check.`})]}),l&&(0,W.jsxs)(`div`,{className:`sf-semantic-draft`,role:`region`,"aria-label":`Changes not saved`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:i?`New model, not saved`:`${D.size} ${D.size===1?`change`:`changes`} not saved`}),e.proposedBy?`, proposed by ${e.proposedBy}. Read ${i?`it`:`them`} before saving.`:`.`,` `,i?`${u.dimensions.length} dimensions, ${u.measures.length} measures, ${u.metrics.length} metrics.`:[...D].map(mG).join(`, `)]}),(ee.length>0||e.problem)&&(0,W.jsx)(`ul`,{className:`sf-filter-problem`,role:`alert`,children:[...ee,...e.problem?[e.problem]:[]].map(e=>(0,W.jsx)(`li`,{children:e},e))}),n&&(0,W.jsxs)(`div`,{className:`sf-semantic-actions`,children:[(0,W.jsx)(`label`,{htmlFor:`${o}-note`,className:`sf-a2-visually-hidden`,children:`What changed`}),(0,W.jsx)(`input`,{id:`${o}-note`,className:`sf-input`,placeholder:`What changed, in a few words`,value:ne,onChange:e=>re(e.target.value)}),(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:ee.length>0||ie,onClick:()=>void j(),children:ie?`Saving…`:`Save as version ${t.version+1}`}),(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{d(void 0),h(`draft.discarded`,i?`The new model was cleared, to start again.`:`${D.size} ${D.size===1?`change`:`changes`} dropped; the model is as saved.`)},children:i?`Start again`:`Drop changes`})]})]}),te&&(0,W.jsx)(uW,{pill:te.pill,all:E,columns:g,isNew:te.isNew,onCancel:()=>A(void 0),onSave:e=>{ce(te.isNew?e.id:te.pill.id,e),h(te.isNew?`field.added`:`field.changed`,`${e.label} ${te.isNew?`added to`:`changed in`} the draft. Save to keep it.`,{field:e,...te.isNew?{}:{was:te.pill}}),A(void 0)},onRemove:te.isNew?void 0:()=>{ce(te.pill.id,void 0),h(`field.removed`,`${te.pill.label} taken out of the draft. Save to remove it from the model.`,{field:te.pill.id}),A(void 0)}},`${te.pill.id}-${te.isNew}`),[`attribute`,`metric`,`derived`].map(ve),!i&&_e,(0,W.jsx)(`p`,{className:`sf-explore-note`,role:`status`,children:p})]})}var W,lG,uG,dG,fG,pG,mG,hG,gG=n((()=>{W=HA(),zb(),rw(),vS(),lG=jM(),uI(),UN(),oP(),WB(),TV(),iW(),bW(),QU(),oG(),uG={attribute:{title:`Dimensions`,one:`dimension`,hint:`Ways to break the rows down: a category, or a date grouped by month.`},metric:{title:`Measures`,one:`measure`,hint:`A column summarised: a sum, an average, a count.`},derived:{title:`Metrics`,one:`metric`,hint:`Arithmetic over measures, worked out by the database after summarising: a rate, a margin.`}},dG={sum:`Sum`,avg:`Average`,count:`Count`,count_distinct:`Distinct count`,min:`Smallest`,max:`Largest`,median:`Median`,stddev:`Standard deviation`,variance:`Variance`},fG={added:`Added`,changed:`Changed`,removed:`Removed`},pG={"(name)":`the name`,"(label)":`the label`,"(description)":`the description`,"(sql)":`the query`,"(grain)":`what one row is`,"(primaryKey)":`the key`,"(joins)":`the tables and joins`,"(dataset)":`the pipeline dataset`},mG=([e,t])=>pG[e]?`Changed ${pG[e]}`:`${fG[t]} ${e}`,hG=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^[^a-z]+|_+$/g,``).slice(0,64)}));function _G(e,t,n){let r=e;for(let e of t.remove??[])r=GU(r,e,void 0,n);for(let e of t.add??[])r=GU(r,e.id,e,e.by||n);let i=t.rows;return i&&(r=Hh(pS,r),i.grain!==void 0&&(r.grain=i.grain),i.primaryKey!==void 0&&(r.primaryKey=[...i.primaryKey]),(i.tables!==void 0||i.joins!==void 0)&&(r.tables=[...i.tables??r.tables],r.joins=(i.joins??[]).map(e=>ym(hS,{left:e.left,right:e.right,keys:e.keys,type:rG(e.type??`left`),definedBy:n})),r.sql=YW({tables:r.tables,joins:r.joins.map(e=>({left:e.left,right:e.right,keys:e.keys,type:iG(e.type)}))}).sql),i.sql!==void 0&&(r.sql=i.sql,i.tables===void 0&&(r.tables=[],r.joins=[])),i.dataset?(r.dataset=ym(mS,{pipelineId:i.dataset.pipeline,dataset:i.dataset.dataset}),r.sql=wC(i.dataset.dataset),r.tables=[],r.joins=[]):(i.sql!==void 0||i.tables!==void 0)&&(r.dataset=void 0)),r}function vG(e,t){let n=KU(e,t),r=new Map(zU(t).map(e=>[e.id,e])),i={add:[...n].filter(([e,t])=>t!==`removed`&&r.has(e)).map(([e])=>r.get(e)),remove:[...n].filter(([,e])=>e===`removed`).map(([e])=>e)},a={};return n.has(`(grain)`)&&(a.grain=t.grain),n.has(`(primaryKey)`)&&(a.primaryKey=t.primaryKey),n.has(`(joins)`)&&(a.tables=t.tables,a.joins=t.joins.map(e=>({left:e.left,right:e.right,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),type:iG(e.type)}))),t.dataset&&n.has(`(dataset)`)?a.dataset={pipeline:t.dataset.pipelineId,dataset:t.dataset.dataset}:n.has(`(sql)`)&&t.tables.length===0&&(a.sql=t.sql),Object.keys(a).length>0&&(i.rows=a),i}var yG=n((()=>{zb(),vS(),QU(),oG(),rw()})),bG=n((()=>{})),xG=n((()=>{})),SG=n((()=>{HA(),jM()})),CG=n((()=>{HA(),jM()})),wG=n((()=>{HA()})),TG=n((()=>{HA(),jM()})),EG=n((()=>{HA(),jM()})),DG=n((()=>{HA(),jM()})),OG=n((()=>{HA()})),kG=n((()=>{HA()})),AG=n((()=>{})),jG=n((()=>{BA(),GA(),UM(),WM(),UN(),tP(),oP(),sP(),fP(),MP(),vF(),oF(),xF(),CF(),nI(),CI(),RI(),eR(),LF(),oR(),dR(),yR(),ER(),RR(),NR(),HR(),Mz(),zL(),OL(),zz(),Bz(),Gz(),Yz(),bB(),iz(),GI(),QI(),WB(),DB(),eV(),LP(),uV(),mV(),rV(),yV(),jV(),TV(),FV(),VV(),_P(),GF(),rw(),XV(),mH(),vH(),EH(),BH(),VH(),HH(),YF(),eU(),oU(),uU(),RU(),bW(),MW(),VW(),QU(),KW(),gG(),oG(),iW(),yG(),uI(),bG(),SG(),IW(),CG(),wG(),TG(),EG(),DG(),OG(),kG(),xG(),AG()}));jG();function MG(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function NG(e,t=`|`){return e.map(e=>tK(e)).join(t)}function PG(e,t){return typeof t==`bigint`?t.toString():t}function FG(e){return new NK(e)}function IG(e){return e==null}function LG(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function RG(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function zG(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==PK)return r===void 0&&(r=PK,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function BG(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function VG(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function HG(e){return VG(e._zod.def)??e._zod.def.shape}function UG(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return BG(this,t,e),e},enumerable:!0,configurable:!0})}function WG(e,t,n){t in e?BG(e,t,n):e[t]=n}function GG(e,t,n,r){let i=HG(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?UG(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):WG(e,a,r?r(n.value,a):n.value))}}function KG(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?UG(e,n,()=>t[n]):WG(e,n,r.value))}}function qG(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function JG(e){return JSON.stringify(e)}function YG(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function XG(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZG(e){if(XG(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return XG(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function QG(e){return ZG(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function $G(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function eK(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function G(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function tK(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function nK(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}function rK(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return GG(i,e,iK(e,t)),eK(e,qG(n,{shape:i,checks:[]}))}function iK(e,t){let n=HG(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function aK(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(iK(e,t)),a={};return GG(a,e,Reflect.ownKeys(HG(e)).filter(e=>!i.has(e))),eK(e,qG(n,{shape:a,checks:[]}))}function oK(e,t){if(!ZG(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=HG(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eK(e,qG(e._zod.def,{shape:sK(e,t)}))}function sK(e,t){let n={};return GG(n,e,Reflect.ownKeys(HG(e))),KG(n,t),n}function cK(e,t){if(!ZG(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return eK(e,qG(e._zod.def,{shape:sK(e,t)}))}function lK(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return GG(n,e,Reflect.ownKeys(HG(e))),GG(n,t,Reflect.ownKeys(HG(t))),eK(e,qG(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function uK(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(iK(t,n)):void 0,o={};return GG(o,t,Reflect.ownKeys(HG(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),eK(t,qG(t._zod.def,{shape:o,checks:[]}))}function dK(e,t,n){let r=n?new Set(iK(t,n)):void 0,i={};return GG(i,t,Reflect.ownKeys(HG(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),eK(t,qG(t._zod.def,{shape:i}))}function fK(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pK(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function mK(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function hK(e){return typeof e==`string`?e:e?.message}function gK(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function _K(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function vK(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:hK(e.inst?._zod.def?.error?.(e))??hK(a?.(e))??hK(t?.error?.(e))??hK(n.customError?.(e))??hK(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}function yK(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function bK(e){let t=e.length;if(!VK.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function xK(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function SK(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function CK(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function wK(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):OK(e,n,r.value)}}function TK(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function EK(e,t,n){return TK(e,t,n,!1)}function DK(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return TK(this,n,r(this))},set(e){TK(this,n,e)}})}return t}function OK(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:TK(this,t,n.bind(this))},set(e){TK(this,t,e)}})}function kK(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}function AK(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&HK!==e._zod?HK=void 0:(HK=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,WK);let e=UK;UK=!1;try{let r=n(this);return UK?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),UK||=e,r}catch(n){throw delete this[t],UK||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function jK(e,t,n,r){let i=kK(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function MK(e){let t=()=>e;return t[GK]=!0,t}var NK,PK,FK,IK,LK,RK,zK,BK,VK,HK,UK,WK,GK,KK=n((()=>{tq(),NK=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}},PK=Symbol(`evaluating`),FK=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},IK=FG(()=>{if(eq.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),LK=new Set([`string`,`number`,`symbol`]),RK=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]),zK={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},BK={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]},VK=/[\uD800-\uDBFF]/,UK=!1,WK={configurable:!0,get(){UK=!0}},GK=`~constantCatch`}));function qK(e){let t=ZK;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return ZK=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function K(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){XK.value=new a(r);try{Object.defineProperty(n,"_zod",XK)}finally{XK.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),wK(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?qK(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}function JK(e){return e&&Object.assign(eq,e),eq}var YK,XK,ZK,QK,$K,eq,tq=n((()=>{KK(),XK={value:void 0,enumerable:!1},ZK=`captureStackTrace`in Error?Error:null,QK=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},$K=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(YK=globalThis).__zod_globalConfig??(YK.__zod_globalConfig={}),eq=globalThis.__zod_globalConfig}));function nq(){let e=this._zod;return e.message??=JSON.stringify(e.def,PG,2),e.message}function rq(e){this._zod.message=e}function iq(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function aq(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?iq(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function oq(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}var sq,cq,lq,uq,dq,fq,pq=n((()=>{tq(),KK(),sq={get:nq,set:rq,enumerable:!0,configurable:!0},cq={value:void 0,enumerable:!1},lq=new WeakSet([Object.prototype,Error.prototype]),uq=(e,t)=>{e.name=`$ZodError`,cq.value=t,Object.defineProperty(e,"issues",cq),cq.value=void 0,Object.defineProperty(e,"message",sq);let n=Object.getPrototypeOf(e);lq.has(n)||(lq.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},dq=K(`$ZodError`,uq),fq=K(`$ZodError`,uq,void 0,{Parent:Error})}));function mq(e,t){return{callee:t?.callee??e,Err:t?.Err}}function hq(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>vK(e,n,JK()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}function gq(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[wq]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new QK;return a.issues.length===0}var _q,vq,yq,bq,xq,Sq,Cq,wq,Tq,Eq,Dq,Oq,kq,Aq,jq,Mq,Nq,Pq,Fq=n((()=>{tq(),pq(),KK(),_q=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new QK;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>vK(e,o,JK())));throw FK(n,a?.callee??t),n}return s.value};return t},vq=_q(fq),yq=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>vK(e,o,JK())));throw FK(n,a?.callee??t),n}return s.value};return t},bq=yq(fq),xq=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new QK;return a.issues.length?hq(e,a.issues,i):{success:!0,data:a.value}},Sq=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?hq(e,a.issues,i):{success:!0,data:a.value}},Cq=Symbol.for(`zod.compile.invalid`),wq=Symbol.for(`zod.compile.fallback`),Tq=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Cq)return!0;if(r.definite===!0&&n===void 0)return!1}return gq(e,t,n)}),Eq=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Dq=e=>{let t=_q(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,mq(n,a))};return n},Oq=e=>{let t=_q(e),n=(e,r,i,a)=>t(e,r,i,mq(n,a));return n},kq=e=>{let t=yq(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,mq(n,a))};return n},Aq=e=>{let t=yq(e),n=async(e,r,i,a)=>await t(e,r,i,mq(n,a));return n},jq=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xq(e)(t,n,i)},Mq=e=>(t,n,r)=>xq(e)(t,n,r),Nq=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Sq(e)(t,n,i)},Pq=e=>async(t,n,r)=>Sq(e)(t,n,r)})),Iq=i({anyString:()=>DJ,base64:()=>gJ,base64url:()=>_J,bigint:()=>kJ,boolean:()=>MJ,browserEmail:()=>lJ,cidrv4:()=>mJ,cidrv6:()=>hJ,creditCard:()=>SJ,cuid:()=>Gq,cuid2:()=>Kq,currencyCode:()=>CJ,date:()=>EJ,datetime:()=>Hq,domain:()=>yJ,duration:()=>Zq,e164:()=>xJ,email:()=>iJ,emoji:()=>Rq,extendedDuration:()=>Qq,guid:()=>$q,hex:()=>LJ,hostname:()=>vJ,html5Email:()=>aJ,httpProtocol:()=>bJ,iban:()=>wJ,idnEmail:()=>cJ,integer:()=>AJ,ipv4:()=>dJ,ipv6:()=>fJ,ksuid:()=>Yq,lowercase:()=>FJ,mac:()=>pJ,md5_base64:()=>zJ,md5_base64url:()=>BJ,md5_hex:()=>RJ,nanoid:()=>Xq,nanoidOfLength:()=>Lq,null:()=>NJ,number:()=>jJ,rfc5322Email:()=>oJ,sha1_base64:()=>HJ,sha1_base64url:()=>UJ,sha1_hex:()=>VJ,sha256_base64:()=>GJ,sha256_base64url:()=>KJ,sha256_hex:()=>WJ,sha384_base64:()=>JJ,sha384_base64url:()=>YJ,sha384_hex:()=>qJ,sha512_base64:()=>ZJ,sha512_base64url:()=>QJ,sha512_hex:()=>XJ,string:()=>OJ,time:()=>Vq,ulid:()=>qq,undefined:()=>PJ,unicodeEmail:()=>sJ,uppercase:()=>IJ,uuid:()=>eJ,uuid4:()=>tJ,uuid6:()=>nJ,uuid7:()=>rJ,xid:()=>Jq});function Lq(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}function Rq(){return new RegExp(uJ,`u`)}function zq(e){return RegExp(`^${e}$`)}function Bq(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Vq(e){return RegExp(`^${Bq(e)}$`)}function Hq(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Bq({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Bq({precision:e.precision})}`:n;return RegExp(`^${TJ}T(?:${r})$`)}function Uq(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Wq(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Gq,Kq,qq,Jq,Yq,Xq,Zq,Qq,$q,eJ,tJ,nJ,rJ,iJ,aJ,oJ,sJ,cJ,lJ,uJ,dJ,fJ,pJ,mJ,hJ,gJ,_J,vJ,yJ,bJ,xJ,SJ,CJ,wJ,TJ,EJ,DJ,OJ,kJ,AJ,jJ,MJ,NJ,PJ,FJ,IJ,LJ,RJ,zJ,BJ,VJ,HJ,UJ,WJ,GJ,KJ,qJ,JJ,YJ,XJ,ZJ,QJ,$J=n((()=>{KK(),Gq=/^[cC][0-9a-z]{6,}$/,Kq=/^[0-9a-z]+$/,qq=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Jq=/^[0-9a-vA-V]{20}$/,Yq=/^[A-Za-z0-9]{27}$/,Xq=/^[a-zA-Z0-9_-]{21}$/,Zq=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qq=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,$q=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,eJ=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tJ=eJ(4),nJ=eJ(6),rJ=eJ(7),iJ=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,aJ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,oJ=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,sJ=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,cJ=sJ,lJ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,uJ=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,dJ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,fJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,pJ=e=>{let t=$G(e??`:`);return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},mJ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gJ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_J=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,vJ=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,yJ=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,bJ=/^https?$/,xJ=/^\+[1-9]\d{6,14}$/,SJ=/^\d(?:[ -]?\d){11,18}$/,CJ=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,wJ=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,TJ=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,EJ=zq(TJ),DJ=/^[\s\S]{0,}$/,OJ=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},kJ=/^-?\d+n?$/,AJ=/^-?\d+$/,jJ=/^-?\d+(?:\.\d+)?$/,MJ=/^(?:true|false)$/i,NJ=/^null$/i,PJ=/^undefined$/i,FJ=/^[^A-Z]*$/,IJ=/^[^a-z]*$/,LJ=/^[0-9a-fA-F]*$/,RJ=/^[0-9a-fA-F]{32}$/,zJ=Uq(22,`==`),BJ=Wq(22),VJ=/^[0-9a-fA-F]{40}$/,HJ=Uq(27,`=`),UJ=Wq(27),WJ=/^[0-9a-fA-F]{64}$/,GJ=Uq(43,`=`),KJ=Wq(43),qJ=/^[0-9a-fA-F]{96}$/,JJ=Uq(64,``),YJ=Wq(64),XJ=/^[0-9a-fA-F]{128}$/,ZJ=Uq(86,`==`),QJ=Wq(86)}));function eY(e,t,n){e.issues.length&&t.issues.push(...mK(n,e.issues))}var tY,nY,rY,iY,aY,oY,sY,cY,lY,uY,dY,fY,pY,mY,hY,gY,_Y,vY,yY,bY,xY,SY,CY,wY,TY,EY,DY=n((()=>{tq(),$J(),KK(),tY=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nY=e=>{let t=e.value;return!IG(t)&&t.size!==void 0},rY=e=>{let t=e.value;return!IG(t)&&t.length!==void 0},iY={number:`number`,bigint:`bigint`,object:`date`},aY=K(`$ZodCheckLessThan`,(e,t)=>{tY.init(e,t);let n=iY[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:iY[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),oY=K(`$ZodCheckGreaterThan`,(e,t)=>{tY.init(e,t);let n=iY[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:iY[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),sY=K(`$ZodCheckMultipleOf`,(e,t)=>{tY.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):RG(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),cY=K(`$ZodCheckNumberFormat`,(e,t)=>{tY.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=zK[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),lY=K(`$ZodCheckBigIntFormat`,(e,t)=>{tY.init(e,t);let[n,r]=BK[t.format];e._zod.check=i=>{let a=i.value;a<n&&i.issues.push({origin:`bigint`,input:a,code:`too_small`,minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:`bigint`,input:a,code:`too_big`,maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),uY=K(`$ZodCheckMaxSize`,(e,t)=>{var n;tY.init(e,t),(n=e._zod.def).when??(n.when=nY),e._zod.check=n=>{let r=n.value;r.size<=t.maximum||n.issues.push({origin:yK(r),code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),dY=K(`$ZodCheckMinSize`,(e,t)=>{var n;tY.init(e,t),(n=e._zod.def).when??(n.when=nY),e._zod.check=n=>{let r=n.value;r.size>=t.minimum||n.issues.push({origin:yK(r),code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fY=K(`$ZodCheckSizeEquals`,(e,t)=>{var n;tY.init(e,t),(n=e._zod.def).when??(n.when=nY),e._zod.check=n=>{let r=n.value,i=r.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:yK(r),...a?{code:`too_big`,maximum:t.size}:{code:`too_small`,minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),pY=K(`$ZodCheckMaxLength`,(e,t)=>{var n;tY.init(e,t),(n=e._zod.def).when??(n.when=rY),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?bK(r):i)<=t.maximum)return;let a=xK(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mY=K(`$ZodCheckMinLength`,(e,t)=>{var n;tY.init(e,t),(n=e._zod.def).when??(n.when=rY),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?bK(r):i)>=t.minimum)return;let a=xK(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hY=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;tY.init(e,t),(n=e._zod.def).when??(n.when=rY),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?bK(r):i;if(a===t.length)return;let o=xK(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),gY=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;tY.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),_Y=K(`$ZodCheckRegex`,(e,t)=>{gY.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),vY=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=FJ,gY.init(e,t)}),yY=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=IJ,gY.init(e,t)}),bY=K(`$ZodCheckIncludes`,(e,t)=>{tY.init(e,t);let n=$G(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),xY=K(`$ZodCheckStartsWith`,(e,t)=>{tY.init(e,t);let n=RegExp(`^${$G(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),SY=K(`$ZodCheckEndsWith`,(e,t)=>{tY.init(e,t);let n=RegExp(`.*${$G(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),CY=K(`$ZodCheckProperty`,(e,t)=>{tY.init(e,t),e._zod.check=e=>{let n=t.schema._zod.run({value:e.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(n=>eY(n,e,t.property));eY(n,e,t.property)}}),wY=K(`$ZodCheckProperties`,(e,t)=>{tY.init(e,t),EK(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:`object`,code:`invalid_type`,input:r.value,inst:e});return}n??=Reflect.ownKeys(t.shape).map(e=>[e,t.shape[e]]);let i=r.value,a;for(let[e,t]of n){let n=t._zod.run({value:i[e],issues:[]},{});n instanceof Promise?(a??=[],a.push(n.then(t=>eY(t,r,e)))):eY(n,r,e)}if(a)return Promise.all(a).then(()=>void 0)}}),TY=K(`$ZodCheckMimeType`,(e,t)=>{tY.init(e,t);let n=new Set(t.mime);e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:`invalid_value`,values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),EY=K(`$ZodCheckOverwrite`,(e,t)=>{tY.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),OY,kY=n((()=>{OY=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
43
|
+
`),unjoined:s,order:i,columns:l}}function bz(e,t,n,r=()=>void 0){let i=_z(e,t),a=i.keys.map(e=>e.leftColumn),o=i.keys.map(e=>e.rightColumn),s=(n(i.right)??[]).filter(e=>e.primaryKey).map(e=>e.name);return s.length>0&&s.every(e=>o.some(t=>Nz(t,e)))||(r(i.left)??[]).some(e=>Nz(e.references?.table??``,i.right)&&e.columns.length>0&&e.columns.every(e=>a.some(t=>Nz(t,e)))&&e.referencedColumns.every(e=>o.some(t=>Nz(t,e))))?`one`:s.length>0?`many`:`unknown`}function xz(e,t){let n=new Map;e[0]&&n.set(e[0],0);for(let r=!0;r;){r=!1;for(let i of t){let t=e.find(e=>Nz(e,i.left)),a=e.find(e=>Nz(e,i.right));if(!t||!a)continue;let[o,s]=n.has(t)&&!n.has(a)?[t,a]:n.has(a)&&!n.has(t)?[a,t]:[];o&&s&&(n.set(s,n.get(o)+1),r=!0)}}let r=Math.max(0,...n.values())+1;for(let t of e)n.has(t)||n.set(t,r);return n}function Sz(e,t){if(Nz(e.left,e.right))return{ok:!1,reason:`A join needs two different tables.`};if(e.keys.length===0)return{ok:!1,reason:`A join needs a column from each table.`};for(let n of e.keys){let r=[{table:e.left,name:n.leftColumn},{table:e.right,name:n.rightColumn}].map(e=>{let n=t(e.table),r=n?.find(t=>Nz(t.name,e.name));return{...e,known:n!==void 0,column:r,family:r?oC(r):`unknown`}});for(let e of r){if(e.known&&!e.column)return{ok:!1,reason:`${e.table} has no column ${e.name}.`};if(e.family===`nested`||e.family===`binary`)return{ok:!1,reason:`${e.table}.${e.name} holds ${zz[e.family]}, which cannot be matched.`}}let[i,a]=r;if(i.family!==`unknown`&&a.family!==`unknown`&&i.family!==a.family)return{ok:!1,reason:`${i.table}.${i.name} is ${zz[i.family]} and ${a.table}.${a.name} is ${zz[a.family]}, so they can never match.`}}return{ok:!0}}function Cz(e,t,n){let r=new Set([Mz(t)]);for(let t=!0;t;){t=!1;for(let n of e){let[e,i]=[Mz(n.left),Mz(n.right)];r.has(e)!==r.has(i)&&(r.add(e),r.add(i),t=!0)}}return r.has(Mz(n))}function wz(e){return{x:16+e%3*300,y:16+Math.floor(e/3)*346}}function Tz(e){let{sourceId:t,height:n=420,suggestJoins:r=!0,rowsFrom:i=!1}=e,a=VN(e.dataSource),o=NF(e.discovery),s=(0,Ez.useId)(),c=JSON.stringify([e.tables??[],e.joins??[]]),[l,u]=(0,Ez.useState)(e.tables??[]),[d,f]=(0,Ez.useState)(e.joins??[]),[p,m]=(0,Ez.useState)({}),[h,g]=(0,Ez.useState)({}),[_,v]=(0,Ez.useState)({}),[y,b]=(0,Ez.useState)({}),[x,S]=(0,Ez.useState)(new Set),[C,w]=(0,Ez.useState)(),[T,E]=(0,Ez.useState)(``),[D,O]=(0,Ez.useState)([]),[k,ee]=(0,Ez.useState)({left:``,leftColumn:``,right:``,rightColumn:``}),[te,A]=(0,Ez.useState)(``),[ne,re]=(0,Ez.useState)(``),[ie,ae]=(0,Ez.useState)(0),[oe,se]=(0,Ez.useState)({}),ce=(0,Ez.useRef)(null),le=(0,Ez.useRef)(void 0),ue=(0,Ez.useRef)(new Set),de=(0,Ez.useRef)(e.onChange);de.current=e.onChange;let fe=(0,Ez.useRef)(c);(0,Ez.useEffect)(()=>{fe.current!==c&&(fe.current=c,ue.current=new Set,u(e.tables??[]),f(e.joins??[]),m({}))},[c]);let pe=(0,Ez.useMemo)(()=>({tables:l,joins:d}),[l,d]),me=(e,t=pe)=>{let n=yz(t).order,r=e=>{let r=n.findIndex(t=>Nz(t,e));return r>=0?r:n.length+t.tables.findIndex(t=>Nz(t,e))};return r(e.left)<=r(e.right)?e.left:e.right},he=(e,t)=>!i||e.type?e:{..._z(e,me(e,t)),type:`left`},ge=(0,Ez.useRef)({sourceId:t,dataSource:a});ge.current={sourceId:t,dataSource:a},(0,Ez.useEffect)(()=>{let e=()=>ge.current.sourceId===t&&ge.current.dataSource===a;for(let n of l){if(h[n]!==void 0||(g(e=>({...e,[n]:`loading`})),a.describeTable({sourceId:t,ref:{table:n}}).then(t=>{e()&&(g(e=>({...e,[n]:t.table?.columns??[]})),b(e=>({...e,[n]:{comment:t.table?.summary?.comment??``,foreignKeys:t.table?.foreignKeys??[]}})))}).catch(t=>e()&&g(e=>({...e,[n]:{error:aP(t)}}))),!o))continue;let r={sourceId:t,kind:Bx.TABLE,table:n};o.getObject({ref:r}).then(t=>{let r=t.profile?.object?.certification;e()&&r&&v(e=>({...e,[n]:r}))}).catch(()=>{})}},[l,a,o,t,ie]),(0,Ez.useEffect)(()=>{if(!o||!r)return;let e=!0;for(let n of l)o.getRelated({ref:{sourceId:t,kind:Bx.TABLE,table:n},kinds:[Wx.JOIN]}).then(t=>{if(!e)return;let r=[];for(let e of t.relations){let t=e.object?.ref?.table;if(!t||!l.some(e=>Nz(e,t))||e.keys.length===0)continue;let i={left:n,right:t,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),inferred:e.inferred};ue.current.has(pz(i))||(ue.current.add(pz(i)),r.push(i))}r.length>0&&f(e=>[...e,...r.filter(t=>!e.some(e=>pz(e)===pz(t))).map(t=>he(t,{tables:l,joins:e}))])}).catch(()=>{});return()=>{e=!1}},[l,o,t,r]),(0,Ez.useEffect)(()=>{let e=[];for(let t of l)for(let n of y[t]?.foreignKeys??[]){let r=l.find(e=>Nz(e,n.references?.table??``));if(!r||n.columns.length===0)continue;let i={left:t,right:r,keys:n.columns.map((e,t)=>({leftColumn:e,rightColumn:n.referencedColumns[t]??e})),declared:!0};ue.current.has(pz(i))||(ue.current.add(pz(i)),e.push(i))}e.length!==0&&f(t=>{let n=t.map(t=>e.find(e=>pz(e)===pz(t))?{...t,inferred:!1,declared:!0}:t);return[...n,...e.filter(e=>!t.some(t=>pz(t)===pz(e))).map(e=>he(e,{tables:l,joins:n}))]})},[l,y]),(0,Ez.useEffect)(()=>{let e=T.trim();if(!e)return O([]);let n=!0,r=setTimeout(()=>{a.listTables({sourceId:t,search:e,pageSize:8}).then(e=>n&&O(e.tables.map(e=>e.ref?.table??``).filter(e=>e&&!l.some(t=>Nz(t,e))))).catch(e=>{n&&(O([]),re(`Could not search for tables: ${aP(e)}`))})},180);return()=>{n=!1,clearTimeout(r)}},[T,a,t,l]);let j=e=>p[e]??je?.[e]??wz(l.findIndex(t=>t===e)),_e=e=>Array.isArray(h[e])?h[e]:[],ve=e=>x.has(e)?_e(e):_e(e).slice(0,jz),ye=e=>{let t=_e(e).length,n=ve(e).length;return kz+Math.max(1,n+ +(t>jz))*Az+6},be=(e,t)=>{e&&!l.some(t=>Nz(t,e))&&(t&&m(n=>({...n,[e]:t})),u(t=>[...t,e]),A(`Added ${e}.`),E(``))},xe=e=>{u(t=>t.filter(t=>t!==e)),f(t=>t.filter(t=>!Nz(t.left,e)&&!Nz(t.right,e))),A(`Removed ${e}.`)},Se=e=>Array.isArray(h[e])?h[e]:void 0,M=e=>Sz(e,Se),Ce=e=>{re(`Not joined. ${e}`),A(``)},we=(e,t)=>{f(n=>n.flatMap(n=>{if(pz(n)!==pz(e))return[n];let r=n.keys.filter(e=>!(Nz(e.leftColumn,t.leftColumn)&&Nz(e.rightColumn,t.rightColumn)));return r.length>0?[{...n,keys:r}]:[]})),re(``),A(`Removed ${mz({...e,keys:[t]})}.`)},Te=e=>{let t=M(e);if(!t.ok)return Ce(t.reason);let n=!d.some(t=>pz(t)===pz(e))&&Cz(d.filter(Ae).filter(t=>pz({...t,keys:[]})!==pz({...e,keys:[]})),e.left,e.right);re(``),ue.current.add(pz(e)),f(t=>{let n=t.findIndex(t=>pz(t)===pz(e));return n>=0?t.map((e,t)=>t===n?{...e,inferred:!1}:e):[...t,he(e,{tables:l,joins:t})]}),A(`Joined ${mz(e)}.${n?` ${e.left} and ${e.right} were already connected another way, so rows must now match on both routes.`:``}`)},Ee=(e,t,n)=>{f(r=>r.map(r=>pz(r)===pz(e)?{...t,type:n}:r)),A(`${mz(t)} now keeps ${hz(t,n).toLowerCase()}.`)},De=e=>{let t=[e,...l.filter(t=>!Nz(t,e))];f(e=>e.map(n=>_z(n,me(n,{tables:l,joins:e})).type===`left`?{..._z(n,me(n,{tables:t,joins:e})),type:`left`}:n)),u(t),A(`The rows now come from ${e}: one row of the result is one ${e} row.`)},Oe=(e,t)=>`${pz(e)}>${Mz(t)}`,ke=(e,n)=>{let r=_z(e,n),i=Oe(e,r.right);se(e=>({...e,[i]:`checking`})),lC(a,{sourceId:t,sql:`SELECT * FROM ${Fz(r.right)}`,columns:r.keys.map(e=>e.rightColumn)}).then(e=>{se(t=>({...t,[i]:e})),A(e>1?`Up to ${e} ${r.right} rows share one ${r.keys.map(e=>e.rightColumn).join(` and `)}, so this join can repeat ${r.left} rows.`:`Each ${r.left} row finds at most one ${r.right} row.`)}).catch(e=>se(t=>({...t,[i]:{error:aP(e)}})))},Ae=e=>l.some(t=>Nz(t,e.left))&&l.some(t=>Nz(t,e.right)),je=i?(()=>{let e=xz(l,d),t=new Map,n={};for(let r of l){let i=e.get(r)??0,a=t.get(i)??16;n[r]={x:16+i*360,y:a},t.set(i,a+ye(r)+24)}return n})():void 0,Me={width:l.length===0?0:Math.max(...l.map(e=>j(e).x+Oz))+16,height:l.length===0?0:Math.max(...l.map(e=>j(e).y+ye(e)))+16},Ne=az({content:Me}),Pe=Ne.viewportRef,Fe=(0,Ez.useCallback)(e=>{ce.current=e,Pe(e)},[Pe]),Ie=e=>Ne.pointToWorld(e),Le=e=>t=>{if(t.target.closest(`button`))return;let n=Ie(t),r=j(e);le.current={table:e,dx:n.x-r.x,dy:n.y-r.y},t.currentTarget.setPointerCapture?.(t.pointerId)},Re=(e,t)=>n=>{n.stopPropagation(),w({table:e,column:t,to:Ie(n)}),ce.current?.setPointerCapture?.(n.pointerId)},ze=e=>{let t=Ie(e),n=le.current;n?m(e=>({...e,[n.table]:{x:Math.max(0,t.x-n.dx),y:Math.max(0,t.y-n.dy)}})):C&&w({...C,to:t})},Be=e=>{if(le.current=void 0,!C)return;ce.current?.releasePointerCapture?.(e.pointerId);let t=document.elementFromPoint?.(e.clientX,e.clientY)?.closest(`[data-model-column]`),n=t?.dataset.modelTable,r=t?.dataset.modelColumn;n&&r?Te({left:C.table,right:n,keys:[{leftColumn:C.column,rightColumn:r}]}):A(`Drop the column on a column of another table to join them.`),w(void 0)},Ve=e=>{let t=e.dataTransfer.getData(AF);if(t){e.preventDefault();try{let n=JSON.parse(t),r=Ie(e);be(n.table,{x:Math.max(0,r.x-Oz/2),y:Math.max(0,r.y-kz/2)})}catch{}}},He=(e,t,n)=>{let r=j(e),i=ve(e).findIndex(e=>Nz(e.name,t)),a=i>=0?i:ve(e).length,o=j(n).x+Oz/2>=r.x+Oz/2;return{x:r.x+(o?Oz:0),y:r.y+kz+a*Az+Az/2}},Ue=(e,t)=>{let n=Math.max(40,Math.abs(t.x-e.x)/2),r=t.x>=e.x?1:-1;return`M ${e.x} ${e.y} C ${e.x+n*r} ${e.y}, ${t.x-n*r} ${t.y}, ${t.x} ${t.y}`},We=Math.max(Me.width+16,320),Ge=Math.max(Me.height+16,120),Ke=d.filter(Ae),qe=new Map(Ke.flatMap(e=>{let t=M(e);return t.ok?[]:[[pz(e),t.reason]]})),Je=l.filter(e=>typeof h[e]==`object`&&!Array.isArray(h[e])),Ye=yz({tables:l.filter(e=>!Je.includes(e)),joins:Ke.filter(e=>!qe.has(pz(e))&&!(i&&e.inferred))},e=>Array.isArray(h[e])?h[e].map(e=>e.name):void 0),Xe=(0,Ez.useRef)({model:pe,sql:Ye.sql});(0,Ez.useEffect)(()=>{(Xe.current.model!==pe||Xe.current.sql!==Ye.sql)&&(Xe.current={model:pe,sql:Ye.sql},de.current?.(pe,Ye))});let Ze=new Map((Ye.columns??[]).map(e=>[Mz(`${e.table}.${e.column}`),e.name])),Qe=e.usedColumns?new Set(e.usedColumns.map(Mz)):void 0,$e=l[0]??``,et=e=>{let t=i?me(e):e.left,n=_z(e,t),r=n.right,a=oe[Oe(e,r)],o=typeof a==`number`?a>1?`many`:`one`:a===`checking`?`checking`:bz(e,t,Se,e=>y[e]?.foreignKeys),s=o===`one`?`One ${r} row for each ${t} row${typeof a==`number`?`, checked by the engine`:``}.`:o===`many`?typeof a==`number`?`Can repeat ${t} rows: up to ${a} ${r} rows share one ${n.keys.map(e=>e.rightColumn).join(` and `)}.`:`Can repeat ${t} rows: ${r} has a key this join does not use, so more than one row may match.`:o===`checking`?`Counting ${r} rows per key…`:`Not known whether ${r} has more than one row per ${t} row.`,c=n.type??`inner`;return{near:t,far:r,read:n,shape:o,shapeText:s,kind:c,kindNote:c===`inner`?`${t} rows with no ${r} row are dropped.`:c===`right`||c===`full`?`Adds ${r} rows that match no ${t} row${i?`, so not every row is a ${$e} row`:``}.`:``,error:typeof a==`object`?a.error:``,chip:o===`one`?`1 per row`:o===`many`?`▲ can repeat`:o===`checking`?`Counting…`:`? not known`}},tt=(e,t,n,r=!1)=>(0,V.jsx)(`select`,{className:n,tabIndex:r?-1:void 0,value:t.type??`inner`,"aria-label":`Rows kept by ${mz(t)}${r?`, on the diagram`:``}`,onPointerDown:e=>e.stopPropagation(),onChange:n=>Ee(e,t,n.target.value),children:Dz.map(e=>(0,V.jsx)(`option`,{value:e,children:hz(t,e)},e))}),nt=k.left&&k.leftColumn?oC(_e(k.left).find(e=>e.name===k.leftColumn)??{nativeType:``,arrowType:``}):`unknown`,rt=(e,t)=>_e(e).filter(e=>{let n=oC(e);return n!==`nested`&&n!==`binary`&&(t===`unknown`||n===`unknown`||n===t)}).map(e=>e.name),it=(e,t)=>{let n=y[e]?.foreignKeys.find(e=>e.columns.some(e=>Nz(e,t)));if(!n)return;let r=n.columns.findIndex(e=>Nz(e,t));return`${n.references?.table}.${n.referencedColumns[r]??t}`},at=new Set(d.flatMap(e=>e.keys.flatMap(t=>[Mz(`${e.left}.${t.leftColumn}`),Mz(`${e.right}.${t.rightColumn}`)]))),ot=(e,t,n,r)=>(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:e}),(0,V.jsxs)(`select`,{className:`sf-input`,value:t,onChange:e=>r(e.target.value),children:[(0,V.jsx)(`option`,{value:``,children:`Choose…`}),n.map(e=>(0,V.jsx)(`option`,{children:e},e))]})]});return(0,V.jsxs)(`div`,{className:[`sf-model`,e.className].filter(Boolean).join(` `),children:[(0,V.jsxs)(`div`,{className:`sf-model-bar`,children:[(0,V.jsx)(`input`,{className:`sf-input`,type:`search`,placeholder:`Add a table`,"aria-label":`Add a table`,"aria-controls":`${s}-matches`,value:T,onChange:e=>E(e.target.value)}),(0,V.jsx)(`span`,{id:`${s}-matches`,className:`sf-model-matches`,children:D.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`sf-button`,onClick:()=>be(e),children:[`Add `,e]},e))}),e.onUseSql&&(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:Ye.sql===``,onClick:()=>e.onUseSql?.(Ye.sql,pe),children:`Use as query`})]}),l.length>0&&(0,V.jsx)(oz,{panZoom:Ne,label:`Zoom the data model`}),(0,V.jsxs)(`div`,{ref:Fe,className:`sf-model-canvas sf-panzoom`,style:{height:n},role:`group`,"aria-label":e.label??`Data model`,"aria-describedby":`${s}-keys`,"data-linking":C?``:void 0,...Ne.viewportProps,onPointerMove:e=>{ze(e),Ne.viewportProps.onPointerMove(e)},onPointerUp:e=>{Be(e),Ne.viewportProps.onPointerUp(e)},onPointerCancel:e=>{Be(e),Ne.viewportProps.onPointerCancel(e)},onDragOver:e=>e.dataTransfer.types.includes(`application/x-surfaces-ref+json`)&&e.preventDefault(),onDrop:Ve,children:[(0,V.jsx)(`span`,{id:`${s}-keys`,className:`sf-a2-visually-hidden`,children:`Drag the background or scroll to move around. Plus and minus zoom, 0 fits the diagram to view, arrow keys move it.`}),(0,V.jsxs)(`div`,{className:`sf-model-plane sf-panzoom-plane`,style:{width:We,height:Ge,...Ne.planeStyle},"data-animate":Ne.animate||void 0,children:[(0,V.jsxs)(`svg`,{className:`sf-model-lines`,width:We,height:Ge,"aria-hidden":`true`,children:[d.filter(Ae).flatMap(e=>e.keys.map(t=>(0,V.jsx)(`path`,{d:Ue(He(e.left,t.leftColumn,e.right),He(e.right,t.rightColumn,e.left)),"data-inferred":e.inferred||void 0,"data-broken":qe.has(pz(e))||void 0,"data-fanout":i&&et(e).shape===`many`||void 0},`${pz(e)}:${t.leftColumn}:${t.rightColumn}`))),C&&(0,V.jsx)(`path`,{d:Ue(He(C.table,C.column,C.table),C.to),"data-drawing":``})]}),l.map(e=>{let t=j(e),n=h[e],r=_e(e),a=i&&e===$e,o=Ye.order.some(t=>Nz(t,e)),s=Qe?r.filter(t=>Qe.has(Mz(Ze.get(Mz(`${e}.${t.name}`))??t.name))).length:0;return(0,V.jsxs)(`section`,{className:`sf-model-card`,"data-pan-ignore":``,"data-base":a||void 0,"data-outside":i&&!o||void 0,style:{left:t.x,top:t.y,width:Oz},"aria-label":`Table ${e}${a?`, where the rows come from`:``}`,children:[(0,V.jsxs)(`header`,{className:`sf-model-head`,style:{height:kz},onPointerDown:Le(e),children:[(0,V.jsxs)(`span`,{className:`sf-model-name`,title:y[e]?.comment||void 0,children:[e,y[e]?.comment&&(0,V.jsxs)(`span`,{className:`sf-a2-visually-hidden`,children:[`. `,y[e].comment]})]}),a&&(0,V.jsx)(`span`,{className:`sf-schema-tag`,title:`One row of the result is one row of this table`,children:`Rows`}),Qe&&Array.isArray(n)&&(0,V.jsxs)(`span`,{className:`sf-model-used`,title:`${s} of ${r.length} columns are used by a field`,children:[s,`/`,r.length,(0,V.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:` columns used`})]}),(0,V.jsx)(FF,{certification:_[e]}),(0,V.jsx)(`button`,{type:`button`,className:`sf-model-remove`,"aria-label":`Remove ${e} from the diagram`,onClick:()=>xe(e),children:(0,V.jsx)(dI,{icon:`close`})})]}),n===void 0||n===`loading`?(0,V.jsx)(`p`,{className:`sf-model-note`,style:{height:Az},children:`Loading…`}):Array.isArray(n)?(0,V.jsxs)(`ul`,{className:`sf-model-columns`,children:[ve(e).map(t=>{let n=it(e,t.name),r=[t.primaryKey&&`primary key`,n&&`refers to ${n}`,t.partitionKey&&`partition key`,!t.nullable&&!t.primaryKey&&`never empty`].filter(Boolean),a=Ze.get(Mz(`${e}.${t.name}`)),o=i&&a!==void 0&&a!==t.name;return(0,V.jsxs)(`li`,{style:{height:Az},"data-model-table":e,"data-model-column":t.name,"data-key":at.has(Mz(`${e}.${t.name}`))||void 0,"data-unused":Qe&&!Qe.has(Mz(a??t.name))||void 0,title:[`${t.name} ${t.nativeType.toLowerCase()}${r.length?` · ${r.join(` · `)}`:``}`,t.comment,`Drag onto a column of another table to join`].filter(Boolean).join(`
|
|
44
|
+
`),onPointerDown:Re(e,t.name),children:[(0,V.jsxs)(`span`,{className:`sf-model-keys`,"aria-hidden":`true`,children:[t.primaryKey&&(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`pk`,children:`PK`}),n&&(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`fk`,children:`FK`})]}),(0,V.jsx)(`span`,{className:`sf-model-column`,children:t.name}),(0,V.jsx)(`span`,{className:`sf-model-type`,children:o?(0,V.jsxs)(`span`,{className:`sf-model-as`,children:[`as `,a]}):t.nativeType.toLowerCase()}),o&&(0,V.jsxs)(`span`,{className:`sf-a2-visually-hidden`,children:[`, named `,a,` in the result because an earlier table has a column of this name`]}),(r.length>0||t.comment)&&(0,V.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:[...r,t.comment].filter(Boolean).join(`. `)})]},t.name)}),r.length>jz&&(0,V.jsx)(`li`,{style:{height:Az},children:(0,V.jsx)(`button`,{type:`button`,className:`sf-model-more`,onClick:()=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:x.has(e)?`Show fewer`:`${r.length-jz} more columns`})})]}):(0,V.jsxs)(`p`,{className:`sf-model-note`,role:`alert`,children:[`Could not read this table: `,n.error,` `,(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{g(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),ae(e=>e+1)},children:`Try again`})]})]},e)}),Ke.flatMap(e=>e.keys.map(t=>{let n=He(e.left,t.leftColumn,e.right),r=He(e.right,t.rightColumn,e.left);return(0,V.jsx)(`button`,{type:`button`,className:`sf-model-cut`,style:{left:(n.x+r.x)/2,top:(n.y+r.y)/2},"aria-label":`Remove the line ${mz({...e,keys:[t]})}`,title:`Remove this join`,onPointerDown:e=>e.stopPropagation(),onClick:()=>we(e,t),children:(0,V.jsx)(dI,{icon:`close`})},`cut:${pz(e)}:${t.leftColumn}:${t.rightColumn}`)})),Ke.map(e=>{let t=e.keys[0];if(!t||qe.has(pz(e)))return null;let n=He(e.left,t.leftColumn,e.right),r=He(e.right,t.rightColumn,e.left),a=et(e);return(0,V.jsxs)(`div`,{className:`sf-model-joinbox`,"data-pan-ignore":``,"data-shape":i?a.shape:void 0,style:{left:(n.x+r.x)/2,top:(n.y+r.y)/2},onPointerDown:e=>e.stopPropagation(),children:[tt(e,a.read,`sf-model-kind`,!0),i&&(0,V.jsx)(`span`,{className:`sf-model-shape`,title:`${a.shapeText} ${a.kindNote}`.trim(),children:a.chip})]},`box:${pz(e)}`)}),l.length===0&&(0,V.jsx)(`p`,{className:`sf-model-empty`,children:`Add a table above, or drag one here from the browser.`})]})]}),l.length>0&&(0,V.jsxs)(`p`,{className:`sf-model-legend`,children:[(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`pk`,children:`PK`}),` primary key `,(0,V.jsx)(`abbr`,{className:`sf-model-key`,"data-kind":`fk`,children:`FK`}),` refers to another table. Point at a column for its description.`]}),(0,V.jsx)(`p`,{className:`sf-model-status`,"aria-live":`polite`,children:te}),ne&&(0,V.jsxs)(`p`,{className:`sf-model-problem`,role:`alert`,children:[ne,` `,(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>re(``),children:`Dismiss`})]}),(0,V.jsxs)(`section`,{className:`sf-model-joins`,"aria-label":`Joins`,children:[i&&l.length>1&&(0,V.jsxs)(`label`,{className:`sf-model-base`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`Rows come from`}),(0,V.jsx)(`select`,{className:`sf-input`,"aria-label":`Rows come from`,value:$e,onChange:e=>De(e.target.value),children:l.map(e=>(0,V.jsx)(`option`,{children:e},e))}),(0,V.jsxs)(`span`,{className:`sf-object-muted`,children:[`One row of the result is one `,$e,` row; the other tables add detail to it.`]})]}),(0,V.jsx)(`h4`,{className:`sf-object-label`,children:`Joins`}),d.filter(Ae).length===0?(0,V.jsx)(`p`,{className:`sf-object-muted`,children:`None yet. Drag a column onto a column of another table, or add one below.`}):(0,V.jsx)(`ul`,{children:d.filter(Ae).map(e=>{let t=et(e);return(0,V.jsxs)(`li`,{"data-shape":i?t.shape:void 0,children:[(0,V.jsx)(`code`,{children:mz(t.read)}),e.inferred&&(0,V.jsx)(`span`,{className:`sf-schema-tag`,children:`Inferred`}),e.declared&&!e.inferred&&(0,V.jsx)(`span`,{className:`sf-schema-tag`,children:`Declared`}),tt(e,t.read,`sf-input sf-model-kind-field`),i&&!qe.has(pz(e))&&(0,V.jsxs)(`span`,{className:`sf-model-effect`,children:[t.shape===`many`&&(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`▲ `}),t.shapeText,` `,t.kindNote,e.inferred&&` Not in the query until confirmed.`,t.error&&(0,V.jsxs)(`span`,{role:`alert`,children:[` The engine could not count: `,t.error]})]}),i&&!qe.has(pz(e))&&t.shape!==`checking`&&(t.shape===`unknown`||t.shape===`many`||t.error)&&(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>ke(e,t.near),children:`Check with the engine`}),qe.has(pz(e))&&(0,V.jsxs)(`span`,{className:`sf-model-broken`,children:[`▲ Will not work, left out of the SQL. `,qe.get(pz(e))]}),e.inferred&&!qe.has(pz(e))&&(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>Te(e),children:`Confirm`}),(0,V.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-label":`Remove join ${mz(e)}`,onClick:()=>{f(t=>t.filter(t=>pz(t)!==pz(e))),re(``),A(`Removed the join.`)},children:`Remove`})]},pz(e))})}),l.length>1&&(0,V.jsxs)(`form`,{className:`sf-model-add`,onSubmit:e=>{if(e.preventDefault(),!k.left||!k.leftColumn||!k.right||!k.rightColumn)return A(`Choose two tables and a column in each.`);Te({left:k.left,right:k.right,keys:[{leftColumn:k.leftColumn,rightColumn:k.rightColumn}]}),ee({left:``,leftColumn:``,right:``,rightColumn:``})},children:[ot(`Table`,k.left,l,e=>ee({...k,left:e,leftColumn:``})),ot(`Column`,k.leftColumn,rt(k.left,`unknown`),e=>ee({...k,leftColumn:e,rightColumn:``})),ot(`Joins table`,k.right,l.filter(e=>e!==k.left),e=>ee({...k,right:e,rightColumn:``})),ot(`On column`,k.rightColumn,rt(k.right,nt),e=>ee({...k,rightColumn:e})),(0,V.jsx)(`button`,{type:`submit`,className:`sf-button`,children:`Add join`})]})]}),Ye.sql&&(0,V.jsxs)(`details`,{className:`sf-result-sql`,children:[(0,V.jsx)(`summary`,{children:`SQL for this model`}),(0,V.jsx)(VL,{code:Ye.sql,language:`sql`,label:`SQL for this model`}),Ye.unjoined.length>0&&(0,V.jsxs)(`p`,{className:`sf-result-notice`,children:[`Not joined to the rest, so left out: `,Ye.unjoined.join(`, `),`.`]}),Je.length>0&&(0,V.jsxs)(`p`,{className:`sf-result-notice`,children:[`Could not be read, so left out: `,Je.join(`, `),`.`]}),qe.size>0&&(0,V.jsxs)(`p`,{className:`sf-result-notice`,children:[qe.size===1?`One join`:`${qe.size} joins`,` cannot work and `,qe.size===1?`is`:`are`,` left out. See the list above.`]})]})]})}var V,Ez,Dz,Oz,kz,Az,jz,Mz,Nz,Pz,Fz,Iz,Lz,Rz,zz,Bz=n((()=>{V=WA(),rw(),vS(),Ez=NM(),GN(),cP(),GF(),fz(),jF(),vI(),qL(),Dz=[`inner`,`left`,`right`,`full`],Oz=240,kz=34,Az=24,jz=10,Mz=e=>e.toLowerCase(),Nz=(e,t)=>Mz(e)===Mz(t),Pz=e=>/^[A-Za-z_]\w*$/.test(e)?e:`"${e.replace(/"/g,`""`)}"`,Fz=e=>/^[A-Za-z_]\w*(\.[A-Za-z_]\w*){1,2}$/.test(e)?e:Pz(e),Iz={inner:`JOIN`,left:`LEFT OUTER JOIN`,right:`RIGHT OUTER JOIN`,full:`FULL OUTER JOIN`},Lz={inner:`inner`,left:`right`,right:`left`,full:`full`},Rz=e=>`"${e.replace(/"/g,`""`)}"`,zz={number:`a number`,text:`text`,time:`a date or time`,boolean:`true or false`,binary:`binary data`,nested:`nested data`,unknown:`of an unknown type`}}));function Vz(e){return e.ambientCredentials?`The server's own cloud credentials`:e.credentialsSecret?`Secret ${e.credentialsSecret}`:`None (public)`}function Hz(e){let t=VN(e.dataSource),[n,r]=(0,Wz.useState)(),[i,a]=(0,Wz.useState)(),[o,s]=(0,Wz.useState)({});(0,Wz.useEffect)(()=>{let e=!0;return t.listSources({}).then(t=>e&&r(t.sources)).catch(t=>e&&a(aP(t))),()=>{e=!1}},[t]);let c=e=>{t.testSource&&(s(t=>({...t,[e]:`running`})),t.testSource({target:{case:`id`,value:e}}).then(t=>s(n=>({...n,[e]:t}))).catch(t=>s(n=>({...n,[e]:{error:aP(t)}}))))};return i?(0,Uz.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:i}):n?n.length===0?(0,Uz.jsx)(`p`,{className:`sf-object-muted`,children:`No sources are configured.`}):(0,Uz.jsx)(`ul`,{className:[`sf-sources`,e.className].filter(Boolean).join(` `),children:n.map(n=>{let r=o[n.id],i=r&&r!==`running`&&!(`error`in r)?r:void 0;return(0,Uz.jsxs)(`li`,{className:`sf-source`,children:[(0,Uz.jsxs)(`header`,{className:`sf-source-head`,children:[(0,Uz.jsxs)(`div`,{children:[(0,Uz.jsx)(`h3`,{className:`sf-object-title`,children:n.displayName||n.id}),(0,Uz.jsx)(`p`,{className:`sf-object-facts`,children:[n.id,Gz[n.engine],n.readOnly?`Read only`:void 0,n.capabilities?.timeTravel?`Time travel`:void 0,n.capabilities?.storedResults?`Keeps results`:void 0].filter(Boolean).join(` · `)})]}),(0,Uz.jsxs)(`div`,{className:`sf-object-buttons`,children:[e.onSelect&&(0,Uz.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onSelect?.(n),children:`Open`}),t.testSource&&(0,Uz.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:r===`running`,onClick:()=>c(n.id),children:r===`running`?`Testing…`:`Test connection`})]})]}),n.connections.length>0&&(0,Uz.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Connections of ${n.displayName||n.id}`,children:(0,Uz.jsxs)(`table`,{children:[(0,Uz.jsxs)(`caption`,{className:`sf-a2-visually-hidden`,children:[`Connections of `,n.displayName||n.id]}),(0,Uz.jsx)(`thead`,{children:(0,Uz.jsxs)(`tr`,{children:[(0,Uz.jsx)(`th`,{scope:`col`,children:`Connection`}),(0,Uz.jsx)(`th`,{scope:`col`,children:`Type`}),(0,Uz.jsx)(`th`,{scope:`col`,children:`Covers`}),(0,Uz.jsx)(`th`,{scope:`col`,children:`Signs in with`})]})}),(0,Uz.jsx)(`tbody`,{children:n.connections.map(e=>(0,Uz.jsxs)(`tr`,{children:[(0,Uz.jsx)(`th`,{scope:`row`,children:e.name}),(0,Uz.jsx)(`td`,{children:Kz[e.kind]??`Other`}),(0,Uz.jsx)(`td`,{className:`sf-object-type`,children:e.scope}),(0,Uz.jsx)(`td`,{children:Vz(e)})]},e.name))})]})}),(0,Uz.jsxs)(`div`,{"aria-live":`polite`,children:[r&&r!==`running`&&`error`in r&&(0,Uz.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:r.error}),i&&(0,Uz.jsxs)(Uz.Fragment,{children:[(0,Uz.jsxs)(`p`,{className:`sf-source-result`,"data-ok":i.ok||void 0,children:[(0,Uz.jsx)(`span`,{"aria-hidden":`true`,children:i.ok?`✓`:`!`}),` `,i.message,i.engineVersion?` · ${Gz[n.engine]??`Engine`} ${i.engineVersion}`:``,` · `,Number(i.elapsedMs),` ms`]}),i.checks.length>0&&(0,Uz.jsx)(`ul`,{className:`sf-source-checks`,children:i.checks.map(e=>(0,Uz.jsxs)(`li`,{"data-ok":e.ok||void 0,children:[(0,Uz.jsx)(`span`,{"aria-hidden":`true`,children:e.ok?`✓`:`!`}),(0,Uz.jsx)(`strong`,{children:e.name}),(0,Uz.jsx)(`span`,{children:e.ok?`Reachable`:e.message})]},e.name))})]})]})]},n.id)})}):(0,Uz.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`})}var Uz,Wz,Gz,Kz,qz=n((()=>{Uz=WA(),vS(),Wz=NM(),GN(),cP(),Gz={[Nx.DUCKDB]:`DuckDB`,[Nx.DATAFUSION]:`DataFusion`,[Nx.TERADATA]:`Teradata`,[Nx.POSTGRES]:`Postgres`,[Nx.MYSQL]:`MySQL`,[Nx.SQLSERVER]:`SQL Server`,[Nx.SNOWFLAKE]:`Snowflake`,[Nx.BIGQUERY]:`BigQuery`,[Nx.DATABRICKS]:`Databricks`,[Nx.ORACLE]:`Oracle`},Kz={[Mx.S3]:`Amazon S3`,[Mx.GCS]:`Google Cloud Storage`,[Mx.AZURE]:`Azure Storage`,[Mx.HTTP]:`Web (https)`,[Mx.ICEBERG_REST]:`Iceberg REST catalog`,[Mx.DATABASE_FILE]:`Database file`,[Mx.POSTGRES]:`Postgres database`}})),Jz=n((()=>{WA(),NM()}));function Yz(e,t=`number`,n=`USD`){return NA(t===`currency`?Math.abs(e)>=1e5?{style:`currency`,currency:n,notation:`compact`,maximumFractionDigits:1}:Math.abs(e)>=1e3?{style:`currency`,currency:n,minimumFractionDigits:0,maximumFractionDigits:0}:{style:`currency`,currency:n,maximumFractionDigits:2}:t===`percent`?{style:`percent`,maximumFractionDigits:1}:t===`compact`?{notation:`compact`,maximumFractionDigits:1}:{maximumFractionDigits:2}).format(e)}function Xz(e){let{sourceId:t,sql:n,column:r,aggregate:i,percentile:a,label:o,format:s,currency:c,filters:l,timeTravel:u,notBefore:d}=e,f=VN(e.dataSource),[p,m]=(0,Qz.useState)({loading:!0}),h=JSON.stringify([t,n,r,i,a,l,u,d],(e,t)=>typeof t==`bigint`?`${t}n`:t);return(0,Qz.useEffect)(()=>{let e=new AbortController;return m(e=>({...e,loading:!0,error:void 0})),JS(f.execute({sourceId:t,timeTravel:u,notBefore:d,query:{baseSql:n,filters:l,aggregates:[{function:wF[i],column:r??``,alias:`value`,percentile:i===`percentile`?a??.9:0}]}},{signal:e.signal})).then(t=>{if(e.signal.aborted)return;let n=t.table.schema.fields.find(e=>e.name===`value`),r=t.table.getChild(`value`)?.get(0);m({value:n?$N(r,n.type):null,loading:!1,notes:uP(t.header.notices)})}).catch(t=>{e.signal.aborted||m({error:aP(t),loading:!1})}),()=>e.abort()},[f,h]),(0,Zz.jsxs)(`div`,{className:[`sf-a2-stat sf-metric`,e.className].filter(Boolean).join(` `),"aria-busy":p.loading,children:[(0,Zz.jsx)(`span`,{className:`sf-a2-stat-label`,children:o}),p.error?(0,Zz.jsx)(`span`,{className:`sf-metric-error`,role:`alert`,"data-error":p.error,children:e.errorMessage??p.error}):(0,Zz.jsx)(`span`,{className:`sf-a2-stat-value`,children:p.value===void 0?z(`metric.loading`):p.value===null?e.emptyMessage??z(`metric.none`):Yz(p.value,s,c)}),(0,Zz.jsx)(dP,{notes:p.notes})]})}var Zz,Qz,$z=n((()=>{Zz=WA(),rw(),Qz=NM(),EF(),GN(),mP(),rP(),HA(),cP()}));function eB(e){let{sourceId:t,sql:n,label:r,renderRow:i,filters:a,sorts:o,rowKey:s,layout:c=`list`,timeTravel:l,notBefore:u}=e,d=VN(e.dataSource),f=Math.max(1,Math.min(100,Math.trunc(e.pageSize??20))),[p,m]=(0,nB.useState)({rows:[],more:!1,loading:!0}),[h,g]=(0,nB.useState)(1),_=JSON.stringify([t,n,a,o,f,l,u],(e,t)=>typeof t==`bigint`?`${t}n`:t),v=(0,nB.useRef)(_),y=v.current===_?h:1;(0,nB.useEffect)(()=>{v.current!==_&&(v.current=_,g(1))},[_]),(0,nB.useEffect)(()=>{let e=new AbortController,r=y===1;m(e=>({rows:r?[]:e.rows,more:!1,loading:!0}));let i=(y-1)*f,s=Math.min(f,200-i)+1;return JS(d.execute({sourceId:t,timeTravel:l,notBefore:u,query:{baseSql:n,filters:a,sorts:o,page:{limit:s,offset:BigInt(i)}}},{signal:e.signal})).then(t=>{if(e.signal.aborted)return;let n=t.table.schema.fields,i=n.map((e,n)=>t.table.getChildAt(n)),a=Array.from({length:t.table.numRows},(e,t)=>Object.fromEntries(n.map((e,n)=>[e.name,tP(i[n].get(t),e.type)])));m(e=>({rows:[...r?[]:e.rows,...a.slice(0,s-1)],more:a.length>=s,loading:!1,notes:uP(t.header.notices)}))}).catch(t=>{e.signal.aborted||m(e=>({rows:r?[]:e.rows,more:!1,loading:!1,error:aP(t)}))}),()=>e.abort()},[d,_,y]);let{rows:b}=p,x=b.length>=200;return(0,tB.jsxs)(`div`,{className:[`sf-rowlist`,e.className].filter(Boolean).join(` `),"aria-busy":p.loading,children:[b.length>0&&(0,tB.jsx)(`ul`,{className:`sf-rowlist-rows`,"data-layout":c,"aria-label":r,children:b.map((e,t)=>(0,tB.jsx)(`li`,{children:i(e,t)},s&&e[s]!=null?`${String(e[s])}:${t}`:t))}),p.error?(0,tB.jsx)(`p`,{className:`sf-rowlist-note`,role:`alert`,"data-error":p.error,children:e.errorMessage??p.error}):(0,tB.jsx)(`p`,{className:`sf-rowlist-note`,role:`status`,children:p.loading?z(`rows.loading`):b.length===0?e.emptyMessage??z(`rows.empty`):x&&p.more?z(`rows.full`,{count:NA().format(b.length)}):p.more?z(`rows.some`,{count:NA().format(b.length)}):``}),(0,tB.jsx)(dP,{notes:p.notes}),p.more&&!x&&!p.loading&&(0,tB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{g(y+1),e.onContext?.({kind:`rows.more`,summary:`Asked for more of ${r}, past the first ${b.length}.`,subject:{label:r,shown:b.length}})},children:z(`rows.more`)})]})}var tB,nB,rB=n((()=>{tB=WA(),rw(),nB=NM(),GN(),mP(),rP(),cP(),HA()}));function iB(e,t){let n=new Set(e.map(e=>e.id)),r=new Map(e.map(e=>[e.id,[]]));for(let e of t)n.has(e.from)&&n.has(e.to)&&r.get(e.to).push(e.from);let i=new Map,a=(e,t)=>{let n=i.get(e);if(n!==void 0)return n;if(t.has(e))return 0;t.add(e);let o=Math.max(-1,...r.get(e).map(e=>a(e,t)))+1;return t.delete(e),i.set(e,o),o};for(let t of e)a(t.id,new Set);let o=new Map,s={};for(let t of e){let e=i.get(t.id),n=o.get(e)??0;o.set(e,n+1),s[t.id]={x:16+e*272,y:16+n*84,column:e}}let c=Math.max(0,...i.values())+1,l=Math.max(1,...o.values());return{positions:s,width:32+c*_B+(c-1)*yB,height:32+l*vB+(l-1)*bB}}function aB(e,t){let n=new Set([e]),r=(e,r)=>{let i=[e];for(;i.length>0;){let e=i.pop();for(let a of t){let[t,o]=r(a);t===e&&!n.has(o)&&(n.add(o),i.push(o))}}};return r(e,e=>[e.from,e.to]),r(e,e=>[e.to,e.from]),n}function oB(e){let{nodes:t,edges:n,selected:r,height:i=360}=e,a=(0,mB.useMemo)(()=>iB(t,n),[t,n]),o=(0,mB.useMemo)(()=>r?aB(r,n):void 0,[r,n]),s=(0,mB.useId)(),c=az({content:{width:a.width,height:a.height}}),l=c.viewport.width>0?tz(a,{width:c.viewport.width,height:i}).k:1,u=Math.min(i,Math.max(Math.ceil(a.height*l)+32,Math.min(i,160))),d=(0,mB.useMemo)(()=>[...t].sort((e,t)=>a.positions[e.id].x-a.positions[t.id].x||a.positions[e.id].y-a.positions[t.id].y),[t,a]),f=(e,t)=>{let n=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;n!==0&&(e.preventDefault(),(e.currentTarget.parentElement?.querySelectorAll(`button.sf-pipeline-node`))?.[Math.max(0,Math.min(d.length-1,t+n))]?.focus())};return t.length===0?(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`This pipeline has no datasets.`}):(0,H.jsxs)(`div`,{className:[`sf-pipeline-graph`,e.className].filter(Boolean).join(` `),children:[(0,H.jsx)(oz,{panZoom:c,label:`Zoom the ${(e.label??`pipeline`).toLowerCase()}`}),(0,H.jsxs)(`div`,{ref:c.viewportRef,className:`sf-pipeline sf-panzoom`,style:{height:u},role:`group`,"aria-label":e.label??`Pipeline`,"aria-describedby":`${s}-keys`,...c.viewportProps,children:[(0,H.jsx)(`span`,{id:`${s}-keys`,className:`sf-a2-visually-hidden`,children:`Drag the background or scroll to move around. Plus and minus zoom, 0 fits the pipeline to view, arrow keys move it.`}),(0,H.jsxs)(`div`,{className:`sf-pipeline-plane sf-panzoom-plane`,style:{width:a.width,height:a.height,...c.planeStyle},"data-animate":c.animate||void 0,children:[(0,H.jsx)(`svg`,{width:a.width,height:a.height,"aria-hidden":`true`,children:n.map(e=>{let t=a.positions[e.from],n=a.positions[e.to];if(!t||!n)return null;let[r,i,s,c]=[t.x+_B,t.y+vB/2,n.x,n.y+vB/2],l=Math.max(24,(s-r)/2),u=!o||o.has(e.from)&&o.has(e.to);return(0,H.jsx)(`path`,{d:`M ${r} ${i} C ${r+l} ${i}, ${s-l} ${c}, ${s} ${c}`,"data-mode":e.mode??`batch`,"data-dim":u?void 0:``},`${e.from}>${e.to}`)})}),d.map((i,s)=>{let c=a.positions[i.id],l=i.status??`idle`,u=n.filter(e=>e.from===i.id).map(e=>t.find(t=>t.id===e.to)?.name).filter(Boolean);return(0,H.jsxs)(`button`,{type:`button`,className:`sf-pipeline-node`,style:{left:c.x,top:c.y,width:_B,height:vB},"data-status":l,"data-kind":i.kind,"data-dim":o&&!o.has(i.id)?``:void 0,"aria-pressed":r===i.id,onClick:()=>e.onSelect?.(i),onKeyDown:e=>f(e,s),children:[(0,H.jsxs)(`span`,{className:`sf-pipeline-name`,children:[(0,H.jsx)(`span`,{className:`sf-pipeline-mark`,"aria-hidden":`true`,children:gB[l]}),i.name,` `,(0,H.jsx)(`span`,{className:`sf-visually-hidden`,children:`(${hB[i.kind]}, ${l}${u.length>0?`, feeds ${u.join(`, `)}`:``})`})]}),(0,H.jsxs)(`span`,{className:`sf-pipeline-meta`,"aria-hidden":`true`,children:[hB[i.kind],i.layer?` · ${i.layer}`:``]}),(0,H.jsxs)(`span`,{className:`sf-pipeline-meta`,"aria-hidden":`true`,children:[i.rowsWritten===void 0?l:`${xB.format(i.rowsWritten)} rows`,i.expectationsFailed?` · ${xB.format(i.expectationsFailed)} records broke rules`:``,i.checksFailed?` · ${i.checksFailed} ${i.checksFailed===1?`check`:`checks`} failed`:``,i.checksWarned?` · ${i.checksWarned} ${i.checksWarned===1?`warning`:`warnings`}`:``]})]},i.id)})]})]})]})}function sB(e){if(!(e>=0))return`–`;let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n} min ${t%60} s`:`${Math.floor(n/60)} h ${n%60} min`}function cB({runs:e,selected:t,onSelect:n,className:r}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`This pipeline has not run yet.`});let i=[...e].sort((e,t)=>t.startTime.localeCompare(e.startTime)),a=Math.max(1,...i.map(e=>e.endTime?Date.parse(e.endTime)-Date.parse(e.startTime):0));return(0,H.jsx)(`div`,{className:[`sf-object-table sf-runs`,r].filter(Boolean).join(` `),tabIndex:0,role:`region`,"aria-label":`Runs`,children:(0,H.jsxs)(`table`,{children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,children:`Run`}),(0,H.jsx)(`th`,{scope:`col`,children:`Result`}),(0,H.jsx)(`th`,{scope:`col`,children:`Started`}),(0,H.jsx)(`th`,{scope:`col`,children:`Took`}),(0,H.jsx)(`th`,{scope:`col`,children:`Kind`}),(0,H.jsx)(`th`,{scope:`col`,children:`Started by`})]})}),(0,H.jsx)(`tbody`,{children:i.map(e=>{let r=e.endTime?Date.parse(e.endTime)-Date.parse(e.startTime):NaN;return(0,H.jsxs)(`tr`,{"data-status":e.state,"aria-selected":t===e.id,children:[(0,H.jsx)(`th`,{scope:`row`,children:n?(0,H.jsx)(`button`,{type:`button`,className:`sf-runs-open`,onClick:()=>n(e),children:e.id}):e.id}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-pipeline-mark`,"aria-hidden":`true`,children:gB[e.state]}),` `,e.state,e.errorMessage&&(0,H.jsx)(`span`,{className:`sf-object-column-note`,children:e.errorMessage})]}),(0,H.jsx)(`td`,{children:e.startTime.replace(`T`,` `).slice(0,19)}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-runs-bar`,style:{inlineSize:`${Number.isNaN(r)?0:Math.max(2,r/a*100)}%`},"aria-hidden":`true`}),Number.isNaN(r)?`In progress`:sB(r)]}),(0,H.jsxs)(`td`,{children:[SB[e.refreshKind??`default`],e.datasets&&e.datasets.length>0?` · ${e.datasets.length} ${e.datasets.length===1?`dataset`:`datasets`}`:``]}),(0,H.jsx)(`td`,{children:e.trigger??`–`})]},e.id)})})]})})}function lB({expectations:e,onOpenFailing:t,className:n}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`No data quality rules are defined.`});let r=e=>e.passedRecords+e.failedRecords===0?0:e.failedRecords/(e.passedRecords+e.failedRecords),i=[...e].sort((e,t)=>r(t)-r(e)||e.name.localeCompare(t.name));return(0,H.jsx)(`div`,{className:[`sf-object-table sf-expectations`,n].filter(Boolean).join(` `),tabIndex:0,role:`region`,"aria-label":`Data quality rules`,children:(0,H.jsxs)(`table`,{children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,children:`Rule`}),(0,H.jsx)(`th`,{scope:`col`,children:`Dataset`}),(0,H.jsx)(`th`,{scope:`col`,children:`A failing record is`}),(0,H.jsx)(`th`,{scope:`col`,className:`sf-object-number`,children:`Failed`}),(0,H.jsx)(`th`,{scope:`col`,children:`Share failing`})]})}),(0,H.jsx)(`tbody`,{children:i.map(e=>(0,H.jsxs)(`tr`,{"data-failing":e.failedRecords>0||void 0,children:[(0,H.jsxs)(`th`,{scope:`row`,children:[e.name,(0,H.jsx)(`span`,{className:`sf-object-column-note sf-object-type`,children:e.constraint})]}),(0,H.jsx)(`td`,{children:e.dataset}),(0,H.jsx)(`td`,{children:CB[e.action]}),(0,H.jsxs)(`td`,{className:`sf-object-number`,children:[wB.format(e.failedRecords),` of `,wB.format(e.passedRecords+e.failedRecords)]}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-meter`,role:`img`,"aria-label":`${(r(e)*100).toFixed(1)}% failing`,children:(0,H.jsx)(`span`,{style:{inlineSize:`${Math.min(100,r(e)*100)}%`},"data-bad":``})}),` `,(r(e)*100).toFixed(1),`%`,t&&e.failedRecords>0&&(0,H.jsx)(`button`,{type:`button`,className:`sf-button sf-expectations-open`,onClick:()=>t(e),children:`See failing rows`})]})]},`${e.dataset}.${e.name}`))})]})})}function uB({checks:e,onOpenFailing:t,className:n}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`No checks on this dataset.`});let r=e=>e.failedRecords===void 0?1:e.failedRecords>0?e.severity===`fail`?0:.5:2,i=[...e].sort((e,t)=>r(e)-r(t)||e.name.localeCompare(t.name));return(0,H.jsx)(`div`,{className:[`sf-object-table sf-checks`,n].filter(Boolean).join(` `),tabIndex:0,role:`region`,"aria-label":`Checks`,children:(0,H.jsxs)(`table`,{children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,children:`Check`}),(0,H.jsx)(`th`,{scope:`col`,children:`Result`}),(0,H.jsx)(`th`,{scope:`col`,children:`On failure`})]})}),(0,H.jsx)(`tbody`,{children:i.map(e=>{let n=(e.failedRecords??0)>0;return(0,H.jsxs)(`tr`,{"data-failing":n||void 0,children:[(0,H.jsxs)(`th`,{scope:`row`,children:[e.name,(0,H.jsxs)(`span`,{className:`sf-object-column-note sf-object-type`,children:[e.description,e.fromKey?` (from the key)`:``]})]}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`span`,{className:`sf-check-mark`,"data-state":e.failedRecords===void 0?`unknown`:n?e.severity:`pass`,children:e.failedRecords===void 0?`Not run yet`:n?e.severity===`fail`?`! Failed`:`! Warning`:`✓ Passed`}),e.summary&&e.summary!==`Passed.`&&(0,H.jsx)(`span`,{className:`sf-object-column-note`,children:e.summary}),t&&n&&e.canOpenFailing!==!1&&(0,H.jsx)(`button`,{type:`button`,className:`sf-button sf-expectations-open`,onClick:()=>t(e),children:`See what breaks it`})]}),(0,H.jsx)(`td`,{children:e.severity===`fail`?`Stops what reads it`:`Warns`})]},e.name)})})]})})}function dB({changes:e,rescuedCount:t,mode:n,className:r}){return(0,H.jsxs)(`div`,{className:[`sf-schema-diff`,r].filter(Boolean).join(` `),children:[(n||t!==void 0)&&(0,H.jsx)(`p`,{className:`sf-object-facts`,children:[n?`New columns: ${n}`:void 0,t===void 0?void 0:`${wB.format(t)} records had fields set aside`].filter(Boolean).join(` · `)}),e.length===0?(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`The incoming data matches the table.`}):(0,H.jsx)(`ul`,{children:e.map(e=>(0,H.jsxs)(`li`,{"data-change":e.change,children:[(0,H.jsx)(`span`,{className:`sf-schema-diff-mark`,"aria-hidden":`true`,children:EB[e.change]}),(0,H.jsx)(`strong`,{children:e.column}),(0,H.jsx)(`span`,{children:TB[e.change]}),(0,H.jsx)(`span`,{className:`sf-object-type`,children:e.change===`typeChanged`?`${e.before??`?`} → ${e.after??`?`}`:e.after??e.before??``})]},`${e.change}:${e.column}`))})]})}function fB(e){if(e.length===0)return``;let t=Math.max(...e),n=Math.min(...e),r=t-n||1;return e.map((t,i)=>`${e.length===1?50:i/(e.length-1)*100},${26-(t-n)/r*24}`).join(` `)}function pB({progress:e,className:t}){if(e.length===0)return(0,H.jsx)(`p`,{className:`sf-object-muted`,children:`No progress has been reported yet.`});let n=e.at(-1),r=n.processedRowsPerSecond<n.inputRowsPerSecond;return(0,H.jsxs)(`div`,{className:[`sf-stream`,t].filter(Boolean).join(` `),children:[(0,H.jsxs)(`p`,{className:`sf-stream-status`,"data-behind":r||void 0,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:r?`!`:`✓`}),` `,r?`Falling behind: rows arrive faster than they are processed.`:`Keeping up with its input.`,` Last report`,` `,n.timestamp.replace(`T`,` `).slice(0,19),`.`]}),(0,H.jsx)(`dl`,{className:`sf-stream-grid`,children:DB.filter(t=>e.some(e=>e[t.key]!==void 0)).map(t=>{let n=e.map(e=>e[t.key]).filter(e=>e!==void 0);return(0,H.jsxs)(`div`,{className:`sf-stream-tile`,children:[(0,H.jsx)(`dt`,{children:t.label}),(0,H.jsxs)(`dd`,{children:[xB.format(n.at(-1)),` `,(0,H.jsx)(`span`,{children:t.unit}),(0,H.jsx)(`svg`,{viewBox:`0 0 100 28`,preserveAspectRatio:`none`,role:`img`,"aria-label":`${t.label} over the last ${n.length} reports, from ${xB.format(Math.min(...n))} to ${xB.format(Math.max(...n))}`,children:(0,H.jsx)(`polyline`,{points:fB(n)})})]})]},t.key)})})]})}var H,mB,hB,gB,_B,vB,yB,bB,xB,SB,CB,wB,TB,EB,DB,OB=n((()=>{H=WA(),mB=NM(),fz(),HA(),hB={source:`Source`,table:`Table`,view:`View`,streamingTable:`Streaming table`,materializedView:`Materialized view`,temporaryView:`Temporary view`,sink:`Sink`},gB={idle:`○`,starting:`…`,running:`…`,completed:`✓`,failed:`!`,cancelled:`×`,skipped:`–`},_B=200,vB=64,yB=72,bB=20,xB={format:e=>NA({notation:`compact`,maximumFractionDigits:1}).format(e)},SB={default:`New data`,refresh:`Refresh`,fullRefresh:`Full refresh`},CB={warn:`Kept, with a warning`,drop:`Dropped`,fail:`Fails the run`},wB={format:e=>NA().format(e)},TB={added:`New column`,removed:`Missing column`,typeChanged:`Type changed`},EB={added:`+`,removed:`−`,typeChanged:`~`},DB=[{key:`inputRowsPerSecond`,label:`Input rate`,unit:`rows/s`},{key:`processedRowsPerSecond`,label:`Processing rate`,unit:`rows/s`},{key:`numInputRows`,label:`Rows per batch`,unit:`rows`},{key:`batchDurationMs`,label:`Batch duration`,unit:`ms`},{key:`stateRows`,label:`Rows in state`,unit:`rows`}]}));function kB(e){let t=e.columns.join(`, `);if(e.kind===nS.UNSPECIFIED&&e.description)return e.description;switch(e.kind){case nS.RELATIONSHIPS:return`${t} is found in ${e.toTable}.${e.toColumn}`;case nS.ACCEPTED_VALUES:return`${t} is one of ${e.values.join(`, `)}`;case nS.ROW_COUNT:return e.minRows!==void 0&&e.maxRows!==void 0?`between ${e.minRows} and ${e.maxRows} rows`:e.minRows===void 0?e.maxRows===void 0?`row count`:`at most ${e.maxRows} rows`:`at least ${e.minRows} rows`;default:return`${t} ${PB[e.kind]??``}`.trim()}}function AB(e,t){if(!e)return[`New dataset`];let n=[],r=(e,t)=>JSON.stringify(e)===JSON.stringify(t);e.sql.trim()!==t.sql.trim()&&n.push(`Query`),e.grain!==t.grain&&n.push(`Grain`),r(e.primaryKey,t.primaryKey)||n.push(`Key`),r(e.inputs,t.inputs)||n.push(`What it reads`),r(e.columns.map(e=>[e.name,e.type,e.description]),t.columns.map(e=>[e.name,e.type,e.description]))||n.push(`Columns`);let i=e=>e.checks.filter(e=>!e.implied).map(e=>[e.kind,e.columns,e.toTable,e.toColumn,e.values,String(e.minRows),String(e.maxRows),e.severity]);return r(i(e),i(t))||n.push(`Checks`),e.description!==t.description&&n.push(`Description`),(e.kind!==t.kind||e.layer!==t.layer)&&n.push(`Kind`),n}function jB(e){let t=IB(e.pipelines),n=(0,NB.useId)(),[r,i]=(0,NB.useState)(()=>ym(Zx,e.pipeline)),[a,o]=(0,NB.useState)(),[s,c]=(0,NB.useState)(e.approver??``),[l,u]=(0,NB.useState)(``),[d,f]=(0,NB.useState)(),[p,m]=(0,NB.useState)(),[h,g]=(0,NB.useState)(!1),[_,v]=(0,NB.useState)(!1);(0,NB.useEffect)(()=>i(ym(Zx,e.pipeline)),[e.pipeline]),(0,NB.useEffect)(()=>{let e=!0;return GS(r).then(t=>e&&f(t)),()=>{e=!1}},[r]),(0,NB.useEffect)(()=>{if(!t||e.expectedVersion===0)return;let n=!0;return t.getPipeline({id:r.id}).then(({pipeline:e})=>n&&o(e),()=>void 0),()=>{n=!1}},[t,r.id,e.expectedVersion]);let y=r.datasets.findIndex(t=>t.name.toLowerCase()===e.dataset.toLowerCase()),b=r.datasets[y],x=a?.datasets.find(t=>t.kind!==Qx.SOURCE&&t.name.toLowerCase()===e.dataset.toLowerCase()),S=(0,NB.useMemo)(()=>b?AB(x,b):[],[x,b]),C=d!==void 0&&e.digest!==void 0&&d!==e.digest,w=!!t?.savePipeline;if(!b)return(0,MB.jsxs)(`p`,{className:`sf-surface-notice`,role:`note`,children:[`The proposal has no dataset called `,e.dataset,`.`]});let T=b.name,E=(t,n)=>{i(e=>ym(Zx,{...e,datasets:e.datasets.map((e,n)=>n===y?{...e,...t}:e)})),e.onContext?.({kind:`field.changed`,summary:n,subject:{pipeline:r.id,dataset:T}})},D=b.checks.filter(e=>!e.implied),O=async n=>{if(!n){v(!0),m({text:`Rejected. Nothing was saved.`}),e.onDecide?.({approved:!1,...l?{note:l}:{}});return}let i=s.trim();if(!i){m({text:`Say who is approving it.`,error:!0});return}let a=await GS(r);if(!w)v(!0),m({text:`Approved. This page cannot save pipelines, so the approval was passed on.`}),e.onDecide?.({approved:!0,digest:a,approvedBy:i,...l?{note:l}:{}});else{g(!0);try{let{pipeline:n}=await t.savePipeline({pipeline:r,expectedVersion:e.expectedVersion,approvedBy:i,approvalDigest:a,note:l});v(!0),m({text:`Saved as version ${n?.version}. Nothing has been built yet; run the pipeline to build it.`}),e.onDecide?.({approved:!0,version:n?.version,digest:a,approvedBy:i,...l?{note:l}:{}})}catch(e){m({text:aP(e),error:!0})}finally{g(!1)}}};return(0,MB.jsxs)(`section`,{className:[`sf-plan-review`,`sf-dataset-review`,e.className].filter(Boolean).join(` `),"aria-labelledby":`${n}-title`,children:[(0,MB.jsxs)(`header`,{children:[(0,MB.jsxs)(`p`,{className:`sf-plan-review-title`,id:`${n}-title`,children:[x?`Change`:`Add`,` `,T,` in `,r.name||r.id]}),(0,MB.jsx)(`p`,{className:`sf-plan-review-summary`,children:[b.description,b.kind===Qx.VIEW?`Built as a view`:`Built as a table`,b.layer?`${b.layer} layer`:void 0,`on ${r.sourceId}`].filter(Boolean).join(` · `)}),e.proposedBy&&(0,MB.jsxs)(`p`,{className:`sf-plan-review-by`,children:[`Proposed by `,e.proposedBy,`. Nothing is saved until you approve, and nothing is built until the pipeline runs.`]}),(0,MB.jsx)(`p`,{className:`sf-dataset-review-changes`,children:S.map(e=>(0,MB.jsx)(`span`,{className:`sf-schema-tag`,children:e===`New dataset`?e:`${e} changed`},e))})]}),(0,MB.jsxs)(`div`,{className:`sf-dataset-review-body`,children:[(0,MB.jsx)(`h4`,{className:`sf-dataset-review-heading`,children:`Query`}),(0,MB.jsx)(VL,{code:b.sql,language:`sql`}),x&&x.sql.trim()!==b.sql.trim()&&(0,MB.jsxs)(`details`,{className:`sf-plan-review-sql`,children:[(0,MB.jsx)(`summary`,{children:`The saved query`}),(0,MB.jsx)(VL,{code:x.sql,language:`sql`})]}),(0,MB.jsx)(`p`,{className:`sf-plan-review-detail`,children:b.inputs.length>0?`Reads ${b.inputs.join(`, `)}.`:`What it reads is worked out from the query when it is saved.`}),(0,MB.jsxs)(`label`,{className:`sf-dataset-review-field`,children:[(0,MB.jsx)(`span`,{children:`Grain: what one row is`}),(0,MB.jsx)(`input`,{className:`sf-input`,value:b.grain,disabled:_,onChange:e=>E({grain:e.target.value},`Changed the grain of ${T} to "${e.target.value}"`)})]}),(0,MB.jsx)(`p`,{className:`sf-plan-review-detail`,children:b.primaryKey.length>0?`Key: ${b.primaryKey.join(`, `)}. After every build it is checked that no two rows share it and that it is never empty.`:`No key, so nothing checks that rows do not repeat.`}),b.columns.length>0&&(0,MB.jsxs)(MB.Fragment,{children:[(0,MB.jsx)(`h4`,{className:`sf-dataset-review-heading`,children:`Columns`}),(0,MB.jsxs)(`table`,{className:`sf-dataset-review-columns`,children:[(0,MB.jsx)(`thead`,{children:(0,MB.jsxs)(`tr`,{children:[(0,MB.jsx)(`th`,{scope:`col`,children:`Column`}),(0,MB.jsx)(`th`,{scope:`col`,children:`Type`}),(0,MB.jsx)(`th`,{scope:`col`,children:`Description`})]})}),(0,MB.jsx)(`tbody`,{children:b.columns.map((e,t)=>(0,MB.jsxs)(`tr`,{children:[(0,MB.jsx)(`th`,{scope:`row`,children:e.name}),(0,MB.jsx)(`td`,{children:e.type}),(0,MB.jsx)(`td`,{children:(0,MB.jsx)(`input`,{className:`sf-input`,"aria-label":`Description of ${e.name}`,value:e.description,disabled:_,onChange:n=>E({columns:b.columns.map((e,r)=>r===t?{...e,description:n.target.value}:e)},`Described ${T}.${e.name}`)})})]},e.name))})]})]}),(0,MB.jsx)(`h4`,{className:`sf-dataset-review-heading`,children:`Checks after each build`}),D.length===0?(0,MB.jsx)(`p`,{className:`sf-plan-review-detail`,children:`No checks beyond the key.`}):(0,MB.jsx)(`ul`,{className:`sf-dataset-review-checks`,children:D.map(e=>{let t=KS(e),n=e.severity===rS.WARN;return(0,MB.jsxs)(`li`,{className:`sf-controls-host`,"data-controls":`corner`,children:[(0,MB.jsxs)(`span`,{className:`sf-dataset-review-check`,children:[(0,MB.jsx)(`code`,{children:t}),` `,kB(e)]}),(0,MB.jsxs)(`label`,{className:`sf-dataset-review-severity`,children:[(0,MB.jsx)(`input`,{type:`checkbox`,checked:!n,disabled:_,onChange:()=>E({checks:b.checks.map(t=>t===e?{...t,severity:n?rS.FAIL:rS.WARN}:t)},n?`${t} now stops what reads ${T}`:`${t} now only warns`)}),`Stops what reads it when it fails`]}),!_&&(0,MB.jsx)(fI,{label:`Check ${t}`,controls:pI(`the check ${t}`,{remove:()=>E({checks:b.checks.filter(t=>t!==e)},`Removed the check ${t} from ${T}`)})})]},t)})})]}),p&&(0,MB.jsx)(`p`,{className:`sf-plan-review-outcome`,role:p.error?`alert`:`status`,children:p.text}),!_&&(0,MB.jsxs)(`footer`,{className:`sf-plan-review-actions`,children:[(0,MB.jsxs)(`label`,{className:`sf-plan-review-note`,children:[`Approved by`,(0,MB.jsx)(`input`,{className:`sf-input`,value:s,onChange:e=>c(e.target.value),autoComplete:`name`})]}),(0,MB.jsxs)(`label`,{className:`sf-plan-review-note`,children:[`Note (optional)`,(0,MB.jsx)(`input`,{className:`sf-input`,value:l,onChange:e=>u(e.target.value)})]}),(0,MB.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:h,onClick:()=>void O(!0),children:w?`Approve and save`:`Approve`}),(0,MB.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:h,onClick:()=>void O(!1),children:`Reject`})]}),!_&&C&&(0,MB.jsx)(`p`,{className:`sf-plan-review-detail`,children:`You changed the proposal; what you approve is what is shown here.`})]})}var MB,NB,PB,FB=n((()=>{MB=WA(),zb(),rw(),vS(),NB=NM(),vI(),cP(),qL(),QB(),PB={[nS.UNIQUE]:`never repeats`,[nS.NOT_NULL]:`is never empty`,[nS.RELATIONSHIPS]:`is found in`,[nS.ACCEPTED_VALUES]:`is one of`,[nS.ROW_COUNT]:`row count`}}));function IB(e){let t=(0,GB.useContext)(KB);return NN(`Pipelines`,e??t)}function LB(e){let t=(0,GB.useContext)(KB),n=NN(`Pipelines`,e??t);if(!n)throw Error(`No Pipelines backend: wrap the component in <PipelinesProvider> or pass pipelines.`);return n}function RB(e,t){let n=new Map(t?.datasetRuns.map(e=>[e.name,e]));return{nodes:e.datasets.map(t=>{let r=n.get(t.name),i=!e.externalRuns||(r?r.rowsWritten>0n:!!t.rowsWritten);return{id:t.name,name:t.name,kind:JB[t.kind]??`table`,layer:t.layer||void 0,status:t.kind===Qx.SOURCE?void 0:qB[r?.state??t.state],rowsWritten:i?r?r.state===$x.COMPLETED&&t.kind!==Qx.VIEW?Number(r.rowsWritten):void 0:t.rowsWritten===void 0||t.kind===Qx.VIEW?void 0:Number(t.rowsWritten):void 0,expectationsFailed:r?.expectations.reduce((e,t)=>e+Number(t.failedRecords),0)||void 0,checksFailed:r?.checks.filter(e=>e.failedRecords>0n&&e.severity!==rS.WARN).length||void 0,checksWarned:r?.checks.filter(e=>e.failedRecords>0n&&e.severity===rS.WARN).length||void 0}}),edges:e.datasets.flatMap(e=>e.inputs.map(t=>({from:t,to:e.name})))}}function zB(e){return{id:e.id,state:qB[e.state],startTime:e.startTime,endTime:e.endTime||void 0,trigger:e.dryRun?`check only`:e.trigger||void 0,refreshKind:XB[e.refreshKind]??`default`,datasets:e.datasets,errorMessage:e.errorMessage||void 0}}function BB(e,t){let n=new Map(t?.datasetRuns.find(t=>t.name===e.name)?.checks.map(e=>[e.name,e]));return e.checks.map(e=>{let t=n.get(e.name);return{name:e.name,description:kB(e),severity:e.severity===rS.WARN?`warn`:`fail`,...t?{failedRecords:Number(t.failedRecords),summary:t.summary,canOpenFailing:!!t.failingRowsSql}:{},...e.implied?{fromKey:!0}:{}}})}function VB(e,t){return{kind:t,runId:e.id,state:ZB[e.state]??`running`,...e.dryRun?{dryRun:!0}:{},...t===`finished`?{built:e.datasetRuns.filter(e=>e.state===$x.COMPLETED).length,failed:e.datasetRuns.filter(e=>e.state===$x.FAILED).map(e=>e.name),failedChecks:e.datasetRuns.flatMap(e=>e.checks.filter(e=>e.failedRecords>0n&&e.severity!==rS.WARN).map(t=>`${e.name}.${t.name}`))}:{}}}function HB(e,t){return`SELECT * FROM (${e.sql}) AS d WHERE NOT COALESCE((${t}), FALSE)`}function UB(e){let{pipelineId:t,pollMs:n=1e3}=e,r=LB(e.pipelines),[i,a]=(0,GB.useState)(),[o,s]=(0,GB.useState)([]),[c,l]=(0,GB.useState)(),[u,d]=(0,GB.useState)(),[f,p]=(0,GB.useState)(),[m,h]=(0,GB.useState)(!1),[g,_]=(0,GB.useState)(``),v=(0,GB.useRef)(!0),y=(0,GB.useCallback)(async()=>{try{let[e,n]=await Promise.all([r.getPipeline({id:t}),r.listRuns({pipelineId:t,pageSize:20})]);if(!v.current)return;a(e.pipeline),s(n.runs),l(void 0)}catch(e){v.current&&l(aP(e))}},[r,t]);(0,GB.useEffect)(()=>(v.current=!0,a(void 0),s([]),d(void 0),p(void 0),y(),()=>{v.current=!1}),[y]);let b=o.find(e=>e.state===$x.RUNNING);(0,GB.useEffect)(()=>{if(!b)return;let e=setInterval(()=>void y(),n);return()=>clearInterval(e)},[b?.id,y,n]);let x=(0,GB.useRef)(void 0),{onRun:S,onContext:C}=e;(0,GB.useEffect)(()=>{let e=o.find(e=>e.id===x.current);if(!e||e.state===$x.RUNNING)return;x.current=void 0;let n=VB(e,`finished`);S?.(n);let r=n.failedChecks?.length?`; failed checks: ${n.failedChecks.join(`, `)}`:``;C?.({kind:`run.finished`,summary:`${e.id} ${n.state}: ${n.built} built${n.failed?.length?`, ${n.failed.join(`, `)} failed`:``}${r}.`,subject:{pipeline:t,...n}})},[o,S,C,t]);let w=async e=>{h(!1);try{let{run:n}=await r.startRun({pipelineId:t,trigger:`manual`,...e});if(n){p(n.id),_(e.dryRun?n.state===$x.FAILED?`The check found problems: ${n.errorMessage}`:`The check found no problems. Nothing was built.`:`Started ${n.id}.`);let r=e.dryRun?`Checked`:e.refreshKind===eS.FULL_REFRESH?`Started a full refresh of`:e.datasets?`Started rebuilding ${e.datasets.join(`, `)} and what uses it in`:`Started a run of`;e.dryRun||(x.current=n.id,S?.(VB(n,`started`))),C?.({kind:e.dryRun?`pipeline.checked`:`run.started`,summary:`${r} the pipeline ${t}${e.dryRun?n.state===$x.FAILED?`: problems found`:`: no problems`:``}.`,subject:{pipeline:t,runId:n.id,...e.datasets?{datasets:e.datasets}:{}}})}await y()}catch(e){_(aP(e))}};if(c)return(0,WB.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:c});if(!i?.summary)return(0,WB.jsx)(`p`,{className:`sf-object-muted`,children:`Loading…`});let T=o.find(e=>e.id===f)??o.find(e=>!e.dryRun),{nodes:E,edges:D}=RB(i,T),O=i.datasets.find(e=>e.name===u),k=O&&O.kind!==Qx.SOURCE,ee=T?.datasetRuns.find(e=>e.name===u),te=(ee?.expectations??[]).map(e=>({name:e.name,dataset:u??``,constraint:e.constraint,action:YB[e.action]??`warn`,passedRecords:Number(e.passedRecords),failedRecords:Number(e.failedRecords)})),A=i.summary.sourceId,ne=i.canBuild||!i.externalRuns;return(0,WB.jsxs)(`div`,{className:[`sf-pipeline-view`,e.className].filter(Boolean).join(` `),children:[(0,WB.jsxs)(`header`,{className:`sf-source-head`,children:[(0,WB.jsxs)(`div`,{children:[(0,WB.jsx)(`h3`,{className:`sf-object-title`,children:i.summary.name}),(0,WB.jsx)(`p`,{className:`sf-object-facts`,children:[i.summary.description,`${i.summary.datasetCount} datasets`,`Source ${A}`,i.recomputeOnly?`Each run rebuilds whole tables`:void 0].filter(Boolean).join(` · `)})]}),(0,WB.jsx)(`div`,{className:`sf-object-buttons`,children:ne?b?(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void r.cancelRun({pipelineId:t,runId:b.id}).then(()=>_(`Stopping after the table being built.`)),children:`Cancel run`}):(0,WB.jsxs)(WB.Fragment,{children:[(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,onClick:()=>void w({}),children:`Run`}),(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void w({dryRun:!0}),children:`Check only`}),e.fullRefresh!==!1&&(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>h(!0),children:`Full refresh…`})]}):(0,WB.jsx)(`p`,{className:`sf-object-facts`,children:`Built by another tool; its runs are reported here.`})})]}),m&&(0,WB.jsxs)(`div`,{className:`sf-pipeline-confirm`,role:`alertdialog`,"aria-label":`Confirm full refresh`,children:[(0,WB.jsx)(`p`,{children:`A full refresh deletes every table this pipeline built and builds them again. Queries against them will fail until it finishes.`}),(0,WB.jsxs)(`div`,{className:`sf-object-buttons`,children:[(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,onClick:()=>void w({refreshKind:eS.FULL_REFRESH,confirmFullRefresh:!0}),children:`Delete and rebuild`}),(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>h(!1),children:`Keep the tables`})]})]}),(0,WB.jsx)(`p`,{className:`sf-model-status`,role:`status`,children:g}),(0,WB.jsx)(oB,{nodes:E,edges:D,selected:u,onSelect:e=>{d(e.id),C?.({kind:`dataset.selected`,summary:`Looked at ${e.name} in ${i.summary?.name}.`,subject:{pipeline:t,dataset:e.name}})},label:`${i.summary.name} pipeline`}),O&&(0,WB.jsxs)(`section`,{className:`sf-pipeline-detail`,"aria-label":`Dataset ${O.name}`,children:[(0,WB.jsxs)(`header`,{className:`sf-source-head`,children:[(0,WB.jsxs)(`div`,{children:[(0,WB.jsx)(`h4`,{className:`sf-object-title`,children:O.name}),(0,WB.jsx)(`p`,{className:`sf-object-facts`,children:[O.description,O.inputs.length>0?`Reads ${O.inputs.join(`, `)}${O.inputsDeclared?``:` (worked out from the query)`}`:void 0,O.owner?`Owner ${O.owner}`:void 0,O.tags.length>0?O.tags.join(`, `):void 0,O.builtAt?`Built ${new Date(O.builtAt).toLocaleString()}`:void 0].filter(Boolean).join(` · `)||`A table this pipeline reads.`}),k&&(O.grain||O.primaryKey.length>0)&&(0,WB.jsx)(`p`,{className:`sf-object-facts`,children:[O.grain?`One row: ${O.grain}`:void 0,O.primaryKey.length>0?`Key ${O.primaryKey.join(`, `)}`:void 0].filter(Boolean).join(` · `)}),ee?.errorMessage&&(0,WB.jsx)(`p`,{className:`sf-search-error`,role:`note`,children:ee.errorMessage})]}),(0,WB.jsxs)(`div`,{className:`sf-object-buttons`,children:[e.onOpenTable&&(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onOpenTable?.(O.name,A),children:`Open table`}),k&&!b&&ne&&(0,WB.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void w({refreshKind:eS.REFRESH,datasets:[O.name]}),children:`Rebuild this and what uses it`})]})]}),k&&i.externalRuns&&O.sql&&(0,WB.jsx)(`p`,{className:`sf-explore-hint`,children:`The query as the other tool compiled it, shown read-only. That tool builds the dataset from its own definition, never from this text.`}),k&&O.sql&&(0,WB.jsx)(VL,{code:O.sql,language:`sql`,label:i.externalRuns?`Compiled query (read-only preview)`:void 0}),k&&O.columns.length>0&&(0,WB.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Columns of ${O.name}`,children:(0,WB.jsxs)(`table`,{children:[(0,WB.jsxs)(`caption`,{className:`sf-a2-visually-hidden`,children:[`Columns of `,O.name]}),(0,WB.jsx)(`thead`,{children:(0,WB.jsxs)(`tr`,{children:[(0,WB.jsx)(`th`,{scope:`col`,children:`Column`}),(0,WB.jsx)(`th`,{scope:`col`,children:`Type`}),(0,WB.jsx)(`th`,{scope:`col`,children:`Description`})]})}),(0,WB.jsx)(`tbody`,{children:O.columns.map(e=>(0,WB.jsxs)(`tr`,{children:[(0,WB.jsx)(`th`,{scope:`row`,children:e.name}),(0,WB.jsx)(`td`,{className:`sf-object-type`,children:e.type}),(0,WB.jsx)(`td`,{children:e.description})]},e.name))})]})}),k&&O.checks.length>0&&(0,WB.jsx)(uB,{checks:BB(O,T),onOpenFailing:e.onOpenSql?t=>{let n=T?.datasetRuns.find(e=>e.name===O.name)?.checks.find(e=>e.name===t.name)?.failingRowsSql;n&&e.onOpenSql?.(n,A)}:void 0}),k&&(te.length>0?(0,WB.jsx)(lB,{expectations:te,onOpenFailing:e.onOpenSql?t=>e.onOpenSql?.(HB(O,t.constraint),A):void 0}):O.expectations.length>0?(0,WB.jsxs)(`p`,{className:`sf-object-muted`,children:[O.expectations.length,` data quality `,O.expectations.length===1?`rule`:`rules`,`: `,O.expectations.map(e=>e.name).join(`, `),`. Run the pipeline to see results.`]}):(0,WB.jsx)(`p`,{className:`sf-object-muted`,children:`No data quality rules on this dataset.`}))]}),(0,WB.jsx)(cB,{runs:o.map(zB),selected:T?.id,onSelect:e=>p(e.id)})]})}var WB,GB,KB,qB,JB,YB,XB,ZB,QB=n((()=>{WB=WA(),vS(),zN(),GB=NM(),cP(),qL(),FB(),OB(),KB=(0,GB.createContext)(void 0),qB={[$x.UNSPECIFIED]:`idle`,[$x.QUEUED]:`starting`,[$x.RUNNING]:`running`,[$x.COMPLETED]:`completed`,[$x.FAILED]:`failed`,[$x.CANCELLED]:`cancelled`,[$x.SKIPPED]:`skipped`},JB={[Qx.SOURCE]:`source`,[Qx.TABLE]:`table`,[Qx.VIEW]:`view`,[Qx.STREAMING_TABLE]:`streamingTable`,[Qx.SINK]:`sink`},YB={[tS.DROP]:`drop`,[tS.FAIL]:`fail`},XB={[eS.REFRESH]:`refresh`,[eS.FULL_REFRESH]:`fullRefresh`},ZB={[$x.RUNNING]:`running`,[$x.COMPLETED]:`completed`,[$x.FAILED]:`failed`,[$x.CANCELLED]:`cancelled`}}));function $B(e){let t=[],n=e.columns.filter(e=>e.include);e.location.trim()||t.push(`Say where the files are.`),oV.test(e.rawTable)||t.push(`Name the table using letters, digits and underscores.`),e.targetTable&&!oV.test(e.targetTable)&&t.push(`The cleaned table's name uses letters, digits and underscores.`),e.targetTable&&e.targetTable.toLowerCase()===e.rawTable.toLowerCase()&&t.push(`The cleaned table needs a different name from the raw one.`),e.columns.length>0&&n.length===0&&t.push(`Keep at least one column.`);let r=n.map(e=>e.target.trim().toLowerCase());n.some(e=>!oV.test(e.target.trim()))?t.push(`Column names use letters, digits and underscores.`):new Set(r).size!==r.length&&t.push(`Two columns have the same name.`);let i=`{ name: ${JSON.stringify(e.rawTable)}, format: ${JSON.stringify(e.format)}, path: ${JSON.stringify(e.location.trim())} },`,a=n.map(e=>{let t=e.targetType?`CAST(${sV(e.source)} AS ${e.targetType})`:sV(e.source);return e.target.trim()===e.source&&!e.targetType?` ${t}`:` ${t} AS ${sV(e.target.trim())}`}).join(`,
|
|
45
|
+
`);return{table:i,dataset:e.targetTable?`{\n name: ${JSON.stringify(e.targetTable)},\n layer: "silver",\n sql: ${JSON.stringify(`SELECT\n${a}\nFROM ${sV(e.rawTable)}`)},\n},`:``,problems:t}}function eV({sourceId:e,value:t,onChange:n,className:r,...i}){let a=LB(i.pipelines),[o,s]=(0,nV.useState)({loading:!1}),c=$B(t),l=e=>n({...t,...e}),u=(e,n)=>l({columns:t.columns.map((t,r)=>r===e?{...t,...n}:t)}),d=async()=>{s({loading:!0});try{let n=await a.inspectFiles({sourceId:e,format:iV[t.format],location:t.location});l({columns:n.columns.map(e=>({source:e.name,sourceType:e.nativeType,include:!0,target:e.name.toLowerCase().replace(/\W+/g,`_`),targetType:``}))}),s({loading:!1,rows:n.rowCount===void 0?void 0:Number(n.rowCount)})}catch(e){s({loading:!1,error:aP(e)})}};return(0,tV.jsxs)(`div`,{className:[`sf-connect sf-ingest`,r].filter(Boolean).join(` `),children:[(0,tV.jsxs)(`fieldset`,{className:`sf-connect-group`,children:[(0,tV.jsx)(`legend`,{children:`1. Where the files are`}),(0,tV.jsxs)(`label`,{children:[(0,tV.jsx)(`span`,{children:`Format`}),(0,tV.jsxs)(`select`,{className:`sf-input`,value:t.format,onChange:e=>l({format:e.target.value,columns:[]}),children:[(0,tV.jsx)(`option`,{value:`parquet`,children:`Parquet`}),(0,tV.jsx)(`option`,{value:`delta`,children:`Delta Lake`}),(0,tV.jsx)(`option`,{value:`iceberg`,children:`Iceberg`}),(0,tV.jsx)(`option`,{value:`csv`,children:`CSV`}),(0,tV.jsx)(`option`,{value:`json`,children:`JSON`})]})]}),(0,tV.jsxs)(`label`,{className:`sf-connect-path`,children:[(0,tV.jsx)(`span`,{children:`Location`}),(0,tV.jsx)(`input`,{className:`sf-input`,value:t.location,placeholder:`s3://acme-lake/landing/orders/*.parquet`,onChange:e=>l({location:e.target.value,columns:[]})})]}),(0,tV.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:o.loading||!t.location.trim(),onClick:()=>void d(),children:o.loading?`Looking…`:`Look at the files`}),(0,tV.jsx)(`p`,{className:`sf-connect-note`,children:`The server reads only the schema. The location must be one this source is allowed to reach.`}),o.error&&(0,tV.jsx)(`p`,{className:`sf-search-error`,role:`alert`,children:o.error})]}),t.columns.length>0&&(0,tV.jsxs)(tV.Fragment,{children:[(0,tV.jsxs)(`fieldset`,{className:`sf-connect-group sf-connect-tables`,children:[(0,tV.jsx)(`legend`,{children:`2. Columns to keep`}),(0,tV.jsxs)(`p`,{className:`sf-connect-note`,role:`status`,children:[`Found `,t.columns.length,` columns`,o.rows===void 0?``:` and ${NA().format(o.rows)} rows`,`.`]}),(0,tV.jsx)(`div`,{className:`sf-object-table`,tabIndex:0,role:`region`,"aria-label":`Columns found`,children:(0,tV.jsxs)(`table`,{children:[(0,tV.jsx)(`thead`,{children:(0,tV.jsxs)(`tr`,{children:[(0,tV.jsx)(`th`,{scope:`col`,children:`Keep`}),(0,tV.jsx)(`th`,{scope:`col`,children:`In the files`}),(0,tV.jsx)(`th`,{scope:`col`,children:`Type found`}),(0,tV.jsx)(`th`,{scope:`col`,children:`Name in the table`}),(0,tV.jsx)(`th`,{scope:`col`,children:`Type in the table`})]})}),(0,tV.jsx)(`tbody`,{children:t.columns.map((e,t)=>(0,tV.jsxs)(`tr`,{children:[(0,tV.jsx)(`td`,{children:(0,tV.jsx)(`input`,{type:`checkbox`,checked:e.include,"aria-label":`Keep ${e.source}`,onChange:e=>u(t,{include:e.target.checked})})}),(0,tV.jsx)(`th`,{scope:`row`,children:e.source}),(0,tV.jsx)(`td`,{className:`sf-object-type`,children:e.sourceType.toLowerCase()}),(0,tV.jsx)(`td`,{children:(0,tV.jsx)(`input`,{className:`sf-input`,value:e.target,disabled:!e.include,"aria-label":`Name for ${e.source}`,onChange:e=>u(t,{target:e.target.value})})}),(0,tV.jsx)(`td`,{children:(0,tV.jsx)(`select`,{className:`sf-input`,value:e.targetType,disabled:!e.include,"aria-label":`Type for ${e.source}`,onChange:e=>u(t,{targetType:e.target.value}),children:aV.map(e=>(0,tV.jsx)(`option`,{value:e,children:e?e.toLowerCase():`as found`},e))})})]},e.source))})]})})]}),(0,tV.jsxs)(`fieldset`,{className:`sf-connect-group`,children:[(0,tV.jsx)(`legend`,{children:`3. What to call it`}),(0,tV.jsxs)(`label`,{children:[(0,tV.jsx)(`span`,{children:`Table for the files as they are`}),(0,tV.jsx)(`input`,{className:`sf-input`,value:t.rawTable,placeholder:`orders_landing`,onChange:e=>l({rawTable:e.target.value})})]}),(0,tV.jsxs)(`label`,{children:[(0,tV.jsx)(`span`,{children:`Cleaned table (optional)`}),(0,tV.jsx)(`input`,{className:`sf-input`,value:t.targetTable,placeholder:`orders_clean`,onChange:e=>l({targetTable:e.target.value})})]})]}),(0,tV.jsx)(`section`,{className:`sf-connect-plan`,"aria-label":`What to add`,"aria-live":`polite`,children:c.problems.length>0?(0,tV.jsx)(`ul`,{className:`sf-connect-problems`,children:c.problems.map(e=>(0,tV.jsx)(`li`,{children:e},e))}):(0,tV.jsxs)(tV.Fragment,{children:[(0,tV.jsx)(`p`,{className:`sf-object-label`,children:`Add this to the source's tables in surfaces.config.ts`}),(0,tV.jsx)(VL,{code:c.table,language:`ts`}),c.dataset&&(0,tV.jsxs)(tV.Fragment,{children:[(0,tV.jsx)(`p`,{className:`sf-object-label`,children:`Add this dataset to a pipeline to build the cleaned table`}),(0,tV.jsx)(VL,{code:c.dataset,language:`ts`})]}),(0,tV.jsx)(`p`,{className:`sf-connect-note`,children:`Nothing has been loaded. Restart the server after adding these, then run the pipeline.`})]})})]})]})}var tV,nV,rV,iV,aV,oV,sV,cV=n((()=>{tV=WA(),vS(),nV=NM(),cP(),qL(),QB(),HA(),rV={format:`parquet`,location:``,rawTable:``,targetTable:``,columns:[]},iV={parquet:Cx.PARQUET,delta:Cx.DELTA,iceberg:Cx.ICEBERG,csv:Cx.CSV,json:Cx.JSON},aV=[``,`VARCHAR`,`BIGINT`,`INTEGER`,`DOUBLE`,`DECIMAL(18,2)`,`BOOLEAN`,`DATE`,`TIMESTAMP`],oV=/^[A-Za-z_][A-Za-z0-9_]*$/,sV=e=>oV.test(e)?e:`"${e.replace(/"/g,`""`)}"`}));function lV(e,t){let[n,r]=(0,uV.useState)({loading:!0}),i=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t);return(0,uV.useEffect)(()=>{let n=new AbortController;r(e=>({...e,loading:!0,error:void 0}));let{sourceId:i,sql:a,column:o,aggregate:s,filters:c,notBefore:l,x:u,grain:d,points:f=60}=t,p=u!==void 0&&d!==void 0;return JS(e.execute({sourceId:i,notBefore:l,query:{baseSql:a,filters:c,aggregates:[{function:wF[s],column:o??``,alias:`value`,percentile:s===`percentile`?.9:0}],...p?{buckets:[{column:u,by:{case:`grain`,value:TF[d]}}],sorts:[{column:u,direction:ax.DESC}],page:{limit:f}}:{}}},{signal:n.signal})).then(e=>{if(n.signal.aborted)return;let t=e.table.getChild(`value`),i=e.table.schema.fields.find(e=>e.name===`value`),a=Array.from({length:e.table.numRows},(e,n)=>i?$N(t?.get(n),i.type):null);r({values:p?a.reverse():a,loading:!1,notes:uP(e.header.notices)})}).catch(e=>{n.signal.aborted||r({error:aP(e),loading:!1})}),()=>n.abort()},[e,i]),n}var uV,dV=n((()=>{rw(),mP(),uV=NM(),EF(),rP(),cP(),vS()}));function fV(e,t=hV,n=gV,r=_V){let i=e.filter(e=>e!==null);if(i.length===0)return[];let a=Math.min(...i),o=Math.max(...i),s=o-a||1,c=e.length>1?(t-r*2)/(e.length-1):0;return e.flatMap((e,t)=>e===null?[]:[{x:r+t*c,y:o===a?n/2:r+(1-(e-a)/s)*(n-r*2),value:e}])}function pV(e){let{sourceId:t,sql:n,x:r,grain:i,column:a,aggregate:o,label:s,format:c,currency:l,points:u=30,filters:d,notBefore:f}=e,p=lV(VN(e.dataSource),{sourceId:t,sql:n,column:a,aggregate:o,filters:d,notBefore:f,x:r,grain:i,points:u}),m=fV(p.values??[]),h=e=>Yz(e,c,l),g=m.at(-1),_=m.reduce((e,t)=>!e||t.value<e.value?t:e,void 0),v=m.reduce((e,t)=>!e||t.value>e.value?t:e,void 0),y=g&&_&&v&&m[0]?z(`sparkline.summary`,{label:s,now:h(g.value),first:h(m[0].value),low:h(_.value),high:h(v.value),count:m.length,grain:i}):e.emptyMessage?`${s}: ${e.emptyMessage}`:z(`sparkline.empty`,{label:s});return(0,mV.jsxs)(`span`,{className:[`sf-spark`,e.className].filter(Boolean).join(` `),"aria-busy":p.loading,children:[(0,mV.jsx)(`span`,{className:`sf-spark-label`,children:s}),p.error?(0,mV.jsx)(`span`,{className:`sf-metric-error`,role:`alert`,"data-error":p.error,children:e.errorMessage??p.error}):(0,mV.jsxs)(mV.Fragment,{children:[(0,mV.jsxs)(`svg`,{className:`sf-spark-line`,viewBox:`0 0 ${hV} ${gV}`,width:hV,height:gV,role:`img`,"aria-label":y,children:[m.length>1&&(0,mV.jsx)(`polyline`,{points:m.map(e=>`${e.x.toFixed(1)},${e.y.toFixed(1)}`).join(` `)}),_&&v&&_!==v&&(0,mV.jsxs)(mV.Fragment,{children:[(0,mV.jsx)(`circle`,{className:`sf-spark-extreme`,cx:_.x,cy:_.y,r:1.8}),(0,mV.jsx)(`circle`,{className:`sf-spark-extreme`,cx:v.x,cy:v.y,r:1.8})]}),g&&(0,mV.jsx)(`circle`,{className:`sf-spark-last`,cx:g.x,cy:g.y,r:2.4})]}),(0,mV.jsx)(`span`,{className:`sf-spark-value`,children:g?h(g.value):p.loading?z(`metric.loading`):e.emptyMessage??z(`metric.none`)})]}),(0,mV.jsx)(dP,{notes:p.notes})]})}var mV,hV,gV,_V,vV=n((()=>{mV=WA(),GN(),mP(),HA(),$z(),dV(),hV=120,gV=28,_V=3}));function yV(e,t){return t.find(t=>e<=t.to)??t.at(-1)}function bV(e){let{sourceId:t,sql:n,column:r,aggregate:i,label:a,target:o,format:s,currency:c,filters:l,notBefore:u}=e,d=[...e.ranges].sort((e,t)=>e.to-t.to).slice(0,5),f=lV(VN(e.dataSource),{sourceId:t,sql:n,column:r,aggregate:i,filters:l,notBefore:u}),p=f.values?.[0]??void 0,m=e=>Yz(e,s,c),h=Math.max(d.at(-1)?.to??0,o??0,p??0)||1,g=e=>`${Math.max(0,Math.min(100,e/h*100))}%`,_=p==null?void 0:yV(p,d),v=p==null?f.loading?z(`bullet.loading`,{label:a}):e.emptyMessage?`${a}: ${e.emptyMessage}`:z(`bullet.empty`,{label:a}):z(`bullet.reading`,{label:a,value:m(p),band:_?`, ${_.label.toLowerCase()}`:``,target:o===void 0?``:z(p>=o?`bullet.targetMet`:`bullet.targetNotMet`,{target:m(o)})});return(0,xV.jsxs)(`div`,{className:[`sf-bullet`,e.className].filter(Boolean).join(` `),"aria-busy":f.loading,children:[(0,xV.jsxs)(`div`,{className:`sf-bullet-head`,children:[(0,xV.jsx)(`span`,{className:`sf-bullet-label`,children:a}),f.error?(0,xV.jsx)(`span`,{className:`sf-metric-error`,role:`alert`,"data-error":f.error,children:e.errorMessage??f.error}):(0,xV.jsxs)(`span`,{className:`sf-bullet-value`,children:[p==null?f.loading?z(`metric.loading`):e.emptyMessage??z(`metric.none`):m(p),_&&(0,xV.jsxs)(`span`,{className:`sf-bullet-band`,children:[` `,_.label]})]})]}),(0,xV.jsxs)(`div`,{className:`sf-bullet-track`,role:`img`,"aria-label":v,children:[d.map((e,t)=>(0,xV.jsx)(`span`,{className:`sf-bullet-range`,"data-band":t+1,style:{left:g(d[t-1]?.to??0),right:`calc(100% - ${g(e.to)})`}},e.to)),p!=null&&(0,xV.jsx)(`span`,{className:`sf-bullet-bar`,style:{width:g(p)}}),o!==void 0&&(0,xV.jsx)(`span`,{className:`sf-bullet-target`,style:{left:g(o)}})]}),(0,xV.jsxs)(`div`,{className:`sf-bullet-scale`,"aria-hidden":`true`,children:[(0,xV.jsx)(`span`,{children:m(0)}),o!==void 0&&(0,xV.jsx)(`span`,{children:z(`bullet.target`,{target:m(o)})}),(0,xV.jsx)(`span`,{children:m(h)})]}),(0,xV.jsx)(dP,{notes:f.notes})]})}var xV,SV=n((()=>{xV=WA(),GN(),mP(),HA(),$z(),dV()}));function CV(e){let{title:t,summary:n,steps:r,proposedBy:i,onDecide:a}=e,o=(0,TV.useId)(),[s,c]=(0,TV.useState)(()=>new Set(r.filter(e=>e.required||e.risk!==`high`).map(e=>e.id))),[l,u]=(0,TV.useState)(``),[d,f]=(0,TV.useState)(e.decided),p=e.decided??d,m=r.filter(e=>p?p.stepIds.includes(e.id):s.has(e.id)),h=e=>{let t={approved:e,stepIds:e?m.map(e=>e.id):[],...l.trim()?{note:l.trim()}:{}};f(t),a(t)};return(0,wV.jsxs)(`section`,{className:[`sf-plan-review`,e.className].filter(Boolean).join(` `),"aria-labelledby":`${o}-title`,children:[(0,wV.jsxs)(`header`,{children:[(0,wV.jsx)(`p`,{className:`sf-plan-review-title`,id:`${o}-title`,children:t}),n&&(0,wV.jsx)(`p`,{className:`sf-plan-review-summary`,children:n}),i&&(0,wV.jsx)(`p`,{className:`sf-plan-review-by`,children:z(`plan.proposedBy`,{who:i})})]}),(0,wV.jsx)(`ol`,{className:`sf-plan-review-steps`,children:r.map((e,t)=>{let n=e.risk??`low`;return(0,wV.jsxs)(`li`,{className:`sf-plan-review-step`,"data-risk":n,children:[(0,wV.jsxs)(`label`,{className:`sf-plan-review-pick`,children:[(0,wV.jsx)(`input`,{type:`checkbox`,checked:p?p.stepIds.includes(e.id):s.has(e.id),disabled:p!==void 0||e.required,onChange:t=>c(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}),(0,wV.jsxs)(`span`,{className:`sf-plan-review-name`,children:[t+1,`. `,e.title]})]}),(0,wV.jsxs)(`span`,{className:`sf-plan-review-tags`,children:[e.kind&&(0,wV.jsx)(`span`,{className:`sf-schema-tag`,children:e.kind}),e.required&&(0,wV.jsx)(`span`,{className:`sf-schema-tag`,children:z(`plan.required`)}),n!==`low`&&(0,wV.jsxs)(`span`,{className:`sf-plan-review-risk`,"data-risk":n,children:[n===`high`?`▲ `:`● `,z(EV[n])]})]}),e.detail&&(0,wV.jsx)(`p`,{className:`sf-plan-review-detail`,children:e.detail}),e.affects&&(0,wV.jsx)(`p`,{className:`sf-plan-review-detail`,children:z(`plan.affects`,{what:e.affects})}),e.sql&&(0,wV.jsxs)(`details`,{className:`sf-plan-review-sql`,children:[(0,wV.jsx)(`summary`,{children:z(`plan.whatItWouldRun`)}),(0,wV.jsx)(VL,{code:e.sql,language:`sql`})]})]},e.id)})}),p?(0,wV.jsxs)(`p`,{className:`sf-plan-review-outcome`,role:`status`,children:[p.approved?z(`plan.approved`,{count:p.stepIds.length,total:r.length}):z(`plan.rejected`),p.note?z(`plan.decisionNote`,{note:p.note}):``]}):(0,wV.jsxs)(`footer`,{className:`sf-plan-review-actions`,children:[(0,wV.jsxs)(`label`,{className:`sf-plan-review-note`,children:[(0,wV.jsx)(`span`,{children:z(`plan.noteLabel`)}),(0,wV.jsx)(`input`,{className:`sf-input`,value:l,onChange:e=>u(e.target.value)})]}),(0,wV.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:m.length===0,onClick:()=>h(!0),children:z(m.length===1?`plan.approveOne`:`plan.approve`,{count:m.length})}),(0,wV.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>h(!1),children:z(`plan.reject`)})]})]})}var wV,TV,EV,DV=n((()=>{wV=WA(),TV=NM(),HA(),qL(),EV={low:`plan.riskLow`,medium:`plan.riskMedium`,high:`plan.riskHigh`}}));function OV(e){return e.flatMap(e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/[^A-Za-z0-9]+/g,`_`).toLowerCase(),n=MV.find(([,e])=>e.test(t));return n?[{column:e,category:n[0],basis:`name`}]:[]})}var kV,AV,jV,MV,NV=n((()=>{kV={name:`Person's name`,email:`Email address`,phone:`Phone number`,address:`Postal address`,government_id:`Government ID`,financial:`Card or account number`,date_of_birth:`Date of birth`,network:`IP or device ID`,location:`Precise location`,credential:`Password or key`,health:`Health information`,demographic:`Sensitive personal trait`},AV={keep:`Keep as is`,mask:`Mask (show part)`,hash:`Hash (keep joins working)`,generalize:`Generalise (coarser value)`,drop:`Leave out`},jV={name:`mask`,email:`hash`,phone:`mask`,address:`drop`,government_id:`drop`,financial:`drop`,date_of_birth:`generalize`,network:`hash`,location:`generalize`,credential:`drop`,health:`drop`,demographic:`drop`},MV=[[`credential`,/(^|_)(password|passwd|pwd|secret|api_?key|token|private_?key)(_|$)/],[`government_id`,/(^|_)(ssn|social_security|national_id|nin|passport|drivers?_licen[cs]e|tax_id|tin|ein|aadhaar)(_|$)/],[`financial`,/(^|_)(card_?(number|num|no)|pan|cvv|cvc|iban|swift|routing|account_?(number|num|no)|bank_account)(_|$)/],[`email`,/(^|_)e?_?mail(_address)?(_|$)/],[`phone`,/(^|_)(phone|mobile|cell|msisdn|fax|tel)(_?(number|num|no))?(_|$)/],[`date_of_birth`,/(^|_)(dob|birth_?(date|day)|date_of_birth|birthdate)(_|$)/],[`network`,/(^|_)(ip|ip_?address|ipv4|ipv6|mac_?address|device_id|imei|idfa|user_agent)(_|$)/],[`location`,/(^|_)(lat|latitude|lng|lon|longitude|geo|geohash|gps)(_|$)/],[`address`,/(^|_)(address|addr|street|postcode|post_code|postal_code|zip|zip_code)(_?\d)?(_|$)/],[`health`,/(^|_)(diagnosis|icd|medication|prescription|blood_type|allerg(y|ies)|medical|patient)(_|$)/],[`demographic`,/(^|_)(gender|sex|race|ethnicity|religion|nationality|marital_status|sexual_orientation|disability)(_|$)/],[`name`,/(^|_)((first|last|full|middle|given|family|sur|maiden)_?name|customer_name|contact_name|person_name|username)(_|$)/]]}));function PV(e){let{table:t,columns:n,purpose:r,onDecide:i}=e,a=(0,IV.useId)(),o=e=>e.action??(e.category?jV[e.category]:`keep`),[s,c]=(0,IV.useState)(()=>Object.fromEntries(n.map(e=>[e.name,o(e)]))),[l,u]=(0,IV.useState)(!1),[d,f]=(0,IV.useState)(e.decided),p=e.decided??d,m=e=>p?.columns.find(t=>t.name===e.name)?.action??s[e.name]??`keep`,h=n.filter(e=>e.category),g=h.filter(e=>m(e)===`keep`);return(0,FV.jsxs)(`section`,{className:[`sf-pii`,e.className].filter(Boolean).join(` `),"aria-labelledby":`${a}-title`,children:[(0,FV.jsxs)(`header`,{children:[(0,FV.jsxs)(`p`,{className:`sf-plan-review-title`,id:`${a}-title`,children:[`Personal data in `,t]}),(0,FV.jsxs)(`p`,{className:`sf-plan-review-summary`,children:[h.length===0?`No column was flagged.`:`${h.length} of ${n.length} columns may hold personal data.`,` `,r??``]}),(0,FV.jsx)(`p`,{className:`sf-plan-review-by`,children:`Flags are suggestions and can miss a column. Check the ones left unflagged too.`})]}),(0,FV.jsx)(`div`,{className:`sf-pii-scroll`,children:(0,FV.jsxs)(`table`,{className:`sf-pii-table`,children:[(0,FV.jsx)(`thead`,{children:(0,FV.jsxs)(`tr`,{children:[(0,FV.jsx)(`th`,{scope:`col`,children:`Column`}),(0,FV.jsx)(`th`,{scope:`col`,children:`May hold`}),(0,FV.jsx)(`th`,{scope:`col`,children:`Treatment`})]})}),(0,FV.jsx)(`tbody`,{children:n.map(e=>(0,FV.jsxs)(`tr`,{"data-flagged":e.category?``:void 0,children:[(0,FV.jsxs)(`th`,{scope:`row`,children:[(0,FV.jsx)(`span`,{className:`sf-pii-name`,children:e.name}),e.type&&(0,FV.jsxs)(`span`,{className:`sf-pii-type`,children:[` `,e.type]})]}),(0,FV.jsx)(`td`,{children:e.category?(0,FV.jsxs)(FV.Fragment,{children:[(0,FV.jsxs)(`span`,{className:`sf-pii-flag`,children:[`◆ `,kV[e.category]]}),(0,FV.jsx)(`span`,{className:`sf-pii-basis`,children:LV[e.basis??`name`]})]}):(0,FV.jsx)(`span`,{className:`sf-pii-basis`,children:`Not flagged`})}),(0,FV.jsx)(`td`,{children:(0,FV.jsx)(`select`,{className:`sf-input`,"aria-label":`Treatment for ${e.name}`,value:m(e),disabled:p!==void 0,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),children:RV.map(e=>(0,FV.jsx)(`option`,{value:e,children:AV[e]},e))})})]},e.name))})]})}),g.length>0&&(0,FV.jsxs)(`p`,{className:`sf-pii-warning`,role:`note`,children:[`▲ `,g.length===1?`${g[0].name} is flagged and will be kept as is.`:`${g.length} flagged columns will be kept as is: ${g.map(e=>e.name).join(`, `)}.`]}),p?(0,FV.jsxs)(`p`,{className:`sf-plan-review-outcome`,role:`status`,children:[`Decision recorded for `,p.columns.length,` columns.`]}):(0,FV.jsxs)(`footer`,{className:`sf-plan-review-actions`,children:[(0,FV.jsxs)(`label`,{className:`sf-pii-confirm`,children:[(0,FV.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,FV.jsx)(`span`,{children:`I have checked every column and may decide how this data is handled.`})]}),(0,FV.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:!l,onClick:()=>{let e={table:t,confirmed:!0,columns:n.map(e=>({name:e.name,...e.category?{category:e.category}:{},action:m(e)}))};f(e),i(e)},children:`Record decision`})]})]})}var FV,IV,LV,RV,zV=n((()=>{FV=WA(),IV=NM(),NV(),LV={name:`Guessed from the column name`,values:`Found by scanning values`,person:`Marked by a person`},RV=Object.keys(AV)}));function BV({label:e,steps:t,className:n}){let r=t.filter(e=>e.status===`done`||e.status===`skipped`).length;return(0,VV.jsxs)(`section`,{className:[`sf-flow`,n].filter(Boolean).join(` `),"aria-label":e,children:[(0,VV.jsxs)(`p`,{className:`sf-flow-head`,children:[(0,VV.jsx)(`span`,{className:`sf-flow-label`,children:e}),(0,VV.jsx)(`span`,{className:`sf-flow-count`,children:z(`flow.count`,{done:r,total:t.length})})]}),(0,VV.jsx)(`ol`,{className:`sf-flow-steps`,children:t.map(e=>(0,VV.jsxs)(`li`,{className:`sf-flow-step`,"data-status":e.status,"aria-current":e.status===`current`||e.status===`waiting`?`step`:void 0,children:[(0,VV.jsx)(`span`,{className:`sf-flow-mark`,"aria-hidden":`true`,children:HV[e.status].mark}),(0,VV.jsxs)(`span`,{className:`sf-flow-body`,children:[(0,VV.jsx)(`span`,{className:`sf-flow-title`,children:e.title}),(0,VV.jsx)(`span`,{className:`sf-flow-status`,children:z(HV[e.status].text)}),e.detail&&(0,VV.jsx)(`span`,{className:`sf-flow-detail`,children:e.detail})]})]},e.id))})]})}var VV,HV,UV=n((()=>{VV=WA(),HA(),HV={done:{mark:`✓`,text:`flow.done`},current:{mark:`●`,text:`flow.current`},waiting:{mark:`‖`,text:`flow.waiting`},pending:{mark:`○`,text:`flow.pending`},failed:{mark:`✕`,text:`flow.failed`},skipped:{mark:`–`,text:`flow.skipped`}}}));function WV({title:e,outcome:t,summary:n,ranAt:r,ranBy:i,approvedBy:a=[],sql:o,changes:s=[],undo:c,onUndo:l,now:u=Date.now,className:d}){let[f,p]=(0,KV.useState)(!1),m=c?.until?Date.parse(c.until)<=u():!1,h=qV[t];return(0,GV.jsxs)(`section`,{className:[`sf-receipt`,d].filter(Boolean).join(` `),"aria-label":e,"data-outcome":t,children:[(0,GV.jsxs)(`p`,{className:`sf-receipt-head`,children:[(0,GV.jsx)(`span`,{className:`sf-receipt-mark`,"aria-hidden":`true`,children:h.mark}),(0,GV.jsx)(`span`,{className:`sf-receipt-title`,children:e}),(0,GV.jsx)(`span`,{className:`sf-receipt-status`,children:z(h.text)})]}),n&&(0,GV.jsx)(`p`,{className:`sf-receipt-summary`,children:n}),(0,GV.jsxs)(`dl`,{className:`sf-receipt-facts`,children:[(r||i)&&(0,GV.jsxs)(GV.Fragment,{children:[(0,GV.jsx)(`dt`,{children:z(`receipt.ran`)}),(0,GV.jsx)(`dd`,{children:[JV(r),i?z(`receipt.by`,{who:i}):``].filter(Boolean).join(` `)})]}),(0,GV.jsx)(`dt`,{children:z(`receipt.approved`)}),(0,GV.jsx)(`dd`,{children:a.length===0?z(`receipt.noApproval`):(0,GV.jsx)(`ul`,{children:a.map((e,t)=>(0,GV.jsxs)(`li`,{children:[e.by,e.at?`, ${JV(e.at)}`:``,e.reason?`: “${e.reason}”`:``]},`${e.by}-${t}`))})})]}),s.length>0&&(0,GV.jsxs)(`table`,{className:`sf-receipt-changes`,children:[(0,GV.jsx)(`caption`,{className:`sf-a2-visually-hidden`,children:z(`receipt.whatChanged`)}),(0,GV.jsx)(`thead`,{children:(0,GV.jsxs)(`tr`,{children:[(0,GV.jsx)(`th`,{scope:`col`,children:z(`receipt.what`)}),(0,GV.jsx)(`th`,{scope:`col`,children:z(`receipt.before`)}),(0,GV.jsx)(`th`,{scope:`col`,children:z(`receipt.after`)})]})}),(0,GV.jsx)(`tbody`,{children:s.map(e=>(0,GV.jsxs)(`tr`,{children:[(0,GV.jsx)(`th`,{scope:`row`,children:e.label}),(0,GV.jsx)(`td`,{children:e.before??`–`}),(0,GV.jsx)(`td`,{children:e.after})]},e.label))})]}),o&&(0,GV.jsx)(VL,{code:o,language:`sql`,label:z(`receipt.whatRan`)}),c?m?(0,GV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:z(`receipt.undoClosed`,{time:JV(c.until)})}):(0,GV.jsxs)(`div`,{className:`sf-receipt-undo`,children:[c.description&&(0,GV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:c.description}),c.until&&(0,GV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:z(`receipt.undoUntil`,{time:JV(c.until)})}),f?(0,GV.jsx)(`p`,{className:`sf-receipt-undo-note`,role:`status`,children:z(`receipt.undoRequested`)}):l&&(0,GV.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{p(!0),l()},children:c.label})]}):(0,GV.jsx)(`p`,{className:`sf-receipt-undo-note`,children:z(`receipt.cannotUndo`)})]})}var GV,KV,qV,JV,YV=n((()=>{GV=WA(),KV=NM(),HA(),qL(),qV={done:{mark:`✓`,text:`receipt.done`},partial:{mark:`◐`,text:`receipt.partial`},failed:{mark:`✕`,text:`receipt.failed`}},JV=e=>{if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:PA({dateStyle:`medium`,timeStyle:`short`}).format(new Date(t))}}));function XV(e){let t=(0,tH.useContext)(nH);return e??t}function ZV(e,t){return ym(oS,{id:e,fields:t.map(e=>({name:e.name,label:e.label,type:rH[e.type],required:e.required??!1,options:e.options??[],min:e.min,max:e.max,maxLength:e.maxLength,pattern:e.pattern??``,help:e.help??``,visibleWhen:QS(e.visibleWhen)}))})}function QV({field:e,value:t,onChange:n,error:r,disabled:i}){let a=(0,tH.useId)(),o=[e.help?`${a}-help`:``,r?`${a}-error`:``].filter(Boolean).join(` `)||void 0,s={id:a,name:e.name,disabled:i,"aria-invalid":r?!0:void 0,"aria-describedby":o,required:e.required},c=t==null?``:String(t),l;switch(e.type){case`longtext`:l=(0,eH.jsx)(`textarea`,{...s,className:`sf-input sf-form-textarea`,value:c,maxLength:e.maxLength,placeholder:e.placeholder,onChange:e=>n(e.target.value)});break;case`number`:case`integer`:l=(0,eH.jsx)(`input`,{...s,className:`sf-input`,type:`number`,inputMode:e.type===`integer`?`numeric`:`decimal`,value:c,min:e.min,max:e.max,step:e.step??(e.type===`integer`?1:`any`),placeholder:e.placeholder,onChange:e=>n(e.target.value===``?``:Number(e.target.value))});break;case`boolean`:return(0,eH.jsxs)(`div`,{className:`sf-form-field sf-form-check`,children:[(0,eH.jsx)(`input`,{...s,required:void 0,type:`checkbox`,checked:t===!0,onChange:e=>n(e.target.checked)}),(0,eH.jsx)(`label`,{htmlFor:a,children:e.label}),e.help&&(0,eH.jsx)(`p`,{id:`${a}-help`,className:`sf-form-help`,children:e.help}),r&&(0,eH.jsx)(`p`,{id:`${a}-error`,className:`sf-form-error`,role:`alert`,children:r})]});case`date`:l=(0,eH.jsx)(`input`,{...s,className:`sf-input`,type:`date`,value:c,onChange:e=>n(e.target.value)});break;case`datetime`:l=(0,eH.jsx)(`input`,{...s,className:`sf-input`,type:`datetime-local`,value:c.replace(/Z$/,``).slice(0,16),onChange:e=>n(e.target.value?new Date(e.target.value).toISOString():``)});break;case`choice`:l=(e.options?.length??0)<=4?(0,eH.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`${a}-label`,"aria-describedby":o,className:`sf-form-choices`,children:(e.options??[]).map(t=>(0,eH.jsxs)(`label`,{className:`sf-form-choice`,children:[(0,eH.jsx)(`input`,{type:`radio`,name:`${a}-${e.name}`,value:t,checked:c===t,disabled:i,onChange:()=>n(t)}),t]},t))}):(0,eH.jsxs)(`select`,{...s,className:`sf-input`,value:c,onChange:e=>n(e.target.value),children:[(0,eH.jsx)(`option`,{value:``,children:z(`form.choose`)}),(e.options??[]).map(e=>(0,eH.jsx)(`option`,{value:e,children:e},e))]});break;default:l=(0,eH.jsx)(`input`,{...s,className:`sf-input`,type:`text`,value:c,maxLength:e.maxLength,placeholder:e.placeholder,onChange:e=>n(e.target.value)})}return(0,eH.jsxs)(`div`,{className:`sf-form-field`,children:[(0,eH.jsxs)(`label`,{id:`${a}-label`,htmlFor:e.type===`choice`&&(e.options?.length??0)<=4?void 0:a,className:`sf-form-label`,children:[e.label,e.required&&(0,eH.jsxs)(`span`,{className:`sf-form-required`,children:[` `,z(`form.required`)]})]}),l,e.help&&(0,eH.jsx)(`p`,{id:`${a}-help`,className:`sf-form-help`,children:e.help}),r&&(0,eH.jsx)(`p`,{id:`${a}-error`,className:`sf-form-error`,role:`alert`,children:r})]})}function $V(e){let{formId:t,fields:n,title:r,description:i,submitLabel:a=z(`form.submit`),onSubmit:o,children:s}=e,c=XV(e.forms),[l,u]=(0,tH.useState)({}),d=e.values??l,[f,p]=(0,tH.useState)({}),[m,h]=(0,tH.useState)({kind:`idle`}),g=(0,tH.useRef)(0),_=(0,tH.useId)(),v=t=>{e.values===void 0&&u(t),e.onValuesChange?.(t)},y=(e,t)=>{v({...d,[e]:t}),f[e]&&p(({[e]:t,...n})=>n)},b=ZV(t,n),x=n.filter((e,t)=>$S(b,b.fields[t],d));return(0,eH.jsxs)(`form`,{className:[`sf-form`,e.className].filter(Boolean).join(` `),onSubmit:async n=>{if(n.preventDefault(),m.kind===`sending`)return;let r=eC(b,d);if(r.errors.length>0)p(Object.fromEntries(r.errors.map(e=>[e.field,e.message]))),h({kind:`rejected`,text:r.errors.length===1?z(`form.needsAttentionOne`):z(`form.needsAttention`,{count:r.errors.length})});else if(p({}),!c)o?.({values:r.values}),h({kind:`saved`,text:z(`form.sent`)}),e.resetOnSubmit!==!1&&v({});else{h({kind:`sending`});try{let n=await c.submit({formId:t,values:r.values,idempotencyKey:`${t}-${Date.now()}-${g.current++}`});if(!n.submission){p(Object.fromEntries(n.fieldErrors.map(e=>[e.field,e.message]))),h({kind:`rejected`,text:n.message||z(`form.notSaved`)});return}h({kind:`saved`,text:n.message||z(`form.saved`)}),o?.({submissionId:n.submission.id,values:n.submission.values??r.values}),e.resetOnSubmit!==!1&&v({})}catch(e){h({kind:`rejected`,text:z(`form.couldNotSend`,{error:e instanceof Error?e.message:String(e)})})}}},noValidate:!0,"aria-labelledby":r?_:void 0,children:[r&&(0,eH.jsx)(`p`,{id:_,className:`sf-form-title`,children:r}),i&&(0,eH.jsx)(`p`,{className:`sf-form-help`,children:i}),s??x.map(e=>(0,eH.jsx)(QV,{field:e,value:d[e.name],error:f[e.name],disabled:m.kind===`sending`,onChange:t=>y(e.name,t)},e.name)),s&&Object.keys(f).length>0&&(0,eH.jsx)(`ul`,{className:`sf-form-error`,role:`alert`,children:Object.entries(f).map(([e,t])=>(0,eH.jsxs)(`li`,{children:[n.find(t=>t.name===e)?.label??e,`: `,t]},e))}),(0,eH.jsxs)(`div`,{className:`sf-form-actions`,children:[(0,eH.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:m.kind===`sending`,"aria-busy":m.kind===`sending`||void 0,children:m.kind===`sending`?z(`form.sending`):a}),(0,eH.jsx)(`p`,{className:m.kind===`rejected`?`sf-form-error`:`sf-form-status`,role:`status`,"aria-live":`polite`,children:m.kind===`saved`||m.kind===`rejected`?m.text:``})]}),(0,eH.jsx)(`p`,{className:`sf-form-help`,children:z(c?`form.connected`:`form.notConnected`)})]})}var eH,tH,nH,rH,iH=n((()=>{eH=WA(),zb(),rw(),vS(),tH=NM(),HA(),nH=(0,tH.createContext)(void 0),rH={text:cS.TEXT,longtext:cS.TEXT,number:cS.NUMBER,integer:cS.INTEGER,boolean:cS.BOOLEAN,date:cS.DATE,datetime:cS.DATETIME,choice:cS.CHOICE}}));function aH(e,t){if(t===0)return[];if(!e||e.length!==t||e.some(e=>typeof e!=`number`||!Number.isFinite(e)||e<=0))return xH(t);let n=e.map(e=>Math.max(bH,e)),r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)}function oH(e,t){let n=t?new Set(t):void 0,r=[...new Set((Array.isArray(e?.hidden)?e.hidden:[]).filter(e=>typeof e==`string`&&(!n||n.has(e))))],i=new Set(r),a=Array.isArray(e?.columns)?e.columns:[],o=new Map;a.forEach((t,n)=>{Array.isArray(t)&&t.forEach((t,r)=>o.set(String(t),e?.rowHeights?.[n]?.[r]??NaN))});let s=[],c=[];a.forEach((t,r)=>{if(!Array.isArray(t))return;let a=[];for(let e of t)typeof e!=`string`||i.has(e)||n&&!n.has(e)||(i.add(e),a.push(e));a.length!==0&&(s.push(a),c.push(e?.columnWidths?.[r]??NaN))});let l=s.length!==a.length;for(let e of t??[]){if(i.has(e))continue;i.add(e);let t=s[s.length-1];t&&t.length<4?t.push(e):s.length<4?(s.push([e]),l=!0):(t??(s[0]=[])).push(e)}s.length>4&&(s=[...s.slice(0,3),s.slice(3).flat()],l=!0);let u=new Set(s.flat()),d={};for(let[t,n]of Object.entries(e?.places&&typeof e.places==`object`?e.places:{}))r.includes(t)&&n&&Number.isInteger(n.column)&&Number.isInteger(n.row)&&n.column>=0&&n.row>=0&&(d[t]={column:n.column,row:n.row,...n.sole?{sole:!0}:{}});let f=[...new Set((Array.isArray(e?.collapsed)?e.collapsed:[]).filter(e=>typeof e==`string`&&u.has(e)))];for(let e of s)e.every(e=>f.includes(e))&&(f=f.filter(t=>t!==e[0]));return{columns:s,columnWidths:aH(l?void 0:c,s.length),rowHeights:s.map(e=>aH(e.map(e=>o.get(e)??NaN),e.length)),hidden:r,collapsed:f,places:d}}function sH(e,t){let n=dH(e,t);if(!n)return e;let r=e.collapsed.filter(e=>e!==t),i=e.columns[n.column].filter(e=>!r.includes(e)),a=i.filter(e=>e!==t).slice(0,Math.max(0,i.length-2));return oH({...e,collapsed:[...r,...a]})}function cH(e,t){return sH(oH(e),t)}function lH(e,t){let n=oH(e),r=dH(n,t);return!r||n.collapsed.includes(t)||n.columns[r.column].filter(e=>!n.collapsed.includes(e)).length<=1?n:oH({...n,collapsed:[...n.collapsed,t]})}function uH(e,t){let n=Math.max(bH,Math.min(.28,1/(e.length+1))),r=e.map(e=>e*(1-n));return r.splice(t,0,n),r}function dH(e,t){for(let n=0;n<e.columns.length;n++){let r=e.columns[n].indexOf(t);if(r!==-1)return{column:n,row:r}}}function fH(e,t,n,r){let i=oH(e),a=dH(i,t);if(!a||n<0||n>=i.columns.length||a.column===n&&(a.row===r||a.row===r-1)||a.column!==n&&i.columns[n].length>=4)return i;let o=i.columns.map(e=>[...e]);o[a.column].splice(a.row,1);let s=a.column===n&&a.row<r?r-1:r;return o[n].splice(Math.max(0,Math.min(s,o[n].length)),0,t),sH(oH({...i,columns:o,rowHeights:void 0}),t)}function pH(e,t,n){let r=oH(e),i=dH(r,t);if(!i)return r;let a=r.columns[i.column].length===1;if(!a&&r.columns.length>=4)return r;let o=r.columns.map(e=>[...e]);o[i.column].splice(i.row,1);let s=o.filter(e=>e.length>0),c=a&&i.column<n?n-1:n;s.splice(Math.max(0,Math.min(c,s.length)),0,[t]);let l=Math.max(0,Math.min(c,s.length-1));return sH(oH({columns:s,hidden:r.hidden,collapsed:r.collapsed,places:r.places,...a?{}:{columnWidths:uH(r.columnWidths,l)}}),t)}function mH(e,t,n){let r=oH(e),i=dH(r,t);if(!i)return r;if(n===`up`)return i.row===0?r:fH(r,t,i.column,i.row-1);if(n===`down`)return i.row>=r.columns[i.column].length-1?r:fH(r,t,i.column,i.row+2);let a=i.column+(n===`left`?-1:1);return a<0?r.columns[i.column].length>1?pH(r,t,0):r:a>=r.columns.length?r.columns[i.column].length>1?pH(r,t,r.columns.length):r:fH(r,t,a,r.columns[a].length)}function hH(e,t){let n=oH(e),r=dH(n,t);return!r||n.columns.flat().length<=1?n:oH({...n,columns:n.columns.map(e=>e.filter(e=>e!==t)),hidden:[...n.hidden,t],places:{...n.places,[t]:{...r,...n.columns[r.column].length===1?{sole:!0}:{}}},rowHeights:void 0})}function gH(e,t){let n=oH(e);if(!n.hidden.includes(t))return n;let r=n.hidden.filter(e=>e!==t),{[t]:i,...a}=n.places,o=n.columns.map(e=>[...e]),s={...n,hidden:r,places:a,rowHeights:void 0};if(i?.sole&&o.length<4){let e=Math.min(i.column,o.length);return o.splice(e,0,[t]),sH(oH({...s,columns:o,columnWidths:uH(n.columnWidths,e)}),t)}let c=i&&!i.sole?o[i.column]:void 0;if(c&&c.length<4)return c.splice(Math.min(i.row,c.length),0,t),sH(oH({...s,columns:o}),t);let l=o[o.length-1];return l&&l.length<2?(l.push(t),sH(oH({...s,columns:o}),t)):o.length<4?sH(oH({...s,columns:[...o,[t]],columnWidths:uH(n.columnWidths,o.length)}),t):((o.filter(e=>e.length<4).sort((e,t)=>e.length-t.length)[0]??l??(o[0]=[])).push(t),sH(oH({...s,columns:o}),t))}function _H(e,t,n){let r=e[t],i=e[t+1];if(r===void 0||i===void 0)return e;let a=Math.max(bH-r,Math.min(i-bH,n));if(r+i<.24)return e;let o=[...e];return o[t]=r+a,o[t+1]=i-a,o}function vH(e,t,n){let r=oH(e);return{...r,columnWidths:_H(r.columnWidths,t,n)}}function yH(e,t,n,r){let i=oH(e),a=i.rowHeights[t];return a?{...i,rowHeights:i.rowHeights.map((e,i)=>i===t?_H(a,n,r):e)}:i}var bH,xH,SH=n((()=>{bH=.12,xH=e=>Array.from({length:e},()=>1/e)}));function CH({icon:e,title:t}){return typeof e==`string`&&e in TH?(0,wH.jsx)(`svg`,{className:`sf-workspace-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,wH.jsx)(`path`,{d:TH[e]})}):e!=null&&typeof e!=`string`?(0,wH.jsx)(`span`,{className:`sf-workspace-icon`,children:e}):(0,wH.jsx)(`span`,{className:`sf-workspace-icon sf-workspace-icon-letter`,"aria-hidden":`true`,children:(t.trim()[0]??`?`).toUpperCase()})}var wH,TH,EH=n((()=>{wH=WA(),TH={surface:`M4 5h16v14H4z M4 10h16 M10 10v9`,agent:`M4 5h16v11H10l-5 4v-4H4z`,components:`M4 5h16v4H4z M4 12h11v3H4z M4 18h14v2H4z`,table:`M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14`,code:`M9 4c-2 0-3 1-3 3v2c0 1.2-.8 2.2-2 3 1.2.8 2 1.8 2 3v2c0 2 1 3 3 3 M15 4c2 0 3 1 3 3v2c0 1.2.8 2.2 2 3-1.2.8-2 1.8-2 3v2c0 2-1 3-3 3`,data:`M5 6c0-1.7 3.1-3 7-3s7 1.3 7 3-3.1 3-7 3-7-1.3-7-3z M5 6v12c0 1.7 3.1 3 7 3s7-1.3 7-3V6 M5 12c0 1.7 3.1 3 7 3s7-1.3 7-3`,history:`M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16z M12 8v4l3 2`,save:`M5 4h11l3 3v13H5z M8 4v5h7V4 M8 20v-6h8v6`,search:`M11 5a6 6 0 1 0 0 12 6 6 0 0 0 0-12z M20 20l-4.6-4.6`,map:`M6 4a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M18 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 16a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M8 6.4l8 1.2 M6.8 7.9l2.6 8.2 M16.8 9.6l-5.6 6.8`,chart:`M4 4v16h16 M8 16v-5 M12 16V8 M16 16v-9`,grid:`M4 4h7v7H4z M13 4h7v7h-7z M4 13h7v7H4z M13 13h7v7h-7z`,settings:`M4 7h9 M19 7h1 M4 17h3 M13 17h7 M16 5a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 15a2 2 0 1 0 0 4 2 2 0 0 0 0-4z`,note:`M7 3h8l4 4v14H7z M15 3v4h4 M10 12h6 M10 16h6`,folder:`M3 6h6l2 2h10v11H3z`,person:`M12 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M5.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5`,bell:`M18 16v-5a6 6 0 0 0-12 0v5l-2 2h16z M10 21a2 2 0 0 0 4 0`,people:`M9 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M2.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5 M16 4.4a3.5 3.5 0 0 1 0 6.2 M18 14c2 .9 3.5 3.2 3.5 6`},Object.keys(TH)}));function DH({label:e,panels:t,layout:n,defaultLayout:r,onLayoutChange:i,rail:a=`right`,railLabels:o,defaultRailLabels:s=!1,onRailLabelsChange:c,height:l=`32rem`,className:u}){let d=(0,kH.useContext)(AH),[f,p]=(0,kH.useState)(s),m=!d&&(o??f),h=(0,kH.useRef)(null),[g,_]=(0,kH.useState)(),v=e=>t=>{let n=h.current?.getBoundingClientRect(),r=t.currentTarget.closest(`.sf-workspace-rail`);if(!n||!r)return;let i=t.currentTarget.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.height>=a.width?r.getAttribute(`data-side`)===`left`?{top:i.top+i.height/2-n.top,left:a.right-n.left,transform:`translate(0, -50%)`}:{top:i.top+i.height/2-n.top,right:n.right-a.left,transform:`translate(0, -50%)`}:{top:i.bottom-n.top,left:i.left+i.width/2-n.left,transform:`translate(-50%, 0)`,marginTop:`var(--sf-space-1)`};_({text:e,style:o})},y=()=>_(void 0),b=e=>({onPointerEnter:v(e),onPointerLeave:y,onFocus:v(e),onBlur:y,onKeyDown:e=>{e.key===`Escape`&&y()}}),x=(0,kH.useMemo)(()=>t.map(e=>e.id),[t]),S=x.join(`\0`),[C,w]=(0,kH.useState)(r),T=(0,kH.useMemo)(()=>oH(n??C,x),[n,C,S]),E=(0,kH.useRef)(T);E.current=T;let D=(0,kH.useCallback)(e=>{JSON.stringify(e)!==JSON.stringify(E.current)&&(w(e),i?.(e))},[i]),O=(0,kH.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),k=(0,kH.useRef)(null),[ee,te]=(0,kH.useState)(),[A,ne]=(0,kH.useState)(),[re,ie]=(0,kH.useState)(``),ae=(0,kH.useRef)(void 0),oe=()=>{ae.current=void 0,te(void 0),ne(void 0)},se=e=>{let t=ae.current;t&&D(e.kind===`row`?fH(E.current,t,e.column,e.row):pH(E.current,t,e.at)),oe()},[ce,le]=(0,kH.useState)(),ue=(0,kH.useRef)(void 0),de=(e,t,n)=>{if(e.button!==0||e.target.closest(`button, select, input, a`))return;let r={x:e.clientX,y:e.clientY},i=!1,a=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),window.removeEventListener(`keydown`,l,!0);let t=ue.current;ue.current=void 0,le(void 0),i&&e&&t?se(t):oe()},o=e=>{if(!i){if(Math.hypot(e.clientX-r.x,e.clientY-r.y)<MH)return;i=!0,ae.current=t,te(t)}e.preventDefault(),le({x:e.clientX,y:e.clientY,title:n});let a=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-drop]`),o=a&&a.closest(`.sf-workspace`)===h.current?JSON.parse(a.dataset.drop??`null`):null;ue.current=o??void 0,ne(e=>o?jH(e,o)?e:o:void 0)},s=()=>a(!0),c=()=>a(!1),l=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(!1))};window.addEventListener(`pointermove`,o,{passive:!1}),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),window.addEventListener(`keydown`,l,!0)},fe=(e,t,n)=>(0,OH.jsx)(`div`,{className:t,"data-drop":JSON.stringify(e),"data-over":jH(A,e)||void 0,"aria-hidden":`true`,children:(0,OH.jsx)(`span`,{children:n})}),pe=(e,t,n,r)=>(0,OH.jsx)(`div`,{className:`sf-workspace-divider`,role:`separator`,tabIndex:0,"aria-orientation":e,"aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n*100),onPointerDown:t=>{let n=(e===`vertical`?k.current:t.currentTarget.closest(`.sf-workspace-column`))?.getBoundingClientRect(),i=e===`vertical`?n?.width:n?.height;if(!i)return;t.preventDefault(),t.currentTarget.setPointerCapture?.(t.pointerId);let a=e===`vertical`?t.clientX:t.clientY,o=t=>{let n=e===`vertical`?t.clientX:t.clientY;r((n-a)/i),a=n},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},onKeyDown:t=>{let n=e===`vertical`?`ArrowLeft`:`ArrowUp`,i=e===`vertical`?`ArrowRight`:`ArrowDown`;(t.key===n||t.key===i)&&(t.preventDefault(),r(t.key===i?NH:-.04))}}),me=(e,t,n)=>{let r=E.current,i=n===`hide`?hH(r,e):n===`new-left`?pH(r,e,0):n===`new-right`?pH(r,e,r.columns.length):mH(r,e,n),a=dH(i,e);ie(JSON.stringify(i)===JSON.stringify(r)?`${t} cannot move that way.`:a?`${t} is now in column ${a.column+1} of ${i.columns.length}, place ${a.row+1}.`:`${t} is hidden. The panels rail brings it back.`),D(i)},he=gP(),ge=(e,t)=>{let n=JSON.stringify(E.current),r=(r,i,a)=>({label:r,disabled:JSON.stringify(a)===n,onSelect:()=>me(e,t,i)}),i=E.current;return[r(`Move left`,`left`,mH(i,e,`left`)),r(`Move right`,`right`,mH(i,e,`right`)),r(`Move up`,`up`,mH(i,e,`up`)),r(`Move down`,`down`,mH(i,e,`down`)),{separator:!0},r(`To a new column on the left`,`new-left`,pH(i,e,0)),r(`To a new column on the right`,`new-right`,pH(i,e,i.columns.length)),{separator:!0},r(`Hide`,`hide`,hH(i,e))]},j=T.columns.length,_e=a&&(0,OH.jsxs)(`div`,{className:`sf-workspace-rail`,role:`toolbar`,"aria-label":`${e}: show or hide panels`,"aria-orientation":`vertical`,"data-side":a,"data-labels":m||void 0,children:[t.map(e=>{let t=!T.hidden.includes(e.id),n=t&&T.columns.flat().length<=1;return(0,OH.jsxs)(`button`,{type:`button`,className:`sf-workspace-rail-button`,"aria-pressed":t,"aria-label":e.title,"aria-disabled":n||void 0,...b(n?`${e.title}: the only panel showing`:t?`Hide ${e.title}`:`Show ${e.title}`),onClick:()=>{n||(_(void 0),ie(t?`${e.title} is hidden.`:`${e.title} is showing.`),D(t?hH(E.current,e.id):gH(E.current,e.id)))},children:[(0,OH.jsx)(CH,{icon:e.icon,title:e.title}),m&&(0,OH.jsx)(`span`,{className:`sf-workspace-rail-label`,children:e.shortTitle??e.title})]},e.id)}),!d&&(0,OH.jsx)(`button`,{type:`button`,className:`sf-workspace-rail-size`,"aria-pressed":m,"aria-label":`Show panel names on the rail`,...b(m?`Icons only`:`Show names`),onClick:()=>{_(void 0),p(!m),c?.(!m)},children:(0,OH.jsx)(`span`,{"aria-hidden":`true`,children:a===`left`===m?`«`:`»`})})]});return(0,OH.jsxs)(`div`,{ref:h,className:`sf-workspace sf-container${u?` ${u}`:``}`,role:`group`,"aria-label":e,style:{"--sf-workspace-height":typeof l==`number`?`${l}px`:l},children:[(0,OH.jsxs)(`div`,{className:`sf-workspace-frame`,children:[a===`left`&&_e,(0,OH.jsxs)(`div`,{className:`sf-workspace-grid`,ref:k,"data-dragging":ee?!0:void 0,children:[ee&&j<4&&fe({kind:`column`,at:0},`sf-workspace-drop-column`,`New column`),T.columns.map((e,t)=>(0,OH.jsxs)(`div`,{className:`sf-workspace-column-wrap`,style:{flexGrow:T.columnWidths[t],flexBasis:0},children:[(0,OH.jsx)(`div`,{className:`sf-workspace-column`,children:e.map((n,r)=>{let i=O.get(n);if(!i)return null;let a=T.collapsed.includes(n),o=T.collapsed.includes(e[r+1]??``),s=ee&&(ae.current===void 0||dH(T,ee)?.column===t||e.length<4);return(0,OH.jsxs)(`div`,{className:`sf-workspace-cell`,"data-folded":a||void 0,style:a?void 0:{flexGrow:T.rowHeights[t]?.[r]??1,flexBasis:0},children:[s&&fe({kind:`row`,column:t,row:r},`sf-workspace-drop-row`,`Drop here`),(0,OH.jsxs)(`section`,{className:`sf-workspace-panel`,"aria-label":i.title,"data-fill":i.fill||void 0,"data-dragging":ee===n||void 0,"data-folded":a||void 0,children:[(0,OH.jsxs)(`header`,{className:`sf-workspace-panel-head`,onPointerDown:e=>de(e,n,i.title),onContextMenu:e=>he.open(e,`Move ${i.title}`,ge(n,i.title)),children:[(0,OH.jsx)(`span`,{className:`sf-workspace-grip`,"aria-hidden":`true`,children:`⠿`}),e.length>1&&(0,OH.jsx)(`button`,{type:`button`,className:`sf-workspace-fold`,"aria-expanded":!a,"aria-label":a?`Open ${i.title}`:`Fold ${i.title} to its heading`,onClick:()=>{ie(a?`${i.title} is open.`:`${i.title} is folded.`),D(a?cH(E.current,n):lH(E.current,n))},children:(0,OH.jsx)(`span`,{"aria-hidden":`true`,children:a?`▸`:`▾`})}),(0,OH.jsx)(`h3`,{className:`sf-workspace-panel-title`,children:i.title}),(0,OH.jsx)(`button`,{type:`button`,className:`sf-workspace-menu-button`,"aria-label":`Move ${i.title}`,"aria-haspopup":`menu`,onClick:e=>he.open(e,`Move ${i.title}`,ge(n,i.title)),children:(0,OH.jsx)(`span`,{"aria-hidden":`true`,children:`⋯`})})]}),(0,OH.jsx)(`div`,{className:`sf-workspace-panel-body`,hidden:a,children:(0,OH.jsx)(AH.Provider,{value:!0,children:i.content})})]}),!ee&&r<e.length-1&&!a&&!o&&pe(`horizontal`,`Resize ${i.title} and the panel below it`,T.rowHeights[t]?.[r]??.5,e=>D(yH(E.current,t,r,e))),ee&&r===e.length-1&&s&&fe({kind:`row`,column:t,row:e.length},`sf-workspace-drop-row`,`Drop here`)]},n)})}),t<j-1&&(ee?j<4&&fe({kind:`column`,at:t+1},`sf-workspace-drop-column`,`New column`):pe(`vertical`,`Resize column ${t+1} and column ${t+2}`,T.columnWidths[t]??.5,e=>D(vH(E.current,t,e))))]},e.join(`\0`))),ee&&j<4&&fe({kind:`column`,at:j},`sf-workspace-drop-column`,`New column`)]}),a===`right`&&_e]}),g&&(0,OH.jsx)(`div`,{className:`sf-workspace-tip`,"aria-hidden":`true`,style:g.style,children:g.text}),ce&&(0,OH.jsx)(`div`,{className:`sf-workspace-ghost`,"aria-hidden":`true`,style:{left:ce.x,top:ce.y},children:ce.title}),he.element,(0,OH.jsx)(`p`,{className:`sf-workspace-said`,role:`status`,children:re})]})}var OH,kH,AH,jH,MH,NH,PH=n((()=>{OH=WA(),kH=NM(),yP(),EH(),SH(),AH=(0,kH.createContext)(!1),jH=(e,t)=>!!e&&e.kind===t.kind&&(e.kind===`row`?e.column===t.column&&e.row===t.row:e.at===t.at),MH=6,NH=.04}));function FH(e,t,n=240){if(!e)return;let r=Math.max(e.top,0),i=Math.max(e.left,0),a=Math.min(e.left+e.width,t.width)-i,o=Math.min(e.top+e.height,t.height)-r;if(a>=n&&o>=n)return{top:r,left:i,width:a,height:o}}function IH(e,t,n){if(!t.top&&!t.left)return e;let r=e??{top:0,left:0,width:n.width,height:n.height};return{top:r.top-t.top,left:r.left-t.left,width:r.width,height:r.height}}function LH(e){if(!e)return{top:0,left:0};let t=e.getBoundingClientRect(),n=getComputedStyle(e),r=t.top-Number.parseFloat(n.top),i=t.left-Number.parseFloat(n.left);return{top:Math.abs(r)>=.5?r:0,left:Math.abs(i)>=.5?i:0}}function RH(e){let[t,n]=(0,VH.useState)(()=>UH()?.matches??!1),[r,i]=(0,VH.useState)(!1);return(0,VH.useEffect)(()=>{let e=UH();if(!e)return;let t=()=>n(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,VH.useEffect)(()=>{let t=GH(e.current);if(!t||typeof ResizeObserver>`u`)return;let n=()=>{let e=t.getBoundingClientRect().width,n=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)||16;i(e>0&&e<WH*n)};n();let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[e]),t||r}function zH({label:e,groups:t,current:n,onSelect:r,pinned:i,defaultPinned:a=!0,onPinnedChange:o,header:s,footer:c,className:l}){let u=(0,VH.useId)(),[d,f]=(0,VH.useState)(a),p=(0,VH.useRef)(null),m=RH(p),h=(i??d)&&!m,[g,_]=(0,VH.useState)(!1),v=(0,VH.useRef)(null),y=(0,VH.useRef)(null),b=()=>document.getElementById(`${u}-open`),x=()=>{_(!1),requestAnimationFrame(()=>b()?.focus())},S=e=>{f(e),_(!1),o?.(e),e||requestAnimationFrame(()=>b()?.focus())},C=!h&&g,[w,T]=(0,VH.useState)(void 0);(0,VH.useLayoutEffect)(()=>{if(!C)return;let e=()=>{let e=GH(p.current)?.getBoundingClientRect(),t={width:window.innerWidth,height:window.innerHeight},n=IH(FH(e?{top:e.top,left:e.left,width:e.width,height:e.height}:void 0,t),LH(y.current),t);T(e=>e&&n&&e.top===n.top&&e.left===n.left&&e.width===n.width&&e.height===n.height?e:n)};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[C]);let E=!h&&w?{"--sf-sidenav-top":`${w.top}px`,"--sf-sidenav-left":`${w.left}px`,"--sf-sidenav-width":`${w.width}px`,"--sf-sidenav-height":`${w.height}px`}:void 0;(0,VH.useEffect)(()=>{C&&v.current?.querySelector(`.sf-sidenav-close`)?.focus()},[C]);let D=e=>{if(C){if(e.key===`Escape`)e.preventDefault(),x();else if(e.key===`Tab`&&v.current){let t=[...v.current.querySelectorAll(qH)],n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}}},O=e=>{r?.(e),C&&x()};return(0,BH.jsxs)(`div`,{ref:p,className:`sf-sidenav${l?` ${l}`:``}`,"data-pinned":h,"data-open":g||void 0,"data-narrow":m||void 0,style:E,onKeyDown:D,children:[!h&&(0,BH.jsx)(`button`,{id:`${u}-open`,type:`button`,className:`sf-sidenav-open`,"aria-expanded":g,"aria-controls":`${u}-panel`,"aria-label":`Show ${KH(e)}`,onClick:()=>_(!0),children:(0,BH.jsx)(dI,{icon:`menu`})}),(0,BH.jsxs)(`div`,{ref:y,className:`sf-sidenav-stage`,children:[C&&(0,BH.jsx)(`div`,{className:`sf-sidenav-backdrop`,"aria-hidden":`true`,onClick:x}),(0,BH.jsxs)(`div`,{id:`${u}-panel`,ref:v,className:`sf-sidenav-panel`,role:h?void 0:`dialog`,"aria-modal":C||void 0,"aria-label":h?void 0:KH(e),children:[(0,BH.jsxs)(`div`,{className:`sf-sidenav-top`,children:[(0,BH.jsx)(`div`,{className:`sf-sidenav-header`,children:s}),!m&&(0,BH.jsxs)(`button`,{type:`button`,className:`sf-sidenav-pin`,"aria-pressed":h,title:h?`Let the navigation fold away`:`Keep the navigation open`,onClick:()=>S(!h),children:[(0,BH.jsx)(dI,{icon:h?`fold`:`unfold`}),(0,BH.jsx)(`span`,{className:`sf-sidenav-pin-label`,children:h?`Fold away`:`Keep open`})]}),!h&&(0,BH.jsx)(`button`,{type:`button`,className:`sf-sidenav-close`,"aria-label":`Close ${KH(e)}`,onClick:x,children:(0,BH.jsx)(dI,{icon:`close`})})]}),(0,BH.jsx)(`nav`,{className:`sf-sidenav-nav`,"aria-label":e,children:t.map((e,t)=>(0,BH.jsxs)(`section`,{className:`sf-sidenav-group`,"aria-labelledby":e.label?`${u}-group-${t}`:void 0,children:[e.label&&(0,BH.jsx)(`h2`,{id:`${u}-group-${t}`,className:`sf-sidenav-group-label`,children:e.label}),(0,BH.jsx)(`ul`,{children:e.items.map(e=>(0,BH.jsx)(`li`,{children:e.href?(0,BH.jsx)(`a`,{href:e.href,"aria-current":e.id===n?`page`:void 0,onClick:()=>O(e.id),children:e.label}):(0,BH.jsx)(`button`,{type:`button`,"aria-current":e.id===n?`page`:void 0,onClick:()=>O(e.id),children:e.label})},e.id))})]},e.label??t))}),c&&(0,BH.jsx)(`div`,{className:`sf-sidenav-footer`,children:c})]})]})]})}var BH,VH,HH,UH,WH,GH,KH,qH,JH=n((()=>{BH=WA(),VH=NM(),vI(),HH=`(max-width: 40rem)`,UH=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(HH):void 0,WH=40,GH=e=>e?.closest(`.sf-container`)??void 0,KH=e=>/\bnavigation\s*$/i.test(e)?e.trim():`${e.trim()} navigation`,qH=`a[href], button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`})),YH=n((()=>{WA(),NM()})),XH=n((()=>{WA(),NM()}));function ZH(e){let t=e.toLowerCase().replace(/\.(gz|zst)$/,``);if(t.endsWith(`.parquet`))return`parquet`;if(t.endsWith(`.csv`)||t.endsWith(`.tsv`))return`csv`;if(t.endsWith(`.json`)||t.endsWith(`.ndjson`)||t.endsWith(`.jsonl`))return`json`}function QH(e){if(e===void 0||!Number.isFinite(e))return``;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${r===0||n>=100?Math.round(n):n.toFixed(1)} ${t[r]}`}function $H(e,t,n=t,r=200){let i=e.listFiles?.bind(e);if(i)return{id:t,label:n,origin:`source`,async list(e,n){let a=await i({sourceId:t,path:e,pageSize:r,pageToken:n??``});return{items:a.entries.map(e=>({name:e.name,path:e.path,kind:e.kind===Px.FOLDER?`folder`:`file`,...e.sizeBytes===void 0?{}:{size:Number(e.sizeBytes)},...e.modifiedAt?{modified:e.modifiedAt}:{},...iU[e.format]?{format:iU[e.format]}:{},...e.table?{table:e.table}:{}})),...a.nextPageToken?{next:a.nextPageToken}:{},...a.truncated?{truncated:!0}:{}}}}}function eU(e,t,n){let r=Math.max(0,Number.parseInt(t??`0`,10)||0),i=r+n;return{items:e.slice(r,i),...i<e.length?{next:String(i)}:{}}}function tU(e,t=200){let n=e=>e.webkitRelativePath||e.name,r=e.filter(e=>!n(e).split(`/`).some(e=>e.startsWith(`.`))),i=n(r[0]??e[0]??new File([],`folder`)).split(`/`)[0]??`folder`;return{id:`local:${i}`,label:i,origin:`local`,async list(e,i){let a=e?`${e}/`:``,o=new Map,s=[];for(let e of r){let t=n(e);if(!t.startsWith(a))continue;let r=t.slice(a.length),i=r.indexOf(`/`);if(i>=0){let e=r.slice(0,i);o.has(e)||o.set(e,{name:e,path:`${a}${e}`,kind:`folder`})}else{let n=ZH(e.name);s.push({name:e.name,path:t,kind:`file`,size:e.size,modified:new Date(e.lastModified).toISOString(),...n?{format:n}:{},file:e})}}return eU(aU([...o.values(),...s]),i,t)}}}function nU(e,t=200){let n=e,r=new Map,i=async e=>{let t=n;for(let n of e.split(`/`).slice(1).filter(Boolean))t=await t.getDirectoryHandle(n);return t};return{id:`local:${n.name}`,label:n.name,origin:`local`,async list(e,a){let o=e||n.name,s=a?r.get(o):void 0;if(!s){let e=[];for await(let t of(await i(o)).values())if(!t.name.startsWith(`.`)){if(t.kind===`directory`)e.push({name:t.name,path:`${o}/${t.name}`,kind:`folder`});else{let n=await t.getFile(),r=ZH(t.name);e.push({name:t.name,path:`${o}/${t.name}`,kind:`file`,size:n.size,modified:new Date(n.lastModified).toISOString(),...r?{format:r}:{},file:n})}}s=aU(e),r.set(o,s)}return eU(s,a,t)}}}async function rU(){let e=window.showDirectoryPicker;if(e)try{return nU(await e({mode:`read`}))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;throw e}}var iU,aU,oU,sU,cU=n((()=>{vS(),iU={[Cx.PARQUET]:`parquet`,[Cx.CSV]:`csv`,[Cx.JSON]:`json`,[Cx.DELTA]:`delta`,[Cx.ICEBERG]:`iceberg`},aU=e=>[...e].sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name,void 0,{numeric:!0}):e.kind===`folder`?-1:1),oU=()=>typeof window<`u`&&typeof window.showDirectoryPicker==`function`,sU=(e,t)=>({sourceId:e.id,kind:`file`,table:``,path:t.path})}));function lU(e){let t=VN(e.dataSource),n=RM(),r=dM[n?.theme.density??`comfortable`].rowHeight-4,i=e.height??420,a=gP(),o=(0,dU.useMemo)(()=>e.sourceId?$H(t,e.sourceId,e.sourceLabel??e.sourceId):void 0,[t,e.sourceId,e.sourceLabel]),[s,c]=(0,dU.useState)([]),l=(0,dU.useMemo)(()=>[...o?[o]:[],...e.places??[],...s],[o,e.places,s]),[u,d]=(0,dU.useState)({}),[f,p]=(0,dU.useState)(new Set),[m,h]=(0,dU.useState)(0),[g,_]=(0,dU.useState)(new Set),v=(0,dU.useRef)(0),[y,b]=(0,dU.useState)(``),[x,S]=(0,dU.useState)(0),C=(0,dU.useRef)(null),w=(0,dU.useRef)(null),T=(0,dU.useCallback)((e,t,n)=>{let r=fU(e,t);d(e=>n?e:{...e,[r]:`loading`}),e.list(t,n).then(e=>d(t=>{let i=t[r],a=n&&i&&i!==`loading`&&!(`error`in i)?i.items:[];return{...t,[r]:{...e,items:[...a,...e.items]}}})).catch(e=>d(t=>({...t,[r]:{error:e instanceof Error?e.message.replace(/^\[[a-z_]+\]\s*/i,``):String(e)}})))},[]);(0,dU.useEffect)(()=>{for(let e of l){let t=fU(e,``);u[t]===void 0&&(T(e,``),p(e=>new Set(e).add(t)))}},[l,u,T]);let E=(0,dU.useMemo)(()=>{let e=[],t=(n,r,i)=>{let a=u[fU(n,r)];if(a===void 0||a===`loading`)return void e.push({id:`${fU(n,r)}\u0000loading`,kind:`note`,level:i,label:`Loading…`,place:n,path:r});if(`error`in a)return void e.push({id:`${fU(n,r)}\u0000error`,kind:`note`,level:i,label:a.error,place:n,path:r,error:!/no storage to list/i.test(a.error)});a.items.length===0&&e.push({id:`${fU(n,r)}\u0000empty`,kind:`note`,level:i,label:`Nothing here.`,place:n,path:r});for(let r of a.items){let a=fU(n,r.path);e.push({id:a,kind:r.kind,level:i,label:r.name,place:n,path:r.path,item:r,meta:r.kind===`file`?[QH(r.size),pU(r.modified)].filter(Boolean).join(` · `):void 0,tag:r.table?`table ${r.table}`:r.format}),r.kind===`folder`&&f.has(a)&&t(n,r.path,i+1)}a.next?e.push({id:`${fU(n,r)}\u0000more`,kind:`more`,level:i,label:`Show more`,place:n,path:r}):a.truncated&&e.push({id:`${fU(n,r)}\u0000cut`,kind:`note`,level:i,label:`This folder is too large to list whole; the rest is not shown.`,place:n,path:r})};for(let n of l){let r=fU(n,``);e.push({id:r,kind:`place`,level:1,label:n.label,place:n,path:``,tag:n.origin===`local`?`this computer`:`storage`}),f.has(r)&&t(n,``,2)}return e},[l,u,f]),D=e=>{if(e.kind===`more`){let t=u[fU(e.place,e.path)];t&&t!==`loading`&&!(`error`in t)&&t.next&&T(e.place,e.path,t.next);return}if(e.kind!==`place`&&e.kind!==`folder`)return;let t=new Set(f);t.has(e.id)?t.delete(e.id):(t.add(e.id),(u[e.id]===void 0||typeof u[e.id]==`object`&&`error`in u[e.id])&&T(e.place,e.path)),p(t)},O=e=>{let t=E.filter(e=>g.has(e.id)&&e.item);return t.length>0&&g.has(e.id)?t:e.item?[e]:[]},k=e=>e.map(e=>sU(e.place,e.item)),ee=t=>{let n=O(t);n.length!==0&&e.onAttach&&(e.onAttach(k(n),n.map(e=>e.item)),b(`${n.length===1?n[0].label:`${n.length} items`} added.`),e.onContext?.({kind:`files.attached`,summary:`Attached ${n.length===1?n[0].path:`${n.length} files and folders`}.`,subject:{files:n.map(e=>({place:e.place.id,path:e.path,kind:e.kind}))}}))},te=(t,n)=>{let r=E[t];if(!r?.item)return;let i=new Set(n===`range`?[]:g);if(n===`range`){let[e,n]=[Math.min(v.current,t),Math.max(v.current,t)];for(let t=e;t<=n;t++)E[t]?.item&&i.add(E[t].id)}else i.has(r.id)?i.delete(r.id):i.add(r.id),v.current=t;_(i),h(t),b(i.size>0?`${i.size} selected. Shift+Enter ${e.onAttach?`adds them`:`does nothing here`}; Escape clears.`:``)},A=t=>{t.kind===`file`&&t.item?(e.onOpen?.(t.item,t.place),e.onContext?.({kind:`file.opened`,summary:`Opened ${t.path}${t.place.origin===`local`?` (on their own computer)`:``}.`,subject:{place:t.place.id,path:t.path,format:t.item.format??``,table:t.item.table??``}})):D(t)},ne=t=>{let n=O(t).length;return[...t.kind===`folder`?[{label:f.has(t.id)?`Close folder`:`Open folder`,onSelect:()=>D(t),hint:`Enter`}]:[],...t.kind===`file`&&e.onOpen?[{label:`Open`,onSelect:()=>A(t),hint:`Enter`}]:[],...e.onAttach?[{label:n>1?`${e.attachLabel??`Add to chat`}: ${n} items`:e.attachLabel??`Add to chat`,onSelect:()=>ee(t),hint:`Shift+Enter`}]:[],{label:g.has(t.id)?`Remove from selection`:`Select`,onSelect:()=>te(E.indexOf(t),`toggle`),hint:`Space`},{separator:!0},{label:`Copy path`,hint:`Ctrl+C`,onSelect:()=>void hP(t.path).then(e=>b(e?`Path copied.`:`The path could not be copied.`))}]},re=e=>{let t=Math.max(0,Math.min(E.length-1,e));h(t);let n=C.current;n&&(t*r<n.scrollTop?n.scrollTop=t*r:(t+1)*r>n.scrollTop+n.clientHeight&&(n.scrollTop=(t+1)*r-n.clientHeight))},ie=e=>{let t=E[m];if(!t)return;let n=t.kind===`place`||t.kind===`folder`;switch(e.key){case`ArrowDown`:re(m+1);break;case`ArrowUp`:re(m-1);break;case`Home`:re(0);break;case`End`:re(E.length-1);break;case`ArrowRight`:n&&!f.has(t.id)?D(t):n&&re(m+1);break;case`ArrowLeft`:if(n&&f.has(t.id))D(t);else for(let n=m-1;n>=0;n--)if(E[n].level<t.level)return void(e.preventDefault(),re(n));break;case`Enter`:e.shiftKey?ee(t):A(t);break;case` `:te(m,`toggle`);break;case`Escape`:if(g.size===0)return;_(new Set),b(``);break;case`c`:if(!(e.ctrlKey||e.metaKey)||!t.item)return;hP(t.path).then(e=>b(e?`Path copied.`:`The path could not be copied.`));break;default:return}e.preventDefault()},ae=t=>{c(e=>[...e.filter(e=>e.id!==t.id),t]),d(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!e.startsWith(`${t.id}\u0000`)))),e.onPlaceAdded?.(t),b(`Opened ${t.label}. It is read by this browser; nothing is uploaded.`),e.onContext?.({kind:`folder.opened`,summary:`Opened the folder ${t.label} from their own computer. Only its file names are listed; nothing was uploaded.`,subject:{place:t.id}})},oe=async()=>{if(!oU())return w.current?.click();try{let e=await rU();e&&ae(e)}catch(e){b(e instanceof Error?e.message:`The folder could not be opened.`)}},se=e=>{let t=[...e.target.files??[]];e.target.value=``,t.length>0&&ae(tU(t))},ce=e=>t=>{let n=O(e);n.length!==0&&(tI(t.dataTransfer,k(n),n.map(e=>e.path).join(`, `)),t.dataTransfer.effectAllowed=`copy`)},le=Math.max(0,Math.floor(x/r)-4),ue=Math.min(E.length,le+Math.ceil(i/r)+8),de=[];for(let t=le;t<ue;t++){let n=E[t],i=n.kind===`place`||n.kind===`folder`,o=f.has(n.id);de.push((0,uU.jsxs)(`div`,{id:`sf-files-${t}`,className:`sf-schema-row sf-browser-row sf-files-row`,"data-kind":n.kind,"data-active":t===m||void 0,"data-error":n.error||void 0,"data-picked":g.has(n.id)||void 0,style:{top:t*r,height:r,paddingInlineStart:`calc(var(--sf-space-2) + ${n.level-1} * var(--sf-space-4))`},role:`treeitem`,"aria-level":n.level,"aria-expanded":i?o:void 0,"aria-selected":g.size>0?g.has(n.id):t===m,draggable:n.item!==void 0,onDragStart:n.item?ce(n):void 0,onClick:r=>{if(r.ctrlKey||r.metaKey)return te(t,`toggle`);if(r.shiftKey)return te(t,`range`);g.size>0&&(_(new Set),b(``)),h(t),v.current=t,D(n),n.item&&e.onSelect?.(n.item,n.place)},onDoubleClick:()=>n.kind===`file`&&A(n),onContextMenu:n.item?e=>{h(t),a.open(e,`${n.label} actions`,ne(n))}:void 0,children:[(0,uU.jsx)(`span`,{className:`sf-schema-caret`,"aria-hidden":`true`,"data-open":i&&o||void 0,children:i?`▸`:``}),(0,uU.jsx)(`span`,{className:`sf-files-icon`,"data-kind":n.kind,"aria-hidden":`true`}),(0,uU.jsx)(`span`,{className:`sf-schema-name`,children:n.label}),n.meta&&(0,uU.jsx)(`span`,{className:`sf-schema-meta`,children:n.meta}),n.tag&&(0,uU.jsx)(`span`,{className:`sf-schema-tag`,children:n.tag}),n.kind===`file`&&n.item&&e.renderActions&&(0,uU.jsx)(`span`,{className:`sf-schema-actions`,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:e.renderActions(n.item,n.place)})]},n.id))}let fe=l.length===0;return(0,uU.jsxs)(`div`,{className:[`sf-schema sf-files`,e.className].filter(Boolean).join(` `),style:{height:i},children:[e.local&&(0,uU.jsxs)(`div`,{className:`sf-files-bar`,children:[(0,uU.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>void oe(),children:`Open a folder on this computer`}),(0,uU.jsx)(`input`,{ref:w,type:`file`,hidden:!0,multiple:!0,onChange:se,webkitdirectory:``,"aria-hidden":`true`,tabIndex:-1})]}),(0,uU.jsxs)(`div`,{ref:C,className:`sf-schema-list`,role:`tree`,"aria-label":e.label??`Folders and files`,"aria-activedescendant":E.length>0?`sf-files-${m}`:void 0,"aria-multiselectable":`true`,"aria-keyshortcuts":`Shift+F10 Space Shift+Enter Control+C`,tabIndex:0,onKeyDown:ie,onContextMenu:e=>{let t=E[m];e.target===e.currentTarget&&t?.item&&a.open(e,`${t.label} actions`,ne(t))},onScroll:e=>S(e.currentTarget.scrollTop),children:[(0,uU.jsx)(`div`,{style:{height:E.length*r,position:`relative`},children:de}),fe&&(0,uU.jsxs)(`p`,{className:`sf-schema-empty`,children:[e.sourceId&&!o?`This backend cannot list a source's storage.`:`No place to list.`,e.local?` Open a folder on this computer to browse it here.`:``]})]}),(0,uU.jsx)(`p`,{className:`sf-schema-note`,role:`status`,children:y}),a.element]})}var uU,dU,fU,pU,mU=n((()=>{uU=WA(),jM(),dU=NM(),GN(),yP(),rI(),GM(),cU(),fU=(e,t)=>`${e.id}\u0000${t}`,pU=e=>e?new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}):``}));function hU({sourceId:e,sql:t,filters:n,onChange:r,columns:i,onContext:a,className:o,...s}){let c=VN(s.dataSource),[l,u]=(0,_U.useState)([]),[d,f]=(0,_U.useState)();(0,_U.useEffect)(()=>{let n=new AbortController;return f(void 0),JS(c.execute({sourceId:e,query:{baseSql:t,page:{limit:1}}},{signal:n.signal})).then(e=>!n.signal.aborted&&u(e.table.schema.fields)).catch(e=>!n.signal.aborted&&(u([]),f(aP(e)))),()=>n.abort()},[c,e,t]);let p=(0,_U.useCallback)(async n=>{let r=await JS(c.execute({sourceId:e,query:{baseSql:t,groupBy:[n],aggregates:[{function:ux.COUNT,alias:`sf_count`}],sorts:[{column:`sf_count`,direction:ax.DESC}],page:{limit:50}}})),i=r.table.getChildAt(0),a=r.table.schema.fields[0]?.type;return Array.from({length:r.table.numRows},(e,t)=>i?.get(t)).filter(e=>e!=null).map(e=>a?XN(e,a).text:String(e))},[c,e,t]),m=(0,_U.useMemo)(()=>i?.length?l.filter(e=>i.includes(e.name)):l,[l,i]),{fixed:h,relative:g}=(0,_U.useMemo)(()=>UC(n),[n]),[_,v]=(0,_U.useMemo)(()=>{try{return[LC(h),void 0]}catch(e){return[[],e instanceof Error?e.message:`The filters could not be read.`]}},[h]),y=e=>{r(e),a?.({kind:`filter.changed`,summary:e.length===0?`Cleared every filter.`:`Filters are now: ${e.map(YC).join(`; `)}.`,subject:{filters:e}})};return(0,gU.jsxs)(`div`,{className:[`sf-query-filters`,o].filter(Boolean).join(` `),children:[(0,gU.jsx)(CI,{fields:m,filters:_,onChange:e=>y(WC(VC(e),g)),loadValues:p,relative:g,onRelativeChange:e=>y(WC(h,e))}),(d??v)&&(0,gU.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:d??v})]})}var gU,_U,vU=n((()=>{gU=WA(),rw(),vS(),_U=NM(),GN(),rP(),cP(),jI()}));function yU(e,t){if(!e||typeof e!=`object`)return;let n=Object.fromEntries(Object.entries(e.measures??{}).filter(([e])=>t.includes(e)).map(([e,t])=>[e,{...t?.type&&LU.includes(t.type)?{type:t.type}:{},...t?.axis===`right`?{axis:`right`}:{}}]).filter(([,e])=>Object.keys(e).length>0)),r={...e.type&&LU.includes(e.type)?{type:e.type}:{},...e.swap?{swap:!0}:{},...Object.keys(n).length>0?{measures:n}:{}};return Object.keys(r).length>0?r:void 0}function bU(e,t,n){let r={...e.chart?.measures??{},[t]:{...e.chart?.measures?.[t]??{},...n}};return{...e,chart:yU({...e.chart,measures:r},e.values)}}function xU(e,t){return{...e,chart:yU({...e.chart,...t},e.values)}}function SU(e,t=[]){let n=new Set(t),r=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^(\d)/,`n$1`).slice(0,40)||`field`,i=r;for(let e=2;n.has(i);e++)i=`${r}_${e}`;return i}function CU(e,t=`the columns`){let n=[],r=()=>n.map(e=>e.id);for(let i of e){let{name:e,type:a}=i;if(!(P.isList(a)||P.isStruct(a)||P.isMap(a)||P.isBinary(a))){if(P.isTimestamp(a)||P.isDate(a))n.push({id:SU(e,r()),kind:`attribute`,label:`${UU(e)} (month)`,column:e,grain:`month`,by:t});else if(YN(a)&&!VU.test(e)){let i=HU.test(e);n.push({id:SU(e,r()),kind:`metric`,label:i?UU(e):`Average ${UU(e).toLowerCase()}`,column:e,aggregate:i?`sum`:`avg`,format:BU.test(e)?`currency`:i?`compact`:`number`,by:t})}else n.push({id:SU(e,r()),kind:`attribute`,label:UU(e),column:e,by:t}),VU.test(e)&&n.push({id:SU(`${e}_count`,r()),kind:`metric`,label:`Distinct ${UU(e).toLowerCase()}`,column:e,aggregate:`count_distinct`,format:`compact`,by:t})}}return n.push({id:SU(`rows`,r()),kind:`metric`,label:`Rows`,aggregate:`count`,format:`compact`,by:t}),n}function wU(e,t=`suggested from the columns`){let n=[],r=()=>[...e,...n].map(e=>e.id),i=t=>[...e,...n].some(e=>e.kind===`derived`&&e.expression?.replace(/\s+/g,``)===t.replace(/\s+/g,``)),a=(e,a,o,s)=>{i(a)||n.push({id:SU(e,r()),kind:`derived`,label:e,expression:a,format:o,description:s,by:t})},o=e.filter(e=>e.kind===`metric`&&e.aggregate===`sum`),s=e.find(e=>e.kind===`metric`&&e.aggregate===`count`&&!e.column);if(s)for(let e of o.slice(0,3))a(`${e.label} per row`,`${e.id} / ${s.id}`,e.format===`currency`?`currency`:`number`,`${e.label} divided by the number of rows.`);let c=o.find(e=>/(revenue|sales|amount|price|total)/i.test(e.column??``)),l=o.find(e=>/cost/i.test(e.column??``));c&&l&&c!==l&&a(`Margin`,`(${c.id} - ${l.id}) / ${c.id}`,`percent`,`What is left of ${c.label.toLowerCase()} after ${l.label.toLowerCase()}, as a share.`);let u=o.filter(e=>e.format===`currency`),d=u.find(e=>/(refund|discount|fee|tax|return)/i.test(e.column??``)),f=u.find(e=>e!==d&&/(revenue|sales|amount|total|price)/i.test(e.column??``));return d&&f&&a(`${d.label} share of ${f.label.toLowerCase()}`,`${d.id} / ${f.id}`,`percent`,`${d.label} divided by ${f.label.toLowerCase()}.`),n}function TU(e,t,n){if(!zU.test(e.id))return`Its name in calculations must start with a letter and use only letters, digits and underscores.`;if(t.filter(t=>t.id===e.id).length>1)return`Another field is already called "${e.id}".`;if(!e.label.trim())return`It needs a label.`;let r=e=>!n||e!==void 0&&n.includes(e);return e.kind===`attribute`?e.column?r(e.column)?void 0:`There is no column "${e.column}" in this query.`:`An attribute needs a column.`:e.kind===`metric`?e.aggregate?e.column?r(e.column)?void 0:`There is no column "${e.column}" in this query.`:e.aggregate===`count`?void 0:`Only a count can do without a column.`:`A metric needs a way to summarise: sum, average, count.`:SS(e.expression??``,t.filter(e=>e.kind===`metric`).map(e=>e.id))}function EU(e){let t=new Map(e.fields.map(e=>[e.id,e.kind])),n=[...new Set(e.rows)].filter(e=>t.get(e)===`attribute`).slice(0,3),r=e.split&&t.get(e.split)===`attribute`&&!n.includes(e.split)?e.split:void 0,i=[...new Set(e.values)].filter(e=>t.get(e)===`metric`||t.get(e)===`derived`).slice(0,6),a=yU(e.chart,i);return{fields:e.fields,rows:n,...r?{split:r}:{},values:i,filters:e.filters,...e.view?{view:e.view}:{},...a?{chart:a}:{}}}function DU(e,t,n,r){let i=e.fields.find(e=>e.id===t);if(!i)return e;let a=n??(i.kind===`attribute`?`rows`:`values`),o=e=>{let n=e.filter(e=>e!==t),i=r===void 0?n.length:Math.max(0,Math.min(n.length,r));return[...n.slice(0,i),t,...n.slice(i)]};return EU(a===`split`?{...e,rows:e.rows.filter(e=>e!==t),split:t}:a===`rows`?{...e,rows:o(e.rows),...e.split===t?{split:void 0}:{}}:{...e,values:o(e.values)})}function OU(e,t,n){let r=e.rows.includes(t)?`rows`:e.values.includes(t)?`values`:void 0;if(!r)return e;let i=e[r].indexOf(t)+n;return i<0||i>=e[r].length?e:DU(e,t,r,i)}function kU(e,t,n){return n===`split`?{...e,split:void 0}:{...e,[n]:e[n].filter(e=>e!==t)}}function AU(e,t,n){let r=e.fields.some(e=>e.id===t),i=n?r?e.fields.map(e=>e.id===t?n:e):[...e.fields,n]:e.fields.filter(e=>e.id!==t),a=n&&n.id!==t?n.id:void 0;a&&(i=i.map(e=>e.kind===`derived`&&e.expression?{...e,expression:e.expression.replace(RegExp(`\\b${t}\\b`,`g`),a)}:e));let o=e=>e===t?a:e,s=e=>e.map(e=>e===t?n?a??t:void 0:e).filter(e=>e!==void 0);return EU({...e,fields:i,rows:s(e.rows),values:s(e.values),split:e.split===t?n?o(t)??t:void 0:e.split})}function jU(e){let t=[];for(let n of e.values){let r=WU(e,n);if(r?.kind===`metric`&&t.push(n),r?.kind===`derived`)try{t.push(...xS(bS(r.expression??``)))}catch{}}return[...new Set(t)].map(t=>WU(e,t)).filter(e=>e?.kind===`metric`)}function MU(e,t,n=200,r){let i=[...e.rows,...e.split?[e.split]:[]].map(t=>WU(e,t)).filter(e=>e?.kind===`attribute`),a=i.filter(e=>!e.grain),o=i.filter(e=>e.grain),s=e.values.map(t=>WU(e,t)).filter(e=>e?.kind===`derived`),c=i[0];return{baseSql:t,filters:LC(e.filters,r),groupBy:a.map(e=>e.column),buckets:o.map(e=>({column:e.column,alias:e.id,by:{case:`grain`,value:TF[e.grain]}})),aggregates:jU(e).map(e=>({function:wF[e.aggregate??`count`],column:e.column??``,alias:e.id})),derived:s.map(e=>({alias:e.id,expression:e.expression??``})),sorts:c?.grain?[{column:c.id,direction:ax.ASC}]:e.values[0]?[{column:e.values[0],direction:ax.DESC}]:[],page:{limit:n}}}function NU(e){let t=PU({...e,chart:{...e.chart,swap:!1}});if(!t)return`There is no chart to turn yet.`;if(!HP(t.type,t.y))return`Only bars on one scale can be turned on their side.`}function PU(e){let t=e.rows.map(t=>WU(e,t)).filter(e=>e?.kind===`attribute`),n=e.values.map(t=>WU(e,t)).filter(e=>!!e&&e.kind!==`attribute`),r=t[0];if(!r||n.length===0)return;let i=(e.split?WU(e,e.split):t[1])??void 0,a=e.chart?.type??(r.grain?`line`:`bar`),o=new Set(n.filter(t=>e.chart?.measures?.[t.id]?.axis===`right`).map(e=>e.id));o.size===n.length&&o.clear();let s=t=>{let n=e.chart?.measures?.[t.id]?.type;return{...n&&n!==a?{type:n}:{},...o.has(t.id)?{axis:`right`}:{}}},c=n.map(t=>{if(t.kind===`metric`)return{...t.column?{column:t.column}:{},aggregate:t.aggregate??`count`,label:t.label,...s(t)};let n=[];try{n=xS(bS(t.expression??``))}catch{}let r=Object.fromEntries(n.map(t=>WU(e,t)).filter(e=>e?.kind===`metric`).map(e=>[e.id,{...e.column?{column:e.column}:{},aggregate:e.aggregate??`count`}]));return{expression:t.expression??``,terms:r,label:t.label,...s(t)}}),l=n.filter(e=>!o.has(e.id)),u=n.filter(e=>o.has(e.id)),d=!!e.chart?.swap&&HP(a,c);return{type:a,x:r.column,...r.grain?{xGrain:r.grain}:{},...i?.column&&!i.grain&&(e.split||n.length===1)?{splitBy:i.column}:{},y:c,xTitle:r.label,...u.length>0?{yTitle:l.map(e=>e.label).join(`, `),yRightTitle:u.map(e=>e.label).join(`, `)}:{},...l[0]?.format&&l.every(e=>e.format===l[0].format)?{yFormat:l[0].format}:{},...d?{horizontal:!0}:{}}}function FU(e,t){if(e==null)return`–`;let n=Number(e);return Number.isFinite(n)?t===`percent`?NA({style:`percent`,maximumFractionDigits:1}).format(n):t===`currency`?NA({style:`currency`,currency:`USD`,notation:Math.abs(n)>=1e5?`compact`:`standard`,maximumFractionDigits:Math.abs(n)>=1e5?1:2}).format(n):t===`compact`?NA({notation:`compact`,maximumFractionDigits:1}).format(n):NA({maximumFractionDigits:2}).format(n):String(e)}function IU(e){let t=e.filter(e=>e.kind===`attribute`),n=t.find(e=>!e.grain&&!VU.test(e.column??``))??t.find(e=>e.grain),r=e.filter(e=>e.kind===`metric`),i=r.find(e=>e.column&&e.aggregate!==`count_distinct`)??r.find(e=>!e.column)??r[0];return n&&i?{rows:[n.id],values:[i.id]}:{rows:[],values:[]}}var LU,RU,zU,BU,VU,HU,UU,WU,GU,KU=n((()=>{rw(),vS(),_p(),EF(),cF(),rP(),HA(),LU=[`bar`,`line`,`area`],RU={fields:[],rows:[],values:[],filters:[]},zU=/^[A-Za-z][A-Za-z0-9_]*$/,BU=/(amount|price|cost|revenue|sales|total|refund|paid|charge|fee|balance|margin|spend|value)/i,VU=/(^id$|_id$|_key$|_no$|_number$|^sku$|code$)/i,HU=/(amount|cost|revenue|sales|total|refund|paid|charge|fee|spend|income|profit|count|qty|quantity|units|orders|items|hours|minutes|seconds|days|kwh|mwh|energy|volume|clicks|views|visits|sessions|downloads|bytes|calls|tickets|^n_|^num_)/i,UU=e=>e.replace(/_/g,` `).replace(/^\w/,e=>e.toUpperCase()),WU=(e,t)=>e.fields.find(e=>e.id===t),GU=e=>e.kind===`attribute`&&!e.grain?e.column:e.id}));function qU(e){let t=t=>t||iW(e),n=[];for(let r of e.dimensions){let i=r.kind===gS.TIME;n.push({id:r.name,kind:`attribute`,label:r.label||r.name,column:r.column,...i?{grain:r.grain||`month`}:{},...r.description?{description:r.description}:{},by:t(r.definedBy),model:e.name})}for(let r of e.measures){let i=_C(r.aggregate);i&&n.push({id:r.name,kind:`metric`,label:r.label||r.name,...r.column?{column:r.column}:{},aggregate:i,...rW(r.format)?{format:rW(r.format)}:{},...r.description?{description:r.description}:{},by:t(r.definedBy),model:e.name})}for(let r of e.metrics)n.push({id:r.name,kind:`derived`,label:r.label||r.name,expression:r.expression,...rW(r.format)?{format:rW(r.format)}:{},...r.description?{description:r.description}:{},by:t(r.definedBy),model:e.name});return n}function JU(e,t){let n=qU(e),r=new Set(n.flatMap(e=>e.column?[e.column]:[])),i=new Set(n.map(e=>e.id)),a=n.some(e=>e.kind===`metric`&&e.aggregate===`count`&&!e.column),o=CU(t.filter(e=>!r.has(e.name))).filter(e=>!i.has(e.id)&&!(a&&e.aggregate===`count`&&!e.column));return[...n,...o]}function YU(e,t){return e.id===t.id&&e.kind===t.kind&&(e.column??``)===(t.column??``)&&(e.aggregate??``)===(t.aggregate??``)&&(e.grain??``)===(t.grain??``)&&(e.expression??``).replace(/\s+/g,``)===(t.expression??``).replace(/\s+/g,``)&&(e.format??``)===(t.format??``)&&e.label===t.label&&(e.description??``)===(t.description??``)}function XU(e,t){let n=qU(t),r=new Map(n.map(e=>[e.id,e])),i=e.flatMap(e=>{let n=r.get(e.id);return n?e.model===t.name||YU(e,n)?[n]:[e]:e.model===t.name?[]:[e]}),a=new Set(i.map(e=>e.id));return[...n.filter(e=>!a.has(e.id)),...i]}function ZU(e,t,n,r){let i=ym(pS,e),a=[t];if(t.kind===`derived`){let e=[];try{e=xS(bS(t.expression??``))}catch{e=[]}for(let t of e){let e=n.find(e=>e.id===t&&e.kind===`metric`);e&&!i.measures.some(e=>e.name===t)&&a.unshift(e)}}let o=i;for(let n of a)o=$U(o,n.id,n,n===t||n.model!==e.name?r:QU(e,n.id)?.definedBy??``);return o}function QU(e,t){return e.dimensions.find(e=>e.name===t)??e.measures.find(e=>e.name===t)??e.metrics.find(e=>e.name===t)}function $U(e,t,n,r){let i=Hh(pS,e),a=n&&{name:n.id,label:n.label,description:n.description??``,definedBy:r},o=n?.kind===`attribute`?{$typeName:`surfaces.v1.Dimension`,...a,column:n.column??``,kind:n.grain?gS.TIME:gS.CATEGORY,grain:n.grain??``}:void 0,s=n?.kind===`metric`?{$typeName:`surfaces.v1.Measure`,...a,column:n.column??``,aggregate:vC(n.aggregate??``),format:n.format??``}:void 0,c=n?.kind===`derived`?{$typeName:`surfaces.v1.Metric`,...a,expression:n.expression??``,format:n.format??``}:void 0,l=(e,n)=>{let r=e.findIndex(e=>e.name===t);return r<0?n?[...e,n]:e:n?e.map((e,t)=>t===r?n:e):e.filter((e,t)=>t!==r)};if(i.dimensions=l(i.dimensions,o),i.measures=l(i.measures,s),i.metrics=l(i.metrics,c),n&&n.id!==t){let e=RegExp(`\\b${t}\\b`,`g`);i.metrics=i.metrics.map(t=>({...t,expression:t.expression.replace(e,n.id)}))}return i}function eW(e,t){let n=new Map(qU(e).map(e=>[e.id,e])),r=new Map(qU(t).map(e=>[e.id,e])),i=new Map;for(let[e,t]of r){let r=n.get(e);r?YU(r,t)||i.set(e,`changed`):i.set(e,`added`)}for(let e of n.keys())r.has(e)||i.set(e,`removed`);for(let n of[`name`,`label`,`description`,`sql`,`grain`])e[n]!==t[n]&&i.set(`(${n})`,`changed`);e.primaryKey.join(`|`)!==t.primaryKey.join(`|`)&&i.set(`(primaryKey)`,`changed`);let a=e=>JSON.stringify([e.tables,e.joins.map(e=>[e.left,e.right,e.keys.map(e=>[e.leftColumn,e.rightColumn]),e.definedBy,e.type||1])]);a(e)!==a(t)&&i.set(`(joins)`,`changed`);let o=e=>e.dataset?`${e.dataset.pipelineId}/${e.dataset.dataset}`:``;return o(e)!==o(t)&&i.set(`(dataset)`,`changed`),i}function tW(e){return ym(pS,e)}var nW,rW,iW,aW,oW=n((()=>{zb(),rw(),vS(),KU(),nW=[`number`,`compact`,`currency`,`percent`],rW=e=>nW.includes(e)?e:void 0,iW=e=>`the ${e.label||e.name} model`,aW=(e,t)=>!!t&&e.model!==t.name}));function sW(e,t){let n=e.dataset,[r,i]=(0,uW.useState)({});return(0,uW.useEffect)(()=>{if(!n?.pipelineId||!t)return i({});let e=new AbortController,r={signal:e.signal};return(async()=>{let a;try{a=(await t.getPipeline({id:n.pipelineId},r)).pipeline}catch{return!e.signal.aborted&&i({gone:!0})}if(!a)return i({gone:!0});let o=a.datasets.find(e=>e.name===n.dataset)?.lastRunId||a.summary?.latestRun?.id,s=o?(await t.getRun({pipelineId:n.pipelineId,runId:o},r).catch(()=>void 0))?.run:void 0;e.signal.aborted||i({pipeline:a,standing:EC(a,n.dataset,s)})})().catch(t=>!e.signal.aborted&&i({problem:aP(t)})),()=>e.abort()},[t,n?.pipelineId,n?.dataset]),r}function cW(e){let{model:t,compact:n}=e,r=IB(e.pipelines),{pipeline:i,standing:a,problem:o,gone:s}=sW(t,r),c=(0,uW.useId)(),l=t.dataset;if(!l?.pipelineId)return null;let u=a?.pipelineName||l.pipelineId,d=r&&(i||s)?DC(t,i):[],f=s||d.length>0||a?.state===`failed`||(a?.failing??0)>0||a&&!a.built?`warn`:`ok`,p=e.onOpenDataset&&(0,lW.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onOpenDataset?.(l.pipelineId,l.dataset),children:`Open in the pipeline`});return n?(0,lW.jsxs)(`p`,{className:`sf-lineage`,"data-compact":!0,"data-tone":f,role:`note`,children:[(0,lW.jsx)(`span`,{className:`sf-lineage-mark`,"aria-hidden":`true`,children:f===`ok`?`✓`:`!`}),(0,lW.jsxs)(`span`,{children:[`Rows from `,(0,lW.jsx)(`strong`,{children:l.dataset}),`, built by `,AC(u),a?.builtAt?` · ${dW(a.builtAt)}`:a&&!a.built?` · not built yet`:``,a&&a.checks.length>0&&(a.failing>0?` · ${a.failing} of ${a.checks.length} checks failing`:a.warnings>0?` · ${a.warnings} ${a.warnings===1?`warning`:`warnings`}, no check failing`:` · checks passed`),s&&` · the pipeline is not there any more`,d.length>0&&!s&&` · ${d.length===1?`differs`:`${d.length} differences`} from the dataset`]}),p]}):(0,lW.jsxs)(`section`,{className:`sf-lineage`,"data-tone":f,"aria-labelledby":`${c}-title`,children:[(0,lW.jsx)(`h4`,{id:`${c}-title`,className:`sf-explore-heading`,children:`From a pipeline`}),(0,lW.jsxs)(`p`,{children:[`The rows are the dataset `,(0,lW.jsx)(`strong`,{children:l.dataset}),`, which `,AC(u),` builds on `,t.sourceId,`. Its grain and key are checked after every build.`]}),!r&&(0,lW.jsx)(`p`,{className:`sf-explore-hint`,children:`How it was last built is shown where the pipelines can be read.`}),o&&(0,lW.jsxs)(`p`,{className:`sf-filter-problem`,children:[`The pipeline could not be read: `,o]}),a&&(0,lW.jsxs)(`dl`,{className:`sf-lineage-facts`,children:[(0,lW.jsx)(`dt`,{children:`Last built`}),(0,lW.jsx)(`dd`,{children:a.builtAt?dW(a.builtAt):`Not built yet: the query has no table to read until the pipeline runs.`}),a.state===`failed`||a.state===`running`||a.state===`skipped`?(0,lW.jsxs)(lW.Fragment,{children:[(0,lW.jsx)(`dt`,{children:`Latest run`}),(0,lW.jsx)(`dd`,{children:a.state===`failed`?`Failed. The table holds what the last good build left.`:a.state===`running`?`Under way.`:`Skipped, because something it reads failed.`})]}):null,(0,lW.jsx)(`dt`,{children:`Grain`}),(0,lW.jsx)(`dd`,{children:a.grain||`Not declared.`}),(0,lW.jsx)(`dt`,{children:`Key`}),(0,lW.jsx)(`dd`,{children:a.primaryKey.length?`${a.primaryKey.join(`, `)} · ${a.keyChecked?`checked unique and not empty by the latest run`:`not checked by the latest run`}`:`Not declared.`}),(0,lW.jsx)(`dt`,{children:`Reads`}),(0,lW.jsx)(`dd`,{children:a.inputs.length?`${a.inputs.join(`, `)}${a.inputsDeclared?``:` (worked out from its query)`}`:`Nothing named.`}),a.owner&&(0,lW.jsxs)(lW.Fragment,{children:[(0,lW.jsx)(`dt`,{children:`Owner`}),(0,lW.jsx)(`dd`,{children:a.owner})]})]}),a&&a.checks.length>0&&(0,lW.jsx)(`ul`,{className:`sf-lineage-checks`,"aria-label":`Checks from the latest run`,children:a.checks.map(e=>(0,lW.jsxs)(`li`,{"data-failing":e.failedRecords>0||void 0,children:[(0,lW.jsx)(`span`,{"aria-hidden":`true`,children:e.failedRecords>0?e.severity===`warn`?`!`:`✕`:`✓`}),` `,(0,lW.jsx)(`code`,{children:e.name}),` `,e.failedRecords>0?`${e.severity===`warn`?`warns`:`fails`}: ${e.summary}`:`passed`]},e.name))}),s&&(0,lW.jsxs)(`p`,{className:`sf-filter-problem`,children:[AC(l.pipelineId).replace(/^t/,`T`),` is not there any more.`]}),d.length>0&&!s&&(0,lW.jsxs)(`div`,{className:`sf-filter-problem`,role:`alert`,children:[d.map(e=>(0,lW.jsx)(`p`,{children:e},e)),e.onUseDataset&&a&&(0,lW.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>e.onUseDataset?.(a),children:`Use the dataset's grain and key`})]}),p]})}var lW,uW,dW,fW=n((()=>{lW=WA(),rw(),uW=NM(),cP(),HA(),QB(),dW=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:PA({dateStyle:`medium`,timeStyle:`short`}).format(t)}}));function pW(e,t,n,r,i){let a=JSON.stringify([t,n,r.rows,r.split,r.values,r.filters,r.fields,i]),[o,s]=(0,bW.useState)({key:``});return(0,bW.useEffect)(()=>{let o=new AbortController,c;try{c=MU(r,n,i)}catch(e){s({key:a,error:aP(e)});return}return JS(e.execute({sourceId:t,query:c},{signal:o.signal})).then(e=>{if(o.signal.aborted)return;let t=Object.fromEntries(e.table.schema.fields.map(e=>[e.name,e.type]));s({key:a,rows:e.table.toArray().map(e=>e.toJSON()),types:t})}).catch(e=>!o.signal.aborted&&s({key:a,error:aP(e)})),()=>o.abort()},[e,a]),o.key===a?o:{}}function mW({dataSource:e,sourceId:t,sql:n,state:r,limit:i=200}){let a=pW(e,t,n,r,i),o=DW(r);if(a.error)return(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:a.error});if(!a.rows)return(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:`Working it out…`});let s=(e,t)=>{let n=t[GU(e)],r=a.types?.[GU(e)];return e.kind===`attribute`?n==null?`–`:r?XN(n,r).text:String(n):FU(r?$N(n,r):n,e.format)};return(0,U.jsxs)(`div`,{className:`sf-explore-table`,tabIndex:0,role:`region`,"aria-label":`The numbers behind the view`,children:[(0,U.jsxs)(`table`,{children:[(0,U.jsx)(`thead`,{children:(0,U.jsx)(`tr`,{children:o.map(e=>(0,U.jsx)(`th`,{scope:`col`,"data-number":e.kind!==`attribute`||void 0,children:e.label},e.id))})}),(0,U.jsx)(`tbody`,{children:a.rows.map((e,t)=>(0,U.jsx)(`tr`,{children:o.map(t=>(0,U.jsx)(`td`,{"data-number":t.kind!==`attribute`||void 0,children:s(t,e)},t.id))},t))})]}),a.rows.length>=i&&(0,U.jsxs)(`p`,{className:`sf-explore-hint`,children:[`The first `,i,` rows, in the order shown. Add a filter or a coarser breakdown to see fewer.`]})]})}function hW({dataSource:e,sourceId:t,sql:n,state:r}){let i=pW(e,t,n,{...r,rows:[],split:void 0},1),a=r.values.map(e=>r.fields.find(t=>t.id===e)).filter(e=>!!e);return i.error?(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:i.error}):(0,U.jsx)(`dl`,{className:`sf-explore-numbers`,children:a.map(e=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:e.label}),(0,U.jsx)(`dd`,{children:i.rows?FU(i.types?.[e.id]?$N(i.rows[0]?.[e.id],i.types[e.id]):i.rows[0]?.[e.id],e.format):`…`})]},e.id))})}function gW(e){let{sourceId:t,sql:n,state:r,height:i=300,label:a,onPointClick:o}=e,s=VN(e.dataSource),c=(0,bW.useMemo)(()=>PU(r),[r]),l=!!o&&!!c&&!c.xGrain,[u,d]=(0,bW.useMemo)(()=>{try{return[LC(l?JC(r.filters,c.x):r.filters),void 0]}catch(e){return[[],aP(e)]}},[r.filters,l,c]);if(r.values.length===0)return null;if(d)return(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:d});let f=e.view??r.view??`chart`;return c?f===`table`?(0,U.jsx)(mW,{dataSource:s,sourceId:t,sql:n,state:r}):(0,U.jsx)(xF,{dataSource:s,sourceId:t,sql:n,filters:u,type:c.type,x:c.x,xGrain:c.xGrain,splitBy:c.splitBy,y:c.y,xTitle:c.xTitle,yTitle:c.yTitle,yRightTitle:c.yRightTitle,yFormat:c.yFormat,horizontal:c.horizontal,height:i,label:a,onPointClick:l?e=>e.x!=null&&o(c.x,e.x):void 0},JSON.stringify(c)):(0,U.jsx)(hW,{dataSource:s,sourceId:t,sql:n,state:r})}function _W(e){let t=t=>e.fields.find(e=>e.id===t)?.label;return[e.values.map(t).filter(Boolean).join(` and `),e.rows.length>0?`by ${e.rows.map(t).filter(Boolean).join(`, then `)}`:``,e.split?`split by ${t(e.split)}`:``].filter(Boolean).join(` `)}function vW({pill:e,all:t,columns:n,isNew:r,modelLabel:i,onSave:a,onCancel:o,onRemove:s,onPromote:c}){let l=(0,bW.useId)(),[u,d]=(0,bW.useState)(e),f=t.filter(t=>t.id!==e.id),p=r?{...u,id:SU(u.label||CW[u.kind],f.map(e=>e.id))}:u,m=TU(p,[...f,p],n.map(e=>e.name)),h=t.filter(e=>e.kind===`metric`),g=n.find(e=>e.name===u.column),_=!!g&&/Timestamp|Date/.test(String(g.type)),v=r||e.kind!==`metric`?[]:t.filter(t=>t.kind===`derived`&&RegExp(`\\b${e.id}\\b`).test(t.expression??``)),y=v.length>0&&(u.aggregate!==e.aggregate||u.column!==e.column);return(0,U.jsxs)(`form`,{className:`sf-explore-editor`,onSubmit:e=>{e.preventDefault(),m||a(p)},"aria-label":r?`New ${CW[u.kind]}`:`Edit ${e.label}`,children:[(0,U.jsxs)(`p`,{className:`sf-explore-editor-title`,children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,"aria-hidden":`true`,children:SW[u.kind]}),r?`New ${CW[u.kind]}`:`Edit ${CW[u.kind]}`,!r&&e.by&&(0,U.jsxs)(`span`,{className:`sf-explore-by`,children:[` · made by `,e.by]})]}),i&&(0,U.jsxs)(`p`,{className:`sf-explore-hint`,children:[`Defined in the `,i,` model. A change here stays in this view until it is added to the model again.`]}),(0,U.jsx)(`label`,{htmlFor:`${l}-label`,children:`Label`}),(0,U.jsx)(`input`,{id:`${l}-label`,className:`sf-input`,value:u.label,autoFocus:!0,onChange:e=>d({...u,label:e.target.value})}),u.kind!==`derived`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-column`,children:`Column`}),(0,U.jsxs)(`select`,{id:`${l}-column`,className:`sf-input`,value:u.column??``,onChange:e=>d({...u,column:e.target.value||void 0}),children:[u.kind===`metric`&&(0,U.jsx)(`option`,{value:``,children:`(rows)`}),n.map(e=>(0,U.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),u.kind===`attribute`&&_&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-grain`,children:`Grouped by`}),(0,U.jsx)(`select`,{id:`${l}-grain`,className:`sf-input`,value:u.grain??`month`,onChange:e=>d({...u,grain:e.target.value}),children:TW.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),u.kind===`metric`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-aggregate`,children:`Summarised as`}),(0,U.jsx)(`select`,{id:`${l}-aggregate`,className:`sf-input`,value:u.aggregate??`sum`,onChange:e=>d({...u,aggregate:e.target.value}),children:wW.map(e=>(0,U.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),u.kind===`derived`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-expression`,children:`Calculation`}),(0,U.jsx)(`textarea`,{id:`${l}-expression`,className:`sf-input sf-explore-expression`,rows:2,spellCheck:!1,value:u.expression??``,"aria-describedby":`${l}-names`,placeholder:`refund_amount / line_amount`,onChange:e=>d({...u,expression:e.target.value})}),(0,U.jsx)(`p`,{id:`${l}-names`,className:`sf-explore-hint`,children:`Metrics, numbers, + − × ÷ and parentheses. Worked out by the database after summarising. Press a metric to add it:`}),(0,U.jsx)(`div`,{className:`sf-explore-names`,children:h.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:`sf-pill`,"data-kind":`metric`,title:e.label,onClick:()=>d({...u,expression:`${u.expression??``}${u.expression&&!/[\s(]$/.test(u.expression)?` `:``}${e.id}`}),children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,"aria-hidden":`true`,children:`Σ`}),e.id]},e.id))})]}),u.kind!==`attribute`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`${l}-format`,children:`Shown as`}),(0,U.jsx)(`select`,{id:`${l}-format`,className:`sf-input`,value:u.format??`number`,onChange:e=>d({...u,format:e.target.value}),children:EW.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),(0,U.jsx)(`label`,{htmlFor:`${l}-description`,children:`What it means (optional)`}),(0,U.jsx)(`input`,{id:`${l}-description`,className:`sf-input`,value:u.description??``,onChange:e=>d({...u,description:e.target.value||void 0})}),y&&(0,U.jsxs)(`p`,{className:`sf-explore-warning`,role:`status`,children:[v.length===1?`A calculation uses`:`${v.length} calculations use`,` this metric and will change with it: `,v.map(e=>e.label).join(`, `),`. To keep `,v.length===1?`it`:`them`,` as `,v.length===1?`it is`:`they are`,`, cancel and duplicate this metric instead.`]}),m&&(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:m}),(0,U.jsxs)(`div`,{className:`sf-explore-editor-actions`,children:[(0,U.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:!!m,children:r?`Add`:`Save`}),(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:o,children:`Cancel`}),c&&(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:c,children:`Add to the model`}),s&&(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`danger`,onClick:s,children:`Remove`})]})]})}function yW(e){let{onChange:t,onAsk:n,editor:r=`you`,chartHeight:i=300,model:a}=e,o=e.sourceId??a?.sourceId??``,s=e.sql??a?.sql??``,c=VN(e.dataSource),l=gP(),u=(0,bW.useId)(),[d,f]=(0,bW.useState)(e.defaultValue??RU),p=(0,bW.useMemo)(()=>EU(e.value??d),[e.value,d]),m=(0,bW.useRef)(e.value??d);m.current=e.value??d;let h=(0,bW.useRef)(a);h.current=a;let g=(0,bW.useCallback)(e=>{let n=EU(e);f(n),t?.(n)},[t]),[_,v]=(0,bW.useState)([]),[y,b]=(0,bW.useState)(),[x,S]=(0,bW.useState)(``),[C,w]=(0,bW.useState)(),[T,E]=(0,bW.useState)(``),D=(0,bW.useRef)(e.onContext);D.current=e.onContext;let O=(e,t,n)=>{S(t),D.current?.({kind:e,summary:t,...n?{subject:n}:{}})},[k,ee]=(0,bW.useState)(``),[te,A]=(0,bW.useState)(()=>(e.value??e.defaultValue)?.fields?.some(e=>e.kind===`derived`)??!1),[ne,re]=(0,bW.useState)(()=>((e.value??e.defaultValue)?.filters?.length??0)>0),ie=p.view??`chart`;(0,bW.useEffect)(()=>{let t=new AbortController;return b(void 0),JS(c.execute({sourceId:o,query:{baseSql:s,page:{limit:1}}},{signal:t.signal})).then(n=>{if(t.signal.aborted)return;let r=n.table.schema.fields;if(v(r),m.current.fields.length===0){let t=h.current?JU(h.current,r):CU(r),n=m.current.rows.length===0&&m.current.values.length===0&&!m.current.split;g({...m.current,fields:t,...e.startWithView&&n?IU(t):{}});let i=t.filter(e=>e.model).length;O(`fields.generated`,i>0?`${i} fields from the ${h.current?.label||h.current?.name} model, and ${t.length-i} generated from the other columns.`:`${t.length} fields generated from the columns. Edit any of them, or add your own.`,{fields:t.map(e=>({id:e.id,kind:e.kind,label:e.label,...e.model?{model:e.model}:{}}))})}}).catch(e=>!t.signal.aborted&&b(aP(e))),()=>t.abort()},[c,o,s]),(0,bW.useEffect)(()=>{if(!a||m.current.fields.length===0)return;let e=XU(m.current.fields,a);JSON.stringify(e)!==JSON.stringify(m.current.fields)&&g({...m.current,fields:e})},[a]);let ae=async t=>{if(e.onPromote)try{let n=await e.onPromote(t,p.fields);O(`field.promoted`,n||`${t.label} offered to the model.`,{field:t,...a?{model:a.name}:{}})}catch(e){S(aP(e))}},oe=t=>!!e.onPromote&&aW(t,a),se=e=>p.fields.find(t=>t.id===e),ce=e=>p.rows.includes(e)?`rows`:p.split===e?`split`:p.values.includes(e)?`values`:void 0,le=(e,t,n)=>{let r=se(e);if(!r)return;let i=t??(r.kind===`attribute`?`rows`:`values`),a=xW.find(e=>e.id===i).label;if(!xW.find(e=>e.id===i).takes.includes(r.kind))return S(`${r.label} is ${r.kind===`attribute`?`an attribute`:`a ${CW[r.kind]}`}, so it cannot go on “${a}”.`);let o=ce(e),s=DU(p,e,i,n);g(s);let c=i===`split`?[]:s[i],l=c.indexOf(e)+1;O(`shelf.changed`,o===i&&c.length>1?`${r.label} moved to place ${l} of ${c.length} on “${a}”.`:`${r.label} added to “${a}”.`,{...o===i?{moved:r.id}:{added:r.id},shelf:i,rows:s.rows,split:s.split??null,values:s.values})},ue=(e,t)=>{let n=ce(e.id);if(n!==`rows`&&n!==`values`)return;let r=OU(p,e.id,t);if(r===p)return S(`${e.label} is already ${t<0?`first`:`last`} on “${xW.find(e=>e.id===n).label}”.`);g(r),O(`shelf.changed`,`${e.label} moved to place ${r[n].indexOf(e.id)+1} of ${r[n].length} on “${xW.find(e=>e.id===n).label}”.`,{moved:e.id,shelf:n,rows:r.rows,split:r.split??null,values:r.values})},de=(e,t)=>{let n=kU(p,e,t);g(n),O(`shelf.changed`,`${se(e)?.label??e} removed from “${xW.find(e=>e.id===t).label}”.`,{removed:e,shelf:t,rows:n.rows,split:n.split??null,values:n.values})},fe=e=>{g(AU(p,e.id,void 0)),O(`field.removed`,`${e.label} removed.`,{field:e})},pe={bar:`bars`,line:`a line`,area:`an area`},me=p.chart?.type??(se(p.rows[0]??``)?.grain?`line`:`bar`),he=e=>{g({...xU(p,{type:e}),view:`chart`}),O(`chart.changed`,`Drawn as ${pe[e]}.`,{chart:{type:e}})},ge=()=>{g({...p,view:`table`}),O(`view.changed`,`Shown as a table.`,{view:`table`})},j=NU(p),_e=!!p.chart?.swap&&!j,ve=()=>{let e=!_e;g(xU(p,{swap:e})),O(`chart.changed`,e?`Axes swapped: the bars run across, the breakdown down the side.`:`Axes back: the bars stand up, the breakdown along the bottom.`,{chart:{swap:e}})},ye=e=>p.chart?.measures?.[e]??{},be=(e,t)=>{g(bU(p,e.id,t));let n=t.type?`${e.label} drawn as ${pe[t.type]}.`:t.axis===`right`?`${e.label} measured on its own scale, at the right.`:`${e.label} measured on the left scale.`;O(`chart.changed`,n,{measure:e.id,...t})},xe=p.values.filter(e=>ye(e).axis===`right`).length,Se=xe>0&&xe<p.values.length,M=e=>Se?ye(e).axis===`right`?`right`:`left`:void 0,Ce={rows:_e?`Y axis`:`X axis`,values:_e?`X axis`:Se?`Y axes`:`Y axis`,split:`Colour`},we=e=>({id:``,kind:e,label:``,by:r,...e===`metric`?{aggregate:`sum`,column:_.find(e=>/Int|Float|Decimal/.test(String(e.type)))?.name}:e===`attribute`?{column:_[0]?.name}:{expression:``,format:`number`}}),Te=e=>[...e.kind===`attribute`?[{label:`Break down by this`,onSelect:()=>le(e.id,`rows`),hint:`Enter`},{label:`Split by this`,onSelect:()=>le(e.id,`split`),hint:`S`}]:[{label:`Measure this`,onSelect:()=>le(e.id,`values`),hint:`Enter`}],...ce(e.id)?[{label:`Take off the shelves`,onSelect:()=>de(e.id,ce(e.id)),hint:`Delete`}]:[],...(ce(e.id)===`rows`||ce(e.id)===`values`)&&p[ce(e.id)].length>1?[{label:`Move earlier`,onSelect:()=>ue(e,-1),hint:`Alt+←`,disabled:p[ce(e.id)][0]===e.id},{label:`Move later`,onSelect:()=>ue(e,1),hint:`Alt+→`,disabled:p[ce(e.id)].at(-1)===e.id}]:[],{separator:!0},{label:`Edit`,onSelect:()=>w({pill:e,isNew:!1}),hint:`E`},{label:`Remove the field`,onSelect:()=>fe(e),hint:`Shift+Delete`},{label:`Duplicate`,onSelect:()=>w({pill:{...e,label:`${e.label} copy`,by:r,model:void 0},isNew:!0}),hint:`D`},...oe(e)?[{label:a&&[...a.dimensions,...a.measures,...a.metrics].some(t=>t.name===e.id)?`Update it in the model`:`Add to the model`,onSelect:()=>void ae(e),hint:`M`}]:[]],[Ee,De]=(0,bW.useState)(),Oe=(e,t)=>n=>{if(n.button!==0)return;let r={x:n.clientX,y:n.clientY},i=!1,a=n.pointerType!==`touch`,o=(e,t)=>document.elementFromPoint(e,t)?.closest(`[data-shelf]`)?.dataset.shelf,s=(t,n,r)=>{if(t===`split`)return;let i=Array.from(document.querySelectorAll(`[data-shelf="${t}"] [data-pill]`)).filter(t=>t.dataset.pill!==e.id),a=i.findIndex(e=>{let t=e.getBoundingClientRect();return r<t.top||r<=t.bottom&&n<t.left+t.width/2});return a<0?i.length:a},c=a?void 0:window.setTimeout(()=>{a=!0,De({label:e.label,kind:e.kind,x:r.x,y:r.y,over:o(r.x,r.y)})},300),l=e=>a&&e.cancelable&&e.preventDefault(),u=t=>{let n=Math.hypot(t.clientX-r.x,t.clientY-r.y)>=6;if(!a)return n?void d(t):void 0;if(!i&&!n)return;i=!0;let c=o(t.clientX,t.clientY);De({label:e.label,kind:e.kind,x:t.clientX,y:t.clientY,over:c,id:e.id,...c?{place:s(c,t.clientX,t.clientY)}:{}})},d=e=>(window.clearTimeout(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,d),window.removeEventListener(`contextmenu`,d),window.removeEventListener(`touchmove`,l),window.removeEventListener(`keydown`,p),De(void 0),e),f=n=>{if(d(n),!i)return;let r=e=>e.stopPropagation();window.addEventListener(`click`,r,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,r,{capture:!0}),0);let a=o(n.clientX,n.clientY);a?le(e.id,a,s(a,n.clientX,n.clientY)):t&&de(e.id,t)},p=e=>e.key===`Escape`&&d(e);window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,d),window.addEventListener(`contextmenu`,d),window.addEventListener(`touchmove`,l,{passive:!1}),window.addEventListener(`keydown`,p)},ke=e=>t=>{if(t.key===`s`&&e.kind===`attribute`)le(e.id,`split`);else if(t.key===`e`)w({pill:e,isNew:!1});else if(t.key===`d`)w({pill:{...e,label:`${e.label} copy`,by:r,model:void 0},isNew:!0});else if(t.key===`m`&&oe(e))ae(e);else if(t.altKey&&(t.key===`ArrowLeft`||t.key===`ArrowUp`))ue(e,-1);else if(t.altKey&&(t.key===`ArrowRight`||t.key===`ArrowDown`))ue(e,1);else if((t.key===`Delete`||t.key===`Backspace`)&&t.shiftKey)fe(e);else if((t.key===`Delete`||t.key===`Backspace`)&&ce(e.id))de(e.id,ce(e.id));else return;t.preventDefault()},Ae=(e,t)=>!Ee||Ee.place===void 0||e===`split`?!1:p[e].filter(e=>e!==Ee.id)[Ee.place]===t,je=(e,t)=>{let n=TU(e,p.fields,_.length>0?_.map(e=>e.name):void 0),r=t===`values`&&Pe&&ie===`chart`?M(e.id):void 0,i=t?void 0:e.model?`model`:e.by&&e.by!==`the columns`?e.by===`suggested from the columns`?`suggested`:e.by:void 0;return(0,U.jsxs)(`span`,{className:`sf-pill-wrap`,"data-pill":t?e.id:void 0,"data-insert":t&&Ee?.over===t&&Ee.id!==e.id&&Ae(t,e.id)?`before`:void 0,"data-kind":e.kind,"data-on":!t&&ce(e.id)||void 0,"data-bad":n?`true`:void 0,children:[(0,U.jsxs)(`button`,{type:`button`,className:`sf-pill`,"data-kind":e.kind,title:[e.description,n,e.kind===`derived`?e.expression:void 0,e.model?`From the ${a?.label||e.model} model`:void 0,e.by?`Made by ${e.by}`:void 0].filter(Boolean).join(` · `),"aria-keyshortcuts":`Enter S E D${oe(e)?` M`:``} Delete Shift+Delete${t===`rows`||t===`values`?` Alt+ArrowLeft Alt+ArrowRight`:``} Shift+F10`,onPointerDown:Oe(e,t),onClick:()=>t?w({pill:e,isNew:!1}):le(e.id),onKeyDown:ke(e),onContextMenu:t=>l.open(t,`${e.label} actions`,Te(e)),children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,"aria-hidden":`true`,children:SW[e.kind]}),(0,U.jsxs)(`span`,{className:`sf-pill-label`,children:[e.label,` `,(0,U.jsx)(`span`,{className:`sf-visually-hidden`,children:`(${CW[e.kind]}${i?`, ${i===`model`?`from the model`:`by ${i}`}`:``}${r?`, ${r} scale`:``}${t?``:ce(e.id)?`, in use`:``}${n?`, problem: ${n}`:``})`})]}),r&&(0,U.jsx)(`span`,{className:`sf-pill-side`,"data-side":r,"aria-hidden":`true`,children:r}),i&&(0,U.jsx)(`span`,{className:`sf-pill-by`,"data-model":e.model?`true`:void 0,"aria-hidden":`true`,children:i})]}),t?(0,U.jsx)(`button`,{type:`button`,className:`sf-pill-x`,"aria-label":`Take ${e.label} off “${xW.find(e=>e.id===t).label}”`,onClick:()=>de(e.id,t),children:(0,U.jsx)(dI,{icon:`close`})}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:`sf-pill-x`,"data-control":`edit`,"aria-label":`Edit ${e.label}`,onClick:()=>w({pill:e,isNew:!1}),children:(0,U.jsx)(dI,{icon:`edit`})}),ce(e.id)&&(0,U.jsx)(`button`,{type:`button`,className:`sf-pill-x`,"aria-label":`Take ${e.label} off “${xW.find(t=>t.id===ce(e.id)).label}”`,onClick:()=>de(e.id,ce(e.id)),children:(0,U.jsx)(dI,{icon:`close`})})]})]},e.id)},Me=T.trim().toLowerCase(),Ne=e=>p.fields.filter(t=>t.kind===e&&(!Me||t.label.toLowerCase().includes(Me)||t.id.includes(Me))),Pe=(0,bW.useMemo)(()=>PU(p),[p]),Fe=_W(p);return(0,U.jsxs)(`div`,{className:[`sf-explore`,e.className].filter(Boolean).join(` `),children:[a?.dataset&&(0,U.jsx)(cW,{model:a,compact:!0}),(0,U.jsxs)(`div`,{className:`sf-explore-frame`,children:[(0,U.jsxs)(`aside`,{className:`sf-explore-fields`,"aria-label":`Fields`,children:[(0,U.jsx)(`input`,{className:`sf-input`,type:`search`,placeholder:`Find a field`,"aria-label":`Find a field`,value:T,onChange:e=>E(e.target.value)}),[`attribute`,`metric`].map(e=>(0,U.jsxs)(`section`,{"aria-label":e===`attribute`?`Attributes`:`Metrics`,children:[(0,U.jsxs)(`h4`,{className:`sf-explore-heading`,children:[e===`attribute`?`Attributes`:e===`metric`?`Metrics`:`Calculations`,(0,U.jsx)(`button`,{type:`button`,className:`sf-explore-add`,"aria-label":`New ${CW[e]}`,onClick:()=>w({pill:we(e),isNew:!0}),children:(0,U.jsx)(dI,{icon:`add`})})]}),(0,U.jsxs)(`div`,{className:`sf-explore-pills`,children:[Ne(e).map(e=>je(e)),Ne(e).length===0&&(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:Me?`None match.`:`None.`})]})]},e)),(0,U.jsxs)(`details`,{className:`sf-explore-more`,open:te||!!Me&&Ne(`derived`).length>0,onToggle:e=>A(e.currentTarget.open),children:[(0,U.jsxs)(`summary`,{children:[`Calculations`,p.fields.some(e=>e.kind===`derived`)&&(0,U.jsx)(`span`,{className:`sf-explore-count`,children:p.fields.filter(e=>e.kind===`derived`).length})]}),(0,U.jsxs)(`section`,{"aria-label":`Calculations`,children:[(0,U.jsxs)(`h4`,{className:`sf-explore-heading`,children:[`Calculations`,(0,U.jsx)(`button`,{type:`button`,className:`sf-explore-add`,"aria-label":`New ${CW.derived}`,onClick:()=>w({pill:we(`derived`),isNew:!0}),children:(0,U.jsx)(dI,{icon:`add`})})]}),(0,U.jsxs)(`div`,{className:`sf-explore-pills`,children:[Ne(`derived`).map(e=>je(e)),Ne(`derived`).length===0&&(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:Me?`None match.`:`None yet. A calculation is arithmetic over metrics: a rate, a margin, an average.`})]})]}),(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{let e=wU(p.fields);if(e.length===0)return S(`Nothing more to suggest from these columns. Make a calculation of your own with “New calculation”.`);g({...p,fields:[...p.fields,...e]}),O(`fields.suggested`,`${e.length} ${e.length===1?`calculation`:`calculations`} suggested from the column names: ${e.map(e=>e.label).join(`, `)}. They are guesses to keep, edit or remove.`,{fields:e})},children:`Suggest calculations`})]}),C&&(0,U.jsx)(vW,{pill:C.pill,all:p.fields,columns:_,isNew:C.isNew,modelLabel:C.pill.model?a?.label||C.pill.model:void 0,onPromote:!C.isNew&&oe(C.pill)?()=>(ae(C.pill),w(void 0)):void 0,onCancel:()=>w(void 0),onSave:e=>{let t={...e,by:r,model:void 0};g(AU(p,C.isNew?t.id:C.pill.id,t)),O(C.isNew?`field.added`:`field.changed`,`${t.label} ${C.isNew?`added`:`saved`}.`,{field:t,...C.isNew?{}:{was:C.pill}}),w(void 0)},onRemove:C.isNew?void 0:()=>{g(AU(p,C.pill.id,void 0)),O(`field.removed`,`${C.pill.label} removed.`,{field:C.pill}),w(void 0)}},`${C.pill.id}-${C.isNew}`)]}),(0,U.jsxs)(`div`,{className:`sf-explore-main`,children:[n&&(0,U.jsxs)(`form`,{className:`sf-explore-ask`,onSubmit:e=>{e.preventDefault(),k.trim()&&(n(k.trim(),p),O(`asked`,`Asked: “${k.trim()}”.`,{text:k.trim()}),ee(``))},children:[(0,U.jsx)(`input`,{className:`sf-input`,"aria-label":`Ask for a field or a view`,placeholder:`Ask for a field or a view: refund rate by region, split by channel`,value:k,onChange:e=>ee(e.target.value)}),(0,U.jsx)(`button`,{type:`submit`,className:`sf-button`,disabled:!k.trim(),children:`Ask`})]}),(0,U.jsx)(`div`,{className:`sf-explore-shelves`,children:xW.map(e=>{let t=e.id===`split`?p.split?[p.split]:[]:p[e.id];return(0,U.jsxs)(`div`,{className:`sf-explore-shelf`,"data-shelf":e.id,"data-over":Ee?.over===e.id||void 0,"data-accepts":Ee?e.takes.includes(Ee.kind):void 0,role:`group`,"aria-label":e.label,children:[(0,U.jsx)(`span`,{className:`sf-explore-shelf-name`,title:e.hint,children:e.label}),Pe&&ie===`chart`&&(e.id!==`split`||p.values.length===1)&&(0,U.jsx)(`span`,{className:`sf-explore-axis`,"data-axis":e.id===`split`?`colour`:Ce[e.id]===`X axis`?`x`:`y`,title:e.id===`values`&&Se?`Each measure's pill says which side's scale it is read against.`:void 0,children:Ce[e.id]}),t.map(e=>se(e)).filter(e=>!!e).map(t=>je(t,e.id)),t.length===0&&(0,U.jsx)(`span`,{className:`sf-explore-hint`,children:Ee?e.takes.includes(Ee.kind)?`Drop here`:`Not for this field`:e.id===`values`?`Press a metric`:e.id===`rows`?`Press an attribute`:`Optional`})]},e.id)})}),Pe&&(0,U.jsxs)(`div`,{className:`sf-explore-chart-settings`,children:[(0,U.jsxs)(`div`,{className:`sf-segmented sf-result-views`,role:`group`,"aria-label":`Draw as`,children:[[`bar`,`line`,`area`].map(e=>{let t=ie===`chart`&&me===e;return(0,U.jsx)(`button`,{type:`button`,className:`sf-segment`,"data-checked":t||void 0,"aria-pressed":t,onClick:()=>he(e),children:e===`bar`?`Bars`:e===`line`?`Line`:`Area`},e)}),(0,U.jsx)(`button`,{type:`button`,className:`sf-segment`,"data-checked":ie===`table`||void 0,"aria-pressed":ie===`table`,onClick:ge,children:`Table`})]}),ie===`chart`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-pressed":_e,"aria-disabled":!!j||void 0,title:j,"aria-describedby":j?`${u}-swap`:void 0,onClick:()=>!j&&ve(),children:`Swap axes`}),j&&(0,U.jsx)(`span`,{id:`${u}-swap`,className:`sf-explore-hint`,children:j}),p.values.length>1&&(0,U.jsx)(`ul`,{className:`sf-explore-measures`,"aria-label":`Each measure`,children:p.values.map(e=>se(e)).filter(e=>!!e).map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`sf-explore-measure-name`,children:e.label}),(0,U.jsxs)(`select`,{className:`sf-input`,"aria-label":`Draw ${e.label} as`,value:ye(e.id).type??me,onChange:t=>be(e,{type:t.target.value}),children:[(0,U.jsx)(`option`,{value:`bar`,children:`Bars`}),(0,U.jsx)(`option`,{value:`line`,children:`Line`}),(0,U.jsx)(`option`,{value:`area`,children:`Area`})]}),(0,U.jsxs)(`select`,{className:`sf-input`,"aria-label":`Scale for ${e.label}`,value:ye(e.id).axis??`left`,onChange:t=>be(e,{axis:t.target.value}),children:[(0,U.jsx)(`option`,{value:`left`,children:`Left scale`}),(0,U.jsx)(`option`,{value:`right`,children:`Right scale`})]})]},e.id))})]})]}),(0,U.jsxs)(`details`,{className:`sf-explore-more`,open:ne,onToggle:e=>re(e.currentTarget.open),children:[(0,U.jsxs)(`summary`,{children:[`Filters`,p.filters.length>0&&(0,U.jsx)(`span`,{className:`sf-explore-count`,children:p.filters.length})]}),(0,U.jsx)(hU,{sourceId:o,sql:s,filters:p.filters,onChange:e=>g({...p,filters:e}),onContext:e.onContext,dataSource:c})]}),y&&(0,U.jsx)(`p`,{className:`sf-filter-problem`,role:`alert`,children:y}),p.values.length===0?(0,U.jsx)(`p`,{className:`sf-explore-empty`,children:`Press a metric to measure it, then an attribute to break it down. Each press, drag or edit asks the database again; nothing is worked out in this page.`}):(0,U.jsxs)(`div`,{className:`sf-explore-result sf-controls-host`,"data-controls":`corner`,children:[e.controls?.length?(0,U.jsx)(fI,{label:`${Fe||`View`} controls`,controls:e.controls}):null,(0,U.jsx)(`p`,{className:`sf-explore-reading`,children:Fe}),!Pe&&(0,U.jsx)(`p`,{className:`sf-explore-hint`,children:`With nothing to break down by there is one number each. Press an attribute for a chart.`}),(0,U.jsx)(gW,{dataSource:c,sourceId:o,sql:s,state:p,view:ie,height:i,label:Fe}),e.actions&&(0,U.jsx)(`div`,{className:`sf-explore-actions`,children:e.actions})]}),(0,U.jsx)(`p`,{className:`sf-explore-note`,role:`status`,children:x})]})]}),Ee&&(0,U.jsxs)(`span`,{className:`sf-pill sf-pill-ghost`,"data-kind":Ee.kind,"aria-hidden":`true`,style:{left:Ee.x,top:Ee.y},children:[(0,U.jsx)(`span`,{className:`sf-pill-glyph`,children:SW[Ee.kind]}),Ee.label]}),l.element]})}var U,bW,xW,SW,CW,wW,TW,EW,DW,OW=n((()=>{U=WA(),rw(),bW=NM(),EF(),vI(),GN(),rP(),cP(),vU(),yP(),KU(),oW(),fW(),xW=[{id:`rows`,label:`Break down by`,takes:[`attribute`],hint:`An attribute: one bar, point or row for each of its values.`},{id:`split`,label:`Split by`,takes:[`attribute`],hint:`An attribute whose values become separate series.`},{id:`values`,label:`Measure`,takes:[`metric`,`derived`],hint:`Metrics and calculations: what is counted or added up.`}],SW={attribute:`Abc`,metric:`Σ`,derived:`ƒ`},CW={attribute:`attribute`,metric:`metric`,derived:`calculation`},wW=[{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`count`,label:`Count`},{value:`count_distinct`,label:`Count of distinct values`},{value:`min`,label:`Smallest`},{value:`max`,label:`Largest`},{value:`median`,label:`Median`}],TW=[`day`,`week`,`month`,`quarter`,`year`],EW=[`number`,`compact`,`currency`,`percent`],DW=e=>[...e.rows,...e.split?[e.split]:[],...e.values].map(t=>e.fields.find(e=>e.id===t)).filter(e=>!!e)}));function kW(e,t){return EU({fields:e.fields,rows:t.rows,...t.split?{split:t.split}:{},values:t.values,filters:e.filters,...t.view?{view:t.view}:{},...t.chart?{chart:t.chart}:{}})}function AW(e){let t=e.draft??{rows:[],values:[]};return{fields:e.fields,rows:t.rows,...t.split?{split:t.split}:{},values:t.values,filters:e.filters,...t.view?{view:t.view}:{},...t.chart?{chart:t.chart}:{}}}function jW(e,t){return{...e,fields:t.fields,filters:t.filters,draft:{rows:t.rows,...t.split?{split:t.split}:{},values:t.values,...t.view?{view:t.view}:{},...t.chart?{chart:t.chart}:{}}}}function MW(e,t){let n=e.draft,r=n?kW(e,n):void 0;if(!n||!r||r.values.length===0)return e;let i={rows:r.rows,...r.split?{split:r.split}:{},values:r.values,...n.view?{view:n.view}:{},chart:r.chart};if(e.editing&&e.tiles.some(t=>t.id===e.editing))return{...e,tiles:e.tiles.map(n=>n.id===e.editing?{...n,...i,...i.split?{}:{split:void 0},...t===void 0?{}:{title:t||void 0}}:n),editing:void 0};if(e.tiles.length>=24)return e;let a=r.rows.length===0?3:1,{chart:o,...s}=i;return{...e,tiles:[...e.tiles,{id:zW(e.tiles),...t?{title:t}:{},...s,...o?{chart:o}:{},span:a}]}}function NW(e,t){let n=e.tiles.find(e=>e.id===t);return n?{...e,editing:t,draft:{rows:n.rows,...n.split?{split:n.split}:{},values:n.values,...n.view?{view:n.view}:{},...n.chart?{chart:n.chart}:{}}}:e}function PW(e,t){return{...e,tiles:e.tiles.filter(e=>e.id!==t),...e.editing===t?{editing:void 0}:{}}}function FW(e,t,n){let r=e.tiles.findIndex(e=>e.id===t),i=r+n;if(r<0||i<0||i>=e.tiles.length)return e;let a=[...e.tiles];return[a[r],a[i]]=[a[i],a[r]],{...e,tiles:a}}function IW(e,t,n){return{...e,tiles:e.tiles.map(e=>e.id===t?{...e,...n}:e)}}function LW(e){if(e.fields.length===0)return e;let t=new Set,n=[];for(let r of e.tiles.slice(0,24)){let i=kW(e,r);if(i.values.length===0)continue;let a=r.id||zW(n);t.has(a)&&(a=zW(n)),t.add(a);let o=r.span===2||r.span===3?r.span:1;n.push({id:a,...r.title?{title:r.title}:{},rows:i.rows,...i.split?{split:i.split}:{},values:i.values,...r.view?{view:r.view}:{},...i.chart?{chart:i.chart}:{},span:o})}return{...e,tiles:n,...e.editing&&!n.some(t=>t.id===e.editing)?{editing:void 0}:{}}}var RW,zW,BW=n((()=>{KU(),RW={fields:[],filters:[],tiles:[]},zW=e=>{for(let t=e.length+1;;t++)if(!e.some(e=>e.id===`tile-${t}`))return`tile-${t}`}}));function VW(e){let{label:t,options:n,value:r,onChange:i,fit:a=`content`,className:o}=e,s=(0,UW.useId)(),c=e.name??s;return(0,HW.jsx)(`div`,{className:[`sf-segmented`,`sf-segmented-control`,o].filter(Boolean).join(` `),"data-fit":a,role:`radiogroup`,"aria-label":t,children:n.map(e=>(0,HW.jsxs)(`label`,{className:`sf-segment`,"data-checked":e.value===r||void 0,"data-disabled":e.disabled||void 0,children:[(0,HW.jsx)(`input`,{type:`radio`,name:c,value:e.value,checked:e.value===r,"aria-disabled":e.disabled||void 0,onChange:()=>{e.disabled||i(e.value)}}),e.label]},e.value))})}var HW,UW,WW=n((()=>{HW=WA(),UW=NM()}));function GW(e){let{onChange:t,onAsk:n,editor:r,model:i}=e,a=e.sourceId??i?.sourceId??``,o=e.sql??i?.sql??``,s=VN(e.dataSource),[c,l]=(0,JW.useState)(e.defaultValue??RW),u=(0,JW.useMemo)(()=>LW(e.value??c),[e.value,c]),d=(0,JW.useCallback)(e=>{let n=LW(e);l(n),t?.(n)},[t]),[f,p]=(0,JW.useState)(`build`),m=e.mode??f,h=t=>{p(t),e.onModeChange?.(t),e.onContext?.({kind:`mode.changed`,summary:t===`view`?`Switched to viewing the report.`:`Switched to building the report.`,subject:{mode:t}})},[g,_]=(0,JW.useState)(``),v=(t,n,r)=>{_(n),e.onContext?.({kind:t,summary:n,...r?{subject:r}:{}})},y=e=>({rows:e.rows,split:e.split??null,values:e.values,view:e.view??`chart`}),b=(0,JW.useMemo)(()=>AW(u),[u]),x=u.tiles.find(e=>e.id===u.editing),S=!x&&u.tiles.length>=24,C=e=>e.title||_W(kW(u,e))||z(`report.untitled`),w=()=>{let e=MW(u);if(e===u)return _(S?z(`report.maxViews`,{max:24}):z(`report.needMeasure`));d(e);let t=x?e.tiles.find(e=>e.id===x.id):e.tiles.at(-1);v(x?`view.changed`:`view.added`,x?`${C(x)} updated: it now shows ${_W(KW(u))}.`:`Added to the report: ${_W(KW(u))||`a view`}. The shelves are as you left them, for the next one.`,t?{tile:t.id,...y(t)}:void 0)},T=(0,qW.jsx)(`div`,{className:`sf-report-tiles`,"data-mode":m,children:u.tiles.map((e,t)=>{let n=kW(u,e),r=C(e);return(0,qW.jsxs)(`section`,{className:`sf-report-tile sf-controls-host`,"data-controls":`corner`,"data-span":e.span??1,"data-editing":u.editing===e.id||void 0,"aria-label":r,children:[(0,qW.jsxs)(`header`,{className:`sf-report-tile-head`,children:[m===`build`?(0,qW.jsx)(`input`,{className:`sf-report-tile-title`,"aria-label":z(`report.tileTitle`,{title:r}),value:e.title??``,placeholder:_W(n),onChange:t=>d(IW(u,e.id,{title:t.target.value||void 0}))}):(0,qW.jsx)(`h4`,{className:`sf-report-tile-title`,children:r}),m===`build`&&(0,qW.jsx)(fI,{label:z(`report.tileControls`,{title:r}),controls:pI(r,{edit:()=>(d(NW(u,e.id)),v(`view.opened`,`${r} is on the shelves. Change it, then press “Update view”.`,{tile:e.id,...y(e)})),...n.rows.length>0?{view:{now:e.view??`chart`,toggle:()=>(d(IW(u,e.id,{view:(e.view??`chart`)===`chart`?`table`:`chart`})),v(`view.changed`,`${r} is shown as a ${(e.view??`chart`)===`chart`?`table`:`chart`}.`,{tile:e.id,view:(e.view??`chart`)===`chart`?`table`:`chart`}))}}:{},wider:(e.span??1)<3?()=>(d(IW(u,e.id,{span:(e.span??1)+1})),v(`view.resized`,`${r} made wider.`,{tile:e.id,span:(e.span??1)+1})):!1,narrower:(e.span??1)>1?()=>(d(IW(u,e.id,{span:(e.span??1)-1})),v(`view.resized`,`${r} made narrower.`,{tile:e.id,span:(e.span??1)-1})):!1,earlier:t>0?()=>(d(FW(u,e.id,-1)),v(`view.moved`,`${r} moved earlier.`,{tile:e.id,order:FW(u,e.id,-1).tiles.map(e=>e.id)})):!1,later:t<u.tiles.length-1?()=>(d(FW(u,e.id,1)),v(`view.moved`,`${r} moved later.`,{tile:e.id,order:FW(u,e.id,1).tiles.map(e=>e.id)})):!1,remove:()=>(d(PW(u,e.id)),v(`view.removed`,`${r} removed from the report.`,{tile:e.id,...y(e)}))})})]}),(0,qW.jsx)(gW,{dataSource:s,sourceId:a,sql:o,state:n,height:240,label:r,onPointClick:(t,n)=>{let i=KC(u.filters,t,n);d({...u,filters:i});let a=GC(i,t),o=a.some(e=>String(e)===String(n));v(`point.selected`,o?`Clicked ${n} in “${r}”: the report is filtered to ${t} ${a.length===1?`is`:`is one of`} ${a.join(`, `)}. Click the bar again to take it out.`:`Clicked ${n} in “${r}” again: ${n} is taken out of the filter on ${t}${a.length===0?`, which is now cleared`:``}.`,{tile:e.id,column:t,value:n,filters:i})}})]},e.id)})});return(0,qW.jsxs)(`div`,{className:[`sf-report`,e.className].filter(Boolean).join(` `),"data-mode":m,children:[(0,qW.jsxs)(`header`,{className:`sf-report-head`,children:[m===`build`?(0,qW.jsx)(`input`,{className:`sf-report-title`,"aria-label":z(`report.title`),placeholder:z(`report.untitledReport`),value:u.title??``,onChange:e=>d({...u,title:e.target.value||void 0})}):(0,qW.jsx)(`h3`,{className:`sf-report-title`,children:u.title||z(`report.untitledReport`)}),(0,qW.jsx)(VW,{label:z(`report.mode`),value:m,onChange:h,options:[{value:`build`,label:z(`report.build`)},{value:`view`,label:z(`report.view`)}]})]}),i?.dataset&&(0,qW.jsx)(cW,{model:i,compact:!0}),m===`build`&&(0,qW.jsxs)(`section`,{className:`sf-report-builder`,"aria-label":z(`report.builder`),children:[x&&(0,qW.jsxs)(`p`,{className:`sf-report-editing`,role:`status`,children:[z(`report.changing`,{title:C(x)}),` `,(0,qW.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>(d({...u,editing:void 0}),_(z(`report.leftAsItWas`))),children:z(`report.leaveAsItWas`)})]}),(0,qW.jsx)(yW,{dataSource:s,sourceId:a,sql:o,model:i,onPromote:e.onPromote,value:b,onChange:e=>d(jW(u,e)),onAsk:n?e=>n(e,u):void 0,editor:r,onContext:e.onContext,chartHeight:240,controls:[{id:`keep`,label:z(x?`report.updateView`:`report.addToReport`),icon:x?`confirm`:`add`,onSelect:w,disabled:S,pinned:!0}]})]}),(0,qW.jsxs)(`section`,{className:`sf-report-body`,"aria-label":z(`report.body`),children:[m===`view`&&u.fields.length>0&&(0,qW.jsx)(hU,{dataSource:s,sourceId:a,sql:o,filters:u.filters,onChange:e=>d({...u,filters:e}),onContext:e.onContext}),u.tiles.length===0?(0,qW.jsx)(`p`,{className:`sf-explore-empty`,children:z(m===`build`?`report.emptyBuild`:`report.emptyView`)}):T]}),(0,qW.jsx)(`p`,{className:`sf-explore-note`,role:`status`,children:g})]})}function KW(e){return kW(e,e.draft??{rows:[],values:[]})}var qW,JW,YW=n((()=>{qW=WA(),JW=NM(),HA(),vI(),WW(),rw(),GN(),vU(),OW(),fW(),BW()}));function XW(e){let t=(0,QW.useContext)($W);return NN(`Semantics`,e??t)}function ZW(e,t={}){let n=XW(t.semantics),r=t.editor??`you`,[i,a]=(0,QW.useState)(),[o,s]=(0,QW.useState)(),[c,l]=(0,QW.useState)(!1),[u,d]=(0,QW.useState)(!1),[f,p]=(0,QW.useState)(0);(0,QW.useEffect)(()=>{if(!e)return a(void 0);if(!n)return s(`There is no store of semantic models here, so "${e}" cannot be read.`);let t=!0;return l(!0),n.getSemanticModel({name:e}).then(e=>t&&(a(e.model),s(void 0),d(!1))).catch(e=>t&&(s(aP(e)),d(/no semantic model|not found/i.test(aP(e))))).finally(()=>t&&l(!1)),()=>{t=!1}},[n,e,f]);let m=(0,QW.useCallback)(async(e,t)=>{if(n)try{let o=await n.saveSemanticModel({model:{...e,savedBy:r},expectedVersion:i?.version??e.version,note:t});return a(o.model),s(void 0),d(!1),o.model}catch(e){(e instanceof hC||/saved by someone else/.test(aP(e)))&&p(e=>e+1),s(aP(e));return}},[n,r,i?.version]);return{model:i,problem:o,missing:u,loading:c,promote:(0,QW.useCallback)(async(e,t)=>{if(!i)return`There is no model to add it to.`;let n=[...i.dimensions,...i.measures,...i.metrics].some(t=>t.name===e.id),a=await m(ZU(i,e,t,r),`${n?`Changed`:`Added`} ${e.label}`);return a?`${e.label} ${n?`changed in`:`added to`} the ${a.label||a.name} model (version ${a.version}). Every report on it now uses this definition.`:`${e.label} was not saved to the model.`},[i,m,r]),save:m,reload:()=>p(e=>e+1)}}var QW,$W,eG=n((()=>{WA(),rw(),zN(),QW=NM(),cP(),oW(),$W=(0,QW.createContext)(void 0)}));function tG(e){return e.map(e=>({left:e.left,right:e.right,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),type:fG(e.type),...e.definedBy===`inferred from names`?{inferred:!0}:{},...e.definedBy===`declared by the source`?{declared:!0}:{}}))}function nG(e,t,n,r){let i=new Map(tG(e.joins).map((t,n)=>[pz(t),e.joins[n].definedBy])),a=t.joins.map(e=>ym(hS,{left:e.left,right:e.right,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),type:dG(e.type),definedBy:e.inferred?sG:e.declared?cG:(e=>e&&e!==`inferred from names`?e:n)(i.get(pz(e)))}));return ym(pS,{...e,tables:t.tables,joins:a,sql:r?.sql??rG(t).sql})}function rG(e){return yz({tables:e.tables,joins:e.joins.filter(e=>!e.inferred)})}function iG(e){let{model:t,columns:n,onChange:r,editor:i,dataSource:a}=e,o=(0,oG.useId)(),s=!!r,c=t.tables.length>0,[l,u]=(0,oG.useState)(),d=l??(!c&&!!t.sql.trim()&&!e.building),[f,p]=(0,oG.useState)(),[m,h]=(0,oG.useState)(!1),g=n.map(e=>e.name),_=c?rG({tables:t.tables,joins:tG(t.joins)}).unjoined:[],v=t.joins.filter(e=>e.definedBy===sG),y=[...t.dimensions.map(e=>e.column),...t.measures.map(e=>e.column)].filter(Boolean),[b,x]=(0,oG.useState)(()=>({tables:t.tables,joins:tG(t.joins)})),[S,C]=(0,oG.useState)(0),w=(0,oG.useRef)(pG(t)),T=pG(t);(0,oG.useEffect)(()=>{w.current!==T&&(w.current=T,x({tables:t.tables,joins:tG(t.joins)}),C(e=>e+1))},[T]);let E=(e,n)=>r?.(ym(pS,{...t,...e}),n),D=e=>{let n=t.primaryKey.includes(e)?t.primaryKey.filter(t=>t!==e):[...t.primaryKey,e];p(void 0),E({primaryKey:n},n.length?`The key is now ${n.join(`, `)}.`:`The model has no key yet.`)},O=async()=>{h(!0);try{let e=await cC(t,a);p(e?{ok:!1,text:e}:{ok:!0,text:`Unique: each ${t.primaryKey.join(` and `)} names one row, so sums count each row once.`})}catch(e){p({ok:!1,text:aP(e)})}finally{h(!1)}};return(0,aG.jsxs)(`section`,{className:`sf-semantic-section sf-semantic-rows`,"aria-labelledby":`${o}-rows`,children:[(0,aG.jsx)(`h4`,{id:`${o}-rows`,className:`sf-explore-heading`,children:(0,aG.jsx)(`span`,{children:`Rows`})}),(0,aG.jsx)(`p`,{className:`sf-explore-hint`,children:`What one row is, and where the rows come from. Sums are right only when each row is one thing.`}),(0,aG.jsxs)(`div`,{className:`sf-semantic-grain`,children:[(0,aG.jsx)(`label`,{htmlFor:`${o}-grain`,children:`One row is`}),s?(0,aG.jsx)(`input`,{id:`${o}-grain`,className:`sf-input`,placeholder:`One order line.`,value:t.grain,onChange:e=>E({grain:e.target.value}),onBlur:e=>e.target.value.trim()&&E({grain:e.target.value},`One row is now: ${e.target.value.trim()}`)}):(0,aG.jsx)(`span`,{id:`${o}-grain`,children:t.grain||`not said yet`})]}),(0,aG.jsxs)(`div`,{className:`sf-semantic-key`,children:[(0,aG.jsx)(`span`,{id:`${o}-key`,children:`Unique by`}),t.primaryKey.length>0?(0,aG.jsx)(`span`,{className:`sf-semantic-chips`,"aria-labelledby":`${o}-key`,children:t.primaryKey.map(e=>(0,aG.jsx)(`code`,{children:e},e))}):(0,aG.jsx)(`span`,{className:`sf-explore-hint`,children:`no key yet`}),s&&g.length>0&&(0,aG.jsxs)(`details`,{className:`sf-semantic-pick`,children:[(0,aG.jsx)(`summary`,{children:`Choose the key`}),(0,aG.jsxs)(`fieldset`,{children:[(0,aG.jsx)(`legend`,{className:`sf-a2-visually-hidden`,children:`Columns that make a row unique`}),g.map(e=>(0,aG.jsxs)(`label`,{className:`sf-semantic-option`,children:[(0,aG.jsx)(`input`,{type:`checkbox`,checked:t.primaryKey.includes(e),onChange:()=>D(e)}),` `,e]},e))]})]}),t.primaryKey.length>0&&t.sql.trim()&&(0,aG.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:m,onClick:()=>void O(),children:m?`Checking…`:`Check the key`})]}),f&&(0,aG.jsx)(`p`,{className:f.ok?`sf-explore-hint`:`sf-filter-problem`,role:f.ok?`status`:`alert`,children:f.text}),s&&!d?(0,aG.jsxs)(aG.Fragment,{children:[(0,aG.jsx)(`p`,{className:`sf-explore-hint`,children:`Tables and joins. The first table is where the rows come from; each join adds detail to it and says whether it keeps every row and whether it can repeat rows.`}),(0,aG.jsx)(Tz,{sourceId:t.sourceId,tables:b.tables,joins:b.joins,height:400,rowsFrom:!0,usedColumns:y,label:`The model's tables and joins`,dataSource:a,onChange:(e,n)=>{let a=nG(t,e,i,n),o=pG(a)===pG(t);if(o&&(a.sql===t.sql||t.version>0))return;w.current=pG(a);let s=e.joins.map(e=>`${mz(e)} keeps ${hz(e,e.type??`inner`).toLowerCase()}`);r?.(a,o?void 0:`The rows now come from ${e.tables.join(`, `)||`no table`}${s.length?`: ${s.join(`; `)}`:``}.`)}},S),v.length>0&&(0,aG.jsxs)(`p`,{className:`sf-result-notice`,children:[v.length,` inferred `,v.length===1?`join is`:`joins are`,` a guess from names: confirm `,v.length===1?`it`:`them`,` in the joins to use `,v.length===1?`it`:`them`,`.`]})]}):c?(0,aG.jsxs)(`div`,{className:`sf-semantic-from`,children:[(0,aG.jsxs)(`p`,{children:[`From `,(0,aG.jsx)(`code`,{children:t.tables[0]}),t.tables.length>1?(0,aG.jsxs)(aG.Fragment,{children:[`, with the detail of`,` `,t.tables.slice(1).map((e,t)=>(0,aG.jsxs)(`span`,{children:[t>0&&`, `,(0,aG.jsx)(`code`,{children:e})]},e))]}):` alone`,`. The first table's rows are the model's rows.`]}),t.joins.length>0&&(0,aG.jsx)(`ul`,{className:`sf-semantic-joins`,children:tG(t.joins).map((e,n)=>(0,aG.jsxs)(`li`,{"data-inferred":e.inferred||void 0,children:[(0,aG.jsx)(`code`,{children:mz(e)}),` `,(0,aG.jsxs)(`span`,{className:`sf-semantic-format`,children:[`· keeps `,hz(e,e.type??`inner`).toLowerCase(),` · `,e.inferred?`Inferred, not in the query until confirmed`:t.joins[n].definedBy||`—`]})]},pz(e)))}),_.length>0&&(0,aG.jsxs)(`p`,{className:`sf-result-notice`,children:[`Not joined to the first table, so left out: `,_.join(`, `),`.`]})]}):(0,aG.jsx)(`p`,{children:t.sql.trim()?`Written as a query.`:`No rows yet: add a table, or write the query.`}),(0,aG.jsxs)(`details`,{className:`sf-semantic-query`,children:[(0,aG.jsx)(`summary`,{children:`The query`}),t.sql.trim()?(0,aG.jsx)(VL,{code:t.sql,language:`sql`,label:`The model's query`}):(0,aG.jsx)(`p`,{className:`sf-explore-hint`,children:`No query yet: add a table, or write one.`})]}),s&&(0,aG.jsx)(`div`,{className:`sf-semantic-actions`,children:(0,aG.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-expanded":d,onClick:()=>u(!d),children:d?`Build from tables instead`:`Write the query instead`})}),s&&d&&(0,aG.jsxs)(`div`,{className:`sf-semantic-write`,children:[(0,aG.jsx)(`p`,{id:`${o}-sql`,children:`The model's query, one read-only SELECT`}),(0,aG.jsx)(`div`,{onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||E({},`The query was rewritten.`)},children:(0,aG.jsx)(DF,{value:t.sql,onChange:e=>E({sql:e,tables:[],joins:[]}),label:`The model's query, one read-only SELECT`,minHeight:120,maxHeight:320})})]})]})}var aG,oG,sG,cG,lG,uG,dG,fG,pG,mG=n((()=>{aG=WA(),zb(),rw(),vS(),oG=NM(),cP(),Bz(),qL(),kF(),sG=`inferred from names`,cG=`declared by the source`,lG={[Kx.UNSPECIFIED]:`inner`,[Kx.INNER]:`inner`,[Kx.LEFT]:`left`,[Kx.RIGHT]:`right`,[Kx.FULL]:`full`},uG={inner:Kx.INNER,left:Kx.LEFT,right:Kx.RIGHT,full:Kx.FULL},dG=e=>uG[e??`inner`],fG=e=>lG[e]??`inner`,pG=e=>JSON.stringify([e.tables,tG(e.joins).map(e=>[pz(e),e.type,e.left,!!e.inferred])])}));function hG(e,t){return t.kind===`attribute`?e.dimensions.find(e=>e.name===t.id)?.kind===gS.TIME?`${t.column}, by ${t.grain??`month`}`:t.column??``:t.kind===`metric`?t.column?`${yG[t.aggregate??``]??t.aggregate} of ${t.column}`:`Count of rows`:t.expression??``}function gG(e){let{model:t,onSave:n,editor:r=`you`}=e,i=t.version===0,a=VN(e.dataSource),o=(0,_G.useId)(),[s,c]=(0,_G.useState)(e.defaultDraft),l=e.draft!==void 0||e.onDraftChange?e.draft:s,u=l??t,d=t=>{c(t),e.onDraftChange?.(t)},f=(0,_G.useRef)(e.onContext);f.current=e.onContext;let[p,m]=(0,_G.useState)(``),h=(e,t,n)=>{m(t),f.current?.({kind:e,summary:t,...n?{subject:n}:{}})},[g,_]=(0,_G.useState)([]),[v,y]=(0,_G.useState)();(0,_G.useEffect)(()=>{if(!u.sql.trim()||!u.sourceId)return _([]),y(void 0);let e=new AbortController;return JS(a.execute({sourceId:u.sourceId,query:{baseSql:u.sql,page:{limit:1}}},{signal:e.signal})).then(t=>!e.signal.aborted&&(_(t.table.schema.fields),y(void 0))).catch(t=>!e.signal.aborted&&y(aP(t))),()=>e.abort()},[a,u.sourceId,u.sql]);let b=IB(e.pipelines),[x,S]=(0,_G.useState)([]),[C,w]=(0,_G.useState)(``);(0,_G.useEffect)(()=>{if(!i||!n||!b)return;let e=new AbortController,r={signal:e.signal};return b.listPipelines({},r).then(e=>Promise.all(e.pipelines.filter(e=>!t.sourceId||e.sourceId===t.sourceId).map(e=>b.getPipeline({id:e.id},r).then(e=>e.pipeline)))).then(t=>!e.signal.aborted&&S(t.filter(e=>!!e&&e.datasets.some(e=>e.kind!==Qx.SOURCE)))).catch(()=>!e.signal.aborted&&S([])),()=>e.abort()},[b,i,!!n,t.sourceId]);let T=()=>{let[e,t]=C.split(`:`).map(Number),n=x[e??-1],r=n?.datasets[t??-1]?.name,i=n?.summary?.id??``;if(!n||!r)return;let a=TC(n,r,{...u.name?{name:u.name}:{},...u.label?{label:u.label}:{}});u.description&&(a.description=u.description),se(a),de(!0),h(`rows.changed`,`Started from the dataset ${r} of ${AC(n.summary?.name||i)}: its grain, key and ${a.dimensions.length+a.measures.length} fields from its columns, for you to check.`,{pipeline:i,dataset:r})},E=(0,_G.useMemo)(()=>qU(u),[u]),D=(0,_G.useMemo)(()=>l?eW(t,l):new Map,[t,l]),O=(0,_G.useMemo)(()=>qU(t).filter(e=>D.get(e.id)===`removed`),[t,D]),k=g.map(e=>e.name),ee=(0,_G.useMemo)(()=>{let e=l?mC(l,{isNew:i}):[];if(g.length>0)for(let t of E)t.column&&!k.includes(t.column)&&e.push(`"${t.id}" names the column "${t.column}", which the query does not return.`);return e},[l,E,g]),[te,A]=(0,_G.useState)(),[ne,re]=(0,_G.useState)(``),[ie,ae]=(0,_G.useState)(!1),oe=e=>({id:``,kind:e,label:``,by:r,...e===`metric`?{aggregate:`sum`,column:g.find(e=>/Int|Float|Decimal/.test(String(e.type)))?.name}:e===`attribute`?{column:g[0]?.name}:{expression:``,format:`number`}}),se=e=>d(!i&&eW(t,e).size===0?void 0:e),ce=(e,t)=>se($U(u,e,t,r)),le=e=>se(ym(pS,{...u,...e})),[ue,de]=(0,_G.useState)(!i||!!t.name),fe=()=>{let e=new Set(OV(g.map(e=>e.name)).map(e=>e.column)),t=sC(g.map(t=>({name:t.name,type:String(t.type),personal:e.has(t.name)})),{grain:u.grain}),n=Hh(pS,u);n.dimensions=(t.dimensions??[]).map(e=>ym(dS,e)),n.measures=(t.measures??[]).map(e=>ym(fS,e)),se(n),h(`fields.drafted`,`Fields drafted from the query's ${g.length} columns by name and type${e.size?`, leaving out ${e.size} that may hold personal data`:``}. Check them before saving.`)},[pe,me]=(0,_G.useState)(``),he=()=>{let t=pe.trim();t&&e.onAsk&&(e.onAsk(t,u),me(``),m(`Sent to ${e.askLabel??`the agent`}.`))},ge=e=>{let n=qU(t).find(t=>t.id===e);n&&(ce(e,n),h(`field.restored`,`${n.label} put back as it is saved.`,{field:e}))},j=async()=>{if(!(!l||!n||ee.length>0)){ae(!0);try{let e=await n(l,ne.trim()||`${D.size} ${D.size===1?`change`:`changes`}`);e&&(d(void 0),re(``),h(`model.saved`,`Saved as version ${e.version}. Every report and explorer on this model now uses it.`,{model:e.name,version:e.version,changes:Object.fromEntries(D)}))}catch(e){m(aP(e))}finally{ae(!1)}}},_e=e.onAsk&&(0,W.jsxs)(`form`,{className:`sf-semantic-ask`,onSubmit:e=>{e.preventDefault(),he()},children:[(0,W.jsx)(`label`,{htmlFor:`${o}-ask`,children:i?`Tell ${e.askLabel??`the agent`} what this model should measure; it drafts the tables, joins, grain and fields for you to check.`:`Ask ${e.askLabel??`the agent`} to change this model.`}),(0,W.jsxs)(`span`,{className:`sf-semantic-ask-row`,children:[(0,W.jsx)(`input`,{id:`${o}-ask`,className:`sf-input`,placeholder:i?`Order lines with their store and product, to measure revenue and refunds`:`Add margin as a share of revenue`,value:pe,onChange:e=>me(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:!pe.trim(),children:`Ask`})]})]}),ve=e=>{let i=[...E.filter(t=>t.kind===e),...O.filter(t=>t.kind===e)];return(0,W.jsxs)(`section`,{className:`sf-semantic-section`,"aria-labelledby":`${o}-${e}`,children:[(0,W.jsxs)(`h4`,{id:`${o}-${e}`,className:`sf-explore-heading`,children:[(0,W.jsxs)(`span`,{children:[vG[e].title,` `,(0,W.jsx)(`span`,{className:`sf-semantic-count`,children:E.filter(t=>t.kind===e).length})]}),n&&(0,W.jsx)(`button`,{type:`button`,className:`sf-explore-add`,"aria-label":`Add a ${vG[e].one}`,onClick:()=>A({pill:oe(e),isNew:!0}),children:`+`})]}),(0,W.jsx)(`p`,{className:`sf-explore-hint`,children:vG[e].hint}),i.length===0?(0,W.jsx)(`p`,{className:`sf-explore-hint`,children:`None yet.`}):(0,W.jsxs)(`table`,{className:`sf-semantic-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,children:`Label`}),(0,W.jsx)(`th`,{scope:`col`,children:`Name`}),(0,W.jsx)(`th`,{scope:`col`,children:e===`derived`?`Calculation`:`Definition`}),(0,W.jsx)(`th`,{scope:`col`,children:`Defined by`}),n&&(0,W.jsx)(`th`,{scope:`col`,children:(0,W.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:`Controls`})})]})}),(0,W.jsx)(`tbody`,{children:i.map(e=>{let i=D.get(e.id),a=i===`removed`;return(0,W.jsxs)(`tr`,{className:_I,"data-change":i,children:[(0,W.jsxs)(`th`,{scope:`row`,children:[e.label,i&&(0,W.jsx)(`span`,{className:`sf-semantic-change`,children:bG[i]}),e.description&&(0,W.jsx)(`span`,{className:`sf-semantic-description`,children:e.description})]}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`code`,{children:e.id})}),(0,W.jsxs)(`td`,{children:[(0,W.jsx)(`code`,{children:hG(a?t:u,e)}),e.format&&(0,W.jsxs)(`span`,{className:`sf-semantic-format`,children:[` · `,e.format]})]}),(0,W.jsx)(`td`,{children:QU(a?t:u,e.id)?.definedBy||`—`}),n&&(0,W.jsx)(`td`,{children:a?(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>ge(e.id),children:`Put back`}):(0,W.jsx)(fI,{label:`${e.label} controls`,controls:pI(e.label,{edit:()=>A({pill:e,isNew:!1}),duplicate:()=>A({pill:{...e,label:`${e.label} copy`,by:r},isNew:!0}),remove:()=>{ce(e.id,void 0),h(`field.removed`,`${e.label} taken out of the draft. Save to remove it from the model.`,{field:e.id})}})})})]},e.id)})})]})]},e)};return(0,W.jsxs)(`div`,{className:[`sf-semantic`,e.className].filter(Boolean).join(` `),children:[(0,W.jsxs)(`header`,{className:`sf-semantic-header`,children:[i&&n?(0,W.jsxs)(`div`,{className:`sf-semantic-identity`,children:[(0,W.jsx)(`h3`,{className:`sf-semantic-title`,children:`New model`}),(0,W.jsx)(`label`,{htmlFor:`${o}-label`,children:`Name for people`}),(0,W.jsx)(`input`,{id:`${o}-label`,className:`sf-input`,placeholder:`Sales lines`,value:u.label,onChange:e=>le({label:e.target.value,...ue?{}:{name:CG(e.target.value)}})}),(0,W.jsx)(`label`,{htmlFor:`${o}-name`,children:`Name in calculations and files`}),(0,W.jsx)(`input`,{id:`${o}-name`,className:`sf-input`,placeholder:`sales_lines`,value:u.name,onChange:e=>(de(!0),le({name:e.target.value}))}),(0,W.jsx)(`label`,{htmlFor:`${o}-about`,children:`What it is for`}),(0,W.jsx)(`input`,{id:`${o}-about`,className:`sf-input`,placeholder:`Revenue, cost and refunds by store and product.`,value:u.description,onChange:e=>le({description:e.target.value})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`sf-semantic-title`,children:u.label||u.name}),u.description&&(0,W.jsx)(`p`,{className:`sf-semantic-description`,children:u.description})]}),(0,W.jsxs)(`p`,{className:`sf-explore-hint`,children:[u.name?(0,W.jsx)(`code`,{children:u.name}):`Not named yet`,` on `,t.sourceId,i?` · not saved yet`:` · version ${t.version}`,t.savedBy&&` · saved by ${t.savedBy}`,t.updatedAt&&` on ${t.updatedAt.slice(0,10)}`]}),v&&(0,W.jsxs)(`p`,{className:`sf-filter-problem`,role:`alert`,children:[`The query does not run: `,v]})]}),i&&n&&x.length>0&&!u.dataset&&(0,W.jsxs)(`div`,{className:`sf-semantic-actions sf-semantic-from-dataset`,children:[(0,W.jsx)(`label`,{htmlFor:`${o}-dataset`,children:`Start from a pipeline dataset`}),(0,W.jsxs)(`select`,{id:`${o}-dataset`,className:`sf-input`,value:C,onChange:e=>w(e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Choose a dataset…`}),x.map((e,t)=>(0,W.jsx)(`optgroup`,{label:e.summary?.name||e.summary?.id,children:e.datasets.map((e,n)=>e.kind===Qx.SOURCE?null:(0,W.jsxs)(`option`,{value:`${t}:${n}`,children:[e.name,e.grain?` · ${e.grain}`:``,e.builtAt?``:` · not built yet`]},e.name))},e.summary?.id))]}),(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,disabled:!C,onClick:T,children:`Use this dataset`}),(0,W.jsx)(`span`,{className:`sf-explore-hint`,children:`Its grain and key are checked by the pipeline after every build; its columns become fields for you to check.`})]}),(0,W.jsx)(cW,{model:u,pipelines:b,onOpenDataset:e.onOpenDataset,onUseDataset:n?e=>{se(ym(pS,{...u,sourceId:u.sourceId,sql:wC({name:e.dataset,relation:e.relation??``}),grain:e.grain||u.grain,primaryKey:e.primaryKey})),h(`rows.changed`,`The grain and key are the dataset's again: ${e.primaryKey.join(`, `)}.`,{grain:e.grain,primaryKey:e.primaryKey})}:void 0}),i&&_e,(0,W.jsx)(iG,{model:u,columns:g,editor:r,dataSource:a,building:e.building&&!u.dataset,onChange:n?(e,t)=>{e.dataset&&(e.tables.length>0||e.sql!==u.sql)&&(e=ym(pS,{...e,dataset:void 0})),se(e),t&&h(`rows.changed`,t,{grain:e.grain,primaryKey:e.primaryKey,tables:e.tables})}:void 0}),n&&g.length>0&&u.dimensions.length===0&&u.measures.length===0&&(0,W.jsxs)(`p`,{className:`sf-semantic-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:fe,children:`Draft fields from the columns`}),(0,W.jsx)(`span`,{className:`sf-explore-hint`,children:`Dimensions and measures from the columns' names and types, marked as generated, for you to check.`})]}),l&&(0,W.jsxs)(`div`,{className:`sf-semantic-draft`,role:`region`,"aria-label":`Changes not saved`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:i?`New model, not saved`:`${D.size} ${D.size===1?`change`:`changes`} not saved`}),e.proposedBy?`, proposed by ${e.proposedBy}. Read ${i?`it`:`them`} before saving.`:`.`,` `,i?`${u.dimensions.length} dimensions, ${u.measures.length} measures, ${u.metrics.length} metrics.`:[...D].map(SG).join(`, `)]}),(ee.length>0||e.problem)&&(0,W.jsx)(`ul`,{className:`sf-filter-problem`,role:`alert`,children:[...ee,...e.problem?[e.problem]:[]].map(e=>(0,W.jsx)(`li`,{children:e},e))}),n&&(0,W.jsxs)(`div`,{className:`sf-semantic-actions`,children:[(0,W.jsx)(`label`,{htmlFor:`${o}-note`,className:`sf-a2-visually-hidden`,children:`What changed`}),(0,W.jsx)(`input`,{id:`${o}-note`,className:`sf-input`,placeholder:`What changed, in a few words`,value:ne,onChange:e=>re(e.target.value)}),(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,disabled:ee.length>0||ie,onClick:()=>void j(),children:ie?`Saving…`:`Save as version ${t.version+1}`}),(0,W.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{d(void 0),h(`draft.discarded`,i?`The new model was cleared, to start again.`:`${D.size} ${D.size===1?`change`:`changes`} dropped; the model is as saved.`)},children:i?`Start again`:`Drop changes`})]})]}),te&&(0,W.jsx)(vW,{pill:te.pill,all:E,columns:g,isNew:te.isNew,onCancel:()=>A(void 0),onSave:e=>{ce(te.isNew?e.id:te.pill.id,e),h(te.isNew?`field.added`:`field.changed`,`${e.label} ${te.isNew?`added to`:`changed in`} the draft. Save to keep it.`,{field:e,...te.isNew?{}:{was:te.pill}}),A(void 0)},onRemove:te.isNew?void 0:()=>{ce(te.pill.id,void 0),h(`field.removed`,`${te.pill.label} taken out of the draft. Save to remove it from the model.`,{field:te.pill.id}),A(void 0)}},`${te.pill.id}-${te.isNew}`),[`attribute`,`metric`,`derived`].map(ve),!i&&_e,(0,W.jsx)(`p`,{className:`sf-explore-note`,role:`status`,children:p})]})}var W,_G,vG,yG,bG,xG,SG,CG,wG=n((()=>{W=WA(),zb(),rw(),vS(),_G=NM(),vI(),GN(),cP(),QB(),NV(),fW(),OW(),oW(),mG(),vG={attribute:{title:`Dimensions`,one:`dimension`,hint:`Ways to break the rows down: a category, or a date grouped by month.`},metric:{title:`Measures`,one:`measure`,hint:`A column summarised: a sum, an average, a count.`},derived:{title:`Metrics`,one:`metric`,hint:`Arithmetic over measures, worked out by the database after summarising: a rate, a margin.`}},yG={sum:`Sum`,avg:`Average`,count:`Count`,count_distinct:`Distinct count`,min:`Smallest`,max:`Largest`,median:`Median`,stddev:`Standard deviation`,variance:`Variance`},bG={added:`Added`,changed:`Changed`,removed:`Removed`},xG={"(name)":`the name`,"(label)":`the label`,"(description)":`the description`,"(sql)":`the query`,"(grain)":`what one row is`,"(primaryKey)":`the key`,"(joins)":`the tables and joins`,"(dataset)":`the pipeline dataset`},SG=([e,t])=>xG[e]?`Changed ${xG[e]}`:`${bG[t]} ${e}`,CG=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^[^a-z]+|_+$/g,``).slice(0,64)}));function TG(e,t,n){let r=e;for(let e of t.remove??[])r=$U(r,e,void 0,n);for(let e of t.add??[])r=$U(r,e.id,e,e.by||n);let i=t.rows;return i&&(r=Hh(pS,r),i.grain!==void 0&&(r.grain=i.grain),i.primaryKey!==void 0&&(r.primaryKey=[...i.primaryKey]),(i.tables!==void 0||i.joins!==void 0)&&(r.tables=[...i.tables??r.tables],r.joins=(i.joins??[]).map(e=>ym(hS,{left:e.left,right:e.right,keys:e.keys,type:dG(e.type??`left`),definedBy:n})),r.sql=rG({tables:r.tables,joins:r.joins.map(e=>({left:e.left,right:e.right,keys:e.keys,type:fG(e.type)}))}).sql),i.sql!==void 0&&(r.sql=i.sql,i.tables===void 0&&(r.tables=[],r.joins=[])),i.dataset?(r.dataset=ym(mS,{pipelineId:i.dataset.pipeline,dataset:i.dataset.dataset}),r.sql=wC(i.dataset.dataset),r.tables=[],r.joins=[]):(i.sql!==void 0||i.tables!==void 0)&&(r.dataset=void 0)),r}function EG(e,t){let n=eW(e,t),r=new Map(qU(t).map(e=>[e.id,e])),i={add:[...n].filter(([e,t])=>t!==`removed`&&r.has(e)).map(([e])=>r.get(e)),remove:[...n].filter(([,e])=>e===`removed`).map(([e])=>e)},a={};return n.has(`(grain)`)&&(a.grain=t.grain),n.has(`(primaryKey)`)&&(a.primaryKey=t.primaryKey),n.has(`(joins)`)&&(a.tables=t.tables,a.joins=t.joins.map(e=>({left:e.left,right:e.right,keys:e.keys.map(e=>({leftColumn:e.leftColumn,rightColumn:e.rightColumn})),type:fG(e.type)}))),t.dataset&&n.has(`(dataset)`)?a.dataset={pipeline:t.dataset.pipelineId,dataset:t.dataset.dataset}:n.has(`(sql)`)&&t.tables.length===0&&(a.sql=t.sql),Object.keys(a).length>0&&(i.rows=a),i}var DG=n((()=>{zb(),vS(),oW(),mG(),rw()})),OG=n((()=>{})),kG=n((()=>{})),AG=n((()=>{WA(),NM()})),jG=n((()=>{WA(),NM()})),MG=n((()=>{WA()})),NG=n((()=>{WA(),NM()})),PG=n((()=>{WA(),NM()})),FG=n((()=>{WA(),NM()})),IG=n((()=>{WA()})),LG=n((()=>{WA()})),RG=n((()=>{})),zG=n((()=>{HA(),qA(),GM(),KM(),GN(),rP(),cP(),lP(),mP(),PP(),EF(),cF(),kF(),jF(),uI(),jI(),KI(),cR(),GF(),mR(),yR(),DR(),PR(),KR(),VR(),XR(),Bz(),qL(),IL(),qz(),Jz(),$z(),rB(),OB(),fz(),$I(),oL(),QB(),FB(),cV(),zP(),vV(),SV(),dV(),DV(),zV(),NV(),UV(),YV(),yP(),$F(),rw(),iH(),SH(),EH(),PH(),JH(),YH(),XH(),rI(),cU(),mU(),vU(),KU(),OW(),BW(),YW(),oW(),eG(),wG(),mG(),fW(),DG(),vI(),OG(),AG(),WW(),jG(),MG(),NG(),PG(),FG(),IG(),LG(),kG(),RG()}));zG();function BG(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function VG(e,t=`|`){return e.map(e=>lK(e)).join(t)}function HG(e,t){return typeof t==`bigint`?t.toString():t}function UG(e){return new VK(e)}function WG(e){return e==null}function GG(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function KG(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function qG(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==HK)return r===void 0&&(r=HK,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function JG(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function YG(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function XG(e){return YG(e._zod.def)??e._zod.def.shape}function ZG(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return JG(this,t,e),e},enumerable:!0,configurable:!0})}function QG(e,t,n){t in e?JG(e,t,n):e[t]=n}function $G(e,t,n,r){let i=XG(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?ZG(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):QG(e,a,r?r(n.value,a):n.value))}}function eK(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?ZG(e,n,()=>t[n]):QG(e,n,r.value))}}function tK(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function nK(e){return JSON.stringify(e)}function rK(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function iK(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function aK(e){if(iK(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return iK(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function oK(e){return aK(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function sK(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function cK(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function G(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function lK(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function uK(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}function dK(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return $G(i,e,fK(e,t)),cK(e,tK(n,{shape:i,checks:[]}))}function fK(e,t){let n=XG(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function pK(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(fK(e,t)),a={};return $G(a,e,Reflect.ownKeys(XG(e)).filter(e=>!i.has(e))),cK(e,tK(n,{shape:a,checks:[]}))}function mK(e,t){if(!aK(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=XG(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return cK(e,tK(e._zod.def,{shape:hK(e,t)}))}function hK(e,t){let n={};return $G(n,e,Reflect.ownKeys(XG(e))),eK(n,t),n}function gK(e,t){if(!aK(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return cK(e,tK(e._zod.def,{shape:hK(e,t)}))}function _K(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return $G(n,e,Reflect.ownKeys(XG(e))),$G(n,t,Reflect.ownKeys(XG(t))),cK(e,tK(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function vK(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(fK(t,n)):void 0,o={};return $G(o,t,Reflect.ownKeys(XG(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),cK(t,tK(t._zod.def,{shape:o,checks:[]}))}function yK(e,t,n){let r=n?new Set(fK(t,n)):void 0,i={};return $G(i,t,Reflect.ownKeys(XG(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),cK(t,tK(t._zod.def,{shape:i}))}function bK(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function xK(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function SK(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function CK(e){return typeof e==`string`?e:e?.message}function wK(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function TK(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function EK(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:CK(e.inst?._zod.def?.error?.(e))??CK(a?.(e))??CK(t?.error?.(e))??CK(n.customError?.(e))??CK(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}function DK(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function OK(e){let t=e.length;if(!YK.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function kK(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function AK(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function jK(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function MK(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):IK(e,n,r.value)}}function NK(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function PK(e,t,n){return NK(e,t,n,!1)}function FK(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return NK(this,n,r(this))},set(e){NK(this,n,e)}})}return t}function IK(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:NK(this,t,n.bind(this))},set(e){NK(this,t,e)}})}function LK(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}function RK(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&XK!==e._zod?XK=void 0:(XK=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,QK);let e=ZK;ZK=!1;try{let r=n(this);return ZK?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),ZK||=e,r}catch(n){throw delete this[t],ZK||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function zK(e,t,n,r){let i=LK(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function BK(e){let t=()=>e;return t[$K]=!0,t}var VK,HK,UK,WK,GK,KK,qK,JK,YK,XK,ZK,QK,$K,eq=n((()=>{lq(),VK=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}},HK=Symbol(`evaluating`),UK=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},WK=UG(()=>{if(cq.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),GK=new Set([`string`,`number`,`symbol`]),KK=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]),qK={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},JK={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]},YK=/[\uD800-\uDBFF]/,ZK=!1,QK={configurable:!0,get(){ZK=!0}},$K=`~constantCatch`}));function tq(e){let t=aq;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return aq=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function K(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){iq.value=new a(r);try{Object.defineProperty(n,"_zod",iq)}finally{iq.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),MK(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?tq(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}function nq(e){return e&&Object.assign(cq,e),cq}var rq,iq,aq,oq,sq,cq,lq=n((()=>{eq(),iq={value:void 0,enumerable:!1},aq=`captureStackTrace`in Error?Error:null,oq=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},sq=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(rq=globalThis).__zod_globalConfig??(rq.__zod_globalConfig={}),cq=globalThis.__zod_globalConfig}));function uq(){let e=this._zod;return e.message??=JSON.stringify(e.def,HG,2),e.message}function dq(e){this._zod.message=e}function fq(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function pq(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?fq(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function mq(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}var hq,gq,_q,vq,yq,bq,xq=n((()=>{lq(),eq(),hq={get:uq,set:dq,enumerable:!0,configurable:!0},gq={value:void 0,enumerable:!1},_q=new WeakSet([Object.prototype,Error.prototype]),vq=(e,t)=>{e.name=`$ZodError`,gq.value=t,Object.defineProperty(e,"issues",gq),gq.value=void 0,Object.defineProperty(e,"message",hq);let n=Object.getPrototypeOf(e);_q.has(n)||(_q.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},yq=K(`$ZodError`,vq),bq=K(`$ZodError`,vq,void 0,{Parent:Error})}));function Sq(e,t){return{callee:t?.callee??e,Err:t?.Err}}function Cq(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>EK(e,n,nq()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}function wq(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Mq]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new oq;return a.issues.length===0}var Tq,Eq,Dq,Oq,kq,Aq,jq,Mq,Nq,Pq,Fq,Iq,Lq,Rq,zq,Bq,Vq,Hq,Uq=n((()=>{lq(),xq(),eq(),Tq=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new oq;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>EK(e,o,nq())));throw UK(n,a?.callee??t),n}return s.value};return t},Eq=Tq(bq),Dq=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>EK(e,o,nq())));throw UK(n,a?.callee??t),n}return s.value};return t},Oq=Dq(bq),kq=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new oq;return a.issues.length?Cq(e,a.issues,i):{success:!0,data:a.value}},Aq=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Cq(e,a.issues,i):{success:!0,data:a.value}},jq=Symbol.for(`zod.compile.invalid`),Mq=Symbol.for(`zod.compile.fallback`),Nq=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==jq)return!0;if(r.definite===!0&&n===void 0)return!1}return wq(e,t,n)}),Pq=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Fq=e=>{let t=Tq(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Sq(n,a))};return n},Iq=e=>{let t=Tq(e),n=(e,r,i,a)=>t(e,r,i,Sq(n,a));return n},Lq=e=>{let t=Dq(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Sq(n,a))};return n},Rq=e=>{let t=Dq(e),n=async(e,r,i,a)=>await t(e,r,i,Sq(n,a));return n},zq=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return kq(e)(t,n,i)},Bq=e=>(t,n,r)=>kq(e)(t,n,r),Vq=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Aq(e)(t,n,i)},Hq=e=>async(t,n,r)=>Aq(e)(t,n,r)})),Wq=i({anyString:()=>FJ,base64:()=>wJ,base64url:()=>TJ,bigint:()=>LJ,boolean:()=>BJ,browserEmail:()=>_J,cidrv4:()=>SJ,cidrv6:()=>CJ,creditCard:()=>AJ,cuid:()=>$q,cuid2:()=>eJ,currencyCode:()=>jJ,date:()=>PJ,datetime:()=>Xq,domain:()=>DJ,duration:()=>aJ,e164:()=>kJ,email:()=>fJ,emoji:()=>Kq,extendedDuration:()=>oJ,guid:()=>sJ,hex:()=>GJ,hostname:()=>EJ,html5Email:()=>pJ,httpProtocol:()=>OJ,iban:()=>MJ,idnEmail:()=>gJ,integer:()=>RJ,ipv4:()=>yJ,ipv6:()=>bJ,ksuid:()=>rJ,lowercase:()=>UJ,mac:()=>xJ,md5_base64:()=>qJ,md5_base64url:()=>JJ,md5_hex:()=>KJ,nanoid:()=>iJ,nanoidOfLength:()=>Gq,null:()=>VJ,number:()=>zJ,rfc5322Email:()=>mJ,sha1_base64:()=>XJ,sha1_base64url:()=>ZJ,sha1_hex:()=>YJ,sha256_base64:()=>$J,sha256_base64url:()=>eY,sha256_hex:()=>QJ,sha384_base64:()=>nY,sha384_base64url:()=>rY,sha384_hex:()=>tY,sha512_base64:()=>aY,sha512_base64url:()=>oY,sha512_hex:()=>iY,string:()=>IJ,time:()=>Yq,ulid:()=>tJ,undefined:()=>HJ,unicodeEmail:()=>hJ,uppercase:()=>WJ,uuid:()=>cJ,uuid4:()=>lJ,uuid6:()=>uJ,uuid7:()=>dJ,xid:()=>nJ});function Gq(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}function Kq(){return new RegExp(vJ,`u`)}function qq(e){return RegExp(`^${e}$`)}function Jq(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Yq(e){return RegExp(`^${Jq(e)}$`)}function Xq(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Jq({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Jq({precision:e.precision})}`:n;return RegExp(`^${NJ}T(?:${r})$`)}function Zq(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Qq(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var $q,eJ,tJ,nJ,rJ,iJ,aJ,oJ,sJ,cJ,lJ,uJ,dJ,fJ,pJ,mJ,hJ,gJ,_J,vJ,yJ,bJ,xJ,SJ,CJ,wJ,TJ,EJ,DJ,OJ,kJ,AJ,jJ,MJ,NJ,PJ,FJ,IJ,LJ,RJ,zJ,BJ,VJ,HJ,UJ,WJ,GJ,KJ,qJ,JJ,YJ,XJ,ZJ,QJ,$J,eY,tY,nY,rY,iY,aY,oY,sY=n((()=>{eq(),$q=/^[cC][0-9a-z]{6,}$/,eJ=/^[0-9a-z]+$/,tJ=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,nJ=/^[0-9a-vA-V]{20}$/,rJ=/^[A-Za-z0-9]{27}$/,iJ=/^[a-zA-Z0-9_-]{21}$/,aJ=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,oJ=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,sJ=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,cJ=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,lJ=cJ(4),uJ=cJ(6),dJ=cJ(7),fJ=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,pJ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,mJ=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,hJ=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,gJ=hJ,_J=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,vJ=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,yJ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,bJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xJ=e=>{let t=sK(e??`:`);return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},SJ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,CJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wJ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,TJ=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,EJ=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,DJ=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,OJ=/^https?$/,kJ=/^\+[1-9]\d{6,14}$/,AJ=/^\d(?:[ -]?\d){11,18}$/,jJ=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,MJ=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,NJ=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,PJ=qq(NJ),FJ=/^[\s\S]{0,}$/,IJ=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},LJ=/^-?\d+n?$/,RJ=/^-?\d+$/,zJ=/^-?\d+(?:\.\d+)?$/,BJ=/^(?:true|false)$/i,VJ=/^null$/i,HJ=/^undefined$/i,UJ=/^[^A-Z]*$/,WJ=/^[^a-z]*$/,GJ=/^[0-9a-fA-F]*$/,KJ=/^[0-9a-fA-F]{32}$/,qJ=Zq(22,`==`),JJ=Qq(22),YJ=/^[0-9a-fA-F]{40}$/,XJ=Zq(27,`=`),ZJ=Qq(27),QJ=/^[0-9a-fA-F]{64}$/,$J=Zq(43,`=`),eY=Qq(43),tY=/^[0-9a-fA-F]{96}$/,nY=Zq(64,``),rY=Qq(64),iY=/^[0-9a-fA-F]{128}$/,aY=Zq(86,`==`),oY=Qq(86)}));function cY(e,t,n){e.issues.length&&t.issues.push(...SK(n,e.issues))}var lY,uY,dY,fY,pY,mY,hY,gY,_Y,vY,yY,bY,xY,SY,CY,wY,TY,EY,DY,OY,kY,AY,jY,MY,NY,PY,FY=n((()=>{lq(),sY(),eq(),lY=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),uY=e=>{let t=e.value;return!WG(t)&&t.size!==void 0},dY=e=>{let t=e.value;return!WG(t)&&t.length!==void 0},fY={number:`number`,bigint:`bigint`,object:`date`},pY=K(`$ZodCheckLessThan`,(e,t)=>{lY.init(e,t);let n=fY[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:fY[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mY=K(`$ZodCheckGreaterThan`,(e,t)=>{lY.init(e,t);let n=fY[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:fY[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hY=K(`$ZodCheckMultipleOf`,(e,t)=>{lY.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):KG(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),gY=K(`$ZodCheckNumberFormat`,(e,t)=>{lY.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=qK[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),_Y=K(`$ZodCheckBigIntFormat`,(e,t)=>{lY.init(e,t);let[n,r]=JK[t.format];e._zod.check=i=>{let a=i.value;a<n&&i.issues.push({origin:`bigint`,input:a,code:`too_small`,minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:`bigint`,input:a,code:`too_big`,maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),vY=K(`$ZodCheckMaxSize`,(e,t)=>{var n;lY.init(e,t),(n=e._zod.def).when??(n.when=uY),e._zod.check=n=>{let r=n.value;r.size<=t.maximum||n.issues.push({origin:DK(r),code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yY=K(`$ZodCheckMinSize`,(e,t)=>{var n;lY.init(e,t),(n=e._zod.def).when??(n.when=uY),e._zod.check=n=>{let r=n.value;r.size>=t.minimum||n.issues.push({origin:DK(r),code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bY=K(`$ZodCheckSizeEquals`,(e,t)=>{var n;lY.init(e,t),(n=e._zod.def).when??(n.when=uY),e._zod.check=n=>{let r=n.value,i=r.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:DK(r),...a?{code:`too_big`,maximum:t.size}:{code:`too_small`,minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),xY=K(`$ZodCheckMaxLength`,(e,t)=>{var n;lY.init(e,t),(n=e._zod.def).when??(n.when=dY),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?OK(r):i)<=t.maximum)return;let a=kK(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),SY=K(`$ZodCheckMinLength`,(e,t)=>{var n;lY.init(e,t),(n=e._zod.def).when??(n.when=dY),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?OK(r):i)>=t.minimum)return;let a=kK(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),CY=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;lY.init(e,t),(n=e._zod.def).when??(n.when=dY),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?OK(r):i;if(a===t.length)return;let o=kK(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),wY=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;lY.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),TY=K(`$ZodCheckRegex`,(e,t)=>{wY.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),EY=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=UJ,wY.init(e,t)}),DY=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=WJ,wY.init(e,t)}),OY=K(`$ZodCheckIncludes`,(e,t)=>{lY.init(e,t);let n=sK(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),kY=K(`$ZodCheckStartsWith`,(e,t)=>{lY.init(e,t);let n=RegExp(`^${sK(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),AY=K(`$ZodCheckEndsWith`,(e,t)=>{lY.init(e,t);let n=RegExp(`.*${sK(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),jY=K(`$ZodCheckProperty`,(e,t)=>{lY.init(e,t),e._zod.check=e=>{let n=t.schema._zod.run({value:e.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(n=>cY(n,e,t.property));cY(n,e,t.property)}}),MY=K(`$ZodCheckProperties`,(e,t)=>{lY.init(e,t),PK(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:`object`,code:`invalid_type`,input:r.value,inst:e});return}n??=Reflect.ownKeys(t.shape).map(e=>[e,t.shape[e]]);let i=r.value,a;for(let[e,t]of n){let n=t._zod.run({value:i[e],issues:[]},{});n instanceof Promise?(a??=[],a.push(n.then(t=>cY(t,r,e)))):cY(n,r,e)}if(a)return Promise.all(a).then(()=>void 0)}}),NY=K(`$ZodCheckMimeType`,(e,t)=>{lY.init(e,t);let n=new Set(t.mime);e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:`invalid_value`,values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),PY=K(`$ZodCheckOverwrite`,(e,t)=>{lY.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),IY,LY=n((()=>{IY=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
45
46
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
46
|
-
`)}\n};`)(...Object.values(this.closed))}}})),AY,jY=n((()=>{AY={major:4,minor:6,patch:7}}));async function MY(e,t){let n={async:!0};return SX(await e._zod.run({value:t,issues:[]},n),n)}function NY(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return SX(r,n)}catch{}return MY(e,t)},vendor:`zod`,version:1}}function PY(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function FY(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?PY(e)||2:IY(e,t)}function IY(e,t){if(!t.normalize&&t.protocol?.source===bJ.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}function LY(e){return e.replace(OX,``)}function RY(e,t){return t.lastIndex=0,t.test(e.hostname)}function zY(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}function BY(e){return HX.test(e)?PY(`http://[${e}]`):!1}function VY(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:BY(n)}function HY(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function UY(e){if(!YX.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return HY(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function WY(e){let t=e.length,n=1,r=0;for(;t;){let i=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][i]:i}return r%10==0}function GY(e){return SJ.test(e)?WY(e.replace(QX,``)):!1}function KY(e){let t=0,n=e.length;for(let r=4;r<n;r++){let n=e.charCodeAt(r);t=(n>=65?t*100+(n-55):t*10+(n-48))%97}for(let n=0;n<4;n++){let r=e.charCodeAt(n);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}return t===1}function qY(e){return wJ.test(e)?KY(e):!1}function JY(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function YY(e,t){let n=gK(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of gK(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,_K(n.issues,t,e),n}}return i(n,a)}}function XY(e,t,n){e.issues.length&&t.issues.push(...mK(n,e.issues)),t.value[n]=e.value}function ZY(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...mK(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}function QY(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:bZ,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=nK(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function $Y(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(fK(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ZY(e,n,i,t,d,f))):ZY(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}function eX(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!fK(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>vK(e,r,JK())))}),t)}function tX(e,t,n,r){let i=[];for(let t=0;t<e.length;t++)e[t].issues.length===0&&i.push(t);return i.length===1?(t.value=e[i[0]].value,t):(i.length===0?t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>vK(e,r,JK())))}):t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}function nX(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}function rX(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ZG(e)&&ZG(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=rX(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=rX(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function iX(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=rX(t.value,n.value);if(!c.valid){if(fK(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}function aX(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function oX(e,t,n){e.issues.length&&t.issues.push(...mK(n,e.issues)),t.value[n]=e.value}function sX(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...mK(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}function cX(e,t,n,r,i,a,o){e.issues.length&&(LK.has(typeof r)?n.issues.push(...mK(r,e.issues)):n.issues.push({code:`invalid_key`,origin:`map`,input:i,inst:a,issues:e.issues.map(e=>vK(e,o,JK()))})),t.issues.length&&(LK.has(typeof r)?n.issues.push(...mK(r,t.issues)):n.issues.push({origin:`map`,code:`invalid_element`,input:i,inst:a,key:r,issues:t.issues.map(e=>vK(e,o,JK()))})),n.value.set(e.value,t.value)}function lX(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function uX(e,t){return e.value=t.issues.length?void 0:t.value,e}function dX(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function fX(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function pX(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>vK(e,r,JK()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}function mX(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function hX(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>gX(e,r,t.out,n)):gX(e,r,t.out,n)}{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>gX(e,r,t.in,n)):gX(e,r,t.in,n)}}function gX(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}function _X(e){return e.memo||(e.value=Object.freeze(e.value)),e}function vX(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes(`int`),i,a;for(let e of t.checks??[]){let t=e._zod.def;t.pattern&&(n=t.pattern),r||=!!t.format?.includes(`int`);let o=t.minimum??t.length,s=t.maximum??t.length;o!==void 0&&(i===void 0||o>i)&&(i=o),s!==void 0&&(a===void 0||s<a)&&(a=s)}if(n)return n.source;if(i!==void 0&&a!==void 0&&i>a)return`(?!)`;if(i!==void 0||a!==void 0)return OJ({minimum:i,maximum:a}).source;let o=e._zod.pattern;return(r&&o===jJ?AJ:o)?.source}function yX(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let e=r._zod.pattern?.source,t=yX(r);return n&&e&&t&&t!==e?n.replace(LG(e),()=>LG(t)):n}if(t.options){let e=t.options.map(yX);if(e.every(Boolean))return`^(${e.map(e=>LG(e)).join(`|`)})$`}return vX(e)}function bX(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(CK(e))}}var xX,SX,CX,wX,TX,EX,DX,OX,kX,AX,jX,MX,NX,PX,FX,IX,LX,RX,zX,BX,VX,HX,UX,WX,GX,KX,qX,JX,YX,XX,ZX,QX,$X,eZ,tZ,nZ,rZ,iZ,aZ,oZ,sZ,cZ,lZ,uZ,dZ,fZ,pZ,mZ,hZ,gZ,_Z,vZ,yZ,bZ,xZ,SZ,CZ,wZ,TZ,EZ,DZ,OZ,kZ,AZ,jZ,MZ,NZ,PZ,FZ,IZ,LZ,RZ,zZ,BZ,VZ,HZ,UZ,WZ,GZ,KZ,qZ,JZ,YZ,XZ,ZZ,QZ,$Z=n((()=>{DY(),tq(),kY(),Fq(),$J(),KK(),jY(),xX=K(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=AY;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=fK(t),a;for(let o of n){if(o._zod.def.when){if(pK(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new QK;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(_K(t.issues,n,e),i||=fK(t,n))});else{if(t.issues.length===n)continue;_K(t.issues,n,e),i||=fK(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(fK(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new QK;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new QK;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return EK(this,`~standard`,NY(this))},set"~standard"(e){TK(this,`~standard`,e)}}),SX=(e,t)=>e.issues.length?{issues:e.issues.map(e=>vK(e,t,JK()))}:{value:e.value},CX=K(`$ZodString`,(e,t)=>{xX.init(e,t),e._zod.pattern=t.pattern??DJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),wX=K(`$ZodStringFormat`,(e,t)=>{gY.init(e,t),CX.init(e,t)}),TX=K(`$ZodGUID`,(e,t)=>{t.pattern??=$q,wX.init(e,t)}),EX=K(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=eJ(e)}else t.pattern??=eJ();wX.init(e,t)}),DX=K(`$ZodEmail`,(e,t)=>{t.pattern??=iJ,wX.init(e,t)}),OX=/[\t\n\r]/g,kX=K(`$ZodURL`,(e,t)=>{wX.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=FY(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=LY(r);return}t.hostname&&!RY(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!zY(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:LY(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),AX=K(`$ZodEmoji`,(e,t)=>{t.pattern??=Rq(),wX.init(e,t)}),jX=K(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Xq:Lq(t.length),wX.init(e,t)}),MX=K(`$ZodCUID`,(e,t)=>{t.pattern??=Gq,wX.init(e,t)}),NX=K(`$ZodCUID2`,(e,t)=>{t.pattern??=Kq,wX.init(e,t)}),PX=K(`$ZodULID`,(e,t)=>{t.pattern??=qq,wX.init(e,t)}),FX=K(`$ZodXID`,(e,t)=>{t.pattern??=Jq,wX.init(e,t)}),IX=K(`$ZodKSUID`,(e,t)=>{t.pattern??=Yq,wX.init(e,t)}),LX=K(`$ZodISODateTime`,(e,t)=>{t.pattern??=Hq(t),wX.init(e,t)}),RX=K(`$ZodISODate`,(e,t)=>{t.pattern??=EJ,wX.init(e,t)}),zX=K(`$ZodISOTime`,(e,t)=>{t.pattern??=Vq(t),wX.init(e,t)}),BX=K(`$ZodISODuration`,(e,t)=>{t.pattern??=Zq,wX.init(e,t)}),VX=K(`$ZodIPv4`,(e,t)=>{t.pattern??=dJ,wX.init(e,t)}),HX=/^[0-9a-fA-F:.]+$/,UX=K(`$ZodIPv6`,(e,t)=>{t.pattern??=fJ,wX.init(e,t),e._zod.check=n=>{BY(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),WX=K(`$ZodMAC`,(e,t)=>{t.pattern??=pJ(t.delimiter),wX.init(e,t)}),GX=K(`$ZodCIDRv4`,(e,t)=>{t.pattern??=mJ,wX.init(e,t)}),KX=K(`$ZodCIDRv6`,(e,t)=>{t.pattern??=hJ,wX.init(e,t),e._zod.check=n=>{VY(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}),qX=/^[0-9a-zA-Z+/]*={0,2}$/,JX=K(`$ZodBase64`,(e,t)=>{t.pattern??=qX,wX.init(e,t),e._zod.check=n=>{HY(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),YX=/^[A-Za-z0-9_-]*$/,XX=K(`$ZodBase64URL`,(e,t)=>{t.pattern??=YX,wX.init(e,t),e._zod.check=n=>{UY(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ZX=K(`$ZodE164`,(e,t)=>{t.pattern??=xJ,wX.init(e,t)}),QX=/[- ]/g,$X=K(`$ZodCreditCard`,(e,t)=>{t.pattern??=SJ,wX.init(e,t),e._zod.check=n=>{GY(n.value)||n.issues.push({code:`invalid_format`,format:`credit_card`,input:n.value,inst:e,continue:!t.abort})}}),eZ=K(`$ZodIBAN`,(e,t)=>{t.pattern??=wJ,wX.init(e,t),e._zod.check=n=>{qY(n.value)||n.issues.push({code:`invalid_format`,format:`iban`,input:n.value,inst:e,continue:!t.abort})}}),tZ=K(`$ZodJWT`,(e,t)=>{wX.init(e,t),e._zod.check=n=>{JY(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),nZ=K(`$ZodCustomStringFormat`,(e,t)=>{wX.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:`invalid_format`,format:t.format,input:n.value,inst:e,continue:!t.abort})}}),rZ=K(`$ZodNumber`,(e,t)=>{xX.init(e,t),e._zod.pattern=jJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),iZ=K(`$ZodNumberFormat`,(e,t)=>{cY.init(e,t),rZ.init(e,t)}),aZ=K(`$ZodBoolean`,(e,t)=>{xX.init(e,t),e._zod.pattern=MJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),oZ=K(`$ZodBigInt`,(e,t)=>{xX.init(e,t),e._zod.pattern=kJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value==`bigint`||n.issues.push({expected:`bigint`,code:`invalid_type`,input:n.value,inst:e}),n}}),sZ=K(`$ZodBigIntFormat`,(e,t)=>{lY.init(e,t),oZ.init(e,t)}),cZ=K(`$ZodSymbol`,(e,t)=>{xX.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return typeof r==`symbol`||t.issues.push({expected:`symbol`,code:`invalid_type`,input:r,inst:e}),t}}),lZ=K(`$ZodUndefined`,(e,t)=>{xX.init(e,t),e._zod.pattern=PJ,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),uZ=K(`$ZodNull`,(e,t)=>{xX.init(e,t),e._zod.pattern=NJ,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),dZ=K(`$ZodAny`,(e,t)=>{xX.init(e,t),e._zod.parse=e=>e}),fZ=K(`$ZodUnknown`,(e,t)=>{xX.init(e,t),e._zod.parse=e=>e}),pZ=K(`$ZodNever`,(e,t)=>{xX.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),mZ=K(`$ZodVoid`,(e,t)=>{xX.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}}),hZ=K(`$ZodDate`,(e,t)=>{xX.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}}),gZ=e=>Array.isArray(e)?e.length:-1,_Z=e=>e instanceof Map?e.size:-1,vZ=e=>e instanceof Set?e.size:-1,yZ=K(`$ZodArray`,(e,t)=>{xX.init(e,t);let n=eq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>XY(t,r,e)));else if(XY(c,r,e),s&&c.issues.length!==0&&fK(c))break}return o.length?Promise.all(o).then(()=>r):r},YY(e,gZ)}),bZ=[],xZ=K(`$ZodObject`,(e,t)=>{xX.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=FG(()=>QY(t));AK(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||BG(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=XG,o=t.catchall,s,c=eq.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(fK(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ZY(n,t,e,r,a,o))):ZY(s,t,e,r,a,o)}return o?$Y(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),SZ=K(`$ZodObjectJIT`,(e,t)=>{xZ.init(e,t);let n=e._zod.parse,r=FG(()=>QY(t)),i=eq.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new OY([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
47
|
+
`)}\n};`)(...Object.values(this.closed))}}})),RY,zY=n((()=>{RY={major:4,minor:6,patch:7}}));async function BY(e,t){let n={async:!0};return AX(await e._zod.run({value:t,issues:[]},n),n)}function VY(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return AX(r,n)}catch{}return BY(e,t)},vendor:`zod`,version:1}}function HY(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function UY(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?HY(e)||2:WY(e,t)}function WY(e,t){if(!t.normalize&&t.protocol?.source===OJ.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}function GY(e){return e.replace(IX,``)}function KY(e,t){return t.lastIndex=0,t.test(e.hostname)}function qY(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}function JY(e){return XX.test(e)?HY(`http://[${e}]`):!1}function YY(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:JY(n)}function XY(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function ZY(e){if(!rZ.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return XY(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function QY(e){let t=e.length,n=1,r=0;for(;t;){let i=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][i]:i}return r%10==0}function $Y(e){return AJ.test(e)?QY(e.replace(oZ,``)):!1}function eX(e){let t=0,n=e.length;for(let r=4;r<n;r++){let n=e.charCodeAt(r);t=(n>=65?t*100+(n-55):t*10+(n-48))%97}for(let n=0;n<4;n++){let r=e.charCodeAt(n);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}return t===1}function tX(e){return MJ.test(e)?eX(e):!1}function nX(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function rX(e,t){let n=wK(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of wK(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,TK(n.issues,t,e),n}}return i(n,a)}}function iX(e,t,n){e.issues.length&&t.issues.push(...SK(n,e.issues)),t.value[n]=e.value}function aX(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...SK(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}function oX(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:OZ,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=uK(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function sX(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(bK(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>aX(e,n,i,t,d,f))):aX(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}function cX(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!bK(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>EK(e,r,nq())))}),t)}function lX(e,t,n,r){let i=[];for(let t=0;t<e.length;t++)e[t].issues.length===0&&i.push(t);return i.length===1?(t.value=e[i[0]].value,t):(i.length===0?t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>EK(e,r,nq())))}):t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}function uX(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}function dX(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(aK(e)&&aK(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=dX(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=dX(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function fX(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=dX(t.value,n.value);if(!c.valid){if(bK(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}function pX(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function mX(e,t,n){e.issues.length&&t.issues.push(...SK(n,e.issues)),t.value[n]=e.value}function hX(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...SK(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}function gX(e,t,n,r,i,a,o){e.issues.length&&(GK.has(typeof r)?n.issues.push(...SK(r,e.issues)):n.issues.push({code:`invalid_key`,origin:`map`,input:i,inst:a,issues:e.issues.map(e=>EK(e,o,nq()))})),t.issues.length&&(GK.has(typeof r)?n.issues.push(...SK(r,t.issues)):n.issues.push({origin:`map`,code:`invalid_element`,input:i,inst:a,key:r,issues:t.issues.map(e=>EK(e,o,nq()))})),n.value.set(e.value,t.value)}function _X(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function vX(e,t){return e.value=t.issues.length?void 0:t.value,e}function yX(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function bX(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function xX(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>EK(e,r,nq()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}function SX(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function CX(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>wX(e,r,t.out,n)):wX(e,r,t.out,n)}{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>wX(e,r,t.in,n)):wX(e,r,t.in,n)}}function wX(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}function TX(e){return e.memo||(e.value=Object.freeze(e.value)),e}function EX(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes(`int`),i,a;for(let e of t.checks??[]){let t=e._zod.def;t.pattern&&(n=t.pattern),r||=!!t.format?.includes(`int`);let o=t.minimum??t.length,s=t.maximum??t.length;o!==void 0&&(i===void 0||o>i)&&(i=o),s!==void 0&&(a===void 0||s<a)&&(a=s)}if(n)return n.source;if(i!==void 0&&a!==void 0&&i>a)return`(?!)`;if(i!==void 0||a!==void 0)return IJ({minimum:i,maximum:a}).source;let o=e._zod.pattern;return(r&&o===zJ?RJ:o)?.source}function DX(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let e=r._zod.pattern?.source,t=DX(r);return n&&e&&t&&t!==e?n.replace(GG(e),()=>GG(t)):n}if(t.options){let e=t.options.map(DX);if(e.every(Boolean))return`^(${e.map(e=>GG(e)).join(`|`)})$`}return EX(e)}function OX(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(jK(e))}}var kX,AX,jX,MX,NX,PX,FX,IX,LX,RX,zX,BX,VX,HX,UX,WX,GX,KX,qX,JX,YX,XX,ZX,QX,$X,eZ,tZ,nZ,rZ,iZ,aZ,oZ,sZ,cZ,lZ,uZ,dZ,fZ,pZ,mZ,hZ,gZ,_Z,vZ,yZ,bZ,xZ,SZ,CZ,wZ,TZ,EZ,DZ,OZ,kZ,AZ,jZ,MZ,NZ,PZ,FZ,IZ,LZ,RZ,zZ,BZ,VZ,HZ,UZ,WZ,GZ,KZ,qZ,JZ,YZ,XZ,ZZ,QZ,$Z,eQ,tQ,nQ,rQ,iQ,aQ,oQ,sQ=n((()=>{FY(),lq(),LY(),Uq(),sY(),eq(),zY(),kX=K(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=RY;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=bK(t),a;for(let o of n){if(o._zod.def.when){if(xK(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new oq;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(TK(t.issues,n,e),i||=bK(t,n))});else{if(t.issues.length===n)continue;TK(t.issues,n,e),i||=bK(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(bK(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new oq;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new oq;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return PK(this,`~standard`,VY(this))},set"~standard"(e){NK(this,`~standard`,e)}}),AX=(e,t)=>e.issues.length?{issues:e.issues.map(e=>EK(e,t,nq()))}:{value:e.value},jX=K(`$ZodString`,(e,t)=>{kX.init(e,t),e._zod.pattern=t.pattern??FJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),MX=K(`$ZodStringFormat`,(e,t)=>{wY.init(e,t),jX.init(e,t)}),NX=K(`$ZodGUID`,(e,t)=>{t.pattern??=sJ,MX.init(e,t)}),PX=K(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=cJ(e)}else t.pattern??=cJ();MX.init(e,t)}),FX=K(`$ZodEmail`,(e,t)=>{t.pattern??=fJ,MX.init(e,t)}),IX=/[\t\n\r]/g,LX=K(`$ZodURL`,(e,t)=>{MX.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=UY(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=GY(r);return}t.hostname&&!KY(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!qY(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:GY(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),RX=K(`$ZodEmoji`,(e,t)=>{t.pattern??=Kq(),MX.init(e,t)}),zX=K(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?iJ:Gq(t.length),MX.init(e,t)}),BX=K(`$ZodCUID`,(e,t)=>{t.pattern??=$q,MX.init(e,t)}),VX=K(`$ZodCUID2`,(e,t)=>{t.pattern??=eJ,MX.init(e,t)}),HX=K(`$ZodULID`,(e,t)=>{t.pattern??=tJ,MX.init(e,t)}),UX=K(`$ZodXID`,(e,t)=>{t.pattern??=nJ,MX.init(e,t)}),WX=K(`$ZodKSUID`,(e,t)=>{t.pattern??=rJ,MX.init(e,t)}),GX=K(`$ZodISODateTime`,(e,t)=>{t.pattern??=Xq(t),MX.init(e,t)}),KX=K(`$ZodISODate`,(e,t)=>{t.pattern??=PJ,MX.init(e,t)}),qX=K(`$ZodISOTime`,(e,t)=>{t.pattern??=Yq(t),MX.init(e,t)}),JX=K(`$ZodISODuration`,(e,t)=>{t.pattern??=aJ,MX.init(e,t)}),YX=K(`$ZodIPv4`,(e,t)=>{t.pattern??=yJ,MX.init(e,t)}),XX=/^[0-9a-fA-F:.]+$/,ZX=K(`$ZodIPv6`,(e,t)=>{t.pattern??=bJ,MX.init(e,t),e._zod.check=n=>{JY(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),QX=K(`$ZodMAC`,(e,t)=>{t.pattern??=xJ(t.delimiter),MX.init(e,t)}),$X=K(`$ZodCIDRv4`,(e,t)=>{t.pattern??=SJ,MX.init(e,t)}),eZ=K(`$ZodCIDRv6`,(e,t)=>{t.pattern??=CJ,MX.init(e,t),e._zod.check=n=>{YY(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}),tZ=/^[0-9a-zA-Z+/]*={0,2}$/,nZ=K(`$ZodBase64`,(e,t)=>{t.pattern??=tZ,MX.init(e,t),e._zod.check=n=>{XY(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),rZ=/^[A-Za-z0-9_-]*$/,iZ=K(`$ZodBase64URL`,(e,t)=>{t.pattern??=rZ,MX.init(e,t),e._zod.check=n=>{ZY(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),aZ=K(`$ZodE164`,(e,t)=>{t.pattern??=kJ,MX.init(e,t)}),oZ=/[- ]/g,sZ=K(`$ZodCreditCard`,(e,t)=>{t.pattern??=AJ,MX.init(e,t),e._zod.check=n=>{$Y(n.value)||n.issues.push({code:`invalid_format`,format:`credit_card`,input:n.value,inst:e,continue:!t.abort})}}),cZ=K(`$ZodIBAN`,(e,t)=>{t.pattern??=MJ,MX.init(e,t),e._zod.check=n=>{tX(n.value)||n.issues.push({code:`invalid_format`,format:`iban`,input:n.value,inst:e,continue:!t.abort})}}),lZ=K(`$ZodJWT`,(e,t)=>{MX.init(e,t),e._zod.check=n=>{nX(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),uZ=K(`$ZodCustomStringFormat`,(e,t)=>{MX.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:`invalid_format`,format:t.format,input:n.value,inst:e,continue:!t.abort})}}),dZ=K(`$ZodNumber`,(e,t)=>{kX.init(e,t),e._zod.pattern=zJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),fZ=K(`$ZodNumberFormat`,(e,t)=>{gY.init(e,t),dZ.init(e,t)}),pZ=K(`$ZodBoolean`,(e,t)=>{kX.init(e,t),e._zod.pattern=BJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),mZ=K(`$ZodBigInt`,(e,t)=>{kX.init(e,t),e._zod.pattern=LJ,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value==`bigint`||n.issues.push({expected:`bigint`,code:`invalid_type`,input:n.value,inst:e}),n}}),hZ=K(`$ZodBigIntFormat`,(e,t)=>{_Y.init(e,t),mZ.init(e,t)}),gZ=K(`$ZodSymbol`,(e,t)=>{kX.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return typeof r==`symbol`||t.issues.push({expected:`symbol`,code:`invalid_type`,input:r,inst:e}),t}}),_Z=K(`$ZodUndefined`,(e,t)=>{kX.init(e,t),e._zod.pattern=HJ,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),vZ=K(`$ZodNull`,(e,t)=>{kX.init(e,t),e._zod.pattern=VJ,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),yZ=K(`$ZodAny`,(e,t)=>{kX.init(e,t),e._zod.parse=e=>e}),bZ=K(`$ZodUnknown`,(e,t)=>{kX.init(e,t),e._zod.parse=e=>e}),xZ=K(`$ZodNever`,(e,t)=>{kX.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),SZ=K(`$ZodVoid`,(e,t)=>{kX.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}}),CZ=K(`$ZodDate`,(e,t)=>{kX.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}}),wZ=e=>Array.isArray(e)?e.length:-1,TZ=e=>e instanceof Map?e.size:-1,EZ=e=>e instanceof Set?e.size:-1,DZ=K(`$ZodArray`,(e,t)=>{kX.init(e,t);let n=cq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>iX(t,r,e)));else if(iX(c,r,e),s&&c.issues.length!==0&&bK(c))break}return o.length?Promise.all(o).then(()=>r):r},rX(e,wZ)}),OZ=[],kZ=K(`$ZodObject`,(e,t)=>{kX.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=UG(()=>oX(t));RK(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||JG(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=iK,o=t.catchall,s,c=cq.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(bK(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>aX(n,t,e,r,a,o))):aX(s,t,e,r,a,o)}return o?sX(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),AZ=K(`$ZodObjectJIT`,(e,t)=>{kZ.init(e,t);let n=e._zod.parse,r=UG(()=>oX(t)),i=cq.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new IY([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
47
48
|
let ${e}_ab = false;
|
|
48
49
|
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
49
50
|
const iss = ${e}.issues[i];
|
|
@@ -54,7 +55,7 @@ var surfaces=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mod
|
|
|
54
55
|
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
55
56
|
payload.value = newResult;
|
|
56
57
|
return payload;
|
|
57
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:
|
|
58
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:nK(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
58
59
|
const ${n}_present = ${i};
|
|
59
60
|
if (!${n}.issues.length || ${n}_present) {
|
|
60
61
|
if (${n}.issues.length) {${c(n,r)}
|
|
@@ -93,12 +94,12 @@ var surfaces=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mod
|
|
|
93
94
|
newResult[${r}] = ${n}.value;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=XG,c=!eq.jitless,l=c&&IK.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?$Y([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}}),CZ=K(`$ZodUnion`,(e,t)=>{xX.init(e,t),AK(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),AK(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),AK(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),AK(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>LG(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>eX(t,r,e,i)):eX(o,r,e,i)}}),wZ=K(`$ZodXor`,(e,t)=>{CZ.init(e,t),t.inclusive=!1;let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);t instanceof Promise?(o.push(t),a=!0):o.push(t)}return a?Promise.all(o).then(t=>tX(t,r,e,i)):tX(o,r,e,i)}}),TZ=K(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,CZ.init(e,t);let n=e._zod.parse;AK(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||BG(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=VG(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=FG(()=>nX(t));e._zod.parse=(i,a)=>{let o=i.value;if(!XG(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),EZ=K(`$ZodIntersection`,(e,t)=>{xX.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>iX(e,t,n)):iX(e,i,a)}}),DZ=K(`$ZodTuple`,(e,t)=>{xX.init(e,t);let n=t.items,r=eq.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=aX(n,`optin`),l=aX(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=fK(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(fK(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>oX(t,i,e))):oX(r,i,e)}}return s.length?Promise.all(s).then(()=>sX(u,i,n,o,l)):sX(u,i,n,o,l)}}),OZ=K(`$ZodRecord`,(e,t)=>{xX.init(e,t);let n=eq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!ZG(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>vK(e,i,JK())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...mK(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...mK(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&jJ.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>vK(e,i,JK())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...mK(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...mK(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),kZ=K(`$ZodMap`,(e,t)=>{xX.init(e,t);let n=eq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!(a instanceof Map))return r.issues.push({expected:`map`,code:`invalid_type`,input:a,inst:e}),r;let o=[];r.value=n?n.alloc(e,r,new Map,i):new Map;let s=i?.abortEarly,c=r.issues.length;for(let[n,l]of a){if(s&&r.issues.length!==c){if(fK(r,c))break;c=r.issues.length}let u=t.keyType._zod.run({value:n,issues:[]},i),d=t.valueType._zod.run({value:l,issues:[]},i);u instanceof Promise||d instanceof Promise?o.push(Promise.all([u,d]).then(([t,o])=>{cX(t,o,r,n,a,e,i)})):cX(u,d,r,n,a,e,i)}return o.length?Promise.all(o).then(()=>r):r},YY(e,_Z)}),AZ=K(`$ZodSet`,(e,t)=>{xX.init(e,t);let n=eq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!(a instanceof Set))return r.issues.push({input:a,inst:e,expected:`set`,code:`invalid_type`}),r;let o=[];r.value=n?n.alloc(e,r,new Set,i):new Set;let s=i?.abortEarly,c=r.issues.length;for(let e of a){if(s&&r.issues.length!==c){if(fK(r,c))break;c=r.issues.length}let n=t.valueType._zod.run({value:e,issues:[]},i);n instanceof Promise?o.push(n.then(e=>lX(e,r))):lX(n,r)}return o.length?Promise.all(o).then(()=>r):r},YY(e,vZ)}),jZ=K(`$ZodEnum`,(e,t)=>{xX.init(e,t);let n=MG(t.entries),r=new Set(n);e._zod.values=r,AK(e,`pattern`,e=>{let t=MG(e.def.entries).filter(e=>LK.has(typeof e));return RegExp(t.length?`^(${t.map(e=>$G(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),MZ=K(`$ZodLiteral`,(e,t)=>{xX.init(e,t);let n=new Set(t.values);e._zod.values=n,AK(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?$G(e):e?$G(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),NZ=K(`$ZodFile`,(e,t)=>{xX.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:`file`,code:`invalid_type`,input:r,inst:e}),t}}),PZ=K(`$ZodTransform`,(e,t)=>{xX.init(e,t),e._zod.optin=`optional`,eq.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $K(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new QK;return n.value=i,n}}),FZ=K(`$ZodOptional`,(e,t)=>{xX.init(e,t),AK(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,AK(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),AK(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${LG(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>uX(e,t)):uX(e,r)}return t.innerType._zod.run(e,n)}}),IZ=K(`$ZodExactOptional`,(e,t)=>{FZ.init(e,t),AK(e,`values`,e=>e.def.innerType._zod.values),AK(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),LZ=K(`$ZodNullable`,(e,t)=>{xX.init(e,t),AK(e,`optin`,e=>e.def.innerType._zod.optin),AK(e,`optout`,e=>e.def.innerType._zod.optout),AK(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${LG(t.source)}|null)$`):void 0}),AK(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),RZ=K(`$ZodDefault`,(e,t)=>{xX.init(e,t),e._zod.optin=`defaulted`,AK(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>dX(e,t)):dX(r,t)}}),zZ=K(`$ZodPrefault`,(e,t)=>{xX.init(e,t),e._zod.optin=`defaulted`,AK(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),BZ=K(`$ZodNonOptional`,(e,t)=>{xX.init(e,t),AK(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>fX(t,e)):fX(i,e)}}),VZ=K(`$ZodSuccess`,(e,t)=>{xX.init(e,t),e._zod.parse=(e,n)=>{if(n.direction===`backward`)throw new $K(`ZodSuccess`);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=t.issues.length===0,e)):(e.value=r.issues.length===0,e)}}),HZ=K(`$ZodCatch`,(e,t)=>{xX.init(e,t),AK(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),AK(e,`optout`,e=>e.def.innerType._zod.optout),AK(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>pX(e,r,t,n)):pX(e,r,t,n)}}),UZ=K(`$ZodNaN`,(e,t)=>{xX.init(e,t),e._zod.parse=(t,n)=>(typeof t.value==`number`&&Number.isNaN(t.value)||t.issues.push({input:t.value,inst:e,expected:`nan`,code:`invalid_type`}),t)}),WZ=K(`$ZodPipe`,(e,t)=>{xX.init(e,t),AK(e,`values`,e=>e.def.in._zod.values),AK(e,`optin`,e=>e.def.in._zod.optin),AK(e,`optout`,e=>e.def.out._zod.optout),AK(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>mX(e,t.in,n)):mX(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mX(e,t.out,n)):mX(r,t.out,n)}}),GZ=K(`$ZodCodec`,(e,t)=>{xX.init(e,t),AK(e,`values`,e=>e.def.in._zod.values),AK(e,`optin`,e=>e.def.in._zod.optin),AK(e,`optout`,e=>e.def.out._zod.optout),AK(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>hX(e,t,n)):hX(r,t,n)}{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>hX(e,t,n)):hX(r,t,n)}}}),KZ=K(`$ZodPreprocess`,(e,t)=>{WZ.init(e,t)}),qZ=K(`$ZodReadonly`,(e,t)=>{xX.init(e,t),AK(e,`propValues`,e=>e.def.innerType._zod.propValues),AK(e,`values`,e=>e.def.innerType._zod.values),AK(e,`optin`,e=>e.def.innerType?._zod?.optin),AK(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(_X):_X(r)}}),JZ=K(`$ZodTemplateLiteral`,(e,t)=>{xX.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){let t=yX(e);if(!t)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);n.push(LG(t))}else if(e===null||RK.has(typeof e))n.push($G(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),YZ=K(`$ZodFunction`,(e,t)=>(xX.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return Object.defineProperty(function(...n){let r=e._def.input?vq(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?vq(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return Object.defineProperty(async function(...n){let r=e._def.input?await bq(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await bq(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(t,n)=>typeof t.value==`function`?(t.value=e._def.output&&e._def.output._zod.def.type===`promise`?e.implementAsync(t.value):e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new DZ({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),XZ=K(`$ZodPromise`,(e,t)=>{xX.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),ZZ=K(`$ZodLazy`,(e,t)=>{xX.init(e,t),zG(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),AK(e,`pattern`,e=>e.innerType?._zod?.pattern),AK(e,`propValues`,e=>e.innerType?._zod?.propValues),AK(e,`optin`,e=>e.innerType?._zod?.optin??void 0),AK(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),QZ=K(`$ZodCustom`,(e,t)=>{tY.init(e,t),xX.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>bX(t,n,r,e));bX(i,n,r,e)}})}));function eQ(e){return typeof e==`object`&&!!e}function tQ(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}function nQ(e,t,n){let r=uQ.get(e);if(r!==void 0)return r?pQ:dQ;if(t.has(e))return pQ;t.add(e);let i=dQ,a=e=>{if(i!==pQ&&e?._zod){let r=nQ(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=dQ;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?fQ:o.value?._zod?nQ(o.value,t,n):dQ;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=VG(c);s(e?o(e,!0):fQ),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?nQ(r,t,!1):fQ);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),rQ(e,i)}function rQ(e,t){return t!==fQ&&uQ.set(e,t===pQ),t}function iQ(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}function aQ(){return gQ}function oQ(e,t){let n=e[cQ]?.backEdges;return n!==void 0&&eQ(t)&&n.has(t)}var sQ,cQ,lQ,uQ,dQ,fQ,pQ,mQ,hQ,gQ,_Q=n((()=>{KK(),sQ=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},cQ=`~memo`,lQ=[],uQ=new WeakMap,dQ=0,fQ=1,pQ=2,hQ=[],gQ={alloc(e,t,n){let r=mQ;if(!r)return n;mQ=void 0;let i={value:n,issues:null};return r.set(t.value,i),hQ.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&oQ(n,e.value))throw new sQ;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=nQ(e,new Set,!1);if(i===dQ)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===pQ||r?n=!0:r=!0}let l=s.value;if(!eQ(l))return t(s,c);let u=c[cQ];u||(u={buckets:new WeakMap,backEdges:void 0},c[cQ]=u);let d;i===c?d=a:(d=iQ(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...tQ(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;mQ=d;let p=hQ.length,m=t(s,c);mQ=void 0;let h=hQ.length>p?hQ.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?tQ(e.issues):lQ),e)):(h&&(h.issues=m.issues.length?tQ(m.issues):lQ),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}}}));function vQ(){return{localeError:yQ()}}var yQ,bQ=n((()=>{KK(),yQ=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(SK(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${tK(e.values[0])}`:`Invalid option: expected one of ${NG(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${NG(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function xQ(){return new CQ}var SQ,CQ,wQ,TQ=n((()=>{CQ=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(SQ=globalThis).__zod_globalRegistry??(SQ.__zod_globalRegistry=xQ()),wQ=globalThis.__zod_globalRegistry})),EQ=n((()=>{}));function DQ(e){return e.checks&&=[...e.checks],e}function OQ(e,t){return new e(DQ({type:`string`,...G(t)}))}function kQ(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...G(t)})}function AQ(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...G(t)})}function jQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...G(t)})}function MQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...G(t)})}function NQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...G(t)})}function PQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...G(t)})}function FQ(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...G(t)})}function IQ(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...G(t)})}function LQ(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...G(t)})}function RQ(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...G(t)})}function zQ(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...G(t)})}function BQ(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...G(t)})}function VQ(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...G(t)})}function HQ(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...G(t)})}function UQ(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...G(t)})}function WQ(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...G(t)})}function GQ(e,t){return new e({type:`string`,format:`mac`,check:`string_format`,abort:!1,...G(t)})}function KQ(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...G(t)})}function qQ(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...G(t)})}function JQ(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...G(t)})}function YQ(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...G(t)})}function XQ(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...G(t)})}function ZQ(e,t){return new e({type:`string`,format:`credit_card`,check:`string_format`,abort:!1,...G(t)})}function QQ(e,t){return new e({type:`string`,format:`iban`,check:`string_format`,abort:!1,...G(t)})}function $Q(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...G(t)})}function e$(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...G(t)})}function t$(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...G(t)})}function n$(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...G(t)})}function r$(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...G(t)})}function i$(e,t){return new e(DQ({type:`number`,checks:[],...G(t)}))}function a$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...G(t)})}function o$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float32`,...G(t)})}function s$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float64`,...G(t)})}function c$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`int32`,...G(t)})}function l$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`uint32`,...G(t)})}function u$(e,t){return new e({type:`boolean`,...G(t)})}function d$(e,t){return new e({type:`bigint`,...G(t)})}function f$(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`int64`,...G(t)})}function p$(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`uint64`,...G(t)})}function m$(e,t){return new e({type:`symbol`,...G(t)})}function h$(e,t){return new e({type:`undefined`,...G(t)})}function g$(e,t){return new e({type:`null`,...G(t)})}function _$(e){return new e({type:`any`})}function v$(e){return new e({type:`unknown`})}function y$(e,t){return new e({type:`never`,...G(t)})}function b$(e,t){return new e({type:`void`,...G(t)})}function x$(e,t){return new e({type:`date`,...G(t)})}function S$(e,t){return new e({type:`nan`,...G(t)})}function C$(e,t){return new aY({check:`less_than`,...G(t),value:e,inclusive:!1})}function w$(e,t){return new aY({check:`less_than`,...G(t),value:e,inclusive:!0})}function T$(e,t){return new oY({check:`greater_than`,...G(t),value:e,inclusive:!1})}function E$(e,t){return new oY({check:`greater_than`,...G(t),value:e,inclusive:!0})}function D$(e){return T$(0,e)}function O$(e){return C$(0,e)}function k$(e){return w$(0,e)}function A$(e){return E$(0,e)}function j$(e,t){return new sY({check:`multiple_of`,...G(t),value:e})}function M$(e,t){return new uY({check:`max_size`,...G(t),maximum:e})}function N$(e,t){return new dY({check:`min_size`,...G(t),minimum:e})}function P$(e,t){return new fY({check:`size_equals`,...G(t),size:e})}function F$(e,t){return new pY({check:`max_length`,...G(t),maximum:e})}function I$(e,t){return new mY({check:`min_length`,...G(t),minimum:e})}function L$(e,t){return new hY({check:`length_equals`,...G(t),length:e})}function R$(e,t){return new _Y({check:`string_format`,format:`regex`,...G(t),pattern:e})}function z$(e){return new vY({check:`string_format`,format:`lowercase`,...G(e)})}function B$(e){return new yY({check:`string_format`,format:`uppercase`,...G(e)})}function V$(e,t){return new bY({check:`string_format`,format:`includes`,...G(t),includes:e})}function H$(e,t){return new xY({check:`string_format`,format:`starts_with`,...G(t),prefix:e})}function U$(e,t){return new SY({check:`string_format`,format:`ends_with`,...G(t),suffix:e})}function W$(e,t,n){return new CY({check:`property`,property:e,schema:t,...G(n)})}function G$(e,t){return new wY({check:`properties`,shape:e,...G(t)})}function K$(e,t){return new TY({check:`mime_type`,mime:e,...G(t)})}function q$(e){return new EY({check:`overwrite`,tx:e})}function J$(e){return q$(t=>t.normalize(e))}function Y$(){return q$(e=>e.trim())}function X$(){return q$(e=>e.toLowerCase())}function Z$(){return q$(e=>e.toUpperCase())}function Q$(){return q$(e=>YG(e))}function $$(e,t,n){return new e({type:`array`,element:t,...G(n)})}function e1(e,t){return new e({type:`file`,...G(t)})}function t1(e,t,n){let r=G(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function n1(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...G(n)})}function r1(e,t){let n=i1(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(CK(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(CK(r))}},e(t.value,t)),t);return n}function i1(e,t){let n=new tY({check:`custom`,...G(t)});return n._zod.check=e,n}function a1(e){let t=new tY({check:`describe`});return t._zod.onattach=[t=>{let n=wQ.get(t)??{};wQ.add(t,{...n,description:e})}],t._zod.check=()=>{},t}function o1(e){let t=new tY({check:`meta`});return t._zod.onattach=[t=>{let n=wQ.get(t)??{};wQ.add(t,{...n,...e})}],t._zod.check=()=>{},t}function s1(e,t){let n=G(t),r=n.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],i=n.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];n.case!==`sensitive`&&(r=r.map(e=>typeof e==`string`?e.toLowerCase():e),i=i.map(e=>typeof e==`string`?e.toLowerCase():e));let a=new Set(r),o=new Set(i),s=e.Codec??GZ,c=e.Boolean??aZ,l=new s({type:`pipe`,in:new(e.String??CX)({type:`string`,error:n.error}),out:new c({type:`boolean`,error:n.error}),transform:((e,t)=>{let r=e;return n.case!==`sensitive`&&(r=r.toLowerCase()),a.has(r)?!0:!o.has(r)&&(t.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...a,...o],input:t.value,inst:l,continue:!1}),{})}),reverseTransform:((e,t)=>e===!0?r[0]||`true`:i[0]||`false`),error:n.error});return l._zod.bag.truthy=r,l._zod.bag.falsy=i,l._zod.bag.case=n.case??`insensitive`,l}function c1(e,t,n,r={}){let i=G(r),a={check:`string_format`,type:`string`,format:t,fn:typeof n==`function`?n:e=>n.test(e),...i};return n instanceof RegExp&&(a.pattern=n),new e(a)}var l1=n((()=>{DY(),TQ(),$Z(),KK()}));function u1(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&BG(e,t,n[t]);return e}function d1(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??wQ,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function f1(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function p1(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,p1(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&u1(o.schema,c),t.io===`input`&&x1(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function m1(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function h1(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${m1(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+m1(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
97
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=iK,c=!cq.jitless,l=c&&WK.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?sX([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}}),jZ=K(`$ZodUnion`,(e,t)=>{kX.init(e,t),RK(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),RK(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),RK(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),RK(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>GG(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>cX(t,r,e,i)):cX(o,r,e,i)}}),MZ=K(`$ZodXor`,(e,t)=>{jZ.init(e,t),t.inclusive=!1;let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);t instanceof Promise?(o.push(t),a=!0):o.push(t)}return a?Promise.all(o).then(t=>lX(t,r,e,i)):lX(o,r,e,i)}}),NZ=K(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,jZ.init(e,t);let n=e._zod.parse;RK(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||JG(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=YG(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=UG(()=>uX(t));e._zod.parse=(i,a)=>{let o=i.value;if(!iK(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),PZ=K(`$ZodIntersection`,(e,t)=>{kX.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>fX(e,t,n)):fX(e,i,a)}}),FZ=K(`$ZodTuple`,(e,t)=>{kX.init(e,t);let n=t.items,r=cq.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=pX(n,`optin`),l=pX(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=bK(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(bK(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>mX(t,i,e))):mX(r,i,e)}}return s.length?Promise.all(s).then(()=>hX(u,i,n,o,l)):hX(u,i,n,o,l)}}),IZ=K(`$ZodRecord`,(e,t)=>{kX.init(e,t);let n=cq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!aK(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>EK(e,i,nq())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...SK(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...SK(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&zJ.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>EK(e,i,nq())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...SK(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...SK(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),LZ=K(`$ZodMap`,(e,t)=>{kX.init(e,t);let n=cq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!(a instanceof Map))return r.issues.push({expected:`map`,code:`invalid_type`,input:a,inst:e}),r;let o=[];r.value=n?n.alloc(e,r,new Map,i):new Map;let s=i?.abortEarly,c=r.issues.length;for(let[n,l]of a){if(s&&r.issues.length!==c){if(bK(r,c))break;c=r.issues.length}let u=t.keyType._zod.run({value:n,issues:[]},i),d=t.valueType._zod.run({value:l,issues:[]},i);u instanceof Promise||d instanceof Promise?o.push(Promise.all([u,d]).then(([t,o])=>{gX(t,o,r,n,a,e,i)})):gX(u,d,r,n,a,e,i)}return o.length?Promise.all(o).then(()=>r):r},rX(e,TZ)}),RZ=K(`$ZodSet`,(e,t)=>{kX.init(e,t);let n=cq.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!(a instanceof Set))return r.issues.push({input:a,inst:e,expected:`set`,code:`invalid_type`}),r;let o=[];r.value=n?n.alloc(e,r,new Set,i):new Set;let s=i?.abortEarly,c=r.issues.length;for(let e of a){if(s&&r.issues.length!==c){if(bK(r,c))break;c=r.issues.length}let n=t.valueType._zod.run({value:e,issues:[]},i);n instanceof Promise?o.push(n.then(e=>_X(e,r))):_X(n,r)}return o.length?Promise.all(o).then(()=>r):r},rX(e,EZ)}),zZ=K(`$ZodEnum`,(e,t)=>{kX.init(e,t);let n=BG(t.entries),r=new Set(n);e._zod.values=r,RK(e,`pattern`,e=>{let t=BG(e.def.entries).filter(e=>GK.has(typeof e));return RegExp(t.length?`^(${t.map(e=>sK(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),BZ=K(`$ZodLiteral`,(e,t)=>{kX.init(e,t);let n=new Set(t.values);e._zod.values=n,RK(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?sK(e):e?sK(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),VZ=K(`$ZodFile`,(e,t)=>{kX.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:`file`,code:`invalid_type`,input:r,inst:e}),t}}),HZ=K(`$ZodTransform`,(e,t)=>{kX.init(e,t),e._zod.optin=`optional`,cq.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new sq(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new oq;return n.value=i,n}}),UZ=K(`$ZodOptional`,(e,t)=>{kX.init(e,t),RK(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,RK(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),RK(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${GG(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>vX(e,t)):vX(e,r)}return t.innerType._zod.run(e,n)}}),WZ=K(`$ZodExactOptional`,(e,t)=>{UZ.init(e,t),RK(e,`values`,e=>e.def.innerType._zod.values),RK(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),GZ=K(`$ZodNullable`,(e,t)=>{kX.init(e,t),RK(e,`optin`,e=>e.def.innerType._zod.optin),RK(e,`optout`,e=>e.def.innerType._zod.optout),RK(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${GG(t.source)}|null)$`):void 0}),RK(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),KZ=K(`$ZodDefault`,(e,t)=>{kX.init(e,t),e._zod.optin=`defaulted`,RK(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>yX(e,t)):yX(r,t)}}),qZ=K(`$ZodPrefault`,(e,t)=>{kX.init(e,t),e._zod.optin=`defaulted`,RK(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),JZ=K(`$ZodNonOptional`,(e,t)=>{kX.init(e,t),RK(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>bX(t,e)):bX(i,e)}}),YZ=K(`$ZodSuccess`,(e,t)=>{kX.init(e,t),e._zod.parse=(e,n)=>{if(n.direction===`backward`)throw new sq(`ZodSuccess`);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=t.issues.length===0,e)):(e.value=r.issues.length===0,e)}}),XZ=K(`$ZodCatch`,(e,t)=>{kX.init(e,t),RK(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),RK(e,`optout`,e=>e.def.innerType._zod.optout),RK(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>xX(e,r,t,n)):xX(e,r,t,n)}}),ZZ=K(`$ZodNaN`,(e,t)=>{kX.init(e,t),e._zod.parse=(t,n)=>(typeof t.value==`number`&&Number.isNaN(t.value)||t.issues.push({input:t.value,inst:e,expected:`nan`,code:`invalid_type`}),t)}),QZ=K(`$ZodPipe`,(e,t)=>{kX.init(e,t),RK(e,`values`,e=>e.def.in._zod.values),RK(e,`optin`,e=>e.def.in._zod.optin),RK(e,`optout`,e=>e.def.out._zod.optout),RK(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>SX(e,t.in,n)):SX(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>SX(e,t.out,n)):SX(r,t.out,n)}}),$Z=K(`$ZodCodec`,(e,t)=>{kX.init(e,t),RK(e,`values`,e=>e.def.in._zod.values),RK(e,`optin`,e=>e.def.in._zod.optin),RK(e,`optout`,e=>e.def.out._zod.optout),RK(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>CX(e,t,n)):CX(r,t,n)}{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>CX(e,t,n)):CX(r,t,n)}}}),eQ=K(`$ZodPreprocess`,(e,t)=>{QZ.init(e,t)}),tQ=K(`$ZodReadonly`,(e,t)=>{kX.init(e,t),RK(e,`propValues`,e=>e.def.innerType._zod.propValues),RK(e,`values`,e=>e.def.innerType._zod.values),RK(e,`optin`,e=>e.def.innerType?._zod?.optin),RK(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(TX):TX(r)}}),nQ=K(`$ZodTemplateLiteral`,(e,t)=>{kX.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){let t=DX(e);if(!t)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);n.push(GG(t))}else if(e===null||KK.has(typeof e))n.push(sK(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),rQ=K(`$ZodFunction`,(e,t)=>(kX.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return Object.defineProperty(function(...n){let r=e._def.input?Eq(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?Eq(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return Object.defineProperty(async function(...n){let r=e._def.input?await Oq(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await Oq(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(t,n)=>typeof t.value==`function`?(t.value=e._def.output&&e._def.output._zod.def.type===`promise`?e.implementAsync(t.value):e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new FZ({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),iQ=K(`$ZodPromise`,(e,t)=>{kX.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),aQ=K(`$ZodLazy`,(e,t)=>{kX.init(e,t),qG(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),RK(e,`pattern`,e=>e.innerType?._zod?.pattern),RK(e,`propValues`,e=>e.innerType?._zod?.propValues),RK(e,`optin`,e=>e.innerType?._zod?.optin??void 0),RK(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),oQ=K(`$ZodCustom`,(e,t)=>{lY.init(e,t),kX.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>OX(t,n,r,e));OX(i,n,r,e)}})}));function cQ(e){return typeof e==`object`&&!!e}function lQ(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}function uQ(e,t,n){let r=vQ.get(e);if(r!==void 0)return r?xQ:yQ;if(t.has(e))return xQ;t.add(e);let i=yQ,a=e=>{if(i!==xQ&&e?._zod){let r=uQ(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=yQ;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?bQ:o.value?._zod?uQ(o.value,t,n):yQ;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=YG(c);s(e?o(e,!0):bQ),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?uQ(r,t,!1):bQ);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),dQ(e,i)}function dQ(e,t){return t!==bQ&&vQ.set(e,t===xQ),t}function fQ(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}function pQ(){return wQ}function mQ(e,t){let n=e[gQ]?.backEdges;return n!==void 0&&cQ(t)&&n.has(t)}var hQ,gQ,_Q,vQ,yQ,bQ,xQ,SQ,CQ,wQ,TQ=n((()=>{eq(),hQ=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},gQ=`~memo`,_Q=[],vQ=new WeakMap,yQ=0,bQ=1,xQ=2,CQ=[],wQ={alloc(e,t,n){let r=SQ;if(!r)return n;SQ=void 0;let i={value:n,issues:null};return r.set(t.value,i),CQ.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&mQ(n,e.value))throw new hQ;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=uQ(e,new Set,!1);if(i===yQ)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===xQ||r?n=!0:r=!0}let l=s.value;if(!cQ(l))return t(s,c);let u=c[gQ];u||(u={buckets:new WeakMap,backEdges:void 0},c[gQ]=u);let d;i===c?d=a:(d=fQ(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...lQ(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;SQ=d;let p=CQ.length,m=t(s,c);SQ=void 0;let h=CQ.length>p?CQ.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?lQ(e.issues):_Q),e)):(h&&(h.issues=m.issues.length?lQ(m.issues):_Q),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}}}));function EQ(){return{localeError:DQ()}}var DQ,OQ=n((()=>{eq(),DQ=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(AK(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${lK(e.values[0])}`:`Invalid option: expected one of ${VG(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${VG(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function kQ(){return new jQ}var AQ,jQ,MQ,NQ=n((()=>{jQ=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(AQ=globalThis).__zod_globalRegistry??(AQ.__zod_globalRegistry=kQ()),MQ=globalThis.__zod_globalRegistry})),PQ=n((()=>{}));function FQ(e){return e.checks&&=[...e.checks],e}function IQ(e,t){return new e(FQ({type:`string`,...G(t)}))}function LQ(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...G(t)})}function RQ(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...G(t)})}function zQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...G(t)})}function BQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...G(t)})}function VQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...G(t)})}function HQ(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...G(t)})}function UQ(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...G(t)})}function WQ(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...G(t)})}function GQ(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...G(t)})}function KQ(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...G(t)})}function qQ(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...G(t)})}function JQ(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...G(t)})}function YQ(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...G(t)})}function XQ(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...G(t)})}function ZQ(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...G(t)})}function QQ(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...G(t)})}function $Q(e,t){return new e({type:`string`,format:`mac`,check:`string_format`,abort:!1,...G(t)})}function e$(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...G(t)})}function t$(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...G(t)})}function n$(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...G(t)})}function r$(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...G(t)})}function i$(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...G(t)})}function a$(e,t){return new e({type:`string`,format:`credit_card`,check:`string_format`,abort:!1,...G(t)})}function o$(e,t){return new e({type:`string`,format:`iban`,check:`string_format`,abort:!1,...G(t)})}function s$(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...G(t)})}function c$(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...G(t)})}function l$(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...G(t)})}function u$(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...G(t)})}function d$(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...G(t)})}function f$(e,t){return new e(FQ({type:`number`,checks:[],...G(t)}))}function p$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...G(t)})}function m$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float32`,...G(t)})}function h$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float64`,...G(t)})}function g$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`int32`,...G(t)})}function _$(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`uint32`,...G(t)})}function v$(e,t){return new e({type:`boolean`,...G(t)})}function y$(e,t){return new e({type:`bigint`,...G(t)})}function b$(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`int64`,...G(t)})}function x$(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`uint64`,...G(t)})}function S$(e,t){return new e({type:`symbol`,...G(t)})}function C$(e,t){return new e({type:`undefined`,...G(t)})}function w$(e,t){return new e({type:`null`,...G(t)})}function T$(e){return new e({type:`any`})}function E$(e){return new e({type:`unknown`})}function D$(e,t){return new e({type:`never`,...G(t)})}function O$(e,t){return new e({type:`void`,...G(t)})}function k$(e,t){return new e({type:`date`,...G(t)})}function A$(e,t){return new e({type:`nan`,...G(t)})}function j$(e,t){return new pY({check:`less_than`,...G(t),value:e,inclusive:!1})}function M$(e,t){return new pY({check:`less_than`,...G(t),value:e,inclusive:!0})}function N$(e,t){return new mY({check:`greater_than`,...G(t),value:e,inclusive:!1})}function P$(e,t){return new mY({check:`greater_than`,...G(t),value:e,inclusive:!0})}function F$(e){return N$(0,e)}function I$(e){return j$(0,e)}function L$(e){return M$(0,e)}function R$(e){return P$(0,e)}function z$(e,t){return new hY({check:`multiple_of`,...G(t),value:e})}function B$(e,t){return new vY({check:`max_size`,...G(t),maximum:e})}function V$(e,t){return new yY({check:`min_size`,...G(t),minimum:e})}function H$(e,t){return new bY({check:`size_equals`,...G(t),size:e})}function U$(e,t){return new xY({check:`max_length`,...G(t),maximum:e})}function W$(e,t){return new SY({check:`min_length`,...G(t),minimum:e})}function G$(e,t){return new CY({check:`length_equals`,...G(t),length:e})}function K$(e,t){return new TY({check:`string_format`,format:`regex`,...G(t),pattern:e})}function q$(e){return new EY({check:`string_format`,format:`lowercase`,...G(e)})}function J$(e){return new DY({check:`string_format`,format:`uppercase`,...G(e)})}function Y$(e,t){return new OY({check:`string_format`,format:`includes`,...G(t),includes:e})}function X$(e,t){return new kY({check:`string_format`,format:`starts_with`,...G(t),prefix:e})}function Z$(e,t){return new AY({check:`string_format`,format:`ends_with`,...G(t),suffix:e})}function Q$(e,t,n){return new jY({check:`property`,property:e,schema:t,...G(n)})}function $$(e,t){return new MY({check:`properties`,shape:e,...G(t)})}function e1(e,t){return new NY({check:`mime_type`,mime:e,...G(t)})}function t1(e){return new PY({check:`overwrite`,tx:e})}function n1(e){return t1(t=>t.normalize(e))}function r1(){return t1(e=>e.trim())}function i1(){return t1(e=>e.toLowerCase())}function a1(){return t1(e=>e.toUpperCase())}function o1(){return t1(e=>rK(e))}function s1(e,t,n){return new e({type:`array`,element:t,...G(n)})}function c1(e,t){return new e({type:`file`,...G(t)})}function l1(e,t,n){let r=G(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function u1(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...G(n)})}function d1(e,t){let n=f1(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(jK(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(jK(r))}},e(t.value,t)),t);return n}function f1(e,t){let n=new lY({check:`custom`,...G(t)});return n._zod.check=e,n}function p1(e){let t=new lY({check:`describe`});return t._zod.onattach=[t=>{let n=MQ.get(t)??{};MQ.add(t,{...n,description:e})}],t._zod.check=()=>{},t}function m1(e){let t=new lY({check:`meta`});return t._zod.onattach=[t=>{let n=MQ.get(t)??{};MQ.add(t,{...n,...e})}],t._zod.check=()=>{},t}function h1(e,t){let n=G(t),r=n.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],i=n.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];n.case!==`sensitive`&&(r=r.map(e=>typeof e==`string`?e.toLowerCase():e),i=i.map(e=>typeof e==`string`?e.toLowerCase():e));let a=new Set(r),o=new Set(i),s=e.Codec??$Z,c=e.Boolean??pZ,l=new s({type:`pipe`,in:new(e.String??jX)({type:`string`,error:n.error}),out:new c({type:`boolean`,error:n.error}),transform:((e,t)=>{let r=e;return n.case!==`sensitive`&&(r=r.toLowerCase()),a.has(r)?!0:!o.has(r)&&(t.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...a,...o],input:t.value,inst:l,continue:!1}),{})}),reverseTransform:((e,t)=>e===!0?r[0]||`true`:i[0]||`false`),error:n.error});return l._zod.bag.truthy=r,l._zod.bag.falsy=i,l._zod.bag.case=n.case??`insensitive`,l}function g1(e,t,n,r={}){let i=G(r),a={check:`string_format`,type:`string`,format:t,fn:typeof n==`function`?n:e=>n.test(e),...i};return n instanceof RegExp&&(a.pattern=n),new e(a)}var _1=n((()=>{FY(),NQ(),sQ(),eq()}));function v1(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&JG(e,t,n[t]);return e}function y1(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??MQ,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function b1(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function x1(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,x1(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&v1(o.schema,c),t.io===`input`&&k1(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function S1(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function C1(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${S1(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+S1(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
97
98
|
|
|
98
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function g1(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;g1(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}function _1(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function v1(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!S1.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??_1(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}BG(n,r,e.length===1?e[0]:v1(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=_1(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function y1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of S1)if(t in e)return;let n=t.filter(e=>C1.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=v1(t);else{let e=n[0],i=C1.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>v1([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,u1(e,r))}function b1(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):u1(i,s),u1(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())g1(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])y1(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}u1(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,BG(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:T1(t,`input`,e.processors),output:T1(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function x1(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return x1(r.element,n);if(r.type===`set`)return x1(r.valueType,n);if(r.type===`lazy`)return x1(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return x1(r.innerType,n);if(r.type===`intersection`)return x1(r.left,n)||x1(r.right,n);if(r.type===`record`||r.type===`map`)return x1(r.keyType,n)||x1(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:x1(r.in,n)||x1(r.out,n);if(r.type===`object`){for(let e in r.shape)if(x1(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(x1(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(x1(e,n))return!0;return!!(r.rest&&x1(r.rest,n))}return!1}var S1,C1,w1,T1,E1=n((()=>{TQ(),KK(),S1=new Set([`type`,`properties`,`required`,`additionalProperties`]),C1=[`oneOf`,`anyOf`],w1=(e,t={})=>n=>{let r=d1({...n,processors:t});return p1(e,r),h1(r,e),b1(r,e)},T1=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=d1({...i??{},target:a,io:t,processors:n});return p1(e,o),h1(o,e),b1(o,e)}}));function D1(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)H1[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&M1(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&M1(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&N1(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&N1(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&F1(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&L1(t,i.mime);for(let e of i.patterns??[])I1(t,e);return t}function O1(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?O1(t.out):t.type===`catch`?O1(t.innerType):e._zod.optin}function k1(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=k1(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>k1(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?jJ:AJ).source)),p}function A1(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of b0.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=k1(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}function j1(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(f1(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),w0):JSON.parse(o)}var M1,N1,P1,F1,I1,L1,R1,z1,B1,V1,H1,U1,W1,G1,K1,q1,J1,Y1,X1,Z1,Q1,$1,e0,t0,n0,r0,i0,a0,o0,s0,c0,l0,u0,d0,f0,p0,m0,h0,g0,_0,v0,y0,b0,x0,S0,C0,w0,T0,E0,D0,O0,k0,A0,j0,M0,N0=n((()=>{$J(),$Z(),E1(),KK(),M1=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},N1=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},P1=(e,t)=>{M1(e,`minimum`,t),N1(e,`maximum`,t)},F1=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},I1=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},L1=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},R1=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},z1=(e,t)=>M1(e,`minimum`,t.minimum),B1=(e,t)=>N1(e,`maximum`,t.maximum),V1=e=>(t,n)=>{R1(t,n.format);let[r,i]=e[n.format];M1(t,`minimum`,r),N1(t,`maximum`,i)},H1={greater_than:(e,t)=>M1(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>N1(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>F1(e,t.value),number_format:V1(zK),bigint_format:V1(BK),min_length:z1,max_length:B1,length_equals:(e,t)=>P1(e,t.length),min_size:z1,max_size:B1,size_equals:(e,t)=>P1(e,t.size),string_format:(e,t)=>{R1(e,t.format),t.pattern&&I1(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>L1(e,t.mime)},U1={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},W1=new Map([[qX,gJ],[YX,_J]]),G1=e=>W1.get(e)??e,K1=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=D1(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=U1[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(G1);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},q1=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=D1(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):f1(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},J1=(e,t,n,r)=>{n.type=`boolean`},Y1=(e,t,n,r)=>{f1(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},X1=(e,t,n,r)=>{f1(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},Z1=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Q1=(e,t,n,r)=>{f1(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},$1=(e,t,n,r)=>{f1(e,t,n,r,`Void cannot be represented in JSON Schema`)},e0=(e,t,n,r)=>{n.not={}},t0=(e,t,n,r)=>{},n0=(e,t,n,r)=>{},r0=(e,t,n,r)=>{f1(e,t,n,r,`Date cannot be represented in JSON Schema`)},i0=(e,t,n,r)=>{let i=e._zod.def,a=MG(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},a0=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(f1(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(f1(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},o0=(e,t,n,r)=>{f1(e,t,n,r,`NaN cannot be represented in JSON Schema`)},s0=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},c0=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=D1(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},l0=(e,t,n,r)=>{n.type=`boolean`},u0=(e,t,n,r)=>{f1(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},d0=(e,t,n,r)=>{f1(e,t,n,r,`Function types cannot be represented in JSON Schema`)},f0=(e,t,n,r)=>{f1(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},p0=(e,t,n,r)=>{f1(e,t,n,r,`Map cannot be represented in JSON Schema`)},m0=(e,t,n,r)=>{f1(e,t,n,r,`Set cannot be represented in JSON Schema`)},h0=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=D1(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=p1(a.element,t,{...r,path:[...r.path,`items`]})},g0=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&f1(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)BG(i.properties,e,p1(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?O1(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=p1(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},_0=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>p1(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},v0=(e,t,n,r)=>{let i=e._zod.def,a=p1(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=p1(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},y0=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>p1(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?p1(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?O1(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=D1(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)},b0=new WeakMap,x0=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=D1(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=p1(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)BG(i.patternProperties,G1(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=p1(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=b0.get(t);n||(n=[],b0.set(t,n),t.deferred.push(()=>A1(t))),n.push(e)}i.additionalProperties=p1(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&O1(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},S0=(e,t,n,r)=>{let i=e._zod.def,a=p1(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},C0=(e,t,n,r)=>{let i=e._zod.def;p1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},w0=Symbol(),T0=(e,t,n,r)=>{let i=e._zod.def;p1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=j1(i.defaultValue,e,t,n,r);o!==w0&&(n.default=o)},E0=(e,t,n,r)=>{let i=e._zod.def;p1(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=j1(i.defaultValue,e,t,n,r);o!==w0&&(n._prefault=o)},D0=(e,t,n,r)=>{let i=e._zod.def;p1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{f1(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},O0=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;p1(o,t,r);let s=t.seen.get(e);s.ref=o},k0=(e,t,n,r)=>{let i=e._zod.def;p1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},A0=(e,t,n,r)=>{let i=e._zod.def;p1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},j0=(e,t,n,r)=>{let i=e._zod.def;p1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},M0=(e,t,n,r)=>{let i=e._zod.innerType;p1(i,t,r);let a=t.seen.get(e);a.ref=i}})),P0=n((()=>{tq(),Fq(),pq(),$Z(),_Q(),DY(),jY(),KK(),$J(),bQ(),TQ(),kY(),EQ(),l1(),E1(),N0(),E1()})),F0=i({endsWith:()=>U$,gt:()=>T$,gte:()=>E$,includes:()=>V$,length:()=>L$,lowercase:()=>z$,lt:()=>C$,lte:()=>w$,maxLength:()=>F$,maxSize:()=>M$,mime:()=>K$,minLength:()=>I$,minSize:()=>N$,multipleOf:()=>j$,negative:()=>O$,nonnegative:()=>A$,nonpositive:()=>k$,normalize:()=>J$,overwrite:()=>q$,positive:()=>D$,properties:()=>G$,property:()=>W$,regex:()=>R$,size:()=>P$,slugify:()=>Q$,startsWith:()=>H$,toLowerCase:()=>X$,toUpperCase:()=>Z$,trim:()=>Y$,uppercase:()=>B$}),I0=n((()=>{P0()}));function L0(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var R0,z0,B0,V0=n((()=>{P0(),KK(),R0=new WeakSet([Object.prototype,Error.prototype]),z0=(e,t)=>{dq.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);R0.has(n)||(R0.add(n),L0(n,`format`,e=>t=>oq(e,t)),L0(n,`flatten`,e=>t=>aq(e,t)),L0(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,PG,2)}),L0(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,PG,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},B0=K(`ZodError`,z0,void 0,{Parent:Error})})),H0,U0,W0,G0,K0,q0,J0,Y0,X0,Z0,Q0,$0,e2=n((()=>{P0(),V0(),H0=_q(B0),U0=yq(B0),W0=xq(B0),G0=Sq(B0),K0=Dq(B0),q0=Oq(B0),J0=kq(B0),Y0=Aq(B0),X0=jq(B0),Z0=Mq(B0),Q0=Nq(B0),$0=Pq(B0)})),t2=i({ZodAny:()=>D3,ZodArray:()=>M3,ZodBase64:()=>f3,ZodBase64URL:()=>p3,ZodBigInt:()=>S3,ZodBigIntFormat:()=>C3,ZodBoolean:()=>x3,ZodCIDRv4:()=>u3,ZodCIDRv6:()=>d3,ZodCUID:()=>n3,ZodCUID2:()=>r3,ZodCatch:()=>$3,ZodCodec:()=>n6,ZodCreditCard:()=>h3,ZodCustom:()=>l6,ZodCustomStringFormat:()=>v3,ZodDate:()=>j3,ZodDefault:()=>Y3,ZodDiscriminatedUnion:()=>I3,ZodE164:()=>m3,ZodEmail:()=>X4,ZodEmoji:()=>e3,ZodEnum:()=>H3,ZodExactOptional:()=>q3,ZodFile:()=>W3,ZodFunction:()=>c6,ZodGUID:()=>Z4,ZodIBAN:()=>g3,ZodIPv4:()=>s3,ZodIPv6:()=>l3,ZodISODate:()=>q4,ZodISODateTime:()=>K4,ZodISODuration:()=>Y4,ZodISOTime:()=>J4,ZodInstanceOf:()=>f6,ZodIntersection:()=>L3,ZodJWT:()=>_3,ZodKSUID:()=>o3,ZodLazy:()=>o6,ZodLiteral:()=>U3,ZodMAC:()=>c3,ZodMap:()=>B3,ZodNaN:()=>e6,ZodNanoID:()=>t3,ZodNever:()=>k3,ZodNonOptional:()=>Z3,ZodNull:()=>E3,ZodNullable:()=>J3,ZodNumber:()=>y3,ZodNumberFormat:()=>b3,ZodObject:()=>N3,ZodOptional:()=>K3,ZodPipe:()=>t6,ZodPrefault:()=>X3,ZodPreprocess:()=>r6,ZodPromise:()=>s6,ZodReadonly:()=>i6,ZodRecord:()=>z3,ZodSet:()=>V3,ZodString:()=>W4,ZodStringFormat:()=>G4,ZodSuccess:()=>Q3,ZodSymbol:()=>w3,ZodTemplateLiteral:()=>a6,ZodTransform:()=>G3,ZodTuple:()=>R3,ZodType:()=>H4,ZodULID:()=>i3,ZodURL:()=>$4,ZodUUID:()=>Q4,ZodUndefined:()=>T3,ZodUnion:()=>P3,ZodUnknown:()=>O3,ZodVoid:()=>A3,ZodXID:()=>a3,ZodXor:()=>F3,_ZodString:()=>U4,_default:()=>x4,_function:()=>P4,any:()=>J2,array:()=>J,base64:()=>w2,base64url:()=>T2,bigint:()=>H2,boolean:()=>V2,catch:()=>T4,check:()=>F4,cidrv4:()=>S2,cidrv6:()=>C2,codec:()=>O4,creditCard:()=>D2,cuid:()=>m2,cuid2:()=>h2,currencyCode:()=>N2,custom:()=>I4,date:()=>Q2,describe:()=>u6,discriminatedUnion:()=>a4,e164:()=>E2,email:()=>i2,emoji:()=>f2,enum:()=>Y,exactOptional:()=>v4,file:()=>h4,float32:()=>L2,float64:()=>R2,function:()=>P4,guid:()=>a2,hash:()=>P2,hex:()=>M2,hostname:()=>j2,httpUrl:()=>d2,iban:()=>O2,instanceof:()=>z4,int:()=>I2,int32:()=>z2,int64:()=>U2,intersection:()=>o4,invertCodec:()=>k4,ipv4:()=>y2,ipv6:()=>x2,json:()=>B4,jwt:()=>k2,keyof:()=>$2,ksuid:()=>v2,lazy:()=>M4,literal:()=>m4,looseObject:()=>n4,looseRecord:()=>u4,mac:()=>b2,map:()=>d4,meta:()=>d6,nan:()=>E4,nanoid:()=>p2,nativeEnum:()=>p4,never:()=>X2,nonoptional:()=>C4,null:()=>q2,nullable:()=>y4,nullish:()=>b4,number:()=>F2,object:()=>e4,optional:()=>_4,partialRecord:()=>l4,pipe:()=>D4,prefault:()=>S4,preprocess:()=>V4,promise:()=>N4,readonly:()=>A4,record:()=>c4,refine:()=>L4,set:()=>f4,strictObject:()=>t4,string:()=>q,stringFormat:()=>A2,stringbool:()=>p6,success:()=>w4,superRefine:()=>R4,symbol:()=>G2,templateLiteral:()=>j4,transform:()=>g4,tuple:()=>s4,uint32:()=>B2,uint64:()=>W2,ulid:()=>g2,undefined:()=>K2,union:()=>r4,unknown:()=>Y2,url:()=>u2,uuid:()=>o2,uuidv4:()=>s2,uuidv6:()=>c2,uuidv7:()=>l2,void:()=>Z2,xid:()=>_2,xor:()=>i4});function n2(){eq.localeError||JK(vQ())}function r2(){eq.memoizer||JK({memoizer:aQ()})}function q(e){return OQ(W4,e)}function i2(e){return kQ(X4,e)}function a2(e){return AQ(Z4,e)}function o2(e){return jQ(Q4,e)}function s2(e){return MQ(Q4,e)}function c2(e){return NQ(Q4,e)}function l2(e){return PQ(Q4,e)}function u2(e){return FQ($4,e)}function d2(e){return FQ($4,{protocol:bJ,hostname:yJ,...G(e)})}function f2(e){return IQ(e3,e)}function p2(e){return LQ(t3,e)}function m2(e){return RQ(n3,e)}function h2(e){return zQ(r3,e)}function g2(e){return BQ(i3,e)}function _2(e){return VQ(a3,e)}function v2(e){return HQ(o3,e)}function y2(e){return UQ(s3,e)}function b2(e){return GQ(c3,e)}function x2(e){return WQ(l3,e)}function S2(e){return KQ(u3,e)}function C2(e){return qQ(d3,e)}function w2(e){return JQ(f3,e)}function T2(e){return YQ(p3,e)}function E2(e){return XQ(m3,e)}function D2(e){return ZQ(h3,e)}function O2(e){return QQ(g3,e)}function k2(e){return $Q(_3,e)}function A2(e,t,n={}){return c1(v3,e,t,n)}function j2(e){return c1(v3,`hostname`,vJ,e)}function M2(e){return c1(v3,`hex`,LJ,e)}function N2(e){return c1(v3,`currency_code`,CJ,e)}function P2(e,t){let n=`${e}_${t?.enc??`hex`}`,r=Iq[n];if(!r)throw Error(`Unrecognized hash format: ${n}`);return c1(v3,n,r,t)}function F2(e){return i$(y3,e)}function I2(e){return a$(b3,e)}function L2(e){return o$(b3,e)}function R2(e){return s$(b3,e)}function z2(e){return c$(b3,e)}function B2(e){return l$(b3,e)}function V2(e){return u$(x3,e)}function H2(e){return d$(S3,e)}function U2(e){return f$(C3,e)}function W2(e){return p$(C3,e)}function G2(e){return m$(w3,e)}function K2(e){return h$(T3,e)}function q2(e){return g$(E3,e)}function J2(){return _$(D3)}function Y2(){return v$(O3)}function X2(e){return y$(k3,e)}function Z2(e){return b$(A3,e)}function Q2(e){return x$(j3,e)}function J(e,t){return $$(M3,e,t)}function $2(e){let t=e._zod.def.shape;return Y(Object.keys(t))}function e4(e,t){let n={type:`object`,shape:e??{},...G(t)};return new N3(n)}function t4(e,t){return new N3({type:`object`,shape:e,catchall:X2(),...G(t)})}function n4(e,t){return new N3({type:`object`,shape:e,catchall:Y2(),...G(t)})}function r4(e,t){return new P3({type:`union`,options:e,...G(t)})}function i4(e,t){return new F3({type:`union`,options:e,inclusive:!1,...G(t)})}function a4(e,t,n){return new I3({type:`union`,options:t,discriminator:e,...G(n)})}function o4(e,t){return new L3({type:`intersection`,left:e,right:t})}function s4(e,t,n){let r=t instanceof xX;return new R3({type:`tuple`,items:e,rest:r?t:null,...G(r?n:t)})}function c4(e,t,n){return!t||!t._zod?new z3({type:`record`,keyType:q(),valueType:e,...G(t)}):new z3({type:`record`,keyType:e,valueType:t,...G(n)})}function l4(e,t,n){return new z3({type:`record`,keyType:e,valueType:t,...G(n),partial:!0})}function u4(e,t,n){return new z3({type:`record`,keyType:e,valueType:t,mode:`loose`,...G(n)})}function d4(e,t,n){return new B3({type:`map`,keyType:e,valueType:t,...G(n)})}function f4(e,t){return new V3({type:`set`,valueType:e,...G(t)})}function Y(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new H3({type:`enum`,entries:n,...G(t)})}function p4(e,t){return new H3({type:`enum`,entries:e,...G(t)})}function m4(e,t){return new U3({type:`literal`,values:Array.isArray(e)?e:[e],...G(t)})}function h4(e){return e1(W3,e)}function g4(e){return new G3({type:`transform`,transform:e})}function _4(e){return new K3({type:`optional`,innerType:e})}function v4(e){return new q3({type:`optional`,innerType:e})}function y4(e){return new J3({type:`nullable`,innerType:e})}function b4(e){return _4(y4(e))}function x4(e,t){return new Y3({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():QG(t)}})}function S4(e,t){return new X3({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():QG(t)}})}function C4(e,t){return new Z3({type:`nonoptional`,innerType:e,...G(t)})}function w4(e){return new Q3({type:`success`,innerType:e})}function T4(e,t){return new $3({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:MK(t)})}function E4(e){return S$(e6,e)}function D4(e,t){return new t6({type:`pipe`,in:e,out:t})}function O4(e,t,n){return new n6({type:`pipe`,in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function k4(e){let t=e._zod.def;return new n6({type:`pipe`,in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function A4(e){return new i6({type:`readonly`,innerType:e})}function j4(e,t){return new a6({type:`template_literal`,parts:e,...G(t)})}function M4(e){return new o6({type:`lazy`,getter:e})}function N4(e){return new s6({type:`promise`,innerType:e})}function P4(e){return new c6({type:`function`,input:Array.isArray(e?.input)?s4(e?.input):e?.input??J(Y2()),output:e?.output??Y2()})}function F4(e){let t=new tY({check:`custom`});return t._zod.check=e,t}function I4(e,t){return t1(l6,e??(()=>!0),t)}function L4(e,t={}){return n1(l6,e,t)}function R4(e,t){return r1(e,t)}function z4(e,t={}){let n=new f6({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...G(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function B4(e){let t=M4(()=>r4([q(e),F2(),V2(),q2(),J(t),c4(q(),t)]));return t}function V4(e,t){return new r6({type:`pipe`,in:g4(e),out:t})}var H4,U4,W4,G4,K4,q4,J4,Y4,X4,Z4,Q4,$4,e3,t3,n3,r3,i3,a3,o3,s3,c3,l3,u3,d3,f3,p3,m3,h3,g3,_3,v3,y3,b3,x3,S3,C3,w3,T3,E3,D3,O3,k3,A3,j3,M3,N3,P3,F3,I3,L3,R3,z3,B3,V3,H3,U3,W3,G3,K3,q3,J3,Y3,X3,Z3,Q3,$3,e6,t6,n6,r6,i6,a6,o6,s6,c6,l6,u6,d6,f6,p6,m6=n((()=>{P0(),N0(),$J(),E1(),bQ(),I0(),e2(),H4=K(`ZodType`,(e,t)=>(n2(),xX.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(qG(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eK(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(L4(e,t))},superRefine(e,t){return this.check(R4(e,t))},overwrite(e){return this.check(q$(e))},optional(){return _4(this)},exactOptional(){return v4(this)},nullable(){return y4(this)},nullish(){return _4(y4(this))},nonoptional(e){return C4(this,e)},array(){return J(this)},or(e){return r4([this,e])},and(e){return o4(this,e)},transform(e){return D4(this,g4(e))},default(e){return x4(this,e)},prefault(e){return S4(this,e)},catch(e){return T4(this,e)},pipe(e){return D4(this,e)},readonly(){return A4(this)},describe(e){let t=this.clone();return wQ.add(t,{description:e}),t},meta(...e){if(e.length===0)return wQ.get(this);let t=this.clone();return wQ.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return EK(this,`~standard`,{...NY(this),jsonSchema:{input:T1(this,`input`),output:T1(this,`output`)}})},set"~standard"(e){TK(this,`~standard`,e)},parse:function e(t,n){return H0(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await U0(this,t,n,{callee:e})},safeParse(e,t){return W0(this,e,t)},async safeParseAsync(e,t){return G0(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){TK(this,`spa`,e)},validate(e,t){return Tq(this,e,t)},validateAsync(e,t){return Eq(this,e,t)},encode:function e(t,n){return K0(this,t,n,{callee:e})},decode:function e(t,n){return q0(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await J0(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Y0(this,t,n,{callee:e})},safeEncode(e,t){return X0(this,e,t)},safeDecode(e,t){return Z0(this,e,t)},async safeEncodeAsync(e,t){return Q0(this,e,t)},async safeDecodeAsync(e,t){return $0(this,e,t)},toJSONSchema(e){return w1(this,{})(e)},get description(){return wQ.get(this)?.description},get _def(){return this._zod.def}}),U4=K(`_ZodString`,(e,t)=>{CX.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>K1(e,t,n,r)},DK({format:e=>D1(e).format??null,minLength:e=>D1(e).minimum??null,maxLength:e=>D1(e).maximum??null},{regex(...e){return this.check(R$(...e))},includes(...e){return this.check(V$(...e))},startsWith(...e){return this.check(H$(...e))},endsWith(...e){return this.check(U$(...e))},min(...e){return this.check(I$(...e))},max(...e){return this.check(F$(...e))},length(...e){return this.check(L$(...e))},nonempty(...e){return this.check(I$(1,...e))},lowercase(e){return this.check(z$(e))},uppercase(e){return this.check(B$(e))},trim(){return this.check(Y$())},normalize(...e){return this.check(J$(...e))},toLowerCase(){return this.check(X$())},toUpperCase(){return this.check(Z$())},slugify(){return this.check(Q$())}})),W4=K(`ZodString`,(e,t)=>{CX.init(e,t),U4.init(e,t)},{email(e){return this.check(kQ(X4,e))},url(e){return this.check(FQ($4,e))},jwt(e){return this.check($Q(_3,e))},emoji(e){return this.check(IQ(e3,e))},guid(e){return this.check(AQ(Z4,e))},uuid(e){return this.check(jQ(Q4,e))},uuidv4(e){return this.check(MQ(Q4,e))},uuidv6(e){return this.check(NQ(Q4,e))},uuidv7(e){return this.check(PQ(Q4,e))},nanoid(e){return this.check(LQ(t3,e))},cuid(e){return this.check(RQ(n3,e))},cuid2(e){return this.check(zQ(r3,e))},ulid(e){return this.check(BQ(i3,e))},base64(e){return this.check(JQ(f3,e))},base64url(e){return this.check(YQ(p3,e))},xid(e){return this.check(VQ(a3,e))},ksuid(e){return this.check(HQ(o3,e))},ipv4(e){return this.check(UQ(s3,e))},ipv6(e){return this.check(WQ(l3,e))},cidrv4(e){return this.check(KQ(u3,e))},cidrv6(e){return this.check(qQ(d3,e))},e164(e){return this.check(XQ(m3,e))},datetime(e){return this.check(e$(K4,e))},date(e){return this.check(t$(q4,e))},time(e){return this.check(n$(J4,e))},duration(e){return this.check(r$(Y4,e))}}),G4=K(`ZodStringFormat`,(e,t)=>{wX.init(e,t),U4.init(e,t)}),K4=K(`ZodISODateTime`,(e,t)=>{LX.init(e,t),G4.init(e,t)}),q4=K(`ZodISODate`,(e,t)=>{RX.init(e,t),G4.init(e,t)}),J4=K(`ZodISOTime`,(e,t)=>{zX.init(e,t),G4.init(e,t)}),Y4=K(`ZodISODuration`,(e,t)=>{BX.init(e,t),G4.init(e,t)}),X4=K(`ZodEmail`,(e,t)=>{DX.init(e,t),G4.init(e,t)}),Z4=K(`ZodGUID`,(e,t)=>{TX.init(e,t),G4.init(e,t)}),Q4=K(`ZodUUID`,(e,t)=>{EX.init(e,t),G4.init(e,t)}),$4=K(`ZodURL`,(e,t)=>{kX.init(e,t),G4.init(e,t)}),e3=K(`ZodEmoji`,(e,t)=>{AX.init(e,t),G4.init(e,t)}),t3=K(`ZodNanoID`,(e,t)=>{jX.init(e,t),G4.init(e,t)}),n3=K(`ZodCUID`,(e,t)=>{MX.init(e,t),G4.init(e,t)}),r3=K(`ZodCUID2`,(e,t)=>{NX.init(e,t),G4.init(e,t)}),i3=K(`ZodULID`,(e,t)=>{PX.init(e,t),G4.init(e,t)}),a3=K(`ZodXID`,(e,t)=>{FX.init(e,t),G4.init(e,t)}),o3=K(`ZodKSUID`,(e,t)=>{IX.init(e,t),G4.init(e,t)}),s3=K(`ZodIPv4`,(e,t)=>{VX.init(e,t),G4.init(e,t)}),c3=K(`ZodMAC`,(e,t)=>{WX.init(e,t),G4.init(e,t)}),l3=K(`ZodIPv6`,(e,t)=>{UX.init(e,t),G4.init(e,t)}),u3=K(`ZodCIDRv4`,(e,t)=>{GX.init(e,t),G4.init(e,t)}),d3=K(`ZodCIDRv6`,(e,t)=>{KX.init(e,t),G4.init(e,t)}),f3=K(`ZodBase64`,(e,t)=>{JX.init(e,t),G4.init(e,t)}),p3=K(`ZodBase64URL`,(e,t)=>{XX.init(e,t),G4.init(e,t)}),m3=K(`ZodE164`,(e,t)=>{ZX.init(e,t),G4.init(e,t)}),h3=K(`ZodCreditCard`,(e,t)=>{$X.init(e,t),G4.init(e,t)}),g3=K(`ZodIBAN`,(e,t)=>{eZ.init(e,t),G4.init(e,t)}),_3=K(`ZodJWT`,(e,t)=>{tZ.init(e,t),G4.init(e,t)}),v3=K(`ZodCustomStringFormat`,(e,t)=>{nZ.init(e,t),G4.init(e,t)}),y3=K(`ZodNumber`,(e,t)=>{rZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>q1(e,t,n,r),e.isFinite=!0},DK({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=D1(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=D1(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=D1(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>D1(e).format??null},{gt(e,t){return this.check(T$(e,t))},gte(e,t){return this.check(E$(e,t))},min(e,t){return this.check(E$(e,t))},lt(e,t){return this.check(C$(e,t))},lte(e,t){return this.check(w$(e,t))},max(e,t){return this.check(w$(e,t))},int(e){return this.check(I2(e))},safe(e){return this.check(I2(e))},positive(e){return this.check(T$(0,e))},nonnegative(e){return this.check(E$(0,e))},negative(e){return this.check(C$(0,e))},nonpositive(e){return this.check(w$(0,e))},multipleOf(e,t){return this.check(j$(e,t))},step(e,t){return this.check(j$(e,t))},finite(){return this}})),b3=K(`ZodNumberFormat`,(e,t)=>{iZ.init(e,t),y3.init(e,t)}),x3=K(`ZodBoolean`,(e,t)=>{aZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>J1(e,t,n,r)}),S3=K(`ZodBigInt`,(e,t)=>{oZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Y1(e,t,n,r)},DK({minValue:e=>D1(e).minimum??null,maxValue:e=>D1(e).maximum??null,format:e=>D1(e).format??null},{gte(e,t){return this.check(E$(e,t))},min(e,t){return this.check(E$(e,t))},gt(e,t){return this.check(T$(e,t))},lt(e,t){return this.check(C$(e,t))},lte(e,t){return this.check(w$(e,t))},max(e,t){return this.check(w$(e,t))},positive(e){return this.check(T$(BigInt(0),e))},negative(e){return this.check(C$(BigInt(0),e))},nonpositive(e){return this.check(w$(BigInt(0),e))},nonnegative(e){return this.check(E$(BigInt(0),e))},multipleOf(e,t){return this.check(j$(e,t))}})),C3=K(`ZodBigIntFormat`,(e,t)=>{sZ.init(e,t),S3.init(e,t)}),w3=K(`ZodSymbol`,(e,t)=>{cZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>X1(e,t,n,r)}),T3=K(`ZodUndefined`,(e,t)=>{lZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Q1(e,t,n,r)}),E3=K(`ZodNull`,(e,t)=>{uZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Z1(e,t,n,r)}),D3=K(`ZodAny`,(e,t)=>{dZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t0(e,t,n,r)}),O3=K(`ZodUnknown`,(e,t)=>{fZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>n0(e,t,n,r)}),k3=K(`ZodNever`,(e,t)=>{pZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>e0(e,t,n,r)}),A3=K(`ZodVoid`,(e,t)=>{mZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$1(e,t,n,r)}),j3=K(`ZodDate`,(e,t)=>{hZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>r0(e,t,n,r),e.min=(t,n)=>e.check(E$(t,n)),e.max=(t,n)=>e.check(w$(t,n))},DK({minDate:e=>{let{minimum:t}=D1(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=D1(e);return t?new Date(t):null}},{})),M3=K(`ZodArray`,(e,t)=>{r2(),yZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>h0(e,t,n,r),e.element=t.element},{min(e,t){return this.check(I$(e,t))},nonempty(e){return this.check(I$(1,e))},max(e,t){return this.check(F$(e,t))},length(e,t){return this.check(L$(e,t))},unwrap(){return this.element}}),N3=K(`ZodObject`,(e,t)=>{r2(),SZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>g0(e,t,n,r),jK(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Y(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(qG(this._zod.def,{catchall:e}))},passthrough(){return this.clone(qG(this._zod.def,{catchall:Y2()}))},loose(){return this.clone(qG(this._zod.def,{catchall:Y2()}))},strict(){return this.clone(qG(this._zod.def,{catchall:X2()}))},strip(){return this.clone(qG(this._zod.def,{catchall:void 0}))},extend(e){return oK(this,e)},safeExtend(e){return cK(this,e)},merge(e){return lK(this,e)},pick(e){return rK(this,e)},omit(e){return aK(this,e)},partial(...e){return uK(K3,this,e[0])},exactPartial(...e){return uK(q3,this,e[0],`exactPartial`)},required(...e){return dK(Z3,this,e[0])}}),P3=K(`ZodUnion`,(e,t)=>{CZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_0(e,t,n,r),e.options=t.options}),F3=K(`ZodXor`,(e,t)=>{P3.init(e,t),wZ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_0(e,t,n,r),e.options=t.options}),I3=K(`ZodDiscriminatedUnion`,(e,t)=>{P3.init(e,t),TZ.init(e,t)}),L3=K(`ZodIntersection`,(e,t)=>{EZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>v0(e,t,n,r)}),R3=K(`ZodTuple`,(e,t)=>{r2(),DZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>y0(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new K3({type:`optional`,innerType:e}))})}}),z3=K(`ZodRecord`,(e,t)=>{r2(),OZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>x0(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),B3=K(`ZodMap`,(e,t)=>{r2(),kZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>p0(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(N$(...t)),e.nonempty=t=>e.check(N$(1,t)),e.max=(...t)=>e.check(M$(...t)),e.size=(...t)=>e.check(P$(...t))}),V3=K(`ZodSet`,(e,t)=>{r2(),AZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>m0(e,t,n,r),e.min=(...t)=>e.check(N$(...t)),e.nonempty=t=>e.check(N$(1,t)),e.max=(...t)=>e.check(M$(...t)),e.size=(...t)=>e.check(P$(...t))}),H3=K(`ZodEnum`,(e,t)=>{jZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>i0(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new H3({...t,checks:[],...G(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new H3({...t,checks:[],...G(r),entries:i})}}),U3=K(`ZodLiteral`,(e,t)=>{MZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>a0(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),W3=K(`ZodFile`,(e,t)=>{NZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>c0(e,t,n,r),e.min=(t,n)=>e.check(N$(t,n)),e.max=(t,n)=>e.check(M$(t,n)),e.mime=(t,n)=>e.check(K$(Array.isArray(t)?t:[t],n))}),G3=K(`ZodTransform`,(e,t)=>{r2(),PZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>f0(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $K(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(CK(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(CK(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}}),K3=K(`ZodOptional`,(e,t)=>{FZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>j0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),q3=K(`ZodExactOptional`,(e,t)=>{IZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>j0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),J3=K(`ZodNullable`,(e,t)=>{LZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>S0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Y3=K(`ZodDefault`,(e,t)=>{RZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>T0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),X3=K(`ZodPrefault`,(e,t)=>{zZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>E0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Z3=K(`ZodNonOptional`,(e,t)=>{BZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>C0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Q3=K(`ZodSuccess`,(e,t)=>{VZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>l0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),$3=K(`ZodCatch`,(e,t)=>{HZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>D0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),e6=K(`ZodNaN`,(e,t)=>{UZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>o0(e,t,n,r)}),t6=K(`ZodPipe`,(e,t)=>{WZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>O0(e,t,n,r),e.in=t.in,e.out=t.out}),n6=K(`ZodCodec`,(e,t)=>{t6.init(e,t),GZ.init(e,t)}),r6=K(`ZodPreprocess`,(e,t)=>{t6.init(e,t),KZ.init(e,t)}),i6=K(`ZodReadonly`,(e,t)=>{qZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>k0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),a6=K(`ZodTemplateLiteral`,(e,t)=>{JZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s0(e,t,n,r)}),o6=K(`ZodLazy`,(e,t)=>{ZZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>M0(e,t,n,r),e.unwrap=()=>e._zod.def.getter()}),s6=K(`ZodPromise`,(e,t)=>{XZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>A0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),c6=K(`ZodFunction`,(e,t)=>{YZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>d0(e,t,n,r)}),l6=K(`ZodCustom`,(e,t)=>{QZ.init(e,t),H4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>u0(e,t,n,r)}),u6=a1,d6=o1,f6=K(`ZodInstanceOf`,(e,t)=>{l6.init(e,t)},{properties(e,t){return this.check(G$(e,t))}}),p6=(...e)=>s1({Codec:n6,Boolean:x3,String:W4},...e)})),h6=n((()=>{P0()})),g6=i({ZodISODate:()=>q4,ZodISODateTime:()=>K4,ZodISODuration:()=>Y4,ZodISOTime:()=>J4,date:()=>v6,datetime:()=>_6,duration:()=>b6,time:()=>y6});function _6(e){return e$(K4,e)}function v6(e){return t$(q4,e)}function y6(e){return n$(J4,e)}function b6(e){return r$(Y4,e)}var x6=n((()=>{P0(),m6()}));function S6(e,t){let n=e.$schema;return n===`https://json-schema.org/draft/2020-12/schema`?`draft-2020-12`:n===`http://json-schema.org/draft-07/schema#`?`draft-7`:n===`http://json-schema.org/draft-04/schema#`?`draft-4`:t??`draft-2020-12`}function C6(e,t){return e.map((e,n)=>n<t?e:e.optional())}function w6(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function T6(e,t){if(!e.startsWith(`#`))throw Error(`External $ref is not supported, only local refs (#/...) are allowed`);let n=e.slice(1).split(`/`).filter(Boolean);if(n.length===0)return t.rootSchema;let r=t.version===`draft-2020-12`?`$defs`:`definitions`;if(n[0]===r){let r=n[1]===void 0?void 0:w6(n[1]);if(!r||!t.defs[r])throw Error(`Reference not found: ${e}`);return t.defs[r]}throw Error(`Reference not found: ${e}`)}function E6(e,t){return X.transform(e=>e).check(n=>{let r=n.value;if(typeof r!=`object`||!r||Array.isArray(r))return;let i=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&i.length<t.minProperties&&n.issues.push({origin:`object`,code:`too_small`,minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&n.issues.push({origin:`object`,code:`too_big`,maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let e of i){let r=t.keySchema.safeParse(e);r.success||n.issues.push({code:`invalid_key`,origin:`record`,issues:r.error.issues,input:e,path:[e],continue:!0})}}).pipe(e)}function D6(e,t){if(e===null)return`z`;let n=typeof e;if(n!==`object`){if(n===`number`&&Number.isNaN(e))return null;let t=String(e);return`${n[0]}${t.length}:${t}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let n=[];for(let r of e){let e=D6(r,t);if(e===null)return null;n.push(e)}return`a${n.length}:[${n.join(`,`)}]`}let n=Object.keys(e).sort(),r=[];for(let i of n){let n=D6(e[i],t);if(n===null)return null;r.push(`${i.length}:${i}=${n}`)}return`o${r.length}:{${r.join(`,`)}}`}finally{t.delete(e)}}function O6(e){return typeof e!=`object`||!e?!1:Array.isArray(e)?e.some(O6):typeof e.$ref==`string`||Object.entries(e).some(([e,t])=>I6.has(e)?O6(t):!L6.has(e)||typeof t!=`object`||!t?!1:Object.values(t).some(O6))}function k6(e){return e===1?`element`:`elements`}function A6(e,t){return X.transform(e=>e).check(e=>{let n=e.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let t=new Map;for(let r=0;r<n.length;r++){let i=D6(n[r],new Set);if(i===null)continue;let a=t.get(i);a===void 0?t.set(i,r):e.issues.push({code:`custom`,message:`Array items must be unique: element at index ${r} duplicates the one at index ${a}`,input:n,path:[r],continue:!0})}}if(t.containsSchema){let r=t.minContains??1,i=t.maxContains===void 0?1/0:t.maxContains+1,a=0;for(let e of n)if(t.containsSchema.safeParse(e).success&&++a>=i)break;a<r&&e.issues.push({code:`custom`,message:`Array must contain at least ${r} matching ${k6(r)}; found ${a}`,input:n,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&e.issues.push({code:`custom`,message:`Array must contain at most ${t.maxContains} matching ${k6(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function j6(e,t){if(e!==!1)return e===void 0||e===!0?X.any():N6(e,t)}function M6(e,t){if(e.not!==void 0){if(typeof e.not==`object`&&Object.keys(e.not).length===0)return X.never();throw Error(`not is not supported in Zod (except { not: {} } for never)`)}if(e.unevaluatedItems!==void 0)throw Error(`unevaluatedItems is not supported`);if(e.unevaluatedProperties!==void 0)throw Error(`unevaluatedProperties is not supported`);if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error(`Conditional schemas (if/then/else) are not supported`);if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error(`dependentSchemas and dependentRequired are not supported`);if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return X.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let r=N6(T6(n,t),t);return t.refs.set(n,r),t.processing.delete(n),r}if(e.enum!==void 0){let n=e.enum;if(t.version===`openapi-3.0`&&e.nullable===!0&&n.length===1&&n[0]===null)return X.null();if(n.length===0)return X.never();if(n.length===1)return X.literal(n[0]);if(n.every(e=>typeof e==`string`))return X.enum(n);let r=n.map(e=>X.literal(e));return r.length<2?r[0]:X.union([r[0],r[1],...r.slice(2)])}if(e.const!==void 0)return X.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(n=>M6({...e,type:n},t));return r.length===0?X.never():r.length===1?r[0]:X.union(r)}if(!n)return X.any();let r;switch(n){case`string`:{let t=X.string();if(e.format){let n=e.format;n===`email`?t=t.check(X.email()):n===`uri`||n===`uri-reference`?t=t.check(X.url()):n===`uuid`||n===`guid`?t=t.check(X.uuid()):n===`date-time`?t=t.check(X.iso.datetime({offset:!0})):n===`date`?t=t.check(X.iso.date()):n===`time`?t=t.check(X.regex(R6)):n===`duration`?t=t.check(X.iso.duration()):n===`hostname`?t=t.check(X.hostname()):n===`ipv4`?t=t.check(X.ipv4()):n===`ipv6`?t=t.check(X.ipv6()):n===`mac`?t=t.check(X.mac()):n===`cidr`?t=t.check(X.cidrv4()):n===`cidr-v6`?t=t.check(X.cidrv6()):n===`base64`?t=t.check(X.base64()):n===`base64url`?t=t.check(X.base64url()):n===`e164`?t=t.check(X.e164()):n===`credit_card`?t=t.check(X.creditCard()):n===`iban`?t=t.check(X.iban()):n===`jwt`?t=t.check(X.jwt()):n===`emoji`?t=t.check(X.emoji()):n===`nanoid`?t=t.check(X.nanoid()):n===`cuid`?t=t.check(X.cuid()):n===`cuid2`?t=t.check(X.cuid2()):n===`ulid`?t=t.check(X.ulid()):n===`xid`?t=t.check(X.xid()):n===`ksuid`&&(t=t.check(X.ksuid()))}typeof e.minLength==`number`&&(t=t.min(e.minLength)),typeof e.maxLength==`number`&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),r=t;break}case`number`:case`integer`:{let t=n===`integer`?X.number().int():X.number();typeof e.minimum==`number`&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum==`number`&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum==`number`?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum==`number`&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum==`number`?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum==`number`&&(t=t.lt(e.maximum)),typeof e.multipleOf==`number`&&(t=t.multipleOf(e.multipleOf)),r=t;break}case`boolean`:r=X.boolean();break;case`null`:r=X.null();break;case`object`:{let n={},i=e.properties||{},a=new Set(e.required||[]),o=typeof e.additionalProperties==`object`?N6(e.additionalProperties,t):void 0;for(let[e,r]of Object.entries(i)){let i=N6(r,t);BG(n,e,a.has(e)?i:i.optional())}if(e.patternProperties){let i=e.patternProperties,a=Object.keys(i),o=[];for(let e of a){let n=N6(i[e],t),r=X.string().regex(new RegExp(e));o.push(X.looseRecord(r,n))}let s=[];if(Object.keys(n).length>0&&s.push(X.object(n).passthrough()),s.push(...o),s.length===0)r=X.object({}).passthrough();else if(s.length===1)r=s[0];else{let e=X.intersection(s[0],s[1]);for(let t=2;t<s.length;t++)e=X.intersection(e,s[t]);r=e}if(e.additionalProperties===!1){let e=Object.keys(n),t=a.map(e=>new RegExp(e)),i=r;r=r.check(n=>{if(!ZG(n.value))return;let r=[];for(let i of Object.keys(n.value))e.includes(i)||t.some(e=>e.test(i))||r.push(i);r.length&&n.issues.push({code:`unrecognized_keys`,keys:r,input:n.value,inst:i})})}}else{let t=X.object(n);r=e.additionalProperties===!1?t.strict():o?t.catchall(o):t.passthrough()}let s=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties==`number`?e.minProperties:void 0,l=typeof e.maxProperties==`number`?e.maxProperties:void 0;if(s||c!==void 0||l!==void 0){let n;s&&(n=N6(typeof e.propertyNames==`object`&&e.propertyNames.type===void 0?{type:`string`,...e.propertyNames}:e.propertyNames,t)),r=E6(r,{keySchema:n,minProperties:c,maxProperties:l})}break}case`array`:{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems==`number`?e.minItems:0,o=C6(n.map(e=>N6(e,t)),a),s=Array.isArray(i)?void 0:j6(i,t),c=X.tuple(o);r=s?c.rest(s):c,typeof e.minItems==`number`&&(r=r.check(X.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(X.maxLength(e.maxItems)))}else if(Array.isArray(i)){let n=typeof e.minItems==`number`?e.minItems:0,a=C6(i.map(e=>N6(e,t)),n),o=j6(e.additionalItems,t),s=X.tuple(a);r=o?s.rest(o):s,typeof e.minItems==`number`&&(r=r.check(X.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(X.maxLength(e.maxItems)))}else if(i!==void 0){let n=N6(i,t),a=X.array(n);typeof e.minItems==`number`&&(a=a.min(e.minItems)),typeof e.maxItems==`number`&&(a=a.max(e.maxItems)),r=a}else r=X.array(X.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=A6(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains===void 0?void 0:N6(e.contains,t),minContains:typeof e.minContains==`number`?e.minContains:void 0,maxContains:typeof e.maxContains==`number`?e.maxContains:void 0}));break}default:throw Error(`Unsupported type: ${n}`)}return r}function N6(e,t){if(typeof e==`boolean`)return e?X.any():X.never();let n=M6(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let i=e.anyOf.map(e=>N6(e,t)),a=X.union(i);n=r?X.intersection(n,a):a}if(e.oneOf&&Array.isArray(e.oneOf)){let i=e.oneOf.map(e=>N6(e,t)),a=X.xor(i);n=r?X.intersection(n,a):a}if(e.allOf&&Array.isArray(e.allOf)){if(e.allOf.length===0)n=r?n:X.any();else{let i=r?n:N6(e.allOf[0],t),a=+!r;for(let n=a;n<e.allOf.length;n++)i=X.intersection(i,N6(e.allOf[n],t));n=i}}e.nullable===!0&&t.version===`openapi-3.0`&&(n=X.nullable(n)),e.readOnly===!0&&(n=X.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let i={};for(let t of[`$id`,`id`,`$comment`,`$anchor`,`$vocabulary`,`$dynamicRef`,`$dynamicAnchor`])t in e&&(i[t]=e[t]);for(let t of[`contentEncoding`,`contentMediaType`,`contentSchema`])t in e&&(i[t]=e[t]);if(e.type===`object`&&e.$ref===void 0){e.propertyNames!==void 0&&!O6(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(let t of[`minProperties`,`maxProperties`])e[t]!==void 0&&(i[t]=e[t])}if(e.type===`array`&&e.$ref===void 0){e.contains!==void 0&&!O6(e.contains)&&(i.contains=e.contains);for(let t of[`uniqueItems`,`minContains`,`maxContains`])e[t]!==void 0&&(i[t]=e[t])}for(let t of Object.keys(e))F6.has(t)||BG(i,t,e[t]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function P6(e,t){if(typeof e==`boolean`)return e?X.any():X.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw Error(`fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas`)}let r={version:S6(n,t?.defaultTarget),defs:n.$defs||n.definitions||{},refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??wQ};return N6(n,r)}var X,F6,I6,L6,R6,z6=n((()=>{TQ(),KK(),I0(),x6(),m6(),X={...t2,...F0,iso:g6},F6=new Set(`$schema.$ref.$defs.definitions.$id.id.$comment.$anchor.$vocabulary.$dynamicRef.$dynamicAnchor.type.enum.const.anyOf.oneOf.allOf.not.properties.required.additionalProperties.patternProperties.propertyNames.minProperties.maxProperties.items.prefixItems.additionalItems.minItems.maxItems.uniqueItems.contains.minContains.maxContains.minLength.maxLength.pattern.format.minimum.maximum.exclusiveMinimum.exclusiveMaximum.multipleOf.description.default.contentEncoding.contentMediaType.contentSchema.unevaluatedItems.unevaluatedProperties.if.then.else.dependentSchemas.dependentRequired.nullable.readOnly`.split(`.`)),I6=new Set([`items`,`prefixItems`,`additionalItems`,`additionalProperties`,`contains`,`propertyNames`,`not`,`if`,`then`,`else`,`allOf`,`anyOf`,`oneOf`,`unevaluatedItems`,`unevaluatedProperties`,`contentSchema`]),L6=new Set([`properties`,`patternProperties`,`dependentSchemas`,`dependencies`,`$defs`,`definitions`]),R6=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/})),B6=n((()=>{P0(),m6(),I0(),V0(),e2(),h6(),N0(),z6(),$Z(),KK(),m6(),bQ(),x6()})),V6=n((()=>{B6(),B6()}));function H6(e,t,n=`/`){let r=c8.safeParse(e);if(!r.success)return!0;let i=U6(t,G6(r.data.path,n));return r.data.equals===void 0?r.data.in===void 0?i!=null&&i!==``&&i!==!1:r.data.in.includes(i):i===r.data.equals}function U6(e,t){if(t===``||t===`/`)return e;let n=e;for(let e of t.replace(/^\//,``).split(`/`)){if(typeof n!=`object`||!n)return;let t=e.replace(/~1/g,`/`).replace(/~0/g,`~`);n=n[t]}return n}function W6(e,t,n){if(t===``||t===`/`)return n;let r=t.replace(/^\//,``).split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)),i=(e,t)=>{let a=r[t];if(a===`__proto__`||a===`constructor`||a===`prototype`)return e;let o=t===r.length-1,s=Array.isArray(e)?[...e]:typeof e==`object`&&e?{...e}:/^\d+$/.test(a)?[]:{},c=s;return o?n===void 0?Array.isArray(s)?s.splice(Number(a),1):delete c[a]:c[a]=n:c[a]=i(c[a],t+1),s};return i(e,0)}function G6(e,t){return e.startsWith(`/`)?e:e===``||e===`.`?t||`/`:`${t===`/`?``:t}/${e}`}function K6(e,t,n=0){if(typeof e!=`object`||!e||n>32)return e;if(Array.isArray(e))return e.map(e=>K6(e,t,n+1));if(f8(e))return U6(t.data,G6(e[`@path`],t.scope));if(p8(e)){let r=Object.hasOwn(t.functions,e[`@call`])?t.functions[e[`@call`]]:void 0;return r?r(Object.fromEntries(Object.entries(e.args??{}).map(([e,r])=>[e,K6(r,t,n+1)])),t):void 0}return Object.fromEntries(Object.entries(e).map(([e,r])=>[e,K6(r,t,n+1)]))}var q6,J6,Y6,X6,Z6,Q6,Z,$6,e8,t8,n8,r8,i8,a8,o8,s8,c8,l8,u8,d8,f8,p8,m8=n((()=>{V6(),q6=[`v0.9`,`v0.9.1`],J6=t4({"@path":q()}).describe(`A value read from the data model at this path.`),Y6=t4({"@call":q(),args:c4(q(),Y2()).optional(),catalogId:q().optional()}).describe(`A call to one of the catalog's functions.`),X6=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Z6=`a binding ({ "@path": "/a" }) or a function call ({ "@call": "name", "args": { … } })`,Q6=e=>({error:()=>`Expected ${e}, ${Z6}.`}),Z=r4([q(),J6,Y6],Q6(`text`)),$6=r4([F2(),J6,Y6],Q6(`a number`)),e8=r4([V2(),J6,Y6],Q6(`true or false`)),t8=r4([q(),F2(),V2(),J(Y2()),J6,Y6],Q6(`text, a number, true or false, a list`)),n8=/^[\p{XID_Start}_][\p{XID_Continue}]*$/u,r8=16384,i8=c4(q().regex(n8,`An extension name must be an identifier.`),Y2()),a8=t4({extensions:i8.optional()}).refine(e=>JSON.stringify(e).length<=r8,`Metadata is limited to ${r8} characters of JSON.`),o8=t4({label:Z.optional(),description:Z.optional(),live:Y([`off`,`polite`,`assertive`]).optional(),hidden:e8.optional()}),s8=r4([q(),F2(),V2()]),c8=t4({path:q().describe(`A place in the data model, as a binding's path is written.`),equals:s8.optional().describe(`Shown only while the value there is this.`),in:J(s8).min(1).max(50).optional().describe(`Shown only while the value there is one of these.`)}).refine(e=>e.equals===void 0||e.in===void 0,{message:"Give `equals` or `in`, not both."}).describe(`Shows the component only while a value in the data model is what this says: a field for a table name only once "Table" is chosen.`),l8=q().describe(`ID of a child component.`),u8=r4([J(q()),t4({componentId:q(),path:q()})],{error:()=>`Expected a list of component ids, or { componentId, path } to repeat one component for each item of a list in the data model.`}),d8=r4([t4({event:t4({name:q(),userMessage:Z.optional(),context:c4(q(),t8).optional()})}),t4({functionCall:Y6})],{error:e=>X6(e.input)&&Object.hasOwn(e.input,`@call`)?'In an action, a function call sits inside `functionCall`: { "functionCall": { "@call": "openUrl", "args": { "url": "https://…" } } }.':X6(e.input)&&Object.hasOwn(e.input,`name`)?'In an action, an event sits inside `event`: { "event": { "name": "…", "context": { … } } }.':`Expected { "event": { "name": "…", "context": { … } } } to send an event, or { "functionCall": { "@call": "openUrl", "args": { "url": "https://…" } } } to run a function.`}),f8=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.keys(e);return t.length===1&&t[0]===`@path`&&typeof e[`@path`]==`string`},p8=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e[`@call`]==`string`}));function h8(e,t=0){if(t>32||typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>h8(e,t+1));let n=e,r=Object.keys(n);return r.length===1&&r[0]===`path`&&typeof n.path==`string`?{"@path":n.path}:typeof n.call==`string`&&!(`@call`in n)?{"@call":n.call,...y8(n.args)?{args:h8(n.args,t+1)}:{}}:Object.fromEntries(r.map(e=>[e,h8(n[e],t+1)]))}function g8(e){let t={};for(let[n,r]of Object.entries(e))n===`id`||n===`component`?t[n]=r:n===`accessibility`&&!(`@accessibility`in e)?t[`@accessibility`]=h8(r):n===`checks`&&!(`@checks`in e)?t[`@checks`]=h8(r):t[n]=n.startsWith(`@`)?r:h8(r);return t}function _8(e,t){let n=y8(e)&&y8(e.extensions)?e.extensions:{},r={...t,...n};return Object.keys(r).length>0?{...y8(e)?e:{},extensions:r}:void 0}function v8(e){if(!S8(e))return e;let t=e;if(y8(t.createSurface)){let{theme:e,expects:n,metadata:r,...i}=t.createSurface,a=_8(r,{...y8(e)&&Object.keys(e).length>0?{[b8]:e}:{},...y8(n)&&Object.keys(n).length>0?{[x8]:n}:{}});return{...t,version:`1.0`,createSurface:{...i,...a?{metadata:a}:{}}}}if(y8(t.updateComponents)){let e=t.updateComponents.components;return{...t,version:`1.0`,updateComponents:{...t.updateComponents,components:Array.isArray(e)?e.map(e=>y8(e)&&typeof e.id==`string`&&typeof e.component==`string`?g8(e):e):e}}}return y8(t.updateDataModel)?{...t,version:`1.0`,updateDataModel:{...t.updateDataModel,value:t.updateDataModel.value===void 0?null:t.updateDataModel.value}}:{...t,version:`1.0`}}var y8,b8,x8,S8,C8=n((()=>{m8(),y8=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b8=`surfaces_theme`,x8=`surfaces_expects`,S8=e=>y8(e)&&typeof e.version==`string`&&q6.includes(e.version)}));function w8(e){if(typeof e==`string`)try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.href:void 0}catch{return}}var T8,E8,D8=n((()=>{V6(),m8(),T8=e=>typeof e==`bigint`?Number(e):typeof e==`number`?e:Number(e),E8={formatString:{description:'Builds text from a template. "${path}" is replaced by the data model value at that path. "${path|not chosen yet}" gives the words to use while there is no value there (nothing, or empty text), so a summary of a form never reads as a gap.',args:{value:q()},returnType:`string`,implementation:(e,t)=>String(e.value??``).replace(/\$\{([^}]*)\}/g,(e,n)=>{let r=n.indexOf(`|`),i=r===-1?n:n.slice(0,r),a=r===-1?``:n.slice(r+1).trim(),o=U6(t.data,G6(i.trim(),t.scope));return o==null||typeof o==`object`||o===``?a:String(o)})},formatNumber:{description:`Formats a number with grouping and a fixed number of decimals.`,args:{value:Y2(),decimals:F2().optional(),grouping:V2().optional()},returnType:`string`,implementation:e=>{let t=T8(e.value);if(!Number.isFinite(t))return``;let n=typeof e.decimals==`number`?e.decimals:void 0;return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n??2,useGrouping:e.grouping!==!1}).format(t)}},formatCurrency:{description:`Formats a number as money in the given ISO 4217 currency.`,args:{value:Y2(),currency:q()},returnType:`string`,implementation:e=>{let t=T8(e.value);if(!Number.isFinite(t))return``;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:String(e.currency??`USD`)}).format(t)}catch{return String(t)}}},formatDate:{description:`Formats a date or time. "format" is "date", "time" or "datetime".`,args:{value:Y2(),format:Y([`date`,`time`,`datetime`]).optional()},returnType:`string`,implementation:e=>{let t=new Date(e.value);if(Number.isNaN(t.getTime()))return``;let n=e.format??`date`;return new Intl.DateTimeFormat(`en-US`,{dateStyle:n===`time`?void 0:`medium`,timeStyle:n===`date`?void 0:`short`,timeZone:`UTC`}).format(t)}},openUrl:{description:`Opens a web link in a new tab. Only http and https links are allowed.`,args:{url:q()},returnType:`void`,action:!0,implementation:e=>{let t=w8(e.url);t&&typeof window<`u`&&window.open(t,`_blank`,`noopener,noreferrer`)}}}}));function O8(e){return n4(e.context??{})}function k8(e){if(!e||typeof e!=`object`||Array.isArray(e))return{error:`A contract is a JSON Schema object.`};try{return{schema:P6(e)}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}function A8(e){if(e.code!==`invalid_union`||!e.errors?.length)return[e];let t=e=>e.some(e=>e.path.length===0&&e.code===`invalid_type`)?-1:Math.min(...e.map(e=>e.path.length)),n=e.errors.filter(e=>e.length>0).map(e=>({branch:e,rank:t(e)})),r=Math.max(...n.map(e=>e.rank)),i=n.filter(e=>e.rank===r);return r<1||i.length!==1?[e]:i[0].branch.flatMap(t=>A8({...t,path:[...e.path,...t.path]}))}function j8(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,`height`in t.props||`minHeight`in t.props?t:{...t,props:{...t.props,minHeight:L8}}]))}function M8(e){let t=new Map;for(let[n,r]of Object.entries(e.components))t.set(n,t4({id:q().min(1).describe(`Unique within the surface. The top component must be "root".`),component:m4(n),"@catalogId":m4(e.id).optional().describe(`The component's catalog. This renderer draws one catalog per surface.`),"@accessibility":o8.optional(),"@metadata":a8.optional().describe(`Extensions by name. Never drawn, resolved or run.`),visibleWhen:c8.optional(),...r.props}));let n={...e,functions:{...E8,...e.functions},schema:e=>t.get(e),validateComponent(e){let n=e?.component,r=typeof n==`string`?t.get(n):void 0;if(!r)return[{path:`/component`,message:`Unknown component ${JSON.stringify(n)}. Available: ${[...t.keys()].join(`, `)}.`}];let i=r.safeParse(e);return i.success?[]:N8(i.error)},validateMessage(t){let r=typeof t==`object`&&t?t.version:void 0;if(typeof r==`string`&&r!==`1.0`&&!q6.includes(r))return[{path:`/version`,message:`This renderer reads A2UI 1.0 (and ${q6.join(`, `)}), not ${r}.`}];let i=v8(t),a=typeof i==`object`&&i?i:{},o=Object.keys(I8).find(e=>Object.hasOwn(a,e));if(!o)return[{path:`/`,message:`Expected one of ${Object.keys(I8).join(`, `)}.`}];let s=I8[o].safeParse(i);if(!s.success)return N8(s.error);if(o===`createSurface`){let t=a.createSurface;if(t.catalogId!==void 0&&t.catalogId!==e.id)return[{path:`/createSurface/catalogId`,message:`This renderer supports catalog ${e.id}.`}];let r=t.metadata?.extensions?.[x8],i=typeof r==`object`&&r&&!Array.isArray(r)?r:{};return[...r!==void 0&&i!==r?[{path:`/createSurface/metadata/extensions/${x8}`,message:`Expected event names mapped to JSON Schemas.`}]:[],...Object.entries(i).flatMap(([e,t])=>{let n=k8(t);return`error`in n?[{path:`/createSurface/metadata/extensions/${x8}/${e}`,message:`Not a usable JSON Schema: ${n.error}`}]:[]}),...(t.components??[]).flatMap((e,t)=>n.validateComponent(e).map(e=>({...e,path:`/createSurface/components/${t}${e.path}`})))]}return o===`updateComponents`?a.updateComponents.components.flatMap((e,t)=>n.validateComponent(e).map(e=>({...e,path:`/updateComponents/components/${t}${e.path}`}))):[]}};return{...n,names:Object.keys(e.components)}}var N8,P8,F8,I8,L8,R8=n((()=>{V6(),m8(),C8(),D8(),N8=(e,t=``)=>e.issues.flatMap(A8).map(e=>({path:`${t}/${e.path.join(`/`)}`.replace(/\/$/,``)||`/`,message:e.message})),P8=m4(`1.0`),F8=q().min(1),I8={createSurface:t4({version:P8,createSurface:t4({surfaceId:F8,catalogId:q().optional(),sendDataModel:V2().optional(),components:J(Y2()).optional(),dataModel:Y2().optional(),metadata:a8.optional()})}),updateComponents:t4({version:P8,updateComponents:t4({surfaceId:F8,components:J(Y2()).min(1)})}),updateDataModel:t4({version:P8,updateDataModel:t4({surfaceId:F8,path:q().optional(),value:Y2()}).refine(e=>Object.hasOwn(e,`value`),{path:[`value`],message:`Give a value. null removes what is at the path.`})}),deleteSurface:t4({version:P8,deleteSurface:t4({surfaceId:F8})})},L8=F2().int().min(24).max(1600).optional().describe(`The least height of this component's box, in pixels. It is as tall as what it holds, or this, whichever is more.`)})),z8,B8,V8,H8,U8,W8,G8,K8,q8,J8,Y8,X8,Z8,Q8,$8,e5,t5=n((()=>{kM(),V6(),R8(),m8(),z8=t4({name:q().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).describe(`The key the value is sent and stored under.`),label:q(),type:Y([`text`,`longtext`,`number`,`integer`,`boolean`,`date`,`datetime`,`choice`]),required:V2().optional(),options:J(q()).max(50).optional().describe(`For choice.`),min:F2().optional(),max:F2().optional(),step:F2().positive().optional(),maxLength:F2().int().positive().optional(),pattern:q().max(200).optional().describe(`A regular expression the whole text must match.`),help:q().optional(),placeholder:q().optional(),visibleWhen:t4({field:q().describe(`The name of another field of this form.`),equals:r4([q(),F2(),V2()]).optional().describe(`Asked only while that field's value is this.`),in:J(r4([q(),F2(),V2()])).min(1).max(50).optional().describe(`Asked only while that field's value is one of these.`)}).refine(e=>e.equals===void 0||e.in===void 0,{message:"Give `equals` or `in`, not both."}).optional().describe("Asks for this field only while another field of the form holds a value (with neither `equals` nor `in`, any value). A field that is not asked for is not drawn, not required, and sent as null.")}),B8=J(z8).min(1).max(40).superRefine((e,t)=>{let n=new Set(e.map(e=>e.name));e.forEach((e,r)=>{let i=e.visibleWhen?.field;i!==void 0&&(i===e.name?t.addIssue({code:`custom`,path:[r,`visibleWhen`,`field`],message:`A field cannot wait on itself.`}):n.has(i)||t.addIssue({code:`custom`,path:[r,`visibleWhen`,`field`],message:`This form has no field "${i}". Its fields are: ${[...n].join(`, `)}.`}))})}),V8=[`none`,1,2,3,4,6,8],H8=r4([m4(`none`),m4(1),m4(2),m4(3),m4(4),m4(6),m4(8)]),U8=H8.optional().describe('The space between children, as a step of the theme\'s spacing scale (`--sf-space-<step>`), or "none". Defaults to 4.'),W8=H8.optional(),G8=e=>`The space inside the edge, around the children, as a step of the theme's spacing scale (\`--sf-space-<step>\`), or "none". Defaults to ${e===`none`?`"none"`:e}.`,K8={min:24,max:1600},q8=r4([m4(`hug`),m4(`fill`),t4({fixed:F2().min(K8.min).max(K8.max).describe(`A width in pixels, ${K8.min} to ${K8.max}.`)})]),J8=J(q8).min(1).max(12).optional(),Y8="The value is written to the data model at `value.path` as the person types, so other components (a Button's event context, a Text) can bind to it. Nothing is sent until a control sends an event.",X8=e=>q().describe(e),Z8={Button:{press:{description:`When pressed. Carries only the context declared in the action.`}},SideNav:{select:{description:`When an item without a link is chosen.`,context:{id:X8(`the item's id`)}}},Form:{submit:{description:`After the values pass every check and, when the page has a forms backend, after it stored them.`,context:{formId:X8(`the form`),values:c4(q(),Y2()).describe(`the values as stored`),submissionId:X8(`the backend's id, or empty with no backend`)}}}},Q8={Text:{description:`A heading, paragraph or caption.`,props:{text:Z,variant:Y([`h1`,`h2`,`h3`,`h4`,`h5`,`body`,`caption`]).optional()},example:{id:`title`,component:`Text`,text:`Revenue this quarter`,variant:`h2`}},Row:{description:"Places children side by side. Wraps on narrow screens unless `wrap` is false. Children share the width equally unless `widths` gives each its share, or `sizes` says how each is sized (content width, fill, or fixed pixels); `sizes` wins over `widths` when both have one entry per child. `gap` and `padding` are steps of the theme's spacing scale.",props:{children:u8,widths:J(F2().positive()).min(1).max(12).optional().describe("The share of the width each child takes, one per child: [2, 1] makes the first twice as wide as the second. Used when it has one entry per child and `sizes` is not used."),sizes:J8.describe('How each child is sized, one per child: "hug" keeps its content\'s width and does not grow, "fill" grows to share the space left, { fixed: 240 } is that many pixels wide. Used when it has one entry per child, in place of `widths`. Narrow screens stack the children unless `wrap` is false.'),wrap:V2().optional().describe(`Whether children move onto a new line when they do not fit, and stack on narrow screens. Defaults to true; false keeps them on one line, each shrinking to fit.`),gap:U8,padding:W8.describe(G8(`none`)),justify:Y([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).optional(),align:Y([`start`,`center`,`end`,`stretch`]).optional()},example:{id:`stats`,component:`Row`,children:[`revenue`,`orders`]}},Column:{description:"Stacks children top to bottom. Use it as the root of most surfaces. `gap` and `padding` are steps of the theme's spacing scale.",props:{children:u8,gap:U8,padding:W8.describe(G8(`none`)),justify:Y([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).optional(),align:Y([`start`,`center`,`end`,`stretch`]).optional()},example:{id:`root`,component:`Column`,children:[`title`,`stats`,`chart`]}},Grid:{description:'Lays children out in columns that wrap onto new rows. Use it for dashboards: a row of numbers, then charts side by side. Columns are equal unless `widths` gives each its share, as when a person resizes them by hand. Children in a row are stretched to the tallest one; set `align: "start"` when the row mixes content of different heights, such as a chart beside a form, so each keeps its own height. `gap` is a step of the theme\'s spacing scale, between rows and columns alike.',props:{children:u8,columns:F2().int().min(1).max(6).optional().describe(`Columns per row. Defaults to 2. Narrow screens use one.`),widths:J(F2().positive()).min(1).max(6).optional().describe(`The share of the width each column takes, one per column: [2, 1] makes the first twice as wide as the second. Used when it has one entry per column; otherwise columns are equal.`),align:Y([`start`,`center`,`end`,`stretch`]).optional().describe(`Where each child sits in the height of its row. Defaults to stretch: every child as tall as the tallest. Use start for mixed content, so each keeps its own height.`),gap:U8},example:{id:`tiles`,component:`Grid`,columns:3,children:[`revenue`,`orders`,`average`]}},Card:{description:"A bordered container for one child, to group related content. `padding` is a step of the theme's spacing scale.",props:{child:l8,padding:W8.describe(G8(`4`))},example:{id:`panel`,component:`Card`,child:`chart`}},Divider:{description:`A thin line between sections.`,props:{axis:Y([`horizontal`,`vertical`]).optional()},example:{id:`rule`,component:`Divider`}},SideNav:{description:"Navigation down the side of a surface: groups of items, with the current one marked. A person can fold it away: it then keeps only a slim strip for its menu button, which slides it back in over the surface (never over anything outside it). In a narrow surface or on a narrow screen it is always folded. An item with `href` is a link (http and https only); one without sends the event with its `id`. Bind `current` to a data path to mark the item for what is showing.",props:{label:q().optional().describe(`What the navigation is for, for assistive technology.`),groups:J(t4({label:q().optional(),items:J(t4({id:q(),label:q(),href:q().optional()})).min(1).max(30)})).min(1).max(12),current:Z.optional().describe(`The id of the item for what is showing.`),pinned:V2().optional().describe(`Whether it starts open beside the content. Defaults to true.`),action:d8.optional()},example:{id:`nav`,component:`SideNav`,label:`Sections`,groups:[{label:`Sales`,items:[{id:`overview`,label:`Overview`},{id:`orders`,label:`Orders`}]}],current:`overview`,action:{event:{name:`navigate`}}}},Tabs:{description:`Switches between several children, one visible at a time.`,props:{tabs:J(t4({title:Z,child:l8})).min(1)},example:{id:`views`,component:`Tabs`,tabs:[{title:`Chart`,child:`chart`},{title:`Table`,child:`table`}]}},Button:{description:'A control that sends an event back to the agent or opens a link. Its label is a child Text. To open a link, the action is a function call in place of an event: `"action": {"functionCall": {"@call": "openUrl", "args": {"url": "https://example.com/start"}}}`.',props:{child:l8,variant:Y([`default`,`primary`,`borderless`]).optional(),action:d8,requires:J(q()).max(40).optional().describe("Ids of inputs (TextField, NumberField, ChoicePicker, CheckBox, DateTimeInput) this button waits for. While any of them is missing or wrong the button is marked unavailable; a press then sends nothing, has each say what is wrong beside it and moves to the first. An input that is not shown (`visibleWhen`) is not waited for.")},example:{id:`refresh`,component:`Button`,child:`refresh-label`,variant:`primary`,action:{event:{name:`refresh`,context:{region:{"@path":`/region`}}}}}},TextField:{description:`A labelled text box. ${Y8}`,props:{label:Z,value:J6,multiline:V2().optional(),placeholder:q().optional(),help:Z.optional().describe(`A sentence under the field: what to enter, or why it is asked.`),maxLength:F2().int().positive().optional(),required:V2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`),pattern:q().max(200).optional().describe(`A regular expression the whole text must match; a value that does not is said so beside the field.`)},example:{id:`note`,component:`TextField`,label:`Note`,value:{"@path":`/review/note`},multiline:!0}},NumberField:{description:`A labelled number box. ${Y8}`,props:{label:Z,value:J6,min:F2().optional().describe(`A number below it is said so beside the field.`),max:F2().optional().describe(`A number above it is said so beside the field.`),step:F2().positive().optional(),help:Z.optional(),required:V2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`threshold`,component:`NumberField`,label:`Alert above`,value:{"@path":`/threshold`},min:0,step:50}},ChoicePicker:{description:`Pick one of a few options: radio buttons for four or fewer, a list for more. ${Y8}`,props:{label:Z,value:J6,options:J(q()).min(1).max(50),help:Z.optional(),required:V2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`region`,component:`ChoicePicker`,label:`Region`,value:{"@path":`/region`},options:[`Europe`,`Americas`,`Asia`]}},CheckBox:{description:`A yes-or-no box. ${Y8}`,props:{label:Z,value:J6,help:Z.optional(),required:V2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`include-returns`,component:`CheckBox`,label:`Include returns`,value:{"@path":`/includeReturns`}}},DateTimeInput:{description:`A date, or a date and time (kept in UTC). ${Y8}`,props:{label:Z,value:J6,mode:Y([`date`,`datetime`]).optional(),help:Z.optional(),required:V2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`from`,component:`DateTimeInput`,label:`From`,value:{"@path":`/from`},mode:`date`}},Slider:{description:`A number chosen along a range, with its value shown in words. ${Y8}`,props:{label:Z,value:J6,min:F2(),max:F2(),step:F2().positive().optional(),help:Z.optional()},example:{id:`confidence`,component:`Slider`,label:`Confidence`,value:{"@path":`/confidence`},min:0,max:100,step:5}},Form:{description:"A form that checks what a person enters and submits it. Give the fields and their rules; the form draws a labelled input for each, shows errors beside them and sends nothing while any is wrong. A field with `visibleWhen: { field, equals }` is asked for only once another field holds that value. When the page has a forms backend, values go to the form with this `formId` there (the backend decides where they are stored; you never name a table); either way your event receives them. Use it instead of loose inputs and a Button whenever values must be checked or kept.",props:{formId:q().min(1),title:Z.optional(),description:Z.optional(),fields:B8,values:J6.optional().describe(`Where the entered values live in the data model, to prefill them or show them elsewhere.`),submitLabel:q().optional(),action:d8.optional()},example:{id:`case-review`,component:`Form`,formId:`case-review`,title:`Review this alert`,fields:[{name:`decision`,label:`Decision`,type:`choice`,options:[`Fraud`,`Not fraud`,`Needs more information`],required:!0},{name:`amount_at_risk`,label:`Amount at risk`,type:`number`,min:0},{name:`note`,label:`Note`,type:`longtext`,maxLength:500}],values:{"@path":`/review`},submitLabel:`Save decision`,action:{event:{name:`case_reviewed`}}}},Markdown:{description:`Formatted text: headings, lists, tables, links and code. Use it for explanations longer than a line.`,props:{text:Z},example:{id:`notes`,component:`Markdown`,text:`Revenue is **up 5%**.
|
|
99
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function w1(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;w1(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}function T1(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function E1(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!A1.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??T1(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}JG(n,r,e.length===1?e[0]:E1(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=T1(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function D1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of A1)if(t in e)return;let n=t.filter(e=>j1.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=E1(t);else{let e=n[0],i=j1.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>E1([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,v1(e,r))}function O1(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):v1(i,s),v1(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())w1(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])D1(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}v1(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,JG(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:N1(t,`input`,e.processors),output:N1(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function k1(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return k1(r.element,n);if(r.type===`set`)return k1(r.valueType,n);if(r.type===`lazy`)return k1(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return k1(r.innerType,n);if(r.type===`intersection`)return k1(r.left,n)||k1(r.right,n);if(r.type===`record`||r.type===`map`)return k1(r.keyType,n)||k1(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:k1(r.in,n)||k1(r.out,n);if(r.type===`object`){for(let e in r.shape)if(k1(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(k1(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(k1(e,n))return!0;return!!(r.rest&&k1(r.rest,n))}return!1}var A1,j1,M1,N1,P1=n((()=>{NQ(),eq(),A1=new Set([`type`,`properties`,`required`,`additionalProperties`]),j1=[`oneOf`,`anyOf`],M1=(e,t={})=>n=>{let r=y1({...n,processors:t});return x1(e,r),C1(r,e),O1(r,e)},N1=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=y1({...i??{},target:a,io:t,processors:n});return x1(e,o),C1(o,e),O1(o,e)}}));function F1(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)X1[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&B1(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&B1(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&V1(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&V1(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&U1(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&G1(t,i.mime);for(let e of i.patterns??[])W1(t,e);return t}function I1(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?I1(t.out):t.type===`catch`?I1(t.innerType):e._zod.optin}function L1(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=L1(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>L1(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?zJ:RJ).source)),p}function R1(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of O0.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=L1(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}function z1(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(b1(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),M0):JSON.parse(o)}var B1,V1,H1,U1,W1,G1,K1,q1,J1,Y1,X1,Z1,Q1,$1,e0,t0,n0,r0,i0,a0,o0,s0,c0,l0,u0,d0,f0,p0,m0,h0,g0,_0,v0,y0,b0,x0,S0,C0,w0,T0,E0,D0,O0,k0,A0,j0,M0,N0,P0,F0,I0,L0,R0,z0,B0,V0=n((()=>{sY(),sQ(),P1(),eq(),B1=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},V1=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},H1=(e,t)=>{B1(e,`minimum`,t),V1(e,`maximum`,t)},U1=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},W1=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},G1=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},K1=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},q1=(e,t)=>B1(e,`minimum`,t.minimum),J1=(e,t)=>V1(e,`maximum`,t.maximum),Y1=e=>(t,n)=>{K1(t,n.format);let[r,i]=e[n.format];B1(t,`minimum`,r),V1(t,`maximum`,i)},X1={greater_than:(e,t)=>B1(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>V1(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>U1(e,t.value),number_format:Y1(qK),bigint_format:Y1(JK),min_length:q1,max_length:J1,length_equals:(e,t)=>H1(e,t.length),min_size:q1,max_size:J1,size_equals:(e,t)=>H1(e,t.size),string_format:(e,t)=>{K1(e,t.format),t.pattern&&W1(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>G1(e,t.mime)},Z1={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Q1=new Map([[tZ,wJ],[rZ,TJ]]),$1=e=>Q1.get(e)??e,e0=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=F1(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Z1[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map($1);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},t0=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=F1(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):b1(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},n0=(e,t,n,r)=>{n.type=`boolean`},r0=(e,t,n,r)=>{b1(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},i0=(e,t,n,r)=>{b1(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},a0=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},o0=(e,t,n,r)=>{b1(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},s0=(e,t,n,r)=>{b1(e,t,n,r,`Void cannot be represented in JSON Schema`)},c0=(e,t,n,r)=>{n.not={}},l0=(e,t,n,r)=>{},u0=(e,t,n,r)=>{},d0=(e,t,n,r)=>{b1(e,t,n,r,`Date cannot be represented in JSON Schema`)},f0=(e,t,n,r)=>{let i=e._zod.def,a=BG(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},p0=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(b1(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(b1(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},m0=(e,t,n,r)=>{b1(e,t,n,r,`NaN cannot be represented in JSON Schema`)},h0=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},g0=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=F1(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},_0=(e,t,n,r)=>{n.type=`boolean`},v0=(e,t,n,r)=>{b1(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},y0=(e,t,n,r)=>{b1(e,t,n,r,`Function types cannot be represented in JSON Schema`)},b0=(e,t,n,r)=>{b1(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},x0=(e,t,n,r)=>{b1(e,t,n,r,`Map cannot be represented in JSON Schema`)},S0=(e,t,n,r)=>{b1(e,t,n,r,`Set cannot be represented in JSON Schema`)},C0=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=F1(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=x1(a.element,t,{...r,path:[...r.path,`items`]})},w0=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&b1(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)JG(i.properties,e,x1(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?I1(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=x1(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},T0=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>x1(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},E0=(e,t,n,r)=>{let i=e._zod.def,a=x1(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=x1(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},D0=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>x1(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?x1(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?I1(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=F1(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)},O0=new WeakMap,k0=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=F1(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=x1(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)JG(i.patternProperties,$1(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=x1(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=O0.get(t);n||(n=[],O0.set(t,n),t.deferred.push(()=>R1(t))),n.push(e)}i.additionalProperties=x1(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&I1(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},A0=(e,t,n,r)=>{let i=e._zod.def,a=x1(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},j0=(e,t,n,r)=>{let i=e._zod.def;x1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},M0=Symbol(),N0=(e,t,n,r)=>{let i=e._zod.def;x1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=z1(i.defaultValue,e,t,n,r);o!==M0&&(n.default=o)},P0=(e,t,n,r)=>{let i=e._zod.def;x1(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=z1(i.defaultValue,e,t,n,r);o!==M0&&(n._prefault=o)},F0=(e,t,n,r)=>{let i=e._zod.def;x1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{b1(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},I0=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;x1(o,t,r);let s=t.seen.get(e);s.ref=o},L0=(e,t,n,r)=>{let i=e._zod.def;x1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},R0=(e,t,n,r)=>{let i=e._zod.def;x1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},z0=(e,t,n,r)=>{let i=e._zod.def;x1(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},B0=(e,t,n,r)=>{let i=e._zod.innerType;x1(i,t,r);let a=t.seen.get(e);a.ref=i}})),H0=n((()=>{lq(),Uq(),xq(),sQ(),TQ(),FY(),zY(),eq(),sY(),OQ(),NQ(),LY(),PQ(),_1(),P1(),V0(),P1()})),U0=i({endsWith:()=>Z$,gt:()=>N$,gte:()=>P$,includes:()=>Y$,length:()=>G$,lowercase:()=>q$,lt:()=>j$,lte:()=>M$,maxLength:()=>U$,maxSize:()=>B$,mime:()=>e1,minLength:()=>W$,minSize:()=>V$,multipleOf:()=>z$,negative:()=>I$,nonnegative:()=>R$,nonpositive:()=>L$,normalize:()=>n1,overwrite:()=>t1,positive:()=>F$,properties:()=>$$,property:()=>Q$,regex:()=>K$,size:()=>H$,slugify:()=>o1,startsWith:()=>X$,toLowerCase:()=>i1,toUpperCase:()=>a1,trim:()=>r1,uppercase:()=>J$}),W0=n((()=>{H0()}));function G0(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var K0,q0,J0,Y0=n((()=>{H0(),eq(),K0=new WeakSet([Object.prototype,Error.prototype]),q0=(e,t)=>{yq.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);K0.has(n)||(K0.add(n),G0(n,`format`,e=>t=>mq(e,t)),G0(n,`flatten`,e=>t=>pq(e,t)),G0(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,HG,2)}),G0(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,HG,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},J0=K(`ZodError`,q0,void 0,{Parent:Error})})),X0,Z0,Q0,$0,e2,t2,n2,r2,i2,a2,o2,s2,c2=n((()=>{H0(),Y0(),X0=Tq(J0),Z0=Dq(J0),Q0=kq(J0),$0=Aq(J0),e2=Fq(J0),t2=Iq(J0),n2=Lq(J0),r2=Rq(J0),i2=zq(J0),a2=Bq(J0),o2=Vq(J0),s2=Hq(J0)})),l2=i({ZodAny:()=>F3,ZodArray:()=>B3,ZodBase64:()=>b3,ZodBase64URL:()=>x3,ZodBigInt:()=>A3,ZodBigIntFormat:()=>j3,ZodBoolean:()=>k3,ZodCIDRv4:()=>v3,ZodCIDRv6:()=>y3,ZodCUID:()=>u3,ZodCUID2:()=>d3,ZodCatch:()=>s6,ZodCodec:()=>u6,ZodCreditCard:()=>C3,ZodCustom:()=>_6,ZodCustomStringFormat:()=>E3,ZodDate:()=>z3,ZodDefault:()=>r6,ZodDiscriminatedUnion:()=>W3,ZodE164:()=>S3,ZodEmail:()=>i3,ZodEmoji:()=>c3,ZodEnum:()=>X3,ZodExactOptional:()=>t6,ZodFile:()=>Q3,ZodFunction:()=>g6,ZodGUID:()=>a3,ZodIBAN:()=>w3,ZodIPv4:()=>h3,ZodIPv6:()=>_3,ZodISODate:()=>t3,ZodISODateTime:()=>e3,ZodISODuration:()=>r3,ZodISOTime:()=>n3,ZodInstanceOf:()=>b6,ZodIntersection:()=>G3,ZodJWT:()=>T3,ZodKSUID:()=>m3,ZodLazy:()=>m6,ZodLiteral:()=>Z3,ZodMAC:()=>g3,ZodMap:()=>J3,ZodNaN:()=>c6,ZodNanoID:()=>l3,ZodNever:()=>L3,ZodNonOptional:()=>a6,ZodNull:()=>P3,ZodNullable:()=>n6,ZodNumber:()=>D3,ZodNumberFormat:()=>O3,ZodObject:()=>V3,ZodOptional:()=>e6,ZodPipe:()=>l6,ZodPrefault:()=>i6,ZodPreprocess:()=>d6,ZodPromise:()=>h6,ZodReadonly:()=>f6,ZodRecord:()=>q3,ZodSet:()=>Y3,ZodString:()=>Q4,ZodStringFormat:()=>$4,ZodSuccess:()=>o6,ZodSymbol:()=>M3,ZodTemplateLiteral:()=>p6,ZodTransform:()=>$3,ZodTuple:()=>K3,ZodType:()=>X4,ZodULID:()=>f3,ZodURL:()=>s3,ZodUUID:()=>o3,ZodUndefined:()=>N3,ZodUnion:()=>H3,ZodUnknown:()=>I3,ZodVoid:()=>R3,ZodXID:()=>p3,ZodXor:()=>U3,_ZodString:()=>Z4,_default:()=>k4,_function:()=>H4,any:()=>n4,array:()=>J,base64:()=>M2,base64url:()=>N2,bigint:()=>X2,boolean:()=>Y2,catch:()=>N4,check:()=>U4,cidrv4:()=>A2,cidrv6:()=>j2,codec:()=>I4,creditCard:()=>F2,cuid:()=>S2,cuid2:()=>C2,currencyCode:()=>V2,custom:()=>W4,date:()=>o4,describe:()=>v6,discriminatedUnion:()=>p4,e164:()=>P2,email:()=>f2,emoji:()=>b2,enum:()=>Y,exactOptional:()=>E4,file:()=>C4,float32:()=>G2,float64:()=>K2,function:()=>H4,guid:()=>p2,hash:()=>H2,hex:()=>B2,hostname:()=>z2,httpUrl:()=>y2,iban:()=>I2,instanceof:()=>q4,int:()=>W2,int32:()=>q2,int64:()=>Z2,intersection:()=>m4,invertCodec:()=>L4,ipv4:()=>D2,ipv6:()=>k2,json:()=>J4,jwt:()=>L2,keyof:()=>s4,ksuid:()=>E2,lazy:()=>B4,literal:()=>S4,looseObject:()=>u4,looseRecord:()=>v4,mac:()=>O2,map:()=>y4,meta:()=>y6,nan:()=>P4,nanoid:()=>x2,nativeEnum:()=>x4,never:()=>i4,nonoptional:()=>j4,null:()=>t4,nullable:()=>D4,nullish:()=>O4,number:()=>U2,object:()=>c4,optional:()=>T4,partialRecord:()=>_4,pipe:()=>F4,prefault:()=>A4,preprocess:()=>Y4,promise:()=>V4,readonly:()=>R4,record:()=>g4,refine:()=>G4,set:()=>b4,strictObject:()=>l4,string:()=>q,stringFormat:()=>R2,stringbool:()=>x6,success:()=>M4,superRefine:()=>K4,symbol:()=>$2,templateLiteral:()=>z4,transform:()=>w4,tuple:()=>h4,uint32:()=>J2,uint64:()=>Q2,ulid:()=>w2,undefined:()=>e4,union:()=>d4,unknown:()=>r4,url:()=>v2,uuid:()=>m2,uuidv4:()=>h2,uuidv6:()=>g2,uuidv7:()=>_2,void:()=>a4,xid:()=>T2,xor:()=>f4});function u2(){cq.localeError||nq(EQ())}function d2(){cq.memoizer||nq({memoizer:pQ()})}function q(e){return IQ(Q4,e)}function f2(e){return LQ(i3,e)}function p2(e){return RQ(a3,e)}function m2(e){return zQ(o3,e)}function h2(e){return BQ(o3,e)}function g2(e){return VQ(o3,e)}function _2(e){return HQ(o3,e)}function v2(e){return UQ(s3,e)}function y2(e){return UQ(s3,{protocol:OJ,hostname:DJ,...G(e)})}function b2(e){return WQ(c3,e)}function x2(e){return GQ(l3,e)}function S2(e){return KQ(u3,e)}function C2(e){return qQ(d3,e)}function w2(e){return JQ(f3,e)}function T2(e){return YQ(p3,e)}function E2(e){return XQ(m3,e)}function D2(e){return ZQ(h3,e)}function O2(e){return $Q(g3,e)}function k2(e){return QQ(_3,e)}function A2(e){return e$(v3,e)}function j2(e){return t$(y3,e)}function M2(e){return n$(b3,e)}function N2(e){return r$(x3,e)}function P2(e){return i$(S3,e)}function F2(e){return a$(C3,e)}function I2(e){return o$(w3,e)}function L2(e){return s$(T3,e)}function R2(e,t,n={}){return g1(E3,e,t,n)}function z2(e){return g1(E3,`hostname`,EJ,e)}function B2(e){return g1(E3,`hex`,GJ,e)}function V2(e){return g1(E3,`currency_code`,jJ,e)}function H2(e,t){let n=`${e}_${t?.enc??`hex`}`,r=Wq[n];if(!r)throw Error(`Unrecognized hash format: ${n}`);return g1(E3,n,r,t)}function U2(e){return f$(D3,e)}function W2(e){return p$(O3,e)}function G2(e){return m$(O3,e)}function K2(e){return h$(O3,e)}function q2(e){return g$(O3,e)}function J2(e){return _$(O3,e)}function Y2(e){return v$(k3,e)}function X2(e){return y$(A3,e)}function Z2(e){return b$(j3,e)}function Q2(e){return x$(j3,e)}function $2(e){return S$(M3,e)}function e4(e){return C$(N3,e)}function t4(e){return w$(P3,e)}function n4(){return T$(F3)}function r4(){return E$(I3)}function i4(e){return D$(L3,e)}function a4(e){return O$(R3,e)}function o4(e){return k$(z3,e)}function J(e,t){return s1(B3,e,t)}function s4(e){let t=e._zod.def.shape;return Y(Object.keys(t))}function c4(e,t){let n={type:`object`,shape:e??{},...G(t)};return new V3(n)}function l4(e,t){return new V3({type:`object`,shape:e,catchall:i4(),...G(t)})}function u4(e,t){return new V3({type:`object`,shape:e,catchall:r4(),...G(t)})}function d4(e,t){return new H3({type:`union`,options:e,...G(t)})}function f4(e,t){return new U3({type:`union`,options:e,inclusive:!1,...G(t)})}function p4(e,t,n){return new W3({type:`union`,options:t,discriminator:e,...G(n)})}function m4(e,t){return new G3({type:`intersection`,left:e,right:t})}function h4(e,t,n){let r=t instanceof kX;return new K3({type:`tuple`,items:e,rest:r?t:null,...G(r?n:t)})}function g4(e,t,n){return!t||!t._zod?new q3({type:`record`,keyType:q(),valueType:e,...G(t)}):new q3({type:`record`,keyType:e,valueType:t,...G(n)})}function _4(e,t,n){return new q3({type:`record`,keyType:e,valueType:t,...G(n),partial:!0})}function v4(e,t,n){return new q3({type:`record`,keyType:e,valueType:t,mode:`loose`,...G(n)})}function y4(e,t,n){return new J3({type:`map`,keyType:e,valueType:t,...G(n)})}function b4(e,t){return new Y3({type:`set`,valueType:e,...G(t)})}function Y(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new X3({type:`enum`,entries:n,...G(t)})}function x4(e,t){return new X3({type:`enum`,entries:e,...G(t)})}function S4(e,t){return new Z3({type:`literal`,values:Array.isArray(e)?e:[e],...G(t)})}function C4(e){return c1(Q3,e)}function w4(e){return new $3({type:`transform`,transform:e})}function T4(e){return new e6({type:`optional`,innerType:e})}function E4(e){return new t6({type:`optional`,innerType:e})}function D4(e){return new n6({type:`nullable`,innerType:e})}function O4(e){return T4(D4(e))}function k4(e,t){return new r6({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():oK(t)}})}function A4(e,t){return new i6({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():oK(t)}})}function j4(e,t){return new a6({type:`nonoptional`,innerType:e,...G(t)})}function M4(e){return new o6({type:`success`,innerType:e})}function N4(e,t){return new s6({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:BK(t)})}function P4(e){return A$(c6,e)}function F4(e,t){return new l6({type:`pipe`,in:e,out:t})}function I4(e,t,n){return new u6({type:`pipe`,in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function L4(e){let t=e._zod.def;return new u6({type:`pipe`,in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function R4(e){return new f6({type:`readonly`,innerType:e})}function z4(e,t){return new p6({type:`template_literal`,parts:e,...G(t)})}function B4(e){return new m6({type:`lazy`,getter:e})}function V4(e){return new h6({type:`promise`,innerType:e})}function H4(e){return new g6({type:`function`,input:Array.isArray(e?.input)?h4(e?.input):e?.input??J(r4()),output:e?.output??r4()})}function U4(e){let t=new lY({check:`custom`});return t._zod.check=e,t}function W4(e,t){return l1(_6,e??(()=>!0),t)}function G4(e,t={}){return u1(_6,e,t)}function K4(e,t){return d1(e,t)}function q4(e,t={}){let n=new b6({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...G(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function J4(e){let t=B4(()=>d4([q(e),U2(),Y2(),t4(),J(t),g4(q(),t)]));return t}function Y4(e,t){return new d6({type:`pipe`,in:w4(e),out:t})}var X4,Z4,Q4,$4,e3,t3,n3,r3,i3,a3,o3,s3,c3,l3,u3,d3,f3,p3,m3,h3,g3,_3,v3,y3,b3,x3,S3,C3,w3,T3,E3,D3,O3,k3,A3,j3,M3,N3,P3,F3,I3,L3,R3,z3,B3,V3,H3,U3,W3,G3,K3,q3,J3,Y3,X3,Z3,Q3,$3,e6,t6,n6,r6,i6,a6,o6,s6,c6,l6,u6,d6,f6,p6,m6,h6,g6,_6,v6,y6,b6,x6,S6=n((()=>{H0(),V0(),sY(),P1(),OQ(),W0(),c2(),X4=K(`ZodType`,(e,t)=>(u2(),kX.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(tK(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return cK(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(G4(e,t))},superRefine(e,t){return this.check(K4(e,t))},overwrite(e){return this.check(t1(e))},optional(){return T4(this)},exactOptional(){return E4(this)},nullable(){return D4(this)},nullish(){return T4(D4(this))},nonoptional(e){return j4(this,e)},array(){return J(this)},or(e){return d4([this,e])},and(e){return m4(this,e)},transform(e){return F4(this,w4(e))},default(e){return k4(this,e)},prefault(e){return A4(this,e)},catch(e){return N4(this,e)},pipe(e){return F4(this,e)},readonly(){return R4(this)},describe(e){let t=this.clone();return MQ.add(t,{description:e}),t},meta(...e){if(e.length===0)return MQ.get(this);let t=this.clone();return MQ.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return PK(this,`~standard`,{...VY(this),jsonSchema:{input:N1(this,`input`),output:N1(this,`output`)}})},set"~standard"(e){NK(this,`~standard`,e)},parse:function e(t,n){return X0(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Z0(this,t,n,{callee:e})},safeParse(e,t){return Q0(this,e,t)},async safeParseAsync(e,t){return $0(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){NK(this,`spa`,e)},validate(e,t){return Nq(this,e,t)},validateAsync(e,t){return Pq(this,e,t)},encode:function e(t,n){return e2(this,t,n,{callee:e})},decode:function e(t,n){return t2(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await n2(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await r2(this,t,n,{callee:e})},safeEncode(e,t){return i2(this,e,t)},safeDecode(e,t){return a2(this,e,t)},async safeEncodeAsync(e,t){return o2(this,e,t)},async safeDecodeAsync(e,t){return s2(this,e,t)},toJSONSchema(e){return M1(this,{})(e)},get description(){return MQ.get(this)?.description},get _def(){return this._zod.def}}),Z4=K(`_ZodString`,(e,t)=>{jX.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>e0(e,t,n,r)},FK({format:e=>F1(e).format??null,minLength:e=>F1(e).minimum??null,maxLength:e=>F1(e).maximum??null},{regex(...e){return this.check(K$(...e))},includes(...e){return this.check(Y$(...e))},startsWith(...e){return this.check(X$(...e))},endsWith(...e){return this.check(Z$(...e))},min(...e){return this.check(W$(...e))},max(...e){return this.check(U$(...e))},length(...e){return this.check(G$(...e))},nonempty(...e){return this.check(W$(1,...e))},lowercase(e){return this.check(q$(e))},uppercase(e){return this.check(J$(e))},trim(){return this.check(r1())},normalize(...e){return this.check(n1(...e))},toLowerCase(){return this.check(i1())},toUpperCase(){return this.check(a1())},slugify(){return this.check(o1())}})),Q4=K(`ZodString`,(e,t)=>{jX.init(e,t),Z4.init(e,t)},{email(e){return this.check(LQ(i3,e))},url(e){return this.check(UQ(s3,e))},jwt(e){return this.check(s$(T3,e))},emoji(e){return this.check(WQ(c3,e))},guid(e){return this.check(RQ(a3,e))},uuid(e){return this.check(zQ(o3,e))},uuidv4(e){return this.check(BQ(o3,e))},uuidv6(e){return this.check(VQ(o3,e))},uuidv7(e){return this.check(HQ(o3,e))},nanoid(e){return this.check(GQ(l3,e))},cuid(e){return this.check(KQ(u3,e))},cuid2(e){return this.check(qQ(d3,e))},ulid(e){return this.check(JQ(f3,e))},base64(e){return this.check(n$(b3,e))},base64url(e){return this.check(r$(x3,e))},xid(e){return this.check(YQ(p3,e))},ksuid(e){return this.check(XQ(m3,e))},ipv4(e){return this.check(ZQ(h3,e))},ipv6(e){return this.check(QQ(_3,e))},cidrv4(e){return this.check(e$(v3,e))},cidrv6(e){return this.check(t$(y3,e))},e164(e){return this.check(i$(S3,e))},datetime(e){return this.check(c$(e3,e))},date(e){return this.check(l$(t3,e))},time(e){return this.check(u$(n3,e))},duration(e){return this.check(d$(r3,e))}}),$4=K(`ZodStringFormat`,(e,t)=>{MX.init(e,t),Z4.init(e,t)}),e3=K(`ZodISODateTime`,(e,t)=>{GX.init(e,t),$4.init(e,t)}),t3=K(`ZodISODate`,(e,t)=>{KX.init(e,t),$4.init(e,t)}),n3=K(`ZodISOTime`,(e,t)=>{qX.init(e,t),$4.init(e,t)}),r3=K(`ZodISODuration`,(e,t)=>{JX.init(e,t),$4.init(e,t)}),i3=K(`ZodEmail`,(e,t)=>{FX.init(e,t),$4.init(e,t)}),a3=K(`ZodGUID`,(e,t)=>{NX.init(e,t),$4.init(e,t)}),o3=K(`ZodUUID`,(e,t)=>{PX.init(e,t),$4.init(e,t)}),s3=K(`ZodURL`,(e,t)=>{LX.init(e,t),$4.init(e,t)}),c3=K(`ZodEmoji`,(e,t)=>{RX.init(e,t),$4.init(e,t)}),l3=K(`ZodNanoID`,(e,t)=>{zX.init(e,t),$4.init(e,t)}),u3=K(`ZodCUID`,(e,t)=>{BX.init(e,t),$4.init(e,t)}),d3=K(`ZodCUID2`,(e,t)=>{VX.init(e,t),$4.init(e,t)}),f3=K(`ZodULID`,(e,t)=>{HX.init(e,t),$4.init(e,t)}),p3=K(`ZodXID`,(e,t)=>{UX.init(e,t),$4.init(e,t)}),m3=K(`ZodKSUID`,(e,t)=>{WX.init(e,t),$4.init(e,t)}),h3=K(`ZodIPv4`,(e,t)=>{YX.init(e,t),$4.init(e,t)}),g3=K(`ZodMAC`,(e,t)=>{QX.init(e,t),$4.init(e,t)}),_3=K(`ZodIPv6`,(e,t)=>{ZX.init(e,t),$4.init(e,t)}),v3=K(`ZodCIDRv4`,(e,t)=>{$X.init(e,t),$4.init(e,t)}),y3=K(`ZodCIDRv6`,(e,t)=>{eZ.init(e,t),$4.init(e,t)}),b3=K(`ZodBase64`,(e,t)=>{nZ.init(e,t),$4.init(e,t)}),x3=K(`ZodBase64URL`,(e,t)=>{iZ.init(e,t),$4.init(e,t)}),S3=K(`ZodE164`,(e,t)=>{aZ.init(e,t),$4.init(e,t)}),C3=K(`ZodCreditCard`,(e,t)=>{sZ.init(e,t),$4.init(e,t)}),w3=K(`ZodIBAN`,(e,t)=>{cZ.init(e,t),$4.init(e,t)}),T3=K(`ZodJWT`,(e,t)=>{lZ.init(e,t),$4.init(e,t)}),E3=K(`ZodCustomStringFormat`,(e,t)=>{uZ.init(e,t),$4.init(e,t)}),D3=K(`ZodNumber`,(e,t)=>{dZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t0(e,t,n,r),e.isFinite=!0},FK({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=F1(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=F1(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=F1(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>F1(e).format??null},{gt(e,t){return this.check(N$(e,t))},gte(e,t){return this.check(P$(e,t))},min(e,t){return this.check(P$(e,t))},lt(e,t){return this.check(j$(e,t))},lte(e,t){return this.check(M$(e,t))},max(e,t){return this.check(M$(e,t))},int(e){return this.check(W2(e))},safe(e){return this.check(W2(e))},positive(e){return this.check(N$(0,e))},nonnegative(e){return this.check(P$(0,e))},negative(e){return this.check(j$(0,e))},nonpositive(e){return this.check(M$(0,e))},multipleOf(e,t){return this.check(z$(e,t))},step(e,t){return this.check(z$(e,t))},finite(){return this}})),O3=K(`ZodNumberFormat`,(e,t)=>{fZ.init(e,t),D3.init(e,t)}),k3=K(`ZodBoolean`,(e,t)=>{pZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>n0(e,t,n,r)}),A3=K(`ZodBigInt`,(e,t)=>{mZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>r0(e,t,n,r)},FK({minValue:e=>F1(e).minimum??null,maxValue:e=>F1(e).maximum??null,format:e=>F1(e).format??null},{gte(e,t){return this.check(P$(e,t))},min(e,t){return this.check(P$(e,t))},gt(e,t){return this.check(N$(e,t))},lt(e,t){return this.check(j$(e,t))},lte(e,t){return this.check(M$(e,t))},max(e,t){return this.check(M$(e,t))},positive(e){return this.check(N$(BigInt(0),e))},negative(e){return this.check(j$(BigInt(0),e))},nonpositive(e){return this.check(M$(BigInt(0),e))},nonnegative(e){return this.check(P$(BigInt(0),e))},multipleOf(e,t){return this.check(z$(e,t))}})),j3=K(`ZodBigIntFormat`,(e,t)=>{hZ.init(e,t),A3.init(e,t)}),M3=K(`ZodSymbol`,(e,t)=>{gZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>i0(e,t,n,r)}),N3=K(`ZodUndefined`,(e,t)=>{_Z.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>o0(e,t,n,r)}),P3=K(`ZodNull`,(e,t)=>{vZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>a0(e,t,n,r)}),F3=K(`ZodAny`,(e,t)=>{yZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>l0(e,t,n,r)}),I3=K(`ZodUnknown`,(e,t)=>{bZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>u0(e,t,n,r)}),L3=K(`ZodNever`,(e,t)=>{xZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>c0(e,t,n,r)}),R3=K(`ZodVoid`,(e,t)=>{SZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s0(e,t,n,r)}),z3=K(`ZodDate`,(e,t)=>{CZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>d0(e,t,n,r),e.min=(t,n)=>e.check(P$(t,n)),e.max=(t,n)=>e.check(M$(t,n))},FK({minDate:e=>{let{minimum:t}=F1(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=F1(e);return t?new Date(t):null}},{})),B3=K(`ZodArray`,(e,t)=>{d2(),DZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>C0(e,t,n,r),e.element=t.element},{min(e,t){return this.check(W$(e,t))},nonempty(e){return this.check(W$(1,e))},max(e,t){return this.check(U$(e,t))},length(e,t){return this.check(G$(e,t))},unwrap(){return this.element}}),V3=K(`ZodObject`,(e,t)=>{d2(),AZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>w0(e,t,n,r),zK(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Y(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(tK(this._zod.def,{catchall:e}))},passthrough(){return this.clone(tK(this._zod.def,{catchall:r4()}))},loose(){return this.clone(tK(this._zod.def,{catchall:r4()}))},strict(){return this.clone(tK(this._zod.def,{catchall:i4()}))},strip(){return this.clone(tK(this._zod.def,{catchall:void 0}))},extend(e){return mK(this,e)},safeExtend(e){return gK(this,e)},merge(e){return _K(this,e)},pick(e){return dK(this,e)},omit(e){return pK(this,e)},partial(...e){return vK(e6,this,e[0])},exactPartial(...e){return vK(t6,this,e[0],`exactPartial`)},required(...e){return yK(a6,this,e[0])}}),H3=K(`ZodUnion`,(e,t)=>{jZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>T0(e,t,n,r),e.options=t.options}),U3=K(`ZodXor`,(e,t)=>{H3.init(e,t),MZ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>T0(e,t,n,r),e.options=t.options}),W3=K(`ZodDiscriminatedUnion`,(e,t)=>{H3.init(e,t),NZ.init(e,t)}),G3=K(`ZodIntersection`,(e,t)=>{PZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>E0(e,t,n,r)}),K3=K(`ZodTuple`,(e,t)=>{d2(),FZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>D0(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new e6({type:`optional`,innerType:e}))})}}),q3=K(`ZodRecord`,(e,t)=>{d2(),IZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>k0(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),J3=K(`ZodMap`,(e,t)=>{d2(),LZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>x0(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(V$(...t)),e.nonempty=t=>e.check(V$(1,t)),e.max=(...t)=>e.check(B$(...t)),e.size=(...t)=>e.check(H$(...t))}),Y3=K(`ZodSet`,(e,t)=>{d2(),RZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>S0(e,t,n,r),e.min=(...t)=>e.check(V$(...t)),e.nonempty=t=>e.check(V$(1,t)),e.max=(...t)=>e.check(B$(...t)),e.size=(...t)=>e.check(H$(...t))}),X3=K(`ZodEnum`,(e,t)=>{zZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>f0(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new X3({...t,checks:[],...G(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new X3({...t,checks:[],...G(r),entries:i})}}),Z3=K(`ZodLiteral`,(e,t)=>{BZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>p0(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),Q3=K(`ZodFile`,(e,t)=>{VZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>g0(e,t,n,r),e.min=(t,n)=>e.check(V$(t,n)),e.max=(t,n)=>e.check(B$(t,n)),e.mime=(t,n)=>e.check(e1(Array.isArray(t)?t:[t],n))}),$3=K(`ZodTransform`,(e,t)=>{d2(),HZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>b0(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new sq(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(jK(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(jK(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}}),e6=K(`ZodOptional`,(e,t)=>{UZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>z0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),t6=K(`ZodExactOptional`,(e,t)=>{WZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>z0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),n6=K(`ZodNullable`,(e,t)=>{GZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>A0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),r6=K(`ZodDefault`,(e,t)=>{KZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>N0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),i6=K(`ZodPrefault`,(e,t)=>{qZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>P0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),a6=K(`ZodNonOptional`,(e,t)=>{JZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>j0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),o6=K(`ZodSuccess`,(e,t)=>{YZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),s6=K(`ZodCatch`,(e,t)=>{XZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>F0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),c6=K(`ZodNaN`,(e,t)=>{ZZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>m0(e,t,n,r)}),l6=K(`ZodPipe`,(e,t)=>{QZ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>I0(e,t,n,r),e.in=t.in,e.out=t.out}),u6=K(`ZodCodec`,(e,t)=>{l6.init(e,t),$Z.init(e,t)}),d6=K(`ZodPreprocess`,(e,t)=>{l6.init(e,t),eQ.init(e,t)}),f6=K(`ZodReadonly`,(e,t)=>{tQ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>L0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),p6=K(`ZodTemplateLiteral`,(e,t)=>{nQ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>h0(e,t,n,r)}),m6=K(`ZodLazy`,(e,t)=>{aQ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>B0(e,t,n,r),e.unwrap=()=>e._zod.def.getter()}),h6=K(`ZodPromise`,(e,t)=>{iQ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>R0(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),g6=K(`ZodFunction`,(e,t)=>{rQ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>y0(e,t,n,r)}),_6=K(`ZodCustom`,(e,t)=>{oQ.init(e,t),X4.init(e,t),e._zod.processJSONSchema=(t,n,r)=>v0(e,t,n,r)}),v6=p1,y6=m1,b6=K(`ZodInstanceOf`,(e,t)=>{_6.init(e,t)},{properties(e,t){return this.check($$(e,t))}}),x6=(...e)=>h1({Codec:u6,Boolean:k3,String:Q4},...e)})),C6=n((()=>{H0()})),w6=i({ZodISODate:()=>t3,ZodISODateTime:()=>e3,ZodISODuration:()=>r3,ZodISOTime:()=>n3,date:()=>E6,datetime:()=>T6,duration:()=>O6,time:()=>D6});function T6(e){return c$(e3,e)}function E6(e){return l$(t3,e)}function D6(e){return u$(n3,e)}function O6(e){return d$(r3,e)}var k6=n((()=>{H0(),S6()}));function A6(e,t){let n=e.$schema;return n===`https://json-schema.org/draft/2020-12/schema`?`draft-2020-12`:n===`http://json-schema.org/draft-07/schema#`?`draft-7`:n===`http://json-schema.org/draft-04/schema#`?`draft-4`:t??`draft-2020-12`}function j6(e,t){return e.map((e,n)=>n<t?e:e.optional())}function M6(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function N6(e,t){if(!e.startsWith(`#`))throw Error(`External $ref is not supported, only local refs (#/...) are allowed`);let n=e.slice(1).split(`/`).filter(Boolean);if(n.length===0)return t.rootSchema;let r=t.version===`draft-2020-12`?`$defs`:`definitions`;if(n[0]===r){let r=n[1]===void 0?void 0:M6(n[1]);if(!r||!t.defs[r])throw Error(`Reference not found: ${e}`);return t.defs[r]}throw Error(`Reference not found: ${e}`)}function P6(e,t){return X.transform(e=>e).check(n=>{let r=n.value;if(typeof r!=`object`||!r||Array.isArray(r))return;let i=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&i.length<t.minProperties&&n.issues.push({origin:`object`,code:`too_small`,minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&n.issues.push({origin:`object`,code:`too_big`,maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let e of i){let r=t.keySchema.safeParse(e);r.success||n.issues.push({code:`invalid_key`,origin:`record`,issues:r.error.issues,input:e,path:[e],continue:!0})}}).pipe(e)}function F6(e,t){if(e===null)return`z`;let n=typeof e;if(n!==`object`){if(n===`number`&&Number.isNaN(e))return null;let t=String(e);return`${n[0]}${t.length}:${t}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let n=[];for(let r of e){let e=F6(r,t);if(e===null)return null;n.push(e)}return`a${n.length}:[${n.join(`,`)}]`}let n=Object.keys(e).sort(),r=[];for(let i of n){let n=F6(e[i],t);if(n===null)return null;r.push(`${i.length}:${i}=${n}`)}return`o${r.length}:{${r.join(`,`)}}`}finally{t.delete(e)}}function I6(e){return typeof e!=`object`||!e?!1:Array.isArray(e)?e.some(I6):typeof e.$ref==`string`||Object.entries(e).some(([e,t])=>W6.has(e)?I6(t):!G6.has(e)||typeof t!=`object`||!t?!1:Object.values(t).some(I6))}function L6(e){return e===1?`element`:`elements`}function R6(e,t){return X.transform(e=>e).check(e=>{let n=e.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let t=new Map;for(let r=0;r<n.length;r++){let i=F6(n[r],new Set);if(i===null)continue;let a=t.get(i);a===void 0?t.set(i,r):e.issues.push({code:`custom`,message:`Array items must be unique: element at index ${r} duplicates the one at index ${a}`,input:n,path:[r],continue:!0})}}if(t.containsSchema){let r=t.minContains??1,i=t.maxContains===void 0?1/0:t.maxContains+1,a=0;for(let e of n)if(t.containsSchema.safeParse(e).success&&++a>=i)break;a<r&&e.issues.push({code:`custom`,message:`Array must contain at least ${r} matching ${L6(r)}; found ${a}`,input:n,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&e.issues.push({code:`custom`,message:`Array must contain at most ${t.maxContains} matching ${L6(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function z6(e,t){if(e!==!1)return e===void 0||e===!0?X.any():V6(e,t)}function B6(e,t){if(e.not!==void 0){if(typeof e.not==`object`&&Object.keys(e.not).length===0)return X.never();throw Error(`not is not supported in Zod (except { not: {} } for never)`)}if(e.unevaluatedItems!==void 0)throw Error(`unevaluatedItems is not supported`);if(e.unevaluatedProperties!==void 0)throw Error(`unevaluatedProperties is not supported`);if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error(`Conditional schemas (if/then/else) are not supported`);if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error(`dependentSchemas and dependentRequired are not supported`);if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return X.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let r=V6(N6(n,t),t);return t.refs.set(n,r),t.processing.delete(n),r}if(e.enum!==void 0){let n=e.enum;if(t.version===`openapi-3.0`&&e.nullable===!0&&n.length===1&&n[0]===null)return X.null();if(n.length===0)return X.never();if(n.length===1)return X.literal(n[0]);if(n.every(e=>typeof e==`string`))return X.enum(n);let r=n.map(e=>X.literal(e));return r.length<2?r[0]:X.union([r[0],r[1],...r.slice(2)])}if(e.const!==void 0)return X.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(n=>B6({...e,type:n},t));return r.length===0?X.never():r.length===1?r[0]:X.union(r)}if(!n)return X.any();let r;switch(n){case`string`:{let t=X.string();if(e.format){let n=e.format;n===`email`?t=t.check(X.email()):n===`uri`||n===`uri-reference`?t=t.check(X.url()):n===`uuid`||n===`guid`?t=t.check(X.uuid()):n===`date-time`?t=t.check(X.iso.datetime({offset:!0})):n===`date`?t=t.check(X.iso.date()):n===`time`?t=t.check(X.regex(K6)):n===`duration`?t=t.check(X.iso.duration()):n===`hostname`?t=t.check(X.hostname()):n===`ipv4`?t=t.check(X.ipv4()):n===`ipv6`?t=t.check(X.ipv6()):n===`mac`?t=t.check(X.mac()):n===`cidr`?t=t.check(X.cidrv4()):n===`cidr-v6`?t=t.check(X.cidrv6()):n===`base64`?t=t.check(X.base64()):n===`base64url`?t=t.check(X.base64url()):n===`e164`?t=t.check(X.e164()):n===`credit_card`?t=t.check(X.creditCard()):n===`iban`?t=t.check(X.iban()):n===`jwt`?t=t.check(X.jwt()):n===`emoji`?t=t.check(X.emoji()):n===`nanoid`?t=t.check(X.nanoid()):n===`cuid`?t=t.check(X.cuid()):n===`cuid2`?t=t.check(X.cuid2()):n===`ulid`?t=t.check(X.ulid()):n===`xid`?t=t.check(X.xid()):n===`ksuid`&&(t=t.check(X.ksuid()))}typeof e.minLength==`number`&&(t=t.min(e.minLength)),typeof e.maxLength==`number`&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),r=t;break}case`number`:case`integer`:{let t=n===`integer`?X.number().int():X.number();typeof e.minimum==`number`&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum==`number`&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum==`number`?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum==`number`&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum==`number`?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum==`number`&&(t=t.lt(e.maximum)),typeof e.multipleOf==`number`&&(t=t.multipleOf(e.multipleOf)),r=t;break}case`boolean`:r=X.boolean();break;case`null`:r=X.null();break;case`object`:{let n={},i=e.properties||{},a=new Set(e.required||[]),o=typeof e.additionalProperties==`object`?V6(e.additionalProperties,t):void 0;for(let[e,r]of Object.entries(i)){let i=V6(r,t);JG(n,e,a.has(e)?i:i.optional())}if(e.patternProperties){let i=e.patternProperties,a=Object.keys(i),o=[];for(let e of a){let n=V6(i[e],t),r=X.string().regex(new RegExp(e));o.push(X.looseRecord(r,n))}let s=[];if(Object.keys(n).length>0&&s.push(X.object(n).passthrough()),s.push(...o),s.length===0)r=X.object({}).passthrough();else if(s.length===1)r=s[0];else{let e=X.intersection(s[0],s[1]);for(let t=2;t<s.length;t++)e=X.intersection(e,s[t]);r=e}if(e.additionalProperties===!1){let e=Object.keys(n),t=a.map(e=>new RegExp(e)),i=r;r=r.check(n=>{if(!aK(n.value))return;let r=[];for(let i of Object.keys(n.value))e.includes(i)||t.some(e=>e.test(i))||r.push(i);r.length&&n.issues.push({code:`unrecognized_keys`,keys:r,input:n.value,inst:i})})}}else{let t=X.object(n);r=e.additionalProperties===!1?t.strict():o?t.catchall(o):t.passthrough()}let s=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties==`number`?e.minProperties:void 0,l=typeof e.maxProperties==`number`?e.maxProperties:void 0;if(s||c!==void 0||l!==void 0){let n;s&&(n=V6(typeof e.propertyNames==`object`&&e.propertyNames.type===void 0?{type:`string`,...e.propertyNames}:e.propertyNames,t)),r=P6(r,{keySchema:n,minProperties:c,maxProperties:l})}break}case`array`:{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems==`number`?e.minItems:0,o=j6(n.map(e=>V6(e,t)),a),s=Array.isArray(i)?void 0:z6(i,t),c=X.tuple(o);r=s?c.rest(s):c,typeof e.minItems==`number`&&(r=r.check(X.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(X.maxLength(e.maxItems)))}else if(Array.isArray(i)){let n=typeof e.minItems==`number`?e.minItems:0,a=j6(i.map(e=>V6(e,t)),n),o=z6(e.additionalItems,t),s=X.tuple(a);r=o?s.rest(o):s,typeof e.minItems==`number`&&(r=r.check(X.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(X.maxLength(e.maxItems)))}else if(i!==void 0){let n=V6(i,t),a=X.array(n);typeof e.minItems==`number`&&(a=a.min(e.minItems)),typeof e.maxItems==`number`&&(a=a.max(e.maxItems)),r=a}else r=X.array(X.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=R6(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains===void 0?void 0:V6(e.contains,t),minContains:typeof e.minContains==`number`?e.minContains:void 0,maxContains:typeof e.maxContains==`number`?e.maxContains:void 0}));break}default:throw Error(`Unsupported type: ${n}`)}return r}function V6(e,t){if(typeof e==`boolean`)return e?X.any():X.never();let n=B6(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let i=e.anyOf.map(e=>V6(e,t)),a=X.union(i);n=r?X.intersection(n,a):a}if(e.oneOf&&Array.isArray(e.oneOf)){let i=e.oneOf.map(e=>V6(e,t)),a=X.xor(i);n=r?X.intersection(n,a):a}if(e.allOf&&Array.isArray(e.allOf)){if(e.allOf.length===0)n=r?n:X.any();else{let i=r?n:V6(e.allOf[0],t),a=+!r;for(let n=a;n<e.allOf.length;n++)i=X.intersection(i,V6(e.allOf[n],t));n=i}}e.nullable===!0&&t.version===`openapi-3.0`&&(n=X.nullable(n)),e.readOnly===!0&&(n=X.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let i={};for(let t of[`$id`,`id`,`$comment`,`$anchor`,`$vocabulary`,`$dynamicRef`,`$dynamicAnchor`])t in e&&(i[t]=e[t]);for(let t of[`contentEncoding`,`contentMediaType`,`contentSchema`])t in e&&(i[t]=e[t]);if(e.type===`object`&&e.$ref===void 0){e.propertyNames!==void 0&&!I6(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(let t of[`minProperties`,`maxProperties`])e[t]!==void 0&&(i[t]=e[t])}if(e.type===`array`&&e.$ref===void 0){e.contains!==void 0&&!I6(e.contains)&&(i.contains=e.contains);for(let t of[`uniqueItems`,`minContains`,`maxContains`])e[t]!==void 0&&(i[t]=e[t])}for(let t of Object.keys(e))U6.has(t)||JG(i,t,e[t]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function H6(e,t){if(typeof e==`boolean`)return e?X.any():X.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw Error(`fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas`)}let r={version:A6(n,t?.defaultTarget),defs:n.$defs||n.definitions||{},refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??MQ};return V6(n,r)}var X,U6,W6,G6,K6,q6=n((()=>{NQ(),eq(),W0(),k6(),S6(),X={...l2,...U0,iso:w6},U6=new Set(`$schema.$ref.$defs.definitions.$id.id.$comment.$anchor.$vocabulary.$dynamicRef.$dynamicAnchor.type.enum.const.anyOf.oneOf.allOf.not.properties.required.additionalProperties.patternProperties.propertyNames.minProperties.maxProperties.items.prefixItems.additionalItems.minItems.maxItems.uniqueItems.contains.minContains.maxContains.minLength.maxLength.pattern.format.minimum.maximum.exclusiveMinimum.exclusiveMaximum.multipleOf.description.default.contentEncoding.contentMediaType.contentSchema.unevaluatedItems.unevaluatedProperties.if.then.else.dependentSchemas.dependentRequired.nullable.readOnly`.split(`.`)),W6=new Set([`items`,`prefixItems`,`additionalItems`,`additionalProperties`,`contains`,`propertyNames`,`not`,`if`,`then`,`else`,`allOf`,`anyOf`,`oneOf`,`unevaluatedItems`,`unevaluatedProperties`,`contentSchema`]),G6=new Set([`properties`,`patternProperties`,`dependentSchemas`,`dependencies`,`$defs`,`definitions`]),K6=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/})),J6=n((()=>{H0(),S6(),W0(),Y0(),c2(),C6(),V0(),q6(),sQ(),eq(),S6(),OQ(),k6()})),Y6=n((()=>{J6(),J6()}));function X6(e,t,n=`/`){let r=g8.safeParse(e);if(!r.success)return!0;let i=Z6(t,$6(r.data.path,n));return r.data.equals===void 0?r.data.in===void 0?i!=null&&i!==``&&i!==!1:r.data.in.includes(i):i===r.data.equals}function Z6(e,t){if(t===``||t===`/`)return e;let n=e;for(let e of t.replace(/^\//,``).split(`/`)){if(typeof n!=`object`||!n)return;let t=e.replace(/~1/g,`/`).replace(/~0/g,`~`);n=n[t]}return n}function Q6(e,t,n){if(t===``||t===`/`)return n;let r=t.replace(/^\//,``).split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)),i=(e,t)=>{let a=r[t];if(a===`__proto__`||a===`constructor`||a===`prototype`)return e;let o=t===r.length-1,s=Array.isArray(e)?[...e]:typeof e==`object`&&e?{...e}:/^\d+$/.test(a)?[]:{},c=s;return o?n===void 0?Array.isArray(s)?s.splice(Number(a),1):delete c[a]:c[a]=n:c[a]=i(c[a],t+1),s};return i(e,0)}function $6(e,t){return e.startsWith(`/`)?e:e===``||e===`.`?t||`/`:`${t===`/`?``:t}/${e}`}function e8(e,t,n=0){if(typeof e!=`object`||!e||n>32)return e;if(Array.isArray(e))return e.map(e=>e8(e,t,n+1));if(b8(e))return Z6(t.data,$6(e[`@path`],t.scope));if(x8(e)){let r=Object.hasOwn(t.functions,e[`@call`])?t.functions[e[`@call`]]:void 0;return r?r(Object.fromEntries(Object.entries(e.args??{}).map(([e,r])=>[e,e8(r,t,n+1)])),t):void 0}return Object.fromEntries(Object.entries(e).map(([e,r])=>[e,e8(r,t,n+1)]))}var t8,n8,r8,i8,a8,o8,Z,s8,c8,l8,u8,d8,f8,p8,m8,h8,g8,_8,v8,y8,b8,x8,S8=n((()=>{Y6(),t8=[`v0.9`,`v0.9.1`],n8=l4({"@path":q()}).describe(`A value read from the data model at this path.`),r8=l4({"@call":q(),args:g4(q(),r4()).optional(),catalogId:q().optional()}).describe(`A call to one of the catalog's functions.`),i8=e=>typeof e==`object`&&!!e&&!Array.isArray(e),a8=`a binding ({ "@path": "/a" }) or a function call ({ "@call": "name", "args": { … } })`,o8=e=>({error:()=>`Expected ${e}, ${a8}.`}),Z=d4([q(),n8,r8],o8(`text`)),s8=d4([U2(),n8,r8],o8(`a number`)),c8=d4([Y2(),n8,r8],o8(`true or false`)),l8=d4([q(),U2(),Y2(),J(r4()),n8,r8],o8(`text, a number, true or false, a list`)),u8=/^[\p{XID_Start}_][\p{XID_Continue}]*$/u,d8=16384,f8=g4(q().regex(u8,`An extension name must be an identifier.`),r4()),p8=l4({extensions:f8.optional()}).refine(e=>JSON.stringify(e).length<=d8,`Metadata is limited to ${d8} characters of JSON.`),m8=l4({label:Z.optional(),description:Z.optional(),live:Y([`off`,`polite`,`assertive`]).optional(),hidden:c8.optional()}),h8=d4([q(),U2(),Y2()]),g8=l4({path:q().describe(`A place in the data model, as a binding's path is written.`),equals:h8.optional().describe(`Shown only while the value there is this.`),in:J(h8).min(1).max(50).optional().describe(`Shown only while the value there is one of these.`)}).refine(e=>e.equals===void 0||e.in===void 0,{message:"Give `equals` or `in`, not both."}).describe(`Shows the component only while a value in the data model is what this says: a field for a table name only once "Table" is chosen.`),_8=q().describe(`ID of a child component.`),v8=d4([J(q()),l4({componentId:q(),path:q()})],{error:()=>`Expected a list of component ids, or { componentId, path } to repeat one component for each item of a list in the data model.`}),y8=d4([l4({event:l4({name:q(),userMessage:Z.optional(),context:g4(q(),l8).optional()})}),l4({functionCall:r8})],{error:e=>i8(e.input)&&Object.hasOwn(e.input,`@call`)?'In an action, a function call sits inside `functionCall`: { "functionCall": { "@call": "openUrl", "args": { "url": "https://…" } } }.':i8(e.input)&&Object.hasOwn(e.input,`name`)?'In an action, an event sits inside `event`: { "event": { "name": "…", "context": { … } } }.':`Expected { "event": { "name": "…", "context": { … } } } to send an event, or { "functionCall": { "@call": "openUrl", "args": { "url": "https://…" } } } to run a function.`}),b8=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.keys(e);return t.length===1&&t[0]===`@path`&&typeof e[`@path`]==`string`},x8=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e[`@call`]==`string`}));function C8(e,t=0){if(t>32||typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>C8(e,t+1));let n=e,r=Object.keys(n);return r.length===1&&r[0]===`path`&&typeof n.path==`string`?{"@path":n.path}:typeof n.call==`string`&&!(`@call`in n)?{"@call":n.call,...D8(n.args)?{args:C8(n.args,t+1)}:{}}:Object.fromEntries(r.map(e=>[e,C8(n[e],t+1)]))}function w8(e){let t={};for(let[n,r]of Object.entries(e))n===`id`||n===`component`?t[n]=r:n===`accessibility`&&!(`@accessibility`in e)?t[`@accessibility`]=C8(r):n===`checks`&&!(`@checks`in e)?t[`@checks`]=C8(r):t[n]=n.startsWith(`@`)?r:C8(r);return t}function T8(e,t){let n=D8(e)&&D8(e.extensions)?e.extensions:{},r={...t,...n};return Object.keys(r).length>0?{...D8(e)?e:{},extensions:r}:void 0}function E8(e){if(!A8(e))return e;let t=e;if(D8(t.createSurface)){let{theme:e,expects:n,metadata:r,...i}=t.createSurface,a=T8(r,{...D8(e)&&Object.keys(e).length>0?{[O8]:e}:{},...D8(n)&&Object.keys(n).length>0?{[k8]:n}:{}});return{...t,version:`1.0`,createSurface:{...i,...a?{metadata:a}:{}}}}if(D8(t.updateComponents)){let e=t.updateComponents.components;return{...t,version:`1.0`,updateComponents:{...t.updateComponents,components:Array.isArray(e)?e.map(e=>D8(e)&&typeof e.id==`string`&&typeof e.component==`string`?w8(e):e):e}}}return D8(t.updateDataModel)?{...t,version:`1.0`,updateDataModel:{...t.updateDataModel,value:t.updateDataModel.value===void 0?null:t.updateDataModel.value}}:{...t,version:`1.0`}}var D8,O8,k8,A8,j8=n((()=>{S8(),D8=e=>typeof e==`object`&&!!e&&!Array.isArray(e),O8=`surfaces_theme`,k8=`surfaces_expects`,A8=e=>D8(e)&&typeof e.version==`string`&&t8.includes(e.version)}));function M8(e){if(typeof e==`string`)try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.href:void 0}catch{return}}var N8,P8,F8=n((()=>{Y6(),S8(),N8=e=>typeof e==`bigint`?Number(e):typeof e==`number`?e:Number(e),P8={formatString:{description:'Builds text from a template. "${path}" is replaced by the data model value at that path. "${path|not chosen yet}" gives the words to use while there is no value there (nothing, or empty text), so a summary of a form never reads as a gap.',args:{value:q()},returnType:`string`,implementation:(e,t)=>String(e.value??``).replace(/\$\{([^}]*)\}/g,(e,n)=>{let r=n.indexOf(`|`),i=r===-1?n:n.slice(0,r),a=r===-1?``:n.slice(r+1).trim(),o=Z6(t.data,$6(i.trim(),t.scope));return o==null||typeof o==`object`||o===``?a:String(o)})},formatNumber:{description:`Formats a number with grouping and a fixed number of decimals.`,args:{value:r4(),decimals:U2().optional(),grouping:Y2().optional()},returnType:`string`,implementation:e=>{let t=N8(e.value);if(!Number.isFinite(t))return``;let n=typeof e.decimals==`number`?e.decimals:void 0;return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n??2,useGrouping:e.grouping!==!1}).format(t)}},formatCurrency:{description:`Formats a number as money in the given ISO 4217 currency.`,args:{value:r4(),currency:q()},returnType:`string`,implementation:e=>{let t=N8(e.value);if(!Number.isFinite(t))return``;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:String(e.currency??`USD`)}).format(t)}catch{return String(t)}}},formatDate:{description:`Formats a date or time. "format" is "date", "time" or "datetime".`,args:{value:r4(),format:Y([`date`,`time`,`datetime`]).optional()},returnType:`string`,implementation:e=>{let t=new Date(e.value);if(Number.isNaN(t.getTime()))return``;let n=e.format??`date`;return new Intl.DateTimeFormat(`en-US`,{dateStyle:n===`time`?void 0:`medium`,timeStyle:n===`date`?void 0:`short`,timeZone:`UTC`}).format(t)}},openUrl:{description:`Opens a web link in a new tab. Only http and https links are allowed.`,args:{url:q()},returnType:`void`,action:!0,implementation:e=>{let t=M8(e.url);t&&typeof window<`u`&&window.open(t,`_blank`,`noopener,noreferrer`)}}}}));function I8(e){return u4(e.context??{})}function L8(e){if(!e||typeof e!=`object`||Array.isArray(e))return{error:`A contract is a JSON Schema object.`};try{return{schema:H6(e)}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}function R8(e){if(e.code!==`invalid_union`||!e.errors?.length)return[e];let t=e=>e.some(e=>e.path.length===0&&e.code===`invalid_type`)?-1:Math.min(...e.map(e=>e.path.length)),n=e.errors.filter(e=>e.length>0).map(e=>({branch:e,rank:t(e)})),r=Math.max(...n.map(e=>e.rank)),i=n.filter(e=>e.rank===r);return r<1||i.length!==1?[e]:i[0].branch.flatMap(t=>R8({...t,path:[...e.path,...t.path]}))}function z8(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,`height`in t.props||`minHeight`in t.props?t:{...t,props:{...t.props,minHeight:G8}}]))}function B8(e){let t=new Map;for(let[n,r]of Object.entries(e.components))t.set(n,l4({id:q().min(1).describe(`Unique within the surface. The top component must be "root".`),component:S4(n),"@catalogId":S4(e.id).optional().describe(`The component's catalog. This renderer draws one catalog per surface.`),"@accessibility":m8.optional(),"@metadata":p8.optional().describe(`Extensions by name. Never drawn, resolved or run.`),visibleWhen:g8.optional(),...r.props}));let n={...e,functions:{...P8,...e.functions},schema:e=>t.get(e),validateComponent(e){let n=e?.component,r=typeof n==`string`?t.get(n):void 0;if(!r)return[{path:`/component`,message:`Unknown component ${JSON.stringify(n)}. Available: ${[...t.keys()].join(`, `)}.`}];let i=r.safeParse(e);return i.success?[]:V8(i.error)},validateMessage(t){let r=typeof t==`object`&&t?t.version:void 0;if(typeof r==`string`&&r!==`1.0`&&!t8.includes(r))return[{path:`/version`,message:`This renderer reads A2UI 1.0 (and ${t8.join(`, `)}), not ${r}.`}];let i=E8(t),a=typeof i==`object`&&i?i:{},o=Object.keys(W8).find(e=>Object.hasOwn(a,e));if(!o)return[{path:`/`,message:`Expected one of ${Object.keys(W8).join(`, `)}.`}];let s=W8[o].safeParse(i);if(!s.success)return V8(s.error);if(o===`createSurface`){let t=a.createSurface;if(t.catalogId!==void 0&&t.catalogId!==e.id)return[{path:`/createSurface/catalogId`,message:`This renderer supports catalog ${e.id}.`}];let r=t.metadata?.extensions?.[k8],i=typeof r==`object`&&r&&!Array.isArray(r)?r:{};return[...r!==void 0&&i!==r?[{path:`/createSurface/metadata/extensions/${k8}`,message:`Expected event names mapped to JSON Schemas.`}]:[],...Object.entries(i).flatMap(([e,t])=>{let n=L8(t);return`error`in n?[{path:`/createSurface/metadata/extensions/${k8}/${e}`,message:`Not a usable JSON Schema: ${n.error}`}]:[]}),...(t.components??[]).flatMap((e,t)=>n.validateComponent(e).map(e=>({...e,path:`/createSurface/components/${t}${e.path}`})))]}return o===`updateComponents`?a.updateComponents.components.flatMap((e,t)=>n.validateComponent(e).map(e=>({...e,path:`/updateComponents/components/${t}${e.path}`}))):[]}};return{...n,names:Object.keys(e.components)}}var V8,H8,U8,W8,G8,K8=n((()=>{Y6(),S8(),j8(),F8(),V8=(e,t=``)=>e.issues.flatMap(R8).map(e=>({path:`${t}/${e.path.join(`/`)}`.replace(/\/$/,``)||`/`,message:e.message})),H8=S4(`1.0`),U8=q().min(1),W8={createSurface:l4({version:H8,createSurface:l4({surfaceId:U8,catalogId:q().optional(),sendDataModel:Y2().optional(),components:J(r4()).optional(),dataModel:r4().optional(),metadata:p8.optional()})}),updateComponents:l4({version:H8,updateComponents:l4({surfaceId:U8,components:J(r4()).min(1)})}),updateDataModel:l4({version:H8,updateDataModel:l4({surfaceId:U8,path:q().optional(),value:r4()}).refine(e=>Object.hasOwn(e,`value`),{path:[`value`],message:`Give a value. null removes what is at the path.`})}),deleteSurface:l4({version:H8,deleteSurface:l4({surfaceId:U8})})},G8=U2().int().min(24).max(1600).optional().describe(`The least height of this component's box, in pixels. It is as tall as what it holds, or this, whichever is more.`)})),q8,J8,Y8,X8,Z8,Q8,$8,e5,t5,n5,r5,i5,a5,o5,s5,c5,l5=n((()=>{jM(),Y6(),K8(),S8(),q8=l4({name:q().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).describe(`The key the value is sent and stored under.`),label:q(),type:Y([`text`,`longtext`,`number`,`integer`,`boolean`,`date`,`datetime`,`choice`]),required:Y2().optional(),options:J(q()).max(50).optional().describe(`For choice.`),min:U2().optional(),max:U2().optional(),step:U2().positive().optional(),maxLength:U2().int().positive().optional(),pattern:q().max(200).optional().describe(`A regular expression the whole text must match.`),help:q().optional(),placeholder:q().optional(),visibleWhen:l4({field:q().describe(`The name of another field of this form.`),equals:d4([q(),U2(),Y2()]).optional().describe(`Asked only while that field's value is this.`),in:J(d4([q(),U2(),Y2()])).min(1).max(50).optional().describe(`Asked only while that field's value is one of these.`)}).refine(e=>e.equals===void 0||e.in===void 0,{message:"Give `equals` or `in`, not both."}).optional().describe("Asks for this field only while another field of the form holds a value (with neither `equals` nor `in`, any value). A field that is not asked for is not drawn, not required, and sent as null.")}),J8=J(q8).min(1).max(40).superRefine((e,t)=>{let n=new Set(e.map(e=>e.name));e.forEach((e,r)=>{let i=e.visibleWhen?.field;i!==void 0&&(i===e.name?t.addIssue({code:`custom`,path:[r,`visibleWhen`,`field`],message:`A field cannot wait on itself.`}):n.has(i)||t.addIssue({code:`custom`,path:[r,`visibleWhen`,`field`],message:`This form has no field "${i}". Its fields are: ${[...n].join(`, `)}.`}))})}),Y8=[`none`,1,2,3,4,6,8],X8=d4([S4(`none`),S4(1),S4(2),S4(3),S4(4),S4(6),S4(8)]),Z8=X8.optional().describe('The space between children, as a step of the theme\'s spacing scale (`--sf-space-<step>`), or "none". Defaults to 4.'),Q8=X8.optional(),$8=e=>`The space inside the edge, around the children, as a step of the theme's spacing scale (\`--sf-space-<step>\`), or "none". Defaults to ${e===`none`?`"none"`:e}.`,e5={min:24,max:1600},t5=d4([S4(`hug`),S4(`fill`),l4({fixed:U2().min(e5.min).max(e5.max).describe(`A width in pixels, ${e5.min} to ${e5.max}.`)})]),n5=J(t5).min(1).max(12).optional(),r5="The value is written to the data model at `value.path` as the person types, so other components (a Button's event context, a Text) can bind to it. Nothing is sent until a control sends an event.",i5=e=>q().describe(e),a5={Button:{press:{description:`When pressed. Carries only the context declared in the action.`}},SideNav:{select:{description:`When an item without a link is chosen.`,context:{id:i5(`the item's id`)}}},Form:{submit:{description:`After the values pass every check and, when the page has a forms backend, after it stored them.`,context:{formId:i5(`the form`),values:g4(q(),r4()).describe(`the values as stored`),submissionId:i5(`the backend's id, or empty with no backend`)}}}},o5={Text:{description:`A heading, paragraph or caption.`,props:{text:Z,variant:Y([`h1`,`h2`,`h3`,`h4`,`h5`,`body`,`caption`]).optional()},example:{id:`title`,component:`Text`,text:`Revenue this quarter`,variant:`h2`}},Row:{description:"Places children side by side. Wraps on narrow screens unless `wrap` is false. Children share the width equally unless `widths` gives each its share, or `sizes` says how each is sized (content width, fill, or fixed pixels); `sizes` wins over `widths` when both have one entry per child. `gap` and `padding` are steps of the theme's spacing scale.",props:{children:v8,widths:J(U2().positive()).min(1).max(12).optional().describe("The share of the width each child takes, one per child: [2, 1] makes the first twice as wide as the second. Used when it has one entry per child and `sizes` is not used."),sizes:n5.describe('How each child is sized, one per child: "hug" keeps its content\'s width and does not grow, "fill" grows to share the space left, { fixed: 240 } is that many pixels wide. Used when it has one entry per child, in place of `widths`. Narrow screens stack the children unless `wrap` is false.'),wrap:Y2().optional().describe(`Whether children move onto a new line when they do not fit, and stack on narrow screens. Defaults to true; false keeps them on one line, each shrinking to fit.`),gap:Z8,padding:Q8.describe($8(`none`)),justify:Y([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).optional(),align:Y([`start`,`center`,`end`,`stretch`]).optional()},example:{id:`stats`,component:`Row`,children:[`revenue`,`orders`]}},Column:{description:"Stacks children top to bottom. Use it as the root of most surfaces. `gap` and `padding` are steps of the theme's spacing scale.",props:{children:v8,gap:Z8,padding:Q8.describe($8(`none`)),justify:Y([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).optional(),align:Y([`start`,`center`,`end`,`stretch`]).optional()},example:{id:`root`,component:`Column`,children:[`title`,`stats`,`chart`]}},Grid:{description:'Lays children out in columns that wrap onto new rows. Use it for dashboards: a row of numbers, then charts side by side. Columns are equal unless `widths` gives each its share, as when a person resizes them by hand. Children in a row are stretched to the tallest one; set `align: "start"` when the row mixes content of different heights, such as a chart beside a form, so each keeps its own height. `gap` is a step of the theme\'s spacing scale, between rows and columns alike.',props:{children:v8,columns:U2().int().min(1).max(6).optional().describe(`Columns per row. Defaults to 2. Narrow screens use one.`),widths:J(U2().positive()).min(1).max(6).optional().describe(`The share of the width each column takes, one per column: [2, 1] makes the first twice as wide as the second. Used when it has one entry per column; otherwise columns are equal.`),align:Y([`start`,`center`,`end`,`stretch`]).optional().describe(`Where each child sits in the height of its row. Defaults to stretch: every child as tall as the tallest. Use start for mixed content, so each keeps its own height.`),gap:Z8},example:{id:`tiles`,component:`Grid`,columns:3,children:[`revenue`,`orders`,`average`]}},Card:{description:"A bordered container for one child, to group related content. `padding` is a step of the theme's spacing scale.",props:{child:_8,padding:Q8.describe($8(`4`))},example:{id:`panel`,component:`Card`,child:`chart`}},Divider:{description:`A thin line between sections.`,props:{axis:Y([`horizontal`,`vertical`]).optional()},example:{id:`rule`,component:`Divider`}},SideNav:{description:"Navigation down the side of a surface: groups of items, with the current one marked. A person can fold it away: it then keeps only a slim strip for its menu button, which slides it back in over the surface (never over anything outside it). In a narrow surface or on a narrow screen it is always folded. An item with `href` is a link (http and https only); one without sends the event with its `id`. Bind `current` to a data path to mark the item for what is showing.",props:{label:q().optional().describe(`What the navigation is for, for assistive technology.`),groups:J(l4({label:q().optional(),items:J(l4({id:q(),label:q(),href:q().optional()})).min(1).max(30)})).min(1).max(12),current:Z.optional().describe(`The id of the item for what is showing.`),pinned:Y2().optional().describe(`Whether it starts open beside the content. Defaults to true.`),action:y8.optional()},example:{id:`nav`,component:`SideNav`,label:`Sections`,groups:[{label:`Sales`,items:[{id:`overview`,label:`Overview`},{id:`orders`,label:`Orders`}]}],current:`overview`,action:{event:{name:`navigate`}}}},Tabs:{description:`Switches between several children, one visible at a time.`,props:{tabs:J(l4({title:Z,child:_8})).min(1)},example:{id:`views`,component:`Tabs`,tabs:[{title:`Chart`,child:`chart`},{title:`Table`,child:`table`}]}},Button:{description:'A control that sends an event back to the agent or opens a link. Its label is a child Text. To open a link, the action is a function call in place of an event: `"action": {"functionCall": {"@call": "openUrl", "args": {"url": "https://example.com/start"}}}`.',props:{child:_8,variant:Y([`default`,`primary`,`borderless`]).optional(),action:y8,requires:J(q()).max(40).optional().describe("Ids of inputs (TextField, NumberField, ChoicePicker, CheckBox, DateTimeInput) this button waits for. While any of them is missing or wrong the button is marked unavailable; a press then sends nothing, has each say what is wrong beside it and moves to the first. An input that is not shown (`visibleWhen`) is not waited for.")},example:{id:`refresh`,component:`Button`,child:`refresh-label`,variant:`primary`,action:{event:{name:`refresh`,context:{region:{"@path":`/region`}}}}}},TextField:{description:`A labelled text box. ${r5}`,props:{label:Z,value:n8,multiline:Y2().optional(),placeholder:q().optional(),help:Z.optional().describe(`A sentence under the field: what to enter, or why it is asked.`),maxLength:U2().int().positive().optional(),required:Y2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`),pattern:q().max(200).optional().describe(`A regular expression the whole text must match; a value that does not is said so beside the field.`)},example:{id:`note`,component:`TextField`,label:`Note`,value:{"@path":`/review/note`},multiline:!0}},NumberField:{description:`A labelled number box. ${r5}`,props:{label:Z,value:n8,min:U2().optional().describe(`A number below it is said so beside the field.`),max:U2().optional().describe(`A number above it is said so beside the field.`),step:U2().positive().optional(),help:Z.optional(),required:Y2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`threshold`,component:`NumberField`,label:`Alert above`,value:{"@path":`/threshold`},min:0,step:50}},ChoicePicker:{description:`Pick one of a few options: radio buttons for four or fewer, a list for more. ${r5}`,props:{label:Z,value:n8,options:J(q()).min(1).max(50),help:Z.optional(),required:Y2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`region`,component:`ChoicePicker`,label:`Region`,value:{"@path":`/region`},options:[`Europe`,`Americas`,`Asia`]}},CheckBox:{description:`A yes-or-no box. ${r5}`,props:{label:Z,value:n8,help:Z.optional(),required:Y2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`include-returns`,component:`CheckBox`,label:`Include returns`,value:{"@path":`/includeReturns`}}},DateTimeInput:{description:`A date, or a date and time (kept in UTC). ${r5}`,props:{label:Z,value:n8,mode:Y([`date`,`datetime`]).optional(),help:Z.optional(),required:Y2().optional().describe(`Marked as required, and said to be missing once the person leaves it empty.`)},example:{id:`from`,component:`DateTimeInput`,label:`From`,value:{"@path":`/from`},mode:`date`}},Slider:{description:`A number chosen along a range, with its value shown in words. ${r5}`,props:{label:Z,value:n8,min:U2(),max:U2(),step:U2().positive().optional(),help:Z.optional()},example:{id:`confidence`,component:`Slider`,label:`Confidence`,value:{"@path":`/confidence`},min:0,max:100,step:5}},Form:{description:"A form that checks what a person enters and submits it. Give the fields and their rules; the form draws a labelled input for each, shows errors beside them and sends nothing while any is wrong. A field with `visibleWhen: { field, equals }` is asked for only once another field holds that value. When the page has a forms backend, values go to the form with this `formId` there (the backend decides where they are stored; you never name a table); either way your event receives them. Use it instead of loose inputs and a Button whenever values must be checked or kept.",props:{formId:q().min(1),title:Z.optional(),description:Z.optional(),fields:J8,values:n8.optional().describe(`Where the entered values live in the data model, to prefill them or show them elsewhere.`),submitLabel:q().optional(),action:y8.optional()},example:{id:`case-review`,component:`Form`,formId:`case-review`,title:`Review this alert`,fields:[{name:`decision`,label:`Decision`,type:`choice`,options:[`Fraud`,`Not fraud`,`Needs more information`],required:!0},{name:`amount_at_risk`,label:`Amount at risk`,type:`number`,min:0},{name:`note`,label:`Note`,type:`longtext`,maxLength:500}],values:{"@path":`/review`},submitLabel:`Save decision`,action:{event:{name:`case_reviewed`}}}},Markdown:{description:`Formatted text: headings, lists, tables, links and code. Use it for explanations longer than a line.`,props:{text:Z},example:{id:`notes`,component:`Markdown`,text:`Revenue is **up 5%**.
|
|
99
100
|
|
|
100
101
|
- Europe leads
|
|
101
|
-
- Returns are flat`}},Image:{description:"A picture. `src` is a name the page knows (for example one it gave you), never a web address you choose: the page decides whether and where it loads, and when it does not know the name the `alt` text is shown in its place. Always describe what it shows in `alt`, which is required (an empty string only for decoration). Give `caption` for a line beneath it. `fit` and `maxHeight` keep it from taking over a layout.",props:{src:Z.describe(`The name of the image, as the page gave it to you. Not loaded as written.`),alt:Z.describe(`What the image shows, for anyone who cannot see it.`),caption:Z.optional(),width:F2().int().min(24).max(1600).optional().describe(`The most it is wide, in pixels. It never grows past its container.`),height:F2().int().min(24).max(1600).optional().describe("A fixed height in pixels; the image then fills that box by `fit`."),fit:Y([`contain`,`cover`]).optional().describe(`How a fixed height is filled: the whole image ("contain", the default) or edge to edge, cropped ("cover").`),maxHeight:F2().int().min(24).max(1600).optional().describe(`The most it is tall, in pixels.`)},example:{id:`photo`,component:`Image`,src:`attachment-1`,alt:`A bar chart of monthly revenue, rising through the year`,caption:`Revenue by month`,fit:`contain`,maxHeight:320}},Link:{description:`A link to a web page. Only http and https addresses are shown as links; in a site, a path on the site ("/pricing") is too, and opens in place.`,props:{text:Z,url:Z},example:{id:`docs`,component:`Link`,text:`Metric definitions`,url:`https://example.com/metrics`}},ThemeSwitch:{description:"Changes how the whole page looks, at once: a built-in theme, light or dark, the accent colour, corner radius, font, density or chart colours. Leave out what should stay as it is. The person sees what changed and can undo it. To style only your own surface, put the same fields in `createSurface.theme` instead.",props:{preset:Y(EM.presets).optional(),mode:Y(EM.modes).optional(),accent:q().regex(/^#[0-9a-fA-F]{6}$/).optional().describe(`A hex colour for buttons, links and selection.`),radius:F2().min(EM.radius[0]).max(EM.radius[1]).optional(),font:Y(EM.fonts).optional(),density:Y(EM.densities).optional(),seriesOrder:Y(EM.seriesOrders).optional().describe(`A tested order of chart colours.`)},example:{id:`look`,component:`ThemeSwitch`,preset:`Aurora`,mode:`dark`}}},$8=Object.fromEntries(Object.entries(Q8).map(([e,t])=>[e,Z8[e]?{...t,events:Z8[e]}:t])),e5=M8({id:`urn:surfaces:catalog:basics:v1`,title:`Surfaces basics`,description:`Layout, text, links, buttons, inputs and forms, navigation and the theme switch: the components every Surfaces catalog shares.`,components:j8($8)})}));V6(),t5(),R8(),m8();var n5=Y([`neutral`,`positive`,`negative`,`warning`]),r5=[`sum`,`avg`,`count`,`count_distinct`,`min`,`max`,`median`,`stddev`,`variance`,`percentile`],i5=Y([`idle`,`starting`,`running`,`completed`,`failed`,`cancelled`,`skipped`]),a5=J(t4({column:q(),op:Y([`eq`,`neq`,`lt`,`lte`,`gt`,`gte`,`in`,`not_in`,`between`,`contains`,`starts_with`,`ends_with`,`is_null`,`is_not_null`,`since`]),values:J(r4([q(),F2(),V2()])).max(1e3).optional().describe(`None for is_null and is_not_null, two for between, otherwise one (several for in and not_in). For since, one relative range: "7d", "4w", "3m", "1y", or "week", "month", "quarter", "year" for the start of this one. Use since for anything like "the last 30 days": it is worked out when the query runs, so it does not go stale.`)})).max(20),o5=r4([a5,J6]).describe(`Filters applied by the database. Send the whole list each time; an empty list clears them. Or a binding (\`{ "@path": "/filters" }\`) to read a list kept in the surface's data model: give every view on a page the same path, with a FilterBar writing to it, and they all follow one set of filters. A filter on a column a view's rows lack (a total with no region column, under a filter by region) is left out for that view, which is drawn without it and says so in a note.`),s5=t4({id:q().regex(/^[A-Za-z][A-Za-z0-9_]*$/).describe(`Its name in calculations and on the shelves. Unique.`),kind:Y([`attribute`,`metric`,`derived`]),label:q(),column:q().optional().describe(`Attributes and metrics: the column. A metric without one counts rows.`),grain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional().describe(`A date or time attribute: the size of its buckets.`),aggregate:Y([`sum`,`avg`,`count`,`count_distinct`,`min`,`max`,`median`]).optional().describe(`Metrics: how the column is summarised.`),expression:q().max(400).optional().describe(`Derived metrics: arithmetic over metric ids, e.g. "refund_amount / line_amount".`),format:Y([`number`,`compact`,`currency`,`percent`]).optional(),description:q().optional(),by:q().optional().describe(`Who made it. Put your own name here for fields you write; it is shown on the pill.`),model:q().optional().describe(`Set by the component on a field that is the semantic model's own. Do not set it yourself.`)}),c5=Y([`inner`,`left`,`right`,`full`]).describe('Which rows it keeps, read from `left` to `right`: "left" every row of the left table, "inner" only rows that match, "right" every row of the right table, "full" every row of both.'),l5=t4({left:q().describe(`A table of the model.`),right:q().describe(`Another table of the model.`),keys:J(t4({leftColumn:q(),rightColumn:q()})).min(1).max(4).describe("The columns that match, a column of `left` with one of `right`."),type:c5.optional().describe('Which rows it keeps, read from `left` to `right`. Put the table nearer the first on the left and leave this out: "left", so adding detail never drops one of the model\'s rows. "inner" drops rows with no match; "right" and "full" add rows that are not the first table\'s.')}),u5=Y([`bar`,`line`,`area`]),d5=t4({type:u5.optional().describe(`How measures are drawn unless one says otherwise. Left out: a line over time, bars otherwise.`),swap:V2().optional().describe(`Turn bars on their side: the breakdown down the left, the measure along the bottom. Bars on one scale only; ignored otherwise.`),measures:c4(q(),t4({type:u5.optional(),axis:Y([`left`,`right`]).optional()})).optional().describe('Per measure, by pill id: its own type (a line over bars) and `axis: "right"` for a second scale. Use a second scale only for two measures of very different sizes; the chart says beneath itself that two scales can mislead.')}).describe(`How the chart is drawn. Left out, it is chosen from what is on the shelves.`),f5=t4({grain:q().max(200).optional().describe(`What one row is, in a sentence: "One order line."`),primaryKey:J(q()).max(8).optional().describe(`The columns that make a row unique. The engine checks it before the model is saved.`),tables:J(q()).max(8).optional().describe("The tables, the first being the one whose rows are the model's rows. The query is generated from them and `joins`."),joins:J(l5).max(12).optional().describe(`Joins that add one row of detail to each row of the first table: a line's order, product or store. A join that repeats rows makes the key fail.`),sql:q().max(8e3).optional().describe(`A single read-only SELECT, in place of tables and joins, when the rows need more than joins (a computed column, a filter, a union).`),dataset:t4({pipeline:q().describe(`The pipeline's id.`),dataset:q().describe(`The dataset's name.`)}).optional().describe(`A dataset a pipeline builds, in place of tables, joins and a query: the model reads its table. Prefer it when a pipeline already builds the rows. Give the dataset's grain and primaryKey from describe_pipeline (the pipeline checks that key after every build) and fields from its columns. The editor shows when it was last built and how its checks went.`)}).describe(`What one row is and where the rows come from. Parts left out stay as they are.`),p5=q().regex(/^[a-z][a-z0-9_]{0,63}$/).describe("The name of a semantic model (list them with list_semantic_models). Its dimensions, measures and metrics become the pills, marked as the model's, so a metric means what the model defines; its source and query are used when `sourceId` and `sql` are left out. Prefer it to writing `fields` whenever a model covers the data. A person can add a field they make to the model."),m5=J(t4({column:q(),desc:V2().optional()})).max(8).describe(`Sort order, most important first. An empty list clears it.`),h5=t4({order:J(q()).max(500).optional().describe(`Column names in display order; the rest follow in the query's order.`),hidden:J(q()).max(500).optional(),widths:c4(q(),F2().min(60).max(1200)).optional().describe(`Widths in px by column name.`),labels:c4(q(),q().max(120)).optional().describe(`Headers to show in place of column names, by column name ("Starts" for starts_at).`)}).describe(`Which columns show, in what order, how wide, and under what headers.`),g5=r4([q(),t4({column:q(),grain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional().describe(`Group a date or time column by this size.`),label:q().optional()})]),_5=e=>q().describe(e),v5=t4({speaker:q().max(80),text:q().max(4e3),side:Y([`start`,`end`]).optional().describe(`"end" for the person's own turns.`),time:q().max(40).optional()}),y5={emptyMessage:Z.optional().describe(`What the people using the page read when the query answers with no rows, in place of the component's own empty text. Say what is missing and what to try: "No orders this week yet."`),errorMessage:Z.optional().describe(`What the people using the page read when the query fails, in place of the database's error text, which is kept for developers. Say what went wrong in their terms and what to do.`)},b5="Give `opened` a data path and opening a table also writes its name there, inside the surface; bind another component's `table` to the same path and it follows, with no agent. The event is still sent.",x5=J6.optional().describe(`Where the opened table's name is written in this surface's data model.`),S5=e4({left:q(),right:q(),keys:J(e4({leftColumn:q(),rightColumn:q()})),inferred:V2().optional(),declared:V2().optional()}),C5={Conversation:{send:{description:`When a person sends a turn, typed or picked from the suggestions. It is already in the thread.`,context:{text:_5(`what they wrote`)}}},Chips:{choose:{description:`When a chip is pressed.`,context:{value:_5(`the chip's value: its text, unless the item sets a value`)}}},DecisionCard:{choose:{description:`When an option is chosen.`,context:{choice:_5(`the option's id`),label:_5(`the option's label`)}}},SqlProposal:{run:{description:`When a person presses Run.`,context:{sql:_5(`the SQL as run`)}}},SqlEditor:{run:{description:`When a person runs the SQL.`,context:{sql:_5(`the SQL as written`)}}},ObjectBrowser:{select:{description:`When a table, column or join is picked.`,context:{table:_5(`table name`),column:_5(`column name, or empty`)}}},ReportBuilder:{ask:{description:"When a person asks for a field, a view or a whole report in words. Answer by updating this component's `fields`, `tiles`, `filters` and `draft`.",context:{text:_5(`what they asked for`)}}},Explorer:{ask:{description:"When a person asks for a field or a view in words. Answer by updating this component's `fields`, `rows`, `split` and `values`.",context:{text:_5(`what they asked for`)}}},SemanticModelEditor:{save:{description:`When a person saves the draft as the model's next version, or a new model as version 1. Every report on the model now uses it.`,context:{model:_5(`the model's name`),version:F2().describe(`the version saved`),changes:c4(q(),q()).describe(`each changed field's name and whether it was added, changed or removed; a part of the rows appears as (grain), (primaryKey), (joins), (sql) or (dataset)`)}},ask:{description:"When a person asks for a change, or for a new model, in words. Answer by updating this component's `proposed` (and `create`).",context:{text:_5(`what they asked for`)}}},FilterBar:{change:{description:`When a person adds or removes a filter.`,context:{filters:J(Y2()).describe("the whole filter list, as the `filters` prop takes it")}}},Chart:{select:{description:`When a person clicks a bar or point.`,context:{column:_5(`the x column`),value:_5(`the clicked x value`),series:_5(`the series clicked`)}}},FileBrowser:{open:{description:`When a person opens a file (Enter or a double click).`,context:{path:_5(`the file's path in its place`),name:_5(`the file's name`),place:_5(`the source id, or local:<folder> for a folder on their computer`),format:_5(`parquet, csv, json, delta or iceberg, or empty`)}}},ModelDiagram:{use:{description:`When a person presses Use as query.`,context:{sql:_5(`the generated SELECT`),tables:J(q()).describe(`the tables`),joins:J(S5).describe(`the joins kept`)}}},DataSearch:{open:{description:`When a result is opened.`,context:{table:_5(`table name`),column:_5(`column name, or empty`)}}},RelationshipGraph:{open:{description:`When a related table is opened.`,context:{table:_5(`table name`)}}},NodeGraph:{select:{description:`When a node is opened, on the graph or in the list beside it.`,context:{node:_5(`the node's id`)}}},ObjectDetail:{open:{description:`When a related table is opened.`,context:{table:_5(`table name`)}}},PipelineGraph:{select:{description:`When a node is chosen.`,context:{id:_5(`node id`),name:_5(`node name`)}}},PipelineView:{started:{description:`When a person starts a run here.`,context:{event:_5(`started`),runId:_5(`the run`),state:_5(`running, or how it already ended`)}},finished:{description:`When a run a person started here ends.`,context:{event:_5(`finished`),runId:_5(`the run`),state:_5(`completed, failed or cancelled`),built:F2().describe(`datasets built`),failed:J(q()).describe(`datasets that failed`),failedChecks:J(q()).describe(`checks that failed, as dataset.check`)}}},DatasetReview:{decide:{description:`When the person approves (and the page saved it) or rejects the dataset.`,context:{approved:V2().describe(`whether it was approved`),version:F2().optional().describe(`the version saved, when approved and saved`),approvedBy:q().optional().describe(`who approved it`),digest:q().optional().describe(`the digest of the pipeline as approved`),note:q().optional().describe(`the person's note, if any`)}}},PlanReview:{decide:{description:`When the plan is approved or rejected.`,context:{approved:V2().describe(`whether the plan was approved`),stepIds:J(q()).describe(`the steps left ticked`),note:q().optional().describe(`the person's note, if any`)}}},ActionReceipt:{undo:{description:`When a person asks to undo what ran. Ask again before undoing; this is a request, not an approval.`}},PiiReview:{decide:{description:`When the review is confirmed.`,context:{table:_5(`table name`),columns:J(e4({name:q(),category:q().optional(),action:q()})).describe(`each column's category and treatment`),confirmed:V2().describe(`true when the person confirmed they may decide this`)}}}};function w5(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,C5[e]?{...t,events:C5[e]}:t]))}var T5=M8({id:`urn:surfaces:catalog:analytics:v1`,title:`Surfaces analytics`,description:`Layout, summary, data, discovery and conversation components for dashboards, query results and chat.`,components:j8(w5({Text:$8.Text,Row:$8.Row,Column:$8.Column,Grid:$8.Grid,Card:$8.Card,Divider:$8.Divider,Workspace:{description:'Several children side by side as panels a person can arrange: drag a panel by its heading to another column or to an edge for a column of its own, resize with the dividers, and hide or show panels from a rail. `layout.columns` says where the panels are: a list of columns from left to right, each a list of panel ids from top to bottom, so search on the left and a map on the right is `[["search"], ["map"]]`. To rearrange, send the component again with a new `layout`; how a person left it comes back to you in the surface\'s controls as `layout`. Panels not placed are added to the last column. Each panel shows on a rail as an icon, with its name in a tooltip and, when a person turns names on, a short name under it: keep titles to a few words, and give `short` and `icon` so the rail reads well. Use it when a person will work across several views at once; use Grid or Row for a fixed arrangement.',props:{label:q().optional().describe(`What the workspace is, for assistive technology.`),panels:J(t4({id:q(),title:q().describe(`The panel's heading: one to three words.`),short:q().max(14).optional().describe(`A shorter name for the rail, which has room for about ten characters a line. Give one when the title is longer than that.`),icon:Y([`surface`,`agent`,`components`,`table`,`code`,`data`,`history`,`save`,`search`,`map`,`chart`,`grid`,`settings`,`note`,`folder`,`person`,`bell`,`people`]).optional().describe(`The rail's icon. Left out, the title's first letter.`),child:l8})).min(1).max(12),layout:t4({columns:J(J(q())).max(4).describe(`Panel ids: one list per column, left to right; each list top to bottom.`),columnWidths:J(F2().positive()).optional().describe(`One share per column; they are scaled to add up to 1. Left out, columns are equal.`),rowHeights:J(J(F2().positive())).optional().describe(`One share per panel of each column. Left out, panels are equal.`),hidden:J(q()).optional().describe(`Panels that exist but are not shown; the rail brings them back.`),collapsed:J(q()).optional().describe(`Panels folded to their heading. A column always keeps one open.`),places:c4(q(),t4({column:F2().int().min(0),row:F2().int().min(0),sole:V2().optional()})).optional().describe(`Where hidden panels were, so they come back to the same place. Reported back to you; you need not set it.`)}).optional(),rail:Y([`left`,`right`,`none`]).optional().describe(`Where the rail of panel toggles sits. Defaults to right.`),railLabels:V2().optional().describe(`Whether the rail shows a short name under each icon. Left out, the rail is icons only and each name shows in a tooltip; a person can turn names on.`),height:F2().int().min(240).max(1600).optional().describe(`How tall the workspace is, in pixels. Panels scroll inside it. Defaults to 520.`)},example:{id:`explore`,component:`Workspace`,label:`Explore the catalog`,panels:[{id:`search`,title:`Table search`,short:`Search`,icon:`search`,child:`search`},{id:`map`,title:`Relationship map`,short:`Map`,icon:`map`,child:`map`}],layout:{columns:[[`search`],[`map`]],columnWidths:[.4,.6]},height:520}},SideNav:$8.SideNav,Tabs:$8.Tabs,Button:$8.Button,TextField:$8.TextField,NumberField:$8.NumberField,ChoicePicker:$8.ChoicePicker,CheckBox:$8.CheckBox,DateTimeInput:$8.DateTimeInput,Slider:$8.Slider,Form:$8.Form,Stat:{description:`One headline number with a label, and optionally how it changed.`,props:{label:Z,value:r4([Z,$6]),delta:Z.optional().describe(`Change text, e.g. "+5.4% vs last quarter".`),tone:n5.optional().describe(`Colour of the change text.`)},example:{id:`revenue`,component:`Stat`,label:`Revenue`,value:{"@path":`/revenue`},delta:`+5.4% vs last quarter`,tone:`positive`}},KeyValue:{description:`A short list of labelled facts.`,props:{items:J(t4({label:Z,value:r4([Z,$6])})).min(1)},example:{id:`facts`,component:`KeyValue`,items:[{label:`Source`,value:`lake`},{label:`Rows`,value:{"@path":`/rows`}}]}},Metric:{description:`One headline number worked out by the database from a query: a total, an average, a count. Use it for dashboard figures; use Stat only for a number you already have.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:o5.optional(),column:q().optional(),aggregate:Y(r5),percentile:F2().min(0).max(1).optional().describe(`For the percentile aggregate, a fraction from 0 to 1: 0.9 is the 90th percentile.`),label:Z,format:Y([`number`,`compact`,`currency`,`percent`]).optional(),currency:q().length(3).optional(),...y5},example:{id:`revenue`,component:`Metric`,sourceId:`lake`,sql:`SELECT * FROM orders`,column:`amount`,aggregate:`sum`,label:`Revenue`,format:`currency`}},Badge:{description:`A small status label.`,props:{text:Z,tone:n5.optional()},example:{id:`status`,component:`Badge`,text:`Up to date`,tone:`positive`}},Progress:{description:`Progress toward a total.`,props:{value:$6,max:$6.optional(),label:Z.optional()},example:{id:`load`,component:`Progress`,value:42,max:100,label:`Rows loaded`}},DataGrid:{description:`A table over a SQL query, for any number of rows. Sorting and paging run in the database. Use it to show rows; use Chart to show a trend or comparison.`,props:{sourceId:Z.describe(`The data source to query.`),sql:Z.describe(`A single read-only SELECT statement.`),mode:Y([`scroll`,`pages`]).optional(),sorts:m5.optional(),filters:o5.optional(),columns:h5.optional(),height:F2().int().min(160).max(1200).optional(),label:q().optional().describe(`Accessible name for the table.`),...y5},example:{id:`table`,component:`DataGrid`,sourceId:`lake`,sql:`SELECT * FROM orders`,height:360}},Chart:{description:`A chart over a SQL query. Give each measure an aggregate so the database summarises the data; without one the chart plots a random sample of rows. Each entry in y is a series; give series their own type and axis for a compound chart. Choose the form from the comparison: bars for amounts across categories (they are sorted largest first and start at zero), a line with xGrain for change over time, xBins for a distribution, scatter for two measures. Avoid a pie beyond five slices, more than five lines, and a second y scale (use two charts on the same x instead); the chart shows advice when its shape is hard to read.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:o5.optional(),type:Y([`bar`,`line`,`area`,`scatter`,`pie`]),x:q().describe(`Column for the x axis, or the slices of a pie.`),xGrain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional().describe(`Group a date or time x column into buckets of this size. Use it for every time series.`),xBins:F2().int().min(2).max(200).optional().describe(`Group a numeric x column into about this many bins, for a histogram.`),y:J(t4({column:q().optional(),aggregate:Y(r5).optional(),percentile:F2().min(0).max(1).optional().describe(`For the percentile aggregate, e.g. 0.9.`),expression:q().max(400).optional().describe('A calculation instead of a column: arithmetic (+ - * / and parentheses) over the names in `terms`, e.g. "refunded / revenue". The database works it out after summarising. Use it for any rate, share, margin or average of sums; never divide in SQL per row.'),terms:c4(q().regex(/^[A-Za-z][A-Za-z0-9_]*$/),t4({column:q().optional(),aggregate:Y(r5)})).optional().describe(`The measures an expression names: each a column and how it is summarised.`),label:q().optional(),type:Y([`bar`,`line`,`area`,`scatter`]).optional().describe(`Draw this series differently from the chart type, e.g. a line over bars.`),axis:Y([`left`,`right`]).optional().describe(`Use the right axis for a measure on a different scale.`),slot:F2().int().min(1).max(12).optional().describe(`Which of the theme's series colours to use, from 1. Give a measure the same slot in every chart so it keeps its colour. Never name a colour: the theme chooses them.`)})).min(1).max(8).describe(`One entry per series.`),splitBy:q().optional().describe(`Column whose values become separate series.`),stacked:V2().optional(),select:J6.optional().describe("Makes the chart a filter: the path of a shared filter list (the one its `filters` and a FilterBar use). A click on a bar filters the page to that x value, a click on it again clears it, and this chart ignores filters on its own x column so the bars a person clicks stay. Only for a category x (no xGrain or xBins)."),sort:Y([`value`,`x`]).optional().describe(`Order of bars. Bars over categories are sorted largest first unless you say "x". Dates, bins and numbers keep their own order.`),legend:Y([`top`,`bottom`,`right`,`none`]).optional().describe(`Leave out: up to four lines are labelled at their ends, and one series needs no legend.`),xTitle:q().optional(),yTitle:q().optional(),yRightTitle:q().optional(),yFormat:Y([`number`,`compact`,`currency`,`percent`]).optional().describe(`How the left axis writes its numbers: "percent" for a rate (6%, not 0.06), "currency" for money. Labels only.`),height:F2().int().min(160).max(1200).optional(),action:d8.optional(),label:q().optional().describe(`Accessible description of what the chart shows.`),...y5},example:{id:`chart`,component:`Chart`,sourceId:`lake`,sql:`SELECT * FROM orders`,type:`bar`,x:`region`,y:[{column:`amount`,aggregate:`sum`,label:`Revenue`}],yTitle:`Revenue`,label:`Revenue by region, largest first`}},PivotTable:{description:`A pivot table over a SQL query: row values down the side, column values across the top, summarised measures in the cells, with totals. The database does the grouping. Use it to compare a measure across two dimensions.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:o5.optional(),rows:J(g5).min(1).max(4).describe(`Columns whose values become the rows.`),columns:J(g5).max(2).optional().describe(`Columns whose values become the columns. Choose ones with few distinct values.`),measures:J(t4({column:q().optional(),aggregate:Y(r5),percentile:F2().min(0).max(1).optional().describe(`For the percentile aggregate, a fraction from 0 to 1: 0.9 is the 90th percentile.`),label:q().optional()})).min(1).max(6),totals:V2().optional(),height:F2().int().min(160).max(1200).optional(),label:q().optional().describe(`Accessible name for the table.`),...y5},example:{id:`pivot`,component:`PivotTable`,sourceId:`lake`,sql:`SELECT * FROM orders`,rows:[`region`],columns:[{column:`ordered_at`,grain:`quarter`}],measures:[{column:`amount`,aggregate:`sum`,label:`Revenue`}]}},QueryResult:{description:"A query result a person can explore: filters; a table, a chart and a pivot of the same query; and the SQL that ran. Set `view`, `filters`, `sorts` and `columns` to put its controls in a given state; update them to change what a person sees, and they can go on changing them by hand.",props:{sourceId:Z,sql:Z,view:Y([`grid`,`chart`,`pivot`]).optional(),filters:o5.optional(),sorts:m5.optional(),columns:h5.optional(),height:F2().int().min(160).max(1200).optional(),...y5},example:{id:`explore`,component:`QueryResult`,sourceId:`lake`,sql:`SELECT * FROM orders`}},Message:{description:`One turn of a conversation, for a page that is laid out as a chat: who spoke, what they said (Markdown), and when. Put the turns in a Column, oldest first. \`side: "end"\` sets the person's own turns apart from everyone else's; the speaker is always written, so the side is never the only sign. Offer replies with Chips after the last turn, and take a typed one with a TextField and a Button. It shows a conversation; it does not run one.`,props:{speaker:Z.describe(`Who spoke: a name or a role.`),text:Z.describe(`What they said, as Markdown.`),side:Y([`start`,`end`]).optional().describe(`"end" for the person's own turns. Defaults to "start".`),time:Z.optional().describe(`When, as it should read: "10:42" or "Yesterday".`)},example:{id:`turn-1`,component:`Message`,speaker:`Assistant`,text:`Which table holds the articles?`,time:`10:42`}},Conversation:{description:"A whole chat in one component: the turns so far, replies to pick, and a box to write in. Sending adds the person's turn to the thread at once and sends `send` with what they wrote. Give `messages` the turns, oldest first, or a data path holding them. Keep the thread there: answer `send` by adding the person's turn and yours to the list, and each is drawn once. For a prototype with no agent, `replies` answer in order, one for each turn the person sends. For one turn on its own, or a thread laid out by hand among other components, use Message.",props:{label:q().max(80).describe(`What the conversation is, for assistive technology: "Support chat".`),messages:r4([J(v5).max(200),J6]).describe(`The turns so far, oldest first, or a data path holding them. An empty list starts with only the box.`),you:q().max(80).optional().describe(`Who the person is on their own turns. Defaults to "You".`),suggestions:J(q().max(120)).max(6).optional().describe(`Replies offered under the thread until the person sends something; a press sends one.`),replies:J(t4({speaker:q().max(80),text:q().max(4e3)})).max(20).optional().describe(`Scripted answers for a prototype with no agent: the first answers the person's first turn, and so on. Leave it out when an agent answers.`),placeholder:q().max(120).optional().describe(`What the box says while it is empty. Defaults to "Write a message".`),action:d8.optional()},example:{id:`support`,component:`Conversation`,label:`Support chat`,messages:[{speaker:`Assistant`,text:`Hi! What can I help you with today?`,time:`10:41`},{speaker:`You`,text:`My last order hasn't arrived.`,side:`end`,time:`10:42`},{speaker:`Assistant`,text:`Sorry about that. Which order is it?`,time:`10:42`}],suggestions:[`The one from Monday`,`Show my orders`],replies:[{speaker:`Assistant`,text:`Thanks. It left the warehouse yesterday and arrives **tomorrow**.`}],action:{event:{name:`send`}}}},RowList:{description:'One component drawn once for each row of a SQL query: a feed of posts, a list of cards, rows that each carry their own buttons. `child` is the component drawn per row, usually a Card. Inside it, and in everything it holds, a relative path reads the row\'s column of that name (`{ "@path": "author" }`; `formatString` with `${author}` too), and a Button\'s event carries the row\'s key the same way (`"context": { "post_id": { "@path": "post_id" } }`), so you learn which row was acted on. Absolute paths still read the surface\'s data model. The database sorts, filters and pages; a person asks for more rows, up to 200. An input inside a row must bind an absolute path. For plain rows in columns use DataGrid.',props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement. One row of it is one item.`),child:l8.describe(`ID of the component drawn for each row.`),label:q().describe(`What the items are, for assistive technology: "Posts".`),sorts:m5.optional(),filters:o5.optional(),pageSize:F2().int().min(1).max(100).optional().describe(`Rows fetched at a time. Defaults to 20.`),rowKey:q().optional().describe(`A column that tells rows apart, such as the key.`),layout:Y([`list`,`grid`]).optional().describe(`"list" stacks the rows; "grid" lays them out as cards, as many across as fit.`),...y5},example:{id:`feed`,component:`RowList`,sourceId:`lake`,sql:`SELECT * FROM orders`,child:`order-card`,label:`Orders`,sorts:[{column:`ordered_at`,desc:!0}],rowKey:`order_id`,pageSize:10}},Markdown:$8.Markdown,Image:$8.Image,CodeBlock:{description:`Code with a copy button. For SQL a person should be able to run, use SqlProposal instead.`,props:{code:Z,language:q().optional()},example:{id:`snippet`,component:`CodeBlock`,language:`sql`,code:`SELECT region, SUM(amount) FROM orders GROUP BY region`}},Table:{description:`A small table of values you already have (at most 100 rows). For query results use DataGrid, which pages in the database.`,props:{columns:J(q()).min(1).max(12),rows:J(J(r4([q(),F2(),V2(),q2()]))).max(100),caption:q().optional()},example:{id:`top`,component:`Table`,columns:[`Region`,`Revenue`],rows:[[`Europe`,1200],[`Asia Pacific`,950]],caption:`Top regions`}},Link:$8.Link,Checklist:{description:`A list of steps showing which are done.`,props:{items:J(t4({label:Z,done:V2().optional()})).min(1).max(30)},example:{id:`plan`,component:`Checklist`,items:[{label:`Find the tables`,done:!0},{label:`Check the join`}]}},Chips:{description:"Short choices a person can pick with one press, such as follow-up questions or tables to look at. The chosen chip is sent back in the event context as `value`. An item is its text, or `{ label, value }` when what is sent differs from what is shown. Give `selected` a data path and a press also writes the chip's value there, inside the surface; bind another component's prop to the same path and it follows at once, with no agent: chips of table names whose values are SELECT statements switch a QueryResult whose `sql` is bound to that path. Set the path in the data model to the value that starts selected.",props:{items:J(r4([q(),t4({label:q(),value:q()})])).min(1).max(12),selected:J6.optional().describe(`Where the pressed chip's value is written in this surface's data model. The chip holding the value there is shown as pressed.`),action:d8},example:{id:`next`,component:`Chips`,items:[`Break down by region`,`Show last year`],action:{event:{name:`choose`}}}},DecisionCard:{description:"Asks a person to choose between options before you continue. Mark the option you recommend. The chosen option's id is sent back in the event context as `choice`.",props:{title:Z,detail:Z.optional(),options:J(t4({id:q(),label:q(),description:q().optional(),recommended:V2().optional()})).min(2).max(6),action:d8},example:{id:`grain`,component:`DecisionCard`,title:`Which revenue should I use?`,detail:`The two tables disagree for March.`,options:[{id:`ledger`,label:`Finance ledger`,description:`Certified, updated nightly.`,recommended:!0},{id:`orders`,label:`Orders table`,description:`Live, but includes returns.`}],action:{event:{name:`decide`}}}},Sparkline:{description:`A word-sized trend line beside its latest value, worked out by the database: no axes, grid or legend. Use it in a table of figures or beside a Metric to show direction; use Chart when the values themselves must be read.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:o5.optional(),x:q().describe(`The date or time column the line runs along.`),grain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]),column:q().optional(),aggregate:Y(r5),label:Z,format:Y([`number`,`compact`,`currency`,`percent`]).optional(),currency:q().length(3).optional(),points:F2().int().min(2).max(120).optional(),...y5},example:{id:`trend`,component:`Sparkline`,sourceId:`lake`,sql:`SELECT * FROM orders`,x:`ordered_at`,grain:`month`,column:`amount`,aggregate:`sum`,label:`Revenue`,format:`currency`}},BulletGraph:{description:`One measure against a target and named bands (poor, fair, good), as a bar from zero. Use it instead of a gauge or a traffic light when a number needs judging against a goal.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:o5.optional(),column:q().optional(),aggregate:Y(r5),label:Z,target:F2().optional(),ranges:J(t4({to:F2(),label:q()})).min(1).max(5).describe(`Where each band ends, lowest first. The last end is the end of the scale.`),format:Y([`number`,`compact`,`currency`,`percent`]).optional(),currency:q().length(3).optional(),...y5},example:{id:`goal`,component:`BulletGraph`,sourceId:`lake`,sql:`SELECT * FROM orders`,column:`amount`,aggregate:`sum`,label:`Revenue`,format:`currency`,target:2e6,ranges:[{to:1e6,label:`Poor`},{to:18e5,label:`Fair`},{to:3e6,label:`Good`}]}},StepFlow:{description:"Where multi-step work stands: onboarding, connecting a source, a cleaning or transformation run. Give a step the status `waiting` when the work has stopped for the person, and say in `detail` what you need from them.",props:{label:Z,steps:J(t4({id:q(),title:q(),detail:q().optional(),status:Y([`done`,`current`,`waiting`,`pending`,`failed`,`skipped`])})).min(1).max(20)},example:{id:`flow`,component:`StepFlow`,label:`Connect the sales lake`,steps:[{id:`find`,title:`Find the tables`,status:`done`},{id:`secret`,title:`Add the credential on the server`,detail:`Set LAKE_KEY_ID and LAKE_SECRET, then tell me.`,status:`waiting`},{id:`test`,title:`Test the connection`,status:`pending`}]}},PlanReview:{description:'A plan a person must approve before you act: cleaning steps, transformations, a connection to set up. List every step with what it changes; mark anything that removes or overwrites data or widens access as `risk: "high"` (it starts unticked). The event context carries `approved`, the ticked `stepIds` and any `note`. Do only the approved steps.',props:{title:Z,summary:Z.optional(),proposedBy:q().optional().describe(`Your name, so the person knows who wrote the plan.`),steps:J(t4({id:q(),title:q(),detail:q().optional(),sql:q().optional().describe(`What the step would run, for review only.`),kind:q().optional(),affects:q().optional(),risk:Y([`low`,`medium`,`high`]).optional(),required:V2().optional()})).min(1).max(20),action:d8},example:{id:`clean`,component:`PlanReview`,title:`Clean the orders table`,summary:`Three fixes before it feeds the revenue dashboard.`,proposedBy:`Analyst agent`,steps:[{id:`trim`,title:`Trim spaces from region`,kind:`Clean`,affects:`412 of 58,000 rows`,sql:`SELECT TRIM(region) AS region FROM orders`},{id:`dedupe`,title:`Remove repeated order IDs`,kind:`Clean`,affects:`37 rows removed`,risk:`high`}],action:{event:{name:`plan_decided`}}}},ActionReceipt:{description:"What happened after a person approved something: the outcome, who approved it and why, what ran, what changed, and whether it can be undone. Send one after every approved action that changed something, including a failed one. Give `undo` only when undoing is really possible, with `until` when it stops being; leave it out and the receipt says it cannot be undone. The `undo` event is a request: confirm it with the person before acting.",props:{title:Z,outcome:Y([`done`,`partial`,`failed`]),summary:Z.optional(),ranAt:q().optional().describe(`ISO time it ran.`),ranBy:q().optional().describe(`What ran it: you, a pipeline, a service.`),approvedBy:J(t4({by:q(),at:q().optional(),reason:q().optional()})).max(10).optional(),sql:q().optional().describe(`What ran, for the record. Never run from the receipt.`),changes:J(t4({label:q(),before:q().optional(),after:q()})).max(20).optional(),undo:t4({label:q(),description:q().optional(),until:q().optional()}).optional(),action:d8.optional()},example:{id:`receipt`,component:`ActionReceipt`,title:`Rebuilt orders_clean`,outcome:`done`,summary:`58,000 rows replaced with 57,963 after removing repeated order IDs.`,ranAt:`2026-11-13T10:04:00Z`,ranBy:`sales pipeline`,approvedBy:[{by:`Ada`,at:`2026-11-13T10:02:00Z`,reason:`Counts checked against finance`}],changes:[{label:`Rows`,before:`58,000`,after:`57,963`}],undo:{label:`Restore the previous version`,description:`Restores the table as it was at 10:03. Rows added since then are lost.`,until:`2026-11-20T10:04:00Z`},action:{event:{name:`undo_requested`}}}},PiiReview:{description:"A review of a table's columns for personal data before it is shared, charted or sent to a model. Flag a column with the kind of data you suspect and how you know (`basis`); the person chooses the treatment and confirms. The event context carries `table`, `columns` (name, category, action) and `confirmed`. Never treat your own flags as the decision.",props:{table:q(),purpose:Z.optional(),columns:J(t4({name:q(),type:q().optional(),category:Y([`name`,`email`,`phone`,`address`,`government_id`,`financial`,`date_of_birth`,`network`,`location`,`credential`,`health`,`demographic`]).optional(),basis:Y([`name`,`values`,`person`]).optional(),action:Y([`keep`,`mask`,`hash`,`generalize`,`drop`]).optional()})).min(1).max(200),action:d8},example:{id:`pii`,component:`PiiReview`,table:`customers`,purpose:`Before sharing with the marketing workspace.`,columns:[{name:`customer_id`,type:`BIGINT`},{name:`email`,type:`VARCHAR`,category:`email`,basis:`name`},{name:`birth_date`,type:`DATE`,category:`date_of_birth`,basis:`name`}],action:{event:{name:`pii_decided`}}}},ThemeSwitch:$8.ThemeSwitch,SqlProposal:{description:"SQL you propose, shown for review. It never runs on its own: a person presses Run, and the result appears beneath it. The event, if given, is sent with `sql` when they do.",props:{sourceId:Z,sql:Z,title:q().optional(),action:d8.optional()},example:{id:`proposal`,component:`SqlProposal`,sourceId:`lake`,title:`Revenue by region`,sql:`SELECT region, SUM(amount) AS revenue FROM orders GROUP BY region`}},SqlEditor:{description:"An editor for a person to write or change SQL. The event is sent with `sql` when they run it.",props:{sql:Z.optional(),dialect:Y([`standard`,`duckdb`,`teradata`,`postgres`]).optional(),action:d8.optional()},example:{id:`editor`,component:`SqlEditor`,sql:`SELECT * FROM orders`,action:{event:{name:`run`}}}},ObjectBrowser:{description:"A tree of the source's catalogs, schemas, tables and columns, with the tables each one joins. Use it when a person needs to look around. The event is sent with `table` (and `column`) when they pick something. "+b5,props:{sourceId:Z,height:F2().int().min(200).max(1200).optional(),opened:x5,action:d8.optional()},example:{id:`browse`,component:`ObjectBrowser`,sourceId:`lake`,height:360}},ReportBuilder:{description:"A report built from pills: the dashboard pattern. `fields` are the report's pills (attributes, metrics, derived metrics), defined once so a metric means the same in every view. `tiles` are the views, each a set of shelves (`rows`, `split`, `values`, by pill id) drawn as a chart, a table, or headline numbers when there is nothing to break down by. Every tile follows `filters`, and a click on a bar filters the whole report. In build mode a person makes a view on the shelves and keeps it as a tile, edits pills, retitles, resizes and reorders; in view mode it is the dashboard alone with its filter bar. To write a report yourself, send `fields` and `tiles`; to leave it to the person, send only `sql` and pills are generated from its columns. What they change comes back as this component's controls, so read those first. Give `action` to show a box where they ask in words. Use it for anything with several views over one table or join; use separate Chart and Metric components only when the views read different queries.",props:{model:p5.optional(),sourceId:Z.optional().describe("Where the query runs. Left out with `model`, the model's."),sql:Z.optional().describe("A single read-only SELECT statement, wide enough for every view: a table, or a join. Left out with `model`, the model's."),title:q().optional(),fields:J(s5).max(200).optional().describe(`The report's pills. Left out, they are generated from the query's columns.`),filters:a5.optional().describe(`Filters every tile follows.`),tiles:J(t4({id:q(),title:q().optional().describe(`Left out, the shelves are read out: "Refund rate by Category".`),rows:J(q()).max(3).describe(`Attributes to break down by, by pill id. Empty for headline numbers.`),split:q().optional(),values:J(q()).min(1).max(6).describe(`Metrics and derived metrics, by pill id.`),view:Y([`chart`,`table`]).optional(),chart:d5.optional(),span:r4([m4(1),m4(2),m4(3)]).optional().describe(`How many of the report's three columns it takes.`)})).max(24).optional(),draft:t4({rows:J(q()).max(3),split:q().optional(),values:J(q()).max(6),view:Y([`chart`,`table`]).optional(),chart:d5.optional()}).optional().describe(`What is on the builder's shelves: a view you propose, for the person to add.`),mode:Y([`build`,`view`]).optional().describe(`Leave out to let the person switch. "view" shows the dashboard alone.`),action:d8.optional()},example:{id:`report`,component:`ReportBuilder`,sourceId:`lake`,sql:`SELECT * FROM orders`,title:`Orders`,fields:[{id:`region`,kind:`attribute`,label:`Region`,column:`region`},{id:`ordered_at`,kind:`attribute`,label:`Month`,column:`ordered_at`,grain:`month`},{id:`amount`,kind:`metric`,label:`Revenue`,column:`amount`,aggregate:`sum`,format:`currency`},{id:`orders`,kind:`metric`,label:`Orders`,aggregate:`count`},{id:`per_order`,kind:`derived`,label:`Revenue per order`,expression:`amount / orders`,format:`currency`}],tiles:[{id:`headline`,rows:[],values:[`amount`,`orders`,`per_order`],span:3},{id:`by-region`,rows:[`region`],values:[`amount`]},{id:`over-time`,rows:[`ordered_at`],values:[`per_order`],span:2}]}},SemanticModelEditor:{description:"A semantic model, to create, read and change: what one row is (the grain) and the columns that make it unique, where the rows come from (tables and joins, or a written query), and its dimensions (ways to break rows down), measures (a column summarised) and metrics (arithmetic over measures), each with who defined it. Every Explorer and ReportBuilder given this `model` takes its fields from it, so a change here changes every report on it. To propose a change, send `proposed` with the fields to add or replace (in the pill form: an attribute is a dimension, a metric a measure, a derived metric a metric), the names to remove and any change to the rows, and `proposedBy` with your name; read the model with describe_semantic_model first. To propose a new model, send `create` with its label and source and `proposed` with its rows and fields; read the tables with describe_table first and join from the table whose rows the model counts to tables that add one row of detail each. Either way it is shown as a draft, marked part by part and checked as it is made, and a person can change the joins, the grain, the key and every field before saving; nothing is kept until they save. What the person changes comes back as `proposed` in this component's controls. Give `action` to receive the `save` event, and the `ask` event with `text` when the person asks for something in words.",props:{model:p5.describe("The semantic model to show, or with `create` the name of the one to make."),create:t4({label:q().max(80).describe(`Its name for people.`),description:q().max(400).optional().describe(`What it is for.`),sourceId:q().describe(`The source its rows come from.`)}).optional().describe("Propose a new model named `model`. Its rows and fields go in `proposed`. When a model of that name exists, the proposal is shown as a change to it instead."),proposed:t4({add:J(s5).max(60).optional().describe(`Fields to add, or to put in place of the field of the same id.`),remove:J(q()).max(60).optional().describe(`Names of fields to take out.`),rows:f5.optional()}).optional().describe(`A change you propose, or a new model's rows and fields. Shown as a draft for a person to read, change and save, or drop.`),proposedBy:q().optional().describe(`Who proposed it: your name. Shown above the changes.`),action:d8.optional()},example:{id:`model`,component:`SemanticModelEditor`,model:`sales_lines`,proposed:{add:[{id:`cost_share`,kind:`derived`,label:`Cost share`,expression:`cost / revenue`,format:`percent`,description:`Cost as a share of revenue.`}],remove:[`brand`]},proposedBy:`the analytics agent`,action:{event:{name:`model.saved`}}}},Explorer:{description:"Exploring a query with pills, as a person would in a BI tool but with nothing defined in advance. Each field is a pill: an attribute to break down by, a metric (a column summarised) or a derived metric (arithmetic over metrics: a rate, a margin). Leave `fields` out and pills are generated from the query's columns; send `fields` to add your own metrics and calculations, which a person can then edit. `rows`, `split` and `values` are what is on the shelves, by pill id, and draw a chart and the numbers behind it, worked out by the database. A person drags, presses and edits; what they did comes back as this component's controls, so read those before changing it. Give `action` to show a box where they ask in words, sent as the event with `text`. Use it when someone wants to look around a table or a join themselves; use Chart when you already know the view.",props:{model:p5.optional(),sourceId:Z.optional().describe("Where the query runs. Left out with `model`, the model's."),sql:Z.optional().describe("A single read-only SELECT statement: a table, or a join. Every pill is a column of it or a calculation over them. Left out with `model`, the model's."),fields:J(s5).max(200).optional().describe(`The pills. Left out, they are generated from the query's columns.`),rows:J(q()).max(3).optional().describe(`Attributes to break down by, by pill id. The first is the x axis.`),split:q().optional().describe(`An attribute whose values become separate series.`),values:J(q()).max(6).optional().describe(`Metrics and derived metrics to show, by pill id.`),filters:a5.optional(),view:Y([`chart`,`table`]).optional(),chart:d5.optional(),action:d8.optional()},example:{id:`explore`,component:`Explorer`,sourceId:`lake`,sql:`SELECT * FROM orders`,fields:[{id:`region`,kind:`attribute`,label:`Region`,column:`region`},{id:`amount`,kind:`metric`,label:`Revenue`,column:`amount`,aggregate:`sum`,format:`currency`},{id:`orders`,kind:`metric`,label:`Orders`,aggregate:`count`},{id:`per_order`,kind:`derived`,label:`Revenue per order`,expression:`amount / orders`,format:`currency`}],rows:[`region`],values:[`per_order`]}},FilterBar:{description:'Filters for a whole page: active filters as removable chips and a form to add one, with each column\'s values offered from the database and quick date ranges that stay relative. It writes the list to `filters`, a path in the surface\'s data model; give every Chart, Metric, Sparkline, DataGrid and PivotTable on the page `filters: { "@path": "/filters" }` with the same path and they all follow it. The views should read the same columns as `sql`, since a filter on a column a view does not have fails. Put the starting filters in the data model with updateDataModel. The event, if given, is sent with `filters` on every change.',props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement whose columns can be filtered.`),filters:J6.describe(`Where the filter list is kept in the surface's data model, e.g. { "@path": "/filters" }.`),columns:J(q()).max(50).optional().describe(`Offer only these columns.`),action:d8.optional()},example:{id:`filters`,component:`FilterBar`,sourceId:`lake`,sql:`SELECT * FROM orders`,filters:{"@path":`/filters`},columns:[`region`,`status`,`ordered_at`]}},FileBrowser:{description:"A tree of folders and files: a source's storage (only the places it may read) and, with `local`, folders the person opens from their own computer, which their browser reads and nothing uploads. It shows names, sizes, dates and which table reads a file, never what a file holds. Use it when the data a person means is still files: to find what to bring in, or to see what a table reads. The event is sent with `path`, `name`, `place` and `format` when they open a file. You cannot read a local file; ask the person to load it.",props:{sourceId:Z.optional().describe(`List this source's storage. Leave out to offer only folders on the person's computer.`),local:V2().optional().describe(`Offer "Open a folder on this computer".`),height:F2().int().min(200).max(1200).optional(),action:d8.optional()},example:{id:`files`,component:`FileBrowser`,sourceId:`lake`,local:!0,height:360,action:{event:{name:`open_file`}}}},ModelDiagram:{description:"A relationship diagram: tables as cards with their columns and lines between the columns that join. A person can drag columns together to add joins. Use it to show or agree how tables relate. The event is sent with `sql`, `tables` and `joins` when they press Use as query.",props:{sourceId:Z,tables:J(q()).min(1).max(12).describe(`Tables to show.`),joins:J(t4({left:q(),right:q(),keys:J(t4({leftColumn:q(),rightColumn:q()})).min(1),inferred:V2().optional().describe(`True when you are guessing the join; it is then labelled Inferred.`),declared:V2().optional().describe(`True when the backend reports it as a foreign key; it is then labelled Declared.`),type:c5.optional().describe("Which rows it keeps, read from `left` to `right`. Left out, only rows that match.")})).optional(),rowsFrom:V2().optional().describe(`The first table's rows are the result's rows: it is marked, the rest are laid out as its detail, and each join says whether it adds one row or can repeat rows. Use it to show which tables can be joined without double counting.`),suggest:V2().optional().describe(`False to leave out joins the backend would guess from column names; the joins you send and those the source declares are still shown. Default true.`),height:F2().int().min(200).max(1200).optional(),action:d8.optional()},example:{id:`model`,component:`ModelDiagram`,sourceId:`lake`,tables:[`orders`,`customers`],joins:[{left:`orders`,right:`customers`,keys:[{leftColumn:`customer_id`,rightColumn:`customer_id`}],inferred:!0}],action:{event:{name:`use_model`}}}},DataSearch:{description:`A search box over tables and columns, by name or meaning. The event is sent with \`table\` when a person opens a result. ${b5}`,props:{sourceId:Z.optional(),opened:x5,height:F2().int().min(160).max(1200).optional().describe(`How tall the search is, in pixels. The results scroll inside it. Left out, the list is as long as its results.`),action:d8.optional()},example:{id:`find`,component:`DataSearch`,sourceId:`lake`,opened:{"@path":`/table`},height:420}},ObjectDetail:{description:`Everything known about one table: description, certification, columns with statistics and related tables. Bind \`table\` to a path (\`{ "@path": "/table" }\`) to show whichever table a search or graph in the same surface opened. ${b5}`,props:{sourceId:Z,table:Z,opened:x5,action:d8.optional()},example:{id:`about`,component:`ObjectDetail`,sourceId:`lake`,table:`orders`}},RelationshipGraph:{description:`A small map of one table and the tables it joins with or resembles. For several tables and their columns, use ModelDiagram. ${b5}`,props:{sourceId:Z,table:Z,opened:x5,action:d8.optional()},example:{id:`around`,component:`RelationshipGraph`,sourceId:`lake`,table:`orders`}},NodeGraph:{description:"Things and the links between them, drawn as a graph with the same things listed beside it: concepts in a glossary, tables in a model, systems and what they feed. You give the nodes and links; it reads no data. `group` is what kind of thing a node is (each group takes a colour and is named in the legend); `level` is how far along it is (drawn as how full the node is). Give `selected` a data path to mark the open node and to write the node a person opens there. Past 300 nodes it shows what is around the open node and says how many it left out. For tables and their joins use ModelDiagram; for a pipeline use PipelineGraph.",props:{label:q().describe(`What the graph shows, for assistive technology.`),nodes:J(e4({id:q().min(1),label:q(),description:q().optional(),group:q().optional(),level:Y([`full`,`half`,`outline`]).optional()})).max(2e3),links:J(e4({source:q(),target:q(),label:q().optional()})).max(8e3),selected:r4([q(),J6]).optional().describe(`The open node's id, or a data path that holds it and is written when a person opens a node.`),groups:J(q()).max(12).optional().describe(`The order groups take colours and appear in the legend.`),levels:e4({full:q().optional(),half:q().optional(),outline:q().optional()}).optional().describe(`What each level means, in words.`),noun:q().optional().describe(`What a node is called: "term" gives "7 terms".`),height:F2().int().min(200).max(1200).optional(),action:d8.optional()},example:{id:`concepts`,component:`NodeGraph`,label:`Terms and how they are linked`,noun:`term`,nodes:[{id:`order`,label:`Order`,level:`full`},{id:`customer`,label:`Customer`,level:`half`},{id:`store`,label:`Store`,level:`outline`}],links:[{source:`order`,target:`customer`,label:`placed by`},{source:`order`,target:`store`,label:`taken at`}],levels:{full:`Certified`,half:`Partly certified`,outline:`Not certified`},selected:{"@path":`/term`},height:360}},AskData:{description:`A question box that answers from the catalog and cites the tables it used.`,props:{sourceId:Z.optional(),contextPackId:q().optional()},example:{id:`ask`,component:`AskData`,sourceId:`lake`}},ContextBuilder:{description:`Lets a person assemble the tables, columns and notes an agent should work from, and preview exactly what the agent will receive.`,props:{name:q().optional(),tables:J(t4({sourceId:q(),table:q()})).max(30).optional()},example:{id:`context`,component:`ContextBuilder`,name:`Sales analysis`,tables:[{sourceId:`lake`,table:`orders`}]}},QueryPlan:{description:`How the database intends to run a query, without running it: the steps as a tree and the engine's own plan text. Use it to explain why a query is slow.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`)},example:{id:`plan`,component:`QueryPlan`,sourceId:`lake`,sql:`SELECT region, SUM(amount) FROM orders GROUP BY region`}},SourceList:{description:`The data sources available, how each connects (by secret name only) and a button to test that its tables can be reached.`,props:{},example:{id:`sources`,component:`SourceList`}},PipelineGraph:{description:"A pipeline as a graph of sources, tables, views and sinks with the flows between them and each one's latest status. You supply the nodes and edges as the pipeline engine reported them. The event is sent with `id` and `name` when a node is chosen.",props:{nodes:J(t4({id:q(),name:q(),kind:Y([`source`,`table`,`view`,`streamingTable`,`materializedView`,`temporaryView`,`sink`]),status:i5.optional(),layer:Y([`bronze`,`silver`,`gold`]).optional(),rowsWritten:F2().optional(),expectationsFailed:F2().optional().describe(`records that broke a row rule`),checksFailed:F2().optional().describe(`checks over the whole dataset that failed`)})).min(1).max(200),edges:J(t4({from:q(),to:q(),flowName:q().optional(),mode:Y([`streaming`,`batch`]).optional()})).max(600),height:F2().int().min(160).max(1200).optional(),action:d8.optional()},example:{id:`pipeline`,component:`PipelineGraph`,nodes:[{id:`files`,name:`landing files`,kind:`source`},{id:`raw`,name:`orders_raw`,kind:`streamingTable`,layer:`bronze`,status:`completed`,rowsWritten:12e3},{id:`daily`,name:`daily_revenue`,kind:`materializedView`,layer:`gold`,status:`running`}],edges:[{from:`files`,to:`raw`,mode:`streaming`},{from:`raw`,to:`daily`}]}},PipelineView:{description:"A pipeline the backend runs, live: its datasets and how they feed one another, its runs, and for each dataset its query, grain, key, columns, row rules and checks with the latest results, with buttons to run, check or rebuild it. Give `action` to hear when a person's run starts and ends (`started`, `finished`). Use PipelineGraph instead when you only have a description of a pipeline to draw.",props:{pipelineId:Z,action:d8.optional()},example:{id:`sales-pipeline`,component:`PipelineView`,pipelineId:`sales`}},DatasetReview:{description:"A new or changed pipeline dataset for a person to approve: its query, what it reads, its grain and key, columns and checks, and what changes from the saved version. Give it exactly what `propose_dataset` returned: `pipeline`, `dataset`, `expectedVersion` and `digest`. The person may change the grain, descriptions and checks, names themselves, and approves or rejects. Approving saves it on the server, which checks it again; it builds nothing, so run the pipeline afterwards if they want it built. The `decide` event says what they chose.",props:{pipeline:c4(q(),Y2()).describe(`The whole pipeline as it would be, as propose_dataset returned it.`),dataset:q().describe(`The dataset under review.`),expectedVersion:F2().int().min(0),digest:q().optional(),proposedBy:q().optional().describe(`Your name, so the person knows who proposed it.`),action:d8.optional()},example:{id:`review`,component:`DatasetReview`,pipeline:{id:`sales`,name:`Sales`,sourceId:`lake`,datasets:[{name:`orders_clean`,sql:`SELECT * FROM orders WHERE status IS NOT NULL`,grain:`one row per order`,primaryKey:[`order_id`]},{name:`region_revenue`,sql:`SELECT region, SUM(amount) AS revenue FROM orders_clean GROUP BY region`,inputs:[`orders_clean`],inputsDeclared:!0,grain:`one row per region`,primaryKey:[`region`],columns:[{name:`region`,type:`VARCHAR`},{name:`revenue`,type:`DOUBLE`,description:`Sum of amount.`}],checks:[{name:`relationships_region`,kind:`CHECK_KIND_RELATIONSHIPS`,columns:[`region`],toTable:`orders_clean`,toColumn:`region`}]}]},dataset:`region_revenue`,expectedVersion:1,proposedBy:`Analyst agent`,action:{event:{name:`dataset_decided`}}}},IngestWizard:{description:`Steps a person through bringing new files in: where they are, what the engine finds there, and which columns to keep, rename and retype. It writes configuration to review; it loads nothing.`,props:{sourceId:Z,location:q().optional().describe(`Where the files are, to start from.`),format:Y([`parquet`,`delta`,`iceberg`,`csv`,`json`]).optional()},example:{id:`ingest`,component:`IngestWizard`,sourceId:`lake`,format:`parquet`,location:`s3://acme-lake/landing/orders/*.parquet`}},RunHistory:{description:`The runs of a pipeline, newest first: how each ended, how long it took, what it refreshed and why it failed.`,props:{runs:J(t4({id:q(),state:i5,startTime:q().describe(`ISO 8601.`),endTime:q().optional(),trigger:q().optional(),refreshKind:Y([`default`,`refresh`,`fullRefresh`]).optional(),datasets:J(q()).optional(),errorMessage:q().optional()})).max(200)},example:{id:`runs`,component:`RunHistory`,runs:[{id:`update-42`,state:`completed`,startTime:`2026-11-12T02:00:00Z`,endTime:`2026-11-12T02:01:05Z`,trigger:`schedule`}]}},ExpectationsPanel:{description:`Data quality rules for a pipeline with how many records passed and failed each, worst first. Counts come from the engine.`,props:{expectations:J(t4({name:q(),dataset:q(),constraint:q(),action:Y([`warn`,`drop`,`fail`]),passedRecords:F2().min(0),failedRecords:F2().min(0)})).max(200)},example:{id:`quality`,component:`ExpectationsPanel`,expectations:[{name:`valid_amount`,dataset:`orders_clean`,constraint:`amount >= 0`,action:`drop`,passedRecords:960,failedRecords:40}]}},SchemaDiff:{description:`How incoming data differs from the table it loads into: new, missing and retyped columns.`,props:{changes:J(t4({column:q(),change:Y([`added`,`removed`,`typeChanged`]),before:q().optional(),after:q().optional()})).max(500),rescuedCount:F2().min(0).optional(),mode:q().optional().describe(`How new columns are treated, e.g. addNewColumns, rescue, failOnNewColumns.`)},example:{id:`drift`,component:`SchemaDiff`,mode:`rescue`,rescuedCount:12,changes:[{column:`coupon_code`,change:`added`,after:`string`}]}},StreamMetrics:{description:`How a streaming query is keeping up: input and processing rates, batch size and duration, with recent trends. Give the progress reports oldest first, as reported.`,props:{progress:J(t4({timestamp:q(),numInputRows:F2(),inputRowsPerSecond:F2(),processedRowsPerSecond:F2(),batchDurationMs:F2(),stateRows:F2().optional()})).min(1).max(500)},example:{id:`stream`,component:`StreamMetrics`,progress:[{timestamp:`2026-11-12T10:00:00Z`,numInputRows:500,inputRowsPerSecond:50,processedRowsPerSecond:80,batchDurationMs:900}]}}}))});function E5(e){return e.a2ui===`1.0`?e:{...e,a2ui:`1.0`,components:Object.fromEntries(Object.entries(e.components).map(([e,t])=>[e,g8(t)]))}}var D5=n((()=>{m8(),C8()}));m8(),C8();function O5(e){return e.a2ui===`1.0`?e:{...e,a2ui:`1.0`,components:e.components.map(g8)}}function k5(e){let t=O5(e);return{surfaceId:t.id,catalogId:t.catalogId,a2ui:`1.0`,components:Object.fromEntries(t.components.map(e=>[e.id,e])),data:t.data??{},...t.theme?{theme:{...t.theme}}:{}}}function A5(e){return V8.find(t=>t===e)}function j5(e){if(e===`hug`||e===`fill`)return e;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.fixed;if(Object.keys(e).length===1&&typeof t==`number`&&t>=K8.min&&t<=K8.max)return{fixed:t}}}function M5(e,t){if(!Array.isArray(e)||e.length!==t||t===0)return;let n=e.map(j5);return n.every(e=>e!==void 0)?n:void 0}var N5=n((()=>{t5()}));function P5(e,t,n){let r=(0,K5.useContext)(Y5),i=(0,K5.useRef)(null);(0,K5.useSyncExternalStore)(r?.subscribe??X5.subscribe,r?.read??X5.read,X5.read),(0,K5.useEffect)(()=>{if(!r)return;let a=i.current;return r.set(e,{label:t,problem:n,element:a}),()=>r.remove(e,a)},[r,e,t,n]);let a=(0,K5.useCallback)(e=>{i.current=e},[]);return{shown:r?.shown.has(e)??!1,ref:a}}function F5(e){let t=(0,K5.useContext)(Y5);(0,K5.useSyncExternalStore)(t?.subscribe??X5.subscribe,t?.read??X5.read,X5.read);let n=(Array.isArray(e)?e.filter(e=>typeof e==`string`):[]).flatMap(e=>{let n=t?.fields.get(e);return n?.problem?[{id:e,label:n.label,problem:n.problem}]:[]});return{waiting:n,show:()=>{t&&n.length!==0&&(t.show(n.map(e=>e.id)),t.fields.get(n[0].id)?.element?.querySelector(`input, select, textarea`)?.focus())}}}function I5({render:e,args:t}){return e(t)}function L5(e){let{surfaceId:t,catalogId:n,sendDataModel:r,metadata:i}=e;return{version:`1.0`,createSurface:{surfaceId:t,catalogId:n,...r?{sendDataModel:r}:{},components:Object.values(e.components),dataModel:e.data,...i?{metadata:i}:{}}}}function R5({recorder:e,scope:t,held:n,surfaceKey:r,kind:i,children:a}){return(0,G5.jsxs)(AN,{scope:t,children:[(0,G5.jsx)(z5,{recorder:e,scope:t,held:n,surfaceKey:r,kind:i}),(0,G5.jsx)(B5,{recorder:e,surfaceKey:r,componentId:t.componentId}),a]})}function z5({recorder:e,scope:t,held:n,surfaceKey:r,kind:i}){return(0,K5.useEffect)(()=>{let a=n.places.get(t);return a!==void 0&&n.scopes.set(a,t),n.recorded.has(t)||(n.recorded.add(t),e.record({kind:`component`,name:`${i} "${t.componentId}"`,spanId:t.spanId,detail:{component:i}},{traceId:t.traceId,spanId:e.surfaceScope(r)?.spanId,surfaceId:t.surfaceId,componentId:t.componentId})),()=>{a!==void 0&&n.scopes.get(a)===t&&n.scopes.delete(a)}},[e,t,n,r,i]),null}function B5({recorder:e,surfaceKey:t,componentId:n}){let r=(0,K5.useSyncExternalStore)(e.onInspect,()=>{let r=e.inspected();return r!==void 0&&r.surfaceKey===t&&r.componentId===n?2:+!!e.picking()},()=>0);return r===0||n===void 0?null:(0,G5.jsx)(`template`,{[rN]:t,[iN]:n,...r===2?{[aN]:``}:{}})}function V5({surface:e,catalog:t,renderers:n,onAction:r,onProblem:i,onDataChange:a,onControlsChange:o,onContext:s,frame:c,resolveImage:l,className:u}){let d=(0,K5.useMemo)(()=>E5(e),[e]),f=IN(),p=(0,K5.useRef)(void 0),m=(0,K5.useRef)(void 0),h=f?.keyOf(e),g=f?h??`${p.current??=sN(`v`)}:${d.surfaceId}`:void 0,_=(0,K5.useRef)(``);(0,K5.useLayoutEffect)(()=>{if(!f||h!==void 0||g===void 0)return;let e=L5(d),t=JSON.stringify(GM(e));t!==_.current&&(_.current=t,nN(f,{format:`surface`,key:g,raw:e,snapshot:!0,name:`surface`},{traceId:m.current??=JM()}))},[f,h,g,d]);let v=(0,K5.useRef)({scopes:new Map,places:new WeakMap,recorded:new WeakSet}),y=(e,t,n)=>{if(!f||g===void 0)return;let r=`${g}|${t}|${e}|${n}`,i=v.current.scopes.get(r);if(!i){let t=h!==void 0,n;i={spanId:YM(),surfaceId:g,componentId:e,get traceId(){return n??=(t?f.surfaceScope(g)?.traceId:void 0)??(m.current??=JM())}},v.current.scopes.set(r,i),v.current.places.set(i,r)}return i},b=(0,K5.useRef)(new Map),x=(0,K5.useRef)([]),S=(e,t)=>f?.record({kind:`problem`,name:e.code,status:`error`,surfaceId:g,detail:{code:e.code,path:e.path,message:e.message}},t??(g===void 0?void 0:f.surfaceScope(g)));(0,K5.useEffect)(()=>{for(let{problem:e,scope:t}of x.current.splice(0))S(e,t)});let C=(e,t,n=!1)=>{f&&n?x.current.push({problem:e,scope:t}):S(e,t),i?.(e)},w=(0,K5.useRef)(o);w.current=o;let T=(0,K5.useRef)(s);T.current=s;let E=(0,K5.useMemo)(()=>{let e=new Map;for(let[t,n]of Object.entries(d.expects??{}))e.set(t,k8(n));return e},[d.expects]),[D,O]=(0,K5.useState)({surfaceId:d.surfaceId,values:[]}),k=D.surfaceId===d.surfaceId?D.values:[],ee=(0,K5.useMemo)(()=>k.reduce((e,[t,n])=>W6(e,t,n),d.data),[d.data,k]),te=(0,K5.useRef)(a);te.current=a;let A=(0,K5.useRef)(!1);(0,K5.useEffect)(()=>{A.current&&te.current?.(ee),A.current=!1},[ee]);let ne=(0,K5.useCallback)((e,t,n)=>{f?.record({kind:`state`,name:`data.write`,surfaceId:g,detail:{path:e,value:t}},n),A.current=!0,O(n=>{let r=n.surfaceId===d.surfaceId?n.values.filter(([t])=>t!==e&&!t.startsWith(`${e}/`)):[];return{surfaceId:d.surfaceId,values:[...r,[e,t]]}})},[d.surfaceId,f,g]),re=(0,K5.useMemo)(()=>Object.fromEntries(Object.entries(t.functions).map(([e,t])=>[e,t.implementation])),[t]),ie=(0,K5.useMemo)(()=>new Map,[t]),ae=(0,K5.useMemo)(()=>new J5,[]),oe=(e,i,a,o=ee)=>{if(typeof e!=`string`)return null;let s=Object.hasOwn(d.components,e)?d.components[e]:void 0;if(!s)return null;if(a.includes(e)||a.length>Z5)return(0,G5.jsx)(W5,{text:`"${e}" contains itself.`},e);let l=y(e,i,s.component),u=ie.get(s);if(!u){u=t.validateComponent(s),ie.set(s,u);for(let t of u)C({code:`VALIDATION_FAILED`,surfaceId:d.surfaceId,path:`/${e}${t.path}`,message:t.message},l,!0)}let p=Object.hasOwn(n,s.component)?n[s.component]:void 0;if(u.length>0||!p)return(0,G5.jsx)(W5,{text:u[0]?`${s.component} "${e}": ${u[0].path} ${u[0].message}`:`No renderer for ${s.component}.`},e);if(s.visibleWhen!==void 0&&!H6(s.visibleWhen,o,i))return null;let m={data:o,scope:i,functions:re},{id:h,component:_,action:x,child:S,children:D,visibleWhen:O,...k}=s,te=Object.fromEntries(Object.entries(k).filter(([e])=>!e.startsWith(`@`))),A=[...a,e],ae=(0,G5.jsx)(I5,{render:p,args:{props:K6(te,m),component:s,child:e=>oe(e,i,A,o),children:e=>{let t=e;if(Array.isArray(t))return t.map(e=>(0,G5.jsx)(U5,{children:oe(e,i,A,o)},e));if(t&&typeof t==`object`&&typeof t.componentId==`string`){let e=G6(t.path,i),n=U6(o,e);return Array.isArray(n)?n.map((n,r)=>(0,G5.jsx)(U5,{children:oe(t.componentId,`${e===`/`?``:e}/${r}`,A,o)},r)):[]}return[]},rows:(t,n)=>n.map((n,r)=>{let i=`/${Q5}/${e}/${r}`;return(0,G5.jsx)(U5,{children:oe(t,i,A,W6(o,i,n))},r)}),dispatch:(n,i)=>{let a=n;if(!a)return;if(`functionCall`in a){(Object.hasOwn(t.functions,a.functionCall[`@call`])?t.functions[a.functionCall[`@call`]]:void 0)?.action&&K6(a.functionCall,m);return}let o=t.components[s.component]?.events;if(o&&i){let t=new Set(Object.values(o).flatMap(e=>Object.keys(e.context??{})));for(let n of Object.keys(i))t.has(n)||C({code:`UNDECLARED_EVENT`,surfaceId:d.surfaceId,path:`/${e}`,message:`${s.component} sent "${n}", which its catalog entry does not declare.`},l);Object.values(o).some(e=>O8(e).safeParse(i).success)||C({code:`UNDECLARED_EVENT`,surfaceId:d.surfaceId,path:`/${e}`,message:`${s.component} sent values that do not match its catalog entry's event types.`},l)}let c=a.event.name,u=a.event.userMessage===void 0?void 0:K6(a.event.userMessage,m),p={...K6(a.event.context??{},m)??{},...i},h=E.get(c);if(h){let t=`error`in h?void 0:h.schema.safeParse(p);if(!t||!t.success){let n=t?t.error.issues.map(e=>`${e.path.join(`/`)||`context`}: ${e.message}`).join(`; `):`error`in h?h.error:``;f?.record({kind:`event`,name:c,status:`error`,detail:{type:`action`,context:p,contract:`failed`,reason:n,sent:!1}},l),C({code:`CONTRACT_FAILED`,surfaceId:d.surfaceId,path:`/${e}`,message:`"${c}" was not sent: it does not match what the agent expects. ${n}`},l);return}}f?.record({kind:`event`,name:c,status:r?`ok`:`warning`,detail:{type:`action`,context:p,contract:h?`passed`:`none`,sent:!!r,...typeof u==`string`&&u?{userMessage:u}:{}}},l),r?.({name:c,surfaceId:d.surfaceId,sourceComponentId:e,timestamp:new Date().toISOString(),context:p,...typeof u==`string`&&u?{userMessage:u}:{},...d.sendDataModel?{dataModel:ee}:{}})},setData:(e,t)=>{let n=typeof e==`string`?e:e&&typeof e==`object`&&typeof e[`@path`]==`string`?e[`@path`]:void 0;n!==void 0&&(n.startsWith(`/`)||!i.startsWith(`/${Q5}/`))&&ne(G6(n,i),t,l)},reportControls:t=>{if(f&&l){let n=`${i}|${e}`,r=b.current.get(n),a=JSON.stringify(GM(t));r!==a&&(b.current.set(n,a),f.record({kind:`state`,name:`controls`,detail:{controls:t,changed:wN(r===void 0?{}:JSON.parse(r),JSON.parse(a))}},l))}w.current?.(e,t)},reportContext:t=>{let n={kind:String(t.kind).slice(0,60),summary:String(t.summary).slice(0,400),...t.subject&&typeof t.subject==`object`?{subject:t.subject}:{}};f?.record({kind:`event`,name:`note: ${n.kind}`,detail:{type:`note`,...n,kept:!!T.current}},l),T.current?.(e,n)}}}),se=`${s.component} "${e}"`,ce=(0,G5.jsx)($5,{label:se,component:s,onError:t=>C({code:`RENDER_FAILED`,surfaceId:d.surfaceId,path:`/${e}`,message:`${se} could not be drawn: ${t.message}`},l),children:ae},f&&l?void 0:`${e}:${s.component}`),le=f&&l&&g!==void 0?(0,G5.jsx)(R5,{recorder:f,scope:l,held:v.current,surfaceKey:g,kind:s.component,children:ce},`${e}:${s.component}`):ce,ue=typeof s.minHeight==`number`&&s.minHeight>0?s.minHeight:void 0,de=ue?(0,G5.jsx)(`div`,{className:`sf-surface-sized`,style:{minHeight:ue},children:le}):le;return(0,G5.jsx)(U5,{children:c?c(s,de):de},e)},se=(0,G5.jsx)(`div`,{className:[`sf-surface`,`sf-container`,u].filter(Boolean).join(` `),"data-surface":d.surfaceId,children:(0,G5.jsx)(Y5.Provider,{value:ae,children:Object.hasOwn(d.components,`root`)?oe(`root`,`/`,[]):null})}),ce=d.theme?(0,G5.jsx)(H5,{request:d.theme,children:se}):se;return l?(0,G5.jsx)(yL,{resolve:l,children:ce}):ce}function H5({request:e,children:t}){let n=IM(),r=n?.theme??Xj,i=JSON.stringify(e),a=n?.themes,o=(0,K5.useMemo)(()=>wM(e,r,{themes:a}),[i,r,a]),s=o.mode??n?.mode??`system`;return(0,G5.jsxs)(FM,{scope:`scoped`,storage:null,initialTheme:o.theme,initialMode:s,children:[o.problems.map(e=>(0,G5.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:e},e)),t]},`${i}:${JSON.stringify(r)}:${s}`)}function U5({children:e}){let t=(0,K5.useContext)(q5);return(0,G5.jsx)(q5.Provider,{value:t+1,children:e})}function W5({text:e}){return(0,G5.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:e})}var G5,K5,q5,J5,Y5,X5,Z5,Q5,$5,e7=n((()=>{G5=HA(),K5=jM(),kN(),LN(),kM(),R8(),m8(),D5(),q5=(0,K5.createContext)(0),J5=class{fields=new Map;shown=new Set;version=0;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});read=()=>this.version;changed(){this.version++;for(let e of[...this.listeners])e()}set(e,t){let n=this.fields.get(e);this.fields.set(e,t),n&&n.problem===t.problem&&n.label===t.label||this.changed()}remove(e,t){this.fields.get(e)?.element===t&&(this.fields.delete(e),this.changed())}show(e){for(let t of e)this.shown.add(t);this.changed()}},Y5=(0,K5.createContext)(void 0),X5={subscribe:()=>()=>{},read:()=>0},Z5=48,Q5=`@rows`,$5=class extends K5.Component{state={};static getDerivedStateFromError(e){return{failed:e instanceof Error?e.message:String(e)}}static getDerivedStateFromProps(e,t){return t.of===e.component?null:{of:e.component,...t.of?{failed:void 0}:{}}}componentDidCatch(e){this.props.onError(e)}render(){return this.state.failed===void 0?this.props.children:(0,G5.jsx)(W5,{text:`${this.props.label} could not be drawn: ${this.state.failed}`})}}}));function t7(e,t){let n={},r=t.gap?A5(e.gap):void 0,i=t.padding?A5(e.padding):void 0;return r!==void 0&&(n[`data-gap`]=String(r)),i!==void 0&&(n[`data-padding`]=String(i)),n}var n7=n((()=>{N5()}));function r7({type:e,extra:t,props:n,component:r,setData:i}){let[a,o]=(0,c7.useState)(!1),s={name:r.id,label:l7(n.label),type:e,help:l7(n.help)||void 0,placeholder:l7(n.placeholder)||void 0,required:n.required===!0||void 0,...t?.(n)},c=s.type===`boolean`&&s.required&&n.value!==!0?`${s.label} is required.`:eC(UV(`field`,[{...s,name:`value`}]),{value:n.value??null}).errors[0]?.message,l=P5(r.id,s.label,c),u=a||l.shown?c:void 0;return(0,s7.jsx)(`div`,{className:`sf-a2-field`,ref:l.ref,onBlur:()=>o(!0),children:(0,s7.jsx)(WV,{field:s,value:n.value,error:u,onChange:e=>i(r.value,e)})})}function i7(e,t){return n=>(0,s7.jsx)(r7,{...n,type:e,extra:t})}function a7({props:e,component:t,setData:n}){let r=(0,c7.useId)(),i=u7(e.min)??0,a=u7(e.max)??100,o=u7(e.value)??i;return(0,s7.jsxs)(`div`,{className:`sf-form-field`,children:[(0,s7.jsxs)(`label`,{className:`sf-form-label`,htmlFor:r,children:[l7(e.label),`: `,(0,s7.jsx)(`output`,{htmlFor:r,children:o})]}),(0,s7.jsx)(`input`,{id:r,className:`sf-form-slider`,type:`range`,min:i,max:a,step:u7(e.step)??1,value:o,"aria-describedby":e.help?`${r}-help`:void 0,onChange:e=>n(t.value,Number(e.target.value))}),e.help!=null&&(0,s7.jsx)(`p`,{id:`${r}-help`,className:`sf-form-help`,children:l7(e.help)})]})}function o7({props:e,component:t,dispatch:n,setData:r}){let i=t.values!=null,a=l7(e.formId);return(0,s7.jsx)(GV,{formId:a,title:l7(e.title)||void 0,description:l7(e.description)||void 0,fields:e.fields??[],submitLabel:l7(e.submitLabel)||void 0,values:i?e.values&&typeof e.values==`object`?e.values:{}:void 0,onValuesChange:i?e=>r(t.values,e):void 0,onSubmit:e=>n(t.action,{formId:a,values:e.values,submissionId:e.submissionId??``})})}var s7,c7,l7,u7,d7,f7=n((()=>{s7=HA(),jG(),rw(),c7=jM(),e7(),l7=e=>e==null||typeof e==`object`?``:String(e),u7=e=>typeof e==`number`?e:void 0,d7={TextField:i7(`text`,e=>({type:e.multiline===!0?`longtext`:`text`,maxLength:u7(e.maxLength),pattern:l7(e.pattern)||void 0})),NumberField:i7(`number`,e=>({min:u7(e.min),max:u7(e.max),step:u7(e.step)})),ChoicePicker:i7(`choice`,e=>({options:Array.isArray(e.options)?e.options.map(l7):[]})),CheckBox:i7(`boolean`),DateTimeInput:i7(`date`,e=>({type:e.mode===`datetime`?`datetime`:`date`})),Slider:a7,Form:o7}}));function p7(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e,n={speaker:v7(t.speaker),text:v7(t.text)};return t.side===`end`&&(n.side=`end`),v7(t.time)!==``&&(n.time=v7(t.time)),[n]}):[]}function m7(e,t){let n=e=>`${e.side===`end`?`end`:`start`}\u0000${e.speaker}\u0000${e.text}`,r=new Map;for(let t of e)r.set(n(t),(r.get(n(t))??0)+1);return t.filter(e=>{let t=r.get(n(e))??0;return t===0||(r.set(n(e),t-1),!1)})}function h7({props:e,component:t,dispatch:n}){let r=p7(e.messages),[i,a]=(0,_7.useState)([]),o=[...r,...m7(r,i)],s=v7(e.you)||`You`,c=Array.isArray(e.replies)?p7(e.replies):[],[l,u]=(0,_7.useState)(0),[d,f]=(0,_7.useState)(``),[p,m]=(0,_7.useState)(),h=(0,_7.useRef)(null),g=(0,_7.useRef)(void 0),_=(0,_7.useId)();(0,_7.useEffect)(()=>()=>clearTimeout(g.current),[]),(0,_7.useEffect)(()=>{let e=h.current;e&&(e.scrollTop=e.scrollHeight)},[o.length,p]);let v=e=>a(t=>[...t,e]),y=e=>{let r=e.trim();if(r===``)return;v({speaker:s,text:r,side:`end`,time:y7()}),f(``);let i=c[l];u(e=>e+1),n(t.action,{text:r}),i&&(m(i.speaker),clearTimeout(g.current),g.current=setTimeout(()=>{m(void 0),v({...i,side:`start`,time:y7()})},700))},b=e=>{e.preventDefault(),y(d)},x=e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),y(d))},S=l===0&&Array.isArray(e.suggestions)?e.suggestions.map(v7).filter(e=>e!==``):[],C=v7(e.label)||`Conversation`;return(0,g7.jsxs)(`section`,{className:`sf-a2-conversation`,"aria-label":C,children:[(0,g7.jsxs)(`div`,{ref:h,className:`sf-a2-conversation-thread`,role:`log`,"aria-live":`polite`,tabIndex:0,"aria-label":`${C}: messages`,children:[o.map((e,t)=>(0,g7.jsxs)(`div`,{className:`sf-a2-message`,"data-side":e.side===`end`?`end`:`start`,children:[(0,g7.jsxs)(`p`,{className:`sf-a2-message-who`,children:[(0,g7.jsx)(`b`,{children:e.speaker}),e.time&&(0,g7.jsx)(`span`,{children:e.time})]}),(0,g7.jsx)(`div`,{className:`sf-a2-message-body`,children:(0,g7.jsx)(PL,{text:e.text})})]},t)),p!==void 0&&(0,g7.jsxs)(`p`,{className:`sf-a2-conversation-waiting`,children:[p,` is writing…`]})]}),S.length>0&&(0,g7.jsx)(`div`,{className:`sf-a2-chips`,role:`group`,"aria-label":`Suggested replies`,children:S.map(e=>(0,g7.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>y(e),children:e},e))}),(0,g7.jsxs)(`form`,{className:`sf-a2-conversation-composer`,onSubmit:b,children:[(0,g7.jsx)(`label`,{className:`sf-visually-hidden`,htmlFor:_,children:`Message`}),(0,g7.jsx)(`textarea`,{id:_,className:`sf-input`,rows:1,value:d,placeholder:v7(e.placeholder)||`Write a message`,onChange:e=>f(e.target.value),onKeyDown:x}),(0,g7.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:d.trim()===``,children:`Send`})]})]})}var g7,_7,v7,y7,b7=n((()=>{g7=HA(),jG(),_7=jM(),v7=e=>e==null||typeof e==`object`?``:String(e),y7=()=>new Date().toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}));function x7({name:e,draw:t}){let n=typeof e==`string`&&e?e:void 0,r=UW(n);return n?r.model?(0,Q.jsx)(Q.Fragment,{children:t(r)}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:r.problem??`Loading the semantic model “${n}”…`}):(0,Q.jsx)(Q.Fragment,{children:t(void 0)})}function S7({props:e,component:t,dispatch:n,reportControls:r,reportContext:i}){let a=e.proposed&&typeof e.proposed==`object`?e.proposed:void 0,o=e.create&&typeof e.create==`object`?e.create:void 0,s=$(e.proposedBy)||`the agent`,c=typeof e.model==`string`?e.model:``,l=UW(c||void 0),u=JSON.stringify([a??null,o??null]),d={proposal:a,by:s,component:t,dispatch:n,reportControls:r,reportContext:i};if(l.model)return(0,Q.jsx)(C7,{state:l,model:l.model,...d},`${u}:${l.model.version}`);if(o&&l.missing){let e=qU({name:c,label:o.label??``,description:o.description??``,sourceId:o.sourceId??``});return(0,Q.jsx)(C7,{state:l,model:e,...d},u)}return(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:l.problem??`Loading the semantic model “${c}”…`})}function C7({state:e,model:t,proposal:n,by:r,component:i,dispatch:a,reportControls:o,reportContext:s}){let c=t.version===0,[l,u]=(0,R7.useState)(()=>{if(!n)return c?t:void 0;let e=_G(t,n,r);return c||KU(t,e).size>0?e:void 0}),d=e=>o({proposed:e?vG(t,e):null}),f=i.action==null?void 0:e=>a(i.action,{text:e});return(0,Q.jsx)(cG,{model:t,draft:l,proposedBy:l&&n?r:void 0,problem:e.problem&&!e.missing?e.problem:void 0,building:c&&!n?.rows,onDraftChange:e=>{u(e),d(e)},onAsk:f,onSave:async(n,r)=>{let o=Object.fromEntries(KU(t,n)),s=await e.save(n,r);return s&&i.action!=null&&a(i.action,{model:s.name,version:s.version,changes:o}),s},onContext:s})}function w7({component:e,dispatch:t,setData:n}){return(r,i={})=>{r&&(e.opened!=null&&n(e.opened,r),t(e.action,{table:r,...i}))}}function T7({props:e,component:t,dispatch:n,reportControls:r,reportContext:i}){let a={...typeof e.title==`string`&&e.title?{title:e.title}:{},fields:Array.isArray(e.fields)?e.fields.map(e=>e.by?e:{...e,by:`the agent`}):[],filters:Array.isArray(e.filters)?e.filters:[],tiles:Array.isArray(e.tiles)?e.tiles:[],...e.draft&&typeof e.draft==`object`?{draft:e.draft}:{}},o=JSON.stringify(a),[s,c]=(0,R7.useState)(a);return(0,R7.useEffect)(()=>c(a),[o]),(0,Q.jsx)(x7,{name:e.model,draw:a=>(0,Q.jsx)(LW,{sourceId:$(e.sourceId)||void 0,sql:$(e.sql)||void 0,model:a?.model,onPromote:a?.promote,value:s,mode:e.mode===`build`||e.mode===`view`?e.mode:void 0,onContext:i,onChange:e=>{c(e),r({title:e.title??null,fields:e.fields,filters:e.filters,tiles:e.tiles,...e.draft?{draft:e.draft}:{}})},onAsk:t.action==null?void 0:e=>n(t.action,{text:e})})})}function E7({props:e,component:t,dispatch:n,reportControls:r,reportContext:i}){let a={fields:Array.isArray(e.fields)?e.fields.map(e=>e.by?e:{...e,by:`the agent`}):[],rows:Array.isArray(e.rows)?e.rows:[],...typeof e.split==`string`&&e.split?{split:e.split}:{},values:Array.isArray(e.values)?e.values:[],filters:Array.isArray(e.filters)?e.filters:[],...e.view===`chart`||e.view===`table`?{view:e.view}:{},...e.chart&&typeof e.chart==`object`?{chart:e.chart}:{}},o=JSON.stringify(a),[s,c]=(0,R7.useState)(a);return(0,R7.useEffect)(()=>c(a),[o]),(0,Q.jsx)(x7,{name:e.model,draw:a=>(0,Q.jsx)(dW,{sourceId:$(e.sourceId)||void 0,sql:$(e.sql)||void 0,model:a?.model,onPromote:a?.promote,value:s,onChange:e=>{c(e),r({fields:e.fields,rows:e.rows,split:e.split??null,values:e.values,filters:e.filters,...e.view?{view:e.view}:{},chart:e.chart??null})},onContext:i,onAsk:t.action==null?void 0:e=>n(t.action,{text:e})})})}function D7({props:e,child:t,reportControls:n}){let r=(e.panels??[]).map(e=>({id:e.id,title:$(e.title)||e.id,...e.short?{shortTitle:$(e.short)}:{},...e.icon?{icon:e.icon}:{},content:t(e.child)})),i=JSON.stringify(e.layout??null),[a,o]=(0,R7.useState)(e.layout),s=(0,R7.useRef)(i);return(0,R7.useEffect)(()=>{s.current!==i&&(s.current=i,o(e.layout))},[i,e.layout]),(0,Q.jsx)(yH,{label:$(e.label)||`Panels`,panels:r,layout:a,rail:e.rail===`none`?!1:e.rail===`left`?`left`:`right`,defaultRailLabels:e.railLabels===!0,height:typeof e.height==`number`?e.height:520,onLayoutChange:e=>{o(e),n({layout:e})}})}function O7({children:e}){return TF()?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:`This needs a discovery backend: wrap the page in DiscoveryProvider.`})}function k7({props:e,component:t,dispatch:n}){let r=e.options??[],[i,a]=(0,R7.useState)();return(0,Q.jsxs)(`section`,{className:`sf-a2-decision`,"aria-label":$(e.title),children:[(0,Q.jsx)(`p`,{className:`sf-a2-decision-title`,children:$(e.title)}),e.detail!=null&&(0,Q.jsx)(`p`,{className:`sf-a2-decision-detail`,children:$(e.detail)}),(0,Q.jsx)(`div`,{className:`sf-a2-decision-options`,children:r.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:`sf-a2-decision-option`,"aria-pressed":i===e.id,disabled:i!==void 0,onClick:()=>{a(e.id),n(t.action,{choice:e.id,label:e.label})},children:[(0,Q.jsxs)(`span`,{className:`sf-a2-decision-label`,children:[e.label,e.recommended&&(0,Q.jsx)(`span`,{className:`sf-schema-tag`,children:`Recommended`})]}),e.description&&(0,Q.jsx)(`span`,{className:`sf-a2-decision-description`,children:e.description})]},e.id))}),i!==void 0&&(0,Q.jsxs)(`p`,{className:`sf-a2-decision-detail`,role:`status`,children:[`You chose `,r.find(e=>e.id===i)?.label,`.`]})]})}function A7({props:e,component:t,dispatch:n}){let r=$(e.sql),[i,a]=(0,R7.useState)();return(0,Q.jsxs)(`section`,{className:`sf-a2-proposal`,"aria-label":$(e.title)||`Proposed SQL`,children:[e.title!=null&&(0,Q.jsx)(`p`,{className:`sf-a2-decision-title`,children:$(e.title)}),(0,Q.jsx)(NL,{code:r,language:`sql`,onRun:e=>{a(new Date().toISOString()),n(t.action,{sql:e})}}),i?(0,Q.jsx)(HL,{sourceId:$(e.sourceId),sql:r,notBefore:i,height:320}):(0,Q.jsx)(`p`,{className:`sf-a2-decision-detail`,children:`Proposed by the agent. It has not been run.`})]})}function j7({props:e,component:t,dispatch:n}){let[r,i]=(0,R7.useState)($(e.sql)),a=e=>n(t.action,{sql:e});return(0,Q.jsxs)(`div`,{className:`sf-a2-editor`,children:[(0,Q.jsx)(yF,{value:r,onChange:i,onRun:a,dialect:$(e.dialect)||`standard`,minHeight:100}),t.action!=null&&(0,Q.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,onClick:()=>a(r),children:`Run`})]})}function M7({props:e}){let[t,n]=(0,R7.useState)(()=>(e.tables??[]).reduce((e,t)=>fR(e,t.sourceId,t.table),{..._R,name:$(e.name)}));return(0,Q.jsx)(mR,{value:t,onChange:n})}function N7({children:e}){return OB()?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:`This needs a pipeline backend: wrap the page in PipelinesProvider.`})}function P7({props:e}){let[t,n]=(0,R7.useState)({...YB,location:$(e.location),format:$(e.format)||`parquet`});return(0,Q.jsx)(KB,{sourceId:$(e.sourceId),value:t,onChange:n})}function F7({props:e,component:t,dispatch:n,reportContext:r}){let i=JSON.stringify(e.pipeline??null),[a,o]=(0,R7.useState)({});return(0,R7.useEffect)(()=>{try{o({draft:ib(Zx,JSON.parse(i),{ignoreUnknownFields:!1})})}catch(e){o({problem:`The proposed pipeline could not be read: ${e instanceof Error?e.message:String(e)}`})}},[i]),a.problem?(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:a.problem}):a.draft?(0,Q.jsx)(CB,{pipeline:a.draft,dataset:$(e.dataset),expectedVersion:typeof e.expectedVersion==`number`?e.expectedVersion:0,digest:$(e.digest)||void 0,proposedBy:$(e.proposedBy)||void 0,onDecide:e=>n(t.action,{...e}),onContext:r}):null}function I7({props:e,action:t,dispatch:n}){let[r,i]=(0,R7.useState)();return(0,Q.jsx)(Qz,{nodes:e.nodes??[],edges:e.edges??[],height:typeof e.height==`number`?e.height:320,selected:r,onSelect:e=>{i(e.id),n(t,{id:e.id,name:e.name})}})}function L7({props:e}){let t=IM(),n=JSON.stringify(e),[r,i]=(0,R7.useState)(),[a,o]=(0,R7.useState)(),s=(0,R7.useRef)(t);return s.current=t,(0,R7.useEffect)(()=>{let t=s.current;if(!t)return;let{id:n,component:r,...a}=e,c=wM(a,t.theme,{themes:t.themes});i({theme:t.theme,mode:t.mode}),t.setTheme(c.theme),c.mode&&t.setMode(c.mode),o({text:`The page now uses ${c.theme.name}${c.mode?`, ${c.mode}`:``}.`,problems:c.problems})},[n]),t?(0,Q.jsxs)(`div`,{className:`sf-a2-theme-switch`,role:`status`,children:[(0,Q.jsx)(`span`,{children:a?.text??`Changing the theme…`}),a?.problems.map(e=>(0,Q.jsx)(`span`,{className:`sf-object-muted`,children:e},e)),r&&(0,Q.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{t.setTheme(r.theme),t.setMode(r.mode),i(void 0),o({text:`Theme change undone.`,problems:[]})},children:`Undo`})]}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:`The theme cannot be changed here: this page has no ThemeProvider.`})}var Q,R7,$,z7,B7,V7,H7=n((()=>{Q=HA(),jG(),zb(),vS(),kM(),R7=jM(),D8(),n9(),b7(),n7(),$=e=>e==null||typeof e==`object`?``:String(e),z7=e=>e.map(e=>({column:e.column,direction:e.desc===!0?ax.DESC:ax.ASC})),B7=new Set([`start`,`center`,`end`,`stretch`]),V7={Grid:({props:e,component:t,children:n})=>{let r=typeof e.columns==`number`?e.columns:2,i=Array.isArray(e.widths)&&e.widths.length===r&&e.widths.every(e=>typeof e==`number`&&e>0)?e.widths:void 0,a=typeof e.align==`string`&&B7.has(e.align)?e.align:void 0;return(0,Q.jsx)(`div`,{className:`sf-a2-grid`,"data-align":a,"data-arrange-container":!0,"data-widths":i?!0:void 0,...t7(e,{gap:!0}),style:{"--sf-grid-columns":r,...a?{alignItems:a}:{},...i?{"--sf-grid-template":i.map(e=>`minmax(0, ${e}fr)`).join(` `)}:{}},children:n(t.children)})},Metric:({props:e})=>U7(e.filters,t=>(0,Q.jsx)(Hz,{filters:t,sourceId:$(e.sourceId),sql:$(e.sql),column:$(e.column)||void 0,aggregate:e.aggregate,percentile:typeof e.percentile==`number`?e.percentile:void 0,label:$(e.label),format:$(e.format)||void 0,currency:$(e.currency)||void 0,emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),Message:({props:e})=>(0,Q.jsxs)(`div`,{className:`sf-a2-message`,"data-side":e.side===`end`?`end`:`start`,children:[(0,Q.jsxs)(`p`,{className:`sf-a2-message-who`,children:[(0,Q.jsx)(`b`,{children:$(e.speaker)}),e.time!=null&&$(e.time)!==``&&(0,Q.jsx)(`span`,{children:$(e.time)})]}),(0,Q.jsx)(`div`,{className:`sf-a2-message-body`,children:(0,Q.jsx)(PL,{text:$(e.text)})})]}),Conversation:e=>(0,Q.jsx)(h7,{...e}),RowList:({props:e,component:t,rows:n,reportContext:r})=>U7(e.filters,i=>(0,Q.jsx)(Kz,{sourceId:$(e.sourceId),sql:$(e.sql),label:$(e.label)||`Rows`,filters:i,sorts:Array.isArray(e.sorts)?z7(e.sorts):void 0,pageSize:typeof e.pageSize==`number`?e.pageSize:void 0,rowKey:$(e.rowKey)||void 0,layout:e.layout===`grid`?`grid`:`list`,onContext:r,renderRow:(e,r)=>n(t.child,[e]).map(e=>(0,Q.jsx)(R7.Fragment,{children:e},r)),emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),Markdown:({props:e})=>(0,Q.jsx)(PL,{text:$(e.text)}),Image:({props:e})=>(0,Q.jsx)(CL,{src:$(e.src),alt:$(e.alt),caption:$(e.caption)||void 0,width:typeof e.width==`number`?e.width:void 0,height:typeof e.height==`number`?e.height:void 0,fit:e.fit===`cover`?`cover`:`contain`,maxHeight:typeof e.maxHeight==`number`?e.maxHeight:void 0}),CodeBlock:({props:e})=>(0,Q.jsx)(NL,{code:$(e.code),language:$(e.language)||void 0}),Table:({props:e})=>{let t=e.columns??[],n=e.rows??[];return(0,Q.jsx)(`div`,{className:`sf-markdown-table sf-a2-table`,children:(0,Q.jsxs)(`table`,{children:[e.caption!=null&&(0,Q.jsx)(`caption`,{children:$(e.caption)}),(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{children:t.map((e,t)=>(0,Q.jsx)(`th`,{scope:`col`,children:$(e)},t))})}),(0,Q.jsx)(`tbody`,{children:n.map((e,n)=>(0,Q.jsx)(`tr`,{children:t.map((t,n)=>(0,Q.jsx)(`td`,{"data-numeric":typeof e[n]==`number`||void 0,children:$(e[n])},n))},n))})]})})},Link:({props:e})=>{let t=w8(e.url);return t?(0,Q.jsx)(`a`,{className:`sf-a2-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:$(e.text)}):(0,Q.jsx)(`span`,{children:$(e.text)})},Checklist:({props:e})=>(0,Q.jsx)(`ul`,{className:`sf-a2-checklist`,children:(e.items??[]).map((e,t)=>(0,Q.jsxs)(`li`,{"data-done":e.done||void 0,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:e.done?`✓`:`○`}),(0,Q.jsxs)(`span`,{children:[$(e.label),(0,Q.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:e.done?` (done)`:` (to do)`})]})]},t))}),Chips:({props:e,component:t,dispatch:n,setData:r})=>{let i=(e.items??[]).map(e=>typeof e==`string`?{label:e,value:e}:e),a=t.selected!=null;return(0,Q.jsx)(`div`,{className:`sf-a2-chips`,role:a?`group`:void 0,children:i.map(i=>(0,Q.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-pressed":a?e.selected===i.value:void 0,onClick:()=>{a&&r(t.selected,i.value),n(t.action,{value:i.value})},children:i.label},`${i.label}\u0000${i.value}`))})},Workspace:e=>(0,Q.jsx)(D7,{...e}),SideNav:({props:e,component:t,dispatch:n})=>{let r=(e.groups??[]).map(e=>({...e.label?{label:e.label}:{},items:(e.items??[]).map(e=>({id:e.id,label:e.label,...e.href&&w8(e.href)?{href:w8(e.href)}:{}}))}));return(0,Q.jsx)(jH,{className:`sf-a2-sidenav`,label:$(e.label)||`Sections`,groups:r,current:$(e.current)||void 0,defaultPinned:e.pinned!==!1,onSelect:e=>{r.some(t=>t.items.some(t=>t.id===e&&t.href))||n(t.action,{id:e})}})},DecisionCard:e=>(0,Q.jsx)(k7,{...e}),SqlProposal:e=>(0,Q.jsx)(A7,{...e}),SqlEditor:e=>(0,Q.jsx)(j7,{...e}),ObjectBrowser:e=>{let t=w7(e);return(0,Q.jsx)(ZF,{sourceId:$(e.props.sourceId),height:typeof e.props.height==`number`?e.props.height:360,onSelect:e=>(e.kind===`table`||e.kind===`column`||e.kind===`join`)&&t(e.table??``,{column:e.column??``})})},Explorer:e=>(0,Q.jsx)(E7,{...e}),SemanticModelEditor:e=>(0,Q.jsx)(S7,{...e}),ReportBuilder:e=>(0,Q.jsx)(T7,{...e}),FilterBar:({props:e,component:t,setData:n,dispatch:r,reportControls:i,reportContext:a})=>(0,Q.jsx)(sU,{sourceId:$(e.sourceId),sql:$(e.sql),filters:Array.isArray(e.filters)?e.filters:[],columns:Array.isArray(e.columns)?e.columns:void 0,onContext:a,onChange:e=>{n(t.filters,e),i({filters:e}),t.action!=null&&r(t.action,{filters:e})}}),FileBrowser:({props:e,component:t,dispatch:n,reportContext:r})=>(0,Q.jsx)(tU,{sourceId:$(e.sourceId)||void 0,local:e.local===!0,onContext:r,height:typeof e.height==`number`?e.height:360,onOpen:t.action==null?void 0:(e,r)=>n(t.action,{path:e.path,name:e.name,place:r.id,format:e.format??``})}),ModelDiagram:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(_z,{sourceId:$(e.sourceId),tables:e.tables??[],joins:e.joins??[],rowsFrom:e.rowsFrom===!0,suggestJoins:e.suggest!==!1,height:typeof e.height==`number`?e.height:360,onUseSql:t.action==null?void 0:(e,r)=>n(t.action,{sql:e,tables:r.tables,joins:r.joins})}),DataSearch:e=>{let t=w7(e);return(0,Q.jsx)(O7,{children:(0,Q.jsx)(tR,{sourceIds:$(e.props.sourceId)?[$(e.props.sourceId)]:void 0,height:typeof e.props.height==`number`?e.props.height:void 0,onOpen:e=>t(e.ref?.table??``,{column:e.ref?.column??``})})})},ObjectDetail:e=>{let t=w7(e),n=$(e.props.table);return(0,Q.jsx)(O7,{children:n?(0,Q.jsx)(cR,{objectRef:OF($(e.props.sourceId),n),onOpen:e=>t(e.ref?.table??``)},n):(0,Q.jsx)(`p`,{className:`sf-search-empty`,children:`Open a table to see what is known about it.`})})},RelationshipGraph:e=>{let t=w7(e),n=$(e.props.table);return(0,Q.jsx)(O7,{children:n?(0,Q.jsx)(bR,{objectRef:OF($(e.props.sourceId),n),onOpen:e=>t(e.ref?.table??``)},n):null})},NodeGraph:({props:e,component:t,dispatch:n,setData:r,reportContext:i})=>{let a=e.levels!==null&&typeof e.levels==`object`?e.levels:void 0;return(0,Q.jsx)(PR,{label:$(e.label),nodes:Array.isArray(e.nodes)?e.nodes:[],links:Array.isArray(e.links)?e.links:[],...$(e.selected)?{selected:$(e.selected)}:{},...Array.isArray(e.groups)?{groups:e.groups}:{},...a?{levels:a}:{},...$(e.noun)?{noun:$(e.noun)}:{},...typeof e.height==`number`?{height:e.height}:{},onSelect:e=>{t.selected!==null&&typeof t.selected==`object`&&r(t.selected,e),t.action!=null&&n(t.action,{node:e})},onContext:i})},AskData:({props:e})=>(0,Q.jsx)(O7,{children:(0,Q.jsx)(zR,{sourceIds:$(e.sourceId)?[$(e.sourceId)]:void 0,contextPackId:$(e.contextPackId)||void 0})}),Sparkline:({props:e})=>U7(e.filters,t=>(0,Q.jsx)(aV,{filters:t,sourceId:$(e.sourceId),sql:$(e.sql),x:$(e.x),grain:e.grain,column:$(e.column)||void 0,aggregate:e.aggregate,label:$(e.label),format:$(e.format)||void 0,currency:$(e.currency)||void 0,points:typeof e.points==`number`?e.points:void 0,emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),BulletGraph:({props:e})=>U7(e.filters,t=>(0,Q.jsx)(fV,{filters:t,sourceId:$(e.sourceId),sql:$(e.sql),column:$(e.column)||void 0,aggregate:e.aggregate,label:$(e.label),target:typeof e.target==`number`?e.target:void 0,ranges:e.ranges??[],format:$(e.format)||void 0,currency:$(e.currency)||void 0,emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),StepFlow:({props:e})=>(0,Q.jsx)(MV,{label:$(e.label),steps:e.steps??[]}),PlanReview:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(hV,{title:$(e.title),summary:$(e.summary)||void 0,proposedBy:$(e.proposedBy)||void 0,steps:e.steps??[],onDecide:e=>n(t.action,{...e})}),ActionReceipt:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(IV,{title:$(e.title),outcome:$(e.outcome)||`done`,summary:$(e.summary)||void 0,ranAt:$(e.ranAt)||void 0,ranBy:$(e.ranBy)||void 0,approvedBy:e.approvedBy??[],sql:$(e.sql)||void 0,changes:e.changes??[],undo:e.undo,onUndo:t.action?()=>n(t.action,{}):void 0}),PiiReview:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(EV,{table:$(e.table),purpose:$(e.purpose)||void 0,columns:e.columns??[],onDecide:e=>n(t.action,{...e})}),ThemeSwitch:({props:e})=>(0,Q.jsx)(L7,{props:e}),QueryPlan:({props:e})=>(0,Q.jsx)(YI,{sourceId:$(e.sourceId),sql:$(e.sql)}),SourceList:()=>(0,Q.jsx)(Pz,{}),PipelineGraph:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(I7,{props:e,action:t.action,dispatch:n}),PipelineView:({props:e,component:t,dispatch:n,reportContext:r})=>(0,Q.jsx)(N7,{children:(0,Q.jsx)(FB,{pipelineId:$(e.pipelineId),onRun:t.action==null?void 0:({kind:e,...r})=>n(t.action,{...r,event:e}),onContext:r})}),DatasetReview:e=>(0,Q.jsx)(F7,{...e}),IngestWizard:({props:e})=>(0,Q.jsx)(N7,{children:(0,Q.jsx)(P7,{props:e})}),RunHistory:({props:e})=>(0,Q.jsx)(eB,{runs:e.runs??[]}),ExpectationsPanel:({props:e})=>(0,Q.jsx)(tB,{expectations:e.expectations??[]}),SchemaDiff:({props:e})=>(0,Q.jsx)(rB,{changes:e.changes??[],rescuedCount:typeof e.rescuedCount==`number`?e.rescuedCount:void 0,mode:$(e.mode)||void 0}),StreamMetrics:({props:e})=>(0,Q.jsx)(aB,{progress:e.progress??[]}),ContextBuilder:e=>(0,Q.jsx)(O7,{children:(0,Q.jsx)(M7,{...e})})}}));function U7(e,t){if(!Array.isArray(e))return t(void 0);try{return t(LC(e))}catch(e){return(0,Y7.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:e instanceof Error?e.message:`The filters could not be read.`})}}function W7(e,t){let[n,r]=(0,X7.useState)(e??t),i=JSON.stringify(e??null);return(0,X7.useEffect)(()=>{e!==void 0&&r(e)},[i]),[n,r]}function G7({props:e,filters:t,reportControls:n}){let[r,i]=W7(Array.isArray(e.sorts)?RC(e.sorts):void 0,[]),[a,o]=W7(e.columns,{});return(0,Y7.jsx)(xP,{sourceId:Z7(e.sourceId),sql:Z7(e.sql),mode:e.mode===`pages`?`pages`:`scroll`,height:typeof e.height==`number`?e.height:360,label:Z7(e.label)||void 0,filters:t,sorts:r,onSortsChange:e=>{i(e),n({sorts:HC(e),columns:a})},columns:a,onColumnsChange:e=>{o(e),n({sorts:HC(r),columns:e})},emptyMessage:Z7(e.emptyMessage)||void 0,errorMessage:Z7(e.errorMessage)||void 0})}function K7(e){return{justifyContent:Q7[Z7(e.justify)]??`flex-start`,alignItems:$7[Z7(e.align)]??`stretch`}}function q7({props:e,component:t,child:n,dispatch:r}){let i=F5(e.requires),[a,o]=(0,X7.useState)(!1),s=i.waiting.length>0;return(0,Y7.jsxs)(Y7.Fragment,{children:[(0,Y7.jsx)(`button`,{type:`button`,className:`sf-button sf-a2-button`,"data-variant":Z7(e.variant)||`default`,"aria-disabled":s||void 0,onClick:()=>{s?(o(!0),i.show()):r(t.action)},children:n(t.child)}),s&&a&&(0,Y7.jsx)(`span`,{className:`sf-visually-hidden`,role:`status`,children:i.waiting.length===1?`Nothing was sent. ${i.waiting[0].problem}`:`Nothing was sent. ${i.waiting.length} fields need attention: ${i.waiting.map(e=>e.label).join(`, `)}.`})]})}function J7({props:e,child:t}){let n=e.tabs??[],[r,i]=(0,X7.useState)(0),a=(0,X7.useId)(),o=Math.min(r,n.length-1);return(0,Y7.jsxs)(`div`,{className:`sf-a2-tabs`,children:[(0,Y7.jsx)(`div`,{className:`sf-segmented sf-a2-tablist`,role:`tablist`,children:n.map((e,t)=>(0,Y7.jsx)(`button`,{type:`button`,role:`tab`,id:`${a}-tab-${t}`,"aria-selected":t===o,"aria-controls":`${a}-panel`,className:`sf-segment`,"data-checked":t===o||void 0,onClick:()=>i(t),children:Z7(e.title)},t))}),(0,Y7.jsx)(`div`,{role:`tabpanel`,id:`${a}-panel`,"aria-labelledby":`${a}-tab-${o}`,children:t(n[o]?.child)})]})}var Y7,X7,Z7,Q7,$7,e9,t9,n9=n((()=>{Y7=HA(),jG(),X7=jM(),t5(),N5(),n7(),e7(),f7(),H7(),Z7=e=>e==null||typeof e==`object`?``:String(e),Q7={start:`flex-start`,center:`center`,end:`flex-end`,spaceBetween:`space-between`,spaceAround:`space-around`,spaceEvenly:`space-evenly`,stretch:`stretch`},$7={start:`flex-start`,center:`center`,end:`flex-end`,stretch:`stretch`},e9={h1:`h2`,h2:`h3`,h3:`h4`,h4:`h5`,h5:`h6`,body:`p`,caption:`p`},t9={Text:({props:e})=>{let t=Z7(e.variant)||`body`;return(0,X7.createElement)(e9[t]??`p`,{className:`sf-a2-text`,"data-variant":t},Z7(e.text))},Row:({props:e,component:t,children:n})=>{let r=n(t.children),i=M5(e.sizes,r.length),a=!i&&Array.isArray(e.widths)&&e.widths.length===r.length&&e.widths.every(e=>typeof e==`number`&&e>0)?e.widths:void 0;return(0,Y7.jsx)(`div`,{className:`sf-a2-row`,"data-arrange-container":!0,style:K7(e),"data-widths":a?!0:void 0,"data-sizes":i?!0:void 0,...t7(e,{gap:!0,padding:!0}),"data-wrap":e.wrap===!1?`false`:void 0,children:i?r.map((e,t)=>{let n=i[t];return(0,Y7.jsx)(`div`,{className:`sf-a2-row-cell`,"data-size":typeof n==`string`?n:`fixed`,style:typeof n==`string`?void 0:{"--sf-row-cell-size":`${n.fixed}px`},children:e},t)}):a?r.map((e,t)=>(0,Y7.jsx)(`div`,{className:`sf-a2-row-cell`,style:{flex:`${a[t]} 1 0`},children:e},t)):r})},Column:({props:e,component:t,children:n})=>(0,Y7.jsx)(`div`,{className:`sf-a2-column`,style:K7(e),...t7(e,{gap:!0,padding:!0}),children:n(t.children)}),Card:({props:e,component:t,child:n})=>(0,Y7.jsx)(`div`,{className:`sf-a2-card`,...t7(e,{padding:!0}),children:n(t.child)}),Divider:({props:e})=>(0,Y7.jsx)(`hr`,{className:`sf-a2-divider`,"data-axis":Z7(e.axis)||`horizontal`}),Tabs:e=>(0,Y7.jsx)(J7,{...e}),Button:e=>(0,Y7.jsx)(q7,{...e}),Stat:({props:e})=>(0,Y7.jsxs)(`div`,{className:`sf-a2-stat`,children:[(0,Y7.jsx)(`span`,{className:`sf-a2-stat-label`,children:Z7(e.label)}),(0,Y7.jsx)(`span`,{className:`sf-a2-stat-value`,children:Z7(e.value)}),e.delta!=null&&(0,Y7.jsx)(`span`,{className:`sf-a2-stat-delta`,"data-tone":Z7(e.tone)||`neutral`,children:Z7(e.delta)})]}),KeyValue:({props:e})=>(0,Y7.jsx)(`dl`,{className:`sf-a2-keyvalue`,children:(e.items??[]).map((e,t)=>(0,Y7.jsxs)(`div`,{children:[(0,Y7.jsx)(`dt`,{children:Z7(e.label)}),(0,Y7.jsx)(`dd`,{children:Z7(e.value)})]},t))}),Badge:({props:e})=>(0,Y7.jsx)(`span`,{className:`sf-a2-badge`,"data-tone":Z7(e.tone)||`neutral`,children:Z7(e.text)}),Progress:({props:e})=>{let t=Number(e.max??100)||100,n=Math.max(0,Math.min(t,Number(e.value)||0));return(0,Y7.jsxs)(`div`,{className:`sf-a2-progress`,children:[e.label!=null&&(0,Y7.jsx)(`span`,{children:Z7(e.label)}),(0,Y7.jsx)(`progress`,{value:n,max:t,"aria-label":Z7(e.label)||`Progress`}),(0,Y7.jsxs)(`span`,{className:`sf-a2-progress-value`,children:[Math.round(n/t*100),`%`]})]})},DataGrid:({props:e,reportControls:t})=>U7(e.filters,n=>(0,Y7.jsx)(G7,{props:e,filters:n,reportControls:t})),Chart:({props:e,component:t,setData:n,dispatch:r,reportContext:i})=>{let a=Z7(e.x),o=t.select!=null&&!e.xGrain&&!e.xBins&&a!==``,s=Array.isArray(e.select)?e.select:[],c=o&&Array.isArray(e.filters)?JC(e.filters,a):e.filters,l=o||t.action!=null?e=>{if(e.x!=null){if(o){let r=KC(s,a,e.x);n(t.select,r);let o=GC(r,a);i({kind:`point.selected`,summary:o.some(t=>String(t)===String(e.x))?`Clicked ${e.x} in the chart: the page is filtered to ${a} ${o.length===1?`is`:`is one of`} ${o.join(`, `)}.`:`Clicked ${e.x} in the chart again: ${e.x} is taken out of the filter on ${a}${o.length===0?`, which is now cleared`:``}.`,subject:{column:a,value:e.x,series:e.series,filters:r}})}t.action!=null&&r(t.action,{column:a,value:String(e.x),series:e.series})}}:void 0;return U7(c,t=>(0,Y7.jsx)(pF,{filters:t,sourceId:Z7(e.sourceId),sql:Z7(e.sql),type:Z7(e.type),x:a,y:e.y??[],xGrain:Z7(e.xGrain)||void 0,xBins:typeof e.xBins==`number`?e.xBins:void 0,splitBy:Z7(e.splitBy)||void 0,stacked:e.stacked===!0,sort:e.sort===`x`||e.sort===`value`?e.sort:void 0,legend:Z7(e.legend)||void 0,xTitle:Z7(e.xTitle)||void 0,yTitle:Z7(e.yTitle)||void 0,yRightTitle:Z7(e.yRightTitle)||void 0,yFormat:e.yFormat===`number`||e.yFormat===`compact`||e.yFormat===`currency`||e.yFormat===`percent`?e.yFormat:void 0,height:typeof e.height==`number`?e.height:300,label:Z7(e.label)||void 0,onPointClick:l,emptyMessage:Z7(e.emptyMessage)||void 0,errorMessage:Z7(e.errorMessage)||void 0}))},PivotTable:({props:e})=>U7(e.filters,t=>(0,Y7.jsx)(kI,{filters:t,sourceId:Z7(e.sourceId),sql:Z7(e.sql),rows:e.rows??[],columns:e.columns??[],measures:e.measures??[],totals:e.totals!==!1,height:typeof e.height==`number`?e.height:360,label:Z7(e.label)||void 0,emptyMessage:Z7(e.emptyMessage)||void 0,errorMessage:Z7(e.errorMessage)||void 0})),QueryResult:({props:e,reportControls:t})=>U7(e.filters,n=>(0,Y7.jsx)(HL,{sourceId:Z7(e.sourceId),sql:Z7(e.sql),height:typeof e.height==`number`?e.height:400,view:Z7(e.view)||void 0,filters:n,sorts:Array.isArray(e.sorts)?RC(e.sorts):void 0,columns:e.columns,onControlsChange:e=>t({view:e.view,filters:VC(e.filters),sorts:HC(e.sorts),columns:e.columns}),emptyMessage:Z7(e.emptyMessage)||void 0,errorMessage:Z7(e.errorMessage)||void 0})),...V7,...d7},Object.fromEntries(e5.names.map(e=>[e,t9[e]]))})),r9=r((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&te(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&te(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function te(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,te(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),i9=r(((e,t)=>{t.exports=r9()})),a9=r((e=>{var t=jM();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),o9=r(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=a9()})),s9=r((e=>{var t=i9(),n=jM(),r=o9();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),k=Symbol.for(`react.strict_mode`),ee=Symbol.for(`react.profiler`),te=Symbol.for(`react.consumer`),A=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case ee:return`Profiler`;case k:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case A:return e.displayName||`Context`;case te:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,j=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function M(e,t){be++,ye[be]=e.current,e.current=t}var Ce=xe(null),we=xe(null),Te=xe(null),Ee=xe(null);function De(e,t){switch(M(Te,t),M(we,e),M(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ep(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ep(t),e=Dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(Ce),M(Ce,e)}function Oe(){Se(Ce),Se(we),Se(Te)}function ke(e){var t=e.memoizedState;t!==null&&(Sh._currentValue=t.memoizedState,M(Ee,e)),t=Ce.current;var n=Dp(t,e.type);t!==n&&(M(we,e),M(Ce,n))}function Ae(e){we.current===e&&(Se(Ce),Se(we)),Ee.current===e&&(Se(Ee),Sh._currentValue=ve)}var je,Me;function Ne(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
102
|
+
- Returns are flat`}},Image:{description:"A picture. `src` is a name the page knows (for example one it gave you), never a web address you choose: the page decides whether and where it loads, and when it does not know the name the `alt` text is shown in its place. Always describe what it shows in `alt`, which is required (an empty string only for decoration). Give `caption` for a line beneath it. `fit` and `maxHeight` keep it from taking over a layout.",props:{src:Z.describe(`The name of the image, as the page gave it to you. Not loaded as written.`),alt:Z.describe(`What the image shows, for anyone who cannot see it.`),caption:Z.optional(),width:U2().int().min(24).max(1600).optional().describe(`The most it is wide, in pixels. It never grows past its container.`),height:U2().int().min(24).max(1600).optional().describe("A fixed height in pixels; the image then fills that box by `fit`."),fit:Y([`contain`,`cover`]).optional().describe(`How a fixed height is filled: the whole image ("contain", the default) or edge to edge, cropped ("cover").`),maxHeight:U2().int().min(24).max(1600).optional().describe(`The most it is tall, in pixels.`)},example:{id:`photo`,component:`Image`,src:`attachment-1`,alt:`A bar chart of monthly revenue, rising through the year`,caption:`Revenue by month`,fit:`contain`,maxHeight:320}},Link:{description:`A link to a web page. Only http and https addresses are shown as links; in a site, a path on the site ("/pricing") is too, and opens in place.`,props:{text:Z,url:Z},example:{id:`docs`,component:`Link`,text:`Metric definitions`,url:`https://example.com/metrics`}},ThemeSwitch:{description:"Changes how the whole page looks, at once: a built-in theme, light or dark, the accent colour, corner radius, font, density or chart colours. Leave out what should stay as it is. The person sees what changed and can undo it. To style only your own surface, put the same fields in `createSurface.theme` instead.",props:{preset:Y(OM.presets).optional(),mode:Y(OM.modes).optional(),accent:q().regex(/^#[0-9a-fA-F]{6}$/).optional().describe(`A hex colour for buttons, links and selection.`),radius:U2().min(OM.radius[0]).max(OM.radius[1]).optional(),font:Y(OM.fonts).optional(),density:Y(OM.densities).optional(),seriesOrder:Y(OM.seriesOrders).optional().describe(`A tested order of chart colours.`)},example:{id:`look`,component:`ThemeSwitch`,preset:`Aurora`,mode:`dark`}}},s5=Object.fromEntries(Object.entries(o5).map(([e,t])=>[e,a5[e]?{...t,events:a5[e]}:t])),c5=B8({id:`urn:surfaces:catalog:basics:v1`,title:`Surfaces basics`,description:`Layout, text, links, buttons, inputs and forms, navigation and the theme switch: the components every Surfaces catalog shares.`,components:z8(s5)})}));Y6(),l5(),K8(),S8();var u5=Y([`neutral`,`positive`,`negative`,`warning`]),d5=[`sum`,`avg`,`count`,`count_distinct`,`min`,`max`,`median`,`stddev`,`variance`,`percentile`],f5=Y([`idle`,`starting`,`running`,`completed`,`failed`,`cancelled`,`skipped`]),p5=J(l4({column:q(),op:Y([`eq`,`neq`,`lt`,`lte`,`gt`,`gte`,`in`,`not_in`,`between`,`contains`,`starts_with`,`ends_with`,`is_null`,`is_not_null`,`since`]),values:J(d4([q(),U2(),Y2()])).max(1e3).optional().describe(`None for is_null and is_not_null, two for between, otherwise one (several for in and not_in). For since, one relative range: "7d", "4w", "3m", "1y", or "week", "month", "quarter", "year" for the start of this one. Use since for anything like "the last 30 days": it is worked out when the query runs, so it does not go stale.`)})).max(20),m5=d4([p5,n8]).describe(`Filters applied by the database. Send the whole list each time; an empty list clears them. Or a binding (\`{ "@path": "/filters" }\`) to read a list kept in the surface's data model: give every view on a page the same path, with a FilterBar writing to it, and they all follow one set of filters. A filter on a column a view's rows lack (a total with no region column, under a filter by region) is left out for that view, which is drawn without it and says so in a note.`),h5=l4({id:q().regex(/^[A-Za-z][A-Za-z0-9_]*$/).describe(`Its name in calculations and on the shelves. Unique.`),kind:Y([`attribute`,`metric`,`derived`]),label:q(),column:q().optional().describe(`Attributes and metrics: the column. A metric without one counts rows.`),grain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional().describe(`A date or time attribute: the size of its buckets.`),aggregate:Y([`sum`,`avg`,`count`,`count_distinct`,`min`,`max`,`median`]).optional().describe(`Metrics: how the column is summarised.`),expression:q().max(400).optional().describe(`Derived metrics: arithmetic over metric ids, e.g. "refund_amount / line_amount".`),format:Y([`number`,`compact`,`currency`,`percent`]).optional(),description:q().optional(),by:q().optional().describe(`Who made it. Put your own name here for fields you write; it is shown on the pill.`),model:q().optional().describe(`Set by the component on a field that is the semantic model's own. Do not set it yourself.`)}),g5=Y([`inner`,`left`,`right`,`full`]).describe('Which rows it keeps, read from `left` to `right`: "left" every row of the left table, "inner" only rows that match, "right" every row of the right table, "full" every row of both.'),_5=l4({left:q().describe(`A table of the model.`),right:q().describe(`Another table of the model.`),keys:J(l4({leftColumn:q(),rightColumn:q()})).min(1).max(4).describe("The columns that match, a column of `left` with one of `right`."),type:g5.optional().describe('Which rows it keeps, read from `left` to `right`. Put the table nearer the first on the left and leave this out: "left", so adding detail never drops one of the model\'s rows. "inner" drops rows with no match; "right" and "full" add rows that are not the first table\'s.')}),v5=Y([`bar`,`line`,`area`]),y5=l4({type:v5.optional().describe(`How measures are drawn unless one says otherwise. Left out: a line over time, bars otherwise.`),swap:Y2().optional().describe(`Turn bars on their side: the breakdown down the left, the measure along the bottom. Bars on one scale only; ignored otherwise.`),measures:g4(q(),l4({type:v5.optional(),axis:Y([`left`,`right`]).optional()})).optional().describe('Per measure, by pill id: its own type (a line over bars) and `axis: "right"` for a second scale. Use a second scale only for two measures of very different sizes; the chart says beneath itself that two scales can mislead.')}).describe(`How the chart is drawn. Left out, it is chosen from what is on the shelves.`),b5=l4({grain:q().max(200).optional().describe(`What one row is, in a sentence: "One order line."`),primaryKey:J(q()).max(8).optional().describe(`The columns that make a row unique. The engine checks it before the model is saved.`),tables:J(q()).max(8).optional().describe("The tables, the first being the one whose rows are the model's rows. The query is generated from them and `joins`."),joins:J(_5).max(12).optional().describe(`Joins that add one row of detail to each row of the first table: a line's order, product or store. A join that repeats rows makes the key fail.`),sql:q().max(8e3).optional().describe(`A single read-only SELECT, in place of tables and joins, when the rows need more than joins (a computed column, a filter, a union).`),dataset:l4({pipeline:q().describe(`The pipeline's id.`),dataset:q().describe(`The dataset's name.`)}).optional().describe(`A dataset a pipeline builds, in place of tables, joins and a query: the model reads its table. Prefer it when a pipeline already builds the rows. Give the dataset's grain and primaryKey from describe_pipeline (the pipeline checks that key after every build) and fields from its columns. The editor shows when it was last built and how its checks went.`)}).describe(`What one row is and where the rows come from. Parts left out stay as they are.`),x5=q().regex(/^[a-z][a-z0-9_]{0,63}$/).describe("The name of a semantic model (list them with list_semantic_models). Its dimensions, measures and metrics become the pills, marked as the model's, so a metric means what the model defines; its source and query are used when `sourceId` and `sql` are left out. Prefer it to writing `fields` whenever a model covers the data. A person can add a field they make to the model."),S5=J(l4({column:q(),desc:Y2().optional()})).max(8).describe(`Sort order, most important first. An empty list clears it.`),C5=l4({order:J(q()).max(500).optional().describe(`Column names in display order; the rest follow in the query's order.`),hidden:J(q()).max(500).optional(),widths:g4(q(),U2().min(60).max(1200)).optional().describe(`Widths in px by column name.`),labels:g4(q(),q().max(120)).optional().describe(`Headers to show in place of column names, by column name ("Starts" for starts_at).`)}).describe(`Which columns show, in what order, how wide, and under what headers.`),w5=d4([q(),l4({column:q(),grain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional().describe(`Group a date or time column by this size.`),label:q().optional()})]),T5=e=>q().describe(e),E5=l4({speaker:q().max(80),text:q().max(4e3),side:Y([`start`,`end`]).optional().describe(`"end" for the person's own turns.`),time:q().max(40).optional()}),D5={emptyMessage:Z.optional().describe(`What the people using the page read when the query answers with no rows, in place of the component's own empty text. Say what is missing and what to try: "No orders this week yet."`),errorMessage:Z.optional().describe(`What the people using the page read when the query fails, in place of the database's error text, which is kept for developers. Say what went wrong in their terms and what to do.`)},O5="Give `opened` a data path and opening a table also writes its name there, inside the surface; bind another component's `table` to the same path and it follows, with no agent. The event is still sent.",k5=n8.optional().describe(`Where the opened table's name is written in this surface's data model.`),A5=c4({left:q(),right:q(),keys:J(c4({leftColumn:q(),rightColumn:q()})),inferred:Y2().optional(),declared:Y2().optional()}),j5={Conversation:{send:{description:`When a person sends a turn, typed or picked from the suggestions. It is already in the thread.`,context:{text:T5(`what they wrote`)}}},Chips:{choose:{description:`When a chip is pressed.`,context:{value:T5(`the chip's value: its text, unless the item sets a value`)}}},DecisionCard:{choose:{description:`When an option is chosen.`,context:{choice:T5(`the option's id`),label:T5(`the option's label`)}}},SqlProposal:{run:{description:`When a person presses Run.`,context:{sql:T5(`the SQL as run`)}}},SqlEditor:{run:{description:`When a person runs the SQL.`,context:{sql:T5(`the SQL as written`)}}},ObjectBrowser:{select:{description:`When a table, column or join is picked.`,context:{table:T5(`table name`),column:T5(`column name, or empty`)}}},ReportBuilder:{ask:{description:"When a person asks for a field, a view or a whole report in words. Answer by updating this component's `fields`, `tiles`, `filters` and `draft`.",context:{text:T5(`what they asked for`)}}},Explorer:{ask:{description:"When a person asks for a field or a view in words. Answer by updating this component's `fields`, `rows`, `split` and `values`.",context:{text:T5(`what they asked for`)}}},SemanticModelEditor:{save:{description:`When a person saves the draft as the model's next version, or a new model as version 1. Every report on the model now uses it.`,context:{model:T5(`the model's name`),version:U2().describe(`the version saved`),changes:g4(q(),q()).describe(`each changed field's name and whether it was added, changed or removed; a part of the rows appears as (grain), (primaryKey), (joins), (sql) or (dataset)`)}},ask:{description:"When a person asks for a change, or for a new model, in words. Answer by updating this component's `proposed` (and `create`).",context:{text:T5(`what they asked for`)}}},FilterBar:{change:{description:`When a person adds or removes a filter.`,context:{filters:J(r4()).describe("the whole filter list, as the `filters` prop takes it")}}},Chart:{select:{description:`When a person clicks a bar or point.`,context:{column:T5(`the x column`),value:T5(`the clicked x value`),series:T5(`the series clicked`)}}},FileBrowser:{open:{description:`When a person opens a file (Enter or a double click).`,context:{path:T5(`the file's path in its place`),name:T5(`the file's name`),place:T5(`the source id, or local:<folder> for a folder on their computer`),format:T5(`parquet, csv, json, delta or iceberg, or empty`)}}},ModelDiagram:{use:{description:`When a person presses Use as query.`,context:{sql:T5(`the generated SELECT`),tables:J(q()).describe(`the tables`),joins:J(A5).describe(`the joins kept`)}}},DataSearch:{open:{description:`When a result is opened.`,context:{table:T5(`table name`),column:T5(`column name, or empty`)}}},RelationshipGraph:{open:{description:`When a related table is opened.`,context:{table:T5(`table name`)}}},NodeGraph:{select:{description:`When a node is opened, on the graph or in the list beside it.`,context:{node:T5(`the node's id`)}}},ObjectDetail:{open:{description:`When a related table is opened.`,context:{table:T5(`table name`)}}},PipelineGraph:{select:{description:`When a node is chosen.`,context:{id:T5(`node id`),name:T5(`node name`)}}},PipelineView:{started:{description:`When a person starts a run here.`,context:{event:T5(`started`),runId:T5(`the run`),state:T5(`running, or how it already ended`)}},finished:{description:`When a run a person started here ends.`,context:{event:T5(`finished`),runId:T5(`the run`),state:T5(`completed, failed or cancelled`),built:U2().describe(`datasets built`),failed:J(q()).describe(`datasets that failed`),failedChecks:J(q()).describe(`checks that failed, as dataset.check`)}}},DatasetReview:{decide:{description:`When the person approves (and the page saved it) or rejects the dataset.`,context:{approved:Y2().describe(`whether it was approved`),version:U2().optional().describe(`the version saved, when approved and saved`),approvedBy:q().optional().describe(`who approved it`),digest:q().optional().describe(`the digest of the pipeline as approved`),note:q().optional().describe(`the person's note, if any`)}}},PlanReview:{decide:{description:`When the plan is approved or rejected.`,context:{approved:Y2().describe(`whether the plan was approved`),stepIds:J(q()).describe(`the steps left ticked`),note:q().optional().describe(`the person's note, if any`)}}},ActionReceipt:{undo:{description:`When a person asks to undo what ran. Ask again before undoing; this is a request, not an approval.`}},PiiReview:{decide:{description:`When the review is confirmed.`,context:{table:T5(`table name`),columns:J(c4({name:q(),category:q().optional(),action:q()})).describe(`each column's category and treatment`),confirmed:Y2().describe(`true when the person confirmed they may decide this`)}}}};function M5(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,j5[e]?{...t,events:j5[e]}:t]))}var N5=B8({id:`urn:surfaces:catalog:analytics:v1`,title:`Surfaces analytics`,description:`Layout, summary, data, discovery and conversation components for dashboards, query results and chat.`,components:z8(M5({Text:s5.Text,Row:s5.Row,Column:s5.Column,Grid:s5.Grid,Card:s5.Card,Divider:s5.Divider,Workspace:{description:'Several children side by side as panels a person can arrange: drag a panel by its heading to another column or to an edge for a column of its own, resize with the dividers, and hide or show panels from a rail. `layout.columns` says where the panels are: a list of columns from left to right, each a list of panel ids from top to bottom, so search on the left and a map on the right is `[["search"], ["map"]]`. To rearrange, send the component again with a new `layout`; how a person left it comes back to you in the surface\'s controls as `layout`. Panels not placed are added to the last column. Each panel shows on a rail as an icon, with its name in a tooltip and, when a person turns names on, a short name under it: keep titles to a few words, and give `short` and `icon` so the rail reads well. Use it when a person will work across several views at once; use Grid or Row for a fixed arrangement.',props:{label:q().optional().describe(`What the workspace is, for assistive technology.`),panels:J(l4({id:q(),title:q().describe(`The panel's heading: one to three words.`),short:q().max(14).optional().describe(`A shorter name for the rail, which has room for about ten characters a line. Give one when the title is longer than that.`),icon:Y([`surface`,`agent`,`components`,`table`,`code`,`data`,`history`,`save`,`search`,`map`,`chart`,`grid`,`settings`,`note`,`folder`,`person`,`bell`,`people`]).optional().describe(`The rail's icon. Left out, the title's first letter.`),child:_8})).min(1).max(12),layout:l4({columns:J(J(q())).max(4).describe(`Panel ids: one list per column, left to right; each list top to bottom.`),columnWidths:J(U2().positive()).optional().describe(`One share per column; they are scaled to add up to 1. Left out, columns are equal.`),rowHeights:J(J(U2().positive())).optional().describe(`One share per panel of each column. Left out, panels are equal.`),hidden:J(q()).optional().describe(`Panels that exist but are not shown; the rail brings them back.`),collapsed:J(q()).optional().describe(`Panels folded to their heading. A column always keeps one open.`),places:g4(q(),l4({column:U2().int().min(0),row:U2().int().min(0),sole:Y2().optional()})).optional().describe(`Where hidden panels were, so they come back to the same place. Reported back to you; you need not set it.`)}).optional(),rail:Y([`left`,`right`,`none`]).optional().describe(`Where the rail of panel toggles sits. Defaults to right.`),railLabels:Y2().optional().describe(`Whether the rail shows a short name under each icon. Left out, the rail is icons only and each name shows in a tooltip; a person can turn names on.`),height:U2().int().min(240).max(1600).optional().describe(`How tall the workspace is, in pixels. Panels scroll inside it. Defaults to 520.`)},example:{id:`explore`,component:`Workspace`,label:`Explore the catalog`,panels:[{id:`search`,title:`Table search`,short:`Search`,icon:`search`,child:`search`},{id:`map`,title:`Relationship map`,short:`Map`,icon:`map`,child:`map`}],layout:{columns:[[`search`],[`map`]],columnWidths:[.4,.6]},height:520}},SideNav:s5.SideNav,Tabs:s5.Tabs,Button:s5.Button,TextField:s5.TextField,NumberField:s5.NumberField,ChoicePicker:s5.ChoicePicker,CheckBox:s5.CheckBox,DateTimeInput:s5.DateTimeInput,Slider:s5.Slider,Form:s5.Form,Stat:{description:`One headline number with a label, and optionally how it changed.`,props:{label:Z,value:d4([Z,s8]),delta:Z.optional().describe(`Change text, e.g. "+5.4% vs last quarter".`),tone:u5.optional().describe(`Colour of the change text.`)},example:{id:`revenue`,component:`Stat`,label:`Revenue`,value:{"@path":`/revenue`},delta:`+5.4% vs last quarter`,tone:`positive`}},KeyValue:{description:`A short list of labelled facts.`,props:{items:J(l4({label:Z,value:d4([Z,s8])})).min(1)},example:{id:`facts`,component:`KeyValue`,items:[{label:`Source`,value:`lake`},{label:`Rows`,value:{"@path":`/rows`}}]}},Metric:{description:`One headline number worked out by the database from a query: a total, an average, a count. Use it for dashboard figures; use Stat only for a number you already have.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:m5.optional(),column:q().optional(),aggregate:Y(d5),percentile:U2().min(0).max(1).optional().describe(`For the percentile aggregate, a fraction from 0 to 1: 0.9 is the 90th percentile.`),label:Z,format:Y([`number`,`compact`,`currency`,`percent`]).optional(),currency:q().length(3).optional(),...D5},example:{id:`revenue`,component:`Metric`,sourceId:`lake`,sql:`SELECT * FROM orders`,column:`amount`,aggregate:`sum`,label:`Revenue`,format:`currency`}},Badge:{description:`A small status label.`,props:{text:Z,tone:u5.optional()},example:{id:`status`,component:`Badge`,text:`Up to date`,tone:`positive`}},Progress:{description:`Progress toward a total.`,props:{value:s8,max:s8.optional(),label:Z.optional()},example:{id:`load`,component:`Progress`,value:42,max:100,label:`Rows loaded`}},DataGrid:{description:`A table over a SQL query, for any number of rows. Sorting and paging run in the database. Use it to show rows; use Chart to show a trend or comparison.`,props:{sourceId:Z.describe(`The data source to query.`),sql:Z.describe(`A single read-only SELECT statement.`),mode:Y([`scroll`,`pages`]).optional(),sorts:S5.optional(),filters:m5.optional(),columns:C5.optional(),height:U2().int().min(160).max(1200).optional(),label:q().optional().describe(`Accessible name for the table.`),...D5},example:{id:`table`,component:`DataGrid`,sourceId:`lake`,sql:`SELECT * FROM orders`,height:360}},Chart:{description:`A chart over a SQL query. Give each measure an aggregate so the database summarises the data; without one the chart plots a random sample of rows. Each entry in y is a series; give series their own type and axis for a compound chart. Choose the form from the comparison: bars for amounts across categories (they are sorted largest first and start at zero), a line with xGrain for change over time, xBins for a distribution, scatter for two measures. Avoid a pie beyond five slices, more than five lines, and a second y scale (use two charts on the same x instead); the chart shows advice when its shape is hard to read.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:m5.optional(),type:Y([`bar`,`line`,`area`,`scatter`,`pie`]),x:q().describe(`Column for the x axis, or the slices of a pie.`),xGrain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional().describe(`Group a date or time x column into buckets of this size. Use it for every time series.`),xBins:U2().int().min(2).max(200).optional().describe(`Group a numeric x column into about this many bins, for a histogram.`),y:J(l4({column:q().optional(),aggregate:Y(d5).optional(),percentile:U2().min(0).max(1).optional().describe(`For the percentile aggregate, e.g. 0.9.`),expression:q().max(400).optional().describe('A calculation instead of a column: arithmetic (+ - * / and parentheses) over the names in `terms`, e.g. "refunded / revenue". The database works it out after summarising. Use it for any rate, share, margin or average of sums; never divide in SQL per row.'),terms:g4(q().regex(/^[A-Za-z][A-Za-z0-9_]*$/),l4({column:q().optional(),aggregate:Y(d5)})).optional().describe(`The measures an expression names: each a column and how it is summarised.`),label:q().optional(),type:Y([`bar`,`line`,`area`,`scatter`]).optional().describe(`Draw this series differently from the chart type, e.g. a line over bars.`),axis:Y([`left`,`right`]).optional().describe(`Use the right axis for a measure on a different scale.`),slot:U2().int().min(1).max(12).optional().describe(`Which of the theme's series colours to use, from 1. Give a measure the same slot in every chart so it keeps its colour. Never name a colour: the theme chooses them.`)})).min(1).max(8).describe(`One entry per series.`),splitBy:q().optional().describe(`Column whose values become separate series.`),stacked:Y2().optional(),select:n8.optional().describe("Makes the chart a filter: the path of a shared filter list (the one its `filters` and a FilterBar use). A click on a bar filters the page to that x value, a click on it again clears it, and this chart ignores filters on its own x column so the bars a person clicks stay. Only for a category x (no xGrain or xBins)."),sort:Y([`value`,`x`]).optional().describe(`Order of bars. Bars over categories are sorted largest first unless you say "x". Dates, bins and numbers keep their own order.`),legend:Y([`top`,`bottom`,`right`,`none`]).optional().describe(`Leave out: up to four lines are labelled at their ends, and one series needs no legend.`),xTitle:q().optional(),yTitle:q().optional(),yRightTitle:q().optional(),yFormat:Y([`number`,`compact`,`currency`,`percent`]).optional().describe(`How the left axis writes its numbers: "percent" for a rate (6%, not 0.06), "currency" for money. Labels only.`),height:U2().int().min(160).max(1200).optional(),action:y8.optional(),label:q().optional().describe(`Accessible description of what the chart shows.`),...D5},example:{id:`chart`,component:`Chart`,sourceId:`lake`,sql:`SELECT * FROM orders`,type:`bar`,x:`region`,y:[{column:`amount`,aggregate:`sum`,label:`Revenue`}],yTitle:`Revenue`,label:`Revenue by region, largest first`}},PivotTable:{description:`A pivot table over a SQL query: row values down the side, column values across the top, summarised measures in the cells, with totals. The database does the grouping. Use it to compare a measure across two dimensions.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:m5.optional(),rows:J(w5).min(1).max(4).describe(`Columns whose values become the rows.`),columns:J(w5).max(2).optional().describe(`Columns whose values become the columns. Choose ones with few distinct values.`),measures:J(l4({column:q().optional(),aggregate:Y(d5),percentile:U2().min(0).max(1).optional().describe(`For the percentile aggregate, a fraction from 0 to 1: 0.9 is the 90th percentile.`),label:q().optional()})).min(1).max(6),totals:Y2().optional(),height:U2().int().min(160).max(1200).optional(),label:q().optional().describe(`Accessible name for the table.`),...D5},example:{id:`pivot`,component:`PivotTable`,sourceId:`lake`,sql:`SELECT * FROM orders`,rows:[`region`],columns:[{column:`ordered_at`,grain:`quarter`}],measures:[{column:`amount`,aggregate:`sum`,label:`Revenue`}]}},QueryResult:{description:"A query result a person can explore: filters; a table, a chart and a pivot of the same query; and the SQL that ran. Set `view`, `filters`, `sorts` and `columns` to put its controls in a given state; update them to change what a person sees, and they can go on changing them by hand.",props:{sourceId:Z,sql:Z,view:Y([`grid`,`chart`,`pivot`]).optional(),filters:m5.optional(),sorts:S5.optional(),columns:C5.optional(),height:U2().int().min(160).max(1200).optional(),...D5},example:{id:`explore`,component:`QueryResult`,sourceId:`lake`,sql:`SELECT * FROM orders`}},Message:{description:`One turn of a conversation, for a page that is laid out as a chat: who spoke, what they said (Markdown), and when. Put the turns in a Column, oldest first. \`side: "end"\` sets the person's own turns apart from everyone else's; the speaker is always written, so the side is never the only sign. Offer replies with Chips after the last turn, and take a typed one with a TextField and a Button. It shows a conversation; it does not run one.`,props:{speaker:Z.describe(`Who spoke: a name or a role.`),text:Z.describe(`What they said, as Markdown.`),side:Y([`start`,`end`]).optional().describe(`"end" for the person's own turns. Defaults to "start".`),time:Z.optional().describe(`When, as it should read: "10:42" or "Yesterday".`)},example:{id:`turn-1`,component:`Message`,speaker:`Assistant`,text:`Which table holds the articles?`,time:`10:42`}},Conversation:{description:"A whole chat in one component: the turns so far, replies to pick, and a box to write in. Sending adds the person's turn to the thread at once and sends `send` with what they wrote. Give `messages` the turns, oldest first, or a data path holding them. Keep the thread there: answer `send` by adding the person's turn and yours to the list, and each is drawn once. For a prototype with no agent, `replies` answer in order, one for each turn the person sends. For one turn on its own, or a thread laid out by hand among other components, use Message.",props:{label:q().max(80).describe(`What the conversation is, for assistive technology: "Support chat".`),messages:d4([J(E5).max(200),n8]).describe(`The turns so far, oldest first, or a data path holding them. An empty list starts with only the box.`),you:q().max(80).optional().describe(`Who the person is on their own turns. Defaults to "You".`),suggestions:J(q().max(120)).max(6).optional().describe(`Replies offered under the thread until the person sends something; a press sends one.`),replies:J(l4({speaker:q().max(80),text:q().max(4e3)})).max(20).optional().describe(`Scripted answers for a prototype with no agent: the first answers the person's first turn, and so on. Leave it out when an agent answers.`),placeholder:q().max(120).optional().describe(`What the box says while it is empty. Defaults to "Write a message".`),action:y8.optional()},example:{id:`support`,component:`Conversation`,label:`Support chat`,messages:[{speaker:`Assistant`,text:`Hi! What can I help you with today?`,time:`10:41`},{speaker:`You`,text:`My last order hasn't arrived.`,side:`end`,time:`10:42`},{speaker:`Assistant`,text:`Sorry about that. Which order is it?`,time:`10:42`}],suggestions:[`The one from Monday`,`Show my orders`],replies:[{speaker:`Assistant`,text:`Thanks. It left the warehouse yesterday and arrives **tomorrow**.`}],action:{event:{name:`send`}}}},RowList:{description:'One component drawn once for each row of a SQL query: a feed of posts, a list of cards, rows that each carry their own buttons. `child` is the component drawn per row, usually a Card. Inside it, and in everything it holds, a relative path reads the row\'s column of that name (`{ "@path": "author" }`; `formatString` with `${author}` too), and a Button\'s event carries the row\'s key the same way (`"context": { "post_id": { "@path": "post_id" } }`), so you learn which row was acted on. Absolute paths still read the surface\'s data model. The database sorts, filters and pages; a person asks for more rows, up to 200. An input inside a row must bind an absolute path. For plain rows in columns use DataGrid.',props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement. One row of it is one item.`),child:_8.describe(`ID of the component drawn for each row.`),label:q().describe(`What the items are, for assistive technology: "Posts".`),sorts:S5.optional(),filters:m5.optional(),pageSize:U2().int().min(1).max(100).optional().describe(`Rows fetched at a time. Defaults to 20.`),rowKey:q().optional().describe(`A column that tells rows apart, such as the key.`),layout:Y([`list`,`grid`]).optional().describe(`"list" stacks the rows; "grid" lays them out as cards, as many across as fit.`),...D5},example:{id:`feed`,component:`RowList`,sourceId:`lake`,sql:`SELECT * FROM orders`,child:`order-card`,label:`Orders`,sorts:[{column:`ordered_at`,desc:!0}],rowKey:`order_id`,pageSize:10}},Markdown:s5.Markdown,Image:s5.Image,CodeBlock:{description:`Code with a copy button. For SQL a person should be able to run, use SqlProposal instead.`,props:{code:Z,language:q().optional()},example:{id:`snippet`,component:`CodeBlock`,language:`sql`,code:`SELECT region, SUM(amount) FROM orders GROUP BY region`}},Table:{description:`A small table of values you already have (at most 100 rows). For query results use DataGrid, which pages in the database.`,props:{columns:J(q()).min(1).max(12),rows:J(J(d4([q(),U2(),Y2(),t4()]))).max(100),caption:q().optional()},example:{id:`top`,component:`Table`,columns:[`Region`,`Revenue`],rows:[[`Europe`,1200],[`Asia Pacific`,950]],caption:`Top regions`}},Link:s5.Link,Checklist:{description:`A list of steps showing which are done.`,props:{items:J(l4({label:Z,done:Y2().optional()})).min(1).max(30)},example:{id:`plan`,component:`Checklist`,items:[{label:`Find the tables`,done:!0},{label:`Check the join`}]}},Chips:{description:"Short choices a person can pick with one press, such as follow-up questions or tables to look at. The chosen chip is sent back in the event context as `value`. An item is its text, or `{ label, value }` when what is sent differs from what is shown. Give `selected` a data path and a press also writes the chip's value there, inside the surface; bind another component's prop to the same path and it follows at once, with no agent: chips of table names whose values are SELECT statements switch a QueryResult whose `sql` is bound to that path. Set the path in the data model to the value that starts selected.",props:{items:J(d4([q(),l4({label:q(),value:q()})])).min(1).max(12),selected:n8.optional().describe(`Where the pressed chip's value is written in this surface's data model. The chip holding the value there is shown as pressed.`),action:y8},example:{id:`next`,component:`Chips`,items:[`Break down by region`,`Show last year`],action:{event:{name:`choose`}}}},DecisionCard:{description:"Asks a person to choose between options before you continue. Mark the option you recommend. The chosen option's id is sent back in the event context as `choice`.",props:{title:Z,detail:Z.optional(),options:J(l4({id:q(),label:q(),description:q().optional(),recommended:Y2().optional()})).min(2).max(6),action:y8},example:{id:`grain`,component:`DecisionCard`,title:`Which revenue should I use?`,detail:`The two tables disagree for March.`,options:[{id:`ledger`,label:`Finance ledger`,description:`Certified, updated nightly.`,recommended:!0},{id:`orders`,label:`Orders table`,description:`Live, but includes returns.`}],action:{event:{name:`decide`}}}},Sparkline:{description:`A word-sized trend line beside its latest value, worked out by the database: no axes, grid or legend. Use it in a table of figures or beside a Metric to show direction; use Chart when the values themselves must be read.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:m5.optional(),x:q().describe(`The date or time column the line runs along.`),grain:Y([`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]),column:q().optional(),aggregate:Y(d5),label:Z,format:Y([`number`,`compact`,`currency`,`percent`]).optional(),currency:q().length(3).optional(),points:U2().int().min(2).max(120).optional(),...D5},example:{id:`trend`,component:`Sparkline`,sourceId:`lake`,sql:`SELECT * FROM orders`,x:`ordered_at`,grain:`month`,column:`amount`,aggregate:`sum`,label:`Revenue`,format:`currency`}},BulletGraph:{description:`One measure against a target and named bands (poor, fair, good), as a bar from zero. Use it instead of a gauge or a traffic light when a number needs judging against a goal.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`),filters:m5.optional(),column:q().optional(),aggregate:Y(d5),label:Z,target:U2().optional(),ranges:J(l4({to:U2(),label:q()})).min(1).max(5).describe(`Where each band ends, lowest first. The last end is the end of the scale.`),format:Y([`number`,`compact`,`currency`,`percent`]).optional(),currency:q().length(3).optional(),...D5},example:{id:`goal`,component:`BulletGraph`,sourceId:`lake`,sql:`SELECT * FROM orders`,column:`amount`,aggregate:`sum`,label:`Revenue`,format:`currency`,target:2e6,ranges:[{to:1e6,label:`Poor`},{to:18e5,label:`Fair`},{to:3e6,label:`Good`}]}},StepFlow:{description:"Where multi-step work stands: onboarding, connecting a source, a cleaning or transformation run. Give a step the status `waiting` when the work has stopped for the person, and say in `detail` what you need from them.",props:{label:Z,steps:J(l4({id:q(),title:q(),detail:q().optional(),status:Y([`done`,`current`,`waiting`,`pending`,`failed`,`skipped`])})).min(1).max(20)},example:{id:`flow`,component:`StepFlow`,label:`Connect the sales lake`,steps:[{id:`find`,title:`Find the tables`,status:`done`},{id:`secret`,title:`Add the credential on the server`,detail:`Set LAKE_KEY_ID and LAKE_SECRET, then tell me.`,status:`waiting`},{id:`test`,title:`Test the connection`,status:`pending`}]}},PlanReview:{description:'A plan a person must approve before you act: cleaning steps, transformations, a connection to set up. List every step with what it changes; mark anything that removes or overwrites data or widens access as `risk: "high"` (it starts unticked). The event context carries `approved`, the ticked `stepIds` and any `note`. Do only the approved steps.',props:{title:Z,summary:Z.optional(),proposedBy:q().optional().describe(`Your name, so the person knows who wrote the plan.`),steps:J(l4({id:q(),title:q(),detail:q().optional(),sql:q().optional().describe(`What the step would run, for review only.`),kind:q().optional(),affects:q().optional(),risk:Y([`low`,`medium`,`high`]).optional(),required:Y2().optional()})).min(1).max(20),action:y8},example:{id:`clean`,component:`PlanReview`,title:`Clean the orders table`,summary:`Three fixes before it feeds the revenue dashboard.`,proposedBy:`Analyst agent`,steps:[{id:`trim`,title:`Trim spaces from region`,kind:`Clean`,affects:`412 of 58,000 rows`,sql:`SELECT TRIM(region) AS region FROM orders`},{id:`dedupe`,title:`Remove repeated order IDs`,kind:`Clean`,affects:`37 rows removed`,risk:`high`}],action:{event:{name:`plan_decided`}}}},ActionReceipt:{description:"What happened after a person approved something: the outcome, who approved it and why, what ran, what changed, and whether it can be undone. Send one after every approved action that changed something, including a failed one. Give `undo` only when undoing is really possible, with `until` when it stops being; leave it out and the receipt says it cannot be undone. The `undo` event is a request: confirm it with the person before acting.",props:{title:Z,outcome:Y([`done`,`partial`,`failed`]),summary:Z.optional(),ranAt:q().optional().describe(`ISO time it ran.`),ranBy:q().optional().describe(`What ran it: you, a pipeline, a service.`),approvedBy:J(l4({by:q(),at:q().optional(),reason:q().optional()})).max(10).optional(),sql:q().optional().describe(`What ran, for the record. Never run from the receipt.`),changes:J(l4({label:q(),before:q().optional(),after:q()})).max(20).optional(),undo:l4({label:q(),description:q().optional(),until:q().optional()}).optional(),action:y8.optional()},example:{id:`receipt`,component:`ActionReceipt`,title:`Rebuilt orders_clean`,outcome:`done`,summary:`58,000 rows replaced with 57,963 after removing repeated order IDs.`,ranAt:`2026-11-13T10:04:00Z`,ranBy:`sales pipeline`,approvedBy:[{by:`Ada`,at:`2026-11-13T10:02:00Z`,reason:`Counts checked against finance`}],changes:[{label:`Rows`,before:`58,000`,after:`57,963`}],undo:{label:`Restore the previous version`,description:`Restores the table as it was at 10:03. Rows added since then are lost.`,until:`2026-11-20T10:04:00Z`},action:{event:{name:`undo_requested`}}}},PiiReview:{description:"A review of a table's columns for personal data before it is shared, charted or sent to a model. Flag a column with the kind of data you suspect and how you know (`basis`); the person chooses the treatment and confirms. The event context carries `table`, `columns` (name, category, action) and `confirmed`. Never treat your own flags as the decision.",props:{table:q(),purpose:Z.optional(),columns:J(l4({name:q(),type:q().optional(),category:Y([`name`,`email`,`phone`,`address`,`government_id`,`financial`,`date_of_birth`,`network`,`location`,`credential`,`health`,`demographic`]).optional(),basis:Y([`name`,`values`,`person`]).optional(),action:Y([`keep`,`mask`,`hash`,`generalize`,`drop`]).optional()})).min(1).max(200),action:y8},example:{id:`pii`,component:`PiiReview`,table:`customers`,purpose:`Before sharing with the marketing workspace.`,columns:[{name:`customer_id`,type:`BIGINT`},{name:`email`,type:`VARCHAR`,category:`email`,basis:`name`},{name:`birth_date`,type:`DATE`,category:`date_of_birth`,basis:`name`}],action:{event:{name:`pii_decided`}}}},ThemeSwitch:s5.ThemeSwitch,SqlProposal:{description:"SQL you propose, shown for review. It never runs on its own: a person presses Run, and the result appears beneath it. The event, if given, is sent with `sql` when they do.",props:{sourceId:Z,sql:Z,title:q().optional(),action:y8.optional()},example:{id:`proposal`,component:`SqlProposal`,sourceId:`lake`,title:`Revenue by region`,sql:`SELECT region, SUM(amount) AS revenue FROM orders GROUP BY region`}},SqlEditor:{description:"An editor for a person to write or change SQL. The event is sent with `sql` when they run it.",props:{sql:Z.optional(),dialect:Y([`standard`,`duckdb`,`teradata`,`postgres`]).optional(),action:y8.optional()},example:{id:`editor`,component:`SqlEditor`,sql:`SELECT * FROM orders`,action:{event:{name:`run`}}}},ObjectBrowser:{description:"A tree of the source's catalogs, schemas, tables and columns, with the tables each one joins. Use it when a person needs to look around. The event is sent with `table` (and `column`) when they pick something. "+O5,props:{sourceId:Z,height:U2().int().min(200).max(1200).optional(),opened:k5,action:y8.optional()},example:{id:`browse`,component:`ObjectBrowser`,sourceId:`lake`,height:360}},ReportBuilder:{description:"A report built from pills: the dashboard pattern. `fields` are the report's pills (attributes, metrics, derived metrics), defined once so a metric means the same in every view. `tiles` are the views, each a set of shelves (`rows`, `split`, `values`, by pill id) drawn as a chart, a table, or headline numbers when there is nothing to break down by. Every tile follows `filters`, and a click on a bar filters the whole report. In build mode a person makes a view on the shelves and keeps it as a tile, edits pills, retitles, resizes and reorders; in view mode it is the dashboard alone with its filter bar. To write a report yourself, send `fields` and `tiles`; to leave it to the person, send only `sql` and pills are generated from its columns. What they change comes back as this component's controls, so read those first. Give `action` to show a box where they ask in words. Use it for anything with several views over one table or join; use separate Chart and Metric components only when the views read different queries.",props:{model:x5.optional(),sourceId:Z.optional().describe("Where the query runs. Left out with `model`, the model's."),sql:Z.optional().describe("A single read-only SELECT statement, wide enough for every view: a table, or a join. Left out with `model`, the model's."),title:q().optional(),fields:J(h5).max(200).optional().describe(`The report's pills. Left out, they are generated from the query's columns.`),filters:p5.optional().describe(`Filters every tile follows.`),tiles:J(l4({id:q(),title:q().optional().describe(`Left out, the shelves are read out: "Refund rate by Category".`),rows:J(q()).max(3).describe(`Attributes to break down by, by pill id. Empty for headline numbers.`),split:q().optional(),values:J(q()).min(1).max(6).describe(`Metrics and derived metrics, by pill id.`),view:Y([`chart`,`table`]).optional(),chart:y5.optional(),span:d4([S4(1),S4(2),S4(3)]).optional().describe(`How many of the report's three columns it takes.`)})).max(24).optional(),draft:l4({rows:J(q()).max(3),split:q().optional(),values:J(q()).max(6),view:Y([`chart`,`table`]).optional(),chart:y5.optional()}).optional().describe(`What is on the builder's shelves: a view you propose, for the person to add.`),mode:Y([`build`,`view`]).optional().describe(`Leave out to let the person switch. "view" shows the dashboard alone.`),action:y8.optional()},example:{id:`report`,component:`ReportBuilder`,sourceId:`lake`,sql:`SELECT * FROM orders`,title:`Orders`,fields:[{id:`region`,kind:`attribute`,label:`Region`,column:`region`},{id:`ordered_at`,kind:`attribute`,label:`Month`,column:`ordered_at`,grain:`month`},{id:`amount`,kind:`metric`,label:`Revenue`,column:`amount`,aggregate:`sum`,format:`currency`},{id:`orders`,kind:`metric`,label:`Orders`,aggregate:`count`},{id:`per_order`,kind:`derived`,label:`Revenue per order`,expression:`amount / orders`,format:`currency`}],tiles:[{id:`headline`,rows:[],values:[`amount`,`orders`,`per_order`],span:3},{id:`by-region`,rows:[`region`],values:[`amount`]},{id:`over-time`,rows:[`ordered_at`],values:[`per_order`],span:2}]}},SemanticModelEditor:{description:"A semantic model, to create, read and change: what one row is (the grain) and the columns that make it unique, where the rows come from (tables and joins, or a written query), and its dimensions (ways to break rows down), measures (a column summarised) and metrics (arithmetic over measures), each with who defined it. Every Explorer and ReportBuilder given this `model` takes its fields from it, so a change here changes every report on it. To propose a change, send `proposed` with the fields to add or replace (in the pill form: an attribute is a dimension, a metric a measure, a derived metric a metric), the names to remove and any change to the rows, and `proposedBy` with your name; read the model with describe_semantic_model first. To propose a new model, send `create` with its label and source and `proposed` with its rows and fields; read the tables with describe_table first and join from the table whose rows the model counts to tables that add one row of detail each. Either way it is shown as a draft, marked part by part and checked as it is made, and a person can change the joins, the grain, the key and every field before saving; nothing is kept until they save. What the person changes comes back as `proposed` in this component's controls. Give `action` to receive the `save` event, and the `ask` event with `text` when the person asks for something in words.",props:{model:x5.describe("The semantic model to show, or with `create` the name of the one to make."),create:l4({label:q().max(80).describe(`Its name for people.`),description:q().max(400).optional().describe(`What it is for.`),sourceId:q().describe(`The source its rows come from.`)}).optional().describe("Propose a new model named `model`. Its rows and fields go in `proposed`. When a model of that name exists, the proposal is shown as a change to it instead."),proposed:l4({add:J(h5).max(60).optional().describe(`Fields to add, or to put in place of the field of the same id.`),remove:J(q()).max(60).optional().describe(`Names of fields to take out.`),rows:b5.optional()}).optional().describe(`A change you propose, or a new model's rows and fields. Shown as a draft for a person to read, change and save, or drop.`),proposedBy:q().optional().describe(`Who proposed it: your name. Shown above the changes.`),action:y8.optional()},example:{id:`model`,component:`SemanticModelEditor`,model:`sales_lines`,proposed:{add:[{id:`cost_share`,kind:`derived`,label:`Cost share`,expression:`cost / revenue`,format:`percent`,description:`Cost as a share of revenue.`}],remove:[`brand`]},proposedBy:`the analytics agent`,action:{event:{name:`model.saved`}}}},Explorer:{description:"Exploring a query with pills, as a person would in a BI tool but with nothing defined in advance. Each field is a pill: an attribute to break down by, a metric (a column summarised) or a derived metric (arithmetic over metrics: a rate, a margin). Leave `fields` out and pills are generated from the query's columns; send `fields` to add your own metrics and calculations, which a person can then edit. `rows`, `split` and `values` are what is on the shelves, by pill id, and draw a chart and the numbers behind it, worked out by the database. A person drags, presses and edits; what they did comes back as this component's controls, so read those before changing it. Give `action` to show a box where they ask in words, sent as the event with `text`. Use it when someone wants to look around a table or a join themselves; use Chart when you already know the view.",props:{model:x5.optional(),sourceId:Z.optional().describe("Where the query runs. Left out with `model`, the model's."),sql:Z.optional().describe("A single read-only SELECT statement: a table, or a join. Every pill is a column of it or a calculation over them. Left out with `model`, the model's."),fields:J(h5).max(200).optional().describe(`The pills. Left out, they are generated from the query's columns.`),rows:J(q()).max(3).optional().describe(`Attributes to break down by, by pill id. The first is the x axis.`),split:q().optional().describe(`An attribute whose values become separate series.`),values:J(q()).max(6).optional().describe(`Metrics and derived metrics to show, by pill id.`),filters:p5.optional(),view:Y([`chart`,`table`]).optional(),chart:y5.optional(),action:y8.optional()},example:{id:`explore`,component:`Explorer`,sourceId:`lake`,sql:`SELECT * FROM orders`,fields:[{id:`region`,kind:`attribute`,label:`Region`,column:`region`},{id:`amount`,kind:`metric`,label:`Revenue`,column:`amount`,aggregate:`sum`,format:`currency`},{id:`orders`,kind:`metric`,label:`Orders`,aggregate:`count`},{id:`per_order`,kind:`derived`,label:`Revenue per order`,expression:`amount / orders`,format:`currency`}],rows:[`region`],values:[`per_order`]}},FilterBar:{description:'Filters for a whole page: active filters as removable chips and a form to add one, with each column\'s values offered from the database and quick date ranges that stay relative. It writes the list to `filters`, a path in the surface\'s data model; give every Chart, Metric, Sparkline, DataGrid and PivotTable on the page `filters: { "@path": "/filters" }` with the same path and they all follow it. The views should read the same columns as `sql`, since a filter on a column a view does not have fails. Put the starting filters in the data model with updateDataModel. The event, if given, is sent with `filters` on every change.',props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement whose columns can be filtered.`),filters:n8.describe(`Where the filter list is kept in the surface's data model, e.g. { "@path": "/filters" }.`),columns:J(q()).max(50).optional().describe(`Offer only these columns.`),action:y8.optional()},example:{id:`filters`,component:`FilterBar`,sourceId:`lake`,sql:`SELECT * FROM orders`,filters:{"@path":`/filters`},columns:[`region`,`status`,`ordered_at`]}},FileBrowser:{description:"A tree of folders and files: a source's storage (only the places it may read) and, with `local`, folders the person opens from their own computer, which their browser reads and nothing uploads. It shows names, sizes, dates and which table reads a file, never what a file holds. Use it when the data a person means is still files: to find what to bring in, or to see what a table reads. The event is sent with `path`, `name`, `place` and `format` when they open a file. You cannot read a local file; ask the person to load it.",props:{sourceId:Z.optional().describe(`List this source's storage. Leave out to offer only folders on the person's computer.`),local:Y2().optional().describe(`Offer "Open a folder on this computer".`),height:U2().int().min(200).max(1200).optional(),action:y8.optional()},example:{id:`files`,component:`FileBrowser`,sourceId:`lake`,local:!0,height:360,action:{event:{name:`open_file`}}}},ModelDiagram:{description:"A relationship diagram: tables as cards with their columns and lines between the columns that join. A person can drag columns together to add joins. Use it to show or agree how tables relate. The event is sent with `sql`, `tables` and `joins` when they press Use as query.",props:{sourceId:Z,tables:J(q()).min(1).max(12).describe(`Tables to show.`),joins:J(l4({left:q(),right:q(),keys:J(l4({leftColumn:q(),rightColumn:q()})).min(1),inferred:Y2().optional().describe(`True when you are guessing the join; it is then labelled Inferred.`),declared:Y2().optional().describe(`True when the backend reports it as a foreign key; it is then labelled Declared.`),type:g5.optional().describe("Which rows it keeps, read from `left` to `right`. Left out, only rows that match.")})).optional(),rowsFrom:Y2().optional().describe(`The first table's rows are the result's rows: it is marked, the rest are laid out as its detail, and each join says whether it adds one row or can repeat rows. Use it to show which tables can be joined without double counting.`),suggest:Y2().optional().describe(`False to leave out joins the backend would guess from column names; the joins you send and those the source declares are still shown. Default true.`),height:U2().int().min(200).max(1200).optional(),action:y8.optional()},example:{id:`model`,component:`ModelDiagram`,sourceId:`lake`,tables:[`orders`,`customers`],joins:[{left:`orders`,right:`customers`,keys:[{leftColumn:`customer_id`,rightColumn:`customer_id`}],inferred:!0}],action:{event:{name:`use_model`}}}},DataSearch:{description:`A search box over tables and columns, by name or meaning. The event is sent with \`table\` when a person opens a result. ${O5}`,props:{sourceId:Z.optional(),opened:k5,height:U2().int().min(160).max(1200).optional().describe(`How tall the search is, in pixels. The results scroll inside it. Left out, the list is as long as its results.`),action:y8.optional()},example:{id:`find`,component:`DataSearch`,sourceId:`lake`,opened:{"@path":`/table`},height:420}},ObjectDetail:{description:`Everything known about one table: description, certification, columns with statistics and related tables. Bind \`table\` to a path (\`{ "@path": "/table" }\`) to show whichever table a search or graph in the same surface opened. ${O5}`,props:{sourceId:Z,table:Z,opened:k5,action:y8.optional()},example:{id:`about`,component:`ObjectDetail`,sourceId:`lake`,table:`orders`}},RelationshipGraph:{description:`A small map of one table and the tables it joins with or resembles. For several tables and their columns, use ModelDiagram. ${O5}`,props:{sourceId:Z,table:Z,opened:k5,action:y8.optional()},example:{id:`around`,component:`RelationshipGraph`,sourceId:`lake`,table:`orders`}},NodeGraph:{description:"Things and the links between them, drawn as a graph with the same things listed beside it: concepts in a glossary, tables in a model, systems and what they feed. You give the nodes and links; it reads no data. `group` is what kind of thing a node is (each group takes a colour and is named in the legend); `level` is how far along it is (drawn as how full the node is). Give `selected` a data path to mark the open node and to write the node a person opens there. Past 300 nodes it shows what is around the open node and says how many it left out. For tables and their joins use ModelDiagram; for a pipeline use PipelineGraph.",props:{label:q().describe(`What the graph shows, for assistive technology.`),nodes:J(c4({id:q().min(1),label:q(),description:q().optional(),group:q().optional(),level:Y([`full`,`half`,`outline`]).optional()})).max(2e3),links:J(c4({source:q(),target:q(),label:q().optional()})).max(8e3),selected:d4([q(),n8]).optional().describe(`The open node's id, or a data path that holds it and is written when a person opens a node.`),groups:J(q()).max(12).optional().describe(`The order groups take colours and appear in the legend.`),levels:c4({full:q().optional(),half:q().optional(),outline:q().optional()}).optional().describe(`What each level means, in words.`),noun:q().optional().describe(`What a node is called: "term" gives "7 terms".`),height:U2().int().min(200).max(1200).optional(),action:y8.optional()},example:{id:`concepts`,component:`NodeGraph`,label:`Terms and how they are linked`,noun:`term`,nodes:[{id:`order`,label:`Order`,level:`full`},{id:`customer`,label:`Customer`,level:`half`},{id:`store`,label:`Store`,level:`outline`}],links:[{source:`order`,target:`customer`,label:`placed by`},{source:`order`,target:`store`,label:`taken at`}],levels:{full:`Certified`,half:`Partly certified`,outline:`Not certified`},selected:{"@path":`/term`},height:360}},AskData:{description:`A question box that answers from the catalog and cites the tables it used.`,props:{sourceId:Z.optional(),contextPackId:q().optional()},example:{id:`ask`,component:`AskData`,sourceId:`lake`}},ContextBuilder:{description:`Lets a person assemble the tables, columns and notes an agent should work from, and preview exactly what the agent will receive.`,props:{name:q().optional(),tables:J(l4({sourceId:q(),table:q()})).max(30).optional()},example:{id:`context`,component:`ContextBuilder`,name:`Sales analysis`,tables:[{sourceId:`lake`,table:`orders`}]}},QueryPlan:{description:`How the database intends to run a query, without running it: the steps as a tree and the engine's own plan text. Use it to explain why a query is slow.`,props:{sourceId:Z,sql:Z.describe(`A single read-only SELECT statement.`)},example:{id:`plan`,component:`QueryPlan`,sourceId:`lake`,sql:`SELECT region, SUM(amount) FROM orders GROUP BY region`}},SourceList:{description:`The data sources available, how each connects (by secret name only) and a button to test that its tables can be reached.`,props:{},example:{id:`sources`,component:`SourceList`}},PipelineGraph:{description:"A pipeline as a graph of sources, tables, views and sinks with the flows between them and each one's latest status. You supply the nodes and edges as the pipeline engine reported them. The event is sent with `id` and `name` when a node is chosen.",props:{nodes:J(l4({id:q(),name:q(),kind:Y([`source`,`table`,`view`,`streamingTable`,`materializedView`,`temporaryView`,`sink`]),status:f5.optional(),layer:Y([`bronze`,`silver`,`gold`]).optional(),rowsWritten:U2().optional(),expectationsFailed:U2().optional().describe(`records that broke a row rule`),checksFailed:U2().optional().describe(`checks over the whole dataset that failed`)})).min(1).max(200),edges:J(l4({from:q(),to:q(),flowName:q().optional(),mode:Y([`streaming`,`batch`]).optional()})).max(600),height:U2().int().min(160).max(1200).optional(),action:y8.optional()},example:{id:`pipeline`,component:`PipelineGraph`,nodes:[{id:`files`,name:`landing files`,kind:`source`},{id:`raw`,name:`orders_raw`,kind:`streamingTable`,layer:`bronze`,status:`completed`,rowsWritten:12e3},{id:`daily`,name:`daily_revenue`,kind:`materializedView`,layer:`gold`,status:`running`}],edges:[{from:`files`,to:`raw`,mode:`streaming`},{from:`raw`,to:`daily`}]}},PipelineView:{description:"A pipeline the backend runs, live: its datasets and how they feed one another, its runs, and for each dataset its query, grain, key, columns, row rules and checks with the latest results, with buttons to run, check or rebuild it. Give `action` to hear when a person's run starts and ends (`started`, `finished`). Use PipelineGraph instead when you only have a description of a pipeline to draw.",props:{pipelineId:Z,action:y8.optional()},example:{id:`sales-pipeline`,component:`PipelineView`,pipelineId:`sales`}},DatasetReview:{description:"A new or changed pipeline dataset for a person to approve: its query, what it reads, its grain and key, columns and checks, and what changes from the saved version. Give it exactly what `propose_dataset` returned: `pipeline`, `dataset`, `expectedVersion` and `digest`. The person may change the grain, descriptions and checks, names themselves, and approves or rejects. Approving saves it on the server, which checks it again; it builds nothing, so run the pipeline afterwards if they want it built. The `decide` event says what they chose.",props:{pipeline:g4(q(),r4()).describe(`The whole pipeline as it would be, as propose_dataset returned it.`),dataset:q().describe(`The dataset under review.`),expectedVersion:U2().int().min(0),digest:q().optional(),proposedBy:q().optional().describe(`Your name, so the person knows who proposed it.`),action:y8.optional()},example:{id:`review`,component:`DatasetReview`,pipeline:{id:`sales`,name:`Sales`,sourceId:`lake`,datasets:[{name:`orders_clean`,sql:`SELECT * FROM orders WHERE status IS NOT NULL`,grain:`one row per order`,primaryKey:[`order_id`]},{name:`region_revenue`,sql:`SELECT region, SUM(amount) AS revenue FROM orders_clean GROUP BY region`,inputs:[`orders_clean`],inputsDeclared:!0,grain:`one row per region`,primaryKey:[`region`],columns:[{name:`region`,type:`VARCHAR`},{name:`revenue`,type:`DOUBLE`,description:`Sum of amount.`}],checks:[{name:`relationships_region`,kind:`CHECK_KIND_RELATIONSHIPS`,columns:[`region`],toTable:`orders_clean`,toColumn:`region`}]}]},dataset:`region_revenue`,expectedVersion:1,proposedBy:`Analyst agent`,action:{event:{name:`dataset_decided`}}}},IngestWizard:{description:`Steps a person through bringing new files in: where they are, what the engine finds there, and which columns to keep, rename and retype. It writes configuration to review; it loads nothing.`,props:{sourceId:Z,location:q().optional().describe(`Where the files are, to start from.`),format:Y([`parquet`,`delta`,`iceberg`,`csv`,`json`]).optional()},example:{id:`ingest`,component:`IngestWizard`,sourceId:`lake`,format:`parquet`,location:`s3://acme-lake/landing/orders/*.parquet`}},RunHistory:{description:`The runs of a pipeline, newest first: how each ended, how long it took, what it refreshed and why it failed.`,props:{runs:J(l4({id:q(),state:f5,startTime:q().describe(`ISO 8601.`),endTime:q().optional(),trigger:q().optional(),refreshKind:Y([`default`,`refresh`,`fullRefresh`]).optional(),datasets:J(q()).optional(),errorMessage:q().optional()})).max(200)},example:{id:`runs`,component:`RunHistory`,runs:[{id:`update-42`,state:`completed`,startTime:`2026-11-12T02:00:00Z`,endTime:`2026-11-12T02:01:05Z`,trigger:`schedule`}]}},ExpectationsPanel:{description:`Data quality rules for a pipeline with how many records passed and failed each, worst first. Counts come from the engine.`,props:{expectations:J(l4({name:q(),dataset:q(),constraint:q(),action:Y([`warn`,`drop`,`fail`]),passedRecords:U2().min(0),failedRecords:U2().min(0)})).max(200)},example:{id:`quality`,component:`ExpectationsPanel`,expectations:[{name:`valid_amount`,dataset:`orders_clean`,constraint:`amount >= 0`,action:`drop`,passedRecords:960,failedRecords:40}]}},SchemaDiff:{description:`How incoming data differs from the table it loads into: new, missing and retyped columns.`,props:{changes:J(l4({column:q(),change:Y([`added`,`removed`,`typeChanged`]),before:q().optional(),after:q().optional()})).max(500),rescuedCount:U2().min(0).optional(),mode:q().optional().describe(`How new columns are treated, e.g. addNewColumns, rescue, failOnNewColumns.`)},example:{id:`drift`,component:`SchemaDiff`,mode:`rescue`,rescuedCount:12,changes:[{column:`coupon_code`,change:`added`,after:`string`}]}},StreamMetrics:{description:`How a streaming query is keeping up: input and processing rates, batch size and duration, with recent trends. Give the progress reports oldest first, as reported.`,props:{progress:J(l4({timestamp:q(),numInputRows:U2(),inputRowsPerSecond:U2(),processedRowsPerSecond:U2(),batchDurationMs:U2(),stateRows:U2().optional()})).min(1).max(500)},example:{id:`stream`,component:`StreamMetrics`,progress:[{timestamp:`2026-11-12T10:00:00Z`,numInputRows:500,inputRowsPerSecond:50,processedRowsPerSecond:80,batchDurationMs:900}]}}}))});function P5(e){return e.a2ui===`1.0`?e:{...e,a2ui:`1.0`,components:Object.fromEntries(Object.entries(e.components).map(([e,t])=>[e,w8(t)]))}}var F5=n((()=>{S8(),j8()}));S8(),j8();function I5(e){return e.a2ui===`1.0`?e:{...e,a2ui:`1.0`,components:e.components.map(w8)}}function L5(e){let t=I5(e);return{surfaceId:t.id,catalogId:t.catalogId,a2ui:`1.0`,components:Object.fromEntries(t.components.map(e=>[e.id,e])),data:t.data??{},...t.theme?{theme:{...t.theme}}:{}}}function R5(e){return Y8.find(t=>t===e)}function z5(e){if(e===`hug`||e===`fill`)return e;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.fixed;if(Object.keys(e).length===1&&typeof t==`number`&&t>=e5.min&&t<=e5.max)return{fixed:t}}}function B5(e,t){if(!Array.isArray(e)||e.length!==t||t===0)return;let n=e.map(z5);return n.every(e=>e!==void 0)?n:void 0}var V5=n((()=>{l5()}));function H5(e,t,n){let r=(0,e7.useContext)(r7),i=(0,e7.useRef)(null);(0,e7.useSyncExternalStore)(r?.subscribe??i7.subscribe,r?.read??i7.read,i7.read),(0,e7.useEffect)(()=>{if(!r)return;let a=i.current;return r.set(e,{label:t,problem:n,element:a}),()=>r.remove(e,a)},[r,e,t,n]);let a=(0,e7.useCallback)(e=>{i.current=e},[]);return{shown:r?.shown.has(e)??!1,ref:a}}function U5(e){let t=(0,e7.useContext)(r7);(0,e7.useSyncExternalStore)(t?.subscribe??i7.subscribe,t?.read??i7.read,i7.read);let n=(Array.isArray(e)?e.filter(e=>typeof e==`string`):[]).flatMap(e=>{let n=t?.fields.get(e);return n?.problem?[{id:e,label:n.label,problem:n.problem}]:[]});return{waiting:n,show:()=>{t&&n.length!==0&&(t.show(n.map(e=>e.id)),t.fields.get(n[0].id)?.element?.querySelector(`input, select, textarea`)?.focus())}}}function W5({render:e,args:t}){return e(t)}function G5(e){let{surfaceId:t,catalogId:n,sendDataModel:r,metadata:i}=e;return{version:`1.0`,createSurface:{surfaceId:t,catalogId:n,...r?{sendDataModel:r}:{},components:Object.values(e.components),dataModel:e.data,...i?{metadata:i}:{}}}}function K5({recorder:e,scope:t,held:n,surfaceKey:r,kind:i,children:a}){return(0,$5.jsxs)(MN,{scope:t,children:[(0,$5.jsx)(q5,{recorder:e,scope:t,held:n,surfaceKey:r,kind:i}),(0,$5.jsx)(J5,{recorder:e,surfaceKey:r,componentId:t.componentId}),a]})}function q5({recorder:e,scope:t,held:n,surfaceKey:r,kind:i}){return(0,e7.useEffect)(()=>{let a=n.places.get(t);return a!==void 0&&n.scopes.set(a,t),n.recorded.has(t)||(n.recorded.add(t),e.record({kind:`component`,name:`${i} "${t.componentId}"`,spanId:t.spanId,detail:{component:i}},{traceId:t.traceId,spanId:e.surfaceScope(r)?.spanId,surfaceId:t.surfaceId,componentId:t.componentId})),()=>{a!==void 0&&n.scopes.get(a)===t&&n.scopes.delete(a)}},[e,t,n,r,i]),null}function J5({recorder:e,surfaceKey:t,componentId:n}){let r=(0,e7.useSyncExternalStore)(e.onInspect,()=>{let r=e.inspected();return r!==void 0&&r.surfaceKey===t&&r.componentId===n?2:+!!e.picking()},()=>0);return r===0||n===void 0?null:(0,$5.jsx)(`template`,{[aN]:t,[oN]:n,...r===2?{[sN]:``}:{}})}function Y5({surface:e,catalog:t,renderers:n,onAction:r,onProblem:i,onDataChange:a,onControlsChange:o,onContext:s,frame:c,resolveImage:l,className:u}){let d=(0,e7.useMemo)(()=>P5(e),[e]),f=RN(),p=(0,e7.useRef)(void 0),m=(0,e7.useRef)(void 0),h=f?.keyOf(e),g=f?h??`${p.current??=lN(`v`)}:${d.surfaceId}`:void 0,_=(0,e7.useRef)(``);(0,e7.useLayoutEffect)(()=>{if(!f||h!==void 0||g===void 0)return;let e=G5(d),t=JSON.stringify(qM(e));t!==_.current&&(_.current=t,iN(f,{format:`surface`,key:g,raw:e,snapshot:!0,name:`surface`},{traceId:m.current??=XM()}))},[f,h,g,d]);let v=(0,e7.useRef)({scopes:new Map,places:new WeakMap,recorded:new WeakSet}),y=(e,t,n)=>{if(!f||g===void 0)return;let r=`${g}|${t}|${e}|${n}`,i=v.current.scopes.get(r);if(!i){let t=h!==void 0,n;i={spanId:ZM(),surfaceId:g,componentId:e,get traceId(){return n??=(t?f.surfaceScope(g)?.traceId:void 0)??(m.current??=XM())}},v.current.scopes.set(r,i),v.current.places.set(i,r)}return i},b=(0,e7.useRef)(new Map),x=(0,e7.useRef)([]),S=(e,t)=>f?.record({kind:`problem`,name:e.code,status:`error`,surfaceId:g,detail:{code:e.code,path:e.path,message:e.message}},t??(g===void 0?void 0:f.surfaceScope(g)));(0,e7.useEffect)(()=>{for(let{problem:e,scope:t}of x.current.splice(0))S(e,t)});let C=(e,t,n=!1)=>{f&&n?x.current.push({problem:e,scope:t}):S(e,t),i?.(e)},w=(0,e7.useRef)(o);w.current=o;let T=(0,e7.useRef)(s);T.current=s;let E=(0,e7.useMemo)(()=>{let e=new Map;for(let[t,n]of Object.entries(d.expects??{}))e.set(t,L8(n));return e},[d.expects]),[D,O]=(0,e7.useState)({surfaceId:d.surfaceId,values:[]}),k=D.surfaceId===d.surfaceId?D.values:[],ee=(0,e7.useMemo)(()=>k.reduce((e,[t,n])=>Q6(e,t,n),d.data),[d.data,k]),te=(0,e7.useRef)(a);te.current=a;let A=(0,e7.useRef)(!1);(0,e7.useEffect)(()=>{A.current&&te.current?.(ee),A.current=!1},[ee]);let ne=(0,e7.useCallback)((e,t,n)=>{f?.record({kind:`state`,name:`data.write`,surfaceId:g,detail:{path:e,value:t}},n),A.current=!0,O(n=>{let r=n.surfaceId===d.surfaceId?n.values.filter(([t])=>t!==e&&!t.startsWith(`${e}/`)):[];return{surfaceId:d.surfaceId,values:[...r,[e,t]]}})},[d.surfaceId,f,g]),re=(0,e7.useMemo)(()=>Object.fromEntries(Object.entries(t.functions).map(([e,t])=>[e,t.implementation])),[t]),ie=(0,e7.useMemo)(()=>new Map,[t]),ae=(0,e7.useMemo)(()=>new n7,[]),oe=(e,i,a,o=ee)=>{if(typeof e!=`string`)return null;let s=Object.hasOwn(d.components,e)?d.components[e]:void 0;if(!s)return null;if(a.includes(e)||a.length>a7)return(0,$5.jsx)(Q5,{text:`"${e}" contains itself.`},e);let l=y(e,i,s.component),u=ie.get(s);if(!u){u=t.validateComponent(s),ie.set(s,u);for(let t of u)C({code:`VALIDATION_FAILED`,surfaceId:d.surfaceId,path:`/${e}${t.path}`,message:t.message},l,!0)}let p=Object.hasOwn(n,s.component)?n[s.component]:void 0;if(u.length>0||!p)return(0,$5.jsx)(Q5,{text:u[0]?`${s.component} "${e}": ${u[0].path} ${u[0].message}`:`No renderer for ${s.component}.`},e);if(s.visibleWhen!==void 0&&!X6(s.visibleWhen,o,i))return null;let m={data:o,scope:i,functions:re},{id:h,component:_,action:x,child:S,children:D,visibleWhen:O,...k}=s,te=Object.fromEntries(Object.entries(k).filter(([e])=>!e.startsWith(`@`))),A=[...a,e],ae=(0,$5.jsx)(W5,{render:p,args:{props:e8(te,m),component:s,child:e=>oe(e,i,A,o),children:e=>{let t=e;if(Array.isArray(t))return t.map(e=>(0,$5.jsx)(Z5,{children:oe(e,i,A,o)},e));if(t&&typeof t==`object`&&typeof t.componentId==`string`){let e=$6(t.path,i),n=Z6(o,e);return Array.isArray(n)?n.map((n,r)=>(0,$5.jsx)(Z5,{children:oe(t.componentId,`${e===`/`?``:e}/${r}`,A,o)},r)):[]}return[]},rows:(t,n)=>n.map((n,r)=>{let i=`/${o7}/${e}/${r}`;return(0,$5.jsx)(Z5,{children:oe(t,i,A,Q6(o,i,n))},r)}),dispatch:(n,i)=>{let a=n;if(!a)return;if(`functionCall`in a){(Object.hasOwn(t.functions,a.functionCall[`@call`])?t.functions[a.functionCall[`@call`]]:void 0)?.action&&e8(a.functionCall,m);return}let o=t.components[s.component]?.events;if(o&&i){let t=new Set(Object.values(o).flatMap(e=>Object.keys(e.context??{})));for(let n of Object.keys(i))t.has(n)||C({code:`UNDECLARED_EVENT`,surfaceId:d.surfaceId,path:`/${e}`,message:`${s.component} sent "${n}", which its catalog entry does not declare.`},l);Object.values(o).some(e=>I8(e).safeParse(i).success)||C({code:`UNDECLARED_EVENT`,surfaceId:d.surfaceId,path:`/${e}`,message:`${s.component} sent values that do not match its catalog entry's event types.`},l)}let c=a.event.name,u=a.event.userMessage===void 0?void 0:e8(a.event.userMessage,m),p={...e8(a.event.context??{},m)??{},...i},h=E.get(c);if(h){let t=`error`in h?void 0:h.schema.safeParse(p);if(!t||!t.success){let n=t?t.error.issues.map(e=>`${e.path.join(`/`)||`context`}: ${e.message}`).join(`; `):`error`in h?h.error:``;f?.record({kind:`event`,name:c,status:`error`,detail:{type:`action`,context:p,contract:`failed`,reason:n,sent:!1}},l),C({code:`CONTRACT_FAILED`,surfaceId:d.surfaceId,path:`/${e}`,message:`"${c}" was not sent: it does not match what the agent expects. ${n}`},l);return}}f?.record({kind:`event`,name:c,status:r?`ok`:`warning`,detail:{type:`action`,context:p,contract:h?`passed`:`none`,sent:!!r,...typeof u==`string`&&u?{userMessage:u}:{}}},l),r?.({name:c,surfaceId:d.surfaceId,sourceComponentId:e,timestamp:new Date().toISOString(),context:p,...typeof u==`string`&&u?{userMessage:u}:{},...d.sendDataModel?{dataModel:ee}:{}})},setData:(e,t)=>{let n=typeof e==`string`?e:e&&typeof e==`object`&&typeof e[`@path`]==`string`?e[`@path`]:void 0;n!==void 0&&(n.startsWith(`/`)||!i.startsWith(`/${o7}/`))&&ne($6(n,i),t,l)},reportControls:t=>{if(f&&l){let n=`${i}|${e}`,r=b.current.get(n),a=JSON.stringify(qM(t));r!==a&&(b.current.set(n,a),f.record({kind:`state`,name:`controls`,detail:{controls:t,changed:EN(r===void 0?{}:JSON.parse(r),JSON.parse(a))}},l))}w.current?.(e,t)},reportContext:t=>{let n={kind:String(t.kind).slice(0,60),summary:String(t.summary).slice(0,400),...t.subject&&typeof t.subject==`object`?{subject:t.subject}:{}};f?.record({kind:`event`,name:`note: ${n.kind}`,detail:{type:`note`,...n,kept:!!T.current}},l),T.current?.(e,n)}}}),se=`${s.component} "${e}"`,ce=(0,$5.jsx)(s7,{label:se,component:s,onError:t=>C({code:`RENDER_FAILED`,surfaceId:d.surfaceId,path:`/${e}`,message:`${se} could not be drawn: ${t.message}`},l),children:ae},f&&l?void 0:`${e}:${s.component}`),le=f&&l&&g!==void 0?(0,$5.jsx)(K5,{recorder:f,scope:l,held:v.current,surfaceKey:g,kind:s.component,children:ce},`${e}:${s.component}`):ce,ue=typeof s.minHeight==`number`&&s.minHeight>0?s.minHeight:void 0,de=ue?(0,$5.jsx)(`div`,{className:`sf-surface-sized`,style:{minHeight:ue},children:le}):le;return(0,$5.jsx)(Z5,{children:c?c(s,de):de},e)},se=(0,$5.jsx)(`div`,{className:[`sf-surface`,`sf-container`,u].filter(Boolean).join(` `),"data-surface":d.surfaceId,children:(0,$5.jsx)(r7.Provider,{value:ae,children:Object.hasOwn(d.components,`root`)?oe(`root`,`/`,[]):null})}),ce=d.theme?(0,$5.jsx)(X5,{request:d.theme,children:se}):se;return l?(0,$5.jsx)(DL,{resolve:l,children:ce}):ce}function X5({request:e,children:t}){let n=RM(),r=n?.theme??Qj,i=JSON.stringify(e),a=n?.themes,o=(0,e7.useMemo)(()=>EM(e,r,{themes:a}),[i,r,a]),s=o.mode??n?.mode??`system`;return(0,$5.jsxs)(LM,{scope:`scoped`,storage:null,initialTheme:o.theme,initialMode:s,children:[o.problems.map(e=>(0,$5.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:e},e)),t]},`${i}:${JSON.stringify(r)}:${s}`)}function Z5({children:e}){let t=(0,e7.useContext)(t7);return(0,$5.jsx)(t7.Provider,{value:t+1,children:e})}function Q5({text:e}){return(0,$5.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:e})}var $5,e7,t7,n7,r7,i7,a7,o7,s7,c7=n((()=>{$5=WA(),e7=NM(),jN(),zN(),jM(),K8(),S8(),F5(),t7=(0,e7.createContext)(0),n7=class{fields=new Map;shown=new Set;version=0;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});read=()=>this.version;changed(){this.version++;for(let e of[...this.listeners])e()}set(e,t){let n=this.fields.get(e);this.fields.set(e,t),n&&n.problem===t.problem&&n.label===t.label||this.changed()}remove(e,t){this.fields.get(e)?.element===t&&(this.fields.delete(e),this.changed())}show(e){for(let t of e)this.shown.add(t);this.changed()}},r7=(0,e7.createContext)(void 0),i7={subscribe:()=>()=>{},read:()=>0},a7=48,o7=`@rows`,s7=class extends e7.Component{state={};static getDerivedStateFromError(e){return{failed:e instanceof Error?e.message:String(e)}}static getDerivedStateFromProps(e,t){return t.of===e.component?null:{of:e.component,...t.of?{failed:void 0}:{}}}componentDidCatch(e){this.props.onError(e)}render(){return this.state.failed===void 0?this.props.children:(0,$5.jsx)(Q5,{text:`${this.props.label} could not be drawn: ${this.state.failed}`})}}}));function l7(e,t){let n={},r=t.gap?R5(e.gap):void 0,i=t.padding?R5(e.padding):void 0;return r!==void 0&&(n[`data-gap`]=String(r)),i!==void 0&&(n[`data-padding`]=String(i)),n}var u7=n((()=>{V5()}));function d7({type:e,extra:t,props:n,component:r,setData:i}){let[a,o]=(0,g7.useState)(!1),s={name:r.id,label:_7(n.label),type:e,help:_7(n.help)||void 0,placeholder:_7(n.placeholder)||void 0,required:n.required===!0||void 0,...t?.(n)},c=s.type===`boolean`&&s.required&&n.value!==!0?`${s.label} is required.`:eC(ZV(`field`,[{...s,name:`value`}]),{value:n.value??null}).errors[0]?.message,l=H5(r.id,s.label,c),u=a||l.shown?c:void 0;return(0,h7.jsx)(`div`,{className:`sf-a2-field`,ref:l.ref,onBlur:()=>o(!0),children:(0,h7.jsx)(QV,{field:s,value:n.value,error:u,onChange:e=>i(r.value,e)})})}function f7(e,t){return n=>(0,h7.jsx)(d7,{...n,type:e,extra:t})}function p7({props:e,component:t,setData:n}){let r=(0,g7.useId)(),i=v7(e.min)??0,a=v7(e.max)??100,o=v7(e.value)??i;return(0,h7.jsxs)(`div`,{className:`sf-form-field`,children:[(0,h7.jsxs)(`label`,{className:`sf-form-label`,htmlFor:r,children:[_7(e.label),`: `,(0,h7.jsx)(`output`,{htmlFor:r,children:o})]}),(0,h7.jsx)(`input`,{id:r,className:`sf-form-slider`,type:`range`,min:i,max:a,step:v7(e.step)??1,value:o,"aria-describedby":e.help?`${r}-help`:void 0,onChange:e=>n(t.value,Number(e.target.value))}),e.help!=null&&(0,h7.jsx)(`p`,{id:`${r}-help`,className:`sf-form-help`,children:_7(e.help)})]})}function m7({props:e,component:t,dispatch:n,setData:r}){let i=t.values!=null,a=_7(e.formId);return(0,h7.jsx)($V,{formId:a,title:_7(e.title)||void 0,description:_7(e.description)||void 0,fields:e.fields??[],submitLabel:_7(e.submitLabel)||void 0,values:i?e.values&&typeof e.values==`object`?e.values:{}:void 0,onValuesChange:i?e=>r(t.values,e):void 0,onSubmit:e=>n(t.action,{formId:a,values:e.values,submissionId:e.submissionId??``})})}var h7,g7,_7,v7,y7,b7=n((()=>{h7=WA(),zG(),rw(),g7=NM(),c7(),_7=e=>e==null||typeof e==`object`?``:String(e),v7=e=>typeof e==`number`?e:void 0,y7={TextField:f7(`text`,e=>({type:e.multiline===!0?`longtext`:`text`,maxLength:v7(e.maxLength),pattern:_7(e.pattern)||void 0})),NumberField:f7(`number`,e=>({min:v7(e.min),max:v7(e.max),step:v7(e.step)})),ChoicePicker:f7(`choice`,e=>({options:Array.isArray(e.options)?e.options.map(_7):[]})),CheckBox:f7(`boolean`),DateTimeInput:f7(`date`,e=>({type:e.mode===`datetime`?`datetime`:`date`})),Slider:p7,Form:m7}}));function x7(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e,n={speaker:E7(t.speaker),text:E7(t.text)};return t.side===`end`&&(n.side=`end`),E7(t.time)!==``&&(n.time=E7(t.time)),[n]}):[]}function S7(e,t){let n=e=>`${e.side===`end`?`end`:`start`}\u0000${e.speaker}\u0000${e.text}`,r=new Map;for(let t of e)r.set(n(t),(r.get(n(t))??0)+1);return t.filter(e=>{let t=r.get(n(e))??0;return t===0||(r.set(n(e),t-1),!1)})}function C7({props:e,component:t,dispatch:n}){let r=x7(e.messages),[i,a]=(0,T7.useState)([]),o=[...r,...S7(r,i)],s=E7(e.you)||`You`,c=Array.isArray(e.replies)?x7(e.replies):[],[l,u]=(0,T7.useState)(0),[d,f]=(0,T7.useState)(``),[p,m]=(0,T7.useState)(),h=(0,T7.useRef)(null),g=(0,T7.useRef)(void 0),_=(0,T7.useId)();(0,T7.useEffect)(()=>()=>clearTimeout(g.current),[]),(0,T7.useEffect)(()=>{let e=h.current;e&&(e.scrollTop=e.scrollHeight)},[o.length,p]);let v=e=>a(t=>[...t,e]),y=e=>{let r=e.trim();if(r===``)return;v({speaker:s,text:r,side:`end`,time:D7()}),f(``);let i=c[l];u(e=>e+1),n(t.action,{text:r}),i&&(m(i.speaker),clearTimeout(g.current),g.current=setTimeout(()=>{m(void 0),v({...i,side:`start`,time:D7()})},700))},b=e=>{e.preventDefault(),y(d)},x=e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),y(d))},S=l===0&&Array.isArray(e.suggestions)?e.suggestions.map(E7).filter(e=>e!==``):[],C=E7(e.label)||`Conversation`;return(0,w7.jsxs)(`section`,{className:`sf-a2-conversation`,"aria-label":C,children:[(0,w7.jsxs)(`div`,{ref:h,className:`sf-a2-conversation-thread`,role:`log`,"aria-live":`polite`,tabIndex:0,"aria-label":`${C}: messages`,children:[o.map((e,t)=>(0,w7.jsxs)(`div`,{className:`sf-a2-message`,"data-side":e.side===`end`?`end`:`start`,children:[(0,w7.jsxs)(`p`,{className:`sf-a2-message-who`,children:[(0,w7.jsx)(`b`,{children:e.speaker}),e.time&&(0,w7.jsx)(`span`,{children:e.time})]}),(0,w7.jsx)(`div`,{className:`sf-a2-message-body`,children:(0,w7.jsx)(HL,{text:e.text})})]},t)),p!==void 0&&(0,w7.jsxs)(`p`,{className:`sf-a2-conversation-waiting`,children:[p,` is writing…`]})]}),S.length>0&&(0,w7.jsx)(`div`,{className:`sf-a2-chips`,role:`group`,"aria-label":`Suggested replies`,children:S.map(e=>(0,w7.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>y(e),children:e},e))}),(0,w7.jsxs)(`form`,{className:`sf-a2-conversation-composer`,onSubmit:b,children:[(0,w7.jsx)(`label`,{className:`sf-visually-hidden`,htmlFor:_,children:`Message`}),(0,w7.jsx)(`textarea`,{id:_,className:`sf-input`,rows:1,value:d,placeholder:E7(e.placeholder)||`Write a message`,onChange:e=>f(e.target.value),onKeyDown:x}),(0,w7.jsx)(`button`,{type:`submit`,className:`sf-button`,"data-variant":`primary`,disabled:d.trim()===``,children:`Send`})]})]})}var w7,T7,E7,D7,O7=n((()=>{w7=WA(),zG(),T7=NM(),E7=e=>e==null||typeof e==`object`?``:String(e),D7=()=>new Date().toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}));function k7({name:e,draw:t}){let n=typeof e==`string`&&e?e:void 0,r=ZW(n);return n?r.model?(0,Q.jsx)(Q.Fragment,{children:t(r)}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:r.problem??`Loading the semantic model “${n}”…`}):(0,Q.jsx)(Q.Fragment,{children:t(void 0)})}function A7({props:e,component:t,dispatch:n,reportControls:r,reportContext:i}){let a=e.proposed&&typeof e.proposed==`object`?e.proposed:void 0,o=e.create&&typeof e.create==`object`?e.create:void 0,s=$(e.proposedBy)||`the agent`,c=typeof e.model==`string`?e.model:``,l=ZW(c||void 0),u=JSON.stringify([a??null,o??null]),d={proposal:a,by:s,component:t,dispatch:n,reportControls:r,reportContext:i};if(l.model)return(0,Q.jsx)(j7,{state:l,model:l.model,...d},`${u}:${l.model.version}`);if(o&&l.missing){let e=tW({name:c,label:o.label??``,description:o.description??``,sourceId:o.sourceId??``});return(0,Q.jsx)(j7,{state:l,model:e,...d},u)}return(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:l.problem??`Loading the semantic model “${c}”…`})}function j7({state:e,model:t,proposal:n,by:r,component:i,dispatch:a,reportControls:o,reportContext:s}){let c=t.version===0,[l,u]=(0,K7.useState)(()=>{if(!n)return c?t:void 0;let e=TG(t,n,r);return c||eW(t,e).size>0?e:void 0}),d=e=>o({proposed:e?EG(t,e):null}),f=i.action==null?void 0:e=>a(i.action,{text:e});return(0,Q.jsx)(gG,{model:t,draft:l,proposedBy:l&&n?r:void 0,problem:e.problem&&!e.missing?e.problem:void 0,building:c&&!n?.rows,onDraftChange:e=>{u(e),d(e)},onAsk:f,onSave:async(n,r)=>{let o=Object.fromEntries(eW(t,n)),s=await e.save(n,r);return s&&i.action!=null&&a(i.action,{model:s.name,version:s.version,changes:o}),s},onContext:s})}function M7({component:e,dispatch:t,setData:n}){return(r,i={})=>{r&&(e.opened!=null&&n(e.opened,r),t(e.action,{table:r,...i}))}}function N7({props:e,component:t,dispatch:n,reportControls:r,reportContext:i}){let a={...typeof e.title==`string`&&e.title?{title:e.title}:{},fields:Array.isArray(e.fields)?e.fields.map(e=>e.by?e:{...e,by:`the agent`}):[],filters:Array.isArray(e.filters)?e.filters:[],tiles:Array.isArray(e.tiles)?e.tiles:[],...e.draft&&typeof e.draft==`object`?{draft:e.draft}:{}},o=JSON.stringify(a),[s,c]=(0,K7.useState)(a);return(0,K7.useEffect)(()=>c(a),[o]),(0,Q.jsx)(k7,{name:e.model,draw:a=>(0,Q.jsx)(GW,{sourceId:$(e.sourceId)||void 0,sql:$(e.sql)||void 0,model:a?.model,onPromote:a?.promote,value:s,mode:e.mode===`build`||e.mode===`view`?e.mode:void 0,onContext:i,onChange:e=>{c(e),r({title:e.title??null,fields:e.fields,filters:e.filters,tiles:e.tiles,...e.draft?{draft:e.draft}:{}})},onAsk:t.action==null?void 0:e=>n(t.action,{text:e})})})}function P7({props:e,component:t,dispatch:n,reportControls:r,reportContext:i}){let a={fields:Array.isArray(e.fields)?e.fields.map(e=>e.by?e:{...e,by:`the agent`}):[],rows:Array.isArray(e.rows)?e.rows:[],...typeof e.split==`string`&&e.split?{split:e.split}:{},values:Array.isArray(e.values)?e.values:[],filters:Array.isArray(e.filters)?e.filters:[],...e.view===`chart`||e.view===`table`?{view:e.view}:{},...e.chart&&typeof e.chart==`object`?{chart:e.chart}:{}},o=JSON.stringify(a),[s,c]=(0,K7.useState)(a);return(0,K7.useEffect)(()=>c(a),[o]),(0,Q.jsx)(k7,{name:e.model,draw:a=>(0,Q.jsx)(yW,{sourceId:$(e.sourceId)||void 0,sql:$(e.sql)||void 0,model:a?.model,onPromote:a?.promote,value:s,onChange:e=>{c(e),r({fields:e.fields,rows:e.rows,split:e.split??null,values:e.values,filters:e.filters,...e.view?{view:e.view}:{},chart:e.chart??null})},onContext:i,onAsk:t.action==null?void 0:e=>n(t.action,{text:e})})})}function F7({props:e,child:t,reportControls:n}){let r=(e.panels??[]).map(e=>({id:e.id,title:$(e.title)||e.id,...e.short?{shortTitle:$(e.short)}:{},...e.icon?{icon:e.icon}:{},content:t(e.child)})),i=JSON.stringify(e.layout??null),[a,o]=(0,K7.useState)(e.layout),s=(0,K7.useRef)(i);return(0,K7.useEffect)(()=>{s.current!==i&&(s.current=i,o(e.layout))},[i,e.layout]),(0,Q.jsx)(DH,{label:$(e.label)||`Panels`,panels:r,layout:a,rail:e.rail===`none`?!1:e.rail===`left`?`left`:`right`,defaultRailLabels:e.railLabels===!0,height:typeof e.height==`number`?e.height:520,onLayoutChange:e=>{o(e),n({layout:e})}})}function I7({children:e}){return NF()?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:`This needs a discovery backend: wrap the page in DiscoveryProvider.`})}function L7({props:e,component:t,dispatch:n}){let r=e.options??[],[i,a]=(0,K7.useState)();return(0,Q.jsxs)(`section`,{className:`sf-a2-decision`,"aria-label":$(e.title),children:[(0,Q.jsx)(`p`,{className:`sf-a2-decision-title`,children:$(e.title)}),e.detail!=null&&(0,Q.jsx)(`p`,{className:`sf-a2-decision-detail`,children:$(e.detail)}),(0,Q.jsx)(`div`,{className:`sf-a2-decision-options`,children:r.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:`sf-a2-decision-option`,"aria-pressed":i===e.id,disabled:i!==void 0,onClick:()=>{a(e.id),n(t.action,{choice:e.id,label:e.label})},children:[(0,Q.jsxs)(`span`,{className:`sf-a2-decision-label`,children:[e.label,e.recommended&&(0,Q.jsx)(`span`,{className:`sf-schema-tag`,children:`Recommended`})]}),e.description&&(0,Q.jsx)(`span`,{className:`sf-a2-decision-description`,children:e.description})]},e.id))}),i!==void 0&&(0,Q.jsxs)(`p`,{className:`sf-a2-decision-detail`,role:`status`,children:[`You chose `,r.find(e=>e.id===i)?.label,`.`]})]})}function R7({props:e,component:t,dispatch:n}){let r=$(e.sql),[i,a]=(0,K7.useState)();return(0,Q.jsxs)(`section`,{className:`sf-a2-proposal`,"aria-label":$(e.title)||`Proposed SQL`,children:[e.title!=null&&(0,Q.jsx)(`p`,{className:`sf-a2-decision-title`,children:$(e.title)}),(0,Q.jsx)(VL,{code:r,language:`sql`,onRun:e=>{a(new Date().toISOString()),n(t.action,{sql:e})}}),i?(0,Q.jsx)(XL,{sourceId:$(e.sourceId),sql:r,notBefore:i,height:320}):(0,Q.jsx)(`p`,{className:`sf-a2-decision-detail`,children:`Proposed by the agent. It has not been run.`})]})}function z7({props:e,component:t,dispatch:n}){let[r,i]=(0,K7.useState)($(e.sql)),a=e=>n(t.action,{sql:e});return(0,Q.jsxs)(`div`,{className:`sf-a2-editor`,children:[(0,Q.jsx)(DF,{value:r,onChange:i,onRun:a,dialect:$(e.dialect)||`standard`,minHeight:100}),t.action!=null&&(0,Q.jsx)(`button`,{type:`button`,className:`sf-button`,"data-variant":`primary`,onClick:()=>a(r),children:`Run`})]})}function B7({props:e}){let[t,n]=(0,K7.useState)(()=>(e.tables??[]).reduce((e,t)=>bR(e,t.sourceId,t.table),{...TR,name:$(e.name)}));return(0,Q.jsx)(SR,{value:t,onChange:n})}function V7({children:e}){return IB()?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:`This needs a pipeline backend: wrap the page in PipelinesProvider.`})}function H7({props:e}){let[t,n]=(0,K7.useState)({...rV,location:$(e.location),format:$(e.format)||`parquet`});return(0,Q.jsx)(eV,{sourceId:$(e.sourceId),value:t,onChange:n})}function U7({props:e,component:t,dispatch:n,reportContext:r}){let i=JSON.stringify(e.pipeline??null),[a,o]=(0,K7.useState)({});return(0,K7.useEffect)(()=>{try{o({draft:ib(Zx,JSON.parse(i),{ignoreUnknownFields:!1})})}catch(e){o({problem:`The proposed pipeline could not be read: ${e instanceof Error?e.message:String(e)}`})}},[i]),a.problem?(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:a.problem}):a.draft?(0,Q.jsx)(jB,{pipeline:a.draft,dataset:$(e.dataset),expectedVersion:typeof e.expectedVersion==`number`?e.expectedVersion:0,digest:$(e.digest)||void 0,proposedBy:$(e.proposedBy)||void 0,onDecide:e=>n(t.action,{...e}),onContext:r}):null}function W7({props:e,action:t,dispatch:n}){let[r,i]=(0,K7.useState)();return(0,Q.jsx)(oB,{nodes:e.nodes??[],edges:e.edges??[],height:typeof e.height==`number`?e.height:320,selected:r,onSelect:e=>{i(e.id),n(t,{id:e.id,name:e.name})}})}function G7({props:e}){let t=RM(),n=JSON.stringify(e),[r,i]=(0,K7.useState)(),[a,o]=(0,K7.useState)(),s=(0,K7.useRef)(t);return s.current=t,(0,K7.useEffect)(()=>{let t=s.current;if(!t)return;let{id:n,component:r,...a}=e,c=EM(a,t.theme,{themes:t.themes});i({theme:t.theme,mode:t.mode}),t.setTheme(c.theme),c.mode&&t.setMode(c.mode),o({text:`The page now uses ${c.theme.name}${c.mode?`, ${c.mode}`:``}.`,problems:c.problems})},[n]),t?(0,Q.jsxs)(`div`,{className:`sf-a2-theme-switch`,role:`status`,children:[(0,Q.jsx)(`span`,{children:a?.text??`Changing the theme…`}),a?.problems.map(e=>(0,Q.jsx)(`span`,{className:`sf-object-muted`,children:e},e)),r&&(0,Q.jsx)(`button`,{type:`button`,className:`sf-button`,onClick:()=>{t.setTheme(r.theme),t.setMode(r.mode),i(void 0),o({text:`Theme change undone.`,problems:[]})},children:`Undo`})]}):(0,Q.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:`The theme cannot be changed here: this page has no ThemeProvider.`})}var Q,K7,$,q7,J7,Y7,X7=n((()=>{Q=WA(),zG(),zb(),vS(),jM(),K7=NM(),F8(),u9(),O7(),u7(),$=e=>e==null||typeof e==`object`?``:String(e),q7=e=>e.map(e=>({column:e.column,direction:e.desc===!0?ax.DESC:ax.ASC})),J7=new Set([`start`,`center`,`end`,`stretch`]),Y7={Grid:({props:e,component:t,children:n})=>{let r=typeof e.columns==`number`?e.columns:2,i=Array.isArray(e.widths)&&e.widths.length===r&&e.widths.every(e=>typeof e==`number`&&e>0)?e.widths:void 0,a=typeof e.align==`string`&&J7.has(e.align)?e.align:void 0;return(0,Q.jsx)(`div`,{className:`sf-a2-grid`,"data-align":a,"data-arrange-container":!0,"data-widths":i?!0:void 0,...l7(e,{gap:!0}),style:{"--sf-grid-columns":r,...a?{alignItems:a}:{},...i?{"--sf-grid-template":i.map(e=>`minmax(0, ${e}fr)`).join(` `)}:{}},children:n(t.children)})},Metric:({props:e})=>Z7(e.filters,t=>(0,Q.jsx)(Xz,{filters:t,sourceId:$(e.sourceId),sql:$(e.sql),column:$(e.column)||void 0,aggregate:e.aggregate,percentile:typeof e.percentile==`number`?e.percentile:void 0,label:$(e.label),format:$(e.format)||void 0,currency:$(e.currency)||void 0,emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),Message:({props:e})=>(0,Q.jsxs)(`div`,{className:`sf-a2-message`,"data-side":e.side===`end`?`end`:`start`,children:[(0,Q.jsxs)(`p`,{className:`sf-a2-message-who`,children:[(0,Q.jsx)(`b`,{children:$(e.speaker)}),e.time!=null&&$(e.time)!==``&&(0,Q.jsx)(`span`,{children:$(e.time)})]}),(0,Q.jsx)(`div`,{className:`sf-a2-message-body`,children:(0,Q.jsx)(HL,{text:$(e.text)})})]}),Conversation:e=>(0,Q.jsx)(C7,{...e}),RowList:({props:e,component:t,rows:n,reportContext:r})=>Z7(e.filters,i=>(0,Q.jsx)(eB,{sourceId:$(e.sourceId),sql:$(e.sql),label:$(e.label)||`Rows`,filters:i,sorts:Array.isArray(e.sorts)?q7(e.sorts):void 0,pageSize:typeof e.pageSize==`number`?e.pageSize:void 0,rowKey:$(e.rowKey)||void 0,layout:e.layout===`grid`?`grid`:`list`,onContext:r,renderRow:(e,r)=>n(t.child,[e]).map(e=>(0,Q.jsx)(K7.Fragment,{children:e},r)),emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),Markdown:({props:e})=>(0,Q.jsx)(HL,{text:$(e.text)}),Image:({props:e})=>(0,Q.jsx)(jL,{src:$(e.src),alt:$(e.alt),caption:$(e.caption)||void 0,width:typeof e.width==`number`?e.width:void 0,height:typeof e.height==`number`?e.height:void 0,fit:e.fit===`cover`?`cover`:`contain`,maxHeight:typeof e.maxHeight==`number`?e.maxHeight:void 0}),CodeBlock:({props:e})=>(0,Q.jsx)(VL,{code:$(e.code),language:$(e.language)||void 0}),Table:({props:e})=>{let t=e.columns??[],n=e.rows??[];return(0,Q.jsx)(`div`,{className:`sf-markdown-table sf-a2-table`,children:(0,Q.jsxs)(`table`,{children:[e.caption!=null&&(0,Q.jsx)(`caption`,{children:$(e.caption)}),(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{children:t.map((e,t)=>(0,Q.jsx)(`th`,{scope:`col`,children:$(e)},t))})}),(0,Q.jsx)(`tbody`,{children:n.map((e,n)=>(0,Q.jsx)(`tr`,{children:t.map((t,n)=>(0,Q.jsx)(`td`,{"data-numeric":typeof e[n]==`number`||void 0,children:$(e[n])},n))},n))})]})})},Link:({props:e})=>{let t=M8(e.url);return t?(0,Q.jsx)(`a`,{className:`sf-a2-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:$(e.text)}):(0,Q.jsx)(`span`,{children:$(e.text)})},Checklist:({props:e})=>(0,Q.jsx)(`ul`,{className:`sf-a2-checklist`,children:(e.items??[]).map((e,t)=>(0,Q.jsxs)(`li`,{"data-done":e.done||void 0,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:e.done?`✓`:`○`}),(0,Q.jsxs)(`span`,{children:[$(e.label),(0,Q.jsx)(`span`,{className:`sf-a2-visually-hidden`,children:e.done?` (done)`:` (to do)`})]})]},t))}),Chips:({props:e,component:t,dispatch:n,setData:r})=>{let i=(e.items??[]).map(e=>typeof e==`string`?{label:e,value:e}:e),a=t.selected!=null;return(0,Q.jsx)(`div`,{className:`sf-a2-chips`,role:a?`group`:void 0,children:i.map(i=>(0,Q.jsx)(`button`,{type:`button`,className:`sf-button`,"aria-pressed":a?e.selected===i.value:void 0,onClick:()=>{a&&r(t.selected,i.value),n(t.action,{value:i.value})},children:i.label},`${i.label}\u0000${i.value}`))})},Workspace:e=>(0,Q.jsx)(F7,{...e}),SideNav:({props:e,component:t,dispatch:n})=>{let r=(e.groups??[]).map(e=>({...e.label?{label:e.label}:{},items:(e.items??[]).map(e=>({id:e.id,label:e.label,...e.href&&M8(e.href)?{href:M8(e.href)}:{}}))}));return(0,Q.jsx)(zH,{className:`sf-a2-sidenav`,label:$(e.label)||`Sections`,groups:r,current:$(e.current)||void 0,defaultPinned:e.pinned!==!1,onSelect:e=>{r.some(t=>t.items.some(t=>t.id===e&&t.href))||n(t.action,{id:e})}})},DecisionCard:e=>(0,Q.jsx)(L7,{...e}),SqlProposal:e=>(0,Q.jsx)(R7,{...e}),SqlEditor:e=>(0,Q.jsx)(z7,{...e}),ObjectBrowser:e=>{let t=M7(e);return(0,Q.jsx)(aI,{sourceId:$(e.props.sourceId),height:typeof e.props.height==`number`?e.props.height:360,onSelect:e=>(e.kind===`table`||e.kind===`column`||e.kind===`join`)&&t(e.table??``,{column:e.column??``})})},Explorer:e=>(0,Q.jsx)(P7,{...e}),SemanticModelEditor:e=>(0,Q.jsx)(A7,{...e}),ReportBuilder:e=>(0,Q.jsx)(N7,{...e}),FilterBar:({props:e,component:t,setData:n,dispatch:r,reportControls:i,reportContext:a})=>(0,Q.jsx)(hU,{sourceId:$(e.sourceId),sql:$(e.sql),filters:Array.isArray(e.filters)?e.filters:[],columns:Array.isArray(e.columns)?e.columns:void 0,onContext:a,onChange:e=>{n(t.filters,e),i({filters:e}),t.action!=null&&r(t.action,{filters:e})}}),FileBrowser:({props:e,component:t,dispatch:n,reportContext:r})=>(0,Q.jsx)(lU,{sourceId:$(e.sourceId)||void 0,local:e.local===!0,onContext:r,height:typeof e.height==`number`?e.height:360,onOpen:t.action==null?void 0:(e,r)=>n(t.action,{path:e.path,name:e.name,place:r.id,format:e.format??``})}),ModelDiagram:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(Tz,{sourceId:$(e.sourceId),tables:e.tables??[],joins:e.joins??[],rowsFrom:e.rowsFrom===!0,suggestJoins:e.suggest!==!1,height:typeof e.height==`number`?e.height:360,onUseSql:t.action==null?void 0:(e,r)=>n(t.action,{sql:e,tables:r.tables,joins:r.joins})}),DataSearch:e=>{let t=M7(e);return(0,Q.jsx)(I7,{children:(0,Q.jsx)(lR,{sourceIds:$(e.props.sourceId)?[$(e.props.sourceId)]:void 0,height:typeof e.props.height==`number`?e.props.height:void 0,onOpen:e=>t(e.ref?.table??``,{column:e.ref?.column??``})})})},ObjectDetail:e=>{let t=M7(e),n=$(e.props.table);return(0,Q.jsx)(I7,{children:n?(0,Q.jsx)(gR,{objectRef:IF($(e.props.sourceId),n),onOpen:e=>t(e.ref?.table??``)},n):(0,Q.jsx)(`p`,{className:`sf-search-empty`,children:`Open a table to see what is known about it.`})})},RelationshipGraph:e=>{let t=M7(e),n=$(e.props.table);return(0,Q.jsx)(I7,{children:n?(0,Q.jsx)(OR,{objectRef:IF($(e.props.sourceId),n),onOpen:e=>t(e.ref?.table??``)},n):null})},NodeGraph:({props:e,component:t,dispatch:n,setData:r,reportContext:i})=>{let a=e.levels!==null&&typeof e.levels==`object`?e.levels:void 0;return(0,Q.jsx)(HR,{label:$(e.label),nodes:Array.isArray(e.nodes)?e.nodes:[],links:Array.isArray(e.links)?e.links:[],...$(e.selected)?{selected:$(e.selected)}:{},...Array.isArray(e.groups)?{groups:e.groups}:{},...a?{levels:a}:{},...$(e.noun)?{noun:$(e.noun)}:{},...typeof e.height==`number`?{height:e.height}:{},onSelect:e=>{t.selected!==null&&typeof t.selected==`object`&&r(t.selected,e),t.action!=null&&n(t.action,{node:e})},onContext:i})},AskData:({props:e})=>(0,Q.jsx)(I7,{children:(0,Q.jsx)(qR,{sourceIds:$(e.sourceId)?[$(e.sourceId)]:void 0,contextPackId:$(e.contextPackId)||void 0})}),Sparkline:({props:e})=>Z7(e.filters,t=>(0,Q.jsx)(pV,{filters:t,sourceId:$(e.sourceId),sql:$(e.sql),x:$(e.x),grain:e.grain,column:$(e.column)||void 0,aggregate:e.aggregate,label:$(e.label),format:$(e.format)||void 0,currency:$(e.currency)||void 0,points:typeof e.points==`number`?e.points:void 0,emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),BulletGraph:({props:e})=>Z7(e.filters,t=>(0,Q.jsx)(bV,{filters:t,sourceId:$(e.sourceId),sql:$(e.sql),column:$(e.column)||void 0,aggregate:e.aggregate,label:$(e.label),target:typeof e.target==`number`?e.target:void 0,ranges:e.ranges??[],format:$(e.format)||void 0,currency:$(e.currency)||void 0,emptyMessage:$(e.emptyMessage)||void 0,errorMessage:$(e.errorMessage)||void 0})),StepFlow:({props:e})=>(0,Q.jsx)(BV,{label:$(e.label),steps:e.steps??[]}),PlanReview:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(CV,{title:$(e.title),summary:$(e.summary)||void 0,proposedBy:$(e.proposedBy)||void 0,steps:e.steps??[],onDecide:e=>n(t.action,{...e})}),ActionReceipt:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(WV,{title:$(e.title),outcome:$(e.outcome)||`done`,summary:$(e.summary)||void 0,ranAt:$(e.ranAt)||void 0,ranBy:$(e.ranBy)||void 0,approvedBy:e.approvedBy??[],sql:$(e.sql)||void 0,changes:e.changes??[],undo:e.undo,onUndo:t.action?()=>n(t.action,{}):void 0}),PiiReview:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(PV,{table:$(e.table),purpose:$(e.purpose)||void 0,columns:e.columns??[],onDecide:e=>n(t.action,{...e})}),ThemeSwitch:({props:e})=>(0,Q.jsx)(G7,{props:e}),QueryPlan:({props:e})=>(0,Q.jsx)(rL,{sourceId:$(e.sourceId),sql:$(e.sql)}),SourceList:()=>(0,Q.jsx)(Hz,{}),PipelineGraph:({props:e,component:t,dispatch:n})=>(0,Q.jsx)(W7,{props:e,action:t.action,dispatch:n}),PipelineView:({props:e,component:t,dispatch:n,reportContext:r})=>(0,Q.jsx)(V7,{children:(0,Q.jsx)(UB,{pipelineId:$(e.pipelineId),onRun:t.action==null?void 0:({kind:e,...r})=>n(t.action,{...r,event:e}),onContext:r})}),DatasetReview:e=>(0,Q.jsx)(U7,{...e}),IngestWizard:({props:e})=>(0,Q.jsx)(V7,{children:(0,Q.jsx)(H7,{props:e})}),RunHistory:({props:e})=>(0,Q.jsx)(cB,{runs:e.runs??[]}),ExpectationsPanel:({props:e})=>(0,Q.jsx)(lB,{expectations:e.expectations??[]}),SchemaDiff:({props:e})=>(0,Q.jsx)(dB,{changes:e.changes??[],rescuedCount:typeof e.rescuedCount==`number`?e.rescuedCount:void 0,mode:$(e.mode)||void 0}),StreamMetrics:({props:e})=>(0,Q.jsx)(pB,{progress:e.progress??[]}),ContextBuilder:e=>(0,Q.jsx)(I7,{children:(0,Q.jsx)(B7,{...e})})}}));function Z7(e,t){if(!Array.isArray(e))return t(void 0);try{return t(LC(e))}catch(e){return(0,r9.jsx)(`p`,{className:`sf-surface-notice`,role:`note`,children:e instanceof Error?e.message:`The filters could not be read.`})}}function Q7(e,t){let[n,r]=(0,i9.useState)(e??t),i=JSON.stringify(e??null);return(0,i9.useEffect)(()=>{e!==void 0&&r(e)},[i]),[n,r]}function $7({props:e,filters:t,reportControls:n}){let[r,i]=Q7(Array.isArray(e.sorts)?RC(e.sorts):void 0,[]),[a,o]=Q7(e.columns,{});return(0,r9.jsx)(CP,{sourceId:a9(e.sourceId),sql:a9(e.sql),mode:e.mode===`pages`?`pages`:`scroll`,height:typeof e.height==`number`?e.height:360,label:a9(e.label)||void 0,filters:t,sorts:r,onSortsChange:e=>{i(e),n({sorts:HC(e),columns:a})},columns:a,onColumnsChange:e=>{o(e),n({sorts:HC(r),columns:e})},emptyMessage:a9(e.emptyMessage)||void 0,errorMessage:a9(e.errorMessage)||void 0})}function e9(e){return{justifyContent:o9[a9(e.justify)]??`flex-start`,alignItems:s9[a9(e.align)]??`stretch`}}function t9({props:e,component:t,child:n,dispatch:r}){let i=U5(e.requires),[a,o]=(0,i9.useState)(!1),s=i.waiting.length>0;return(0,r9.jsxs)(r9.Fragment,{children:[(0,r9.jsx)(`button`,{type:`button`,className:`sf-button sf-a2-button`,"data-variant":a9(e.variant)||`default`,"aria-disabled":s||void 0,onClick:()=>{s?(o(!0),i.show()):r(t.action)},children:n(t.child)}),s&&a&&(0,r9.jsx)(`span`,{className:`sf-visually-hidden`,role:`status`,children:i.waiting.length===1?`Nothing was sent. ${i.waiting[0].problem}`:`Nothing was sent. ${i.waiting.length} fields need attention: ${i.waiting.map(e=>e.label).join(`, `)}.`})]})}function n9({props:e,child:t}){let n=e.tabs??[],[r,i]=(0,i9.useState)(0),a=(0,i9.useId)(),o=Math.min(r,n.length-1);return(0,r9.jsxs)(`div`,{className:`sf-a2-tabs`,children:[(0,r9.jsx)(`div`,{className:`sf-segmented sf-a2-tablist`,role:`tablist`,children:n.map((e,t)=>(0,r9.jsx)(`button`,{type:`button`,role:`tab`,id:`${a}-tab-${t}`,"aria-selected":t===o,"aria-controls":`${a}-panel`,className:`sf-segment`,"data-checked":t===o||void 0,onClick:()=>i(t),children:a9(e.title)},t))}),(0,r9.jsx)(`div`,{role:`tabpanel`,id:`${a}-panel`,"aria-labelledby":`${a}-tab-${o}`,children:t(n[o]?.child)})]})}var r9,i9,a9,o9,s9,c9,l9,u9=n((()=>{r9=WA(),zG(),i9=NM(),l5(),V5(),u7(),c7(),b7(),X7(),a9=e=>e==null||typeof e==`object`?``:String(e),o9={start:`flex-start`,center:`center`,end:`flex-end`,spaceBetween:`space-between`,spaceAround:`space-around`,spaceEvenly:`space-evenly`,stretch:`stretch`},s9={start:`flex-start`,center:`center`,end:`flex-end`,stretch:`stretch`},c9={h1:`h2`,h2:`h3`,h3:`h4`,h4:`h5`,h5:`h6`,body:`p`,caption:`p`},l9={Text:({props:e})=>{let t=a9(e.variant)||`body`;return(0,i9.createElement)(c9[t]??`p`,{className:`sf-a2-text`,"data-variant":t},a9(e.text))},Row:({props:e,component:t,children:n})=>{let r=n(t.children),i=B5(e.sizes,r.length),a=!i&&Array.isArray(e.widths)&&e.widths.length===r.length&&e.widths.every(e=>typeof e==`number`&&e>0)?e.widths:void 0;return(0,r9.jsx)(`div`,{className:`sf-a2-row`,"data-arrange-container":!0,style:e9(e),"data-widths":a?!0:void 0,"data-sizes":i?!0:void 0,...l7(e,{gap:!0,padding:!0}),"data-wrap":e.wrap===!1?`false`:void 0,children:i?r.map((e,t)=>{let n=i[t];return(0,r9.jsx)(`div`,{className:`sf-a2-row-cell`,"data-size":typeof n==`string`?n:`fixed`,style:typeof n==`string`?void 0:{"--sf-row-cell-size":`${n.fixed}px`},children:e},t)}):a?r.map((e,t)=>(0,r9.jsx)(`div`,{className:`sf-a2-row-cell`,style:{flex:`${a[t]} 1 0`},children:e},t)):r})},Column:({props:e,component:t,children:n})=>(0,r9.jsx)(`div`,{className:`sf-a2-column`,style:e9(e),...l7(e,{gap:!0,padding:!0}),children:n(t.children)}),Card:({props:e,component:t,child:n})=>(0,r9.jsx)(`div`,{className:`sf-a2-card`,...l7(e,{padding:!0}),children:n(t.child)}),Divider:({props:e})=>(0,r9.jsx)(`hr`,{className:`sf-a2-divider`,"data-axis":a9(e.axis)||`horizontal`}),Tabs:e=>(0,r9.jsx)(n9,{...e}),Button:e=>(0,r9.jsx)(t9,{...e}),Stat:({props:e})=>(0,r9.jsxs)(`div`,{className:`sf-a2-stat`,children:[(0,r9.jsx)(`span`,{className:`sf-a2-stat-label`,children:a9(e.label)}),(0,r9.jsx)(`span`,{className:`sf-a2-stat-value`,children:a9(e.value)}),e.delta!=null&&(0,r9.jsx)(`span`,{className:`sf-a2-stat-delta`,"data-tone":a9(e.tone)||`neutral`,children:a9(e.delta)})]}),KeyValue:({props:e})=>(0,r9.jsx)(`dl`,{className:`sf-a2-keyvalue`,children:(e.items??[]).map((e,t)=>(0,r9.jsxs)(`div`,{children:[(0,r9.jsx)(`dt`,{children:a9(e.label)}),(0,r9.jsx)(`dd`,{children:a9(e.value)})]},t))}),Badge:({props:e})=>(0,r9.jsx)(`span`,{className:`sf-a2-badge`,"data-tone":a9(e.tone)||`neutral`,children:a9(e.text)}),Progress:({props:e})=>{let t=Number(e.max??100)||100,n=Math.max(0,Math.min(t,Number(e.value)||0));return(0,r9.jsxs)(`div`,{className:`sf-a2-progress`,children:[e.label!=null&&(0,r9.jsx)(`span`,{children:a9(e.label)}),(0,r9.jsx)(`progress`,{value:n,max:t,"aria-label":a9(e.label)||`Progress`}),(0,r9.jsxs)(`span`,{className:`sf-a2-progress-value`,children:[Math.round(n/t*100),`%`]})]})},DataGrid:({props:e,reportControls:t})=>Z7(e.filters,n=>(0,r9.jsx)($7,{props:e,filters:n,reportControls:t})),Chart:({props:e,component:t,setData:n,dispatch:r,reportContext:i})=>{let a=a9(e.x),o=t.select!=null&&!e.xGrain&&!e.xBins&&a!==``,s=Array.isArray(e.select)?e.select:[],c=o&&Array.isArray(e.filters)?JC(e.filters,a):e.filters,l=o||t.action!=null?e=>{if(e.x!=null){if(o){let r=KC(s,a,e.x);n(t.select,r);let o=GC(r,a);i({kind:`point.selected`,summary:o.some(t=>String(t)===String(e.x))?`Clicked ${e.x} in the chart: the page is filtered to ${a} ${o.length===1?`is`:`is one of`} ${o.join(`, `)}.`:`Clicked ${e.x} in the chart again: ${e.x} is taken out of the filter on ${a}${o.length===0?`, which is now cleared`:``}.`,subject:{column:a,value:e.x,series:e.series,filters:r}})}t.action!=null&&r(t.action,{column:a,value:String(e.x),series:e.series})}}:void 0;return Z7(c,t=>(0,r9.jsx)(xF,{filters:t,sourceId:a9(e.sourceId),sql:a9(e.sql),type:a9(e.type),x:a,y:e.y??[],xGrain:a9(e.xGrain)||void 0,xBins:typeof e.xBins==`number`?e.xBins:void 0,splitBy:a9(e.splitBy)||void 0,stacked:e.stacked===!0,sort:e.sort===`x`||e.sort===`value`?e.sort:void 0,legend:a9(e.legend)||void 0,xTitle:a9(e.xTitle)||void 0,yTitle:a9(e.yTitle)||void 0,yRightTitle:a9(e.yRightTitle)||void 0,yFormat:e.yFormat===`number`||e.yFormat===`compact`||e.yFormat===`currency`||e.yFormat===`percent`?e.yFormat:void 0,height:typeof e.height==`number`?e.height:300,label:a9(e.label)||void 0,onPointClick:l,emptyMessage:a9(e.emptyMessage)||void 0,errorMessage:a9(e.errorMessage)||void 0}))},PivotTable:({props:e})=>Z7(e.filters,t=>(0,r9.jsx)(LI,{filters:t,sourceId:a9(e.sourceId),sql:a9(e.sql),rows:e.rows??[],columns:e.columns??[],measures:e.measures??[],totals:e.totals!==!1,height:typeof e.height==`number`?e.height:360,label:a9(e.label)||void 0,emptyMessage:a9(e.emptyMessage)||void 0,errorMessage:a9(e.errorMessage)||void 0})),QueryResult:({props:e,reportControls:t})=>Z7(e.filters,n=>(0,r9.jsx)(XL,{sourceId:a9(e.sourceId),sql:a9(e.sql),height:typeof e.height==`number`?e.height:400,view:a9(e.view)||void 0,filters:n,sorts:Array.isArray(e.sorts)?RC(e.sorts):void 0,columns:e.columns,onControlsChange:e=>t({view:e.view,filters:VC(e.filters),sorts:HC(e.sorts),columns:e.columns}),emptyMessage:a9(e.emptyMessage)||void 0,errorMessage:a9(e.errorMessage)||void 0})),...Y7,...y7},Object.fromEntries(c5.names.map(e=>[e,l9[e]]))})),d9=r((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&te(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&te(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function te(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,te(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f9=r(((e,t)=>{t.exports=d9()})),p9=r((e=>{var t=NM();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),m9=r(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p9()})),h9=r((e=>{var t=f9(),n=NM(),r=m9();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),k=Symbol.for(`react.strict_mode`),ee=Symbol.for(`react.profiler`),te=Symbol.for(`react.consumer`),A=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case ee:return`Profiler`;case k:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case A:return e.displayName||`Context`;case te:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,j=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function M(e,t){be++,ye[be]=e.current,e.current=t}var Ce=xe(null),we=xe(null),Te=xe(null),Ee=xe(null);function De(e,t){switch(M(Te,t),M(we,e),M(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ep(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ep(t),e=Dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(Ce),M(Ce,e)}function Oe(){Se(Ce),Se(we),Se(Te)}function ke(e){var t=e.memoizedState;t!==null&&(Sh._currentValue=t.memoizedState,M(Ee,e)),t=Ce.current;var n=Dp(t,e.type);t!==n&&(M(we,e),M(Ce,n))}function Ae(e){we.current===e&&(Se(Ce),Se(we)),Ee.current===e&&(Se(Ee),Sh._currentValue=ve)}var je,Me;function Ne(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
102
103
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
103
104
|
`+je+e+Me}var Pe=!1;function Fe(e,t){if(!e||Pe)return``;Pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
104
105
|
`),l=s.split(`
|
|
@@ -106,4 +107,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
106
107
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Pe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ne(n):``}function Ie(e,t){switch(e.tag){case 26:case 27:case 5:return Ne(e.type);case 16:return Ne(`Lazy`);case 13:return e.child!==t&&t!==null?Ne(`Suspense Fallback`):Ne(`Suspense`);case 19:return Ne(`SuspenseList`);case 0:case 15:return Fe(e.type,!1);case 11:return Fe(e.type.render,!1);case 1:return Fe(e.type,!0);case 31:return Ne(`Activity`);case 30:return Ne(`ViewTransition`);default:return``}}function Le(e){try{var t=``,n=null;do t+=Ie(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
107
108
|
Error generating stack: `+e.message+`
|
|
108
109
|
`+e.stack}}var Re=Object.prototype.hasOwnProperty,ze=t.unstable_scheduleCallback,Be=t.unstable_cancelCallback,Ve=t.unstable_shouldYield,He=t.unstable_requestPaint,Ue=t.unstable_now,We=t.unstable_getCurrentPriorityLevel,Ge=t.unstable_ImmediatePriority,Ke=t.unstable_UserBlockingPriority,qe=t.unstable_NormalPriority,Je=t.unstable_LowPriority,Ye=t.unstable_IdlePriority,Xe=t.log,Ze=t.unstable_setDisableYieldValue,Qe=null,$e=null;function et(e){if(typeof Xe==`function`&&Ze(e),$e&&typeof $e.setStrictMode==`function`)try{$e.setStrictMode(Qe,e)}catch{}}var tt=Math.clz32?Math.clz32:it,nt=Math.log,rt=Math.LN2;function it(e){return e>>>=0,e===0?32:31-(nt(e)/rt|0)|0}var at=256,ot=262144,st=4194304;function ct(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function lt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=ct(n))):i=ct(o):i=ct(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ct(n))):i=ct(o)):i=ct(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ut(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function dt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-tt(n),i=1<<r;t|=e[r],n&=~i}return t}function ft(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function pt(){var e=st;return st<<=1,!(st&62914560)&&(st=4194304),e}function mt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ht(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function gt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-tt(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&_t(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function _t(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-tt(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function vt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-tt(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function yt(e,t){var n=t&-t;return n=n&42?1:bt(n),(n&(e.suspendedLanes|t))===0?n:0}function bt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function xt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function St(){var e=_e.p;return e===0?(e=window.event,e===void 0?32:Rh(e.type)):e}function Ct(e,t){var n=_e.p;try{return _e.p=e,t()}finally{_e.p=n}}var wt=Math.random().toString(36).slice(2),Tt=`__reactFiber$`+wt,Et=`__reactProps$`+wt,Dt=`__reactContainer$`+wt,Ot=`__reactEvents$`+wt,kt=`__reactListeners$`+wt,At=`__reactHandles$`+wt,jt=`__reactResources$`+wt,Mt=`__reactMarker$`+wt,Nt=`__reactLoad$`+wt;function Pt(e){delete e[Tt],delete e[Et],delete e[kt],delete e[At]}function Ft(e){var t;if(t=e[Tt])return t;for(var n=e.parentNode;n;){if(t=n[Dt]||n[Tt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Dm(e);e!==null;){if(n=e[Tt])return n;e=Dm(e)}return t}e=n,n=e.parentNode}return null}function It(e){if(e=e[Tt]||e[Dt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Lt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Rt(e){var t=e[jt];return t||=e[jt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function zt(e){e[Mt]=!0}function Bt(e){e[Nt]=void 0}var Vt=new Set,Ht={};function Ut(e,t){Wt(e,t),Wt(e+`Capture`,t)}function Wt(e,t){for(Ht[e]=t,e=0;e<t.length;e++)Vt.add(t[e])}var Gt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Kt={},qt={};function Jt(e){return Re.call(qt,e)?!0:Re.call(Kt,e)?!1:Gt.test(e)?qt[e]=!0:(Kt[e]=!0,!1)}var Yt=!1;function Xt(){var e=Yt;return Yt=!1,e}function Zt(e,t,n){if(Jt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Qt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function $t(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function en(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function tn(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function nn(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function rn(e){if(!e._valueTracker){var t=tn(e)?`checked`:`value`;e._valueTracker=nn(e,t,``+e[t])}}function an(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=tn(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var on=/[\n"\\]/g;function sn(e){return e.replace(on,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function cn(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+en(t)):e.value!==``+en(t)&&(e.value=``+en(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):un(e,en(n)):o===`number`&&e.value==t?un(e,en(e.value)):un(e,en(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+en(s):e.removeAttribute(`name`)}function ln(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){rn(e);return}n=n==null?``:``+en(n),t=t==null?n:``+en(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),rn(e)}function un(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function dn(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+en(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function fn(e,t,n){t!=null&&(t=``+en(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+en(n)}function pn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(ge(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=en(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),rn(e)}function mn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var hn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function gn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||hn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function _n(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Yt=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(gn(e,a,r),Yt=!0)}else for(var o in t)t.hasOwnProperty(o)&&gn(e,o,t[o])}function vn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var yn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),bn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function xn(e){return bn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Sn(){}var Cn=null;function wn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Tn=null,En=null;function Dn(e){var t=It(e);if(t&&(e=t.stateNode)){var n=e[Et]||null;a:switch(e=t.stateNode,t.type){case`input`:if(cn(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+sn(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Et]||null;if(!a)throw Error(i(90));cn(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&an(r)}break a;case`textarea`:fn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&dn(e,!!n.multiple,t,!1)}}}var On=!1;function kn(e,t,n){if(On)return e(t,n);On=!0;try{return e(t)}finally{if(On=!1,(Tn!==null||En!==null)&&(Qd(),Tn&&(t=Tn,e=En,En=Tn=null,Dn(t),e)))for(t=0;t<e.length;t++)Dn(e[t])}}function N(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Et]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var An=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,jn=!1;if(An)try{var Mn={};Object.defineProperty(Mn,"passive",{get:function(){jn=!0}}),window.addEventListener(`test`,Mn,Mn),window.removeEventListener(`test`,Mn,Mn)}catch{jn=!1}var Nn=null,Pn=null,Fn=null;function In(){if(Fn)return Fn;var e,t=Pn,n=t.length,r,i=`value`in Nn?Nn.value:Nn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Fn=i.slice(e,1<r?1-r:void 0)}function Ln(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Rn(){return!0}function zn(){return!1}function Bn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Rn:zn,this.isPropagationStopped=zn,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Rn)},persist:function(){},isPersistent:Rn}),t}var Vn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hn=Bn(Vn),Un=w({},Vn,{view:0,detail:0}),Wn=Bn(Un),Gn,Kn,qn,Jn=w({},Un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ar,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==qn&&(qn&&e.type===`mousemove`?(Gn=e.screenX-qn.screenX,Kn=e.screenY-qn.screenY):Kn=Gn=0,qn=e),Gn)},movementY:function(e){return`movementY`in e?e.movementY:Kn}}),Yn=Bn(Jn),Xn=Bn(w({},Jn,{dataTransfer:0})),Zn=Bn(w({},Un,{relatedTarget:0})),Qn=Bn(w({},Vn,{animationName:0,elapsedTime:0,pseudoElement:0})),$n=Bn(w({},Vn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),er=Bn(w({},Vn,{data:0})),tr={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},nr={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},rr={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function ir(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=rr[e])?!!t[e]:!1}function ar(){return ir}var or=Bn(w({},Un,{key:function(e){if(e.key){var t=tr[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Ln(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?nr[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ar,charCode:function(e){return e.type===`keypress`?Ln(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Ln(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),sr=Bn(w({},Jn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),cr=Bn(w({},Vn,{submitter:0})),lr=Bn(w({},Un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ar})),ur=Bn(w({},Vn,{propertyName:0,elapsedTime:0,pseudoElement:0})),dr=Bn(w({},Jn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),fr=Bn(w({},Vn,{newState:0,oldState:0,source:0})),pr=[9,13,27,32],mr=An&&`CompositionEvent`in window,hr=null;An&&`documentMode`in document&&(hr=document.documentMode);var gr=An&&`TextEvent`in window&&!hr,_r=An&&(!mr||hr&&8<hr&&11>=hr),vr=` `,yr=!1;function br(e,t){switch(e){case`keyup`:return pr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function xr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Sr=!1;function P(e,t){switch(e){case`compositionend`:return xr(t);case`keypress`:return t.which===32?(yr=!0,vr):null;case`textInput`:return e=t.data,e===vr&&yr?null:e;default:return null}}function Cr(e,t){if(Sr)return e===`compositionend`||!mr&&br(e,t)?(e=In(),Fn=Pn=Nn=null,Sr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return _r&&t.locale!==`ko`?null:t.data;default:return null}}var wr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Tr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!wr[e.type]:t===`textarea`}function Er(e,t,n,r){Tn?En?En.push(r):En=[r]:Tn=r,t=lp(t,`onChange`),0<t.length&&(n=new Hn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Dr=null,Or=null;function kr(e){tp(e,0)}function Ar(e){if(an(Lt(e)))return e}function jr(e,t){if(e===`change`)return t}var Mr=!1;if(An){var Nr;if(An){var Pr=`oninput`in document;if(!Pr){var Fr=document.createElement(`div`);Fr.setAttribute(`oninput`,`return;`),Pr=typeof Fr.oninput==`function`}Nr=Pr}else Nr=!1;Mr=Nr&&(!document.documentMode||9<document.documentMode)}function Ir(){Dr&&(Dr.detachEvent(`onpropertychange`,Lr),Or=Dr=null)}function Lr(e){if(e.propertyName===`value`&&Ar(Or)){var t=[];Er(t,Or,e,wn(e)),kn(kr,t)}}function Rr(e,t,n){e===`focusin`?(Ir(),Dr=t,Or=n,Dr.attachEvent(`onpropertychange`,Lr)):e===`focusout`&&Ir()}function zr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Ar(Or)}function Br(e,t){if(e===`click`)return Ar(t)}function Vr(e,t){if(e===`input`||e===`change`)return Ar(t)}function Hr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Ur=typeof Object.is==`function`?Object.is:Hr;function Wr(e,t){if(Ur(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Re.call(t,i)||!Ur(e[i],t[i]))return!1}return!0}function Gr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Kr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function qr(e,t){var n=Kr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Kr(n)}}function Jr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Jr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Yr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Gr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gr(e.document)}return t}function Xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Zr=An&&`documentMode`in document&&11>=document.documentMode,Qr=null,$r=null,ei=null,ti=!1;function ni(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ti||Qr==null||Qr!==Gr(r)||(r=Qr,`selectionStart`in r&&Xr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ei&&Wr(ei,r)||(ei=r,r=lp($r,`onSelect`),0<r.length&&(t=new Hn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Qr)))}function ri(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ii={animationend:ri(`Animation`,`AnimationEnd`),animationiteration:ri(`Animation`,`AnimationIteration`),animationstart:ri(`Animation`,`AnimationStart`),transitionrun:ri(`Transition`,`TransitionRun`),transitionstart:ri(`Transition`,`TransitionStart`),transitioncancel:ri(`Transition`,`TransitionCancel`),transitionend:ri(`Transition`,`TransitionEnd`)},ai={},oi={};An&&(oi=document.createElement(`div`).style,`AnimationEvent`in window||(delete ii.animationend.animation,delete ii.animationiteration.animation,delete ii.animationstart.animation),`TransitionEvent`in window||delete ii.transitionend.transition);function si(e){if(ai[e])return ai[e];if(!ii[e])return e;var t=ii[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in oi)return ai[e]=t[n];return e}var ci=si(`animationend`),li=si(`animationiteration`),ui=si(`animationstart`),di=si(`transitionrun`),fi=si(`transitionstart`),pi=si(`transitioncancel`),mi=si(`transitionend`),hi=new Map,gi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);gi.push(`scrollEnd`);function _i(e,t){hi.set(e,t),Ut(t,[e])}var vi=0;function yi(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=Nd.identifierPrefix;var n=vi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function bi(e){if(e==null||typeof e==`string`)return e;var t=null,n=Vd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function xi(e,t){return e=bi(e),t=bi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var Si=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Ci=[],wi=0,Ti=0;function Ei(){for(var e=wi,t=Ti=wi=0;t<e;){var n=Ci[t];Ci[t++]=null;var r=Ci[t];Ci[t++]=null;var i=Ci[t];Ci[t++]=null;var a=Ci[t];if(Ci[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Ai(n,i,a)}}function Di(e,t,n,r){Ci[wi++]=e,Ci[wi++]=t,Ci[wi++]=n,Ci[wi++]=r,Ti|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Oi(e,t,n,r){return Di(e,t,n,r),ji(e)}function ki(e,t){return Di(e,null,null,t),ji(e)}function Ai(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-tt(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ji(e){if(50<Hd)throw Hd=0,Ud=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Mi={};function Ni(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pi(e,t,n,r){return new Ni(e,t,n,r)}function Fi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ii(e,t){var n=e.alternate;return n===null?(n=Pi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Li(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ri(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Fi(r)&&(s=1);else if(typeof r==`string`)s=ch(e,n,Ce.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case se:return e=Pi(31,n,t,a),e.elementType=se,e.lanes=o,e;case O:return zi(n.children,a,o,t);case k:s=8,a|=24;break;case ee:return e=Pi(12,n,t,a|2),e.elementType=ee,e.lanes=o,e;case re:return e=Pi(13,n,t,a),e.elementType=re,e.lanes=o,e;case ie:return e=Pi(19,n,t,a),e.elementType=ie,e.lanes=o,e;case ce:case ue:return e=a|32,e=Pi(30,n,t,e),e.elementType=ue,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case A:s=10;break a;case te:s=9;break a;case ne:s=11;break a;case ae:s=14;break a;case oe:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Pi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function zi(e,t,n,r){return e=Pi(7,e,r,t),e.lanes=n,e}function Bi(e,t,n){return e=Pi(6,e,null,t),e.lanes=n,e}function Vi(e){var t=Pi(18,null,null,0);return t.stateNode=e,t}function Hi(e,t,n){return t=Pi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ui=new WeakMap;function Wi(e,t){if(typeof e==`object`&&e){var n=Ui.get(e);return n===void 0?(t={value:e,source:t,stack:Le(t)},Ui.set(e,t),t):n}return{value:e,source:t,stack:Le(t)}}var Gi=[],Ki=0,qi=null,Ji=0,Yi=[],Xi=0,Zi=null,Qi=1,$i=``;function ea(e,t){Gi[Ki++]=Ji,Gi[Ki++]=qi,qi=e,Ji=t}function ta(e,t,n){Yi[Xi++]=Qi,Yi[Xi++]=$i,Yi[Xi++]=Zi,Zi=e;var r=Qi;e=$i;var i=32-tt(r)-1;r&=~(1<<i),n+=1;var a=32-tt(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Qi=1<<32-tt(t)+i|n<<i|r,$i=a+e}else Qi=1<<a|n<<i|r,$i=e}function na(e){e.return!==null&&(ea(e,1),ta(e,1,0))}function ra(e){for(;e===qi;)qi=Gi[--Ki],Gi[Ki]=null,Ji=Gi[--Ki],Gi[Ki]=null;for(;e===Zi;)Zi=Yi[--Xi],Yi[Xi]=null,$i=Yi[--Xi],Yi[Xi]=null,Qi=Yi[--Xi],Yi[Xi]=null}function ia(e,t){Yi[Xi++]=Qi,Yi[Xi++]=$i,Yi[Xi++]=Zi,Qi=t.id,$i=t.overflow,Zi=e}var aa=null,oa=null,sa=!1,ca=null,la=!1,ua=Error(i(519));function da(e){throw _a(Wi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),ua}function fa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Tt]=e,t[Et]=r,n){case`dialog`:np(`cancel`,t),np(`close`,t);break;case`iframe`:case`object`:case`embed`:np(`load`,t);break;case`video`:case`audio`:for(n=0;n<$f.length;n++)np($f[n],t);break;case`source`:np(`error`,t);break;case`img`:case`image`:case`link`:np(`error`,t),np(`load`,t);break;case`details`:np(`toggle`,t);break;case`input`:np(`invalid`,t),ln(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:np(`invalid`,t);break;case`textarea`:np(`invalid`,t),pn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||hp(t.textContent,n)?(r.popover!=null&&(np(`beforetoggle`,t),np(`toggle`,t)),r.onScroll!=null&&np(`scroll`,t),r.onScrollEnd!=null&&np(`scrollend`,t),r.onClick!=null&&(t.onclick=Sn),t=!0):t=!1,t||da(e,!0)}function pa(e){for(aa=e.return;aa;)switch(aa.tag){case 5:case 31:case 13:la=!1;return;case 27:case 3:la=!0;return;default:aa=aa.return}}function ma(e){if(e!==aa)return!1;if(!sa)return pa(e),sa=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||kp(e.type,e.memoizedProps)),n=!n),n&&oa&&da(e),pa(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));oa=Em(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));oa=Em(e)}else t===27?(t=oa,Lp(e.type)?(e=Tm,Tm=null,oa=e):oa=t):oa=aa?wm(e.stateNode.nextSibling):null;return!0}function ha(){oa=aa=null,sa=!1}function ga(){var e=ca;return e!==null&&(Td===null?Td=e:Td.push.apply(Td,e),ca=null),e}function _a(e){ca===null?ca=[e]:ca.push(e)}var va=xe(null),ya=null,ba=null;function xa(e,t,n){M(va,t._currentValue),t._currentValue=n}function Sa(e){e._currentValue=va.current,Se(va)}function Ca(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function wa(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ca(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ca(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),Ca(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Ta(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Ur(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Ee.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Sh]:e.push(Sh))}a=a.return}return e!==null&&wa(t,e,n,r),t.flags|=262144,e!==null}function Ea(e){for(e=e.firstContext;e!==null;){if(!Ur(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Da(e){ya=e,ba=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Oa(e){return Aa(ya,e)}function ka(e,t){return ya===null&&Da(e),Aa(e,t)}function Aa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ba===null){if(e===null)throw Error(i(308));ba=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ba=ba.next=t;return n}var ja=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ma=t.unstable_scheduleCallback,Na=t.unstable_NormalPriority,Pa={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Fa(){return{controller:new ja,data:new Map,refCount:0}}function Ia(e){e.refCount--,e.refCount===0&&Ma(Na,function(){e.controller.abort()})}function La(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Ra=null;function za(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Ba=null,Va=0,Ha=0,Ua=null;function Wa(e,t){if(Ba===null){var n=Ba=[];Va=0,Ha=Jf(),Ua={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Va++,t.then(Ga,Ga),t}function Ga(){if(--Va===0&&(Ra=null,Ba!==null)){Ua!==null&&(Ua.status=`fulfilled`);var e=Ba;Ba=null,Ha=0,Ua=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ka(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var qa=j.S;j.S=function(e,t){if(Od=Ue(),typeof t==`object`&&t&&typeof t.then==`function`&&Wa(e,t),Ra!==null)for(var n=Pf;n!==null;)La(n,Ra),n=n.next;if(n=e.types,n!==null){for(var r=Pf;r!==null;)La(r,n),r=r.next;if(Ha!==0){r=Ra,r===null&&(r=Ra=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}qa!==null&&qa(e,t)};var Ja=xe(null);function Ya(){var e=Ja.current;return e===null?ld.pooledCache:e}function Xa(e,t){t===null?M(Ja,Ja.current):M(Ja,t.pool)}function Za(){var e=Ya();return e===null?null:{parent:Pa._currentValue,pool:e}}var Qa=Error(i(460)),$a=Error(i(474)),eo=Error(i(542)),to={then:function(){}};function no(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ro(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Sn,Sn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,so(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(Sn,Sn);else{if(e=ld,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,so(e),e}throw ao=t,Qa}}function io(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ao=e,Qa):e}}var ao=null;function oo(){if(ao===null)throw Error(i(459));var e=ao;return ao=null,e}function so(e){if(e===Qa||e===eo)throw Error(i(483))}var co=null,lo=0;function uo(e){var t=lo;return lo+=1,co===null&&(co=[]),ro(co,e,t)}function fo(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function po(e,t){throw t.$$typeof===T?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function mo(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Ii(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Bi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===O?(e=d(e,t,n.props.children,r,n.key),fo(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===oe&&io(i)===t.type)?(t=a(t,n.props),fo(t,n),t.return=e,t):(t=Ri(n.type,n.key,n.props,null,e.mode,r),fo(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Hi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=zi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Bi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case E:return n=Ri(t.type,t.key,t.props,null,e.mode,n),fo(n,t),n.return=e,n;case D:return t=Hi(t,e.mode,n),t.return=e,t;case oe:return t=io(t),f(e,t,n)}if(ge(t)||pe(t))return t=zi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,uo(t),n);if(t.$$typeof===A)return f(e,ka(e,t),n);po(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case E:return n.key===i?l(e,t,n,r):null;case D:return n.key===i?u(e,t,n,r):null;case oe:return n=io(n),p(e,t,n,r)}if(ge(n)||pe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,uo(n),r);if(n.$$typeof===A)return p(e,t,ka(e,n),r);po(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case E:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case D:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case oe:return r=io(r),m(e,t,n,r,i)}if(ge(r)||pe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,uo(r),i);if(r.$$typeof===A)return m(e,t,n,ka(t,r),i);po(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),sa&&ea(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return sa&&ea(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),sa&&ea(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),sa&&ea(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return sa&&ea(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),sa&&ea(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===O&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case E:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===O){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),fo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===oe&&io(l)===r.type){n(e,r.sibling),c=a(r,o.props),fo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===O?(c=zi(o.props.children,e.mode,c,o.key),fo(c,o),c.return=e,e=c):(c=Ri(o.type,o.key,o.props,null,e.mode,c),fo(c,o),c.return=e,e=c)}return s(e);case D:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Hi(o,e.mode,c),c.return=e,e=c}return s(e);case oe:return o=io(o),_(e,r,o,c)}if(ge(o))return h(e,r,o,c);if(pe(o)){if(l=pe(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,uo(o),c);if(o.$$typeof===A)return _(e,r,ka(e,o),c);po(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Bi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{lo=0;var i=_(e,t,n,r);return co=null,i}catch(t){if(t===Qa||t===eo)throw t;var a=Pi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ho=mo(!0),go=mo(!1),_o=!1;function vo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function xo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,cd&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ji(e),Ai(e,null,n),t}return Di(e,r,t,n),ji(e)}function So(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,vt(e,n)}}function Co(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var wo=!1;function To(){if(wo){var e=Ua;if(e!==null)throw e}}function Eo(e,t,n,r){wo=!1;var i=e.updateQueue;_o=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(dd&f)===f:(r&f)===f){f!==0&&f===Ha&&(wo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:_o=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),yd|=o,e.lanes=o,e.memoizedState=d}}function Do(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Oo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Do(n[e],t)}var ko=xe(null),Ao=xe(0);function jo(e,t){e=_d,M(Ao,e),M(ko,t),_d=e|t.baseLanes}function Mo(){M(Ao,_d),M(ko,ko.current)}function No(){_d=Ao.current,Se(ko),Se(Ao)}var Po=xe(null),Fo=null;function Io(e){var t=e.alternate;M(Vo,Vo.current&1),M(Po,e),Fo===null&&(t===null||ko.current!==null||t.memoizedState!==null)&&(Fo=e)}function Lo(e){M(Vo,Vo.current),M(Po,e),Fo===null&&(Fo=e)}function Ro(e){e.tag===22?(M(Vo,Vo.current),M(Po,e),Fo===null&&(Fo=e)):zo()}function zo(){M(Vo,Vo.current),M(Po,Po.current)}function Bo(e){Se(Po),Fo===e&&(Fo=null),Se(Vo)}var Vo=xe(0);function Ho(e,t){M(Po,Po.current),M(Vo,t)}function Uo(e){Se(Vo),Se(Po),Fo===e&&(Fo=null)}function Wo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||xm(n)||Sm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Go=0,Ko=null,qo=null,Jo=null,Yo=!1,Xo=!1,Zo=!1,Qo=0,$o=0,es=null,ts=0;function ns(){throw Error(i(321))}function rs(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ur(e[n],t[n]))return!1;return!0}function is(e,t,n,r,i,a){return Go=a,Ko=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,j.H=e===null||e.memoizedState===null?xc:Sc,Zo=!1,a=n(r,i),Zo=!1,Xo&&(a=os(t,n,r,i)),as(e),a}function as(e){j.H=bc;var t=qo!==null&&qo.next!==null;if(Go=0,Jo=qo=Ko=null,Yo=!1,$o=0,es=null,t)throw Error(i(300));e===null||zc||(e=e.dependencies,e!==null&&Ea(e)&&(zc=!0))}function os(e,t,n,r){Ko=e;var a=0;do{if(Xo&&(es=null),$o=0,Xo=!1,25<=a)throw Error(i(301));if(a+=1,Jo=qo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}j.H=Cc,o=t(n,r)}while(Xo);return o}function ss(){var e=j.H,t=e.useState()[0];return t=typeof t.then==`function`?ms(t):t,e=e.useState()[0],(qo===null?null:qo.memoizedState)!==e&&(Ko.flags|=1024),t}function cs(){var e=Qo!==0;return Qo=0,e}function ls(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function us(e){if(Yo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Yo=!1}Go=0,Jo=qo=Ko=null,Xo=!1,$o=Qo=0,es=null}function ds(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jo===null?Ko.memoizedState=Jo=e:Jo=Jo.next=e,Jo}function fs(){if(qo===null){var e=Ko.alternate;e=e===null?null:e.memoizedState}else e=qo.next;var t=Jo===null?Ko.memoizedState:Jo.next;if(t!==null)Jo=t,qo=e;else{if(e===null)throw Ko.alternate===null?Error(i(467)):Error(i(310));qo=e,e={memoizedState:qo.memoizedState,baseState:qo.baseState,baseQueue:qo.baseQueue,queue:qo.queue,next:null},Jo===null?Ko.memoizedState=Jo=e:Jo=Jo.next=e}return Jo}function ps(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ms(e){var t=$o;return $o+=1,es===null&&(es=[]),e=ro(es,e,t),t=Ko,(Jo===null?t.memoizedState:Jo.next)===null&&(t=t.alternate,j.H=t===null||t.memoizedState===null?xc:Sc),e}function hs(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ms(e);if(e.$$typeof===de)return;if(e.$$typeof===A)return Oa(e)}throw Error(i(438,String(e)))}function gs(e){var t=null,n=Ko.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Ko.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ps(),Ko.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=le;return t.index++,n}function _s(e,t){return typeof t==`function`?t(e):t}function vs(e){return ys(fs(),qo,e)}function ys(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Go&f)===f:(dd&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Ha&&(d=!0);else if((Go&p)===p){u=u.next,p===Ha&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Ko.lanes|=p,yd|=p;f=u.action,Zo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Ko.lanes|=f,yd|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Ur(o,e.memoizedState)&&(zc=!0,d&&(n=Ua,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function bs(e){var t=fs(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Ur(o,t.memoizedState)||(zc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function xs(e,t,n){var r=Ko,a=fs(),o=sa;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Ur((qo||a).memoizedState,n);if(s&&(a.memoizedState=n,zc=!0),a=a.queue,Ks(ws.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Jo!==null&&!!(Jo.memoizedState.tag&1),Vs(e?9:8,{destroy:void 0},Cs.bind(null,r,a,n,t),null),e){if(r.flags|=2048,ld===null)throw Error(i(349));o||Go&127||Ss(r,t,n)}return n}function Ss(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ko.updateQueue,t===null?(t=ps(),Ko.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Cs(e,t,n,r){t.value=n,t.getSnapshot=r,Ts(t)&&Es(e)}function ws(e,t,n){return n(function(){Ts(t)&&Es(e)})}function Ts(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ur(e,n)}catch{return!0}}function Es(e){var t=ki(e,2);t!==null&&qd(t,e,2)}function Ds(e){var t=ds();if(typeof e==`function`){var n=e;if(e=n(),Zo){et(!0);try{n()}finally{et(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:e},t}function Os(e,t,n,r){return e.baseState=n,ys(e,qo,typeof r==`function`?r:_s)}function ks(e,t,n,r,a){if(_c(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};j.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,As(t,o)):(o.next=n.next,t.pending=n.next=o)}}function As(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=j.T,o={};o.types=a===null?null:a.types,j.T=o;try{var s=n(i,r),c=j.S;c!==null&&c(o,s),js(e,t,s)}catch(n){Ns(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),j.T=a}}else try{a=n(i,r),js(e,t,a)}catch(n){Ns(e,t,n)}}function js(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ms(e,t,n)},function(n){return Ns(e,t,n)}):Ms(e,t,n)}function Ms(e,t,n){t.status=`fulfilled`,t.value=n,Ps(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,As(e,n)))}function Ns(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ps(t),t=t.next;while(t!==r)}e.action=null}function Ps(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Fs(e,t){return t}function Is(e,t){if(sa){var n=ld.formState;if(n!==null){a:{var r=Ko;if(sa){if(oa){b:{for(var i=oa,a=la;i.nodeType!==8;)if(!a||(i=wm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){oa=wm(i.nextSibling),r=i.data===`F!`;break a}}da(r)}r=!1}r&&(t=n[0])}}return n=ds(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fs,lastRenderedState:t},n.queue=r,n=mc.bind(null,Ko,r),r.dispatch=n,r=Ds(!1),a=gc.bind(null,Ko,!1,r.queue),r=ds(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ks.bind(null,Ko,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ls(e){return Rs(fs(),qo,e)}function Rs(e,t,n){if(t=ys(e,t,Fs)[0],e=vs(_s)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ms(t)}catch(e){throw e===Qa?eo:e}else r=t;t=fs();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Ko.flags|=2048,Vs(9,{destroy:void 0},zs.bind(null,i,n),null)),[r,a,e]}function zs(e,t){e.action=t}function Bs(e){var t=fs(),n=qo;if(n!==null)return Rs(t,n,e);fs(),t=t.memoizedState,n=fs();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Vs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Ko.updateQueue,t===null&&(t=ps(),Ko.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Hs(){return fs().memoizedState}function Us(e,t,n,r){var i=ds();Ko.flags|=e,i.memoizedState=Vs(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ws(e,t,n,r){var i=fs();r=r===void 0?null:r;var a=i.memoizedState.inst;qo!==null&&r!==null&&rs(r,qo.memoizedState.deps)?i.memoizedState=Vs(t,a,n,r):(Ko.flags|=e,i.memoizedState=Vs(1|t,a,n,r))}function Gs(e,t){Us(8390656,8,e,t)}function Ks(e,t){Ws(2048,8,e,t)}function qs(e){Ko.flags|=4;var t=Ko.updateQueue;if(t===null)t=ps(),Ko.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Js(e){var t=fs().memoizedState;return qs({ref:t,nextImpl:e}),function(){if(cd&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ys(e,t){return Ws(4,2,e,t)}function Xs(e,t){return Ws(4,4,e,t)}function Zs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Qs(e,t,n){n=n==null?null:n.concat([e]),Ws(4,4,Zs.bind(null,t,e),n)}function $s(){}function ec(e,t){var n=fs();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&rs(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function tc(e,t){var n=fs();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&rs(t,r[1]))return r[0];if(r=e(),Zo){et(!0);try{e()}finally{et(!1)}}return n.memoizedState=[r,t],r}function nc(e,t,n){return n===void 0||Go&1073741824&&!(dd&261930)?e.memoizedState=t:(e.memoizedState=n,e=Gd(),Ko.lanes|=e,yd|=e,n)}function rc(e,t,n,r){return Ur(n,t)?n:ko.current===null?!(Go&106)||Go&1073741824&&!(dd&261930)?(zc=!0,e.memoizedState=n):(e=Gd(),Ko.lanes|=e,yd|=e,t):(e=nc(e,n,r),Ur(e,t)||(zc=!0),e)}function ic(e,t,n,r,i){var a=_e.p;_e.p=a!==0&&8>a?a:8;var o=j.T,s={};s.types=o===null?null:o.types,j.T=s,gc(e,!1,t,n);try{var c=i(),l=j.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?hc(e,t,Ka(c,r),Wd(e)):hc(e,t,r,Wd(e))}catch(n){hc(e,t,{then:function(){},status:`rejected`,reason:n},Wd())}finally{_e.p=a,o!==null&&s.types!==null&&(o.types=s.types),j.T=o}}function ac(){}function oc(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=sc(e).queue;ic(e,a,t,ve,n===null?ac:function(){return cc(e),n(r)})}function sc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ve,baseState:ve,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:ve},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function cc(e){var t=sc(e);t.next===null&&(t=e.alternate.memoizedState),hc(e,t.next.queue,{},Wd())}function lc(){return Oa(Sh)}function uc(){return fs().memoizedState}function dc(){return fs().memoizedState}function fc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Wd();e=bo(n);var r=xo(t,e,n);r!==null&&(qd(r,t,n),So(r,t,n)),t={cache:Fa()},e.payload=t;return}t=t.return}}function pc(e,t,n){var r=Wd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},_c(e)?vc(t,n):(n=Oi(e,t,n,r),n!==null&&(qd(n,e,r),yc(n,t,r)))}function mc(e,t,n){hc(e,t,n,Wd())}function hc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(_c(e))vc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Ur(s,o))return Di(e,t,i,0),ld===null&&Ei(),!1}catch{}if(n=Oi(e,t,i,r),n!==null)return qd(n,e,r),yc(n,t,r),!0}return!1}function gc(e,t,n,r){if(r={lane:2,revertLane:Jf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},_c(e)){if(t)throw Error(i(479))}else t=Oi(e,n,r,2),t!==null&&qd(t,e,2)}function _c(e){var t=e.alternate;return e===Ko||t!==null&&t===Ko}function vc(e,t){Xo=Yo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function yc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,vt(e,n)}}var bc={readContext:Oa,use:hs,useCallback:ns,useContext:ns,useEffect:ns,useImperativeHandle:ns,useLayoutEffect:ns,useInsertionEffect:ns,useMemo:ns,useReducer:ns,useRef:ns,useState:ns,useDebugValue:ns,useDeferredValue:ns,useTransition:ns,useSyncExternalStore:ns,useId:ns,useHostTransitionStatus:ns,useFormState:ns,useActionState:ns,useOptimistic:ns,useMemoCache:ns,useCacheRefresh:ns,useEffectEvent:ns},xc={readContext:Oa,use:hs,useCallback:function(e,t){return ds().memoizedState=[e,t===void 0?null:t],e},useContext:Oa,useEffect:Gs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Us(4194308,4,Zs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Us(4194308,4,e,t)},useInsertionEffect:function(e,t){Us(4,2,e,t)},useMemo:function(e,t){var n=ds();t=t===void 0?null:t;var r=e();if(Zo){et(!0);try{e()}finally{et(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ds();if(n!==void 0){var i=n(t);if(Zo){et(!0);try{n(t)}finally{et(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=pc.bind(null,Ko,e),[r.memoizedState,e]},useRef:function(e){var t=ds();return e={current:e},t.memoizedState=e},useState:function(e){e=Ds(e);var t=e.queue,n=mc.bind(null,Ko,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:$s,useDeferredValue:function(e,t){return nc(ds(),e,t)},useTransition:function(){var e=Ds(!1);return e=ic.bind(null,Ko,e.queue,!0,!1),ds().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ko,a=ds();if(sa){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),ld===null)throw Error(i(349));dd&127||Ss(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Gs(ws.bind(null,r,o,e),[e]),r.flags|=2048,Vs(9,{destroy:void 0},Cs.bind(null,r,o,n,t),null),n},useId:function(){var e=ds(),t=ld.identifierPrefix;if(sa){var n=$i,r=Qi;n=(r&~(1<<32-tt(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Qo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=ts++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:lc,useFormState:Is,useActionState:Is,useOptimistic:function(e){var t=ds();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=gc.bind(null,Ko,!0,n),n.dispatch=t,[e,t]},useMemoCache:gs,useCacheRefresh:function(){return ds().memoizedState=fc.bind(null,Ko)},useEffectEvent:function(e){var t=ds(),n={impl:e};return t.memoizedState=n,function(){if(cd&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Sc={readContext:Oa,use:hs,useCallback:ec,useContext:Oa,useEffect:Ks,useImperativeHandle:Qs,useInsertionEffect:Ys,useLayoutEffect:Xs,useMemo:tc,useReducer:vs,useRef:Hs,useState:function(){return vs(_s)},useDebugValue:$s,useDeferredValue:function(e,t){return rc(fs(),qo.memoizedState,e,t)},useTransition:function(){var e=vs(_s)[0],t=fs().memoizedState;return[typeof e==`boolean`?e:ms(e),t]},useSyncExternalStore:xs,useId:uc,useHostTransitionStatus:lc,useFormState:Ls,useActionState:Ls,useOptimistic:function(e,t){return Os(fs(),qo,e,t)},useMemoCache:gs,useCacheRefresh:dc,useEffectEvent:Js},Cc={readContext:Oa,use:hs,useCallback:ec,useContext:Oa,useEffect:Ks,useImperativeHandle:Qs,useInsertionEffect:Ys,useLayoutEffect:Xs,useMemo:tc,useReducer:bs,useRef:Hs,useState:function(){return bs(_s)},useDebugValue:$s,useDeferredValue:function(e,t){var n=fs();return qo===null?nc(n,e,t):rc(n,qo.memoizedState,e,t)},useTransition:function(){var e=bs(_s)[0],t=fs().memoizedState;return[typeof e==`boolean`?e:ms(e),t]},useSyncExternalStore:xs,useId:uc,useHostTransitionStatus:lc,useFormState:Bs,useActionState:Bs,useOptimistic:function(e,t){var n=fs();return qo===null?(n.baseState=e,[e,n.queue.dispatch]):Os(n,qo,e,t)},useMemoCache:gs,useCacheRefresh:dc,useEffectEvent:Js};function wc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:w({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Tc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Wd(),i=bo(r);i.payload=t,n!=null&&(i.callback=n),t=xo(e,i,r),t!==null&&(qd(t,e,r),So(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Wd(),i=bo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=xo(e,i,r),t!==null&&(qd(t,e,r),So(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Wd(),r=bo(n);r.tag=2,t!=null&&(r.callback=t),t=xo(e,r,n),t!==null&&(qd(t,e,n),So(t,e,n))}};function Ec(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Wr(n,r)||!Wr(i,a):!0}function Dc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Tc.enqueueReplaceState(t,t.state,null)}function Oc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=w({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function kc(e){Si(e)}function Ac(e){console.error(e)}function jc(e){Si(e)}function Mc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Nc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Pc(e,t,n){return n=bo(n),n.tag=3,n.payload={element:null},n.callback=function(){Mc(e,t)},n}function Fc(e){return e=bo(e),e.tag=3,e}function Ic(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Nc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Nc(t,n,r),typeof i!=`function`&&(jd===null?jd=new Set([this]):jd.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Lc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ta(t,n,a,!0),n=Po.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Fo===null?of():n.alternate===null&&vd===0&&(vd=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===to?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Of(e,r,a)),!1;case 22:return n.flags|=65536,r===to?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Of(e,r,a)),!1}throw Error(i(435,n.tag))}return Of(e,r,a),of(),!1}if(sa)return t=Po.current,t===null?(r!==ua&&(t=Error(i(423),{cause:r}),_a(Wi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Wi(r,n),a=Pc(e.stateNode,r,a),Co(e,a),vd!==4&&(vd=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==ua&&(e=Error(i(422),{cause:r}),_a(Wi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Wi(o,n),wd===null?wd=[o]:wd.push(o),vd!==4&&(vd=2),t===null)return!0;r=Wi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Pc(n.stateNode,r,e),Co(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(jd===null||!jd.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Fc(a),Ic(a,e,n,r),Co(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Rc=Error(i(461)),zc=!1;function Bc(e,t,n,r){t.child=e===null?go(t,null,n,r):ho(t,e.child,n,r)}function Vc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Da(t),r=is(e,t,n,o,a,i),s=cs(),e!==null&&!zc?(ls(e,t,i),hl(e,t,i)):(sa&&s&&na(t),t.flags|=1,Bc(e,t,r,i),t.child)}function Hc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Fi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Uc(e,t,a,r,i)):(e=Ri(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!gl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Wr:n,n(o,r)&&e.ref===t.ref)return hl(e,t,i)}return t.flags|=1,e=Ii(a,r),e.ref=t.ref,e.return=t,t.child=e}function Uc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Wr(a,r)&&e.ref===t.ref){if(zc=!1,t.pendingProps=r=a,gl(e,i))e.flags&131072&&(zc=!0);else return t.lanes=e.lanes,hl(e,t,i)}}return Zc(e,t,n,r,i)}function Wc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Kc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Xa(t,a===null?null:a.cachePool),a===null?Mo():jo(t,a),Ro(t);else return r=t.lanes=536870912,Kc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Xa(t,null),Mo(),zo()):(Xa(t,a.cachePool),jo(t,a),zo(),t.memoizedState=null);return Bc(e,t,i,n),t.child}function Gc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Kc(e,t,n,r,i){var a=Ya();return a=a===null?null:{parent:Pa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Xa(t,null),Mo(),Ro(t),e!==null&&Ta(e,t,r,!0),t.childLanes=i,null}function qc(e,t){return t=ol({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Jc(e,t,n){return ho(t,e.child,null,n),e=qc(t,t.pendingProps),e.flags|=2,Bo(t),t.memoizedState=null,e}function Yc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(sa){if(r.mode===`hidden`)return e=qc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Gc(null,e);if(Lo(t),(e=oa)?(e=bm(e,la),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Zi===null?null:{id:Qi,overflow:$i},retryLane:536870912,hydrationErrors:null},n=Vi(e),n.return=t,t.child=n,aa=t,oa=null)):e=null,e===null)throw da(t);return t.lanes=536870912,null}return qc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Lo(t),a){if(t.flags&256)t.flags&=-257,t=Jc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(zc||Ta(e,t,n,!1),a=(n&e.childLanes)!==0,zc||a){if(ko.current===null){if(r=ld,r!==null&&(s=yt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ki(e,s),qd(r,e,s),Rc;of()}t=Jc(e,t,n)}else e=o.treeContext,oa=wm(s.nextSibling),aa=t,sa=!0,ca=null,la=!1,e!==null&&ia(t,e),t=qc(t,r),t.flags|=134221824;return t}return e=Ii(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Xc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Zc(e,t,n,r,i){return Da(t),n=is(e,t,n,r,void 0,i),r=cs(),e!==null&&!zc?(ls(e,t,i),hl(e,t,i)):(sa&&r&&na(t),t.flags|=1,Bc(e,t,n,i),t.child)}function Qc(e,t,n,r,i,a){return Da(t),t.updateQueue=null,n=os(t,r,n,i),as(e),r=cs(),e!==null&&!zc?(ls(e,t,a),hl(e,t,a)):(sa&&r&&na(t),t.flags|=1,Bc(e,t,n,a),t.child)}function $c(e,t,n,r,i){if(Da(t),t.stateNode===null){var a=Mi,o=n.contextType;typeof o==`object`&&o&&(a=Oa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Tc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},vo(t),o=n.contextType,a.context=typeof o==`object`&&o?Oa(o):Mi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(wc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Tc.enqueueReplaceState(a,a.state,null),Eo(t,r,a,i),To(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Oc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Mi,typeof u==`object`&&u&&(o=Oa(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Dc(t,a,r,o),_o=!1;var f=t.memoizedState;a.state=f,Eo(t,r,a,i),To(),l=t.memoizedState,s||f!==l||_o?(typeof d==`function`&&(wc(t,n,d,r),l=t.memoizedState),(c=_o||Ec(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,yo(e,t),o=t.memoizedProps,u=Oc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Mi,typeof l==`object`&&l&&(c=Oa(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Dc(t,a,r,c),_o=!1,f=t.memoizedState,a.state=f,Eo(t,r,a,i),To();var p=t.memoizedState;o!==d||f!==p||_o||e!==null&&e.dependencies!==null&&Ea(e.dependencies)?(typeof s==`function`&&(wc(t,n,s,r),p=t.memoizedState),(u=_o||Ec(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ea(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Xc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=ho(t,e.child,null,i),t.child=ho(t,null,n,i)):Bc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=hl(e,t,i),e}function el(e,t,n,r){return ha(),t.flags|=256,Bc(e,t,n,r),t.child}var tl={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function nl(e){return{baseLanes:e,cachePool:Za()}}function rl(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Sd),e}function il(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Vo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(sa){if(i?Io(t):zo(),(e=oa)?(e=bm(e,la),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Zi===null?null:{id:Qi,overflow:$i},retryLane:536870912,hydrationErrors:null},n=Vi(e),n.return=t,t.child=n,aa=t,oa=null)):e=null,e===null)throw da(t);return t.lanes=Sm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(zo(),i=t.mode,a=ol({mode:`hidden`,children:a},i),r=zi(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=nl(n),r.childLanes=rl(e,o,n),t.memoizedState=tl,Gc(null,r)):(Io(t),al(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return cl(e,t,a,o,r,c,s,n)}return i?(zo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Ii(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=zi(i,a,n,null),i.flags|=2):i=Ii(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Gc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=nl(n):(a=i.cachePool,a===null?a=Za():(s=Pa._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=rl(e,o,n),t.memoizedState=tl,Gc(e.child,r)):(Io(t),n=e.child,e=n.sibling,n=Ii(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function al(e,t){return t=ol({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function ol(e,t){return e=Pi(22,e,null,t),e.lanes=0,e}function sl(e,t,n){return ho(t,e.child,null,n),e=al(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function cl(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(Io(t),t.flags&=-257,sl(e,t,c)):t.memoizedState===null?(zo(),o=a.fallback,s=t.mode,a=ol({mode:`visible`,children:a.children},s),o=zi(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,ho(t,e.child,null,c),a=t.child,a.memoizedState=nl(c),a.childLanes=rl(e,r,c),t.memoizedState=tl,Gc(null,a)):(zo(),t.child=e.child,t.flags|=128,null);if(Io(t),Sm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,_a({value:a,source:null,stack:null})),sl(e,t,c)}if(zc||Ta(e,t,c,!1),r=(c&e.childLanes)!==0,zc||r){if(ko.current!==null)return sl(e,t,c);if(r=ld,r!==null&&(a=yt(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,ki(e,a),qd(r,e,a),Rc;return xm(o)||of(),sl(e,t,c)}return xm(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,oa=wm(o.nextSibling),aa=t,sa=!0,ca=null,la=!1,e!==null&&ia(t,e),t=al(t,a.children),t.flags|=134221824,t)}function ll(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ca(e.return,t,n)}function ul(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Wo(n)===null&&(t=e),e=e.sibling}return t}function dl(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function fl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function pl(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Vo.current;if(t.flags&128)return Ho(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Ho(t,o),i===`backwards`&&e!==null?(fl(e),Bc(e,t,r,n),fl(e)):Bc(e,t,r,n),r=sa?Ji:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ll(e,n,t);else if(e.tag===19)ll(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=ul(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,fl(t)),dl(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Wo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}dl(t,!0,n,null,a,r);break;case`together`:dl(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=ul(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),dl(t,!1,i,n,a,r)}return t.child}function ml(e,t,n){var r=t.pendingProps;return xa(t,t.type,r.value),Bc(e,t,r.children,n),t.child}function hl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),yd|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Ta(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Ii(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ii(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function gl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Ea(e)))}function _l(e,t,n){switch(t.tag){case 3:De(t,t.stateNode.containerInfo),xa(t,Pa,e.memoizedState.cache),ha();break;case 27:case 5:ke(t);break;case 4:De(t,t.stateNode.containerInfo);break;case 10:xa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Lo(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Io(t),t.flags|=128,null;r=Ta(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?il(e,t,n):(Io(t),e=hl(e,t,n),e===null?null:e.sibling)}Io(t);break;case 19:if(t.flags&128)return pl(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Ta(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return pl(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ho(t,Vo.current),r)break;return null;case 22:return t.lanes=0,Wc(e,t,n,t.pendingProps);case 24:xa(t,Pa,e.memoizedState.cache)}return hl(e,t,n)}function vl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)zc=!0;else{if(!gl(e,n)&&!(t.flags&128))return zc=!1,_l(e,t,n);zc=!!(e.flags&131072)}}else zc=!1,sa&&t.flags&1048576&&ta(t,Ji,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=io(t.elementType),t.type=e,typeof e==`function`)Fi(e)?(r=Oc(e,r),t.tag=1,t=$c(null,t,e,r,n)):(t.tag=0,t=Zc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===ne){t.tag=11,t=Vc(null,t,e,r,n);break a}if(a===ae){t.tag=14,t=Hc(null,t,e,r,n);break a}if(a===A){t.tag=10,t.type=e,t=ml(null,t,n);break a}}throw t=he(e)||e,Error(i(306,t,``))}}return t;case 0:return Zc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Oc(r,t.pendingProps),$c(e,t,r,a,n);case 3:a:{if(De(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,yo(e,t),Eo(t,r,null,n);var s=t.memoizedState;if(r=s.cache,xa(t,Pa,r),r!==o.cache&&wa(t,[Pa],n,!0),To(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=el(e,t,r,n);break a}if(r!==a){a=Wi(Error(i(424)),t),_a(a),t=el(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(oa=wm(e.firstChild),aa=t,sa=!0,ca=null,la=!0,n=go(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(ha(),r===a){t=hl(e,t,n);break a}Bc(e,t,r,n)}t=t.child}return t;case 26:return Xc(e,t),e===null?(n=Jm(t.type,null,t.pendingProps,null))?t.memoizedState=n:sa||(t.stateNode=Op(t.type,t.pendingProps,Te.current,t)):t.memoizedState=Jm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ke(t),e===null&&sa&&(r=t.stateNode=Am(t.type,t.pendingProps,Te.current),aa=t,la=!0,a=oa,Lp(t.type)?(Tm=a,oa=wm(r.firstChild)):oa=a),Bc(e,t,t.pendingProps.children,n),Xc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&sa&&((a=r=oa)&&(r=vm(r,t.type,t.pendingProps,la),r===null?a=!1:(t.stateNode=r,aa=t,oa=wm(r.firstChild),la=!1,a=!0)),a||da(t)),ke(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,kp(a,o)?r=null:s!==null&&kp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=is(e,t,ss,null,null,n),Sh._currentValue=a),Xc(e,t),Bc(e,t,r,n),t.child;case 6:return e===null&&sa&&((e=n=oa)&&(n=ym(n,t.pendingProps,la),n===null?e=!1:(t.stateNode=n,aa=t,oa=null,e=!0)),e||da(t)),null;case 13:return il(e,t,n);case 4:return De(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ho(t,null,r,n):Bc(e,t,r,n),t.child;case 11:return Vc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Xc(e,t),Bc(e,t,r,n),t.child;case 8:return Bc(e,t,t.pendingProps.children,n),t.child;case 12:return Bc(e,t,t.pendingProps.children,n),t.child;case 10:return ml(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,Da(t),a=Oa(a),r=r(a),t.flags|=1,Bc(e,t,r,n),t.child;case 14:return Hc(e,t,t.type,t.pendingProps,n);case 15:return Uc(e,t,t.type,t.pendingProps,n);case 19:return pl(e,t,n);case 31:return Yc(e,t,n);case 22:return Wc(e,t,n,t.pendingProps);case 24:return Da(t),r=Oa(Pa),e===null?(a=Ya(),a===null&&(a=ld,o=Fa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},vo(t),xa(t,Pa,a)):((e.lanes&n)!==0&&(yo(e,t),Eo(t,null,null,n),To()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,xa(t,Pa,r),r!==a.cache&&wa(t,[Pa],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),xa(t,Pa,r))),Bc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:sa&&na(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Xc(e,t),Bc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function yl(e){e.flags|=4}function bl(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?lh(t,r):lh(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(nf())e.flags|=8192;else throw ao=to,$a}}else e.flags&=-16777217}function xl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!uh(t)){if(nf())e.flags|=8192;else throw ao=to,$a}}function Sl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:pt(),e.lanes|=t,Cd|=t)}function Cl(e,t){if(!sa)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function wl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Tl(e,t,n){var r=t.pendingProps;switch(ra(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wl(t),null;case 1:return wl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Sa(Pa),Oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ma(t)?yl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ga())),wl(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(yl(t),o===null?(wl(t),bl(t,a,null,r,n)):(wl(t),xl(t,o))):o?o===e.memoizedState?(wl(t),t.flags&=-16777217):(yl(t),wl(t),xl(t,o)):(e=e.memoizedProps,e!==r&&yl(t),wl(t),bl(t,a,e,r,n)),null;case 27:if(Ae(t),n=Te.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&yl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return wl(t),t.subtreeFlags&=-33554433,null}e=Ce.current,ma(t)?fa(t,e):(e=Am(a,r,n),t.stateNode=e,yl(t))}return wl(t),t.subtreeFlags&=-33554433,null;case 5:if(Ae(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&yl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return wl(t),t.subtreeFlags&=-33554433,null}if(o=Ce.current,ma(t))fa(t,o);else{var s=Tp(Te.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Tt]=t,o[Et]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(vp(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&yl(t)}}return wl(t),t.subtreeFlags&=-33554433,bl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&yl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=Te.current,ma(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=aa,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Tt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||hp(e.nodeValue,n)),e||da(t,!0)}else e=Tp(e).createTextNode(r),e[Tt]=t,t.stateNode=e}return wl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ma(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Tt]=t}else ha(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;wl(t),e=!1}else n=ga(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Bo(t),t):(Bo(t),null);if(t.flags&128)throw Error(i(558))}return wl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ma(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Tt]=t}else ha(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;wl(t),a=!1}else a=ga(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Bo(t),t):(Bo(t),null)}return Bo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Sl(t,t.updateQueue),wl(t),null);case 4:return Oe(),e===null&&ap(t.stateNode.containerInfo),t.flags|=67108864,wl(t),null;case 10:return Sa(t.type),wl(t),null;case 19:if(Uo(t),r=t.memoizedState,r===null)return wl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)Cl(r,!1);else{if(vd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Wo(e),o!==null){for(t.flags|=128,Cl(r,!1),e=o.updateQueue,t.updateQueue=e,Sl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Li(n,e),n=n.sibling;return Ho(t,Vo.current&1|2),sa&&ea(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ue()>kd&&(t.flags|=128,a=!0,Cl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Wo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Sl(t,e),Cl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!sa)return wl(t),null}else 2*Ue()-r.renderingStartTime>kd&&n!==536870912&&(t.flags|=128,a=!0,Cl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ue(),e.sibling=null,o=Vo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||sa?Ho(t,o):(n=o,M(Po,t),M(Vo,n),Fo===null&&(Fo=t)),sa&&ea(t,r.treeForkCount),e}return wl(t),null;case 22:case 23:return Bo(t),No(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(wl(t),t.subtreeFlags&6&&(t.flags|=8192)):wl(t),n=t.updateQueue,n!==null&&Sl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Se(Ja),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Sa(Pa),wl(t),null;case 25:return null;case 30:return t.flags|=33554432,wl(t),null}throw Error(i(156,t.tag))}function El(e,t){switch(ra(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Sa(Pa),Oe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ae(t),null;case 31:if(t.memoizedState!==null){if(Bo(t),t.alternate===null)throw Error(i(340));ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Bo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Uo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Oe(),null;case 10:return Sa(t.type),null;case 22:case 23:return Bo(t),No(),e!==null&&Se(Ja),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Sa(Pa),null;case 25:return null;default:return null}}function Dl(e,t){switch(ra(t),t.tag){case 3:Sa(Pa),Oe();break;case 26:case 27:case 5:Ae(t);break;case 4:Oe();break;case 31:t.memoizedState!==null&&Bo(t);break;case 13:Bo(t);break;case 19:Uo(t);break;case 10:Sa(t.type);break;case 22:case 23:Bo(t),No(),e!==null&&Se(Ja);break;case 24:Sa(Pa)}}function Ol(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Df(t,t.return,e)}}function kl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Df(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Df(t,t.return,e)}}function Al(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Oo(t,n)}catch(t){Df(e,e.return,t)}}}function jl(e,t,n){n.props=Oc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Df(e,t,n)}}function Ml(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=yi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Yp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Xp(e);f(e.child,!1,pm,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Df(e,t,n)}}function Nl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Df(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Df(e,t,n)}else n.current=null}}function Pl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)hm(e.stateNode,t[n])}function Fl(e){for(var t=e.return;t!==null&&(Rl(t)&&hm(e.stateNode,t.stateNode),!Ll(t));)t=t.return}function Il(e){for(var t=e.return;t!==null&&(Rl(t)&&gm(e.stateNode,t.stateNode),!Ll(t));)t=t.return}function Ll(e){return e.tag===5||e.tag===3||e.tag===27}function Rl(e){return e&&e.tag===7&&e.stateNode!==null}function zl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Df(e,e.return,t)}}function Bl(e,t,n){try{var r=e.stateNode;bp(r,e.type,n,t),r[Et]=t}catch(t){Df(e,e.return,t)}}function Vl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Lp(e.type)||e.tag===4}function Hl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Vl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Lp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ul(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Sn)),Pl(e,r),Yt=!0;else if(i!==4&&(i===27&&(Pl(e,r),r=null,Lp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Ul(e,t,n,r),e=e.sibling;e!==null;)Ul(e,t,n,r),e=e.sibling}function Wl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),Pl(e,r),Yt=!0;else if(i!==4&&(i===27&&(Pl(e,r),r=null,Lp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Wl(e,t,n,r),e=e.sibling;e!==null;)Wl(e,t,n,r),e=e.sibling}function Gl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);vp(t,r,n),t[Tt]=e,t[Et]=n}catch(t){Df(e,e.return,t)}}var Kl=!1,ql=null;function Jl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Kl=!0)}var Yl=null;function Xl(){var e=Yl;return Yl=null,e}var Zl=0;function Ql(e,t,n,r,i){return Zl=0,$l(e.child,t,n,r,i)}function $l(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Up(o);r.push(s),s.view&&(a=!0)}else a||Up(o).view&&(a=!0);Kl=!0,Bp(o,Zl===0?t:t+`_`+Zl,n),Zl++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||$l(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function eu(e,t){for(;e!==null;)e.tag===5?Vp(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||eu(e.child,t),e=e.sibling}function tu(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(tu(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=xi(t.default,t.share),t!==`none`&&(Ql(e,n,t,null,!1)||eu(e.child,!1))}e=e.sibling}}function nu(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=yi(r,n),a=xi(r.default,n.paired?r.share:r.enter);a===`none`?tu(e):Ql(e,i,a,null,!1)?(tu(e),n.paired||t||Kd(e,r.onEnter)):eu(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)nu(e,t),e=e.sibling;else tu(e)}function ru(e){if(ql!==null&&ql.size!==0){var t=ql;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=xi(n.default,n.share);if(a!==`none`&&(Ql(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Kd(e,n.onShare)):eu(e.child,!1)),t.delete(r),t.size===0)break}}}ru(e)}e=e.sibling}}}function iu(e){if(e.tag===30){var t=e.memoizedProps,n=yi(t,e.stateNode),r=ql===null?void 0:ql.get(n),i=xi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Ql(e,n,i,null,!1)?r===void 0?Kd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,ql.delete(n),Kd(e,t.onShare)):eu(e.child,!1)),ql!==null&&ru(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)iu(e),e=e.sibling;else ql!==null&&ru(e)}function au(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=yi(t,e.stateNode);t=xi(t.default,t.update),e.flags&=-5,t!==`none`&&Ql(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&au(e);e=e.sibling}}function ou(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,eu(e.child,!1))}ou(e)}e=e.sibling}}function su(e){if(e.tag===30)e.stateNode.paired=null,eu(e.child,!1),ou(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)su(e),e=e.sibling;else ou(e)}function cu(e){for(e=e.child;e!==null;)e.tag===30?eu(e.child,!1):e.subtreeFlags&33554432&&cu(e),e=e.sibling}function lu(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Zl<a.length){var l=a[Zl],u=Up(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Bp(c,Zl===0?n:n+`_`+Zl,i),s&&e.flags&4||(Yl===null&&(Yl=[]),Yl.push(c,Zl===0?r:r+`_`+Zl,t.memoizedProps)),Zl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:lu(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function uu(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=yi(n,r),a=xi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(Wp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Zl=0,i=lu(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Kd(e,n.onUpdate))}else e.subtreeFlags&33554432&&uu(e,t);e=e.sibling}}var du=!1,fu=!1,pu=!1,mu=!1,hu=typeof WeakSet==`function`?WeakSet:Set,gu=null,_u=!1,vu=!1,yu=!1,bu=!1;function xu(e,t,n){if(e=e.containerInfo,Cp=jh,e=Yr(e),Xr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(wp={focusedElem:e,selectionRange:r},jh=!1,n=(n&335544064)===n,gu=t,t=n?9270:1024;gu!==null;){if(e=gu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&iu(r[a]);if(e.alternate===null&&e.flags&2)n&&Jl(e),Su(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&iu(r),Su(n);continue}if(r!==null&&r.memoizedState!==null){n&&Jl(e),Su(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,gu=r):(n&&au(e),Su(n))}}ql=null}function Su(e){for(;gu!==null;){var t=gu,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=Oc(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){Df(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)_m(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:_m(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=yi(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=xi(a.default,a.update),a!==`none`&&Ql(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,gu=r;break}gu=t.return}}function Cu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Uu(e,n),r&4&&Ol(5,n);break;case 1:if(Uu(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Df(n,n.return,e)}else{var i=Oc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Df(n,n.return,e)}}}r&64&&Al(n),r&512&&Ml(n,n.return);break;case 3:if(Uu(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Oo(e,t)}catch(e){Df(n,n.return,e)}}break;case 27:t===null&&r&4&&Gl(n);case 26:case 5:Uu(e,n),t===null&&r&4&&zl(n),r&512&&Ml(n,n.return);break;case 12:Uu(e,n);break;case 31:Uu(e,n),r&4&&Mu(e,n);break;case 13:Uu(e,n),r&4&&Nu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=jf.bind(null,n),Cm(e,n))));break;case 22:if(r=n.memoizedState!==null||du,!r){var a=t!==null&&t.memoizedState!==null||fu;t=du,i=fu,du=r,(fu=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Gu(e,n,r)):Uu(e,n),du=t,fu=i}break;case 30:Uu(e,n),r&512&&Ml(n,n.return);break;case 7:r&512&&Ml(n,n.return);default:Uu(e,n)}}function wu(e,t){for(e=e.child;e!==null;)Tu(e,t),e=e.sibling}function Tu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){Df(e,e.return,t)}Eu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Yt=!0}catch(t){Df(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?zp(s,!0):zp(e.stateNode,!1)}catch(t){Df(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&wu(e,t);break;default:wu(e,t)}}function Eu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:Tu(n,r);break a;case 22:n.memoizedState===null&&Eu(n,r);break a;default:Eu(n,r)}}e=e.sibling}}function Du(e){var t=e.alternate;t!==null&&(e.alternate=null,Du(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Pt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Ou=null,ku=!1;function Au(e,t,n){for(n=n.child;n!==null;)ju(e,t,n),n=n.sibling}function ju(e,t,n){if($e&&typeof $e.onCommitFiberUnmount==`function`)try{$e.onCommitFiberUnmount(Qe,n)}catch{}switch(n.tag){case 26:fu||Nl(n,t),Au(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!fu&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:fu||Nl(n,t),Il(n);var r=Ou,i=ku;Lp(n.type)&&(Ou=n.stateNode,ku=!1),Au(e,t,n),jm(n.stateNode,n.type,n.memoizedProps),Ou=r,ku=i;break;case 5:fu||Nl(n,t),Il(n);case 6:if(n.tag===6&&Il(n),r=Ou,i=ku,Ou=null,Au(e,t,n),Ou=r,ku=i,Ou!==null){if(ku)try{(Ou.nodeType===9?Ou.body:Ou.nodeName===`HTML`?Ou.ownerDocument.body:Ou).removeChild(n.stateNode),Yt=!0}catch(e){Df(n,t,e)}else try{Ou.removeChild(n.stateNode),Yt=!0}catch(e){Df(n,t,e)}}break;case 18:Ou!==null&&(ku?(e=Ou,Rp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),rg(e)):Rp(Ou,n.stateNode));break;case 4:r=Ou,i=ku,Ou=n.stateNode.containerInfo,ku=!0,Au(e,t,n),Ou=r,ku=i;break;case 0:case 11:case 14:case 15:kl(2,n,t),fu||kl(4,n,t),Au(e,t,n);break;case 1:fu||(Nl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&jl(n,t,r)),Au(e,t,n);break;case 21:Au(e,t,n);break;case 22:fu=(r=fu)||n.memoizedState!==null,Au(e,t,n),fu=r;break;case 30:Nl(n,t),Au(e,t,n);break;case 7:fu||Nl(n,t),Au(e,t,n);break;default:Au(e,t,n)}}function Mu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{rg(e)}catch(e){Df(t,t.return,e)}}}function Nu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{rg(e)}catch(e){Df(t,t.return,e)}}function Pu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new hu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new hu),t;default:throw Error(i(435,e.tag))}}function Fu(e,t){var n=Pu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Mf.bind(null,e,t);t.then(r,r)}})}function Iu(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Lp(l.type)){Ou=l.stateNode,ku=!1;break a}break;case 5:Ou=l.stateNode,ku=!1;break a;case 3:case 4:Ou=l.stateNode.containerInfo,ku=!0;break a}l=l.return}if(Ou===null)throw Error(i(160));ju(s,c,o),Ou=null,ku=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Ru(t,e,n),t=t.sibling}var Lu=null;function Ru(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}Iu(t,e,n),zu(e),a&4&&(kl(3,e,e.return),Ol(3,e),kl(5,e,e.return));break;case 1:Iu(t,e,n),zu(e),a&512&&(fu||r===null||Nl(r,r.return)),a&64&&du&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Lu,Iu(t,e,n),zu(e),a&512&&(fu||r===null||Nl(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(du)e.stateNode=Op(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[Mt]||r[Tt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),vp(r,t,n),r[Tt]=e,zt(r),t=r;break a;case`link`:if(o=oh(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),vp(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=oh(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),vp(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[Tt]=e,zt(r),t=r}e.stateNode=t}}else du||sh(o,e.type,e.stateNode)}else e.stateNode=th(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Bl(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||fu||t.parentNode.removeChild(t)):a.count--,n===null?du||sh(o,e.type,e.stateNode):th(o,n,e.memoizedProps))}break;case 27:Iu(t,e,n),zu(e),a&512&&(fu||r===null||Nl(r,r.return)),r!==null&&a&4&&Bl(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=pu,pu=!1,Iu(t,e,n),pu=o,zu(e),a&512&&(fu||r===null||Nl(r,r.return)),e.flags&32){t=e.stateNode;try{mn(t,``),Yt=!0}catch(t){Df(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Bl(e,t,r===null?t:r.memoizedProps)),a&1024&&(mu=!0);break;case 6:if(Iu(t,e,n),zu(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Yt=!0}catch(t){Df(e,e.return,t)}}break;case 3:if(Yt=!1,ah=null,o=Lu,Lu=Fm(t.containerInfo),Iu(t,e,n),Lu=o,zu(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{rg(t.containerInfo)}catch(t){Df(e,e.return,t)}mu&&(mu=!1,Bu(e)),Yt=!1;break;case 4:a=pu,pu=du,r=Xt(),o=Lu,Lu=Fm(e.stateNode.containerInfo),Iu(t,e,n),zu(e),Lu=o,Yt&&vu&&(yu=!0),Yt=r,pu=a;break;case 12:Iu(t,e,n),zu(e);break;case 31:Iu(t,e,n),zu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Fu(e,t)));break;case 13:Iu(t,e,n),zu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Dd=Ue()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Fu(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=du,l=fu,u=pu;du=c||o,pu=u||o,fu=l||s,Iu(t,e,n),fu=l,pu=u,du=c,zu(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||du||fu||(t=s||fu,n=du,r=fu,du=o||du,fu=t,Wu(e,2),du=n,fu=r),!o&&pu||wu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Fu(e,n))));break;case 19:Iu(t,e,n),zu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Fu(e,t)));break;case 30:a&512&&(fu||r===null||Nl(r,r.return)),a=Xt(),o=vu,s=(n&335544064)===n,c=e.memoizedProps,vu=s&&xi(c.default,c.update)!==`none`,Iu(t,e,n),zu(e),s&&r!==null&&Yt&&(e.flags|=4),vu=o,Yt=a;break;case 21:break;case 7:a&512&&(fu||r===null||Nl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Iu(t,e,n),zu(e)}}function zu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Vl(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Rl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Ll(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;Wl(e,Hl(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(mn(l,``),n.flags&=-33),Wl(e,Hl(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Ul(e,Hl(e),u,s);break;default:throw Error(i(161))}}catch(t){Df(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Bu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Bu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,jh=!0,t.reset(),jh=!1),e=e.sibling}}function Vu(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Hu(t,e),t=t.sibling;else uu(t,!1)}function Hu(e,t){var n=e.alternate;if(n===null)nu(e,!1);else switch(e.tag){case 3:if(bu=_u=!1,Xl(),Vu(t,e),!_u&&!yu){if(e=Yl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Vp(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),bu=!0}Yl=null;break;case 5:Vu(t,e);break;case 4:r=_u,_u=!1,Vu(t,e),_u&&(yu=!0),_u=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Vu(t,e):nu(e,!1));break;case 30:r=_u,i=Xl(),_u=!1,Vu(t,e),_u&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=yi(a,o),o=yi(n.memoizedProps,o);var s=xi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Zl=0,t=lu(e,n,t,o,s,a,!0),Zl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Kd(e,e.memoizedProps.onUpdate),Yl=i):i!==null&&(i.push.apply(i,Yl),Yl=i),_u=e.flags&32?!0:r;break;default:Vu(t,e)}}function Uu(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Cu(e,t.alternate,t),t=t.sibling}function Wu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:kl(4,n,n.return),Wu(n,r);break;case 1:Nl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&jl(n,n.return,i),Wu(n,r);break;case 27:r&2&&jm(n.stateNode,n.type,n.memoizedProps);case 5:Nl(n,n.return),n.tag!==5&&n.tag!==27||Il(n),Wu(n,r);break;case 6:Il(n);break;case 26:Nl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||fu||i.parentNode.removeChild(i),Wu(n,r);break;case 22:n.memoizedState===null&&Wu(n,r);break;case 30:Nl(n,n.return),Wu(n,r);break;case 7:Nl(n,n.return);default:Wu(n,r)}e=e.sibling}}function Gu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Gu(i,a,n),Ol(4,a);break;case 1:if(Gu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Df(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)Do(l[i],c)}catch(e){Df(r,r.return,e)}}s&&o&64&&Al(a),Ml(a,a.return);break;case 27:n&2&&Gl(a);case 5:a.tag!==5&&a.tag!==27||Fl(a),Gu(i,a,n),s&&r===null&&o&4&&zl(a),Ml(a,a.return);break;case 6:Fl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||du||sh(Fm(c.ownerDocument),a.type,c),Gu(i,a,n),s&&r===null&&o&4&&zl(a),Ml(a,a.return);break;case 12:Gu(i,a,n);break;case 31:Gu(i,a,n),s&&o&4&&Mu(i,a);break;case 13:Gu(i,a,n),s&&o&4&&Nu(i,a);break;case 22:a.memoizedState===null&&Gu(i,a,n),Ml(a,a.return);break;case 30:Gu(i,a,n),Ml(a,a.return);break;case 7:Ml(a,a.return);default:Gu(i,a,n)}t=t.sibling}}function Ku(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Ia(n))}function qu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ia(e))}function Ju(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Yu(e,t,n,r),t=t.sibling;else i&&cu(t)}function Yu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&su(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Ju(e,t,n,r),a&2048&&Ol(9,t);break;case 1:Ju(e,t,n,r);break;case 3:Ju(e,t,n,r),i&&bu&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Ia(a)));break;case 12:if(a&2048){Ju(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){Df(t,t.return,e)}}else Ju(e,t,n,r);break;case 31:Ju(e,t,n,r);break;case 13:Ju(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&su(t),o._visibility&2?Ju(e,t,n,r):(o._visibility|=2,Xu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&su(s),o._visibility&2?Ju(e,t,n,r):Zu(e,t)),a&2048&&Ku(s,t);break;case 24:Ju(e,t,n,r),a&2048&&qu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(eu(a.child,!0),eu(t.child,!0))),Ju(e,t,n,r);break;default:Ju(e,t,n,r)}}function Xu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Xu(a,o,s,c,i),Ol(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Xu(a,o,s,c,i)):u._visibility&2?Xu(a,o,s,c,i):Zu(a,o),i&&l&2048&&Ku(o.alternate,o);break;case 24:Xu(a,o,s,c,i),i&&l&2048&&qu(o.alternate,o);break;default:Xu(a,o,s,c,i)}t=t.sibling}}function Zu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Zu(n,r),i&2048&&Ku(r.alternate,r);break;case 24:Zu(n,r),i&2048&&qu(r.alternate,r);break;default:Zu(n,r)}t=t.sibling}}var Qu=8192;function $u(e,t,n){if(e.subtreeFlags&Qu)for(e=e.child;e!==null;)ed(e,t,n),e=e.sibling}function ed(e,t,n){switch(e.tag){case 26:$u(e,t,n),e.flags&Qu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&fh(n,e)):ph(n,Lu,e.memoizedState,e.memoizedProps));break;case 5:$u(e,t,n),e.flags&Qu&&(e=e.stateNode,(t&335544128)===t&&fh(n,e));break;case 3:case 4:var r=Lu;Lu=Fm(e.stateNode.containerInfo),$u(e,t,n),Lu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Qu,Qu=16777216,$u(e,t,n),Qu=r):$u(e,t,n));break;case 30:if((e.flags&Qu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,ql===null&&(ql=new Map),ql.set(r,i)}$u(e,t,n);break;default:$u(e,t,n)}}function td(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function nd(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];gu=r,ad(r,e)}td(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)rd(e),e=e.sibling}function rd(e){switch(e.tag){case 0:case 11:case 15:nd(e),e.flags&2048&&kl(9,e,e.return);break;case 3:nd(e);break;case 12:nd(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,id(e)):nd(e);break;default:nd(e)}}function id(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];gu=r,ad(r,e)}td(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:kl(8,t,t.return),id(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,id(t));break;default:id(t)}e=e.sibling}}function ad(e,t){for(;gu!==null;){var n=gu;switch(n.tag){case 0:case 11:case 15:kl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Ia(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,gu=r;else a:for(n=e;gu!==null;){r=gu;var i=r.sibling,a=r.return;if(Du(r),r===n){gu=null;break a}if(i!==null){i.return=a,gu=i;break a}gu=a}}}var od={getCacheForType:function(e){var t=Oa(Pa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Oa(Pa).controller.signal}},sd=typeof WeakMap==`function`?WeakMap:Map,cd=0,ld=null,ud=null,dd=0,fd=0,pd=null,md=!1,hd=!1,gd=!1,_d=0,vd=0,yd=0,bd=0,xd=0,Sd=0,Cd=0,wd=null,Td=null,Ed=!1,Dd=0,Od=0,kd=1/0,Ad=null,jd=null,Md=0,Nd=null,Pd=null,Fd=0,Id=0,Ld=null,Rd=null,zd=null,Bd=null,Vd=null,Hd=0,Ud=null;function Wd(){return cd&2&&dd!==0?dd&-dd:j.T===null?St():Jf()}function Gd(){if(Sd===0){if(!(dd&536870912)||sa){var e=ot;ot<<=1,!(ot&3932160)&&(ot=262144),Sd=e}else Sd=536870912}return e=Po.current,e!==null&&(e.flags|=32),Sd}function Kd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Yp(yi(e.memoizedProps,n))),Bd===null&&(Bd=[]),Bd.push(t.bind(null,r))}}function qd(e,t,n){(e===ld&&(fd===2||fd===9)||e.cancelPendingCommit!==null)&&(ef(e,0),Zd(e,dd,Sd,!1)),ht(e,n),cd&2&&e===ld||(e===ld&&(!(cd&2)&&(bd|=n),vd===4&&Zd(e,dd,Sd,!1)),Bf(e))}function Jd(e,t,n){if(cd&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||ut(e,t),a=r?lf(e,t):sf(e,t,!0),o=r;do{if(a===0){hd&&!r&&Zd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Xd(n))a=sf(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=wd;var l=c.current.memoizedState.isDehydrated;if(l&&(ef(c,s).flags|=256),s=sf(c,s,!1),s!==2&&s!==6){if(gd&&!l){c.errorRecoveryDisabledLanes|=o,bd|=o,a=4;break a}o=Td,Td=a,o!==null&&(Td===null?Td=o:Td.push.apply(Td,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){ef(e,0),Zd(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Zd(r,t,Sd,!md);break a;case 2:Td=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Dd+300-Ue(),10<a)){if(Zd(r,t,Sd,!md),lt(r,0,!0)!==0)break a;Fd=t,r.timeoutHandle=jp(Yd.bind(null,r,n,Td,Ad,Ed,t,Sd,bd,Cd,md,o,`Throttled`,-0,0),a);break a}Yd(r,n,Td,Ad,Ed,t,Sd,bd,Cd,md,o,null,-0,0)}break}}while(1);Bf(e)}function Yd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Sn},ql=null,ed(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=_h.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?Dd-Ue():(a&4194048)===a?Od-Ue():0,m=hh(d,m),m!==null)?(Fd=a,e.cancelPendingCommit=m(gf.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Zd(e,a,o,!l)):gf(e,t,a,n,r,i,o,s,c,l,u,d)}function Xd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Ur(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Zd(e,t,n,r){t=dt(e,t),t&=~xd,t&=~bd,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-tt(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&_t(e,n,t)}function Qd(){return cd&6?!0:(Vf(0,!1),!1)}function $d(){if(ud!==null){if(fd===0)var e=ud.return;else e=ud,ba=ya=null,us(e),co=null,lo=0,e=ud;for(;e!==null;)Dl(e.alternate,e),e=e.return;ud=null}}function ef(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,Mp(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Fd=0,$d(),ld=e,ud=n=Ii(e.current,null),dd=t,fd=0,pd=null,md=!1,hd=ut(e,t),gd=!1,Cd=Sd=xd=bd=yd=vd=0,Td=wd=null,Ed=!1,_d=dt(e,t),Ei(),n}function tf(e,t){Ko=null,j.H=bc,t===Qa||t===eo?(t=oo(),fd=3):t===$a?(t=oo(),fd=4):fd=t===Rc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,pd=t,ud===null&&(vd=1,Mc(e,Wi(t,e.current)))}function nf(){var e=Po.current;return e===null?!0:(dd&4194048)===dd?Fo===null:(dd&62914560)===dd||dd&536870912?e===Fo:!1}function rf(){var e=j.H;return j.H=bc,e===null?bc:e}function af(){var e=j.A;return j.A=od,e}function of(){vd=4,md||(dd&4194048)!==dd&&Po.current!==null||(hd=!0),!(yd&134217727)&&!(bd&134217727)||ld===null||Zd(ld,dd,Sd,!1)}function sf(e,t,n){var r=cd;cd|=2;var i=rf(),a=af();(ld!==e||dd!==t)&&(Ad=null,ef(e,t)),t=!1;var o=vd;a:do try{if(fd!==0&&ud!==null){var s=ud,c=pd;switch(fd){case 8:$d(),o=6;break a;case 3:case 2:case 9:case 6:Po.current===null&&(t=!0);var l=fd;if(fd=0,pd=null,pf(e,s,c,l),n&&hd){o=0;break a}break;default:l=fd,fd=0,pd=null,pf(e,s,c,l)}}cf(),o=vd;break}catch(t){tf(e,t)}while(1);return t&&e.shellSuspendCounter++,ba=ya=null,cd=r,j.H=i,j.A=a,ud===null&&(ld=null,dd=0,Ei()),o}function cf(){for(;ud!==null;)df(ud)}function lf(e,t){var n=cd;cd|=2;var r=rf(),a=af();ld!==e||dd!==t?(Ad=null,kd=Ue()+500,ef(e,t)):hd=ut(e,t);a:do try{if(fd!==0&&ud!==null){t=ud;var o=pd;b:switch(fd){case 1:fd=0,pd=null,pf(e,t,o,1);break;case 2:case 9:if(no(o)){fd=0,pd=null,ff(t);break}t=function(){fd!==2&&fd!==9||ld!==e||(fd=7),Bf(e)},o.then(t,t);break a;case 3:fd=7;break a;case 4:fd=5;break a;case 7:no(o)?(fd=0,pd=null,ff(t)):(fd=0,pd=null,pf(e,t,o,7));break;case 5:var s=null;switch(ud.tag){case 26:s=ud.memoizedState;case 5:case 27:var c=ud;if(s?uh(s):c.stateNode.complete){fd=0,pd=null;var l=c.sibling;if(l!==null)ud=l;else{var u=c.return;u===null?ud=null:(ud=u,mf(u))}break b}}fd=0,pd=null,pf(e,t,o,5);break;case 6:fd=0,pd=null,pf(e,t,o,6);break;case 8:$d(),vd=6;break a;default:throw Error(i(462))}}uf();break}catch(t){tf(e,t)}while(1);return ba=ya=null,j.H=r,j.A=a,cd=n,ud===null?(ld=null,dd=0,Ei(),vd):0}function uf(){for(;ud!==null&&!Ve();)df(ud)}function df(e){var t=vl(e.alternate,e,_d);e.memoizedProps=e.pendingProps,t===null?mf(e):ud=t}function ff(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Qc(n,t,t.pendingProps,t.type,void 0,dd);break;case 11:t=Qc(n,t,t.pendingProps,t.type.render,t.ref,dd);break;case 5:us(t);var r=t;r===aa&&(sa?(pa(r),r.tag===5&&r.stateNode!=null&&(oa=r.stateNode)):(pa(r),sa=!0));default:Dl(n,t),t=ud=Li(t,_d),t=vl(n,t,_d)}e.memoizedProps=e.pendingProps,t===null?mf(e):ud=t}function pf(e,t,n,r){ba=ya=null,us(t),co=null,lo=0;var i=t.return;try{if(Lc(e,i,t,n,dd)){vd=1,Mc(e,Wi(n,e.current)),ud=null;return}}catch(t){if(i!==null)throw ud=i,t;vd=1,Mc(e,Wi(n,e.current)),ud=null;return}t.flags&32768?(sa||r===1?e=!0:hd||dd&536870912?e=!1:(md=e=!0,(r===2||r===9||r===3||r===6)&&(r=Po.current,r!==null&&r.tag===13&&(r.flags|=16384))),hf(t,e)):mf(t)}function mf(e){var t=e;do{if(t.flags&32768){hf(t,md);return}e=t.return;var n=Tl(t.alternate,t,_d);if(n!==null){ud=n;return}if(t=t.sibling,t!==null){ud=t;return}ud=t=e}while(t!==null);vd===0&&(vd=5)}function hf(e,t){do{var n=El(e.alternate,e);if(n!==null){n.flags&=32767,ud=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){ud=e;return}ud=e=n}while(e!==null);vd=6,ud=null}function gf(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do wf();while(Md!==0);if(cd&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===ld&&(ud=ld=null,dd=0),Pd=t,Nd=e,Fd=n,Ld=a,Rd=r,_f(e,t,n,s,c,l,f)}}function _f(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(Id=s,s|=Ti,gt(e,n,s,r,i,a),Bd=null,(n&335544064)===n?(Vd=za(e),r=10262):(Vd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,Nf(qe,function(){return Tf(),null})):(e.callbackNode=null,e.callbackPriority=0),Kl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=j.T,j.T=null,i=_e.p,_e.p=2,a=cd,cd|=4;try{xu(e,t,n)}finally{cd=a,_e.p=i,j.T=r}}Md=1,Kl?zd=qp(o,e.containerInfo,Vd,bf,xf,yf,Sf,Tf,vf,null,null):(bf(),xf(),Sf())}function vf(e){if(Md!==0){var t=Nd.onRecoverableError;t(e,{componentStack:null})}}function yf(){Md===3&&(Md=0,Hu(Pd,Nd),Md=4)}function bf(){if(Md===1){Md=0;var e=Nd,t=Pd,n=Fd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=j.T,j.T=null;var i=_e.p;_e.p=2;var a=cd;cd|=4;try{vu=yu=!1,Ru(t,e,n),n=wp;var o=Yr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Jr(s.ownerDocument.documentElement,s)){if(c!==null&&Xr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=qr(s,h),v=qr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}jh=!!Cp,wp=Cp=null}finally{cd=a,_e.p=i,j.T=r}}e.current=t,Md=2}}function xf(){if(Md===2){Md=0;var e=Nd,t=Pd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=j.T,j.T=null;var r=_e.p;_e.p=2;var i=cd;cd|=4;try{Cu(e,t.alternate,t)}finally{cd=i,_e.p=r,j.T=n}}Md=3}}function Sf(){if(Md===4||Md===3){Md=0;var e=zd;zd=null,He();var t=Nd,n=Pd,r=Fd,i=Rd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?Md=5:(Md=0,Pd=Nd=null,Cf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(jd=null),xt(r),n=n.stateNode,$e&&typeof $e.onCommitFiberRoot==`function`)try{$e.onCommitFiberRoot(Qe,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=j.T,a=_e.p,_e.p=2,j.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{j.T=n,_e.p=a}}if(i=Bd,o=Vd,Vd=null,i!==null&&(Bd=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);Fd&3&&wf(),Bf(t),a=t.pendingLanes,r&261930&&a&42?t===Ud?Hd++:(Hd=0,Ud=t):(Hd=0,Ud=null),Vf(0,!1)}}function Cf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Ia(t)))}function wf(){return zd!==null&&(zd.skipTransition(),zd=null),bf(),xf(),Sf(),Tf()}function Tf(){if(Md!==5)return!1;var e=Nd,t=Id;Id=0;var n=xt(Fd),r=j.T,a=_e.p;try{_e.p=32>n?32:n,j.T=null,n=Ld,Ld=null;var o=Nd,s=Fd;if(Md=0,Pd=Nd=null,Fd=0,cd&6)throw Error(i(331));var c=cd;if(cd|=4,rd(o.current),Yu(o,o.current,s,n),cd=c,Vf(0,!1),$e&&typeof $e.onPostCommitFiberRoot==`function`)try{$e.onPostCommitFiberRoot(Qe,o)}catch{}return!0}finally{_e.p=a,j.T=r,Cf(e,t)}}function Ef(e,t,n){t=Wi(n,t),t=Pc(e.stateNode,t,2),e=xo(e,t,2),e!==null&&(ht(e,2),Bf(e))}function Df(e,t,n){if(e.tag===3)Ef(e,e,n);else for(;t!==null;){if(t.tag===3){Ef(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(jd===null||!jd.has(r))){e=Wi(n,e),n=Fc(2),r=xo(t,n,2),r!==null&&(Ic(n,r,t,e),ht(r,2),Bf(r));break}}t=t.return}}function Of(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new sd;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(gd=!0,i.add(n),e=kf.bind(null,e,t,n),t.then(e,e))}function kf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,ld===e&&(dd&n)===n&&(vd===4||vd===3&&(dd&62914560)===dd&&300>Ue()-Dd?cd&2?xd|=n:ef(e,0):xd|=n,Cd===dd&&(Cd=0)),Bf(e)}function Af(e,t){t===0&&(t=pt()),e=ki(e,t),e!==null&&(ht(e,t),Bf(e))}function jf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Af(e,n)}function Mf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Af(e,n)}function Nf(e,t){return ze(e,t)}var Pf=null,Ff=null,If=!1,Lf=!1,Rf=!1,zf=0;function Bf(e){e!==Ff&&e.next===null&&(Ff===null?Pf=Ff=e:Ff=Ff.next=e),Lf=!0,If||(If=!0,qf())}function Vf(e,t){if(!Rf&&Lf){Rf=!0;do for(var n=!1,r=Pf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-tt(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Kf(r,a))}else a=dd,a=lt(r,r===ld?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ut(r,a)||(n=!0,Kf(r,a))}r=r.next}while(n);Rf=!1}}function Hf(){Uf()}function Uf(){Lf=If=!1;var e=0;zf!==0&&Ap()&&(e=zf);for(var t=Ue(),n=null,r=Pf;r!==null;){var i=r.next,a=Wf(r,t);a===0?(r.next=null,n===null?Pf=i:n.next=i,i===null&&(Ff=n)):(n=r,(e!==0||a&3)&&(Lf=!0)),r=i}Md!==0&&Md!==5||Vf(e,!1),zf!==0&&(zf=0)}function Wf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-tt(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=ft(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=ld,n=dd,n=lt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(fd===2||fd===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Be(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||ut(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Be(r),xt(n)){case 2:case 8:n=Ke;break;case 32:n=qe;break;case 268435456:n=Ye;break;default:n=qe}return r=Gf.bind(null,e),n=ze(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Be(r),e.callbackPriority=2,e.callbackNode=null,2}function Gf(e,t){if(Md!==0&&Md!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(wf()&&e.callbackNode!==n)return null;var r=dd;return r=lt(e,e===ld?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Jd(e,r,t),Wf(e,Ue()),e.callbackNode!=null&&e.callbackNode===n?Gf.bind(null,e):null)}function Kf(e,t){if(wf())return null;Jd(e,t,!0)}function qf(){Fp(function(){cd&6?ze(Ge,Hf):Uf()})}function Jf(){if(zf===0){var e=Ha;e===0&&(e=at,at<<=1,!(at&261888)&&(at=256)),zf=e}return zf}function Yf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:xn(e)}function Xf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Yf((i[Et]||null).action),o=r.submitter;o&&(t=(t=o[Et]||null)?Yf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Hn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(zf!==0){var e=new FormData(i,o);oc(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),oc(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Zf=0;Zf<gi.length;Zf++){var Qf=gi[Zf];_i(Qf.toLowerCase(),`on`+(Qf[0].toUpperCase()+Qf.slice(1)))}_i(ci,`onAnimationEnd`),_i(li,`onAnimationIteration`),_i(ui,`onAnimationStart`),_i(`dblclick`,`onDoubleClick`),_i(`focusin`,`onFocus`),_i(`focusout`,`onBlur`),_i(di,`onTransitionRun`),_i(fi,`onTransitionStart`),_i(pi,`onTransitionCancel`),_i(mi,`onTransitionEnd`),Wt(`onMouseEnter`,[`mouseout`,`mouseover`]),Wt(`onMouseLeave`,[`mouseout`,`mouseover`]),Wt(`onPointerEnter`,[`pointerout`,`pointerover`]),Wt(`onPointerLeave`,[`pointerout`,`pointerover`]),Ut(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ut(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ut(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ut(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ut(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ut(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var $f=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),ep=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat($f));function tp(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Si(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Si(e)}i.currentTarget=null,a=c}}}}function np(e,t){var n=t[Ot];n===void 0&&(n=t[Ot]=new Set);var r=e+`__bubble`;n.has(r)||(op(t,e,2,!1),n.add(r))}function rp(e,t,n){var r=0;t&&(r|=4),op(n,e,r,t)}var ip=`_reactListening`+Math.random().toString(36).slice(2);function ap(e){if(!e[ip]){e[ip]=!0,Vt.forEach(function(t){t!==`selectionchange`&&(ep.has(t)||rp(t,!1,e),rp(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ip]||(t[ip]=!0,rp(`selectionchange`,!1,t))}}function op(e,t,n,r){switch(Rh(t)){case 2:var i=Mh;break;case 8:i=Nh;break;default:i=Ph}n=i.bind(null,t,n,e),i=void 0,!jn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function sp(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=Ft(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}kn(function(){var r=a,i=wn(n),s=[];a:{var c=hi.get(e);if(c!==void 0){var l=Hn,u=e;switch(e){case`keypress`:if(Ln(n)===0)break a;case`keydown`:case`keyup`:l=or;break;case`focusin`:u=`focus`,l=Zn;break;case`focusout`:u=`blur`,l=Zn;break;case`beforeblur`:case`afterblur`:l=Zn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Yn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Xn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=lr;break;case ci:case li:case ui:l=Qn;break;case mi:l=ur;break;case`scroll`:case`scrollend`:l=Wn;break;case`wheel`:l=dr;break;case`copy`:case`cut`:case`paste`:l=$n;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=sr;break;case`submit`:l=cr;break;case`toggle`:case`beforetoggle`:l=fr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=N(m,p),g!=null&&d.push(cp(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==Cn&&(u=n.relatedTarget||n.fromElement)&&(Ft(u)||u[Dt]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Ft(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Yn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=sr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:Lt(c),h=l==null?u:Lt(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,Ft(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?C(c,l,up):null,c!==null&&dp(s,u,c,d,!1),l!==null&&f!==null&&dp(s,f,l,d,!0)))}a:{if(c=r?Lt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=jr;else if(Tr(c)){if(Mr)_=Vr;else{_=zr;var v=Rr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&vn(r.elementType)&&(_=jr):_=Br;if(_&&=_(e,r)){Er(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?Lt(r):window,e){case`focusin`:(Tr(v)||v.contentEditable===`true`)&&(Qr=v,$r=r,ei=null);break;case`focusout`:ei=$r=Qr=null;break;case`mousedown`:ti=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:ti=!1,ni(s,n,i);break;case`selectionchange`:if(Zr)break;case`keydown`:case`keyup`:ni(s,n,i)}var y;if(mr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else Sr?br(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(_r&&n.locale!==`ko`&&(Sr||b!==`onCompositionStart`?b===`onCompositionEnd`&&Sr&&(y=In()):(Nn=i,Pn=`value`in Nn?Nn.value:Nn.textContent,Sr=!0)),v=lp(r,b),0<v.length&&(b=new er(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=xr(n),y!==null&&(b.data=y)))),(y=gr?P(e,n):Cr(e,n))&&(b=lp(r,`onBeforeInput`),0<b.length&&(v=new er(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Xf(s,e,r,n,i)}tp(s,t)})}function cp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function lp(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=N(e,n),i!=null&&r.unshift(cp(e,i,a)),i=N(e,t),i!=null&&r.push(cp(e,i,a))),e.tag===3)return r;e=e.return}return[]}function up(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function dp(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=N(n,a),l!=null&&o.unshift(cp(n,l,c))):i||(l=N(n,a),l!=null&&o.push(cp(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var fp=/\r\n?/g,pp=/\u0000|\uFFFD/g;function mp(e){return(typeof e==`string`?e:``+e).replace(fp,`
|
|
109
|
-
`).replace(pp,``)}function hp(e,t){return t=mp(t),mp(e)===t}function gp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||mn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&mn(e,``+r);else return;break;case`className`:Qt(e,`class`,r);break;case`tabIndex`:Qt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Qt(e,n,r);break;case`style`:_n(e,r,o);return;case`data`:if(t!==`object`){Qt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=xn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&gp(e,t,`name`,a.name,a,null),gp(e,t,`formEncType`,a.formEncType,a,null),gp(e,t,`formMethod`,a.formMethod,a,null),gp(e,t,`formTarget`,a.formTarget,a,null)):(gp(e,t,`encType`,a.encType,a,null),gp(e,t,`method`,a.method,a,null),gp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=xn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Sn);return;case`onScroll`:r!=null&&np(`scroll`,e);return;case`onScrollEnd`:r!=null&&np(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=xn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:np(`beforetoggle`,e),np(`toggle`,e),Zt(e,`popover`,r);break;case`xlinkActuate`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Zt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=yn.get(n)||n,Zt(e,n,r);else return}Yt=!0}function _p(e,t,n,r,a,o){switch(n){case`style`:_n(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)mn(e,r);else if(typeof r==`number`||typeof r==`bigint`)mn(e,``+r);else return;break;case`onScroll`:r!=null&&np(`scroll`,e);return;case`onScrollEnd`:r!=null&&np(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=Sn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Ht.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[Et]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}Yt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Zt(e,n,r)}return}Yt=!0}function vp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:np(`error`,e),np(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:gp(e,t,o,s,n,null)}}a&&gp(e,t,`srcSet`,n.srcSet,n,null),r&&gp(e,t,`src`,n.src,n,null);return;case`input`:np(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:gp(e,t,r,d,n,null)}}ln(e,o,c,l,u,s,a,!1);return;case`select`:for(a in np(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:gp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&dn(e,!!r,n,!0):dn(e,!!r,t,!1);return;case`textarea`:for(s in np(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:gp(e,t,s,c,n,null)}pn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:gp(e,t,l,r,n,null)}return;case`dialog`:np(`beforetoggle`,e),np(`toggle`,e),np(`cancel`,e),np(`close`,e);break;case`iframe`:case`object`:np(`load`,e);break;case`video`:case`audio`:for(r=0;r<$f.length;r++)np($f[r],e);break;case`image`:np(`error`,e),np(`load`,e);break;case`details`:np(`toggle`,e);break;case`embed`:case`source`:case`link`:np(`error`,e),np(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:gp(e,t,u,r,n,null)}return;default:if(vn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&_p(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&gp(e,t,c,r,n,null))}var yp={};function bp(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||gp(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Yt=!0),o=m;break;case`name`:m!==f&&(Yt=!0),a=m;break;case`checked`:m!==f&&(Yt=!0),u=m;break;case`defaultChecked`:m!==f&&(Yt=!0),d=m;break;case`value`:m!==f&&(Yt=!0),s=m;break;case`defaultValue`:m!==f&&(Yt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&gp(e,t,p,m,r,f)}}cn(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||gp(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(Yt=!0),p=o;break;case`defaultValue`:o!==l&&(Yt=!0),c=o;break;case`multiple`:o!==l&&(Yt=!0),s=o;default:o!==l&&gp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?dn(e,!!n,n?[]:``,!1):dn(e,!!n,t,!0)):dn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:gp(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(Yt=!0),p=a;break;case`defaultValue`:a!==o&&(Yt=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&gp(e,t,s,a,r,o)}fn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:gp(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Yt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:gp(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&gp(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:gp(e,t,u,p,r,m)}return;default:if(vn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&_p(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||_p(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&gp(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||gp(e,t,f,p,r,m)}function xp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Sp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&xp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&xp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Cp=null,wp=null;function Tp(e){return e.nodeType===9?e:e.ownerDocument}function Ep(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Op(e,t,n,r){return n=Tp(n).createElement(e),n[Tt]=r,n[Et]=t,vp(n,e,t),zt(n),n}function kp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var F=null;function Ap(){var e=window.event;return e&&e.type===`popstate`?e!==F&&(F=e,!0):(F=null,!1)}var jp=typeof setTimeout==`function`?setTimeout:void 0,Mp=typeof clearTimeout==`function`?clearTimeout:void 0,Np=typeof Promise==`function`?Promise:void 0,Pp=typeof requestAnimationFrame==`function`?requestAnimationFrame:jp,Fp=typeof queueMicrotask==`function`?queueMicrotask:Np===void 0?jp:function(e){return Np.resolve(null).then(e).catch(Ip)};function Ip(e){setTimeout(function(){throw e})}function Lp(e){return e===`head`}function Rp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),rg(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Mm(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Mm(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Mt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Mm(e.ownerDocument.body)}n=i}while(n);rg(t)}function zp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Bp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Vp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Hp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Up(e){return Hp(e.getBoundingClientRect(),getComputedStyle(e),e)}function Wp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Hp(t,n,e)}function Gp(e){return e.documentElement.clientHeight}function Kp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function qp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Gp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=dh(f),u>mh){s.length=o;break}f=new Promise(Kp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Jp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Jp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Jp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Jp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Yp(e){return{name:e,group:new Jp(`group`,e),imagePair:new Jp(`image-pair`,e),old:new Jp(`old`,e),new:new Jp(`new`,e)}}function Xp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Xp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(tm(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=$p(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,Zp,e,s,r)}this._eventListeners=a}};function Zp(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Xp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=tm(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=$p(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Qp,e,n,i),r.splice(t,1),a!==null&&a()}};function Qp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function $p(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function em(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function tm(e,t,n,r){if(e.length===0)return-1;r=em(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&em(a.optionsOrUseCapture)===r)return i}return-1}Xp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,$p(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,$p(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Xp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,nm,e,void 0,void 0)};function nm(e,t){return e.tag!==6&&(e=_(e),Om(e,t))}Xp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,rm,t,void 0,void 0);for(var n=t.length-1;0<=n&&!nm(t[n],e);n--);};function rm(e,t){return t.push(e),!1}Xp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=Tp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,im,e,void 0,void 0))};function im(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Xp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,am,e,void 0,void 0)};function am(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Xp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,om,e,void 0,void 0);for(var n=t=0;n<sm.length;n++){var r=sm[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):sm[t++]=r}sm.length=t}};function om(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var sm=[],cm=!1;function lm(e,t,n){sm.push({fragmentInstance:e,observer:t,instance:n}),cm||(cm=!0,km(function(){cm=!1;var e=sm;sm=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Xp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,um,e,void 0,void 0),e};function um(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Xp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Xp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,rm,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||dm(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function dm(e,t,n,r,i){var a=Ft(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function fm(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Xp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,rm,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),fm(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),fm(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function pm(e,t){return e=_(e),mm(e,t),!1}function mm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function hm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,$p(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<sm.length;i++){var a=sm[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(sm[r++]=a)}sm.length=r,n.observe(e)}),mm(e,t))}function gm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,$p(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?lm(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function _m(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:_m(n),Pt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function vm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Mt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=wm(e.nextSibling),e===null)break}return null}function ym(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=wm(e.nextSibling),e===null))return null;return e}function bm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=wm(e.nextSibling),e===null))return null;return e}function xm(e){return e.data===`$?`||e.data===`$~`}function Sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function Cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function wm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var Tm=null;function Em(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return wm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Dm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Om(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function km(e){Pp(function(){Pp(function(t){return e(t)})})}function Am(e,t,n){switch(t=Tp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function jm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&gp(e,t,r,null,yp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===Sn&&(e.onclick=null),Pt(e)}function Mm(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Pt(e)}var Nm=new Map,Pm=new Set;function Fm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Im=_e.d;_e.d={f:Lm,r:Rm,D:Vm,C:Hm,L:Um,m:Wm,X:Km,S:Gm,M:qm};function Lm(){var e=Im.f(),t=Qd();return e||t}function Rm(e){var t=It(e);t!==null&&t.tag===5&&t.type===`form`?cc(t):Im.r(e)}var zm=typeof document>`u`?null:document;function Bm(e,t,n){var r=zm;if(r&&typeof t==`string`&&t){var i=sn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Pm.has(i)||(Pm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),vp(t,`link`,e),zt(t),r.head.appendChild(t)))}}function Vm(e){Im.D(e),Bm(`dns-prefetch`,e,null)}function Hm(e,t){Im.C(e,t),Bm(`preconnect`,e,t)}function Um(e,t,n){Im.L(e,t,n);var r=zm;if(r&&e&&t){var i=`link[rel="preload"][as="`+sn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+sn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+sn(n.imageSizes)+`"]`)):i+=`[href="`+sn(e)+`"]`;var a=i;switch(t){case`style`:a=Ym(e);break;case`script`:a=$m(e)}if(!(Nm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Nm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Xm(a))||t===`script`&&r.querySelector(eh(a))))){var o=r.createElement(`link`);vp(o,`link`,e),t===`style`&&(o[Nt]=!0,o.onload=o.onerror=function(){Bt(o)}),zt(o),r.head.appendChild(o)}}}function Wm(e,t){Im.m(e,t);var n=zm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+sn(r)+`"][href="`+sn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=$m(e)}if(!Nm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),Nm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(eh(a)))return}r=n.createElement(`link`),vp(r,`link`,e),zt(r),n.head.appendChild(r)}}}function Gm(e,t,n){Im.S(e,t,n);var r=zm;if(r&&e){var i=Rt(r).hoistableStyles,a=Ym(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Xm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Nm.get(a))&&rh(e,n);var c=o=r.createElement(`link`);zt(c),vp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,nh(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Km(e,t){Im.X(e,t);var n=zm;if(n&&e){var r=Rt(n).hoistableScripts,i=$m(e),a=r.get(i);a||(a=n.querySelector(eh(i)),a||(e=w({src:e,async:!0},t),(t=Nm.get(i))&&ih(e,t),a=n.createElement(`script`),zt(a),vp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function qm(e,t){Im.M(e,t);var n=zm;if(n&&e){var r=Rt(n).hoistableScripts,i=$m(e),a=r.get(i);a||(a=n.querySelector(eh(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=Nm.get(i))&&ih(e,t),a=n.createElement(`script`),zt(a),vp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Jm(e,t,n,r){var a=(a=Te.current)?Fm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Ym(n.href),t=Rt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Ym(n.href);var o=Rt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Xm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=Nm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Nm.set(e,o)),Qm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=$m(n),t=Rt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ym(e){return`href="`+sn(e)+`"`}function Xm(e){return`link[rel="stylesheet"][`+e+`]`}function Zm(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Qm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Nt]){r.loading=1;return}}else t=e.createElement(`link`),t[Nt]=!0,t.onload=t.onerror=Bt.bind(null,t),vp(t,`link`,n),zt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function $m(e){return`[src="`+sn(e)+`"]`}function eh(e){return`script[async]`+e}function th(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+sn(n.href)+`"]`);if(r)return t.instance=r,zt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),zt(r),vp(r,`style`,a),nh(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Ym(n.href);var o=e.querySelector(Xm(a));if(o)return t.state.loading|=4,t.instance=o,zt(o),o;r=Zm(n),(a=Nm.get(a))&&rh(r,a),o=(e.ownerDocument||e).createElement(`link`),zt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),vp(o,`link`,r),t.state.loading|=4,nh(o,n.precedence,e),t.instance=o;case`script`:return o=$m(n.src),(a=e.querySelector(eh(o)))?(t.instance=a,zt(a),a):(r=n,(a=Nm.get(o))&&(r=w({},n),ih(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),zt(a),vp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,nh(r,n.precedence,e));return t.instance}function nh(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function rh(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function ih(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var ah=null;function oh(e,t,n){if(ah===null){var r=new Map,i=ah=new Map;i.set(n,r)}else i=ah,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Mt]||a[Tt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function sh(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function ch(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function lh(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function uh(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function dh(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function fh(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=dh(t),e.suspenseyImages.push(t)),e=vh.bind(e),t.decode().then(e,e))}function ph(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Ym(r.href),a=t.querySelector(Xm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=_h.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,zt(a);return}a=t.ownerDocument||t,r=Zm(r),(i=Nm.get(i))&&rh(r,i),a=a.createElement(`link`),zt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),vp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=_h.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var mh=0;function hh(e,t){return e.stylesheets&&e.count===0&&bh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&bh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&mh===0&&(mh=62500*Sp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&bh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>mh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function gh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)bh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function _h(){this.count--,gh(this)}function vh(){this.imgCount--,gh(this)}var yh=null;function bh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,yh=new Map,t.forEach(xh,e),yh=null,_h.call(e))}function xh(e,t){if(!(t.state.loading&4)){var n=yh.get(e);if(n)var r=n.get(null);else{n=new Map,yh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=_h.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Sh={$$typeof:A,Provider:null,Consumer:null,_currentValue:ve,_currentValue2:ve,_threadCount:0};function Ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=mt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mt(0),this.hiddenUpdates=mt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function wh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new Ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Pi(3,null,null,t),e.current=a,a.stateNode=e,t=Fa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},vo(a),e}function Th(e){return e?(e=Mi,e):Mi}function Eh(e,t,n,r,i,a){i=Th(i),r.context===null?r.context=i:r.pendingContext=i,r=bo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=xo(e,r,t),n!==null&&(qd(n,e,t),So(n,e,t))}function Dh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Oh(e,t){Dh(e,t),(e=e.alternate)&&Dh(e,t)}function kh(e){if(e.tag===13||e.tag===31){var t=ki(e,67108864);t!==null&&qd(t,e,67108864),Oh(e,67108864)}}function Ah(e){if(e.tag===13||e.tag===31){var t=Wd();t=bt(t);var n=ki(e,t);n!==null&&qd(n,e,t),Oh(e,t)}}var jh=!0;function Mh(e,t,n,r){var i=j.T;j.T=null;var a=_e.p;try{_e.p=2,Ph(e,t,n,r)}finally{_e.p=a,j.T=i}}function Nh(e,t,n,r){var i=j.T;j.T=null;var a=_e.p;try{_e.p=8,Ph(e,t,n,r)}finally{_e.p=a,j.T=i}}function Ph(e,t,n,r){if(jh){var i=Fh(r);if(i===null)sp(e,t,r,Ih,n),qh(e,r);else if(Yh(i,e,t,n,r))r.stopPropagation();else if(qh(e,r),t&4&&-1<Kh.indexOf(e)){for(;i!==null;){var a=It(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=ct(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-tt(o);s.entanglements[1]|=c,o&=~c}Bf(a),!(cd&6)&&(kd=Ue()+500,Vf(0,!1))}}break;case 31:case 13:s=ki(a,2),s!==null&&qd(s,a,2),Qd(),Oh(a,2)}if(a=Fh(r),a===null&&sp(e,t,r,Ih,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else sp(e,t,r,null,n)}}function Fh(e){return e=wn(e),Lh(e)}var Ih=null;function Lh(e){if(Ih=null,e=Ft(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ih=e,null}function Rh(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(We()){case Ge:return 2;case Ke:return 8;case qe:case Je:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var zh=!1,Bh=null,Vh=null,Hh=null,Uh=new Map,Wh=new Map,Gh=[],Kh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function qh(e,t){switch(e){case`focusin`:case`focusout`:Bh=null;break;case`dragenter`:case`dragleave`:Vh=null;break;case`mouseover`:case`mouseout`:Hh=null;break;case`pointerover`:case`pointerout`:Uh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Wh.delete(t.pointerId)}}function Jh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=It(t),t!==null&&kh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Yh(e,t,n,r,i){switch(t){case`focusin`:return Bh=Jh(Bh,e,t,n,r,i),!0;case`dragenter`:return Vh=Jh(Vh,e,t,n,r,i),!0;case`mouseover`:return Hh=Jh(Hh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Uh.set(a,Jh(Uh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Wh.set(a,Jh(Wh.get(a)||null,e,t,n,r,i)),!0}return!1}function Xh(e){var t=Ft(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Ct(e.priority,function(){Ah(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Ct(e.priority,function(){Ah(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Zh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Fh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Cn=r,n.target.dispatchEvent(r),Cn=null}else return t=It(n),t!==null&&kh(t),e.blockedOn=n,!1;t.shift()}return!0}function Qh(e,t,n){Zh(e)&&n.delete(t)}function $h(){zh=!1,Bh!==null&&Zh(Bh)&&(Bh=null),Vh!==null&&Zh(Vh)&&(Vh=null),Hh!==null&&Zh(Hh)&&(Hh=null),Uh.forEach(Qh),Wh.forEach(Qh)}function eg(e,n){e.blockedOn===n&&(e.blockedOn=null,zh||(zh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,$h)))}var tg=null;function ng(e){tg!==e&&(tg=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){tg===e&&(tg=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Lh(r||n)===null)continue;break}var a=It(n);a!==null&&(e.splice(t,3),t-=3,oc(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function rg(e){function t(t){return eg(t,e)}Bh!==null&&eg(Bh,e),Vh!==null&&eg(Vh,e),Hh!==null&&eg(Hh,e),Uh.forEach(t),Wh.forEach(t);for(var n=0;n<Gh.length;n++){var r=Gh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Gh.length&&(n=Gh[0],n.blockedOn===null);)Xh(n),n.blockedOn===null&&Gh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Et]||null;if(typeof a==`function`)o||ng(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Et]||null)s=o.formAction;else if(Lh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),ng(n)}}}function ig(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function ag(e){this._internalRoot=e}og.prototype.render=ag.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;Eh(n,Wd(),e,t,null,null)},og.prototype.unmount=ag.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Eh(e.current,2,null,e,null,null),Qd(),t[Dt]=null}};function og(e){this._internalRoot=e}og.prototype.unstable_scheduleHydration=function(e){if(e){var t=St();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Gh.length&&t!==0&&t<Gh[n].priority;n++);Gh.splice(n,0,e),n===0&&Xh(e)}};var sg=n.version;if(sg!==`19.3.1`)throw Error(i(527,sg,`19.3.1`));_e.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var cg={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:j,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var lg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lg.isDisabled&&lg.supportsFiber)try{Qe=lg.inject(cg),$e=lg}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=kc,s=Ac,c=jc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=wh(e,1,!1,null,null,n,r,null,o,s,c,ig),e[Dt]=t.current,ap(e),new ag(t)}})),c9=r(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s9()}));jG(),rw(),e7(),n9(),kM();var l9=jM(),u9=c9(),d9=HA();function f9(e){if(e===void 0)return Xj;if(typeof e!=`string`)return e;let t=qj(e);if(!t)throw Error(`There is no theme called "${e}".`);return t}function p9(e,t,n={}){let r=f9(n.theme);if(n.locale!==void 0)try{Intl.getCanonicalLocales(n.locale.replaceAll(`_`,`-`))}catch{throw Error(`"${n.locale}" is not a locale; use a tag such as "en-US".`)}let i=(0,u9.createRoot)(e),a=t9,o=e=>{let t=n.dataSource??VS(e.data);i.render((0,d9.jsx)(l9.StrictMode,{children:(0,d9.jsx)(UA,{locale:n.locale,labels:n.labels,children:(0,d9.jsx)(FM,{initialTheme:r,initialMode:n.mode??`system`,storage:null,scope:`scoped`,children:(0,d9.jsx)(RN,{dataSource:t,children:(0,d9.jsx)(V5,{surface:k5(e),catalog:T5,renderers:a,onAction:n.onAction,onDataChange:n.onDataChange})})})})}))};return o(t),{update:o,unmount:()=>i.unmount()}}rw(),WS(),Zj();async function m9(){let e=await globalThis.claude?.use?.(`mcp`);if(!e)throw Error(`This page reads live data through a connector, which works only when it is opened in Claude.`);return e}async function h9(e,t,n){let{sources:r,host:i,...a}=n,o=await DA(i??await m9(),r),s=t,c=kA(o,()=>VS(s.data)),l=p9(e,t,{...a,dataSource:c});return{update(e){s=e,l.update(e)},unmount:()=>l.unmount()}}return e.connectorCaller=TA,e.connectorDataSource=DA,e.mountConnectedPage=h9,e.mountPage=p9,e.pageDataSource=VS,e.plainRows=zS,e.presets=Yj,e.withPageRows=kA,e})({});
|
|
110
|
+
`).replace(pp,``)}function hp(e,t){return t=mp(t),mp(e)===t}function gp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||mn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&mn(e,``+r);else return;break;case`className`:Qt(e,`class`,r);break;case`tabIndex`:Qt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Qt(e,n,r);break;case`style`:_n(e,r,o);return;case`data`:if(t!==`object`){Qt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=xn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&gp(e,t,`name`,a.name,a,null),gp(e,t,`formEncType`,a.formEncType,a,null),gp(e,t,`formMethod`,a.formMethod,a,null),gp(e,t,`formTarget`,a.formTarget,a,null)):(gp(e,t,`encType`,a.encType,a,null),gp(e,t,`method`,a.method,a,null),gp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=xn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Sn);return;case`onScroll`:r!=null&&np(`scroll`,e);return;case`onScrollEnd`:r!=null&&np(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=xn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:np(`beforetoggle`,e),np(`toggle`,e),Zt(e,`popover`,r);break;case`xlinkActuate`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:$t(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:$t(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Zt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=yn.get(n)||n,Zt(e,n,r);else return}Yt=!0}function _p(e,t,n,r,a,o){switch(n){case`style`:_n(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)mn(e,r);else if(typeof r==`number`||typeof r==`bigint`)mn(e,``+r);else return;break;case`onScroll`:r!=null&&np(`scroll`,e);return;case`onScrollEnd`:r!=null&&np(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=Sn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Ht.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[Et]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}Yt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Zt(e,n,r)}return}Yt=!0}function vp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:np(`error`,e),np(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:gp(e,t,o,s,n,null)}}a&&gp(e,t,`srcSet`,n.srcSet,n,null),r&&gp(e,t,`src`,n.src,n,null);return;case`input`:np(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:gp(e,t,r,d,n,null)}}ln(e,o,c,l,u,s,a,!1);return;case`select`:for(a in np(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:gp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&dn(e,!!r,n,!0):dn(e,!!r,t,!1);return;case`textarea`:for(s in np(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:gp(e,t,s,c,n,null)}pn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:gp(e,t,l,r,n,null)}return;case`dialog`:np(`beforetoggle`,e),np(`toggle`,e),np(`cancel`,e),np(`close`,e);break;case`iframe`:case`object`:np(`load`,e);break;case`video`:case`audio`:for(r=0;r<$f.length;r++)np($f[r],e);break;case`image`:np(`error`,e),np(`load`,e);break;case`details`:np(`toggle`,e);break;case`embed`:case`source`:case`link`:np(`error`,e),np(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:gp(e,t,u,r,n,null)}return;default:if(vn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&_p(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&gp(e,t,c,r,n,null))}var yp={};function bp(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||gp(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Yt=!0),o=m;break;case`name`:m!==f&&(Yt=!0),a=m;break;case`checked`:m!==f&&(Yt=!0),u=m;break;case`defaultChecked`:m!==f&&(Yt=!0),d=m;break;case`value`:m!==f&&(Yt=!0),s=m;break;case`defaultValue`:m!==f&&(Yt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&gp(e,t,p,m,r,f)}}cn(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||gp(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(Yt=!0),p=o;break;case`defaultValue`:o!==l&&(Yt=!0),c=o;break;case`multiple`:o!==l&&(Yt=!0),s=o;default:o!==l&&gp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?dn(e,!!n,n?[]:``,!1):dn(e,!!n,t,!0)):dn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:gp(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(Yt=!0),p=a;break;case`defaultValue`:a!==o&&(Yt=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&gp(e,t,s,a,r,o)}fn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:gp(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Yt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:gp(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&gp(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:gp(e,t,u,p,r,m)}return;default:if(vn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&_p(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||_p(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&gp(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||gp(e,t,f,p,r,m)}function xp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Sp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&xp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&xp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Cp=null,wp=null;function Tp(e){return e.nodeType===9?e:e.ownerDocument}function Ep(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Op(e,t,n,r){return n=Tp(n).createElement(e),n[Tt]=r,n[Et]=t,vp(n,e,t),zt(n),n}function kp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var F=null;function Ap(){var e=window.event;return e&&e.type===`popstate`?e!==F&&(F=e,!0):(F=null,!1)}var jp=typeof setTimeout==`function`?setTimeout:void 0,Mp=typeof clearTimeout==`function`?clearTimeout:void 0,Np=typeof Promise==`function`?Promise:void 0,Pp=typeof requestAnimationFrame==`function`?requestAnimationFrame:jp,Fp=typeof queueMicrotask==`function`?queueMicrotask:Np===void 0?jp:function(e){return Np.resolve(null).then(e).catch(Ip)};function Ip(e){setTimeout(function(){throw e})}function Lp(e){return e===`head`}function Rp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),rg(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Mm(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Mm(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Mt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Mm(e.ownerDocument.body)}n=i}while(n);rg(t)}function zp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Bp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Vp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Hp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Up(e){return Hp(e.getBoundingClientRect(),getComputedStyle(e),e)}function Wp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Hp(t,n,e)}function Gp(e){return e.documentElement.clientHeight}function Kp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function qp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Gp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=dh(f),u>mh){s.length=o;break}f=new Promise(Kp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Jp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Jp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Jp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Jp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Yp(e){return{name:e,group:new Jp(`group`,e),imagePair:new Jp(`image-pair`,e),old:new Jp(`old`,e),new:new Jp(`new`,e)}}function Xp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Xp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(tm(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=$p(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,Zp,e,s,r)}this._eventListeners=a}};function Zp(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Xp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=tm(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=$p(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Qp,e,n,i),r.splice(t,1),a!==null&&a()}};function Qp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function $p(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function em(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function tm(e,t,n,r){if(e.length===0)return-1;r=em(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&em(a.optionsOrUseCapture)===r)return i}return-1}Xp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,$p(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,$p(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Xp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,nm,e,void 0,void 0)};function nm(e,t){return e.tag!==6&&(e=_(e),Om(e,t))}Xp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,rm,t,void 0,void 0);for(var n=t.length-1;0<=n&&!nm(t[n],e);n--);};function rm(e,t){return t.push(e),!1}Xp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=Tp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,im,e,void 0,void 0))};function im(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Xp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,am,e,void 0,void 0)};function am(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Xp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,om,e,void 0,void 0);for(var n=t=0;n<sm.length;n++){var r=sm[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):sm[t++]=r}sm.length=t}};function om(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var sm=[],cm=!1;function lm(e,t,n){sm.push({fragmentInstance:e,observer:t,instance:n}),cm||(cm=!0,km(function(){cm=!1;var e=sm;sm=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Xp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,um,e,void 0,void 0),e};function um(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Xp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Xp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,rm,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||dm(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function dm(e,t,n,r,i){var a=Ft(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function fm(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Xp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,rm,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),fm(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),fm(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function pm(e,t){return e=_(e),mm(e,t),!1}function mm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function hm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,$p(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<sm.length;i++){var a=sm[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(sm[r++]=a)}sm.length=r,n.observe(e)}),mm(e,t))}function gm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,$p(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?lm(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function _m(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:_m(n),Pt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function vm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Mt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=wm(e.nextSibling),e===null)break}return null}function ym(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=wm(e.nextSibling),e===null))return null;return e}function bm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=wm(e.nextSibling),e===null))return null;return e}function xm(e){return e.data===`$?`||e.data===`$~`}function Sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function Cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function wm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var Tm=null;function Em(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return wm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Dm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Om(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function km(e){Pp(function(){Pp(function(t){return e(t)})})}function Am(e,t,n){switch(t=Tp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function jm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&gp(e,t,r,null,yp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===Sn&&(e.onclick=null),Pt(e)}function Mm(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Pt(e)}var Nm=new Map,Pm=new Set;function Fm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Im=_e.d;_e.d={f:Lm,r:Rm,D:Vm,C:Hm,L:Um,m:Wm,X:Km,S:Gm,M:qm};function Lm(){var e=Im.f(),t=Qd();return e||t}function Rm(e){var t=It(e);t!==null&&t.tag===5&&t.type===`form`?cc(t):Im.r(e)}var zm=typeof document>`u`?null:document;function Bm(e,t,n){var r=zm;if(r&&typeof t==`string`&&t){var i=sn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Pm.has(i)||(Pm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),vp(t,`link`,e),zt(t),r.head.appendChild(t)))}}function Vm(e){Im.D(e),Bm(`dns-prefetch`,e,null)}function Hm(e,t){Im.C(e,t),Bm(`preconnect`,e,t)}function Um(e,t,n){Im.L(e,t,n);var r=zm;if(r&&e&&t){var i=`link[rel="preload"][as="`+sn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+sn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+sn(n.imageSizes)+`"]`)):i+=`[href="`+sn(e)+`"]`;var a=i;switch(t){case`style`:a=Ym(e);break;case`script`:a=$m(e)}if(!(Nm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Nm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Xm(a))||t===`script`&&r.querySelector(eh(a))))){var o=r.createElement(`link`);vp(o,`link`,e),t===`style`&&(o[Nt]=!0,o.onload=o.onerror=function(){Bt(o)}),zt(o),r.head.appendChild(o)}}}function Wm(e,t){Im.m(e,t);var n=zm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+sn(r)+`"][href="`+sn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=$m(e)}if(!Nm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),Nm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(eh(a)))return}r=n.createElement(`link`),vp(r,`link`,e),zt(r),n.head.appendChild(r)}}}function Gm(e,t,n){Im.S(e,t,n);var r=zm;if(r&&e){var i=Rt(r).hoistableStyles,a=Ym(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Xm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Nm.get(a))&&rh(e,n);var c=o=r.createElement(`link`);zt(c),vp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,nh(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Km(e,t){Im.X(e,t);var n=zm;if(n&&e){var r=Rt(n).hoistableScripts,i=$m(e),a=r.get(i);a||(a=n.querySelector(eh(i)),a||(e=w({src:e,async:!0},t),(t=Nm.get(i))&&ih(e,t),a=n.createElement(`script`),zt(a),vp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function qm(e,t){Im.M(e,t);var n=zm;if(n&&e){var r=Rt(n).hoistableScripts,i=$m(e),a=r.get(i);a||(a=n.querySelector(eh(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=Nm.get(i))&&ih(e,t),a=n.createElement(`script`),zt(a),vp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Jm(e,t,n,r){var a=(a=Te.current)?Fm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Ym(n.href),t=Rt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Ym(n.href);var o=Rt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Xm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=Nm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Nm.set(e,o)),Qm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=$m(n),t=Rt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ym(e){return`href="`+sn(e)+`"`}function Xm(e){return`link[rel="stylesheet"][`+e+`]`}function Zm(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Qm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Nt]){r.loading=1;return}}else t=e.createElement(`link`),t[Nt]=!0,t.onload=t.onerror=Bt.bind(null,t),vp(t,`link`,n),zt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function $m(e){return`[src="`+sn(e)+`"]`}function eh(e){return`script[async]`+e}function th(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+sn(n.href)+`"]`);if(r)return t.instance=r,zt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),zt(r),vp(r,`style`,a),nh(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Ym(n.href);var o=e.querySelector(Xm(a));if(o)return t.state.loading|=4,t.instance=o,zt(o),o;r=Zm(n),(a=Nm.get(a))&&rh(r,a),o=(e.ownerDocument||e).createElement(`link`),zt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),vp(o,`link`,r),t.state.loading|=4,nh(o,n.precedence,e),t.instance=o;case`script`:return o=$m(n.src),(a=e.querySelector(eh(o)))?(t.instance=a,zt(a),a):(r=n,(a=Nm.get(o))&&(r=w({},n),ih(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),zt(a),vp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,nh(r,n.precedence,e));return t.instance}function nh(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function rh(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function ih(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var ah=null;function oh(e,t,n){if(ah===null){var r=new Map,i=ah=new Map;i.set(n,r)}else i=ah,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Mt]||a[Tt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function sh(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function ch(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function lh(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function uh(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function dh(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function fh(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=dh(t),e.suspenseyImages.push(t)),e=vh.bind(e),t.decode().then(e,e))}function ph(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Ym(r.href),a=t.querySelector(Xm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=_h.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,zt(a);return}a=t.ownerDocument||t,r=Zm(r),(i=Nm.get(i))&&rh(r,i),a=a.createElement(`link`),zt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),vp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=_h.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var mh=0;function hh(e,t){return e.stylesheets&&e.count===0&&bh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&bh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&mh===0&&(mh=62500*Sp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&bh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>mh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function gh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)bh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function _h(){this.count--,gh(this)}function vh(){this.imgCount--,gh(this)}var yh=null;function bh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,yh=new Map,t.forEach(xh,e),yh=null,_h.call(e))}function xh(e,t){if(!(t.state.loading&4)){var n=yh.get(e);if(n)var r=n.get(null);else{n=new Map,yh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=_h.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Sh={$$typeof:A,Provider:null,Consumer:null,_currentValue:ve,_currentValue2:ve,_threadCount:0};function Ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=mt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mt(0),this.hiddenUpdates=mt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function wh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new Ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Pi(3,null,null,t),e.current=a,a.stateNode=e,t=Fa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},vo(a),e}function Th(e){return e?(e=Mi,e):Mi}function Eh(e,t,n,r,i,a){i=Th(i),r.context===null?r.context=i:r.pendingContext=i,r=bo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=xo(e,r,t),n!==null&&(qd(n,e,t),So(n,e,t))}function Dh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Oh(e,t){Dh(e,t),(e=e.alternate)&&Dh(e,t)}function kh(e){if(e.tag===13||e.tag===31){var t=ki(e,67108864);t!==null&&qd(t,e,67108864),Oh(e,67108864)}}function Ah(e){if(e.tag===13||e.tag===31){var t=Wd();t=bt(t);var n=ki(e,t);n!==null&&qd(n,e,t),Oh(e,t)}}var jh=!0;function Mh(e,t,n,r){var i=j.T;j.T=null;var a=_e.p;try{_e.p=2,Ph(e,t,n,r)}finally{_e.p=a,j.T=i}}function Nh(e,t,n,r){var i=j.T;j.T=null;var a=_e.p;try{_e.p=8,Ph(e,t,n,r)}finally{_e.p=a,j.T=i}}function Ph(e,t,n,r){if(jh){var i=Fh(r);if(i===null)sp(e,t,r,Ih,n),qh(e,r);else if(Yh(i,e,t,n,r))r.stopPropagation();else if(qh(e,r),t&4&&-1<Kh.indexOf(e)){for(;i!==null;){var a=It(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=ct(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-tt(o);s.entanglements[1]|=c,o&=~c}Bf(a),!(cd&6)&&(kd=Ue()+500,Vf(0,!1))}}break;case 31:case 13:s=ki(a,2),s!==null&&qd(s,a,2),Qd(),Oh(a,2)}if(a=Fh(r),a===null&&sp(e,t,r,Ih,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else sp(e,t,r,null,n)}}function Fh(e){return e=wn(e),Lh(e)}var Ih=null;function Lh(e){if(Ih=null,e=Ft(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ih=e,null}function Rh(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(We()){case Ge:return 2;case Ke:return 8;case qe:case Je:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var zh=!1,Bh=null,Vh=null,Hh=null,Uh=new Map,Wh=new Map,Gh=[],Kh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function qh(e,t){switch(e){case`focusin`:case`focusout`:Bh=null;break;case`dragenter`:case`dragleave`:Vh=null;break;case`mouseover`:case`mouseout`:Hh=null;break;case`pointerover`:case`pointerout`:Uh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Wh.delete(t.pointerId)}}function Jh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=It(t),t!==null&&kh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Yh(e,t,n,r,i){switch(t){case`focusin`:return Bh=Jh(Bh,e,t,n,r,i),!0;case`dragenter`:return Vh=Jh(Vh,e,t,n,r,i),!0;case`mouseover`:return Hh=Jh(Hh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Uh.set(a,Jh(Uh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Wh.set(a,Jh(Wh.get(a)||null,e,t,n,r,i)),!0}return!1}function Xh(e){var t=Ft(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Ct(e.priority,function(){Ah(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Ct(e.priority,function(){Ah(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Zh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Fh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Cn=r,n.target.dispatchEvent(r),Cn=null}else return t=It(n),t!==null&&kh(t),e.blockedOn=n,!1;t.shift()}return!0}function Qh(e,t,n){Zh(e)&&n.delete(t)}function $h(){zh=!1,Bh!==null&&Zh(Bh)&&(Bh=null),Vh!==null&&Zh(Vh)&&(Vh=null),Hh!==null&&Zh(Hh)&&(Hh=null),Uh.forEach(Qh),Wh.forEach(Qh)}function eg(e,n){e.blockedOn===n&&(e.blockedOn=null,zh||(zh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,$h)))}var tg=null;function ng(e){tg!==e&&(tg=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){tg===e&&(tg=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Lh(r||n)===null)continue;break}var a=It(n);a!==null&&(e.splice(t,3),t-=3,oc(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function rg(e){function t(t){return eg(t,e)}Bh!==null&&eg(Bh,e),Vh!==null&&eg(Vh,e),Hh!==null&&eg(Hh,e),Uh.forEach(t),Wh.forEach(t);for(var n=0;n<Gh.length;n++){var r=Gh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Gh.length&&(n=Gh[0],n.blockedOn===null);)Xh(n),n.blockedOn===null&&Gh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Et]||null;if(typeof a==`function`)o||ng(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Et]||null)s=o.formAction;else if(Lh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),ng(n)}}}function ig(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function ag(e){this._internalRoot=e}og.prototype.render=ag.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;Eh(n,Wd(),e,t,null,null)},og.prototype.unmount=ag.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Eh(e.current,2,null,e,null,null),Qd(),t[Dt]=null}};function og(e){this._internalRoot=e}og.prototype.unstable_scheduleHydration=function(e){if(e){var t=St();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Gh.length&&t!==0&&t<Gh[n].priority;n++);Gh.splice(n,0,e),n===0&&Xh(e)}};var sg=n.version;if(sg!==`19.3.1`)throw Error(i(527,sg,`19.3.1`));_e.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var cg={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:j,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var lg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lg.isDisabled&&lg.supportsFiber)try{Qe=lg.inject(cg),$e=lg}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=kc,s=Ac,c=jc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=wh(e,1,!1,null,null,n,r,null,o,s,c,ig),e[Dt]=t.current,ap(e),new ag(t)}})),g9=r(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h9()}));zG(),rw(),c7(),u9(),jM();var _9=NM(),v9=g9(),y9=WA();function b9(e){if(e===void 0)return Qj;if(typeof e!=`string`)return e;let t=Yj(e);if(!t)throw Error(`There is no theme called "${e}".`);return t}function x9(e,t,n={}){let r=b9(n.theme);if(n.locale!==void 0)try{Intl.getCanonicalLocales(n.locale.replaceAll(`_`,`-`))}catch{throw Error(`"${n.locale}" is not a locale; use a tag such as "en-US".`)}let i=(0,v9.createRoot)(e),a=l9,o=e=>{let t=n.dataSource??VS(e.data);i.render((0,y9.jsx)(_9.StrictMode,{children:(0,y9.jsx)(GA,{locale:n.locale,labels:n.labels,children:(0,y9.jsx)(LM,{initialTheme:r,initialMode:n.mode??`system`,storage:null,scope:`scoped`,children:(0,y9.jsx)(BN,{dataSource:t,children:(0,y9.jsx)(Y5,{surface:L5(e),catalog:N5,renderers:a,onAction:n.onAction,onDataChange:n.onDataChange})})})})}))};return o(t),{update:o,unmount:()=>i.unmount()}}rw(),WS(),$j();async function S9(){let e=await globalThis.claude?.use?.(`mcp`);if(!e)throw Error(`This page reads live data through a connector, which works only when it is opened in Claude.`);return e}async function C9(e,t,n){let{sources:r,host:i,...a}=n,o=await kA(i??await S9(),r),s=t,c=jA(o,()=>VS(s.data)),l=x9(e,t,{...a,dataSource:c});return{update(e){s=e,l.update(e)},unmount:()=>l.unmount()}}return e.connectorCaller=TA,e.connectorDataSource=kA,e.mountConnectedPage=C9,e.mountPage=x9,e.pageDataSource=VS,e.plainRows=zS,e.presets=Zj,e.withPageRows=jA,e})({});
|