wizards 0.2.46 → 0.2.47
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/apps/runtime/dist/app.js +3 -0
- package/apps/runtime/dist/cli/features.js +50 -0
- package/apps/runtime/dist/cli/main.js +4 -1
- package/apps/runtime/dist/features.js +123 -0
- package/apps/runtime/dist/manage.js +13 -0
- package/apps/runtime/dist/plugins/discovery.js +11 -0
- package/apps/runtime/dist/plugins/loader.js +10 -0
- package/apps/runtime/dist/routes/internal.js +3 -0
- package/apps/runtime/dist/routes/studio.js +7 -5
- package/apps/web/dist/assets/{AboutDialog-DkY1j7k6.js → AboutDialog-t7bpiasT.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-820LI5Jt.js → ChangelogDialog-B87yS6aN.js} +1 -1
- package/apps/web/dist/assets/{ChatView-DBl0iRMg.js → ChatView-Dm764bYy.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-BwJ-hqPg.js → EditorPage-BG_Ue2iC.js} +3 -3
- package/apps/web/dist/assets/{Harness-CfUfchNw.js → Harness-zKMptCzB.js} +1 -1
- package/apps/web/dist/assets/HomePage-BXSg5P5k.js +1 -0
- package/apps/web/dist/assets/{ProjectPage-Btf0TeP_.js → ProjectPage-D6Fy7uTV.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-BxYinn04.js → PublicRunner-ChgJs0C9.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-DfnEMPTq.js → RunDrawer-CvIKLphz.js} +1 -1
- package/apps/web/dist/assets/{RunnerView-CLrGb-oq.js → RunnerView-Bmayop7s.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-QkwtRFoD.js +1 -0
- package/apps/web/dist/assets/SetupPage-B3IOQLO3.js +1 -0
- package/apps/web/dist/assets/{SharePage-D5AvnhlY.js → SharePage-C3QEzicl.js} +1 -1
- package/apps/web/dist/assets/ThemeSwitch-3IzIOlNz.js +1 -0
- package/apps/web/dist/assets/changelog-Du2gWzlN.js +1 -0
- package/apps/web/dist/assets/{index-CIO9W4pe.js → index-Cz6c1S5g.js} +4 -4
- package/apps/web/dist/index.html +3 -3
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +21 -0
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.d.ts +54 -0
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.js +46 -0
- package/node_modules/@engenty-wizards/shared/dist/features.d.ts +36 -0
- package/node_modules/@engenty-wizards/shared/dist/features.js +78 -0
- package/package.json +1 -1
- package/apps/web/dist/assets/HomePage-BG5OZJkv.js +0 -1
- package/apps/web/dist/assets/SettingsPage-FWH84btd.js +0 -1
- package/apps/web/dist/assets/SetupPage-BI0kUNVW.js +0 -1
- package/apps/web/dist/assets/ThemeSwitch-C1qYFoYP.js +0 -1
- package/apps/web/dist/assets/changelog-B6QMrVxX.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r}from"./logo-C80CWCDM.js";import{t as i}from"./useMutation-DKcIz55V.js";import{A as a,C as o,G as s,P as c,_ as l,t as u}from"./ui-D92EkdEB.js";import{t as d}from"./refresh-cw-Cli5WGnW.js";import{r as f}from"./ThemeSwitch-C1qYFoYP.js";var p=e(t(),1),m=2,h=1,g=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},_=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=te.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ee(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var te=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ee(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},ne=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function re(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var ie=class{constructor(e=re,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ne;this._linkProvider=this._terminal.registerLinkProvider(new _(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},ae=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?oe(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ae(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ce=`Terminal input`,b={get:()=>ce,set:e=>ce=e},le=`Too much output to announce, navigate to rows manually to read`,ue={get:()=>le,set:e=>le=e};function de(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function fe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function pe(e,t,n,r){e.stopPropagation(),e.clipboardData&&me(e.clipboardData.getData(`text/plain`),t,n,r)}function me(e,t,n,r){e=de(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function he(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ge(e,t,n,r,i){he(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _e(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ve=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ye=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},be=``,xe=` `,Se=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ce}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ce=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends Se{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ce,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},we=`di$target`,Te=`di$dependencies`,Ee=new Map;function De(e){return e[Te]||[]}function w(e){if(Ee.has(e))return Ee.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Oe(t,e,r)};return t._id=e,Ee.set(e,t),t}function Oe(e,t,n){t[we]===t?t[Te].push({id:e,index:n}):(t[Te]=[{id:e,index:n}],t[we]=t)}var T=w(`BufferService`),ke=w(`CoreMouseService`),Ae=w(`CoreService`),je=w(`CharsetService`),Me=w(`InstantiationService`),Ne=w(`LogService`),E=w(`OptionsService`),Pe=w(`OscLinkService`),Fe=w(`UnicodeService`),Ie=w(`DecorationService`),Le=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Re(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Le=v([y(0,T),y(1,E),y(2,Pe)],Le);function Re(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r}from"./logo-C80CWCDM.js";import{t as i}from"./useMutation-DKcIz55V.js";import{A as a,C as o,G as s,P as c,_ as l,t as u}from"./ui-D92EkdEB.js";import{t as d}from"./refresh-cw-Cli5WGnW.js";import{r as f}from"./ThemeSwitch-3IzIOlNz.js";var p=e(t(),1),m=2,h=1,g=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},_=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=te.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ee(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var te=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ee(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},ne=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function re(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var ie=class{constructor(e=re,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ne;this._linkProvider=this._terminal.registerLinkProvider(new _(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},ae=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?oe(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ae(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ce=`Terminal input`,b={get:()=>ce,set:e=>ce=e},le=`Too much output to announce, navigate to rows manually to read`,ue={get:()=>le,set:e=>le=e};function de(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function fe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function pe(e,t,n,r){e.stopPropagation(),e.clipboardData&&me(e.clipboardData.getData(`text/plain`),t,n,r)}function me(e,t,n,r){e=de(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function he(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ge(e,t,n,r,i){he(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _e(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ve=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ye=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},be=``,xe=` `,Se=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ce}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ce=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends Se{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ce,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},we=`di$target`,Te=`di$dependencies`,Ee=new Map;function De(e){return e[Te]||[]}function w(e){if(Ee.has(e))return Ee.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Oe(t,e,r)};return t._id=e,Ee.set(e,t),t}function Oe(e,t,n){t[we]===t?t[Te].push({id:e,index:n}):(t[Te]=[{id:e,index:n}],t[we]=t)}var T=w(`BufferService`),ke=w(`CoreMouseService`),Ae=w(`CoreService`),je=w(`CharsetService`),Me=w(`InstantiationService`),Ne=w(`LogService`),E=w(`OptionsService`),Pe=w(`OscLinkService`),Fe=w(`UnicodeService`),Ie=w(`DecorationService`),Le=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Re(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Le=v([y(0,T),y(1,E),y(2,Pe)],Le);function Re(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ze=w(`CharSizeService`),Be=w(`CoreBrowserService`),Ve=w(`MouseService`),He=w(`RenderService`),Ue=w(`SelectionService`),We=w(`CharacterJoinerService`),Ge=w(`ThemeService`),Ke=w(`LinkProviderService`),qe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$e.isErrorNoTelemetry(e)?new $e(e.message+`
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,t as r}from"./jsx-runtime-D3jfb0Ew.js";import{O as i,r as a}from"./logo-C80CWCDM.js";import{b as o,c as s,f as c,m as l,n as u,p as d,x as f}from"./Marketplace-BWhUJ4UX.js";import{t as p}from"./useMutation-DKcIz55V.js";import{A as m,B as ee,C as h,D as g,G as _,I as v,J as y,M as b,P as x,Q as te,R as ne,V as S,_ as C,a as re,c as w,d as ie,f as T,g as ae,i as oe,n as E,nt as D,o as se,r as O,s as k,t as A}from"./ui-D92EkdEB.js";import{n as ce,r as j,t as le}from"./sparkles-CP5H-O1E.js";import{t as M}from"./external-link-CpU8aJY2.js";import{n as ue}from"./volume-2-0SfkvOho.js";import{O as de}from"./definition-CQGiBQ4X.js";import{d as fe,f as pe,s as N,t as me,u as he}from"./session-miDEdw2c.js";import{i as ge,o as P,r as F,t as _e}from"./ThemeSwitch-3IzIOlNz.js";var I={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};I.node;var ve=y(I),L={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};L.node;var R=y(L),z={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};z.node;var B=y(z),V={name:`fingerprint-pattern`,size:24,node:[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]],aliases:[`fingerprint`]};V.node;var H=y(V),ye={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};ye.node;var be=y(ye),xe={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};xe.node;var Se=y(xe),Ce={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Ce.node;var U=y(Ce),we={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};we.node;var Te=y(we),Ee={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Ee.node;var De=y(Ee),Oe={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Oe.node;var ke=y(Oe),Ae={name:`message-circle-more`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]};Ae.node;var je=y(Ae),W={name:`message-circle`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]};W.node;var Me=y(W),Ne={name:`message-square-text`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]};Ne.node;var Pe=y(Ne),Fe={name:`phone-call`,size:24,node:[[`path`,{d:`M13 2a9 9 0 0 1 9 9`,key:`1itnx2`}],[`path`,{d:`M13 6a5 5 0 0 1 5 5`,key:`11nki7`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};Fe.node;var Ie=y(Fe),Le={name:`radio`,size:24,node:[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};Le.node;var Re=y(Le),ze={name:`rows-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]],aliases:[`panels-top-bottom`]};ze.node;var Be=y(ze),G=e(n(),1),Ve=e=>[`project-files`,e];function He(e){return a({queryKey:Ve(e),queryFn:()=>h.get(`/api/studio/projects/${e}/files`),refetchInterval:e=>e.state.data?.files.some(e=>e.status===`pending`)?2e3:!1})}function Ue(e,t){return m(`/api/studio/projects/${e}/files/${t}/content`)}function We(e,t=!1){let n=i(),[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),c=()=>n.invalidateQueries({queryKey:Ve(e)}),l=async e=>{s(null);try{await e()}catch(e){s(e.message)}finally{await c()}};return{busy:r,error:o,readOnly:t,upload:async(t,n)=>{a(!0),await l(async()=>{for(let r of n)await h.upload(`/api/studio/projects/${e}/files?kind=${t}`,r),await c()}),a(!1)},describe:(t,n)=>l(()=>h.patch(`/api/studio/projects/${e}/files/${t}`,{description:n})),remove:t=>l(()=>h.del(`/api/studio/projects/${e}/files/${t}`)),reindex:t=>l(()=>h.post(`/api/studio/projects/${e}/files/${t}/reindex`)),order:(t,n)=>l(()=>h.put(`/api/studio/projects/${e}/files/order`,{kind:t,ids:n}))}}function Ge(e,t){let n=`wz.layout.${e}`,[r,i]=(0,G.useState)(()=>{try{let e=localStorage.getItem(n);return e===`list`||e===`cards`?e:t}catch{return t}});return[r,()=>i(e=>{let t=e===`list`?`cards`:`list`;try{localStorage.setItem(n,t)}catch{}return t})]}function Ke(e,t,n=700){let[r,i]=(0,G.useState)(`idle`),[a,o]=(0,G.useState)(null),s=JSON.stringify(e),c=(0,G.useRef)(s),l=(0,G.useRef)({value:e,json:s,save:t});l.current={value:e,json:s,save:t};let u=(0,G.useRef)(Promise.resolve()),d=(0,G.useCallback)(()=>{let e=l.current;e.json!==c.current&&(c.current=e.json,i(`saving`),u.current=u.current.then(async()=>{try{await e.save(e.value),o(null),i(`saved`)}catch(e){c.current=``,o(e.message),i(`error`)}}))},[]);return(0,G.useEffect)(()=>{if(s===c.current)return;let e=setTimeout(d,n);return()=>clearTimeout(e)},[s,n,d]),(0,G.useEffect)(()=>d,[d]),{state:r,error:a}}function qe(e){return e<1e6?`${Math.max(1,Math.round(e/1e3))} KB`:`${(e/1e6).toFixed(1)} MB`}var K=e(r(),1);function Je({id:e,children:t}){return(0,K.jsx)(`div`,{id:e,className:`scroll-mt-6 max-md:scroll-mt-20`,children:t})}function q({title:e,hint:t,save:n,action:r,locked:i,plain:a,children:o}){return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),n?.state===`saving`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(T,{className:`size-3`}),` `,x(`project.saving`)]}):n?.state===`saved`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-moss`,children:[(0,K.jsx)(_,{className:`size-3.5`}),` `,x(`settings.saved`)]}):null]}),t?(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:t}):null]}),r?(0,K.jsx)(`div`,{className:`shrink-0`,children:r}):null]}),a?o:(0,K.jsxs)(E,{className:`p-3.5 sm:p-5`,children:[i?(0,K.jsx)(`fieldset`,{disabled:!0,className:`min-w-0`,children:o}):o,n?.state===`error`&&n.error?(0,K.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n.error}):null]})]})}function Ye({children:e,layout:t,onToggle:n}){return(0,K.jsxs)(`div`,{className:`mb-3 flex items-start gap-2`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(`div`,{className:`w-56 max-w-full transition-[width] duration-200 focus-within:w-full has-[input:not(:placeholder-shown)]:w-full`,children:e})}),(0,K.jsx)(se,{label:x(t===`list`?`project.viewCards`:`project.viewList`),onClick:n,children:t===`list`?(0,K.jsx)(Te,{className:`size-4`}):(0,K.jsx)(De,{className:`size-4`})})]})}function Xe({value:e,onChange:t,onEnter:n,placeholder:r,busy:i}){return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(c,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,K.jsx)(`input`,{type:`search`,value:e,placeholder:r,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n?.(),className:`h-9 w-full rounded-lg border border-input bg-card pr-3 pl-9 text-[0.875rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),i?(0,K.jsx)(T,{className:`-translate-y-1/2 absolute top-1/2 right-3 size-4 text-ink-3`}):null]})}function Ze({onFiles:e,accept:t,multiple:n=!0,className:r,children:i}){return(0,K.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),e.currentTarget.dataset.over=`1`},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:t=>{t.preventDefault(),delete t.currentTarget.dataset.over;let r=Array.from(t.dataTransfer.files);r.length&&e(n?r:r.slice(0,1))},className:C(`flex cursor-pointer items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow hover:border-ink-4 hover:text-ink data-[over]:border-focus data-[over]:bg-paper-2 data-[over]:text-ink`,r),children:[i,(0,K.jsx)(`input`,{className:`sr-only`,type:`file`,accept:t,multiple:n,onChange:t=>{let n=Array.from(t.target.files??[]);t.target.value=``,n.length&&e(n)}})]})}function J(e){try{return new URL(e).host}catch{return e}}var Y=e=>`${window.location.origin}${g}/w/${e.shareToken}`;function X(e,t,n){if(!e.published)return{kind:`draft`};if(t.mode===`managed`)return{kind:`live`,url:Y(e),runs:e.publishedVersion??0,notes:0,cloud:!1};if(!t.account||n===null)return{kind:`here`};if(n===void 0)return{kind:`unknown`};let{copy:r,error:i}=n,a=r?.publishedVersion??null,o=r&&a!==null?r.shareUrl:null;return i?.again?{kind:`sending`,url:o,runs:a,again:i.again}:i?{kind:`missing`,url:o,runs:a,why:i.message}:!r||r.version<(e.publishedVersion??0)?{kind:`missing`,url:o,runs:a,why:x(`cloud.notSent`)}:!r.runnable||!o||a===null?{kind:`missing`,url:o,runs:a,why:`${x(`cloud.notRunnable`,{v:r.version})} ${a===null?x(`cloud.nothingRuns`):x(`cloud.keepsRunning`,{v:a})}`}:{kind:`live`,url:o,runs:a,notes:r.problems.filter(e=>!e.blocking).length,cloud:!0}}function Qe(e){return e.kind===`live`||e.kind===`sending`||e.kind===`missing`?e.url:null}function $e({where:e,me:t,version:n}){let r=J(t.account?.cloudUrl??``),i=`size-3.5`;switch(e.kind){case`draft`:return null;case`unknown`:return(0,K.jsx)(O,{tone:`live`,children:x(`home.live`)});case`here`:return(0,K.jsx)(O,{icon:(0,K.jsx)(U,{className:i}),title:x(`where.hereHint`),children:n?x(`where.hereVersion`,{v:n}):x(`where.here`)});case`live`:{let t=n?x(`editor.published`,{v:e.runs}):x(`home.live`),a=e.notes===1?x(`where.note`):e.notes>1?x(`where.notes`,{n:e.notes}):null;return(0,K.jsx)(O,{tone:`live`,icon:e.cloud?(0,K.jsx)(B,{className:i}):void 0,title:e.cloud?x(`where.liveHint`,{host:r}):void 0,children:a?`${t} · ${a}`:t})}case`sending`:return(0,K.jsx)(O,{tone:`warn`,icon:(0,K.jsx)(S,{className:i}),title:x(`cloud.again`,{when:new Intl.DateTimeFormat(b,{timeStyle:`short`}).format(new Date(e.again))}),children:x(`where.sending`)});case`missing`:return(0,K.jsx)(O,{tone:`warn`,icon:(0,K.jsx)(f,{className:i}),title:e.why,children:e.runs===null?x(`where.missing`):x(`editor.published`,{v:e.runs})})}}var et=`mt-1.5 text-[0.8125rem] text-ink-3`;function Z(e){let t=i(),[n,r]=(0,G.useState)(!1),a=p({mutationFn:e=>h.post(`/api/studio/account/link`,e),onSuccess:({url:e})=>{F(e),r(!0)}});return(0,G.useEffect)(()=>{if(!n)return;let e=setInterval(()=>void t.invalidateQueries({queryKey:[`me`]}),2e3),i=setTimeout(()=>r(!1),3e5);return()=>{clearInterval(e),clearTimeout(i)}},[n,t]),(0,G.useEffect)(()=>{e&&r(!1)},[e]),{link:a,waiting:n}}function Q({link:e,waiting:t}){return e.isError?(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:x(`local.accountFailed`)}):t?(0,K.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(T,{className:`size-3.5`}),` `,x(`local.accountWaiting`)]}):null}function tt(){let e=P(`account`),t=Z(!1),{link:n}=t,[r,i]=(0,G.useState)(``);return(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 py-5 first:pt-0 last:pb-0`,children:[(0,K.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2`,children:(0,K.jsx)(be,{className:`size-5`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:x(`account.local`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:x(`account.localText`)})]})]}),e?(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 py-5 last:pb-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:x(`account.with`)}),(0,K.jsxs)(`ul`,{className:`mt-2 flex flex-col gap-2 text-[0.875rem] text-ink-2 leading-snug`,children:[(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-amber`}),x(`account.withCredits`)]}),(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),x(`account.withCloud`)]})]})]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(A,{busy:n.isPending&&!n.variables?.signup,onClick:()=>n.mutate({}),children:x(`account.signIn`)})})]}):null,e?(0,K.jsxs)(`form`,{className:`flex flex-col gap-3 py-5 last:pb-0`,onSubmit:e=>{e.preventDefault(),n.mutate({signup:!0,code:r.trim()||void 0})},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:x(`account.new`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:x(`account.newHint`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(k,{value:r,maxLength:64,autoComplete:`off`,spellCheck:!1,placeholder:x(`account.code`),"aria-label":x(`account.code`),onChange:e=>i(e.target.value),className:`w-56 font-mono text-[0.875rem]`}),(0,K.jsx)(A,{type:`submit`,variant:`secondary`,className:`h-11`,busy:n.isPending&&!!n.variables?.signup,children:x(`account.create`)})]}),(0,K.jsx)(Q,{...t})]}):null]})}var nt={start:`account.kind.start`,monthly:`account.kind.monthly`,gift:`account.kind.gift`};function rt({account:e}){let t=i(),n=Z(e.signedIn),r=p({mutationFn:()=>h.del(`/api/studio/account`),onSuccess:()=>t.invalidateQueries({queryKey:[`me`]})}),a=new Intl.DateTimeFormat(b,{dateStyle:`medium`});return(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 py-5 first:pt-0`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.name||e.email}),e.signedIn?(0,K.jsx)(O,{tone:`live`,children:x(`account.linked`)}):null]}),(0,K.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.email})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(A,{variant:`secondary`,onClick:()=>F(e.url),children:[x(`setup.openAccount`),` `,(0,K.jsx)(M,{className:`size-4`})]}),(0,K.jsxs)(A,{variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(),children:[(0,K.jsx)(ke,{className:`size-4`}),` `,x(`nav.logout`)]})]})]}),e.signedIn?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 py-5`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:x(`local.accountExpired`)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(A,{busy:n.link.isPending,onClick:()=>n.link.mutate({}),children:x(`account.signInAgain`)})}),(0,K.jsx)(Q,{...n})]}),e.credits===null?null:(0,K.jsxs)(`div`,{className:`py-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:x(`account.credits`)}),(0,K.jsx)(`div`,{className:`font-display font-semibold text-[1.375rem] tabular-nums leading-tight`,children:x(`nav.credits`,{n:Math.floor(e.credits).toLocaleString()})})]}),(0,K.jsxs)(A,{variant:`secondary`,onClick:()=>F(`${e.url}/billing`),children:[x(`account.topUp`),` `,(0,K.jsx)(M,{className:`size-4`})]})]}),e.expiring.length?(0,K.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1 text-[0.8125rem] text-ink-3 tabular-nums`,children:e.expiring.map(e=>(0,K.jsxs)(`li`,{children:[x(`account.expires`,{n:Math.floor(e.credits).toLocaleString(),date:a.format(new Date(e.expiresAt))}),nt[e.kind]?(0,K.jsxs)(`span`,{className:`text-ink-4`,children:[` · `,x(nt[e.kind])]}):null]},`${e.kind}:${e.expiresAt}`))}):null]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5 py-5 text-[0.875rem] text-ink-2 leading-snug last:pb-0`,children:[(0,K.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),(0,K.jsx)(`p`,{children:x(`account.cloud`,{host:J(e.cloudUrl)})})]})]})}function it({me:e,fromAccount:t}){let n=i(),[r,a]=(0,G.useState)(e.profile),o=e=>a(t=>({...t,...e})),s=Ke(r,async e=>{await h.put(`/api/studio/profile`,e),await n.invalidateQueries({queryKey:[`me`]})});return(0,K.jsx)(q,{title:x(`account.profile`),hint:x(`account.hint`),save:s,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-6 sm:flex-row sm:gap-8`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-2 sm:w-32`,children:[(0,K.jsx)(`div`,{className:`flex size-20 items-center justify-center overflow-hidden rounded-full bg-ember-tint font-semibold text-[1.75rem] text-ember-strong ring-1 ring-border-soft`,children:e.user.image?(0,K.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full object-cover`}):me(r.name)||`?`}),(0,K.jsx)(`p`,{className:`text-center text-[0.75rem] text-ink-3 leading-snug`,children:x(`account.initials`)})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.name`)}),(0,K.jsx)(k,{value:r.name,maxLength:80,disabled:t,onChange:e=>o({name:e.target.value})}),(0,K.jsx)(`p`,{className:et,children:x(t?`account.fromAccount`:`account.nameHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.about`)}),(0,K.jsx)(ae,{minRows:3,maxLength:2e3,value:r.about,onChange:e=>o({about:e.target.value})}),(0,K.jsx)(`p`,{className:et,children:x(`account.aboutHint`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.email`)}),(0,K.jsx)(k,{type:`email`,value:r.email,maxLength:200,disabled:t,onChange:e=>o({email:e.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(w,{children:x(`account.phone`)}),(0,K.jsx)(k,{type:`tel`,value:r.phone,maxLength:40,onChange:e=>o({phone:e.target.value})})]})]})]})]})})}function at({me:e}){let t=e.mode===`managed`,n=t||!!e.account;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,K.jsx)(q,{title:x(`account.connection`),hint:x(`account.connectionHint`),children:t?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.user.name}),(0,K.jsx)(O,{tone:`live`,children:x(`account.linked`)})]}),(0,K.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.user.email})]}),e.manageUrl?(0,K.jsxs)(A,{variant:`secondary`,onClick:()=>F(`${e.manageUrl}/account`),children:[x(`setup.openAccount`),` `,(0,K.jsx)(M,{className:`size-4`})]}):null]}):e.account?(0,K.jsx)(rt,{account:e.account}):(0,K.jsx)(tt,{})}),(0,K.jsx)(it,{me:e,fromAccount:n},n?`account`:`own`),(0,K.jsx)(q,{title:x(`account.look`),hint:x(`account.lookHint`),children:(0,K.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pb-4`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:x(`nav.language`)}),(0,K.jsx)(ge,{tone:`surface`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-4`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:x(`nav.theme`)}),(0,K.jsx)(_e,{})]})]})})]})}var ot={steps:Be,chat:Me,talk:ee,whatsapp:je,sms:Pe,call:Ie,video:ue},st=e=>ot[e]??d,ct=[`steps`,`chat`];function lt(){return a({queryKey:[`runners`],queryFn:()=>h.get(`/api/studio/runners`),staleTime:6e4})}function ut(e,t){let n=new Set(t.map(e=>e.id)),r=(e.runners?.enabled??ct).filter(e=>n.has(e)),i=e.runners?.default??`steps`;return[...r].sort((e,t)=>e===i?-1:+(t===i))}function dt({w:e,runners:t}){let n=ut(e,t),r=e.runners?.default??`steps`;return(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:n.map(e=>{let n=st(e),i=t.find(t=>t.id===e)?.label[b]??e;return(0,K.jsx)(n,{"aria-label":i,className:C(`size-3.5`,e===r?`text-ink-2`:`text-ink-4`),children:(0,K.jsx)(`title`,{children:i})},e)})})}var ft=t({HomePage:()=>Ot,NewSpaceDialog:()=>$,ProjectSwitcher:()=>mt}),pt=[{icon:s,name:()=>x(`nav.wizards`),what:`space.holds.wizards`},{icon:H,name:()=>x(`space.info`),what:`space.holds.info`},{icon:R,name:()=>`${x(`space.knowledge`)} & ${x(`space.data`)}`,what:`space.holds.knowledge`},{icon:l,name:()=>x(`connectors.title`),what:`space.holds.connectors`},{icon:Se,name:()=>x(`space.results`),what:`space.holds.results`}];function $({open:e,onClose:t}){let{select:n}=N(),r=i(),[a,o]=(0,G.useState)(``),s=p({mutationFn:()=>h.post(`/api/studio/projects`,{name:a}),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`projects`]}),n(e),o(``),t()}});return(0,K.jsxs)(oe,{open:e,onClose:t,title:x(`home.newProject`),children:[(0,K.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:x(`space.holds.intro`)}),(0,K.jsx)(`dl`,{className:`mt-4 flex flex-col gap-2.5 text-[0.8125rem]`,children:pt.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(e.icon,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`dt`,{className:`w-28 shrink-0 font-medium text-ink`,children:e.name()}),(0,K.jsx)(`dd`,{className:`min-w-0 text-ink-3`,children:x(e.what)})]},e.what))}),(0,K.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-4`,children:x(`space.holds.shared`)}),(0,K.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),a.trim()&&s.mutate()},children:[(0,K.jsx)(k,{autoFocus:!0,placeholder:x(`home.projectName`),value:a,onChange:e=>o(e.target.value)}),(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(A,{variant:`ghost`,onClick:t,children:x(`common.cancel`)}),(0,K.jsx)(A,{type:`submit`,busy:s.isPending,disabled:!a.trim(),children:x(`home.newProject`)})]})]})]})}function mt(){let{project:e,projects:t,select:n}=N(),r=pe().data?.limits.projects??1,i=fe(),[a,o]=(0,G.useState)(!1);return!e||r!==null&&r<=1?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ie,{className:`w-56`,value:e.id,onChange:e=>e===`__new`?o(!0):n(e),options:[...t.map(e=>({value:e.id,label:e.name})),...i?[r===null||t.length<r?{value:`__new`,label:`+ ${x(`home.newProject`)}`}:{value:`__new`,label:x(`home.projectLimit`,{n:r}),disabled:!0}]:[]]}),(0,K.jsx)($,{open:a,onClose:()=>o(!1)})]})}function ht({url:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[t?(0,K.jsx)(_,{className:`size-3.5`}):(0,K.jsx)(j,{className:`size-3.5`}),x(t?`share.copied`:`share.link`)]})}function gt(){let e=D(),t=Z(!1),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!n)return;let e=e=>{i.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,K.jsxs)(`div`,{className:`relative`,ref:i,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[(0,K.jsx)(j,{className:`size-3.5`}),` `,x(`share.link`)]}),n?(0,K.jsxs)(`div`,{className:`absolute right-0 bottom-10 z-20 flex w-72 animate-rise flex-col gap-3 rounded-xl bg-card p-3.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-relaxed`,children:x(`teaser.link`)}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(A,{size:`sm`,busy:t.link.isPending,onClick:()=>t.link.mutate({}),children:x(`account.signIn`)}),(0,K.jsx)(A,{size:`sm`,variant:`secondary`,onClick:()=>e(`/settings/account`),children:x(`account.create`)})]}),(0,K.jsx)(Q,{...t})]}):null]})}function _t({w:e,me:t,runners:n}){let r=P(`account`),i=D(),a=X(e,t,e.cloud),o=Qe(a),s=o??(e.published?Y(e):null);return(0,K.jsxs)(`div`,{className:`relative pt-6`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-4 z-10`,children:(0,K.jsx)(de,{kind:e.avatar,size:52})}),(0,K.jsxs)(E,{className:`relative flex h-full cursor-pointer flex-col px-5 pt-10 pb-3 transition hover:shadow-elevated`,onClick:()=>i(`/edit/${e.id}`),children:[(0,K.jsx)(`div`,{className:`absolute top-3 right-3`,children:e.published?(0,K.jsx)($e,{where:a,me:t}):(0,K.jsx)(O,{children:x(`home.draft`)})}),(0,K.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem] leading-snug`,children:e.title}),(0,K.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.description}),(0,K.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between pt-3`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2.5 text-[0.75rem] text-ink-4`,children:[x(`home.steps`,{n:e.stepCount}),(0,K.jsx)(dt,{w:e,runners:n})]}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[o?(0,K.jsx)(ht,{url:o}):a.kind===`here`&&r?(0,K.jsx)(gt,{}):null,s?(0,K.jsx)(se,{label:x(o?`share.open`:`share.openHere`),className:`ml-1 size-8`,onClick:e=>{e.stopPropagation(),F(s)},children:(0,K.jsx)(ve,{className:`size-4`})}):null]})]})]})]})}var vt=[`draft`,`here`,`live`,`missing`],yt={draft:ce,here:U,live:Re,missing:f},bt=e=>x(e===`draft`?`home.draft`:e===`here`?`where.here`:e===`live`?`home.live`:`where.missing`);function xt(e,t){let{kind:n}=X(e,t,e.cloud);return n===`draft`||n===`here`?n:n===`live`||n===`unknown`?`live`:`missing`}function St({wizards:e,me:t,value:n,onChange:r}){let i=new Map;for(let n of e){let e=xt(n,t);i.set(e,(i.get(e)??0)+1)}if(i.size<2)return null;let a=e=>C(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] transition`,e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`);return(0,K.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,className:a(n===null),onClick:()=>r(null),children:[x(`home.all`),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e.length})]}),vt.filter(e=>i.has(e)).map(e=>{let t=yt[e];return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":n===e,className:a(n===e),onClick:()=>r(n===e?null:e),children:[(0,K.jsx)(t,{className:`size-3.5`}),bt(e),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:i.get(e)})]},e)})]})}var Ct=12,wt=3;function Tt({value:e,onChange:t}){return(0,K.jsxs)(`label`,{className:`relative flex h-10 w-full max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[(0,K.jsx)(c,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:x(`home.search`),"aria-label":x(`home.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),e?(0,K.jsx)(`button`,{type:`button`,"aria-label":x(`market.reset`),onClick:()=>t(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,K.jsx)(v,{className:`size-4`})}):null]})}var Et=`curl -fsSL https://engenty.ai/install.sh | bash`;function Dt(){let[e,t]=(0,G.useState)(!1),n=[x(`home.local.install`),x(`home.local.signIn`),x(`home.local.publish`)];return(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-xl animate-rise flex-col items-center pt-4 text-center`,children:[(0,K.jsx)(de,{kind:`round`,size:120}),(0,K.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:x(`home.local.title`)}),(0,K.jsx)(`p`,{className:`mt-3 text-[0.9375rem] text-ink-2 leading-relaxed`,children:x(`home.local.text`)}),(0,K.jsx)(`ol`,{className:`mt-8 flex w-full flex-col gap-4 text-left`,children:n.map((n,r)=>(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.8125rem] text-ink-2`,children:r+1}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,K.jsx)(`p`,{className:`text-[0.9375rem] leading-snug`,children:n}),r===0?(0,K.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-lg bg-paper-2 py-1.5 pr-1.5 pl-3`,children:[(0,K.jsx)(`code`,{className:`min-w-0 flex-1 select-all overflow-x-auto whitespace-nowrap font-mono text-[0.8125rem] text-ink-2`,children:Et}),(0,K.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(Et),t(!0),setTimeout(()=>t(!1),1500)},children:[e?(0,K.jsx)(_,{className:`size-3.5`}):(0,K.jsx)(j,{className:`size-3.5`}),x(e?`share.copied`:`share.copy`)]})]}):null]})]},n))})]})}function Ot(){let e=D(),t=i(),{project:n,projects:r,loading:o}=N(),s=pe().data,c=he(),l=fe(),d=a({queryKey:[`wizards`,n?.id,!!s?.account],queryFn:()=>h.get(`/api/studio/projects/${n.id}/wizards`),enabled:!!n}),f=lt().data??[],[m,ee]=(0,G.useState)(null),[g,_]=(0,G.useState)(``),v=(d.data?.length??0)>Ct,y=v?g.trim().toLowerCase():``,S=(d.data??[]).filter(e=>(!m||!s||xt(e,s)===m)&&(!y||`${e.title} ${e.description}`.toLowerCase().includes(y))),C=!!y&&S.length<wt,w=p({mutationFn:e=>h.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:b}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),ie=r.reduce((e,t)=>e+t.wizardCount,0),T=l&&!n?.readOnly;return!o&&T&&r.length&&ie===0?(0,K.jsx)(te,{to:`/new`,replace:!0}):!o&&!c&&r.length===0?(0,K.jsx)(Dt,{}):(0,K.jsxs)(`div`,{className:`animate-rise`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[v?(0,K.jsx)(Tt,{value:g,onChange:_}):(0,K.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] tracking-tight`,children:x(`home.title`)}),T?(0,K.jsxs)(A,{onClick:()=>e(`/new`),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,x(`home.new`)]}):null]}),n?.origin===`local`?(0,K.jsxs)(`p`,{className:`mt-2 text-[0.875rem] text-ink-3`,children:[x(`home.fromLocal`),` `,n.syncedAt?x(`home.syncedAt`,{when:new Intl.DateTimeFormat(b,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n.syncedAt))}):null]}):null,d.data&&d.data.length===0?(0,K.jsxs)(re,{children:[(0,K.jsx)(`p`,{children:x(`home.empty`)}),T?(0,K.jsxs)(A,{className:`mt-5`,onClick:()=>e(`/new`),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,x(`home.new`)]}):null]}):null,d.data?.length&&s?(0,K.jsx)(St,{wizards:d.data,me:s,value:m,onChange:ee}):null,y&&S.length===0?(0,K.jsx)(`p`,{className:`mt-6 text-[0.875rem] text-ink-3`,children:x(`home.noMatch`)}):null,(0,K.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:s?S.map(e=>(0,K.jsx)(_t,{w:e,me:s,runners:f},e.id)):null}),C?(0,K.jsxs)(K.Fragment,{children:[T?(0,K.jsx)(u,{query:g,busy:w.isPending,onUse:e=>n&&!w.isPending&&w.mutate(e.id)}):(0,K.jsx)(u,{query:g}),T?(0,K.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,K.jsxs)(A,{variant:`secondary`,onClick:()=>e(`/new?wish=${encodeURIComponent(g.trim())}`),children:[(0,K.jsx)(le,{className:`size-4`}),` `,x(`home.newFromSearch`,{q:g.trim()})]})}):null]}):null]})}export{R as A,Me as C,Se as D,U as E,H as O,He as S,Te as T,qe as _,Q as a,We as b,J as c,X as d,Je as f,q as g,Xe as h,at as i,B as k,Y as l,Ye as m,$ as n,Z as o,Ze as p,mt as r,$e as s,ft as t,Qe as u,Ue as v,ke as w,Ge as x,Ke as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,r as i}from"./logo-C80CWCDM.js";import{c as a,d as o,f as s,l as c,p as l,y as u}from"./Marketplace-BWhUJ4UX.js";import{t as d}from"./useMutation-DKcIz55V.js";import{C as f,G as p,J as m,K as h,M as g,P as _,Q as v,R as y,_ as b,a as ee,c as x,d as te,f as S,g as C,i as w,it as ne,m as T,n as E,nt as re,o as D,p as O,r as k,rt as ie,s as A,t as j,tt as ae,z as M}from"./ui-D92EkdEB.js";import{_ as oe,b as N,t as se,v as ce,y as P}from"./RunnerView-CLrGb-oq.js";import{S as F,T as le,_ as I,b as L,f as R,g as z,h as B,m as V,p as H,r as U,v as W,x as ue,y as G}from"./HomePage-BG5OZJkv.js";import{_ as de,a as fe,b as K,c as pe,d as me,f as q,g as he,h as ge,i as _e,l as ve,m as ye,n as J,o as be,p as xe,s as Se,u as Ce,v as we,x as Te,y as Ee}from"./RunDrawer-DfnEMPTq.js";import{t as De}from"./external-link-CpU8aJY2.js";import{n as Oe,t as Y}from"./trash-DU-hZpV0.js";import{t as ke}from"./refresh-cw-Cli5WGnW.js";import{t as Ae}from"./upload-DMq5N6Fw.js";import{c as je,l as Me,s as Ne}from"./session-miDEdw2c.js";import{N as Pe,P as Fe,a as Ie,c as Le,i as Re,m as ze,o as Be,r as Ve,s as He,t as Ue}from"./index-CIO9W4pe.js";import{a as X,c as We,f as Ge,i as Ke,n as qe,o as Je,r as Ye,s as Xe,t as Ze,u as Qe}from"./settings-menu-ROT8Lbbj.js";import{n as $e,t as et}from"./ReadOnly-C9P9aiU6.js";var tt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};tt.node;var nt=m(tt),rt={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};rt.node;var it=m(rt),at={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};at.node;var ot=m(at),Z=e(t(),1),Q=e(n(),1),st={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function ct({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:_(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function lt(e,t){confirm(_(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function ut({projectId:e,file:t,small:n}){let r=W(e,t.id);return t.mime.startsWith(`image/`)?(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:b(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,Q.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,Q.jsx)(it,{className:n?`size-5`:`size-7`}):(0,Q.jsx)(N,{className:n?`size-5`:`size-7`})})}function dt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:s}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(0,Q.jsxs)(`div`,{className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[t===`logo`&&a===0?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(k,{tone:`ember`,children:_(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?st:void 0,children:[s&&i.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${i.name}`,onClick:()=>s(i),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(ut,{projectId:e,file:i})}):(0,Q.jsx)(ut,{projectId:e,file:i}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(D,{label:_(`project.preview`),onClick:()=>s(i),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(u,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,Q.jsx)(D,{label:_(`project.logoMakeMain`),onClick:()=>r.order(`logo`,[i.id,...n.filter(e=>e.id!==i.id).map(e=>e.id)]),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(o,{className:`size-4`})}):null,r.readOnly?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>lt(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:i.name,children:i.name}):null,(0,Q.jsx)(ct,{file:i,actions:r})]},i.id)),a&&!r.readOnly?(0,Q.jsxs)(H,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(S,{className:`size-5`}):(0,Q.jsx)(y,{className:`size-5`}),a]}):null]})}function ft({projectId:e,data:t,readOnly:n}){let r=L(e,n);return(0,Q.jsxs)(z,{title:_(`project.logos`),hint:_(`project.logosHint`),children:[(0,Q.jsx)(dt,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:_(`project.logoAdd`)}),r.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null]})}var pt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),I(e.size)].filter(Boolean).join(` · `);function mt({projectId:e,file:t,actions:n,onClose:r}){let i=W(e,t.id);return(0,Q.jsxs)(w,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:pt(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(De,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:st,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(ct,{file:t,actions:n})})]})}function ht({projectId:e,file:t,actions:n,onPreview:r}){return(0,Q.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(ut,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:pt(t)})]}),(0,Q.jsx)(ct,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,Q.jsx)(D,{label:_(`project.preview`),onClick:r,children:(0,Q.jsx)(u,{className:`size-4`})}),n.readOnly?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>lt(t,n),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function gt({projectId:e,data:t,readOnly:n}){let r=L(e,n),[i,a]=ue(`assets`,`cards`),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(null),u=t.files.filter(e=>e.kind===`asset`),d=u.find(e=>e.id===c),f=o.trim().toLowerCase(),p=f?u.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(f)):u;return(0,Q.jsxs)(z,{title:_(`project.assets`),hint:_(`project.assetsHint`),children:[u.length?(0,Q.jsx)(V,{layout:i,onToggle:a,children:(0,Q.jsx)(B,{value:o,onChange:s,placeholder:_(`project.assetSearch`)})}):null,p.length?(0,Q.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,Q.jsx)(dt,{projectId:e,kind:`asset`,files:p,actions:r,onPreview:e=>l(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map(t=>(0,Q.jsx)(ht,{projectId:e,file:t,actions:r,onPreview:()=>l(t.id)},t.id))})}):null,n?u.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:_(`project.staysLocal`)}):(0,Q.jsxs)(H,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,Q.jsx)(S,{className:`size-4`}):(0,Q.jsx)(Ae,{className:`size-4`}),_(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:_(`project.assetAdd`)})]}),r.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,d?(0,Q.jsx)(mt,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function _t(e,t,n){return i({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>f.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function vt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var yt=e=>[vt(e),e.pages?_(`project.pages`,{n:e.pages}):null,I(e.size)].filter(Boolean).join(` · `),bt=2e5;function xt({projectId:e,fileId:t,readOnly:n,onGone:i}){let a=r(),o=F(e),s=ye(e),c=L(e,n),l=o.data?.files.find(e=>e.id===t),u=l?l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[d,f]=(0,Z.useState)(null);if(!l)return o.isLoading?(0,Q.jsx)(S,{className:`mx-auto text-ink-3`}):null;let p=d??(u?`original`:`text`),m=s.data?.items.find(e=>e.key===`f:${l.id}`),h=W(e,l.id),g=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:b(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:l.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:yt(l)}),(0,Q.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(De,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:_(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(ke,{className:`size-4`})}),(0,Q.jsx)(D,{label:_(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(_(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(q,{projectId:e,itemKey:`f:${l.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(ct,{file:l,actions:c})}),l.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,Q.jsxs)(E,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[u?g(`original`,_(`project.original`)):null,g(`text`,_(`project.readText`))]}),p===`original`?l.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:h,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(St,{projectId:e,file:l})]})]})}function St({projectId:e,file:t}){let n=_t(e,t,bt);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(S,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ze,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:_(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:_(`project.noText`)})}var Ct=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],wt=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,Tt=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,Et=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Dt=/^(https?:\/\/|www\.)\S+$/i,Ot=/^\+?[\d\s()/.-]{7,20}$/,kt=/^(ja|nein|yes|no|true|false)$/i;function At(e){let t=e.trim();return t?t.includes(`
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,r as i}from"./logo-C80CWCDM.js";import{c as a,d as o,f as s,l as c,p as l,y as u}from"./Marketplace-BWhUJ4UX.js";import{t as d}from"./useMutation-DKcIz55V.js";import{C as f,G as p,J as m,K as h,M as g,P as _,Q as v,R as y,_ as b,a as ee,c as x,d as te,f as S,g as C,i as w,it as ne,m as T,n as E,nt as re,o as D,p as O,r as k,rt as ie,s as A,t as j,tt as ae,z as M}from"./ui-D92EkdEB.js";import{_ as oe,b as N,t as se,v as ce,y as P}from"./RunnerView-Bmayop7s.js";import{S as F,T as le,_ as I,b as L,f as R,g as z,h as B,m as V,p as H,r as U,v as W,x as ue,y as G}from"./HomePage-BXSg5P5k.js";import{_ as de,a as fe,b as K,c as pe,d as me,f as q,g as he,h as ge,i as _e,l as ve,m as ye,n as J,o as be,p as xe,s as Se,u as Ce,v as we,x as Te,y as Ee}from"./RunDrawer-CvIKLphz.js";import{t as De}from"./external-link-CpU8aJY2.js";import{n as Oe,t as Y}from"./trash-DU-hZpV0.js";import{t as ke}from"./refresh-cw-Cli5WGnW.js";import{t as Ae}from"./upload-DMq5N6Fw.js";import{c as je,l as Me,s as Ne}from"./session-miDEdw2c.js";import{N as Pe,P as Fe,a as Ie,c as Le,i as Re,m as ze,o as Be,r as Ve,s as He,t as Ue}from"./index-Cz6c1S5g.js";import{a as X,c as We,f as Ge,i as Ke,n as qe,o as Je,r as Ye,s as Xe,t as Ze,u as Qe}from"./settings-menu-ROT8Lbbj.js";import{n as $e,t as et}from"./ReadOnly-C9P9aiU6.js";var tt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};tt.node;var nt=m(tt),rt={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};rt.node;var it=m(rt),at={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};at.node;var ot=m(at),Z=e(t(),1),Q=e(n(),1),st={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function ct({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:_(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function lt(e,t){confirm(_(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function ut({projectId:e,file:t,small:n}){let r=W(e,t.id);return t.mime.startsWith(`image/`)?(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:b(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,Q.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,Q.jsx)(it,{className:n?`size-5`:`size-7`}):(0,Q.jsx)(N,{className:n?`size-5`:`size-7`})})}function dt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:s}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(0,Q.jsxs)(`div`,{className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[t===`logo`&&a===0?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(k,{tone:`ember`,children:_(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?st:void 0,children:[s&&i.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${i.name}`,onClick:()=>s(i),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(ut,{projectId:e,file:i})}):(0,Q.jsx)(ut,{projectId:e,file:i}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(D,{label:_(`project.preview`),onClick:()=>s(i),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(u,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,Q.jsx)(D,{label:_(`project.logoMakeMain`),onClick:()=>r.order(`logo`,[i.id,...n.filter(e=>e.id!==i.id).map(e=>e.id)]),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(o,{className:`size-4`})}):null,r.readOnly?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>lt(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:i.name,children:i.name}):null,(0,Q.jsx)(ct,{file:i,actions:r})]},i.id)),a&&!r.readOnly?(0,Q.jsxs)(H,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(S,{className:`size-5`}):(0,Q.jsx)(y,{className:`size-5`}),a]}):null]})}function ft({projectId:e,data:t,readOnly:n}){let r=L(e,n);return(0,Q.jsxs)(z,{title:_(`project.logos`),hint:_(`project.logosHint`),children:[(0,Q.jsx)(dt,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:_(`project.logoAdd`)}),r.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null]})}var pt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),I(e.size)].filter(Boolean).join(` · `);function mt({projectId:e,file:t,actions:n,onClose:r}){let i=W(e,t.id);return(0,Q.jsxs)(w,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:pt(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(De,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:st,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(ct,{file:t,actions:n})})]})}function ht({projectId:e,file:t,actions:n,onPreview:r}){return(0,Q.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${_(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(ut,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:pt(t)})]}),(0,Q.jsx)(ct,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,Q.jsx)(D,{label:_(`project.preview`),onClick:r,children:(0,Q.jsx)(u,{className:`size-4`})}),n.readOnly?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>lt(t,n),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function gt({projectId:e,data:t,readOnly:n}){let r=L(e,n),[i,a]=ue(`assets`,`cards`),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(null),u=t.files.filter(e=>e.kind===`asset`),d=u.find(e=>e.id===c),f=o.trim().toLowerCase(),p=f?u.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(f)):u;return(0,Q.jsxs)(z,{title:_(`project.assets`),hint:_(`project.assetsHint`),children:[u.length?(0,Q.jsx)(V,{layout:i,onToggle:a,children:(0,Q.jsx)(B,{value:o,onChange:s,placeholder:_(`project.assetSearch`)})}):null,p.length?(0,Q.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,Q.jsx)(dt,{projectId:e,kind:`asset`,files:p,actions:r,onPreview:e=>l(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map(t=>(0,Q.jsx)(ht,{projectId:e,file:t,actions:r,onPreview:()=>l(t.id)},t.id))})}):null,n?u.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:_(`project.staysLocal`)}):(0,Q.jsxs)(H,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,Q.jsx)(S,{className:`size-4`}):(0,Q.jsx)(Ae,{className:`size-4`}),_(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:_(`project.assetAdd`)})]}),r.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,d?(0,Q.jsx)(mt,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function _t(e,t,n){return i({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>f.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function vt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var yt=e=>[vt(e),e.pages?_(`project.pages`,{n:e.pages}):null,I(e.size)].filter(Boolean).join(` · `),bt=2e5;function xt({projectId:e,fileId:t,readOnly:n,onGone:i}){let a=r(),o=F(e),s=ye(e),c=L(e,n),l=o.data?.files.find(e=>e.id===t),u=l?l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[d,f]=(0,Z.useState)(null);if(!l)return o.isLoading?(0,Q.jsx)(S,{className:`mx-auto text-ink-3`}):null;let p=d??(u?`original`:`text`),m=s.data?.items.find(e=>e.key===`f:${l.id}`),h=W(e,l.id),g=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:b(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:l.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:yt(l)}),(0,Q.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":_(`project.openOriginal`),title:_(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(De,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:_(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(ke,{className:`size-4`})}),(0,Q.jsx)(D,{label:_(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(_(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(q,{projectId:e,itemKey:`f:${l.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(ct,{file:l,actions:c})}),l.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,Q.jsxs)(E,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[u?g(`original`,_(`project.original`)):null,g(`text`,_(`project.readText`))]}),p===`original`?l.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:h,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(St,{projectId:e,file:l})]})]})}function St({projectId:e,file:t}){let n=_t(e,t,bt);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(S,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ze,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:_(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:_(`project.noText`)})}var Ct=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],wt=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,Tt=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,Et=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Dt=/^(https?:\/\/|www\.)\S+$/i,Ot=/^\+?[\d\s()/.-]{7,20}$/,kt=/^(ja|nein|yes|no|true|false)$/i;function At(e){let t=e.trim();return t?t.includes(`
|
|
2
2
|
`)||t.length>140?`longtext`:kt.test(t)?`boolean`:Et.test(t)?`email`:Dt.test(t)?`url`:wt.test(t)?`date`:Tt.test(t)&&!/^(\+|0\d)/.test(t)?`number`:Ot.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function jt(e,t=[]){let n=e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFD`).replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`fakt`,r=n;for(let e=2;t.includes(r);e++)r=`${n}_${e}`;return r}var Mt=[{key:`adresse`,de:`Adresse`,en:`Address`},{key:`plz`,de:`PLZ`,en:`Postcode`},{key:`ort`,de:`Ort`,en:`City`},{key:`uid`,de:`UID`,en:`VAT id`},{key:`telefon`,de:`Telefon`,en:`Phone`},{key:`e_mail`,de:`E-Mail`,en:`Email`},{key:`website`,de:`Website`,en:`Website`},{key:`iban`,de:`IBAN`,en:`IBAN`}],Nt={facts:100,colors:12,files:{logo:8,asset:100,document:2e3},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},Pt=/^#[0-9a-fA-F]{6}$/;function Ft({onAdd:e,onClose:t}){let[n,r]=(0,Z.useState)(`#e0531b`),[i,a]=(0,Z.useState)(``),o=Pt.test(n);return(0,Q.jsx)(w,{open:!0,onClose:t,title:_(`project.colorAddTitle`),children:(0,Q.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),o&&(e({name:i.trim(),value:n.toLowerCase()}),t())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.colorValue`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(O,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,Q.jsx)(A,{value:n,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>r(e.target.value.trim()),className:`font-mono text-[0.875rem]`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.colorUseLabel`)}),(0,Q.jsx)(A,{autoFocus:!0,value:i,maxLength:120,placeholder:_(`project.colorName`),onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.colorUse`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:t,children:_(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,disabled:!o,children:_(`project.add`)})]})]})})}function It({colors:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),[i,a]=(0,Z.useState)(()=>e.map(e=>({...e,id:`c${r.current++}`}))),[o,s]=(0,Z.useState)(!1),c=G(i.filter(e=>Pt.test(e.value)).map(({name:e,value:t})=>({name:e.trim(),value:t})),t),l=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n));return(0,Q.jsxs)(z,{title:_(`project.colors`),hint:_(`project.colorsHint`),save:c,locked:n,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(O,{value:Pt.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,Q.jsx)(A,{value:e.name,placeholder:_(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(A,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>l(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center justify-end max-sm:w-auto`,children:[t===0?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(k,{tone:`ember`,children:_(`project.colorAccent`)})}):n?null:(0,Q.jsx)(D,{label:_(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,Q.jsx)(h,{className:`size-4`})}),n?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.colorUse`)}):null,i.length<Nt.colors&&!n?(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,Q.jsx)(y,{className:`size-4`}),` `,_(`project.colorAdd`)]}):null,o?(0,Q.jsx)(Ft,{onClose:()=>s(!1),onAdd:e=>a(t=>[...t,{...e,id:`c${r.current++}`}])}):null]})}var Lt=e=>/^(ja|yes|true)$/i.test(e.trim()),Rt={text:c,longtext:ot,number:K,date:Te,url:Oe,email:P,phone:oe,boolean:Ee};function zt({type:e,detected:t,onChange:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{c.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=Rt[e??t],u=`${_(`project.factType`)}: ${_(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),i(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:b(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:b(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(a,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:_(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:_(`project.type.${t}`)}),(0,Q.jsx)(p,{className:b(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ct.map(t=>{let n=Rt[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:_(`project.type.${t}`)}),(0,Q.jsx)(p,{className:b(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Bt({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=G(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=Mt.filter(e=>!a.some(t=>t.key===e.key));return(0,Q.jsxs)(z,{title:_(`project.facts`),hint:_(`project.factsHint`),save:s,locked:n,action:a.length<Nt.facts&&!n?(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,Q.jsx)(y,{className:`size-4`}),` `,_(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=At(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(A,{ref:u(`${e.id}:label`),value:e.label,placeholder:_(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:jt(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(T,{checked:Lt(e.value),label:e.label,onChange:t=>c(e.id,{value:_(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Lt(e.value)?_(`project.yes`):_(`project.no`)})]}):(0,Q.jsx)(C,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:_(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)(zt,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,Q.jsx)(D,{label:_(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},e.id)})}),a.length<Nt.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,Q.jsx)(y,{className:`size-4`}),` `,_(`project.factAdd`)]}),d.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:g===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(y,{className:`size-3.5`}),` `,g===`en`?e.en:e.de]},e.key))]}):null]})}function Vt({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[i,a]=(0,Z.useState)(e.brand.about??``),o=G({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(z,{title:_(`project.base`),hint:_(`project.baseHint`),save:o,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.title`)}),(0,Q.jsx)(A,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(x,{children:_(`project.about`)}),(0,Q.jsx)(C,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:_(`project.aboutHint`)})]})]})})}function Ht({project:e,group:t,docked:n=!1,children:i}){let a=r(),o=F(e.id),[s,c]=(0,Z.useState)(0),l=async t=>{await f.patch(`/api/studio/projects/${e.id}`,t),await a.invalidateQueries({queryKey:[`projects`]})},u=d({mutationFn:()=>f.del(`/api/studio/projects/${e.id}`),onSuccess:()=>a.invalidateQueries({queryKey:[`projects`]})}),p=Me(),m=je(),h=o.data??{files:[],embeddings:!0},g=`${e.id}:${s}`,v=e.readOnly;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-32`,children:[v?(0,Q.jsx)(et,{children:$e(e)}):(0,Q.jsx)(Le,{projectId:e.id,part:t,docked:n,onChanged:()=>c(e=>e+1)},e.id),t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{id:`base`,children:(0,Q.jsx)(Vt,{project:e,save:l},`base:${g}`)}),(0,Q.jsx)(R,{id:`logos`,children:(0,Q.jsx)(ft,{projectId:e.id,data:h,readOnly:v})}),(0,Q.jsx)(R,{id:`colors`,children:(0,Q.jsx)(It,{colors:e.brand.colors??[],save:e=>l({brand:{colors:e}}),readOnly:v},`colors:${g}`)}),(0,Q.jsx)(R,{id:`assets`,children:(0,Q.jsx)(gt,{projectId:e.id,data:h,readOnly:v})}),(0,Q.jsx)(R,{id:`facts`,children:(0,Q.jsx)(Bt,{facts:e.facts,save:e=>l({facts:e}),readOnly:v},`facts:${g}`)})]}):null,i,t===`info`&&p&&!v&&m?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(j,{variant:`danger`,busy:u.isPending,onClick:()=>confirm(`${_(`settings.delete`)}?`)&&u.mutate(),children:_(`settings.delete`)}),u.error?(0,Q.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:u.error.message}):null]}):null]})}var Ut={q:``,mode:``,days:0};function Wt(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let a=r.toString();return i({queryKey:[`results`,e,a],queryFn:()=>f.get(`/api/studio/projects/${e}/results${a&&`?${a}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Gt({filter:e,onFilter:t}){let[n,r]=(0,Z.useState)(e.q);return(0,Z.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(s,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(A,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:_(`space.resultsSearch`),"aria-label":_(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(te,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:_(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(te,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:_(`space.resultsAnyTime`)},{value:`1`,label:_(`space.resultsDay`)},{value:`7`,label:_(`space.resultsDays`,{n:7})},{value:`30`,label:_(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Kt({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Z.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(g,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(z,{title:t?o(t):_(`space.resultsAll`),hint:_(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(Gt,{filter:n,onFilter:r}),e.runs.length?(0,Q.jsx)(E,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,_(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:_(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(M,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(k,{children:`Test`}):(0,Q.jsxs)(k,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(E,{children:(0,Q.jsx)(ee,{children:n.q.trim()||n.mode||n.days?_(`space.resultsNone`):_(`space.resultsEmpty`)})})]}),i?(0,Q.jsx)(J,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,Q.jsx)(k,{children:`Test`}):(0,Q.jsxs)(k,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,Q.jsx)(se,{runId:i.id,compact:!0},i.id)}):null]})}function qt({project:e,save:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.name),o=d({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:_(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,Q.jsx)(ce,{className:`size-4`})}),(0,Q.jsx)(w,{open:n,onClose:()=>r(!1),title:_(`project.rename`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,Q.jsx)(A,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:()=>r(!1),children:_(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:_(`settings.save`)})]})]})})]})}function Jt({project:e}){let t=r();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(U,{}),e.readOnly?null:(0,Q.jsx)(qt,{project:e,save:async n=>{await f.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Yt(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Pe(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Xt(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function $({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(X,{icon:e.icon??l,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Ke,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function Zt(){let{group:e}=ie(),[t,n]=ne(),r=re(),i=ae(),{hash:o}=i,{project:s,loading:c}=Ne(),l=Me(),u=Ve(),d=Qe(),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,y]=(0,Z.useState)(null),x=Ie(e)?e:void 0,te=i.state?.parts===!0,S=He().map(e=>({...e,to:`/space/${e.id}`})),C=S.find(e=>e.id===x),w=t.get(`show`),T=x?w?2:1:0,E=d?Math.min(T,1):x&&g!==x&&!te?1:0,D=Ge(E),O=Ge(T),k=(0,Z.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),A=s?s.brand.name?.trim()||s.name:_(`nav.project`),j=x&&x!==`results`?Be(x,u):[],M=x?Be(x,u).filter(e=>e.plugin):[],oe=Yt([...j,...x===`results`?M:[]].flatMap(e=>e.sections.map(e=>e.id))),N=x===`results`&&w&&w!==`all`?w:null,[se,ce]=(0,Z.useState)(Ut),P=Wt(x===`results`?s?.id:void 0,N,se),F=P.data?.wizards.find(e=>e.id===N)?.title,I=x===`data`&&w&&w!==`all`||x===`knowledge`&&w&&/^[ptfcvs]:/.test(w)?w:null,L=I?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===I.slice(2)):void 0,B=x===`knowledge`&&I&&/^[ptf]:/.test(I)?I:null,V=pe(x===`data`?s?.id:void 0),H=ye(x===`knowledge`?s?.id:void 0),U=we(I?.startsWith(`v:`)?I.slice(2):``),W=H.data?.categories.find(e=>e.id===(I?.startsWith(`c:`)?I.slice(2):U.data?.category.id)),ue=x===`knowledge`?L?L.label():I?.startsWith(`v:`)?U.data&&`${U.data.category.name}: ${U.data.value}`:I?.startsWith(`c:`)?W?.name:H.data?.items.find(e=>e.key===I)?.title:V.data?Se(V.data).flatMap(e=>e.items).find(e=>e.key===I)?.title:void 0;Fe([{label:_(`nav.project`),to:`/space`},...C?[{label:C.label,to:`/space/${C.id}`}]:[],...C&&(m??F??ue)?[{label:m??F??ue}]:[]]);let G=x===`results`||x===`data`||I?o.slice(1):w||o.slice(1),K=(0,Z.useRef)(``);if((0,Z.useEffect)(()=>{let e=`${x}#${G}`;G&&K.current!==e&&document.getElementById(G)&&(K.current=e,requestAnimationFrame(()=>Xt(G,!1)))},[x,G,s?.id,u.spaceSections]),!x){let t=o.slice(1),n=t?Re(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(v,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(v,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&u.status!==`ready`)return null;if(e!==void 0||!d)return(0,Q.jsx)(v,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(x===`knowledge`&&!w&&u.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(v,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let q=e=>{if(d){r({search:`?show=${e}`});return}K.current=`${x}#${e}`,Xt(e,!0),r({search:``,hash:e},{replace:!0})},J=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Te=e=>e.flatMap(e=>e.sections).map(e=>u.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(R,{id:e.id,children:(0,Q.jsx)(z,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Ue,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),Ee=d?void 0:oe;return(0,Q.jsx)(Je.Provider,{value:k,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,Q.jsxs)(`aside`,{className:b(`min-w-0 md:sticky md:top-6 md:self-start`,d&&T===2&&`hidden`,d&&O===`back`&&We(`back`)),children:[(0,Q.jsx)(qe,{title:A,open:E===1?C??null:null,onBack:()=>d?r(`/space`):y(x??null)}),(0,Q.jsx)(`div`,{className:b(We(D)),children:E===0?(0,Q.jsx)(Ye,{entries:S,current:d?void 0:C,onPick:()=>y(null)}):(0,Q.jsx)(`div`,{ref:p})},E)]}),x?(0,Q.jsxs)(`div`,{className:b(`min-w-0`,d&&T<2&&`hidden`,d&&O===`deeper`&&We(`deeper`)),children:[d?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Ze,{label:C?.label??A,onBack:()=>r(`/space/${x}`)})}):null,l&&s?(0,Q.jsx)(`div`,{className:`mb-6`,children:(0,Q.jsx)(Jt,{project:s})}):null,x===`results`?(0,Q.jsxs)(Xe,{children:[(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(X,{icon:nt,label:_(`space.resultsAll`),selected:!d&&!N,onPick:()=>J(`all`)}),P.data?.wizards.filter(e=>e.results||e.id===N).map(e=>(0,Q.jsx)(X,{icon:a,label:e.title,badge:e.results?(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===N,onPick:()=>J(e.id)},e.id))]}),(0,Q.jsx)($,{groups:M,current:Ee,onPick:q})]}):x===`data`?(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(X,{icon:le,label:_(`data.all`),selected:!d&&!I,onPick:()=>J(`all`)})}),V.data?Se(V.data).map(e=>(0,Q.jsx)(Ke,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(X,{icon:fe[e.kind],label:e.title,selected:!d&&e.key===I,onPick:()=>J(e.key)},e.key))},e.key)):null,(0,Q.jsx)($,{groups:M,current:Ee,onPick:q})]}):x===`knowledge`?(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(X,{icon:le,label:_(`know.all`),selected:!(d||I),onPick:()=>J(`all`)})}),H.data?.categories.length?(0,Q.jsx)(Ke,{label:_(`know.categories`),children:H.data.categories.map(e=>(0,Q.jsx)(X,{icon:ge[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!d&&(I===`c:${e.id}`||U.data?.category.id===e.id),onPick:()=>J(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)($,{groups:M,current:d?void 0:L?.id,onPick:e=>J(`s:${e}`)})]}):(0,Q.jsx)(Xe,{children:(0,Q.jsx)($,{groups:j,current:Ee,onPick:q})}),s&&(x===`info`||x===`knowledge`)?(0,Q.jsxs)(Ht,{project:s,group:x,docked:x===`knowledge`&&!!I&&!L,children:[x===`knowledge`?B?B.startsWith(`p:`)?(0,Q.jsx)(ve,{pageId:B.slice(2),onGone:()=>J(`all`),onOpen:J},B):B.startsWith(`t:`)?(0,Q.jsx)(_e,{tableId:B.slice(2),onGone:()=>J(`all`)},B):(0,Q.jsx)(xt,{projectId:s.id,fileId:B.slice(2),readOnly:s.readOnly,onGone:()=>J(`all`)},B):H.data?L?(0,Q.jsx)(z,{title:L.label(),hint:L.hint?.(),plain:!0,children:(0,Q.jsx)(Ue,{of:L,children:(0,Q.jsx)(L.component,{})})},I):I?.startsWith(`c:`)?W?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(he,{projectId:s.id,category:W,readOnly:s.readOnly,onOpen:J,onGone:()=>J(`all`)}),W.type===`choice`?null:(0,Q.jsx)(Ce,{projectId:s.id,category:W,categories:H.data.categories,onOpen:J})]},I):null:I?.startsWith(`v:`)?U.data?(0,Q.jsx)(de,{value:U.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[U.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:U.data.items.map(e=>(0,Q.jsx)(me,{item:e,categories:H.data.categories.filter(e=>e.id!==U.data?.category.id),onOpen:J},e.key))}):null,U.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>J(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:_(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},I):null:(0,Q.jsx)(R,{id:`documents`,children:(0,Q.jsx)(xe,{projectId:s.id,data:H.data,readOnly:s.readOnly,onOpen:J})}):null:null,x===`info`?Te(M):null]},s.id):null,s&&x===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:I?.startsWith(`t:`)?(0,Q.jsx)(_e,{tableId:I.slice(2),onGone:()=>J(`all`)},I):I?.startsWith(`p:`)?(0,Q.jsx)(ve,{pageId:I.slice(2),onGone:()=>J(`all`)},I):(0,Q.jsxs)(Q.Fragment,{children:[V.data?(0,Q.jsx)(be,{projectId:s.id,data:V.data,readOnly:s.readOnly,onOpen:J}):null,Te(M)]})}):null,s&&x===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[P.data?(0,Q.jsx)(Kt,{data:P.data,wizardId:N,filter:se,onFilter:ce}):null,P.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:P.error.message}):null,Te(M)]}):null,s||c?null:(0,Q.jsx)(ee,{children:_(`settings.noProject`)})]}):null]})})})}export{Zt as ProjectPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{r}from"./logo-C80CWCDM.js";import{A as i,C as a,D as o,I as s,J as c,P as l,Q as u,_ as d,f,nt as p,o as m,rt as h,t as g,w as _}from"./ui-D92EkdEB.js";import{t as ee}from"./RunnerView-CLrGb-oq.js";import{t as v}from"./arrow-right-Dpp_mpHe.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./ChatView-DBl0iRMg.js";import{E,N as te,O as D,k as O}from"./definition-CQGiBQ4X.js";import{A as ne,E as k,k as A}from"./index-CIO9W4pe.js";var j={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};j.node;var M=c(j),N={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};N.node;var P=c(N),F={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};F.node;var I=c(F),L=e(t(),1);function R(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=R(),B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),re=()=>B(`close`);function ie(e){(0,L.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var V=e(n(),1);function H(e){(0,L.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function U(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=i(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var W=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,G=W||/Android/.test(navigator.userAgent);function K(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||G&&!e&&!W)return null;let i=/Mac/.test(navigator.platform),a=l(G?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,V.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{G&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[G?(0,V.jsx)(I,{className:`size-4`}):(0,V.jsx)(M,{className:`size-4`}),l(G?`install.add`:`install.bookmark`)]}),n?(0,V.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function q({brand:e,toggle:t=!0}){return(0,V.jsx)(`header`,{className:`safe-top`,children:(0,V.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,V.jsx)(`img`,{src:i(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,V.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,V.jsx)(`div`,{className:`absolute right-3`,children:(0,V.jsx)(O,{})}):null]})})}function J({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,V.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ae({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||k||z?null:(0,V.jsxs)(`a`,{href:A(`${window.location.origin}${o}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,V.jsx)(P,{className:`size-4`}),` `,l(`install.app`)]})}var Y=e=>`wz.run.${e}`,X=k&&new URLSearchParams(window.location.search).get(`start`)===`1`,Z=z===`inline`?`min-h-80`:`min-h-dvh`;function Q(e,t){let n=p(),[r,i]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(()=>{try{return localStorage.getItem(Y(e.token))}catch{return null}})();return{busy:r,error:o,captcha:c,setCaptcha:l,start:async()=>{i(!0),s(null);try{let{runId:r}=await a.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null});try{localStorage.setItem(Y(e.token),r)}catch{}n(`${t}/${r}`,{replace:X})}catch(e){s(e.message),i(!1)}},resume:u?()=>n(`${t}/${u}`):null}}function oe({wizard:e}){let{busy:t,error:n,captcha:r,setCaptcha:i,start:a,resume:o}=Q(e,`/w/${e.token}`),s=X&&e.available&&!e.turnstileSiteKey,c=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{s&&!c.current&&(c.current=!0,a())},[s]),s&&!n?(0,V.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,V.jsx)(f,{})}):(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,V.jsx)(D,{kind:e.avatar,size:190,fluffy:!0}),(0,V.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,V.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(g,{size:`lg`,className:`mt-10 min-w-48`,busy:t,disabled:!!e.turnstileSiteKey&&!r,onClick:a,children:[l(`run.start`),` `,(0,V.jsx)(v,{className:`size-4`})]}),e.turnstileSiteKey?(0,V.jsx)(J,{siteKey:e.turnstileSiteKey,onToken:i}):null,o?(0,V.jsx)(`button`,{type:`button`,onClick:o,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:l(`run.resume`)}):null,(0,V.jsx)($,{wizard:e,current:`steps`}),z||k?null:(0,V.jsx)(K,{}),(0,V.jsx)(ae,{token:e.token})]}):(0,V.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??l(`run.unavailable`)}),n?(0,V.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n}):null]})}function $({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,V.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,V.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:l(`run.orAs`,{label:e.label})},e.id))}):null}function se({wizard:e}){let t=w();return(0,V.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,V.jsx)(`span`,{className:d(t?.speaking&&`animate-breathe`),children:(0,V.jsx)(D,{kind:e.avatar,size:38})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,V.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null]}),e.brand.logoUrl&&z!==`popout`?(0,V.jsx)(`img`,{src:i(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,z?null:(0,V.jsx)(O,{}),z===`popout`?(0,V.jsx)(m,{label:l(`common.close`),onClick:re,children:(0,V.jsx)(s,{className:`size-5`})}):null]})})}function ce({door:e,wizard:t,header:n,footer:r}){let{busy:i,error:a,captcha:o,setCaptcha:s,start:c,resume:u}=Q(t,`/w/${t.token}/${e}`),d=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&d.push({key:e,who:`bot`,node:l(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||d.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??l(`run.unavailable`)}),a&&d.push({key:`error`,who:`bot`,node:a,tone:`error`}),t.available&&d.push(S(`start`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(b,{primary:!0,busy:i,disabled:!!t.turnstileSiteKey&&!o,onClick:()=>void c(),children:[l(`run.start`),` `,(0,V.jsx)(v,{className:`size-4`})]}),u?(0,V.jsx)(b,{onClick:u,children:l(`run.resume`)}):null,t.turnstileSiteKey?(0,V.jsx)(J,{siteKey:t.turnstileSiteKey,onToken:s}):null]}))),(0,V.jsxs)(x,{header:n,footer:r,children:[(0,V.jsx)(y,{avatar:t.avatar,lines:d}),(0,V.jsx)(C,{})]})}function le({className:e}){return(0,V.jsx)(`footer`,{className:d(`text-center text-ink-4`,e),children:(0,V.jsx)(`a`,{href:`${o}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:l(`run.madeWith`).replace(`engenty wizards`,E.name)})})}function ue({chat:e=!1,steps:t=!1,talk:n=!1,video:i=!1}){let{token:s,runId:c}=h(),m=p(),v=r({queryKey:[`public`,s],queryFn:()=>a.get(`/api/public/wizards/${s}`),retry:(e,t)=>_(t)&&e<3}),y=v.data?.runners??[],b=!v.data||y.some(e=>e.id===`talk`),x=!v.data||y.some(e=>e.id===`video`),S=!v.data||y.some(e=>e.id===`chat`)||n&&b||i&&x,C=y[0]?.id,w=e||z===`popout`||!t&&!c&&S&&(C===`chat`||C===`talk`||C===`video`),O=i&&x||!t&&!e&&!n&&C===`video`,A=!O&&(n&&b||!t&&!e&&C===`talk`),j=O?`video`:A?`talk`:`chat`;if(H(v.data?.brand.accent),te(v.data?.avatar),U(s,v.data?.title),ie(w),(0,L.useEffect)(()=>{v.data&&(document.title=v.data.title)},[v.data]),(0,L.useEffect)(()=>{s&&c&&ne(`run`,{token:s,runId:c})},[s,c]),v.isLoading)return(0,V.jsx)(`div`,{className:d(`flex items-center justify-center text-ink-4`,Z),children:(0,V.jsx)(f,{})});if(e&&v.data&&!S||n&&v.data&&!b||i&&v.data&&!x)return(0,V.jsx)(u,{to:`/w/${s}`,replace:!0});if(!v.data){let e=_(v.error);return(0,V.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Z),children:[(0,V.jsx)(D,{kind:`pebble`,size:80}),(0,V.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:l(e?`common.offline`:`run.notFound`)}),e?(0,V.jsx)(g,{variant:`secondary`,onClick:()=>void v.refetch(),children:l(`common.retry`)}):null]})}if(w){let e=(0,V.jsx)(se,{wizard:v.data}),t=k?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(le,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,V.jsx)(`div`,{className:`flex h-dvh flex-col`,children:c?(0,V.jsx)(T,{runId:c,talk:A,call:O?`video`:A?`audio`:!1,onRestart:()=>m(`/w/${s}/${j}`),header:O||A?void 0:e,footer:t}):(0,V.jsx)(ce,{wizard:v.data,header:e,footer:t,door:j})})}return(0,V.jsxs)(`div`,{className:d(`flex flex-col`,Z),children:[z===`inline`||k?null:(0,V.jsx)(q,{brand:v.data.brand,toggle:!z}),(0,V.jsx)(`div`,{className:`flex-1`,children:c?(0,V.jsx)(ee,{runId:c,onRestart:()=>m(`/w/${s}`)}):(0,V.jsx)(oe,{wizard:v.data})}),k?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,V.jsx)(`a`,{href:`${o}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:l(`run.madeWith`).replace(`engenty wizards`,E.name)})})]})}export{q as BrandHeader,ue as PublicRunner,H as useBrandAccent};
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{r}from"./logo-C80CWCDM.js";import{A as i,C as a,D as o,I as s,J as c,P as l,Q as u,_ as d,f,nt as p,o as m,rt as h,t as g,w as _}from"./ui-D92EkdEB.js";import{t as ee}from"./RunnerView-Bmayop7s.js";import{t as v}from"./arrow-right-Dpp_mpHe.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./ChatView-Dm764bYy.js";import{E,N as te,O as D,k as O}from"./definition-CQGiBQ4X.js";import{A as ne,E as k,k as A}from"./index-Cz6c1S5g.js";var j={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};j.node;var M=c(j),N={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};N.node;var P=c(N),F={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};F.node;var I=c(F),L=e(t(),1);function R(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=R(),B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),re=()=>B(`close`);function ie(e){(0,L.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var V=e(n(),1);function H(e){(0,L.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function U(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=i(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var W=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,G=W||/Android/.test(navigator.userAgent);function K(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||G&&!e&&!W)return null;let i=/Mac/.test(navigator.platform),a=l(G?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,V.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{G&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[G?(0,V.jsx)(I,{className:`size-4`}):(0,V.jsx)(M,{className:`size-4`}),l(G?`install.add`:`install.bookmark`)]}),n?(0,V.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function q({brand:e,toggle:t=!0}){return(0,V.jsx)(`header`,{className:`safe-top`,children:(0,V.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,V.jsx)(`img`,{src:i(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,V.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,V.jsx)(`div`,{className:`absolute right-3`,children:(0,V.jsx)(O,{})}):null]})})}function J({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,V.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ae({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||k||z?null:(0,V.jsxs)(`a`,{href:A(`${window.location.origin}${o}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,V.jsx)(P,{className:`size-4`}),` `,l(`install.app`)]})}var Y=e=>`wz.run.${e}`,X=k&&new URLSearchParams(window.location.search).get(`start`)===`1`,Z=z===`inline`?`min-h-80`:`min-h-dvh`;function Q(e,t){let n=p(),[r,i]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(()=>{try{return localStorage.getItem(Y(e.token))}catch{return null}})();return{busy:r,error:o,captcha:c,setCaptcha:l,start:async()=>{i(!0),s(null);try{let{runId:r}=await a.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null});try{localStorage.setItem(Y(e.token),r)}catch{}n(`${t}/${r}`,{replace:X})}catch(e){s(e.message),i(!1)}},resume:u?()=>n(`${t}/${u}`):null}}function oe({wizard:e}){let{busy:t,error:n,captcha:r,setCaptcha:i,start:a,resume:o}=Q(e,`/w/${e.token}`),s=X&&e.available&&!e.turnstileSiteKey,c=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{s&&!c.current&&(c.current=!0,a())},[s]),s&&!n?(0,V.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,V.jsx)(f,{})}):(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,V.jsx)(D,{kind:e.avatar,size:190,fluffy:!0}),(0,V.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,V.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(g,{size:`lg`,className:`mt-10 min-w-48`,busy:t,disabled:!!e.turnstileSiteKey&&!r,onClick:a,children:[l(`run.start`),` `,(0,V.jsx)(v,{className:`size-4`})]}),e.turnstileSiteKey?(0,V.jsx)(J,{siteKey:e.turnstileSiteKey,onToken:i}):null,o?(0,V.jsx)(`button`,{type:`button`,onClick:o,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:l(`run.resume`)}):null,(0,V.jsx)($,{wizard:e,current:`steps`}),z||k?null:(0,V.jsx)(K,{}),(0,V.jsx)(ae,{token:e.token})]}):(0,V.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??l(`run.unavailable`)}),n?(0,V.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n}):null]})}function $({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,V.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,V.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:l(`run.orAs`,{label:e.label})},e.id))}):null}function se({wizard:e}){let t=w();return(0,V.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,V.jsx)(`span`,{className:d(t?.speaking&&`animate-breathe`),children:(0,V.jsx)(D,{kind:e.avatar,size:38})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,V.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null]}),e.brand.logoUrl&&z!==`popout`?(0,V.jsx)(`img`,{src:i(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,z?null:(0,V.jsx)(O,{}),z===`popout`?(0,V.jsx)(m,{label:l(`common.close`),onClick:re,children:(0,V.jsx)(s,{className:`size-5`})}):null]})})}function ce({door:e,wizard:t,header:n,footer:r}){let{busy:i,error:a,captcha:o,setCaptcha:s,start:c,resume:u}=Q(t,`/w/${t.token}/${e}`),d=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&d.push({key:e,who:`bot`,node:l(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||d.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??l(`run.unavailable`)}),a&&d.push({key:`error`,who:`bot`,node:a,tone:`error`}),t.available&&d.push(S(`start`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(b,{primary:!0,busy:i,disabled:!!t.turnstileSiteKey&&!o,onClick:()=>void c(),children:[l(`run.start`),` `,(0,V.jsx)(v,{className:`size-4`})]}),u?(0,V.jsx)(b,{onClick:u,children:l(`run.resume`)}):null,t.turnstileSiteKey?(0,V.jsx)(J,{siteKey:t.turnstileSiteKey,onToken:s}):null]}))),(0,V.jsxs)(x,{header:n,footer:r,children:[(0,V.jsx)(y,{avatar:t.avatar,lines:d}),(0,V.jsx)(C,{})]})}function le({className:e}){return(0,V.jsx)(`footer`,{className:d(`text-center text-ink-4`,e),children:(0,V.jsx)(`a`,{href:`${o}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:l(`run.madeWith`).replace(`engenty wizards`,E.name)})})}function ue({chat:e=!1,steps:t=!1,talk:n=!1,video:i=!1}){let{token:s,runId:c}=h(),m=p(),v=r({queryKey:[`public`,s],queryFn:()=>a.get(`/api/public/wizards/${s}`),retry:(e,t)=>_(t)&&e<3}),y=v.data?.runners??[],b=!v.data||y.some(e=>e.id===`talk`),x=!v.data||y.some(e=>e.id===`video`),S=!v.data||y.some(e=>e.id===`chat`)||n&&b||i&&x,C=y[0]?.id,w=e||z===`popout`||!t&&!c&&S&&(C===`chat`||C===`talk`||C===`video`),O=i&&x||!t&&!e&&!n&&C===`video`,A=!O&&(n&&b||!t&&!e&&C===`talk`),j=O?`video`:A?`talk`:`chat`;if(H(v.data?.brand.accent),te(v.data?.avatar),U(s,v.data?.title),ie(w),(0,L.useEffect)(()=>{v.data&&(document.title=v.data.title)},[v.data]),(0,L.useEffect)(()=>{s&&c&&ne(`run`,{token:s,runId:c})},[s,c]),v.isLoading)return(0,V.jsx)(`div`,{className:d(`flex items-center justify-center text-ink-4`,Z),children:(0,V.jsx)(f,{})});if(e&&v.data&&!S||n&&v.data&&!b||i&&v.data&&!x)return(0,V.jsx)(u,{to:`/w/${s}`,replace:!0});if(!v.data){let e=_(v.error);return(0,V.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Z),children:[(0,V.jsx)(D,{kind:`pebble`,size:80}),(0,V.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:l(e?`common.offline`:`run.notFound`)}),e?(0,V.jsx)(g,{variant:`secondary`,onClick:()=>void v.refetch(),children:l(`common.retry`)}):null]})}if(w){let e=(0,V.jsx)(se,{wizard:v.data}),t=k?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(le,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,V.jsx)(`div`,{className:`flex h-dvh flex-col`,children:c?(0,V.jsx)(T,{runId:c,talk:A,call:O?`video`:A?`audio`:!1,onRestart:()=>m(`/w/${s}/${j}`),header:O||A?void 0:e,footer:t}):(0,V.jsx)(ce,{wizard:v.data,header:e,footer:t,door:j})})}return(0,V.jsxs)(`div`,{className:d(`flex flex-col`,Z),children:[z===`inline`||k?null:(0,V.jsx)(q,{brand:v.data.brand,toggle:!z}),(0,V.jsx)(`div`,{className:`flex-1`,children:c?(0,V.jsx)(ee,{runId:c,onRestart:()=>m(`/w/${s}`)}):(0,V.jsx)(oe,{wizard:v.data})}),k?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,V.jsx)(`a`,{href:`${o}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:l(`run.madeWith`).replace(`engenty wizards`,E.name)})})]})}export{q as BrandHeader,ue as PublicRunner,H as useBrandAccent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,r as i}from"./logo-C80CWCDM.js";import{l as a,u as o}from"./Marketplace-BWhUJ4UX.js";import{t as s}from"./useMutation-DKcIz55V.js";import{C as c,G as l,H as u,I as d,J as f,M as p,P as m,R as h,S as g,W as _,_ as v,a as y,c as b,d as x,f as S,g as C,i as w,m as T,n as E,o as D,r as O,s as k,t as A,u as j,z as M}from"./ui-D92EkdEB.js";import{b as N,g as P,h as ee,p as te,v as F,y as ne}from"./HomePage-
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,r as i}from"./logo-C80CWCDM.js";import{l as a,u as o}from"./Marketplace-BWhUJ4UX.js";import{t as s}from"./useMutation-DKcIz55V.js";import{C as c,G as l,H as u,I as d,J as f,M as p,P as m,R as h,S as g,W as _,_ as v,a as y,c as b,d as x,f as S,g as C,i as w,m as T,n as E,o as D,r as O,s as k,t as A,u as j,z as M}from"./ui-D92EkdEB.js";import{b as N,g as P,h as ee,p as te,v as F,y as ne}from"./HomePage-BXSg5P5k.js";import{a as I}from"./volume-2-0SfkvOho.js";import{t as L}from"./trash-DU-hZpV0.js";import"./definition-CQGiBQ4X.js";import{t as re}from"./refresh-cw-Cli5WGnW.js";import{t as ie}from"./upload-DMq5N6Fw.js";import{B as ae,m as oe}from"./index-Cz6c1S5g.js";var se={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};se.node;var ce=f(se),le={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};le.node;var ue=f(le),de={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};de.node;var fe=f(de),R={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};R.node;var pe=f(R),z={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};z.node;var B=f(z),V={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};V.node;var me=f(V),he={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};he.node;var ge=f(he),_e={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};_e.node;var H=f(_e),U=e(t(),1),W=e(n(),1),G={choice:ge,date:ce,number:fe,text:a,boolean:H},K=e=>[`knowledge`,e];function ve(e){return e===1?m(`know.item`):m(`know.items`,{n:e})}function q(e,t){if(e.type===`boolean`||typeof t==`boolean`)return m(t?`know.yes`:`know.no`);if(e.type===`date`&&typeof t==`string`){let[e,n]=t.split(` `),r=new Date(`${e}T00:00:00`),i=Number.isNaN(r.getTime())?t:r.toLocaleDateString(p,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(p)}${e.unit?` ${e.unit}`:``}`:String(t)}function ye(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>q(e,t)).join(`, `)]:[]}).join(` · `)}function be({trigger:e,open:t,onOpen:n,children:r}){let i=(0,U.useRef)(null);return(0,U.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,W.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,W.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function xe({category:e,current:t,onSave:n}){let[r,i]=(0,U.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let a=t.map(String);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,W.jsx)(j,{multi:!0,value:a,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!a.includes(e)).slice(0,1))}):null,(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...a,r.trim()]:[r.trim()])},children:[(0,W.jsx)(k,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:m(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(D,{label:m(`know.addValue`),type:`submit`,children:(0,W.jsx)(h,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,W.jsx)(j,{value:t[0]===!0?m(`know.yes`):t[0]===!1?m(`know.no`):``,options:[m(`know.yes`),m(`know.no`)],onChange:e=>n([e===m(`know.yes`)])}):(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,W.jsx)(k,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>i(e.target.value),className:`h-9`}),(0,W.jsx)(A,{type:`submit`,size:`sm`,children:`OK`})]})}function Se({projectId:e,itemKey:t,has:n,categories:i,readOnly:a}){let o=r(),[l,u]=(0,U.useState)(null),[f,p]=(0,U.useState)(n);(0,U.useEffect)(()=>p(n),[n]);let g=s({mutationFn:({categoryId:n,next:r})=>c.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>o.invalidateQueries({queryKey:K(e)})}),_=i.filter(e=>!(e.proposed||e.tableId)),v=(e,t)=>{p(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),g.mutate({categoryId:e.id,next:t}),u(null)},y=_.filter(e=>f.some(t=>t.categoryId===e.id)),b=_.filter(e=>!f.some(t=>t.categoryId===e.id));return _.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[y.map(e=>{let t=f.find(t=>t.categoryId===e.id),n=G[e.type],r=(0,W.jsxs)(`button`,{type:`button`,disabled:a,title:`${e.name} · ${m(`know.by.${t.by}`)}`,onClick:()=>u(l===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,W.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,W.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,W.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>q(e,t)).join(`, `)})]},e.id);return a?(0,W.jsx)(`span`,{children:r},e.id):(0,W.jsxs)(be,{trigger:r,open:l===e.id,onOpen:t=>u(t?e.id:null),children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,W.jsx)(D,{label:m(`know.remove`),onClick:()=>v(e,[]),className:`size-7`,children:(0,W.jsx)(d,{className:`size-3.5`})})]}),(0,W.jsx)(xe,{category:e,current:t.values,onSave:t=>v(e,t)})]},e.id)}),a||!b.length?null:(0,W.jsx)(be,{open:l===`+`,onOpen:e=>u(e?`+`:null),trigger:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,W.jsx)(h,{className:`size-3.5`}),` `,m(`know.category`)]}),children:(0,W.jsx)(Ce,{categories:b,onSave:v})})]}):null}function Ce({categories:e,onSave:t}){let[n,r]=(0,U.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,W.jsx)(x,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,W.jsx)(xe,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function we({projectId:e,open:t,onClose:n,onMade:i}){let a=r(),[o,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(`choice`),[f,p]=(0,U.useState)(``),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),[y,S]=(0,U.useState)(``),[E,D]=(0,U.useState)(``),O=s({mutationFn:()=>c.post(`/api/studio/projects/${e}/categories`,{name:o.trim(),type:u,unit:u===`number`&&f.trim()||null,multiple:u===`choice`&&h,ordered:u===`choice`&&_,hint:E.trim()||null,values:u===`choice`?y.split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:K(e)}),l(``),S(``),D(``),i(t)}});return(0,W.jsx)(w,{open:t,onClose:n,title:m(`know.newCategory`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&O.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`know.name`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:o,maxLength:80,onChange:e=>l(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`know.type`)}),(0,W.jsx)(x,{value:u,onChange:e=>d(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:m(`know.type.${e}`)}))})]}),u===`number`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{hint:m(`know.unitHint`),children:m(`know.unit`)}),(0,W.jsx)(k,{value:f,maxLength:20,onChange:e=>p(e.target.value)})]}):null,u===`choice`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{hint:m(`know.valuesHint`),children:m(`know.values`)}),(0,W.jsx)(C,{minRows:3,value:y,onChange:e=>S(e.target.value)})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[m(`know.multiple`),(0,W.jsx)(T,{checked:h,onChange:g})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[m(`know.ordered`),(0,W.jsx)(T,{checked:_,onChange:v})]})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{hint:m(`know.hintFieldHint`),children:m(`know.hintField`)}),(0,W.jsx)(k,{value:E,maxLength:120,onChange:e=>D(e.target.value)})]}),O.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:O.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,onClick:n,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:O.isPending,disabled:!o.trim(),children:m(`know.create`)})]})]})})}function Te({projectId:e,category:t,readOnly:n,onOpen:i,onGone:a}){let o=r(),l=()=>o.invalidateQueries({queryKey:K(e)}),[u,d]=(0,U.useState)(``),f=s({mutationFn:e=>e(),onSuccess:l}),p=G[t.type],g=new Map(t.values.map(e=>[e.id,e]));return(0,W.jsxs)(P,{title:t.name,hint:[m(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,W.jsx)(D,{label:m(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(m(`know.confirmCategory`,{name:t.name}))&&f.mutate(async()=>{await c.del(`/api/studio/categories/${t.id}`),a()}),children:(0,W.jsx)(L,{className:`size-4`})}),children:[t.proposed&&!n?(0,W.jsxs)(E,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(O,{tone:`ember`,children:m(`know.proposed`)}),(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:m(`know.proposedHint`)}),(0,W.jsx)(A,{size:`sm`,onClick:()=>f.mutate(()=>c.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:m(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=g.get(e),i=g.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,W.jsxs)(E,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:m(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,W.jsx)(A,{size:`sm`,variant:`secondary`,busy:f.isPending,onClick:()=>f.mutate(()=>c.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:m(`know.merge`)})]},`${e}:${t}`)}),(0,W.jsxs)(E,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,W.jsx)(O,{children:m(`know.summary`)}):null,(0,W.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:ve(e.count)})]},e.id)):(0,W.jsx)(y,{children:m(`know.empty`)}):(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,W.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?m(`know.range`,{min:q(t,t.range.min),max:q(t,t.range.max)}):m(`know.unset`)}),(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:ve(t.count)})]}),t.type===`choice`&&!n?(0,W.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=u.trim();n&&(d(``),f.mutate(()=>c.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,W.jsx)(k,{value:u,placeholder:m(`know.addValue`),onChange:e=>d(e.target.value),className:`h-9`}),(0,W.jsx)(D,{label:m(`know.addValue`),type:`submit`,children:(0,W.jsx)(h,{className:`size-4`})})]}):null]}),f.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null]})}function Ee(e){return i({queryKey:[`knowledge-value`,e],queryFn:()=>c.get(`/api/studio/values/${e}`),enabled:!!e})}function De({value:e,readOnly:t,children:n}){let i=r(),a=s({mutationFn:()=>c.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>i.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,W.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,W.jsx)(P,{title:m(`know.summary`),hint:m(`know.summaryHint`),plain:!0,action:t?null:(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,busy:a.isPending,onClick:()=>a.mutate(),children:[e.summary?(0,W.jsx)(re,{className:`size-4`}):null,e.summary?m(`know.summaryAgain`):m(`know.summaryWrite`)]}),children:(0,W.jsxs)(E,{className:`p-4 sm:p-5`,children:[a.isPending?(0,W.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,W.jsx)(S,{})}):e.summary?(0,W.jsx)(oe,{text:e.summary,className:`text-[0.875rem]`}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:m(`know.summaryEmpty`)}),a.error?(0,W.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error.message}):null]})}),(0,W.jsx)(P,{title:m(`know.toc`),plain:!0,children:n})]})}function Oe(e){return i({queryKey:[`knowledge`,e],queryFn:()=>c.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function ke(e){return e.kind===`table`?e.format===`faq`?B:o:e.kind===`file`?M:e.children?ue:I}function J({item:e,categories:t,onOpen:n}){let r=ke(e),i=[ye(t,e.categories),e.children?e.children===1?m(`know.oneSub`):m(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?m(`know.row`):m(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,W.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,W.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,W.jsx)(S,{className:`size-3`}),` `,m(`know.reading`)]}):e.review?(0,W.jsx)(O,{tone:`warn`,title:e.review,children:m(`know.review`)}):null]})}function Y({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:o,readOnly:s,onReviewed:c}){let l=Oe(e),u=[r?m(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[l.data?(0,W.jsx)(Se,{projectId:e,itemKey:t,has:n,categories:l.data.categories,readOnly:s}):null,u.length||o||a?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[u.map(e=>(0,W.jsx)(`span`,{children:e},e)),o?(0,W.jsxs)(`a`,{href:F(e,o.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,W.jsx)(M,{className:`size-3.5`}),` `,m(`know.original`),`: `,o.name]}):null,a?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,W.jsx)(O,{tone:`warn`,children:m(`know.review`)}),(0,W.jsx)(`span`,{children:a}),s?null:(0,W.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:m(`know.reviewed`)})]}):null]}):null]})}function Ae(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(new Set(t).size<=4)return[];let n=t[0],r=t.at(-1),i=e=>e.slice(0,-1).map((t,n)=>({lo:t,hi:e[n+1]})).filter(e=>t.some(t=>t>=e.lo&&t<e.hi));if(n>0&&r/n>=30){let e=Math.floor(Math.log10(n)),t=Math.floor(Math.log10(r))+1;for(let a of[[1,2,5],[1,3],[1]]){let o=[];for(let n=e;n<=t;n++)for(let e of a)o.push(e*10**n);let s=i(o.filter((e,t)=>e<=n||o[t-1]<=r));if(s.length<=7)return s}}let a=(r-n)/5,o=10**Math.floor(Math.log10(a)),s=([1,2,2.5,5,10].map(e=>e*o).find(e=>e>=a)??a)||1,c=[];for(let e=Math.floor(n/s)*s;e<=r;e+=s)c.push(e);return c.push(c.at(-1)+s),i(c)}function je({projectId:e,category:t,categories:n,onOpen:r}){let a=i({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>c.get(`/api/studio/categories/${t.id}/items`)});if(!a.data)return a.isLoading?(0,W.jsx)(S,{className:`mx-auto size-4 text-ink-3`}):null;let o=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],s=[...a.data.items].sort((e,t)=>{let n=o(e),r=o(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),p)}),l=t.type===`number`?Ae(s.map(o).filter(e=>typeof e==`number`)):[],u=new Intl.NumberFormat(p,{notation:`compact`,maximumFractionDigits:1}),d=t.unit?` ${t.unit}`:``,f=new Map;for(let e of s){let n=o(e),r=typeof n==`number`?l.find(e=>n>=e.lo&&n<e.hi):void 0,i=n===void 0?``:t.type===`date`?new Date(`${String(n).slice(0,7)}-01T00:00:00`).toLocaleDateString(p,{month:`long`,year:`numeric`}):r?m(`know.range`,{min:`${u.format(r.lo)}${d}`,max:`${u.format(r.hi)}${d}`}):q(t,n);f.set(i,[...f.get(i)??[],e])}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...f].map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,W.jsx)(J,{item:e,categories:n,onOpen:r},e.key))})]},e)),a.data.rows.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:m(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function Me(e,t,n){return Array.isArray(n)?t.some(e=>n.map(String).includes(String(e))):typeof n==`object`&&n?t.some(t=>{if(e.type===`number`&&typeof t==`number`)return(n.gte===void 0||t>=n.gte)&&(n.lte===void 0||t<=n.lte);if(e.type===`date`){let e=String(t).slice(0,10);return(!n.after||e>=n.after)&&(!n.before||e<=n.before)}return!n.contains||String(t).toLowerCase().includes(n.contains.toLowerCase())}):t.some(e=>e===n)}function Ne(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return m(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${m(`know.contains`)} ${t.contains}`:[n===void 0?``:`${m(`know.minimum`)} ${q(e,n)}`,r===void 0?``:`${m(`know.maximum`)} ${q(e,r)}`].filter(Boolean).join(` `)}return String(t)}function Pe({category:e,value:t,onChange:n}){let[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!r)return;let e=e=>!a.current?.contains(e.target)&&i(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let o=G[e.type],s=typeof t==`object`&&t&&!Array.isArray(t)?t:{},c=(t,r)=>{let i={...s,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,W.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:v(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,W.jsx)(o,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,W.jsxs)(`span`,{className:`font-medium`,children:[`: `,Ne(e,t)]}),(0,W.jsx)(_,{className:`size-3.5 text-ink-3`})]}),r?(0,W.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,W.jsx)(j,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,W.jsx)(j,{value:t===!0?m(`know.yes`):t===!1?m(`know.no`):``,options:[m(`know.yes`),m(`know.no`)],onChange:e=>n(e===m(`know.yes`))}):e.type===`text`?(0,W.jsx)(k,{"data-autofocus":!0,value:s.contains??``,placeholder:m(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(n===0?`know.minimum`:`know.maximum`)}),(0,W.jsx)(k,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(s[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>c(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,W.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),i(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:m(`know.clear`)})]}):null]})}function Fe({found:e,onOpen:t}){return e.hits.length?(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?m(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):m(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,W.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,W.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,W.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,W.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(p,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,W.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:m(`know.searchNone`)})}function Ie({kind:e,projectId:t,onClose:n,onMade:i}){let a=r(),[o,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),f=s({mutationFn:()=>c.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),...e===`table`&&u?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:[`knowledge`,t]}),i(`${e===`table`?`t`:`p`}:${n}`),l(``),d(!1)}});return(0,W.jsx)(w,{open:e!==null,onClose:n,title:m(e===`table`?`know.newTable`:`know.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&f.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.title`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>l(e.target.value)})]}),e===`table`?(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[m(`know.asFaq`),(0,W.jsx)(T,{checked:u,onChange:d})]}):null,f.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,onClick:n,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:f.isPending,disabled:!o.trim(),children:m(`know.create`)})]})]})})}function Le({projectId:e,data:t,readOnly:n,onOpen:i}){let a=r(),o=N(e,n),[l,u]=(0,U.useState)({}),[d,f]=(0,U.useState)(``),[p,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(!1),[b,x]=(0,U.useState)(null),C=t.categories.filter(e=>!e.proposed&&e.count>0),w=t.categories.filter(e=>e.proposed),T=t.items.filter(e=>Object.entries(l).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?Me(i,a.values,r):!1})),D=async()=>{if(!d.trim()){g(null);return}v(!0);try{g(await c.post(`/api/studio/projects/${e}/search`,{query:d,...Object.keys(l).length?{where:l}:{}}))}catch{g({hits:[],candidates:0,checked:!1,filtered:null})}finally{v(!1)}},k=s({mutationFn:({id:e,keep:t})=>t?c.patch(`/api/studio/categories/${e}`,{proposed:!1}):c.del(`/api/studio/categories/${e}`),onSuccess:()=>a.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,W.jsxs)(P,{title:m(`know.title`),hint:m(`know.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>x(`page`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.page`)]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>x(`table`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.table`)]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>x(`category`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.category`)]})]}),children:[w.length&&!n?(0,W.jsx)(E,{className:`flex flex-col gap-2 p-4`,children:w.map(e=>{let t=G[e.type];return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,W.jsx)(O,{tone:`ember`,children:m(`know.proposed`)}),(0,W.jsx)(t,{className:`size-4 text-ink-3`}),(0,W.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[m(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,W.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>k.mutate({id:e.id,keep:!1}),children:m(`know.dismiss`)}),(0,W.jsx)(A,{size:`sm`,onClick:()=>k.mutate({id:e.id,keep:!0}),children:m(`know.accept`)})]},e.id)})}):null,t.items.length?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(ee,{value:d,placeholder:m(`know.search`),busy:_,onEnter:()=>void D(),onChange:e=>{f(e),e.trim()||g(null)}}),C.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[C.map(e=>(0,W.jsx)(Pe,{category:e,value:l[e.name],onChange:t=>{g(null),u(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(l).length?(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:m(`know.clear`)}):null]}):null]}):null,(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:p?(0,W.jsx)(Fe,{found:p,onOpen:i}):T.length?T.map(e=>(0,W.jsx)(J,{item:e,categories:t.categories,onOpen:i},e.key)):(0,W.jsx)(y,{children:m(`know.empty`)})}),n?null:(0,W.jsxs)(te,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await o.upload(`document`,t),await a.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[o.busy?(0,W.jsx)(S,{className:`size-4`}):(0,W.jsx)(ie,{className:`size-4`}),m(`know.drop`),` `,(0,W.jsx)(`span`,{className:`underline`,children:m(`know.pick`)})]}),o.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,W.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:m(`know.keywordsOnly`),t.checked?``:m(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,W.jsx)(Ie,{kind:b===`page`||b===`table`?b:null,projectId:e,onClose:()=>x(null),onMade:e=>{x(null),i(e)}}),(0,W.jsx)(we,{projectId:e,open:b===`category`,onClose:()=>x(null),onMade:e=>{x(null),i(`c:${e}`)}})]})}function Re({page:e,onGone:t,onOpen:n}){let i=r(),[a,o]=(0,U.useState)(e.title),[d,f]=(0,U.useState)(e.markdown),[p,g]=(0,U.useState)(e.markdown?`read`:`write`),_=e.knowledge,y=async()=>{await i.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await i.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},b=ne({title:a.trim()||e.title,markdown:d},async t=>{await c.patch(`/api/studio/pages/${e.id}`,t),i.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await y()}),x=s({mutationFn:()=>c.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await y(),t()}}),C=s({mutationFn:()=>c.post(`/api/studio/projects/${e.projectId}/pages`,{title:m(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await y(),n?.(`p:${e}`)}}),w=s({mutationFn:()=>c.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>i.invalidateQueries({queryKey:[`space-page`,e.id]})}),T=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await c.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},O=e.readOnly,k=_?.file&&(_.file.mime===`application/pdf`||_.file.mime.startsWith(`image/`))?_.file:null,j=(e,t)=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>g(e),className:v(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[_?.parents.length&&n?(0,W.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:_.parents.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,W.jsx)(u,{className:`size-3.5`})]},e.id))}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:a,disabled:O,maxLength:200,onChange:e=>o(e.target.value),"aria-label":m(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),b.state===`saving`?(0,W.jsx)(S,{className:`size-3.5 text-ink-3`}):b.state===`saved`?(0,W.jsx)(l,{className:`size-4 text-moss`,"aria-label":m(`settings.saved`)}):null,O?null:(0,W.jsx)(D,{label:m(`data.deletePage`),onClick:()=>confirm(m(`data.confirmDelete`,{title:e.title}))&&x.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(L,{className:`size-4`})})]}),_?(0,W.jsx)(Y,{projectId:e.projectId,itemKey:`p:${e.id}`,has:_.categories,originLabel:_.originLabel,kept:_.kept,review:_.review,file:k?null:_.file,readOnly:O,onReviewed:()=>w.mutate()}):null,(0,W.jsxs)(E,{className:`flex flex-col`,children:[O&&!k?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[O?null:j(`write`,m(`data.write`)),j(`read`,m(`data.preview`)),k?j(`original`,m(`know.original`)):null,(0,W.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:p===`original`&&k?k.name:m(`data.markdownHint`)})]}),p===`original`&&k?k.mime===`application/pdf`?(0,W.jsx)(`iframe`,{src:F(e.projectId,k.id),title:k.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,W.jsx)(`img`,{src:F(e.projectId,k.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):p===`write`&&!O?(0,W.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),"aria-label":e.title,placeholder:m(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,W.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:T,children:d.trim()?(0,W.jsx)(oe,{text:d}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:m(`data.pageEmpty`)})})]}),b.state===`error`&&b.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:b.error}):null,_&&n&&(_.children.length||!O)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,W.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:_.children.length?m(`know.subPages`):null}),O?null:(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,busy:C.isPending,onClick:()=>C.mutate(),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`know.addSub`)]})]}),_.children.length?(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:_.children.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,W.jsx)(I,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function ze({pageId:e,onGone:t,onOpen:n}){let r=i({queryKey:[`space-page`,e],queryFn:()=>c.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,W.jsx)(Re,{page:r.data,onGone:t,onOpen:n},r.data.id):r.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function Be(e){return i({queryKey:[`space-data`,e],queryFn:()=>c.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function Ve(e){let t=t=>[...e.tables.filter(e=>e.wizardId===t).map(e=>({key:`t:${e.id}`,kind:`table`,title:e.title,rows:e.rows})),...e.pages.filter(e=>e.wizardId===t).map(e=>({key:`p:${e.id}`,kind:`page`,title:e.title}))];return[{key:`own`,label:m(`data.own`),items:t(null)},...e.wizards.map(e=>({key:e.id,label:e.title,items:t(e.id)}))].filter(e=>e.items.length)}var He={table:o,page:I};function Ue({kind:e,projectId:t,data:n,onClose:i,onMade:a}){let o=r(),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(``),p=s({mutationFn:()=>c.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:l.trim(),wizardId:d||null}),onSuccess:async({id:n})=>{await o.invalidateQueries({queryKey:[`space-data`,t]}),a(`${e===`table`?`t`:`p`}:${n}`),u(``),f(``)}});return(0,W.jsx)(w,{open:e!==null,onClose:i,title:m(e===`table`?`data.newTable`:`data.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),l.trim()&&p.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.title`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:l,maxLength:120,onChange:e=>u(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.owner`)}),(0,W.jsx)(x,{value:d,onChange:f,options:[{value:``,label:m(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),p.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:p.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,onClick:i,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:p.isPending,disabled:!l.trim(),children:m(`data.create`)})]})]})})}function We({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,U.useState)(null),o=Ve(t),s=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt])]),c=new Intl.DateTimeFormat(p,{dateStyle:`medium`});return(0,W.jsxs)(P,{title:m(`space.data`),hint:m(`data.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`data.table`)]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`data.page`)]})]}),children:[o.length?(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,W.jsx)(E,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=He[e.kind];return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,W.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${m(`data.rows`,{n:e.rows??0})} · `:``,c.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,W.jsx)(E,{children:(0,W.jsx)(y,{children:m(`data.empty`)})}),(0,W.jsx)(Ue,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function Ge(e,t){let n=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,48)||`column`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}var Ke={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},qe=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Je(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Ke[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}function Ye(e,t){return t.trim()===``?null:e.type===`date`&&e.format.kind===`datetime`?new Date(t).toISOString():t}var X=`w-full min-w-0 rounded-md bg-transparent px-2 py-1.5 text-[0.875rem] outline-none transition placeholder:text-ink-4 hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`;function Xe({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=Je(e,t),[o,s]=(0,U.useState)(a);(0,U.useEffect)(()=>s(a),[a]);let c=(t=o)=>{t!==a&&i(Ye(e,t))};if(e.type===`boolean`)return(0,W.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,W.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>i(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let r=Array.isArray(t)?t:[],a=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-paper-2 py-0.5 pr-1 pl-2 text-[0.75rem]`,children:[a(e),n?null:(0,W.jsx)(`button`,{type:`button`,"aria-label":m(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,W.jsx)(d,{className:`size-3`})})]},e)),n?null:(0,W.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&i([...r,e.target.value]),"aria-label":e.name,className:`h-7 rounded-md bg-transparent px-1 text-[0.75rem] text-ink-3 outline-none hover:bg-accent`,children:[(0,W.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,W.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:X,children:[(0,W.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,W.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>c(),"aria-label":e.name,className:v(X,`field-sizing-content max-h-40 resize-none`)});let l=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,W.jsx)(`input`,{type:l,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&c(t.target.value)},onBlur:()=>e.type!==`date`&&c(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:v(X,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function Ze(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?m(`data.unit.${e.format.inputUnit}`):null}function Qe(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
|
|
3
3
|
`):``,multiple:e?.type===`select`&&!!e.format.multiple}}function $e(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
|
|
4
4
|
`).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??Ge(e,i);return i.push(n),{id:n,label:e}});return{...r,type:`select`,format:{allowCustom:!1,options:a,...e.multiple?{multiple:!0}:{}}}}case`boolean`:return{...r,type:`boolean`};default:return{...r,type:`text`,...e.textStyle===`multiline`?{format:{style:`multiline`}}:{}}}}function et({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,U.useState)(()=>Qe(t)),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&(o(Qe(t)),c(null))},[e,t]);let d=e=>o(t=>({...t,...e})),f=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},p=()=>{let e=t?.id??Ge(a.name,n.map(e=>e.id)),r=$e(a,e,t);return f(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,W.jsx)(w,{open:e,onClose:r,title:t?t.name:m(`data.newColumn`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&p()},children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.columnName`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.columnType`)}),(0,W.jsx)(x,{value:a.type,onChange:e=>d({type:e}),options:qe.map(e=>({value:e,label:m(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,W.jsx)(x,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:m(`data.text.single`)},{value:`multiline`,label:m(`data.text.multiline`)}]}):null,a.type===`number`?(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(x,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:m(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,W.jsx)(k,{value:a.currency,maxLength:3,"aria-label":m(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,W.jsx)(x,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:m(`data.date.${e}`)}))}):null,a.type===`duration`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.unit`)}),(0,W.jsx)(x,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:m(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(b,{children:m(`data.options`)}),(0,W.jsx)(C,{minRows:3,value:a.options,onChange:e=>d({options:e.target.value})})]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(T,{checked:a.multiple,onChange:e=>d({multiple:e})}),m(`data.multiple`)]})]}):null,(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(T,{checked:a.required,onChange:e=>d({required:e})}),m(`data.required`)]}),s?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,W.jsx)(A,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(m(`data.confirmDelete`,{title:t.name}))&&void f(n.filter(e=>e.id!==t.id)),children:m(`data.deleteColumn`)}):null,(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(A,{variant:`ghost`,onClick:r,children:m(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:l,disabled:!a.name.trim(),children:m(`settings.save`)})]})]})})}function tt({tableId:e,onGone:t}){let n=r(),a=[`space-table`,e],o=i({queryKey:a,queryFn:()=>c.get(`/api/studio/tables/${e}`)}),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(null),[p,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(``);(0,U.useEffect)(()=>y(o.data?.title??``),[o.data?.title]);let b=async()=>{await n.invalidateQueries({queryKey:[`space-data`,o.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,o.data?.projectId]})},x=e=>n.setQueryData(a,t=>t&&{...t,rows:e(t.rows)}),S=e=>{f(e.message),o.refetch()},C=async t=>{await c.patch(`/api/studio/tables/${e}`,t),await o.refetch(),await b()},w=s({mutationFn:({row:t,column:n,value:r})=>c.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{f(null),_(e=>e===`${t}:${n}`?null:e),x(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof g&&e.body?.column===n){let e=o.data?.columns.find(e=>e.id===n)?.name??n;_(`${t}:${n}`),f(m(`data.badCell`,{column:e}));return}S(e)}}),T=s({mutationFn:()=>c.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{x(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await b()},onError:S}),O=s({mutationFn:t=>c.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{x(e=>e.filter(e=>e.id!==t)),await b()},onError:S}),k=s({mutationFn:()=>c.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await b(),t()}});if(!o.data)return o.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error.message}):null;let{columns:j,rows:M,readOnly:N}=o.data,P=!!o.data.list;return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:v,disabled:N,maxLength:120,onChange:e=>y(e.target.value),onBlur:()=>v.trim()&&v!==o.data?.title&&void C({title:v}).catch(S),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":m(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),N?null:(0,W.jsx)(D,{label:m(`data.deleteTable`),onClick:()=>confirm(m(`data.confirmDelete`,{title:o.data.title}))&&k.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(L,{className:`size-4`})})]}),P?(0,W.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:m(`data.fromList`)}):null,o.data.knowledge?(0,W.jsx)(Y,{projectId:o.data.projectId,itemKey:`t:${o.data.id}`,has:o.data.knowledge.categories,originLabel:o.data.knowledge.originLabel,kept:o.data.knowledge.kept,review:o.data.knowledge.review,file:o.data.knowledge.file,readOnly:N,onReviewed:()=>void c.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>o.refetch()).catch(S)}):null,(0,W.jsxs)(E,{className:`overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[j.map(e=>(0,W.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,W.jsxs)(`button`,{type:`button`,disabled:N||P,onClick:()=>u(e),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink disabled:hover:bg-transparent`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,W.jsx)(`span`,{className:`text-ember`,children:`*`}):null,Ze(e)?(0,W.jsx)(`span`,{className:`font-normal text-ink-4`,children:Ze(e)}):null]})},e.id)),(0,W.jsx)(`th`,{className:`w-10 p-1`,children:N||P?null:(0,W.jsx)(D,{label:m(`data.newColumn`),onClick:()=>u(`new`),className:`size-8`,children:(0,W.jsx)(h,{className:`size-4`})})})]})}),(0,W.jsx)(`tbody`,{children:M.map(e=>(0,W.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[j.map(t=>(0,W.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,W.jsx)(Xe,{column:t,value:e.cells[t.id],readOnly:N,invalid:p===`${e.id}:${t.id}`,onSave:n=>w.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,W.jsx)(`td`,{className:`w-10 p-1 align-top`,children:N?null:(0,W.jsx)(D,{label:m(`data.deleteRow`),onClick:()=>O.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,W.jsx)(L,{className:`size-3.5`})})})]},e.id))})]})}),M.length?null:(0,W.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:m(`data.noRows`)}),N?null:(0,W.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,busy:T.isPending,onClick:()=>T.mutate(),children:[(0,W.jsx)(h,{className:`size-4`}),` `,m(`data.addRow`)]})})]}),d?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:d}):null,(0,W.jsx)(et,{open:l!==null,column:l===`new`?null:l,columns:j,onClose:()=>u(null),onSave:e=>C({columns:e})})]})}var nt=`wizards.runDrawer.width`,rt=`wizards.runDrawer.wide`,it=`wizards.runDrawer.look`,at=680,Z=400,ot=()=>Math.max(Z,window.innerWidth-120);function Q(e){try{return localStorage.getItem(e)}catch{return null}}function $(e,t){try{localStorage.setItem(e,t)}catch{}}function st(){let[e,t]=(0,U.useState)(()=>{let e=Number(Q(nt));return e?Math.min(Math.max(e,Z),ot()):at}),[n,r]=(0,U.useState)(()=>Q(rt)===`1`),i=(0,U.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,Z),ot()));t(n),$(nt,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),$(rt,n?`0`:`1`)},onPointerDown:t=>{t.preventDefault();let n=t.clientX,r=e,a=e=>i(r+n-e.clientX),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},onKeyDown:t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`?(t.preventDefault(),i(e+n)):t.key===`ArrowRight`&&(t.preventDefault(),i(e-n))},reset:()=>i(at)}}function ct(){let[e,t]=(0,U.useState)(()=>Q(it)===`chat`?`chat`:`steps`);return[e,e=>{t(e),$(it,e)}]}function lt({look:e,onChange:t}){let n=[{id:`steps`,label:m(`chat.steps`),Icon:pe},{id:`chat`,label:m(`chat.chat`),Icon:B}];return(0,W.jsx)(`fieldset`,{"aria-label":m(`chat.view`),className:`m-0 flex min-w-0 rounded-full border-0 bg-paper-2 p-0.5`,children:n.map(({id:n,label:r,Icon:i})=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,title:r,onClick:()=>t(n),className:v(`inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,e===n?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[(0,W.jsx)(i,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`max-sm:hidden`,children:r})]},n))})}function ut({header:e,actions:t,onClose:n,children:r}){let i=st();return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:n,children:(0,W.jsxs)(`div`,{className:v(`relative flex h-full w-full animate-rise flex-col bg-background shadow-overlay`,!i.wide&&`sm:w-[var(--drawer)]`),style:{"--drawer":`${i.width}px`},onClick:e=>e.stopPropagation(),children:[i.wide?null:(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":m(`editor.resize`),"aria-valuenow":i.width,tabIndex:0,title:m(`editor.resize`),onPointerDown:i.onPointerDown,onKeyDown:i.onKeyDown,onDoubleClick:i.reset,className:`group -left-2.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none sm:block`,children:(0,W.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[7px] h-12 w-1.5 rounded-full bg-ink-4/40 transition group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:h-16 group-active:bg-ember`})}),(0,W.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,W.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,W.jsx)(D,{label:m(i.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:i.toggleWide,className:`max-sm:hidden`,children:i.wide?(0,W.jsx)(me,{className:`size-4`}):(0,W.jsx)(ae,{className:`size-4`})}),(0,W.jsx)(D,{label:m(`editor.close`),onClick:n,children:(0,W.jsx)(d,{className:`size-5`})})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r})]})})}export{De as _,He as a,fe as b,Be as c,J as d,Y as f,Te as g,G as h,tt as i,ze as l,Oe as m,ut as n,We as o,Le as p,ct as r,Ve as s,lt as t,je as u,Ee as v,ce as x,H as y};
|