"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[56858],{21625:function(t,e,a){a.r(e),a.d(e,{CopyBox:function(){return l},CopyButton:function(){return d}});var r=a(57437),o=a(61312),i=a(48447),s=a(95257),n=a(29246);let l=t=>{let{value:e,size:a="md",displayValue:o,className:i}=t;return(0,r.jsxs)("div",{className:(0,n.A)("bg-base-3 flex items-center justify-between divide-x divide-base-6 rounded-md border border-base-6",i),children:[(0,r.jsx)("span",{className:(0,n.A)("truncate text-base-11 font-mono","md"===a?"py-2 px-3 text-sm":"","sm"===a?"py-1 px-2 text-xs":""),children:null!=o?o:e}),(0,r.jsx)(d,{value:e,size:a})]})},d=t=>{let{value:e,size:a,showTooltip:l=!0,className:d}=t,{copy:c,copied:u}=(0,i.F)();return(0,r.jsx)(o.zt,{delayDuration:2500,children:(0,r.jsxs)(o.fC,{open:l&&u,children:[(0,r.jsx)(o.xz,{className:(0,n.A)("text-base-11 hover:text-base-12 transition-colors duration-150 outline-none focus:outline-none cursor-pointer","md"===a?"py-2 px-3":"","sm"===a?"py-1 px-2":"",d),onClick:()=>c(e),children:u?(0,r.jsx)(s.Jr,{className:(0,n.A)("text-success","md"===a?"w-4 h-4":"","sm"===a?"w-3 h-3":"")}):(0,r.jsx)(s.CK,{className:(0,n.A)("md"===a?"w-4 h-4":"","sm"===a?"w-3 h-3":"")})}),(0,r.jsx)(o.h_,{children:(0,r.jsxs)(o.VY,{sideOffset:4,className:"text-xs bg-base-2 px-2 py-1 rounded-sm shadow-md data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade select-none will-change-[transform,opacity]",children:["copied!",(0,r.jsx)(o.Eh,{className:"fill-base-2"})]})})]})})}},44574:function(t,e,a){a.d(e,{V9:function(){return s},jH:function(){return n},s_:function(){return i}});var r=a(57437),o=a(29246);let i=t=>{let{className:e,children:a}=t;return(0,r.jsx)("div",{className:(0,o.A)("bg-base-2 border border-base-6 rounded-sm flex flex-col",e),children:a})},s=t=>{let{className:e,title:a,capitalize:i,subtitle:s,icon:n,font:l="base",children:d,offset:c="default"}=t;return(0,r.jsxs)("div",{className:(0,o.A)("flex items-center gap-4 p-4","default"===c&&"md:p-6",e),children:[n,a||s?(0,r.jsxs)("div",{className:"flex flex-col gap-1 ",children:[a&&(0,r.jsx)("h4",{className:(0,o.A)("text-base text-base-12","base"===l&&"font-medium","semibold"===l&&"font-semibold",i&&"capitalize"),children:a}),s&&(0,r.jsx)("div",{className:"text-xs text-base-11",children:s})]}):void 0,d]})},n=t=>{let{className:e,children:a,offset:i="default"}=t;return(0,r.jsx)("div",{className:(0,o.A)("flex items-center border-t border-base-6 bg-base-1 p-4","default"===i&&"md:px-6",e),children:a})}},17238:function(t,e,a){a.d(e,{o:function(){return l}});var r=a(57437),o=a(99376),i=a(52667),s=a(95257),n=a(34274);let l=t=>{let{orgName:e,appName:a,query:l}=t;return(0,o.useRouter)(),(0,r.jsx)(n.z,{onClick:function(){let t=(0,i.compressToEncodedURIComponent)(l),r="/".concat(e,"/").concat(a,"/playground?run_query=true&query=").concat(t);window.open(r,"_blank")},variant:"ghost",size:"xs",icon:(0,r.jsx)(s.xF,{className:"size-4"}),children:"Open Query Explorer"})}},47097:function(t,e,a){a.d(e,{O:function(){return i}});var r=a(57437),o=a(29246);let i=t=>{let{className:e}=t;return(0,r.jsx)("div",{className:(0,o.A)("bg-base-3 animate-pulse",e)})}},81720:function(t,e,a){a.d(e,{r:function(){return n}});var r=a(57437),o=a(2265),i=a(50721),s=a(29246);let n=o.forwardRef((t,e)=>{let{className:a,size:o="md",...n}=t;return(0,r.jsx)(i.fC,{className:(0,s.A)("inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-base-6 focus-visible:ring-offset-2 focus-visible:ring-offset-base-6 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-accnt-10 data-[state=unchecked]:bg-base-8","sm"===o?"h-4 w-7":null,"md"===o?"h-5 w-9":null,a),...n,ref:e,children:(0,r.jsx)(i.bU,{className:(0,s.A)("pointer-events-none block rounded-full bg-base-2 shadow-lg ring-0 transition-transform data-[state=unchecked]:translate-x-0","sm"===o?"h-3 w-3 data-[state=checked]:translate-x-3":null,"md"===o?"h-4 w-4 data-[state=checked]:translate-x-4":null)})})});n.displayName=i.fC.displayName},36470:function(t,e,a){a.d(e,{pz:function(){return s},Xl:function(){return i}});class r extends Error{constructor(t){super(t),this.name="BadRequestError",Object.setPrototypeOf(this,r.prototype)}}var o=a(25566);let i=t=>{var e;return o.env.SPICE_STAMP_URLS,new n((null===(e=o.env.SPICE_STAMP_URLS)||void 0===e?void 0:e.split(","))||"https://useast-2-data.spiceai.io".split(","),t.api_key)},s=t=>new n(["https://data.spiceai.io"],t.api_key);class n{async createDataPlatformOrg(t,e){if(!t)throw Error("Org name is required");if(!e)throw Error("Role is required");for(let a of(await this.callApiParallel("POST","/admin/orgs",{org:{name:t},role:e})))if(!a.ok&&409!==a.status)throw console.error("failed to create org in stamp",a.url,await a.text()),Error("Failed to create data platform org")}async putOrgs(t){let e=t.map(t=>this.cloudOrgToDataPlatformOrg(t));for(let t of(await this.callApiParallel("PUT","/admin/orgs",{orgs:e})))if(!t.ok){let e=await t.text();throw console.error("failed to update org in stamp",t.url,e),Error("Failed to update org in data platform: ".concat(e))}}async putOrg(t,e){let a=this.cloudOrgToDataPlatformOrg(e);for(let e of(await this.callApiParallel("PUT","/admin/orgs/".concat(t),a)))if(!e.ok){let t=await e.text();throw console.error("failed to update org in stamp",e.url,t),Error("Failed to update org in data platform: ".concat(t))}}async postDatasetsFork(t,e){for(let a of(await this.callApiParallel("POST","/admin/datasets/fork",{from:t,to:e})))if(!a.ok)throw console.error("failed to create dataset fork in stamp",a.url,await a.text()),Error("Failed to create dataset fork in data platform")}async postIpfsDataset(t,e){let a=[];for(let r of this._stampUrls){let o=await this.call(r,"POST","/v1/ipfs/add",t,"application/zip");if(!o.ok)throw console.error("failed to add file to ipfs",o.url,o.status,o.statusText),Error("Failed to upload");let{cid:i}=await o.json();for(let t of this._stampUrls){let r=this.call(t,"POST","/v1/datasets",{cid:i,deployment_id:e});a.push(r)}}for(let t of a){let e=await t;if(!e.ok){if(400===e.status)throw new r((await e.json()).error);throw console.error("failed to add dataset to stamp",e.url,e.statusText,await e.text()),Error("Failed to deploy dataset")}}}async postIpfs(t){for(let e of(await this.callApiParallel("POST","/v1/ipfs/add",t,"application/zip"))){if(!e.ok)throw console.error("failed to add file to ipfs",e.url,e.status,e.statusText),Error("Failed to upload");return await e.json()}}async postFunction(t){let e=await this.callData("POST","/v1/functions",t);if(!e.ok){if(400===e.status)throw new r((await e.json()).error);throw console.error("failed to add function to stamp",e.url,e.statusText,await e.text()),Error("Failed to deploy function")}}async putDatasets(t,e,a){for(let r of(await this.callApiParallel("PUT","/v1/orgs/".concat(t,"/apps/").concat(e.id,"/datasets"),a,"text/yaml")))if(!r.ok)throw console.error("failed to update datasets in stamp",r.url,await r.text()),Error("Failed to update datasets")}async deleteDataset(t){for(let e of(await this.callApiParallel("DELETE","/v1/datasets/".concat(t))))if(!e.ok)throw console.error("failed to delete dataset in stamp",e.url,await e.text()),Error("Failed to update datasets")}async trainModel(t){let e=await this.callData("POST","/v1/train",t);if(!e.ok){if(400===e.status)throw new r((await e.json()).error);throw console.error("failed to add function to stamp",e.url,e.statusText,await e.text()),Error("Failed to deploy model")}return await e.json()}async linkAppWithDataPlatformOrg(t,e){if(!t)throw Error("App is required");if(!e)throw Error("Org name is required");let a={id:t.id,name:t.name,api_key:t.api_key,api_key_2:t.api_key_2,org_id:t.org_id,repo_id:t.repo_id};for(let r of((!0===t.has_shared_spicepod||!1===t.has_shared_spicepod)&&(a.has_shared_spicepod=t.has_shared_spicepod),await this.callApiParallel("POST","/admin/orgs/".concat(e,"/link"),a))){if(!r.ok)throw console.error("failed to link organization to app in data-platform",e,await r.text()),Error("Failed to link app with organization");console.log("app linked",r)}}async deleteApp(t,e){if(!t)throw Error("App ID is required");if(!e)throw Error("Org name is required");for(let a of(await this.callApiParallel("DELETE","/admin/orgs/".concat(e,"/").concat(t))))if(!a.ok)throw console.error("failed to delete app in data-platform",a.statusText,e,t,await a.text()),Error("Failed to delete app")}async postAdminJob(t,e,a,r,o,i){return await fetch("".concat(t,"/admin/jobs"),{method:"POST",headers:this.commonHeaders,body:JSON.stringify({name:a,app_id:e,path:r,verb:o,data:i})})}async sqlQuery(t){return this.callData("POST","/v1/sql",t,"text/plain")}async getFunctionOutput(t,e){let a=await this.callData("GET","/v1/functions/".concat(t,"/output/").concat(e));return a.ok?a.text():(console.error("Failed to get function output '".concat(e,"' for '").concat(t,"'"),a),null)}async getFunctionDeploymentOutput(t,e,a){let r=await this.callData("GET","/v1/functions/".concat(t,"/deployment/").concat(e,"/output/").concat(a));return r.ok?r.text():(console.error("Failed to get function deployment output '".concat(a,"' for '").concat(t,"'/'").concat(e,"'"),r),null)}async callData(t,e,a,r){return this.call("https://data.spiceai.io",t,e,a,r)}async callApiParallel(t,e,a,r){let o=[];for(let i of this._stampUrls){let s=this.call(i,t,e,a,r);o.push(s)}return Promise.all(o)}async callApiParallelSettled(t,e,a,r){let o=[];for(let i of this._stampUrls){let s=this.call(i,t,e,a,r);o.push(s)}return await Promise.allSettled(o)}async call(t,e,a,r,o){let i={method:e,headers:this.commonHeaders};return r&&(i.body=o?r:JSON.stringify(r),o?i.headers={...this.commonHeaders,"Content-Type":o}:"GET"!==e&&(i.headers={...this.commonHeaders,"Content-Type":"application/json"})),fetch("".concat(t).concat(a),i)}get stampUrls(){return this._stampUrls}cloudOrgToDataPlatformOrg(t){return{id:t.id,name:t.name,owner_id:t.owner_id,plan_type:t.plan_type,plan_add_ons:t.addons}}constructor(t,e){this._stampUrls=t,this.commonHeaders={"Accept-Encoding":"gzip, deflate","X-API-KEY":e,"X-Spice-Origin":"spice.ai",Accept:"application/json"}}}},48447:function(t,e,a){a.d(e,{F:function(){return i}});var r=a(2265),o=a(54882);function i(){let[t,e]=(0,r.useState)(!1),{set:a}=(0,o.K)();return{copy:t=>{navigator&&navigator.clipboard&&(navigator.clipboard.writeText(t),e(!0),a(()=>e(!1),2500))},copied:t}}},93567:function(t,e,a){a.d(e,{UP:function(){return n},mO:function(){return i},yR:function(){return l}});var r=a(36470);let o={},i=t=>(o[t.id]||(o[t.id]=(0,r.pz)(t)),o[t.id]),s={},n=t=>(s[t.id]||(s[t.id]=(0,r.Xl)(t)),s[t.id]),l=t=>{delete o[t.id]}},54882:function(t,e,a){a.d(e,{K:function(){return o}});var r=a(2265);function o(){let t=(0,r.useRef)(),e=()=>{t.current&&clearTimeout(t.current)};return{set:(a,r)=>{e(),t.current=setTimeout(a,r)},clear:e}}},31304:function(t,e,a){a.d(e,{Zj:function(){return i},k2:function(){return r},yh:function(){return o}});let r=new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}),o=new Intl.NumberFormat(void 0,{style:"decimal",minimumFractionDigits:1,maximumFractionDigits:3});new Intl.NumberFormat(void 0,{style:"currency",currency:"USD"});let i=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:0})}}]);