@takeokunn/gbrainx 0.1.0 → 0.1.2

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.
@@ -23,27 +23,81 @@ Use the webhook event ID to detect duplicate deliveries before applying the even
23
23
 
24
24
  See [[stripe-idempotency]] for checkout keys and [[payment-retries]] for retries.
25
25
  `,_=[{kind:`STRIPE_KEY`,pattern:/\bsk_(?:live|test)_[0-9A-Za-z]{8,}/g},{kind:`API_KEY`,pattern:/\bsk-[0-9A-Za-z_-]{16,}/g},{kind:`AWS_KEY`,pattern:/AKIA[0-9A-Z]{16}/g},{kind:`GITHUB_TOKEN`,pattern:/\bgh[pousr]_[0-9A-Za-z]{20,}/g},{kind:`JWT`,pattern:/(?<![\w-])eyJ[\w-]+\.[\w-]+\.[\w-]+/g},{kind:`CONNECTION`,pattern:/\b[a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^\s/@]+@/g},{kind:`QUERY_TOKEN`,pattern:/[?&](?:access_token|token|api_key|apikey|key|secret|password)=([^&#\s]+)/gi,group:1},{kind:`ENV`,pattern:/^[ \t]*(?:export[ \t]+)?[A-Za-z_][A-Za-z0-9_]{0,127}[ \t]*=[ \t]*("[^\r\n]*|'[^\r\n]*|[^\s#]+)/gm,group:1},{kind:`EMAIL`,pattern:/[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]{1,64}@[A-Za-z0-9-]{1,63}(?:\.[A-Za-z0-9-]{1,63}){1,8}/g},{kind:`HOST`,pattern:/[\w.-]{1,253}\.(?:local|internal|corp)\b/gi},{kind:`IP`,pattern:/\b(?:\d{1,3}\.){3}\d{1,3}\b/g}];function v(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let n=0;for(let r of t.values()){let t=r/e.length;n-=t*Math.log2(t)}return n}var y=/(?:\/(?:Users|home)\/[^/\s\\]+(?:\/|\\)|\b[A-Za-z]:\\Users\\[^/\s\\]+\\)/gi,b=/~[\\/]\.gbrain(?:[\\/](?:\\[ \t]|[^\s\]})"'<>,;])*)?(?=$|[\s\]})"'<>,;])/gi;function x(e,t){let n=e.split(/(?<=\n)|(?<=\r)(?!\n)/),r=-1,i=``;for(let e=0;e<n.length;e++){let a=n[e],o=/^ {0,3}(`{3,}|~{3,})/.exec(a)?.[1];if(o)i?o[0]===i[0]&&o.length>=i.length&&(i=``):i=o;else if(!i&&/^\uFEFF?(?:---|\.\.\.)[ \t]*(?:#.*)?(?:\r\n|\n|\r)?$/.test(a)){if(r<0)a.replace(/^\uFEFF/,``).startsWith(`---`)&&(r=e);else{for(let i=r+1;i<e;i++){let r=/^[ \t]*(?:-[ \t]+)?\?[ \t]+["']?(raw_source|source_path|source_file|source_uri|source_url|import_source|transcript_source|original_source|origin|source)["']?[ \t]*(?:\r\n|\n|\r)$/i.exec(n[i]);if(r&&i+1<e){let a=/^([ \t]*:[ \t]*)([^\r\n]*)(\r\n|\n|\r|$)/.exec(n[i+1]);if(a){let o=a[2],s=i+2,c=/^[ \t]*/.exec(n[i+1])[0].length;for(;s<e&&(!n[s].trim()||/^[ \t]+\S/.test(n[s])&&/^[ \t]*/.exec(n[s])[0].length>c);)o+=a[3]+n[s].replace(/(?:\r\n|\n|\r)$/,``),n[s++]=``;let l=r[1].toLowerCase()===`source`&&/^(?:gbrainx|"gbrainx"|'gbrainx')\s*(?:#.*)?$/i.test(a[2]);l&&o===a[2]||t(o),n[i]=l?`source: gbrainx${a[3]}`:``,n[i+1]=``,i=s-1;continue}}if(/[{,][ \t]*["']?(?:raw_source|source_path|source_file|source_uri|source_url|import_source|transcript_source|original_source|origin|source)["']?[ \t]*:/i.test(n[i])||/[{,][ \t]*"[^"\r\n]*\\/.test(n[i])){let e=n[i].replace(/(?:\r\n|\n|\r)$/,``),r=n[i].slice(e.length),a=/[{,][ \t]*["']?source["']?[ \t]*:[ \t]*(?:gbrainx|"gbrainx"|'gbrainx')[ \t]*(?=[,}])/i.test(e),o=/^[ \t]*/.exec(e)[0];t(e),n[i]=a?`${o}source: gbrainx${r}`:``;continue}let a=/^([ \t]*(?:-[ \t]+)*("(?:[^"\\]|\\.)*"|'[^']*'|[A-Za-z_][A-Za-z0-9_-]*)[ \t]*:[ \t]*)([^\r\n]*)(\r\n|\n|\r|$)/.exec(n[i]),o=/^[ \t]*/.exec(n[i])[0].length,s=i+1<e&&/^[ \t]+\S/.test(n[i+1])&&!/^[ \t]+["']?[A-Za-z_][A-Za-z0-9_-]*["']?[ \t]*:/.test(n[i+1]);if(!a)continue;let c=a[2].replace(/^["']|["']$/g,``),l=c.replace(/\\x([0-9a-f]{2})|\\u([0-9a-f]{4})/gi,(e,t,n)=>String.fromCharCode(parseInt(t??n,16))).toLowerCase();if(!/^(?:raw_source|source_path|source_file|source_uri|source_url|import_source|transcript_source|original_source|origin|source)$/.test(l)&&!c.includes(`\\`))continue;if(l===`source`&&/^(?:gbrainx|"gbrainx"|'gbrainx')\s*(?:#.*)?$/i.test(a[3])){if(s){let r=[],o=i+1;for(;o<e&&/^[ \t]+\S/.test(n[o])&&!/^[ \t]+["']?[A-Za-z_][A-Za-z0-9_-]*["']?[ \t]*:/.test(n[o]);)r.push(n[o].replace(/(?:\r\n|\n|\r)$/,``)),n[o++]=``;t(r.join(a[4])),i=o-1}continue}let u=a[3],d=i+1,f=u[0]===`"`||u[0]===`'`?u[0]:``,p=(e,t)=>{for(let n=t;n<e.length;n++)if(f===`"`&&e[n]===`\\`)n++;else if(e[n]===f){if(f===`'`&&e[n+1]===`'`)n++;else return!0}return!1};if(f&&!p(u,1))for(;d<e;){let e=n[d].replace(/(?:\r\n|\n|\r)$/,``);if(u+=a[4]+e,n[d++]=``,p(e,0))break}else if(!f)for(;d<e&&(!n[d].trim()||/^[ \t]+\S/.test(n[d])&&/^[ \t]*/.exec(n[d])[0].length>o);)u+=a[4]+n[d].replace(/(?:\r\n|\n|\r)$/,``),n[d++]=``;t(u),n[i]=``,i=d-1}r=-1}}}return n.join(``)}function S(e){return/^[a-z0-9]+(?:-[a-z0-9]+)+$/.test(e)?e.split(`-`).filter(e=>/^[a-z]{3,}$/.test(e)).length>=2:!1}function C(e){if(/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(e))return!0;let t=/^(.*)-[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.exec(e);return t&&(e=t[1]),S(e)?!0:/^(?:[a-z0-9]+(?:[-_][a-z0-9]+)*|[A-Z][a-z]+)$/.test(e)?e.split(/[-_]/).every(e=>{let t=e.match(/(?<=[a-z])(?=[0-9])|(?<=[0-9])(?=[a-z])/g);return!(e.length>=20&&/[a-z]/.test(e)&&/[0-9]/.test(e)&&v(e)>=4)&&(t?.length??0)<=2&&!/^[a-f0-9]{20,}$/.test(e)}):!1}function w(e){if(/^sk-[A-Za-z0-9_-]{16,}$/.test(e))return!0;if(/^[a-f0-9]{20,}$/i.test(e)&&/[a-f]/i.test(e)&&/[0-9]/.test(e))return v(e.toLowerCase())>=3.2;if(e.startsWith(`REDACTED_`)||v(e)<4||e.includes(`-`)&&C(e))return!1;if(e.includes(`/`)){let t=e.split(`/`).filter(Boolean);if(t.length>1&&t.every(C))return!1}return!0}function T(e,t,n){let r=/^[A-Za-z0-9]+$/.test(t),i=0,a=0,o=[];for(;;){let s=e.indexOf(t,a);if(s<0)break;let c=s+t.length;r&&(/[A-Za-z0-9]/.test(e[s-1]??``)||/[A-Za-z0-9]/.test(e[c]??``))?a=s+1:(o.push(e.slice(i,s),n()),i=c,a=c)}return o.push(e.slice(i)),o.join(``)}function E(e,t){let n=new Set;for(let t of e)for(let e of[t.title,t.id,...t.markdown.match(/\b[A-Z][a-zA-Z]{2,}\b/g)??[]])e.trim()&&n.add(e.trim());let r=[...n].sort((e,t)=>t.length-e.length||e.localeCompare(t));return{terms:r,shared:r.filter(e=>t.some(t=>t.includes(e)))}}function D(e,t={terms:[],shared:[]}){let n=e,r=[],i=new Map,a=new Map,o=(e,t)=>{let n=`${e}\0${t}`,o=i.get(n);if(!o){let t=(a.get(e)??0)+1;a.set(e,t),o=`[REDACTED_${e}_${t}]`,i.set(n,o)}return r.push({kind:e,before:t,after:o}),o},s=0,c=0,l=[];for(;;){let e=n.indexOf(`-----BEGIN `,s);if(e<0)break;let t=n.indexOf(`
26
- `,e);if(t<0)break;let r=n.slice(e,t).trimEnd(),i=/^-----BEGIN ([A-Z ]{0,32}PRIVATE KEY)-----$/.exec(r);if(!i){s=t+1;continue}let a=`-----END ${i[1]}-----`,u=n.indexOf(a,t);if(u<0)break;let d=u+a.length;l.push(n.slice(c,e),o(`PRIVATE_KEY`,n.slice(e,d))),s=d,c=d}l.push(n.slice(c)),n=l.join(``),n=n.replace(y,e=>(r.push({kind:`HOME_PATH`,before:e,after:`~/`}),`~/`)),n=n.replace(b,e=>o(`GBRAIN_PATH`,e)),n=x(n,e=>o(`SOURCE`,e));for(let{kind:e,pattern:t,group:r}of _)n=n.replace(t,(...t)=>{let n=t[0],i=r?t[r]:n;if(/^\[REDACTED_[A-Z_]+_\d+\]$/.test(i))return n;let a=o(e,i);return r?n.slice(0,n.lastIndexOf(i))+a:a});n=n.replace(/[A-Za-z0-9+/_=-]{20,}/g,e=>w(e)?o(`ENTROPY`,e):e);for(let e of t.terms)e&&n.includes(e)&&(n=n.split(/(\[REDACTED_[A-Z_]+_\d+\])/g).map(t=>/^\[REDACTED_[A-Z_]+_\d+\]$/.test(t)?t:T(t,e,()=>o(`NAME`,e))).join(``));let u=[...new Set(r.map(e=>e.kind))].map(e=>({kind:e,count:r.filter(t=>t.kind===e).length}));return{markdown:n,scrubbed:u,changes:r,remaining:O(n,t)}}function O(e,t){let n=0;n+=[...e.matchAll(y)].length,n+=[...e.matchAll(b)].length,x(e,()=>(n++,``)),/-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----/.test(e)&&n++;for(let{pattern:t,group:r}of _)for(let i of e.matchAll(t))/^\[REDACTED_[A-Z_]+_\d+\]$/.test(r?i[r]:i[0])||n++;for(let t of e.matchAll(/[A-Za-z0-9+/_=-]{20,}/g))w(t[0])&&n++;let r=e.split(/\[REDACTED_[A-Z_]+_\d+\]/g);for(let e of t.terms){if(!e)continue;let t=!1;for(let n of r)if(n.includes(e)&&(T(n,e,()=>(t=!0,``)),t))break;t&&n++}return n}function k(e,t){return O(e,t??{terms:[],shared:[]})}function A(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&Number.isSafeInteger(Math.round(e*100))&&Math.round(e*100)/100===e}function ee(e,t,n){return e.sessions.find(e=>e.id===t)??{id:t,startedAt:n,spentUsd:0,calls:[]}}function te(e,t){let n=e.sessions.findIndex(e=>e.id===t.id);return n<0?[...e.sessions,t]:e.sessions.map((e,r)=>r===n?t:e)}function j(e,t){return e.ledger.some(e=>e.packId===t)}function M(e,t,n,r){let i=e.packs.find(e=>e.id===t);if(!i)return{ok:!1,code:`pack_not_found`};if(j(e,t))return{ok:!0};let a=e.sessions.find(e=>e.id===n)?.spentUsd??0;if(![i.priceUsd,e.wallet.buyerUsd,e.wallet.perPurchaseCapUsd,e.wallet.sessionCapUsd,a].every(A))return{ok:!1,code:`invalid_amount`};let o=Math.round(i.priceUsd*100);return o>Math.round(e.wallet.buyerUsd*100)?{ok:!1,code:`insufficient_balance`,needsApproval:!0}:o>Math.round(e.wallet.perPurchaseCapUsd*100)?{ok:!1,code:`over_purchase_cap`,needsApproval:!0}:o+Math.round(a*100)>Math.round(e.wallet.sessionCapUsd*100)?{ok:!1,code:`over_session_cap`,needsApproval:!0}:!Number.isFinite(r)||r<.5||r>1?{ok:!1,code:`low_score`,needsApproval:!0}:{ok:!0}}function ne(e,t,n,r,i,a,o,s){let c=e.ledger.find(e=>e.packId===t);if(c)return{ok:!0,store:e,tx:c,rev:e.rev,alreadyPurchased:!0};if(e.rev!==o)return{ok:!1,code:`revision_conflict`};let l=M(e,t,n,s);if(!l.ok)return l;if(e.ledger.some(e=>e.id===a))return{ok:!1,code:`duplicate_tx_id`};let u=e.packs.find(e=>e.id===t),d=ee(e,n,i),f=Math.round(u.priceUsd*100),p=Math.round(f*.9),m={id:a,packId:t,sessionId:n,at:i,amountUsd:f/100,authorUsd:p/100,feeUsd:(f-p)/100,via:r,result:`running`,pagesUsed:[]},h={...d,spentUsd:(Math.round(d.spentUsd*100)+f)/100,calls:[...d.calls,{tool:`buy`,at:i,summary:t,txId:a}]},g={...e,rev:e.rev+1,wallet:{...e.wallet,buyerUsd:(Math.round(e.wallet.buyerUsd*100)-f)/100},ledger:[...e.ledger,m],sessions:te(e,h)};return{ok:!0,store:g,tx:m,rev:g.rev,alreadyPurchased:!1}}function re(e,t,n){let r=e.packs.find(e=>e.id===t);if(!r)return{ok:!1,code:`pack_not_found`};if(!j(e,t))return{ok:!1,code:`not_purchased`};if(n===void 0)return{ok:!0,content:r.summary,pages:r.pages.map(e=>e.id)};let i=r.pages.find(e=>e.id===n);return i?{ok:!0,content:i.markdown,page:i.id}:{ok:!1,code:`page_not_found`}}function N(e,t,n,r=[]){let i=e.ledger.find(e=>e.id===t);if(!i)return{ok:!1,code:`tx_not_found`};let a={...i,result:n,pagesUsed:[...r]};return{ok:!0,store:{...e,rev:e.rev+1,ledger:e.ledger.map(e=>e.id===t?a:e)},tx:a}}function P(e){let t=new Map(e.packs.filter(e=>e.author===`you`).map(e=>[e.id,{packId:e.id,uses:0,solved:0,authorUsd:0}])),n=0,r=0,i=0,a=0;for(let o of e.ledger){let e=t.get(o.packId);e&&(a++,e.uses++,o.result===`solved`&&(i++,e.solved++),n+=Math.round(o.authorUsd*100),r+=Math.round(o.feeUsd*100),e.authorUsd=(Math.round(e.authorUsd*100)+Math.round(o.authorUsd*100))/100)}return{uses:a,solved:i,authorUsd:n/100,feeUsd:r/100,byPack:[...t.values()]}}function ie(e,t){if(t.includes(e))return e;let n=e=>e.split(/[\\/]/).pop().replace(/\.md$/i,``),r=n(e),i=t.filter(e=>n(e)===r);return i.length===1?i[0]:void 0}function ae(e){let t=new Map,n=e.map(e=>e.id);for(let r of e)for(let e of new Set(r.links)){let i=ie(e,n);if(i===void 0||i===r.id)continue;let a=t.get(i)??[];a.push(r),t.set(i,a)}return e.flatMap(e=>{let n=t.get(e.id)??[],r=n.length>0&&n.every(e=>e.class===`personal`||e.class===`customer`);return e.markdown.split(/\r?\n[\t ]*\r?\n/).map(e=>e.trim()).filter(Boolean).map((t,n)=>{let i=Te({...e,markdown:t}),a=r?`Only personal or customer pages link to this page.`:{secret:`Contains sensitive data.`,customer:`Matches customer information.`,personal:`Matches personal notes.`,purchased:`Imported from a purchased pack.`,expertise:`No personal, customer, or secret rule matched.`}[i];return{id:`${e.id}#${n+1}`,pageId:e.id,markdown:t,class:i,confidence:r?.6:.95,reason:a,keep:i===`expertise`,confirmed:!1}})})}function F(e){return e.some(e=>e.confidence<.7&&!e.confirmed)}function I(e){return!F(e)&&!e.some(e=>e.keep&&(e.class===`customer`||e.class===`secret`||e.class===`purchased`))}var L=[`symptom`,`cause`,`fix`,`avoid`,`verify`],R=[[`symptom`,/症状|symptom/i],[`cause`,/原因|cause/i],[`fix`,/直し方|fix/i],[`avoid`,/避ける|avoid/i],[`verify`,/確認|verify/i]];function oe(e,t=ae(e),n){let r={fields:{symptom:[],cause:[],fix:[],avoid:[],verify:[]},errorSignatures:[],sourceIds:[],nodes:[]};for(let n of e.filter(e=>e.keep)){r.nodes.push({id:n.id,links:n.links});let e;for(let i of t.filter(e=>e.pageId===n.id)){let t=i.id;i.keep&&r.sourceIds.push(t);let n=[],a=()=>{let a=n.join(`
26
+ `,e);if(t<0)break;let r=n.slice(e,t).trimEnd(),i=/^-----BEGIN ([A-Z ]{0,32}PRIVATE KEY)-----$/.exec(r);if(!i){s=t+1;continue}let a=`-----END ${i[1]}-----`,u=n.indexOf(a,t);if(u<0)break;let d=u+a.length;l.push(n.slice(c,e),o(`PRIVATE_KEY`,n.slice(e,d))),s=d,c=d}l.push(n.slice(c)),n=l.join(``),n=n.replace(y,e=>(r.push({kind:`HOME_PATH`,before:e,after:`~/`}),`~/`)),n=n.replace(b,e=>o(`GBRAIN_PATH`,e)),n=x(n,e=>o(`SOURCE`,e));for(let{kind:e,pattern:t,group:r}of _)n=n.replace(t,(...t)=>{let n=t[0],i=r?t[r]:n;if(/^\[REDACTED_[A-Z_]+_\d+\]$/.test(i))return n;let a=o(e,i);return r?n.slice(0,n.lastIndexOf(i))+a:a});n=n.replace(/[A-Za-z0-9+/_=-]{20,}/g,e=>w(e)?o(`ENTROPY`,e):e);for(let e of t.terms)e&&n.includes(e)&&(n=n.split(/(\[REDACTED_[A-Z_]+_\d+\])/g).map(t=>/^\[REDACTED_[A-Z_]+_\d+\]$/.test(t)?t:T(t,e,()=>o(`NAME`,e))).join(``));let u=[...new Set(r.map(e=>e.kind))].map(e=>({kind:e,count:r.filter(t=>t.kind===e).length}));return{markdown:n,scrubbed:u,changes:r,remaining:O(n,t)}}function O(e,t){let n=0;n+=[...e.matchAll(y)].length,n+=[...e.matchAll(b)].length,x(e,()=>(n++,``)),/-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----/.test(e)&&n++;for(let{pattern:t,group:r}of _)for(let i of e.matchAll(t))/^\[REDACTED_[A-Z_]+_\d+\]$/.test(r?i[r]:i[0])||n++;for(let t of e.matchAll(/[A-Za-z0-9+/_=-]{20,}/g))w(t[0])&&n++;let r=e.split(/\[REDACTED_[A-Z_]+_\d+\]/g);for(let e of t.terms){if(!e)continue;let t=!1;for(let n of r)if(n.includes(e)&&(T(n,e,()=>(t=!0,``)),t))break;t&&n++}return n}function k(e,t){return O(e,t??{terms:[],shared:[]})}function A(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&Number.isSafeInteger(Math.round(e*100))&&Math.round(e*100)/100===e}function ee(e,t,n){return e.sessions.find(e=>e.id===t)??{id:t,startedAt:n,spentUsd:0,calls:[]}}function te(e,t){let n=e.sessions.findIndex(e=>e.id===t.id);return n<0?[...e.sessions,t]:e.sessions.map((e,r)=>r===n?t:e)}function j(e,t){return e.ledger.some(e=>e.packId===t)}function M(e,t,n,r){let i=e.packs.find(e=>e.id===t);if(!i)return{ok:!1,code:`pack_not_found`};if(j(e,t))return{ok:!0};let a=e.sessions.find(e=>e.id===n)?.spentUsd??0;if(![i.priceUsd,e.wallet.buyerUsd,e.wallet.perPurchaseCapUsd,e.wallet.sessionCapUsd,a].every(A))return{ok:!1,code:`invalid_amount`};let o=Math.round(i.priceUsd*100);return o>Math.round(e.wallet.buyerUsd*100)?{ok:!1,code:`insufficient_balance`,needsApproval:!0}:o>Math.round(e.wallet.perPurchaseCapUsd*100)?{ok:!1,code:`over_purchase_cap`,needsApproval:!0}:o+Math.round(a*100)>Math.round(e.wallet.sessionCapUsd*100)?{ok:!1,code:`over_session_cap`,needsApproval:!0}:!Number.isFinite(r)||r<.5||r>1?{ok:!1,code:`low_score`,needsApproval:!0}:{ok:!0}}function ne(e,t,n,r,i,a,o,s){let c=e.ledger.find(e=>e.packId===t);if(c)return{ok:!0,store:e,tx:c,rev:e.rev,alreadyPurchased:!0};if(e.rev!==o)return{ok:!1,code:`revision_conflict`};let l=M(e,t,n,s);if(!l.ok)return l;if(e.ledger.some(e=>e.id===a))return{ok:!1,code:`duplicate_tx_id`};let u=e.packs.find(e=>e.id===t),d=ee(e,n,i),f=Math.round(u.priceUsd*100),p=Math.round(f*.9),m={id:a,packId:t,sessionId:n,at:i,amountUsd:f/100,authorUsd:p/100,feeUsd:(f-p)/100,via:r,result:`running`,pagesUsed:[]},h={...d,spentUsd:(Math.round(d.spentUsd*100)+f)/100,calls:[...d.calls,{tool:`buy`,at:i,summary:t,txId:a}]},g={...e,rev:e.rev+1,wallet:{...e.wallet,buyerUsd:(Math.round(e.wallet.buyerUsd*100)-f)/100},ledger:[...e.ledger,m],sessions:te(e,h)};return{ok:!0,store:g,tx:m,rev:g.rev,alreadyPurchased:!1}}function re(e,t,n){let r=e.packs.find(e=>e.id===t);if(!r)return{ok:!1,code:`pack_not_found`};if(!j(e,t))return{ok:!1,code:`not_purchased`};if(n===void 0)return{ok:!0,content:r.summary,pages:r.pages.map(e=>e.id)};let i=r.pages.find(e=>e.id===n);return i?{ok:!0,content:i.markdown,page:i.id}:{ok:!1,code:`page_not_found`}}function N(e,t,n,r=[]){let i=e.ledger.find(e=>e.id===t);if(!i)return{ok:!1,code:`tx_not_found`};let a={...i,result:n,pagesUsed:[...r]};return{ok:!0,store:{...e,rev:e.rev+1,ledger:e.ledger.map(e=>e.id===t?a:e)},tx:a}}function P(e){let t=new Map(e.packs.filter(e=>e.author===`you`).map(e=>[e.id,{packId:e.id,uses:0,solved:0,authorUsd:0}])),n=0,r=0,i=0,a=0;for(let o of e.ledger){let e=t.get(o.packId);e&&(a++,e.uses++,o.result===`solved`&&(i++,e.solved++),n+=Math.round(o.authorUsd*100),r+=Math.round(o.feeUsd*100),e.authorUsd=(Math.round(e.authorUsd*100)+Math.round(o.authorUsd*100))/100)}return{uses:a,solved:i,authorUsd:n/100,feeUsd:r/100,byPack:[...t.values()]}}function ie(e,t){if(t.includes(e))return e;let n=e=>e.split(/[\\/]/).pop().replace(/\.md$/i,``),r=n(e),i=t.filter(e=>n(e)===r);return i.length===1?i[0]:void 0}function ae(e){let t=new Map,n=e.map(e=>e.id);for(let r of e)for(let e of new Set(r.links)){let i=ie(e,n);if(i===void 0||i===r.id)continue;let a=t.get(i)??[];a.push(r),t.set(i,a)}return e.flatMap(e=>{let n=t.get(e.id)??[],r=n.length>0&&n.every(e=>e.class===`personal`||e.class===`customer`);return e.markdown.split(/\r?\n[\t ]*\r?\n/).map(e=>e.trim()).filter(Boolean).map((t,n)=>{let i=Ee({...e,markdown:t}),a=r?`Only personal or customer pages link to this page.`:{secret:`Contains sensitive data.`,customer:`Matches customer information.`,personal:`Matches personal notes.`,purchased:`Imported from a purchased pack.`,expertise:`No personal, customer, or secret rule matched.`}[i];return{id:`${e.id}#${n+1}`,pageId:e.id,markdown:t,class:i,confidence:r?.6:.95,reason:a,keep:i===`expertise`,confirmed:!1}})})}function F(e){return e.some(e=>e.confidence<.7&&!e.confirmed)}function I(e){return!F(e)&&!e.some(e=>e.keep&&(e.class===`customer`||e.class===`secret`||e.class===`purchased`))}var L=[`symptom`,`cause`,`fix`,`avoid`,`verify`],R=[[`symptom`,/症状|symptom/i],[`cause`,/原因|cause/i],[`fix`,/直し方|fix/i],[`avoid`,/避ける|avoid/i],[`verify`,/確認|verify/i]];function oe(e,t=ae(e),n){let r={fields:{symptom:[],cause:[],fix:[],avoid:[],verify:[]},errorSignatures:[],sourceIds:[],nodes:[]};for(let n of e.filter(e=>e.keep)){r.nodes.push({id:n.id,links:n.links});let e;for(let i of t.filter(e=>e.pageId===n.id)){let t=i.id;i.keep&&r.sourceIds.push(t);let n=[],a=()=>{let a=n.join(`
27
27
  `).trim();i.keep&&e&&a&&r.fields[e].push({text:a,sourceId:t}),n=[]};for(let t of i.markdown.split(/\r?\n/)){let r=/^##\s+(.+?)\s*#*\s*$/.exec(t);r?(a(),e=R.find(([,e])=>e.test(r[1]))?.[0]):n.push(t)}a()}}let i=new Set(e.filter(e=>e.keep&&e.class!==`purchased`).map(e=>e.id)),a=t.filter(e=>e.keep&&e.class===`expertise`&&i.has(e.pageId)),o=new Set(a.map(e=>e.pageId)),s=E(e.filter(e=>!o.has(e.id)),a.map(e=>e.markdown)),c={terms:[...new Set([...s.terms,...n?.terms??[]])],shared:[]},l=a.flatMap(e=>e.markdown.replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/,``).split(/\r?\n/).filter(e=>!/^\s*#/.test(e)).join(` `).split(/(?<=[。!?!?])\s*|(?<=\.)\s+/).map(e=>e.trim()).filter(e=>e&&k(e,c)===0).map(t=>({text:t,sourceId:e.id,confidence:.5})));r.fallbackCandidates=L.filter(e=>r.fields[e].length===0).flatMap(e=>l.slice(0,5).map(t=>({field:e,...t})));let u=(r.fields.symptom.length?r.fields.symptom:r.fallbackCandidates.filter(e=>e.field===`symptom`)).flatMap(({text:e})=>e.split(/[\n。.!?]+/));return r.errorSignatures=[...new Set(u.map(e=>e.replace(/\S*[\\/]\S*/g,` `).replace(/\d+/g,` `).replace(/\s+/g,` `).trim()).filter(e=>!!e&&k(e,c)===0))].slice(0,5),r}function z(e){return L.map(t=>`## ${t}\n\n${e.fields[t].flatMap(({text:e,sourceId:t})=>e.split(/(?<=[。!?!?])\s*|(?<=\.)\s+|\n+/).map(e=>e.trim()).filter(Boolean).map(e=>`${e} [${t}]`)).join(`
28
28
 
29
29
  `)}`).join(`
30
30
 
31
- `)}function se(e){let t=[...new Set(e.map(({id:e})=>e))],n=new Map(t.map(e=>[e,new Set]));for(let r of e)for(let e of r.links){let i=ie(e,t);i!==void 0&&i!==r.id&&(n.get(r.id).add(i),n.get(i).add(r.id))}return n}function ce(e){let t=new Set(e.sourceIds),n=L.flatMap(t=>e.fields[t]).every(({text:e,sourceId:n})=>!e.trim()||!!n.trim()&&t.has(n)),r=z(e).length/4<=2e3,i=[...se(e.nodes)].filter(([,e])=>e.size===0).map(([e])=>e),a=e.nodes.length>0&&i.length===0;return{cited:n,withinLength:r,connected:a,isolatedPageIds:i,passed:n&&r&&a}}function le({pack:e,testNames:t,testCode:n,dictionary:r}){let i=z(e),a=ce(e),o=L.every(t=>e.fields[t].some(({text:e})=>!!e.trim()))&&e.errorSignatures.length>=3&&e.errorSignatures.length<=5&&e.errorSignatures.every(e=>!!e.trim()&&!/[\d\\/]/.test(e))&&a.connected,s=a.cited,c=k(i,r)===0,l=a.withinLength,u=[...t,...n].every(e=>!e.trim()||!i.includes(e));return{format:o,citations:s,rescan:c,length:l,copying:u,isolatedPageIds:a.isolatedPageIds,passed:o&&s&&c&&l&&u}}function ue(e,t){let n=t.filter(t=>!t||!e.includes(t));return{passed:t.length>0&&n.length===0,missing:n}}function de(e){return typeof e==`string`&&e.length>0&&e!==`.`&&e!==`..`&&!Array.from(e).some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||`<>:"/\\|?*[]`.includes(e))&&!/[. ]$/.test(e)&&!/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(e)}function B(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).normalize(`NFC`).toLowerCase()}function fe(e,t){if(!de(e.id)||typeof e.version!=`string`||typeof e.summary!=`string`||typeof t!=`string`||!Array.isArray(e.pages))throw Error(`Invalid import pack`);if(k(e.summary)||e.pages.some(e=>e&&typeof e.markdown==`string`&&k(e.markdown)))throw Error(`Sensitive data in import pack`);let n=`packs/${e.id}`,r=new Set([B(`${n}/index.md`)]),i=`---\nsource: gbrainx\npack: ${JSON.stringify(e.id)}\nversion: ${JSON.stringify(e.version)}\nlicense: personal-use\npurchasedAt: ${JSON.stringify(t)}\n---\n\n`,a=e.pages.map(e=>{if(!e||!de(e.id)||typeof e.markdown!=`string`)throw Error(`Invalid import page`);let t=`${n}/${e.id}.md`,a=B(t);if(r.has(a))throw Error(`Duplicate import path`);return r.add(a),{path:t,markdown:i+e.markdown}}),o=e.pages.map(({id:e})=>`- [[${e}]]`).join(`
31
+ `)}function se(e){let t=[...new Set(e.map(({id:e})=>e))],n=new Map(t.map(e=>[e,new Set]));for(let r of e)for(let e of r.links){let i=ie(e,t);i!==void 0&&i!==r.id&&(n.get(r.id).add(i),n.get(i).add(r.id))}return n}function ce(e){let t=new Set(e.sourceIds),n=L.flatMap(t=>e.fields[t]).every(({text:e,sourceId:n})=>!e.trim()||!!n.trim()&&t.has(n)),r=z(e).length/4<=2e3,i=[...se(e.nodes)].filter(([,e])=>e.size===0).map(([e])=>e),a=e.nodes.length>0&&i.length===0;return{cited:n,withinLength:r,connected:a,isolatedPageIds:i,passed:n&&r&&a}}function le({pack:e,testNames:t,testCode:n,dictionary:r}){let i=z(e),a=ce(e),o=L.every(t=>e.fields[t].some(({text:e})=>!!e.trim()))&&e.errorSignatures.length>=3&&e.errorSignatures.length<=5&&e.errorSignatures.every(e=>!!e.trim()&&!/[\d\\/]/.test(e))&&a.connected,s=a.cited,c=k(i,r)===0,l=a.withinLength,u=[...t,...n].every(e=>!e.trim()||!i.includes(e));return{format:o,citations:s,rescan:c,length:l,copying:u,isolatedPageIds:a.isolatedPageIds,passed:o&&s&&c&&l&&u}}function ue(e,t){let n=t.filter(t=>!t||!e.includes(t));return{passed:t.length>0&&n.length===0,missing:n}}var de={id:`stripe-double-charge-prevention`,title:`Stripe Double-Charge Prevention`,version:`v1`,domain:`payments`,errorSignatures:[`double charge`,`charged twice`,`idempotency`,`orderKey`,`stripe double charge on retry`],nodes:[`stripe-idempotency`,`payment-retries`,`webhook-dedupe`],markdown:`## [[stripe-idempotency]]
32
+
33
+ # Stripe idempotency
34
+
35
+ Import \`orderKey\` from \`./pay-client.mjs\` and use \`payClient.charge(order, { orderKey: orderKey(order) })\`. The key is derived from \`order.merchantId\`, \`order.id\`, and \`order.revision\`. Retry the same operation with the same values. A new revision represents a new operation. The client does not use \`Idempotency-Key\` for deduplication.
36
+
37
+ See [[payment-retries]] for retry handling and [[webhook-dedupe]] for duplicate events.
38
+
39
+
40
+ ## [[payment-retries]]
41
+
42
+ # Payment retries
43
+
44
+ Retry the same checkout operation with the same \`order.merchantId\`, \`order.id\`, and \`order.revision\`. Import \`orderKey\` from \`./pay-client.mjs\` and pass \`orderKey(order)\` as the \`orderKey\` option to \`payClient.charge\`. Generating a new key for each attempt can create a duplicate charge.
45
+
46
+ See [[stripe-idempotency]] and [[webhook-dedupe]] for the charge and event boundaries.
47
+
48
+
49
+ ## [[webhook-dedupe]]
50
+
51
+ # Webhook deduplication
52
+
53
+ Use the webhook event ID to detect duplicate deliveries before applying the event's effects. Record the ID only when processing succeeds, so a failed delivery can be retried.
54
+
55
+ See [[stripe-idempotency]] for checkout keys and [[payment-retries]] for retries.
56
+
57
+
58
+ ## Sources
59
+
60
+ - [[stripe-idempotency]]
61
+ - [[payment-retries]]
62
+ - [[webhook-dedupe]]`,summary:`## symptom
63
+
64
+ Retries can produce a duplicate charge. [payment-retries#2]
65
+
66
+ ## cause
67
+
68
+ A new key on each attempt creates separate operations. [payment-retries#2]
69
+
70
+ ## fix
71
+
72
+ Import orderKey from ./pay-client.mjs and pass orderKey(order) as the orderKey option to payClient.charge. [stripe-idempotency#2]
73
+
74
+ ## avoid
75
+
76
+ Do not generate a new key for retries. [payment-retries#2]
77
+
78
+ ## verify
79
+
80
+ Deduplicate webhook deliveries using the event ID after successful processing. [webhook-dedupe#2]`,pages:[{id:`stripe-idempotency`,markdown:"# Stripe idempotency\n\nImport `orderKey` from `./pay-client.mjs` and use `payClient.charge(order, { orderKey: orderKey(order) })`. The key is derived from `order.merchantId`, `order.id`, and `order.revision`. Retry the same operation with the same values. A new revision represents a new operation. The client does not use `Idempotency-Key` for deduplication.\n\nSee [[payment-retries]] for retry handling and [[webhook-dedupe]] for duplicate events.\n"},{id:`payment-retries`,markdown:"# Payment retries\n\nRetry the same checkout operation with the same `order.merchantId`, `order.id`, and `order.revision`. Import `orderKey` from `./pay-client.mjs` and pass `orderKey(order)` as the `orderKey` option to `payClient.charge`. Generating a new key for each attempt can create a duplicate charge.\n\nSee [[stripe-idempotency]] and [[webhook-dedupe]] for the charge and event boundaries.\n"},{id:`webhook-dedupe`,markdown:`# Webhook deduplication
81
+
82
+ Use the webhook event ID to detect duplicate deliveries before applying the event's effects. Record the ID only when processing succeeds, so a failed delivery can be retried.
83
+
84
+ See [[stripe-idempotency]] for checkout keys and [[payment-retries]] for retries.
85
+ `}],scrubbed:[],eval:{without:`Not recorded`,with:`Not recorded`,recorded:!0},priceUsd:.5,author:`seed`,createdAt:`2026-01-01T00:00:00.000Z`};function B(e){return typeof e==`string`&&e.length>0&&e!==`.`&&e!==`..`&&!Array.from(e).some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||`<>:"/\\|?*[]`.includes(e))&&!/[. ]$/.test(e)&&!/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(e)}function fe(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).normalize(`NFC`).toLowerCase()}function pe(e,t){if(!B(e.id)||typeof e.version!=`string`||typeof e.summary!=`string`||typeof t!=`string`||!Array.isArray(e.pages))throw Error(`Invalid import pack`);if(k(e.summary)||e.pages.some(e=>e&&typeof e.markdown==`string`&&k(e.markdown)))throw Error(`Sensitive data in import pack`);let n=`packs/${e.id}`,r=new Set([fe(`${n}/index.md`)]),i=`---\nsource: gbrainx\npack: ${JSON.stringify(e.id)}\nversion: ${JSON.stringify(e.version)}\nlicense: personal-use\npurchasedAt: ${JSON.stringify(t)}\n---\n\n`,a=e.pages.map(e=>{if(!e||!B(e.id)||typeof e.markdown!=`string`)throw Error(`Invalid import page`);let t=`${n}/${e.id}.md`,a=fe(t);if(r.has(a))throw Error(`Duplicate import path`);return r.add(a),{path:t,markdown:i+e.markdown}}),o=e.pages.map(({id:e})=>`- [[${e}]]`).join(`
32
86
  `);return[{path:`${n}/index.md`,markdown:i+e.summary+(o?`\n\n${o}`:``)+`
33
- `},...a]}var pe=`gbrainx:v1`,V=e=>typeof e==`object`&&!!e&&!Array.isArray(e),H=e=>typeof e==`string`,U=e=>Array.isArray(e)&&e.every(H),W=(e,t)=>H(e)&&t.includes(e),me=e=>new Set(e.map(e=>e.id)).size===e.length;function he(e){return V(e)&&H(e.id)&&H(e.title)&&H(e.markdown)&&U(e.links)&&W(e.class,[`expertise`,`personal`,`customer`,`secret`,`purchased`])&&typeof e.keep==`boolean`}function ge(e){return V(e)&&H(e.id)&&H(e.title)&&H(e.version)&&H(e.domain)&&U(e.errorSignatures)&&U(e.nodes)&&H(e.markdown)&&H(e.summary)&&e.summary.length<=2e3&&Array.isArray(e.pages)&&e.pages.every(e=>V(e)&&H(e.id)&&H(e.markdown))&&Array.isArray(e.scrubbed)&&e.scrubbed.every(e=>V(e)&&H(e.kind)&&typeof e.count==`number`&&Number.isSafeInteger(e.count)&&e.count>=0)&&V(e.eval)&&H(e.eval.without)&&H(e.eval.with)&&e.eval.recorded===!0&&A(e.priceUsd)&&W(e.author,[`you`,`seed`])&&H(e.createdAt)}function _e(e){return V(e)&&H(e.id)&&H(e.packId)&&H(e.sessionId)&&H(e.at)&&A(e.amountUsd)&&A(e.authorUsd)&&A(e.feeUsd)&&W(e.via,[`web`,`mcp`])&&W(e.result,[`running`,`solved`,`unsolved`])&&U(e.pagesUsed)}function ve(e){return V(e)&&H(e.id)&&H(e.startedAt)&&A(e.spentUsd)&&Array.isArray(e.calls)&&e.calls.every(e=>V(e)&&W(e.tool,[`search`,`buy`,`load`])&&H(e.at)&&H(e.summary)&&(e.tool===`buy`?H(e.txId):e.txId===void 0||H(e.txId)))}function ye(e){return!(!V(e)||e.version!==1||typeof e.rev!=`number`||!Number.isSafeInteger(e.rev)||e.rev<0||!V(e.brain)||!Array.isArray(e.brain.pages)||!e.brain.pages.every(he)||!Array.isArray(e.packs)||!e.packs.every(ge)||!me(e.packs)||!V(e.wallet)||!A(e.wallet.buyerUsd)||!A(e.wallet.perPurchaseCapUsd)||!A(e.wallet.sessionCapUsd)||!Array.isArray(e.ledger)||!e.ledger.every(_e)||!me(e.ledger)||!Array.isArray(e.sessions)||!e.sessions.every(ve)||!me(e.sessions))}function be(e){let t=0;for(let n of e){let e=n.codePointAt(0);if(t+=e<=127?1:e<=2047?2:e<=65535?3:4,t>4194304)return t}return t}function xe(e){if(typeof e!=`string`||be(e)>4194304)throw Error(`Invalid store size`);let t=JSON.parse(e);if(!ye(t))throw Error(`Invalid store`);return t}function Se(e){if(!ye(e))throw Error(`Invalid store`);let t=JSON.stringify(e);if(be(t)>4194304)throw Error(`Invalid store size`);return t}function Ce(e){let t=D(e);return{markdown:t.markdown.replace(/\[REDACTED_([A-Z_]+)_\d+\]/g,(e,t)=>t===`NAME`?e:`[REDACTED_${t}]`),scrubbed:t.scrubbed,remaining:t.remaining}}function we(e){let t=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(e)?.[1];return t!==void 0&&/^source[ \t]*:[ \t]*(?:gbrainx|"gbrainx"|'gbrainx')[ \t]*(?:#.*)?$/m.test(t)}function Te(e){if(e.class===`purchased`||we(e.markdown))return`purchased`;let t=D(e.markdown),n=e=>e!==`HOME_PATH`&&e!==`GBRAIN_PATH`&&e!==`SOURCE`;if(t.scrubbed.some(({kind:e})=>n(e))||t.changes.some(({kind:e,before:t})=>(e===`SOURCE`||e===`GBRAIN_PATH`)&&D(e===`GBRAIN_PATH`?t.replace(/^~[\\/]\.gbrain[\\/]?/i,``):t).scrubbed.some(e=>n(e.kind))))return`secret`;let r=[...e.markdown.matchAll(/\+?\d[\d ()-]*/g)].some(t=>{let n=t[0].trimEnd(),r=n.length;for(;r>0&&(n[r-1]===`-`||n[r-1]===`(`);)r--;n=n.slice(0,r).trimEnd();let i=e.markdown[t.index-1]??``,a=e.markdown[t.index+n.length]??``,o=n.replace(/\D/g,``).length;return!/[A-Za-z0-9-]/.test(i)&&!/[A-Za-z0-9-]/.test(a)&&!/^\d{4}-\d{2}-\d{2}$/.test(n)&&/[ ()+-]/.test(n)&&o>=9&&o<=15});return/^customer-/i.test(e.id)||r?`customer`:/standup|1on1|oncall|retro|休暇/i.test(`${e.id}\n${e.markdown}`)?`personal`:`expertise`}function Ee(e){return e.filter(({name:e})=>/\.md$/i.test(e)).map(({name:e,markdown:t})=>{let n=e.split(/[\\/]/).pop().replace(/\.md$/i,``),r={id:n,title:/^#\s+(.+)$/m.exec(t)?.[1].trim()||n,markdown:t,links:[...t.matchAll(/\[\[([^\][|]+)(?:\|[^\][]*)?\]\]/g)].map(e=>e[1].trim()),class:`expertise`,keep:!0};return r.class=Te(r),r.keep=r.class===`expertise`,r})}var G=class extends Error{issues;constructor(e,t=`Static evaluation failed`){super(t),this.issues=e,this.name=`StaticEvaluationError`}};function De(e,t){if(!t.staticEvaluation||!Array.isArray(t.staticEvaluation.testNames)||!Array.isArray(t.staticEvaluation.testCode)||!Array.isArray(t.staticEvaluation.keywords)||!t.staticEvaluation.distilled)throw new G([{code:`invalid_input`}],`Static evaluation input is required`);let{testNames:n,testCode:r,keywords:i}=t.staticEvaluation;if(![...n,...r].some(e=>typeof e==`string`&&e.trim())||[...n,...r].some(e=>typeof e!=`string`))throw new G([{code:`invalid_input`}],`Static evaluation input is required`);let a=t.errorSignatures.map(e=>e.trim()).filter(Boolean);if(!a.length)throw Error(`At least one error signature is required`);if(!t.title.trim())throw Error(`A title is required`);let o=14695981039346656037n;for(let e of t.title)o^=BigInt(e.codePointAt(0)),o=BigInt.asUintN(64,o*1099511628211n);let s=t.title.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)||`pack-${o.toString(36)}`,c=new Set(t.existingIds??[]),l=s;for(let e=2;c.has(l);e++)l=`${s}-${e}`;if(typeof t.eval!=`object`||t.eval===null||Object.keys(t.eval).sort().join(`,`)!==`recorded,with,without`||typeof t.eval.without!=`string`||typeof t.eval.with!=`string`||t.eval.recorded!==!0)throw Error(`Invalid evaluation`);if(t.author!==void 0&&t.author!==`you`&&t.author!==`seed`)throw Error(`Invalid author`);let u=t.priceUsd===void 0?.5:t.priceUsd;if(!Number.isFinite(u)||u<0)throw Error(`Invalid price`);let d=e.filter(e=>e.keep&&e.class!==`purchased`&&!we(e.markdown));if(!d.length)throw Error(`At least one kept page is required`);let f=new Set(d.map(e=>e.id)),p=E(e.filter(e=>!f.has(e.id)),d.map(e=>e.markdown)),m={terms:[...new Set([...p.terms,...t.forbiddenDictionary?.terms??[]])],shared:[...new Set([...p.shared,...t.forbiddenDictionary?.shared??[]])]},h=e=>e.replace(/\[REDACTED_([A-Z_]+)_\d+\]/g,(e,t)=>t===`NAME`?e:`[REDACTED_${t}]`),g=e=>{let t=D(e,m);return{...t,markdown:h(t.markdown)}},_=(e,t,n)=>{if(!t)return;let r=[];throw D(e,m).changes.some(({kind:e})=>e===`NAME`)&&r.push({code:`forbidden_term`,location:n}),(k(e)>0||!r.length)&&r.push({code:`rescan`,location:n}),new G(r,`Sensitive data remains after scrubbing`)},v=()=>({generated:new Set,existing:new Set}),y=(e,t,n)=>{for(let n of t.matchAll(/\[REDACTED_[A-Z_]+(?:_\d+)?\]|~\//g))e.existing.add(h(n[0]));for(let t of n)e.generated.add(t.kind===`HOME_PATH`?`~/`:h(t.after))},b=[t.title,t.version,t.domain,...t.errorSignatures,t.eval.without,t.eval.with,t.createdAt,...d.map(e=>e.id)],x=[];if(b.some(e=>D(e,m).changes.some(({kind:e})=>e===`NAME`))&&x.push({code:`forbidden_term`,location:`metadata`}),b.some(e=>Ce(e).scrubbed.length>0)&&x.push({code:`rescan`,location:`metadata`}),x.length)throw new G(x,`Sensitive data in pack metadata`);let S=new Map(d.map(e=>[e.id,e]));if(S.size!==d.length)throw Error(`Duplicate page id`);let C=[...S.keys()],w=[],T=new Set;for(let e of d){let t=[e];for(;t.length;){let e=t.pop();if(!T.has(e.id)){T.add(e.id),w.push(e);for(let n=e.links.length-1;n>=0;n--){let r=ie(e.links[n],C),i=r===void 0?void 0:S.get(r);i&&t.push(i)}}}}let O=g(`${w.map(e=>`## [[${e.id}]]\n\n${e.markdown}`).join(`
87
+ `},...a]}var me=`gbrainx:v1`,V=e=>typeof e==`object`&&!!e&&!Array.isArray(e),H=e=>typeof e==`string`,U=e=>Array.isArray(e)&&e.every(H),W=(e,t)=>H(e)&&t.includes(e),he=e=>new Set(e.map(e=>e.id)).size===e.length;function ge(e){return V(e)&&H(e.id)&&H(e.title)&&H(e.markdown)&&U(e.links)&&W(e.class,[`expertise`,`personal`,`customer`,`secret`,`purchased`])&&typeof e.keep==`boolean`}function _e(e){return V(e)&&H(e.id)&&H(e.title)&&H(e.version)&&H(e.domain)&&U(e.errorSignatures)&&U(e.nodes)&&H(e.markdown)&&H(e.summary)&&e.summary.length<=2e3&&Array.isArray(e.pages)&&e.pages.every(e=>V(e)&&H(e.id)&&H(e.markdown))&&Array.isArray(e.scrubbed)&&e.scrubbed.every(e=>V(e)&&H(e.kind)&&typeof e.count==`number`&&Number.isSafeInteger(e.count)&&e.count>=0)&&V(e.eval)&&H(e.eval.without)&&H(e.eval.with)&&e.eval.recorded===!0&&A(e.priceUsd)&&W(e.author,[`you`,`seed`])&&H(e.createdAt)}function ve(e){return V(e)&&H(e.id)&&H(e.packId)&&H(e.sessionId)&&H(e.at)&&A(e.amountUsd)&&A(e.authorUsd)&&A(e.feeUsd)&&W(e.via,[`web`,`mcp`])&&W(e.result,[`running`,`solved`,`unsolved`])&&U(e.pagesUsed)}function ye(e){return V(e)&&H(e.id)&&H(e.startedAt)&&A(e.spentUsd)&&Array.isArray(e.calls)&&e.calls.every(e=>V(e)&&W(e.tool,[`search`,`buy`,`load`])&&H(e.at)&&H(e.summary)&&(e.tool===`buy`?H(e.txId):e.txId===void 0||H(e.txId)))}function be(e){return!(!V(e)||e.version!==1||typeof e.rev!=`number`||!Number.isSafeInteger(e.rev)||e.rev<0||!V(e.brain)||!Array.isArray(e.brain.pages)||!e.brain.pages.every(ge)||!Array.isArray(e.packs)||!e.packs.every(_e)||!he(e.packs)||!V(e.wallet)||!A(e.wallet.buyerUsd)||!A(e.wallet.perPurchaseCapUsd)||!A(e.wallet.sessionCapUsd)||!Array.isArray(e.ledger)||!e.ledger.every(ve)||!he(e.ledger)||!Array.isArray(e.sessions)||!e.sessions.every(ye)||!he(e.sessions))}function xe(e){let t=0;for(let n of e){let e=n.codePointAt(0);if(t+=e<=127?1:e<=2047?2:e<=65535?3:4,t>4194304)return t}return t}function Se(e){if(typeof e!=`string`||xe(e)>4194304)throw Error(`Invalid store size`);let t=JSON.parse(e);if(!be(t))throw Error(`Invalid store`);return t}function Ce(e){if(!be(e))throw Error(`Invalid store`);let t=JSON.stringify(e);if(xe(t)>4194304)throw Error(`Invalid store size`);return t}function we(e){let t=D(e);return{markdown:t.markdown.replace(/\[REDACTED_([A-Z_]+)_\d+\]/g,(e,t)=>t===`NAME`?e:`[REDACTED_${t}]`),scrubbed:t.scrubbed,remaining:t.remaining}}function Te(e){let t=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(e)?.[1];return t!==void 0&&/^source[ \t]*:[ \t]*(?:gbrainx|"gbrainx"|'gbrainx')[ \t]*(?:#.*)?$/m.test(t)}function Ee(e){if(e.class===`purchased`||Te(e.markdown))return`purchased`;let t=D(e.markdown),n=e=>e!==`HOME_PATH`&&e!==`GBRAIN_PATH`&&e!==`SOURCE`;if(t.scrubbed.some(({kind:e})=>n(e))||t.changes.some(({kind:e,before:t})=>(e===`SOURCE`||e===`GBRAIN_PATH`)&&D(e===`GBRAIN_PATH`?t.replace(/^~[\\/]\.gbrain[\\/]?/i,``):t).scrubbed.some(e=>n(e.kind))))return`secret`;let r=[...e.markdown.matchAll(/\+?\d[\d ()-]*/g)].some(t=>{let n=t[0].trimEnd(),r=n.length;for(;r>0&&(n[r-1]===`-`||n[r-1]===`(`);)r--;n=n.slice(0,r).trimEnd();let i=e.markdown[t.index-1]??``,a=e.markdown[t.index+n.length]??``,o=n.replace(/\D/g,``).length;return!/[A-Za-z0-9-]/.test(i)&&!/[A-Za-z0-9-]/.test(a)&&!/^\d{4}-\d{2}-\d{2}$/.test(n)&&/[ ()+-]/.test(n)&&o>=9&&o<=15});return/^customer-/i.test(e.id)||r?`customer`:/standup|1on1|oncall|retro|休暇/i.test(`${e.id}\n${e.markdown}`)?`personal`:`expertise`}function De(e){return e.filter(({name:e})=>/\.md$/i.test(e)).map(({name:e,markdown:t})=>{let n=e.split(/[\\/]/).pop().replace(/\.md$/i,``),r={id:n,title:/^#\s+(.+)$/m.exec(t)?.[1].trim()||n,markdown:t,links:[...t.matchAll(/\[\[([^\][|]+)(?:\|[^\][]*)?\]\]/g)].map(e=>e[1].trim()),class:`expertise`,keep:!0};return r.class=Ee(r),r.keep=r.class===`expertise`,r})}var G=class extends Error{issues;constructor(e,t=`Static evaluation failed`){super(t),this.issues=e,this.name=`StaticEvaluationError`}};function Oe(e,t){if(!t.staticEvaluation||!Array.isArray(t.staticEvaluation.testNames)||!Array.isArray(t.staticEvaluation.testCode)||!Array.isArray(t.staticEvaluation.keywords)||!t.staticEvaluation.distilled)throw new G([{code:`invalid_input`}],`Static evaluation input is required`);let{testNames:n,testCode:r,keywords:i}=t.staticEvaluation;if(![...n,...r].some(e=>typeof e==`string`&&e.trim())||[...n,...r].some(e=>typeof e!=`string`))throw new G([{code:`invalid_input`}],`Static evaluation input is required`);let a=t.errorSignatures.map(e=>e.trim()).filter(Boolean);if(!a.length)throw Error(`At least one error signature is required`);if(!t.title.trim())throw Error(`A title is required`);let o=14695981039346656037n;for(let e of t.title)o^=BigInt(e.codePointAt(0)),o=BigInt.asUintN(64,o*1099511628211n);let s=t.title.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)||`pack-${o.toString(36)}`,c=new Set(t.existingIds??[]),l=s;for(let e=2;c.has(l);e++)l=`${s}-${e}`;if(typeof t.eval!=`object`||t.eval===null||Object.keys(t.eval).sort().join(`,`)!==`recorded,with,without`||typeof t.eval.without!=`string`||typeof t.eval.with!=`string`||t.eval.recorded!==!0)throw Error(`Invalid evaluation`);if(t.author!==void 0&&t.author!==`you`&&t.author!==`seed`)throw Error(`Invalid author`);let u=t.priceUsd===void 0?.5:t.priceUsd;if(!Number.isFinite(u)||u<0)throw Error(`Invalid price`);let d=e.filter(e=>e.keep&&e.class!==`purchased`&&!Te(e.markdown));if(!d.length)throw Error(`At least one kept page is required`);let f=new Set(d.map(e=>e.id)),p=E(e.filter(e=>!f.has(e.id)),d.map(e=>e.markdown)),m={terms:[...new Set([...p.terms,...t.forbiddenDictionary?.terms??[]])],shared:[...new Set([...p.shared,...t.forbiddenDictionary?.shared??[]])]},h=e=>e.replace(/\[REDACTED_([A-Z_]+)_\d+\]/g,(e,t)=>t===`NAME`?e:`[REDACTED_${t}]`),g=e=>{let t=D(e,m);return{...t,markdown:h(t.markdown)}},_=(e,t,n)=>{if(!t)return;let r=[];throw D(e,m).changes.some(({kind:e})=>e===`NAME`)&&r.push({code:`forbidden_term`,location:n}),(k(e)>0||!r.length)&&r.push({code:`rescan`,location:n}),new G(r,`Sensitive data remains after scrubbing`)},v=()=>({generated:new Set,existing:new Set}),y=(e,t,n)=>{for(let n of t.matchAll(/\[REDACTED_[A-Z_]+(?:_\d+)?\]|~\//g))e.existing.add(h(n[0]));for(let t of n)e.generated.add(t.kind===`HOME_PATH`?`~/`:h(t.after))},b=[t.title,t.version,t.domain,...t.errorSignatures,t.eval.without,t.eval.with,t.createdAt,...d.map(e=>e.id)],x=[];if(b.some(e=>D(e,m).changes.some(({kind:e})=>e===`NAME`))&&x.push({code:`forbidden_term`,location:`metadata`}),b.some(e=>we(e).scrubbed.length>0)&&x.push({code:`rescan`,location:`metadata`}),x.length)throw new G(x,`Sensitive data in pack metadata`);let S=new Map(d.map(e=>[e.id,e]));if(S.size!==d.length)throw Error(`Duplicate page id`);let C=[...S.keys()],w=[],T=new Set;for(let e of d){let t=[e];for(;t.length;){let e=t.pop();if(!T.has(e.id)){T.add(e.id),w.push(e);for(let n=e.links.length-1;n>=0;n--){let r=ie(e.links[n],C),i=r===void 0?void 0:S.get(r);i&&t.push(i)}}}}let O=g(`${w.map(e=>`## [[${e.id}]]\n\n${e.markdown}`).join(`
34
88
 
35
89
  `)}\n\n## Sources\n\n${w.map(e=>`- [[${e.id}]]`).join(`
36
90
  `)}`);_(O.markdown,O.remaining,`markdown`);let A=new Map,ee=w.map(e=>{let t=g(e.markdown);_(t.markdown,t.remaining,{pageId:e.id});let n=v();return y(n,e.markdown,t.changes),A.set(e.id,n),{id:e.id,markdown:t.markdown}}),te=[`symptom`,`cause`,`fix`,`avoid`,`verify`],j=t.staticEvaluation.distilled,M=new Set(ae(w).filter(e=>e.class===`expertise`||e.class===`personal`).map(e=>e.id));if(!j.fields||!Array.isArray(j.errorSignatures)||a.join(`
37
91
  `)!==j.errorSignatures.join(`
38
- `))throw new G([{code:`invalid_input`}]);let ne={},re=v(),N=[];for(let e of te)Array.isArray(j.fields[e])?ne[e]=j.fields[e].flatMap(e=>{if(!e||typeof e.text!=`string`||typeof e.sourceId!=`string`)return N.push({code:`invalid_input`}),[];if(!M.has(e.sourceId))return N.push({code:`citations`}),[];let t=g(e.text);return _(t.markdown,t.remaining,`summary`),y(re,e.text,t.changes),[{text:t.markdown,sourceId:e.sourceId}]}):N.push({code:`invalid_input`});if(N.length)throw new G(N.filter((e,t)=>N.findIndex(t=>t.code===e.code)===t));let P={fields:ne,errorSignatures:a,sourceIds:[...M],nodes:w.map(({id:e,links:t})=>({id:e,links:t.map(e=>ie(e,C)??e)}))};for(;z(P).length>2e3;){let e=te.flatMap(e=>P.fields[e]).reduce((e,t)=>e.text.length>=t.text.length?e:t);if(e.text.length<=1)throw new G([{code:`length`}]);let t=Math.max(1,e.text.length-(z(P).length-2e3)-1);/[\uD800-\uDBFF]/.test(e.text[t-1])&&t--;for(let n of e.text.matchAll(/\[REDACTED_[A-Z_]+(?:_\d+)?\]|~\//g))n.index<t&&n.index+n[0].length>t&&(t=n.index);e.text=e.text.slice(0,t)+(t<e.text.length-1?`…`:``)}let F=z(P),I=[...n,...r].filter(e=>e.trim()),L=le({pack:P,testNames:n,testCode:r,dictionary:m}),R=[],oe=ce(P).connected;oe||R.push({code:`connected`}),!L.format&&(oe||!te.every(e=>P.fields[e].some(({text:e})=>!!e.trim()))||a.length<3||a.length>5||a.some(e=>!e.trim()||/[\d\\/]/.test(e)))&&R.push({code:`format`}),L.citations||R.push({code:`citations`}),L.length||R.push({code:`length`}),L.copying||R.push({code:`summary_copying`,location:`summary`}),(i.length<2||i.length>3)&&R.push({code:`keyword_count`});let se=i.filter(e=>typeof e==`string`&&e.trim());se.length!==i.length&&R.push({code:`keyword_invalid`}),se.length&&!ue(F,se).passed&&R.push({code:`keyword_missing`,location:`summary`}),I.some(e=>O.markdown.includes(e))&&R.push({code:`markdown_copying`,location:`markdown`});for(let e of ee)I.some(t=>e.markdown.includes(t))&&R.push({code:`page_copying`,location:{pageId:e.id}});let de=[{text:F,location:`summary`},{text:O.markdown,location:`markdown`},...ee.map(e=>({text:e.markdown,location:{pageId:e.id}}))];for(let e of de)D(e.text,m).changes.some(({kind:e})=>e===`NAME`)&&R.push({code:`forbidden_term`,location:e.location}),k(e.text)>0&&R.push({code:`rescan`,location:e.location});if(R.length)throw new G(R);let B={id:l,title:t.title,version:t.version,domain:t.domain,errorSignatures:a,nodes:w.map(e=>e.id),markdown:O.markdown,summary:F,pages:ee,scrubbed:O.scrubbed,eval:t.eval,priceUsd:u,author:t.author??`you`,createdAt:t.createdAt};return{pack:B,redactions:Ae(B,re,A)}}function Oe(e,t){return De(e,t).pack}function ke(e,t){return De(e,t).redactions}function Ae(e,t,n){let r=[],i=(e,t,n)=>{for(let i of e.matchAll(/\[REDACTED(?:_[A-Z0-9_]*)?\]?|~\//g)){let e=i[0],a=n.generated.has(e),o=n.existing.has(e);if(e===`~/`&&!a)continue;let s=a&&o?`ambiguous`:a?`generated`:`existing`;if(e===`~/`)r.push({location:t,symbol:e,kind:`HOME_PATH`,origin:s});else{let n=/^\[REDACTED_([A-Z_]+?)(?:_\d+)?\]$/.exec(e);if(!n)throw Error(`Incomplete redaction marker`);r.push({location:t,symbol:e,kind:n[1],origin:s})}}};i(e.summary,`summary`,t);for(let t of e.pages)i(t.markdown,{pageId:t.id},n.get(t.id));return r}function je(e){let t=e.toLowerCase().replace(/\S+/g,e=>/[\\/]/.test(e)?` `:e),n=new Set(t.match(/[a-z]+/g)??[]);for(let e of t.matchAll(/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]+/gu)){let t=Array.from(e[0]);t.length===1&&n.add(t[0]);for(let e=0;e<t.length-1;e++)n.add(t[e]+t[e+1])}return n}function Me(e,t){if(!e.size||!t.size)return 0;let n=0;for(let r of e)t.has(r)&&n++;return n/(e.size+t.size-n)}function Ne(e,t){let n=je(e),r=new Set(t.ledger.map(e=>e.packId));return t.packs.map(e=>({id:e.id,title:e.title,description:e.domain,priceUsd:e.priceUsd,owned:r.has(e.id),score:Math.max(0,...[...e.errorSignatures,e.title,...e.nodes].map(e=>Me(n,je(e))))})).filter(({score:e})=>e>=.2).sort((e,t)=>t.score-e.score).slice(0,5)}function K(){let e={scrubbed:[],eval:{without:`Not recorded`,with:`Not recorded`,recorded:!0},author:`seed`,createdAt:`2026-01-01T00:00:00.000Z`};return{version:1,rev:0,brain:{pages:[]},wallet:{buyerUsd:10,perPurchaseCapUsd:1,sessionCapUsd:3},ledger:[],sessions:[],packs:[{...e,id:`stripe-webhook-signature-errors`,title:`Stripe Webhook Signature Errors`,version:`v3`,domain:`payments`,errorSignatures:[`webhook signature verification failed`,`raw body parsing`],nodes:[`stripe-webhook-signature`,`raw-body-parsing`],markdown:`Verify the webhook signature against the raw request body.`,summary:`Verify the webhook signature against the raw request body.`,pages:[{id:`stripe-webhook-signature`,markdown:`Verify the webhook signature against the raw request body.`},{id:`raw-body-parsing`,markdown:`Keep the raw request body for verification.`}],priceUsd:.5},{...e,id:`postgres-zero-downtime-migrations`,title:`Postgres Zero-Downtime Migrations`,version:`v2`,domain:`data`,errorSignatures:[`database migration downtime`,`add column safely`],nodes:[`pg-add-column-safely`],markdown:`Add columns in stages and migrate data before enforcing constraints.`,summary:`Add columns in stages and migrate data before enforcing constraints.`,pages:[{id:`pg-add-column-safely`,markdown:`Add columns in stages and migrate data before enforcing constraints.`}],priceUsd:.8}]}}function Pe(e){let t=`${e.domain} の専門知識。`;if(t.length+8>1e3)throw Error(`Domain is too long`);let n=e.errorSignatures.slice(0,2).join(`、`).slice(0,1e3-t.length-8);/[\uD800-\uDBFF]$/.test(n)&&(n=n.slice(0,-1));let r=t+n+` のときに使う。`;return Ce(`---\nname: ${JSON.stringify(e.id)}\ndescription: ${JSON.stringify(r)}\n---\n\n${e.markdown}\n`).markdown}function Fe(e){let t=[];for(let n of e){let e=n.codePointAt(0);e>=55296&&e<=57343&&(e=65533),e<128?t.push(e):e<2048?t.push(192|e>>6,128|e&63):e<65536?t.push(224|e>>12,128|e>>6&63,128|e&63):t.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|e&63)}return new Uint8Array(t)}function Ie(e){let t=0xffffffff;for(let n of e){t^=n;for(let e=0;e<8;e++)t=t>>>1^-(t&1)&0xedb88320}return(t^0xffffffff)>>>0}function Le(e){if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e.id))throw Error(`Invalid pack id`);let t=Fe(`.claude/skills/${e.id}/SKILL.md`),n=Fe(Pe(e));if(t.length>65535||n.length>0xffffffff-t.length-76)throw Error(`Skill is too large for ZIP`);let r=30+t.length+n.length,i=46+t.length,a=new Uint8Array(r+i+22),o=new DataView(a.buffer),s=(e,t)=>o.setUint16(e,t,!0),c=(e,t)=>o.setUint32(e,t,!0),l=Ie(n);c(0,67324752),s(4,20),s(6,2048),s(12,33),c(14,l),c(18,n.length),c(22,n.length),s(26,t.length),a.set(t,30),a.set(n,30+t.length);let u=r;c(u,33639248),s(u+4,20),s(u+6,20),s(u+8,2048),s(u+14,33),c(u+16,l),c(u+20,n.length),c(u+24,n.length),s(u+28,t.length),a.set(t,u+46);let d=u+i;return c(d,0x6054b50),s(d+8,1),s(d+10,1),c(d+12,i),c(d+16,r),a}var Re=()=>({problem:``,testNames:[],testCode:[],keywords:[],static:null,keyword:null}),ze={pages:[],stage:0,draft:null,title:`Stripe Double-Charge Prevention`,signature:`duplicate charge`,domain:`payments`,paragraphs:[],unconfirmed:!1,removedIsolatedCount:0,pruningPassed:!1,distilled:null,distillationCheck:null,scrub:null,evaluation:Re()};function q(e){return{...e,draft:null,distilled:null,distillationCheck:null,scrub:null,evaluation:{...e.evaluation,static:null,keyword:null}}}function Be(e,t){if(!e.distilled||!e.scrub)throw Error(`コンパイルが必要です。`);let n=new Map,r=e.pages.flatMap(t=>{let r=e.paragraphs.filter(e=>e.pageId===t.id&&e.keep);if(!r.length)return[];r.forEach((e,r)=>n.set(e.id,`${t.id}#${r+1}`));let i=r.map(e=>e.markdown).join(`
92
+ `))throw new G([{code:`invalid_input`}]);let ne={},re=v(),N=[];for(let e of te)Array.isArray(j.fields[e])?ne[e]=j.fields[e].flatMap(e=>{if(!e||typeof e.text!=`string`||typeof e.sourceId!=`string`)return N.push({code:`invalid_input`}),[];if(!M.has(e.sourceId))return N.push({code:`citations`}),[];let t=g(e.text);return _(t.markdown,t.remaining,`summary`),y(re,e.text,t.changes),[{text:t.markdown,sourceId:e.sourceId}]}):N.push({code:`invalid_input`});if(N.length)throw new G(N.filter((e,t)=>N.findIndex(t=>t.code===e.code)===t));let P={fields:ne,errorSignatures:a,sourceIds:[...M],nodes:w.map(({id:e,links:t})=>({id:e,links:t.map(e=>ie(e,C)??e)}))};for(;z(P).length>2e3;){let e=te.flatMap(e=>P.fields[e]).reduce((e,t)=>e.text.length>=t.text.length?e:t);if(e.text.length<=1)throw new G([{code:`length`}]);let t=Math.max(1,e.text.length-(z(P).length-2e3)-1);/[\uD800-\uDBFF]/.test(e.text[t-1])&&t--;for(let n of e.text.matchAll(/\[REDACTED_[A-Z_]+(?:_\d+)?\]|~\//g))n.index<t&&n.index+n[0].length>t&&(t=n.index);e.text=e.text.slice(0,t)+(t<e.text.length-1?`…`:``)}let F=z(P),I=[...n,...r].filter(e=>e.trim()),L=le({pack:P,testNames:n,testCode:r,dictionary:m}),R=[],oe=ce(P).connected;oe||R.push({code:`connected`}),!L.format&&(oe||!te.every(e=>P.fields[e].some(({text:e})=>!!e.trim()))||a.length<3||a.length>5||a.some(e=>!e.trim()||/[\d\\/]/.test(e)))&&R.push({code:`format`}),L.citations||R.push({code:`citations`}),L.length||R.push({code:`length`}),L.copying||R.push({code:`summary_copying`,location:`summary`}),(i.length<2||i.length>3)&&R.push({code:`keyword_count`});let se=i.filter(e=>typeof e==`string`&&e.trim());se.length!==i.length&&R.push({code:`keyword_invalid`}),se.length&&!ue(F,se).passed&&R.push({code:`keyword_missing`,location:`summary`}),I.some(e=>O.markdown.includes(e))&&R.push({code:`markdown_copying`,location:`markdown`});for(let e of ee)I.some(t=>e.markdown.includes(t))&&R.push({code:`page_copying`,location:{pageId:e.id}});let de=[{text:F,location:`summary`},{text:O.markdown,location:`markdown`},...ee.map(e=>({text:e.markdown,location:{pageId:e.id}}))];for(let e of de)D(e.text,m).changes.some(({kind:e})=>e===`NAME`)&&R.push({code:`forbidden_term`,location:e.location}),k(e.text)>0&&R.push({code:`rescan`,location:e.location});if(R.length)throw new G(R);let B={id:l,title:t.title,version:t.version,domain:t.domain,errorSignatures:a,nodes:w.map(e=>e.id),markdown:O.markdown,summary:F,pages:ee,scrubbed:O.scrubbed,eval:t.eval,priceUsd:u,author:t.author??`you`,createdAt:t.createdAt};return{pack:B,redactions:je(B,re,A)}}function ke(e,t){return Oe(e,t).pack}function Ae(e,t){return Oe(e,t).redactions}function je(e,t,n){let r=[],i=(e,t,n)=>{for(let i of e.matchAll(/\[REDACTED(?:_[A-Z0-9_]*)?\]?|~\//g)){let e=i[0],a=n.generated.has(e),o=n.existing.has(e);if(e===`~/`&&!a)continue;let s=a&&o?`ambiguous`:a?`generated`:`existing`;if(e===`~/`)r.push({location:t,symbol:e,kind:`HOME_PATH`,origin:s});else{let n=/^\[REDACTED_([A-Z_]+?)(?:_\d+)?\]$/.exec(e);if(!n)throw Error(`Incomplete redaction marker`);r.push({location:t,symbol:e,kind:n[1],origin:s})}}};i(e.summary,`summary`,t);for(let t of e.pages)i(t.markdown,{pageId:t.id},n.get(t.id));return r}function Me(e){let t=e.toLowerCase().replace(/\S+/g,e=>/[\\/]/.test(e)?` `:e),n=new Set(t.match(/[a-z]+/g)??[]);for(let e of t.matchAll(/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]+/gu)){let t=Array.from(e[0]);t.length===1&&n.add(t[0]);for(let e=0;e<t.length-1;e++)n.add(t[e]+t[e+1])}return n}function Ne(e,t){if(!e.size||!t.size)return 0;let n=0;for(let r of e)t.has(r)&&n++;return n/(e.size+t.size-n)}function Pe(e,t){let n=Me(e),r=new Set(t.ledger.map(e=>e.packId));return t.packs.map(e=>({id:e.id,title:e.title,description:e.domain,priceUsd:e.priceUsd,owned:r.has(e.id),score:Math.max(0,...[...e.errorSignatures,e.title,...e.nodes].map(e=>Ne(n,Me(e))))})).filter(({score:e})=>e>=.2).sort((e,t)=>t.score-e.score).slice(0,5)}function K(){let e={scrubbed:[],eval:{without:`Not recorded`,with:`Not recorded`,recorded:!0},author:`seed`,createdAt:`2026-01-01T00:00:00.000Z`};return{version:1,rev:0,brain:{pages:[]},wallet:{buyerUsd:10,perPurchaseCapUsd:1,sessionCapUsd:3},ledger:[],sessions:[],packs:[{...e,id:`stripe-webhook-signature-errors`,title:`Stripe Webhook Signature Errors`,version:`v3`,domain:`payments`,errorSignatures:[`webhook signature verification failed`,`raw body parsing`],nodes:[`stripe-webhook-signature`,`raw-body-parsing`],markdown:`Verify the webhook signature against the raw request body.`,summary:`Verify the webhook signature against the raw request body.`,pages:[{id:`stripe-webhook-signature`,markdown:`Verify the webhook signature against the raw request body.`},{id:`raw-body-parsing`,markdown:`Keep the raw request body for verification.`}],priceUsd:.5},{...e,id:`postgres-zero-downtime-migrations`,title:`Postgres Zero-Downtime Migrations`,version:`v2`,domain:`data`,errorSignatures:[`database migration downtime`,`add column safely`],nodes:[`pg-add-column-safely`],markdown:`Add columns in stages and migrate data before enforcing constraints.`,summary:`Add columns in stages and migrate data before enforcing constraints.`,pages:[{id:`pg-add-column-safely`,markdown:`Add columns in stages and migrate data before enforcing constraints.`}],priceUsd:.8},structuredClone(de)]}}function Fe(e){let t=`${e.domain} の専門知識。`;if(t.length+8>1e3)throw Error(`Domain is too long`);let n=e.errorSignatures.slice(0,2).join(`、`).slice(0,1e3-t.length-8);/[\uD800-\uDBFF]$/.test(n)&&(n=n.slice(0,-1));let r=t+n+` のときに使う。`;return we(`---\nname: ${JSON.stringify(e.id)}\ndescription: ${JSON.stringify(r)}\n---\n\n${e.markdown}\n`).markdown}function Ie(e){let t=[];for(let n of e){let e=n.codePointAt(0);e>=55296&&e<=57343&&(e=65533),e<128?t.push(e):e<2048?t.push(192|e>>6,128|e&63):e<65536?t.push(224|e>>12,128|e>>6&63,128|e&63):t.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|e&63)}return new Uint8Array(t)}function Le(e){let t=0xffffffff;for(let n of e){t^=n;for(let e=0;e<8;e++)t=t>>>1^-(t&1)&0xedb88320}return(t^0xffffffff)>>>0}function Re(e){if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e.id))throw Error(`Invalid pack id`);let t=Ie(`.claude/skills/${e.id}/SKILL.md`),n=Ie(Fe(e));if(t.length>65535||n.length>0xffffffff-t.length-76)throw Error(`Skill is too large for ZIP`);let r=30+t.length+n.length,i=46+t.length,a=new Uint8Array(r+i+22),o=new DataView(a.buffer),s=(e,t)=>o.setUint16(e,t,!0),c=(e,t)=>o.setUint32(e,t,!0),l=Le(n);c(0,67324752),s(4,20),s(6,2048),s(12,33),c(14,l),c(18,n.length),c(22,n.length),s(26,t.length),a.set(t,30),a.set(n,30+t.length);let u=r;c(u,33639248),s(u+4,20),s(u+6,20),s(u+8,2048),s(u+14,33),c(u+16,l),c(u+20,n.length),c(u+24,n.length),s(u+28,t.length),a.set(t,u+46);let d=u+i;return c(d,0x6054b50),s(d+8,1),s(d+10,1),c(d+12,i),c(d+16,r),a}var ze=()=>({problem:``,testNames:[],testCode:[],keywords:[],static:null,keyword:null}),Be={pages:[],stage:0,draft:null,title:`Stripe Double-Charge Prevention`,signature:`duplicate charge`,domain:`payments`,paragraphs:[],unconfirmed:!1,removedIsolatedCount:0,pruningPassed:!1,distilled:null,distillationCheck:null,scrub:null,evaluation:ze()};function q(e){return{...e,draft:null,distilled:null,distillationCheck:null,scrub:null,evaluation:{...e.evaluation,static:null,keyword:null}}}function Ve(e,t){if(!e.distilled||!e.scrub)throw Error(`コンパイルが必要です。`);let n=new Map,r=e.pages.flatMap(t=>{let r=e.paragraphs.filter(e=>e.pageId===t.id&&e.keep);if(!r.length)return[];r.forEach((e,r)=>n.set(e.id,`${t.id}#${r+1}`));let i=r.map(e=>e.markdown).join(`
39
93
 
40
- `);return[{...t,markdown:i,links:Ee([{name:`${t.id}.md`,markdown:i}])[0].links,keep:!0}]}),i=Object.fromEntries(Object.entries(e.distilled.fields).map(([e,t])=>[e,t.map(e=>({...e,sourceId:n.get(e.sourceId)??``}))])),a={...e.distilled,fields:i};return{pages:r,input:{title:e.title,domain:e.domain,version:`v1`,errorSignatures:a.errorSignatures,eval:{without:`事前に記録した結果`,with:`事前に記録した結果`,recorded:!0},createdAt:t,forbiddenDictionary:e.scrub.dictionary,staticEvaluation:{distilled:a,testNames:e.evaluation.testNames,testCode:[...e.evaluation.testCode,...e.evaluation.problem.split(/\r?\n/)],keywords:e.evaluation.keywords}}}}function Ve(e,t){let{pages:n,input:r}=Be(e,t);return Oe(n,r)}function J(e,t){let n=e.paragraphs.filter(e=>e.keep),r=new Set(n.map(e=>e.pageId)),i=E(e.pages.filter(e=>!r.has(e.id)),n.map(e=>e.markdown)),a=z(t),o=D(a,i),s=Object.fromEntries(Object.entries(t.fields).map(([e,t])=>[e,t.map(e=>({...e,text:D(e.text,i).markdown}))])),c=le({pack:{...t,fields:s,errorSignatures:t.errorSignatures.map(e=>D(e,i).markdown)},testNames:e.evaluation.testNames,testCode:[...e.evaluation.testCode,...e.evaluation.problem.split(/\r?\n/)],dictionary:i}),l=[...e.evaluation.testNames,...e.evaluation.testCode].some(e=>e.trim());return{...e,draft:null,distilled:t,distillationCheck:ce(t),scrub:{dictionary:i,result:o,before:a,confirmed:!1,adversarialReview:`not-applicable`},evaluation:{...e.evaluation,static:l?c:{...c,copying:!1,passed:!1},keyword:ue(o.markdown,e.evaluation.keywords)}}}function He(e,t){switch(t.type){case`load`:return{...q(e),pages:t.pages,paragraphs:[],unconfirmed:!1,removedIsolatedCount:0,pruningPassed:!1,evaluation:Re(),stage:1};case`classify`:{let t=e.pages.map(e=>{let t=Te(e);return{...e,class:t,keep:t===`expertise`}}),n=ae(t);return{...q(e),pages:t,paragraphs:n,unconfirmed:F(n),removedIsolatedCount:0,pruningPassed:I(n),stage:2}}case`review`:{if(!e.paragraphs.some(e=>e.id===t.id))return e;let n=e.paragraphs.map(e=>e.id===t.id?{...e,keep:t.keep,confirmed:!0}:e);return{...q(e),paragraphs:n,unconfirmed:F(n),removedIsolatedCount:0,pruningPassed:I(n),stage:2}}case`compile`:{if(!I(e.paragraphs)||!e.paragraphs.some(e=>e.keep))return e;let t=new Set(e.paragraphs.filter(e=>e.keep).map(e=>e.pageId)),n=e.pages.map(n=>{let r=e.paragraphs.filter(e=>e.pageId===n.id&&e.keep).map(e=>e.markdown).join(`
94
+ `);return[{...t,markdown:i,links:De([{name:`${t.id}.md`,markdown:i}])[0].links,keep:!0}]}),i=Object.fromEntries(Object.entries(e.distilled.fields).map(([e,t])=>[e,t.map(e=>({...e,sourceId:n.get(e.sourceId)??``}))])),a={...e.distilled,fields:i};return{pages:r,input:{title:e.title,domain:e.domain,version:`v1`,errorSignatures:a.errorSignatures,eval:{without:`事前に記録した結果`,with:`事前に記録した結果`,recorded:!0},createdAt:t,forbiddenDictionary:e.scrub.dictionary,staticEvaluation:{distilled:a,testNames:e.evaluation.testNames,testCode:[...e.evaluation.testCode,...e.evaluation.problem.split(/\r?\n/)],keywords:e.evaluation.keywords}}}}function He(e,t){let{pages:n,input:r}=Ve(e,t);return ke(n,r)}function J(e,t){let n=e.paragraphs.filter(e=>e.keep),r=new Set(n.map(e=>e.pageId)),i=E(e.pages.filter(e=>!r.has(e.id)),n.map(e=>e.markdown)),a=z(t),o=D(a,i),s=Object.fromEntries(Object.entries(t.fields).map(([e,t])=>[e,t.map(e=>({...e,text:D(e.text,i).markdown}))])),c=le({pack:{...t,fields:s,errorSignatures:t.errorSignatures.map(e=>D(e,i).markdown)},testNames:e.evaluation.testNames,testCode:[...e.evaluation.testCode,...e.evaluation.problem.split(/\r?\n/)],dictionary:i}),l=[...e.evaluation.testNames,...e.evaluation.testCode].some(e=>e.trim());return{...e,draft:null,distilled:t,distillationCheck:ce(t),scrub:{dictionary:i,result:o,before:a,confirmed:!1,adversarialReview:`not-applicable`},evaluation:{...e.evaluation,static:l?c:{...c,copying:!1,passed:!1},keyword:ue(o.markdown,e.evaluation.keywords)}}}function Ue(e,t){switch(t.type){case`load`:return{...q(e),pages:t.pages,paragraphs:[],unconfirmed:!1,removedIsolatedCount:0,pruningPassed:!1,evaluation:ze(),stage:1};case`classify`:{let t=e.pages.map(e=>{let t=Ee(e);return{...e,class:t,keep:t===`expertise`}}),n=ae(t);return{...q(e),pages:t,paragraphs:n,unconfirmed:F(n),removedIsolatedCount:0,pruningPassed:I(n),stage:2}}case`review`:{if(!e.paragraphs.some(e=>e.id===t.id))return e;let n=e.paragraphs.map(e=>e.id===t.id?{...e,keep:t.keep,confirmed:!0}:e);return{...q(e),paragraphs:n,unconfirmed:F(n),removedIsolatedCount:0,pruningPassed:I(n),stage:2}}case`compile`:{if(!I(e.paragraphs)||!e.paragraphs.some(e=>e.keep))return e;let t=new Set(e.paragraphs.filter(e=>e.keep).map(e=>e.pageId)),n=e.pages.map(n=>{let r=e.paragraphs.filter(e=>e.pageId===n.id&&e.keep).map(e=>e.markdown).join(`
41
95
 
42
- `);return{...n,keep:t.has(n.id),links:Ee([{name:`${n.id}.md`,markdown:r}])[0].links}}),r=E(e.pages.filter(e=>!t.has(e.id)),e.paragraphs.filter(e=>e.keep).map(e=>e.markdown));return J({...e,pages:n,stage:3},oe(n,e.paragraphs,r))}case`select-connected`:{if(!e.distilled)return e;let t=new Set(e.distillationCheck?.isolatedPageIds??[]);if(!t.size)return e;let n=e.paragraphs.map(e=>t.has(e.pageId)?{...e,keep:!1,confirmed:!0}:e),r={...e,paragraphs:n,removedIsolatedCount:t.size,unconfirmed:F(n),pruningPassed:I(n)};return n.some(e=>e.keep)?He(r,{type:`compile`}):{...q(r),pages:e.pages.map(e=>t.has(e.id)?{...e,keep:!1}:e),stage:2}}case`distill-field`:return e.distilled?J(e,{...e.distilled,fields:{...e.distilled.fields,[t.field]:t.entries}}):e;case`signatures`:return e.distilled?J(e,{...e.distilled,errorSignatures:t.values}):e;case`evaluation-input`:{let n={...e,evaluation:{...e.evaluation,problem:t.problem,testNames:t.testNames,testCode:t.testCode,keywords:t.keywords}};return n.distilled?J(n,n.distilled):n}case`confirm-scrub`:if(!e.scrub||e.scrub.result.remaining!==0)return e;try{let{pages:t,input:n}=Be(e,new Date().toISOString());return ke(t,n),{...e,scrub:{...e.scrub,confirmed:!0}}}catch{return e}case`scrub`:return{...e,stage:3};case`field`:return{...e,[t.field]:t.value,draft:null,stage:3,scrub:e.scrub&&{...e.scrub,confirmed:!1}};case`draft`:return!e.pruningPassed||!e.distillationCheck?.passed||!e.scrub?.confirmed||e.scrub.result.remaining!==0||!e.evaluation.problem.trim()||!e.evaluation.static?.passed||e.evaluation.keywords.length<2||e.evaluation.keywords.length>3||!e.evaluation.keyword?.passed?e:{...e,draft:t.draft,stage:4};case`reset`:return{...ze,title:e.title,signature:e.signature,domain:e.domain}}}var Y=r(),Ue={invalid_input:{ja:`テスト名かテストコードを入力してください。`,en:`Enter a test name or test code.`},format:{ja:`蒸留の5項目と3〜5個の検索語を確認してください。`,en:`Complete the five distilled fields and provide 3–5 search terms.`},connected:{ja:`ページ間のリンクを確認してください。`,en:`Check the links between pages.`},citations:{ja:`各項目の出典を確認してください。`,en:`Check the source of each field.`},length:{ja:`蒸留した内容を短くしてください。`,en:`Shorten the distilled content.`},summary_copying:{ja:`要約にテスト名やコードが含まれています。`,en:`Remove copied test names or code from the summary.`},page_copying:{ja:`ページにテスト名やコードが含まれています。`,en:`Remove copied test names or code from the page.`},markdown_copying:{ja:`出品本文にテスト名やコードが含まれています。`,en:`Remove copied test names or code from the pack text.`},keyword_count:{ja:`合言葉を2〜3個入力してください。`,en:`Enter 2–3 keywords.`},keyword_invalid:{ja:`空でない合言葉を入力してください。`,en:`Enter non-empty keywords.`},keyword_missing:{ja:`合言葉を要約に含めてください。`,en:`Include the keywords in the summary.`},forbidden_term:{ja:`禁止語を確認してください。`,en:`Check the forbidden terms.`},rescan:{ja:`秘密情報を確認してください。`,en:`Check for sensitive information.`}};function We({state:e,lang:t,dispatch:n}){let r=(0,c.useMemo)(()=>{if(!e.distilled||!e.scrub)return null;try{return Ve(e,`2000-01-01T00:00:00.000Z`),null}catch(e){return e instanceof G?{issues:e.issues,other:``}:{issues:[],other:e instanceof Error?e.message:String(e)}}},[e]),i=e.distillationCheck?.isolatedPageIds??[];return(0,Y.jsxs)(`div`,{children:[e.removedIsolatedCount>0&&(0,Y.jsx)(`p`,{"data-testid":`removed-isolated-pages`,children:t===`ja`?`孤立したページを ${e.removedIsolatedCount} 件外しました`:`Removed ${e.removedIsolatedCount} isolated ${e.removedIsolatedCount===1?`page`:`pages`}`}),i.length>0&&(0,Y.jsxs)(`div`,{"data-testid":`isolated-pages`,children:[(0,Y.jsx)(`p`,{children:t===`ja`?`孤立したページ: ${i.length} 件`:`Isolated pages: ${i.length}`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`select-connected-pages`,onClick:()=>n({type:`select-connected`}),children:t===`ja`?`孤立したページ(${i.length} 件)を外して作り直す`:`Remove ${i.length} isolated ${i.length===1?`page`:`pages`} and rebuild`})]}),r&&(0,Y.jsxs)(`div`,{"data-testid":`evaluation-issues`,children:[r.issues.map((e,n)=>(0,Y.jsxs)(`p`,{"data-testid":`evaluation-issue-${e.code}`,children:[Ue[e.code][t],typeof e.location==`object`?` (${e.location.pageId})`:``]},`${e.code}-${n}`)),r.other&&(0,Y.jsx)(`p`,{children:r.other})]})]})}var X={background:s.white,border:`1px solid ${s.border}`,borderRadius:20,padding:20},Z={background:s.navy,color:s.white,border:0,borderRadius:999,padding:`12px 20px`,cursor:`pointer`},Ge=Object.entries(Object.assign({"../../samples/brain/acme-checkout.md":l,"../../samples/brain/aws-prod-account.md":u,"../../samples/brain/customer-8812.md":d,"../../samples/brain/oncall-rotation.md":f,"../../samples/brain/payment-retries.md":p,"../../samples/brain/standup-notes.md":m,"../../samples/brain/stripe-idempotency.md":h,"../../samples/brain/webhook-dedupe.md":g})).map(([e,t])=>({name:e,markdown:t}));async function Ke(e){if(e.isFile)return[await new Promise((t,n)=>e.file(t,n))];if(!e.isDirectory)return[];let t=e.createReader(),n=[];for(;;){let e=await new Promise((e,n)=>t.readEntries(e,n));if(!e.length)return n;for(let t of e)n.push(...await Ke(t))}}async function qe(e){return Promise.all(e.filter(e=>/\.md$/i.test(e.name)).map(async e=>({name:e.name,markdown:await e.text()})))}function Je(e,t=`en`){let[n,r]=(0,c.useReducer)(He,ze),[i,a]=(0,c.useState)(``);function o(){r({type:`reset`}),a(``)}function s(t){let n=Ee(t);if(!n.length)throw Error(`Markdown ファイルがありません。`);r({type:`load`,pages:n}),e(`${n.length} ページを読み込みました。`)}async function l(t){try{s(await qe(t))}catch(t){e(t instanceof Error?t.message:`読み込みに失敗しました。`)}}async function u(t){t.preventDefault();try{let e=Array.from(t.dataTransfer.items).map(e=>e.webkitGetAsEntry()).filter(e=>e!==null);await l(e.length?(await Promise.all(e.map(Ke))).flat():Array.from(t.dataTransfer.files))}catch(t){e(t instanceof Error?t.message:`読み込みに失敗しました。`)}}function d(){r({type:`classify`})}let f=n.pages.filter(e=>e.keep),p=f.map(e=>Ce(e.markdown)),m=p.flatMap(e=>e.scrubbed).reduce((e,t)=>e+t.count,0),h=p.reduce((e,t)=>e+t.remaining,0);function g(){a(``);try{let t=Ve(n,new Date().toISOString());r({type:`draft`,draft:t}),e(``)}catch(n){let r=n instanceof Error?n.message:`パックを作れませんでした。`;r===`Static evaluation failed`||r===`Static evaluation input is required`?(e(``),a({"Static evaluation failed":{ja:`静的検査に合格しませんでした。出典と評価入力を確認してください。`,en:`Static evaluation failed. Check the sources and evaluation inputs.`},"Static evaluation input is required":{ja:`静的検査の入力が必要です。テスト名またはテストコードを入力してください。`,en:`Static evaluation inputs are required. Enter a test name or test code.`}}[r][t])):e(r)}}function _(e,t){r({type:`field`,field:e,value:t})}return{state:n,lang:t,reset:o,load:s,loadSelected:l,drop:u,runClassify:d,kept:f,scrubCount:m,remaining:h,makePack:g,updateField:_,dispatch:r,packError:i}}function Ye({factory:e}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:t=>{e.drop(t)},style:{border:`2px dashed ${s.borderStrong}`,borderRadius:16,padding:`2rem`,background:s.background},children:[(0,Y.jsxs)(`label`,{children:[`GBrain フォルダを選択 `,(0,Y.jsx)(`input`,{style:{display:`block`,maxWidth:`100%`},ref:e=>{e?.setAttribute(`webkitdirectory`,``)},type:`file`,multiple:!0,onChange:t=>{e.loadSelected(Array.from(t.currentTarget.files??[]))}})]}),(0,Y.jsx)(`p`,{children:`ここにフォルダまたは Markdown ファイルをドロップ`}),(0,Y.jsx)(`button`,{type:`button`,style:Z,onClick:()=>e.load(Ge),children:`サンプルの GBrain で試す`})]}),e.state.stage>=1&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:`1. 読み込み`}),(0,Y.jsxs)(`p`,{children:[e.state.pages.length,` ページ`]}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.state.pages.map(e=>(0,Y.jsxs)(`span`,{style:{border:`1px solid ${e.keep?s.greenText:s.borderStrong}`,borderRadius:999,padding:`6px 10px`},children:[e.title,` (`,e.class,`)`]},e.id))}),(0,Y.jsx)(`p`,{children:(0,Y.jsx)(`button`,{type:`button`,style:Z,onClick:e.runClassify,children:`分類する`})})]})]})}function Xe({factory:e}){return e.state.stage<2?null:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:`段落の判定`}),e.state.paragraphs.map(t=>(0,Y.jsx)(`div`,{"data-testid":`paragraph-${t.id}`,style:{border:`1px solid ${s.border}`,borderRadius:10,padding:10,marginTop:8},children:(0,Y.jsxs)(`div`,{"data-testid":t.confidence<.7&&!t.confirmed?`paragraph-review-pending`:void 0,children:[(0,Y.jsx)(`code`,{children:t.id}),` · `,t.reason,(0,Y.jsx)(`p`,{children:t.markdown}),(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":t.keep,onClick:()=>e.dispatch({type:`review`,id:t.id,keep:!0}),children:`残す`}),` `,(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":!t.keep,onClick:()=>e.dispatch({type:`review`,id:t.id,keep:!1}),children:`外す`})]})},t.id)),(0,Y.jsxs)(`p`,{children:[`保持 `,e.state.paragraphs.filter(e=>e.keep).length,` 段落`]}),(0,Y.jsx)(`button`,{type:`button`,style:Z,disabled:!e.state.pruningPassed||!e.state.paragraphs.some(e=>e.keep),onClick:()=>e.dispatch({type:`compile`}),children:`コンパイル&検証`})]})}function Ze({factory:e}){if(e.state.stage<3)return null;let t=e.state.scrub;if(!t)return null;let n=null;try{let{pages:t,input:r}=Be(e.state,new Date().toISOString());n=ke(t,r)}catch{}let r=e.lang===`ja`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:r?`秘密情報の除去`:`Redaction review`}),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:r?`出品物の伏せ字 ${n.length} 件`:`${n.length} redactions in the pack`}),(0,Y.jsx)(`ul`,{children:n.map((e,t)=>(0,Y.jsxs)(`li`,{children:[e.location===`summary`?r?`要約`:`Summary`:`${r?`ページ`:`Page`} ${e.location.pageId}`,` · `,(0,Y.jsx)(`code`,{children:e.symbol}),` · `,e.kind,` · `,e.origin===`ambiguous`?r?`既存か生成か判別できません`:`Cannot determine whether existing or generated`:e.origin===`existing`?r?`既存`:`Existing`:r?`生成`:`Generated`]},t))})]}):(0,Y.jsx)(`p`,{role:`status`,children:r?`パックの入力と検査を完了すると伏せ字を確認できます。現在は確認できません。`:`Complete pack inputs and checks to review redactions. Review is currently unavailable.`}),(0,Y.jsx)(`button`,{type:`button`,disabled:n===null||t.result.remaining!==0||t.confirmed,onClick:()=>e.dispatch({type:`confirm-scrub`}),children:r?`確認した`:`Confirm`})]})}function Qe({factory:e,ready:t,publish:n}){let{state:r}=e;return r.stage<3?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`パック`}),e.packError&&(0,Y.jsx)(`p`,{role:`alert`,children:e.packError}),(0,Y.jsxs)(`label`,{children:[`パック名 `,(0,Y.jsx)(`input`,{value:r.title,onChange:t=>e.updateField(`title`,t.target.value)})]}),(0,Y.jsx)(`br`,{}),(0,Y.jsxs)(`label`,{children:[`ドメイン `,(0,Y.jsx)(`input`,{value:r.domain,onChange:t=>e.updateField(`domain`,t.target.value)})]}),(0,Y.jsx)(`br`,{}),(0,Y.jsxs)(`label`,{children:[`エラー文の例 `,(0,Y.jsx)(`input`,{value:r.signature,onChange:t=>e.updateField(`signature`,t.target.value)})]}),(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`button`,{type:`button`,style:Z,disabled:!r.pruningPassed||!r.distillationCheck?.passed||!r.scrub?.confirmed||!r.evaluation.static?.passed||!r.evaluation.keyword?.passed||!r.evaluation.problem.trim(),onClick:e.makePack,children:`パックを作る`}),(0,Y.jsx)(We,{state:r,lang:e.lang,dispatch:e.dispatch}),r.stage>=4&&r.draft&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{children:[r.draft.title,` · `,r.draft.nodes.length,` ページ`]}),(0,Y.jsx)(`button`,{type:`button`,style:Z,onClick:n,disabled:!t,children:`出品する`})]})]})}function $e({factory:e,ready:t,publish:n}){let{state:r,dispatch:i}=e,a=[`symptom`,`cause`,`fix`,`avoid`,`verify`],o={symptom:`症状`,cause:`原因`,fix:`直し方`,avoid:`避けること`,verify:`確認方法`},c=r.evaluation;function l(e){let t={...c,...e};i({type:`evaluation-input`,problem:t.problem,testNames:t.testNames,testCode:t.testCode,keywords:t.keywords})}return(0,Y.jsxs)(`section`,{"aria-labelledby":`factory`,style:{color:s.navy,padding:`28px 24px 48px`,background:s.background},children:[(0,Y.jsx)(`h2`,{id:`factory`,children:`ファクトリー`}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(280px,1fr))`,gap:20},children:[(0,Y.jsxs)(`div`,{style:X,children:[(0,Y.jsx)(Ye,{factory:e}),(0,Y.jsx)(Xe,{factory:e})]}),(0,Y.jsxs)(`div`,{style:X,children:[(0,Y.jsx)(`h3`,{children:`4ゲート`}),(0,Y.jsx)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:8,flexWrap:`wrap`},children:[`枝刈り`,`蒸留`,`秘密除去`,`効果測定`].map((e,t)=>(0,Y.jsxs)(`div`,{style:{textAlign:`center`,flex:`1 1 70px`},children:[(0,Y.jsx)(`div`,{style:{margin:`0 auto 8px`,width:54,height:54,borderRadius:`50%`,display:`grid`,placeItems:`center`,background:[r.pruningPassed,r.distillationCheck?.passed,r.scrub?.confirmed,r.evaluation.static?.passed&&r.evaluation.keyword?.passed][t]?s.green:s.background,color:s.navy},children:t+1}),e]},e))}),(0,Y.jsx)(Qe,{factory:e,ready:t,publish:n})]}),(0,Y.jsxs)(`div`,{style:{...X,background:e.state.draft?s.navy:s.background,color:e.state.draft?s.white:s.muted},children:[(0,Y.jsx)(`h3`,{children:`Expert brain`}),e.state.draft?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`strong`,{children:e.state.draft.title}),(0,Y.jsxs)(`p`,{children:[e.state.draft.nodes.length,` ページ`]})]}):(0,Y.jsx)(`p`,{children:`パックを作成するとここに表示されます。`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(260px,1fr))`,gap:20,marginTop:20},children:[(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-prune`,"data-status":r.pruningPassed?`passed`:`pending`,children:[(0,Y.jsx)(`h3`,{children:`枝刈り`}),(0,Y.jsx)(`p`,{children:r.unconfirmed?`要確認の段落があります。`:r.pruningPassed?`判定完了`:`分類後に結果を表示します。`})]}),(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-distill`,"data-status":r.distillationCheck?.passed?`passed`:`pending`,children:[(0,Y.jsx)(`h3`,{children:`蒸留`}),r.distilled?(0,Y.jsxs)(Y.Fragment,{children:[!!r.distilled.fallbackCandidates?.length&&(0,Y.jsx)(`p`,{children:`保持した段落から低確信度の候補を表示しています。内容を確認し、5項目を記入してください。`}),a.map(e=>{let t=r.distilled.fields[e],n=r.distilled.fallbackCandidates?.filter(t=>(t.field??`symptom`)===e)??[];return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{style:{display:`block`},children:[e,(0,Y.jsx)(`textarea`,{"data-testid":`distill-${e}`,value:t.map(e=>e.text).join(`
96
+ `);return{...n,keep:t.has(n.id),links:De([{name:`${n.id}.md`,markdown:r}])[0].links}}),r=E(e.pages.filter(e=>!t.has(e.id)),e.paragraphs.filter(e=>e.keep).map(e=>e.markdown));return J({...e,pages:n,stage:3},oe(n,e.paragraphs,r))}case`select-connected`:{if(!e.distilled)return e;let t=new Set(e.distillationCheck?.isolatedPageIds??[]);if(!t.size)return e;let n=e.paragraphs.map(e=>t.has(e.pageId)?{...e,keep:!1,confirmed:!0}:e),r={...e,paragraphs:n,removedIsolatedCount:t.size,unconfirmed:F(n),pruningPassed:I(n)};return n.some(e=>e.keep)?Ue(r,{type:`compile`}):{...q(r),pages:e.pages.map(e=>t.has(e.id)?{...e,keep:!1}:e),stage:2}}case`distill-field`:return e.distilled?J(e,{...e.distilled,fields:{...e.distilled.fields,[t.field]:t.entries}}):e;case`signatures`:return e.distilled?J(e,{...e.distilled,errorSignatures:t.values}):e;case`evaluation-input`:{let n={...e,evaluation:{...e.evaluation,problem:t.problem,testNames:t.testNames,testCode:t.testCode,keywords:t.keywords}};return n.distilled?J(n,n.distilled):n}case`confirm-scrub`:if(!e.scrub||e.scrub.result.remaining!==0)return e;try{let{pages:t,input:n}=Ve(e,new Date().toISOString());return Ae(t,n),{...e,scrub:{...e.scrub,confirmed:!0}}}catch{return e}case`scrub`:return{...e,stage:3};case`field`:return{...e,[t.field]:t.value,draft:null,stage:3,scrub:e.scrub&&{...e.scrub,confirmed:!1}};case`draft`:return!e.pruningPassed||!e.distillationCheck?.passed||!e.scrub?.confirmed||e.scrub.result.remaining!==0||!e.evaluation.problem.trim()||!e.evaluation.static?.passed||e.evaluation.keywords.length<2||e.evaluation.keywords.length>3||!e.evaluation.keyword?.passed?e:{...e,draft:t.draft,stage:4};case`reset`:return{...Be,title:e.title,signature:e.signature,domain:e.domain}}}var Y=r(),We={invalid_input:{ja:`テスト名かテストコードを入力してください。`,en:`Enter a test name or test code.`},format:{ja:`蒸留の5項目と3〜5個の検索語を確認してください。`,en:`Complete the five distilled fields and provide 3–5 search terms.`},connected:{ja:`ページ間のリンクを確認してください。`,en:`Check the links between pages.`},citations:{ja:`各項目の出典を確認してください。`,en:`Check the source of each field.`},length:{ja:`蒸留した内容を短くしてください。`,en:`Shorten the distilled content.`},summary_copying:{ja:`要約にテスト名やコードが含まれています。`,en:`Remove copied test names or code from the summary.`},page_copying:{ja:`ページにテスト名やコードが含まれています。`,en:`Remove copied test names or code from the page.`},markdown_copying:{ja:`出品本文にテスト名やコードが含まれています。`,en:`Remove copied test names or code from the pack text.`},keyword_count:{ja:`合言葉を2〜3個入力してください。`,en:`Enter 2–3 keywords.`},keyword_invalid:{ja:`空でない合言葉を入力してください。`,en:`Enter non-empty keywords.`},keyword_missing:{ja:`合言葉を要約に含めてください。`,en:`Include the keywords in the summary.`},forbidden_term:{ja:`禁止語を確認してください。`,en:`Check the forbidden terms.`},rescan:{ja:`秘密情報を確認してください。`,en:`Check for sensitive information.`}};function Ge({state:e,lang:t,dispatch:n}){let r=(0,c.useMemo)(()=>{if(!e.distilled||!e.scrub)return null;try{return He(e,`2000-01-01T00:00:00.000Z`),null}catch(e){return e instanceof G?{issues:e.issues,other:``}:{issues:[],other:e instanceof Error?e.message:String(e)}}},[e]),i=e.distillationCheck?.isolatedPageIds??[];return(0,Y.jsxs)(`div`,{children:[e.removedIsolatedCount>0&&(0,Y.jsx)(`p`,{"data-testid":`removed-isolated-pages`,children:t===`ja`?`孤立したページを ${e.removedIsolatedCount} 件外しました`:`Removed ${e.removedIsolatedCount} isolated ${e.removedIsolatedCount===1?`page`:`pages`}`}),i.length>0&&(0,Y.jsxs)(`div`,{"data-testid":`isolated-pages`,children:[(0,Y.jsx)(`p`,{children:t===`ja`?`孤立したページ: ${i.length} 件`:`Isolated pages: ${i.length}`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`select-connected-pages`,onClick:()=>n({type:`select-connected`}),children:t===`ja`?`孤立したページ(${i.length} 件)を外して作り直す`:`Remove ${i.length} isolated ${i.length===1?`page`:`pages`} and rebuild`})]}),r&&(0,Y.jsxs)(`div`,{"data-testid":`evaluation-issues`,children:[r.issues.map((e,n)=>(0,Y.jsxs)(`p`,{"data-testid":`evaluation-issue-${e.code}`,children:[We[e.code][t],typeof e.location==`object`?` (${e.location.pageId})`:``]},`${e.code}-${n}`)),r.other&&(0,Y.jsx)(`p`,{children:r.other})]})]})}var X={background:s.white,border:`1px solid ${s.border}`,borderRadius:20,padding:20},Z={background:s.navy,color:s.white,border:0,borderRadius:999,padding:`12px 20px`,cursor:`pointer`},Ke=Object.entries(Object.assign({"../../samples/brain/acme-checkout.md":l,"../../samples/brain/aws-prod-account.md":u,"../../samples/brain/customer-8812.md":d,"../../samples/brain/oncall-rotation.md":f,"../../samples/brain/payment-retries.md":p,"../../samples/brain/standup-notes.md":m,"../../samples/brain/stripe-idempotency.md":h,"../../samples/brain/webhook-dedupe.md":g})).map(([e,t])=>({name:e,markdown:t}));async function qe(e){if(e.isFile)return[await new Promise((t,n)=>e.file(t,n))];if(!e.isDirectory)return[];let t=e.createReader(),n=[];for(;;){let e=await new Promise((e,n)=>t.readEntries(e,n));if(!e.length)return n;for(let t of e)n.push(...await qe(t))}}async function Je(e){return Promise.all(e.filter(e=>/\.md$/i.test(e.name)).map(async e=>({name:e.name,markdown:await e.text()})))}function Ye(e,t=`en`){let[n,r]=(0,c.useReducer)(Ue,Be),[i,a]=(0,c.useState)(``);function o(){r({type:`reset`}),a(``)}function s(t){let n=De(t);if(!n.length)throw Error(`Markdown ファイルがありません。`);r({type:`load`,pages:n}),e(`${n.length} ページを読み込みました。`)}async function l(t){try{s(await Je(t))}catch(t){e(t instanceof Error?t.message:`読み込みに失敗しました。`)}}async function u(t){t.preventDefault();try{let e=Array.from(t.dataTransfer.items).map(e=>e.webkitGetAsEntry()).filter(e=>e!==null);await l(e.length?(await Promise.all(e.map(qe))).flat():Array.from(t.dataTransfer.files))}catch(t){e(t instanceof Error?t.message:`読み込みに失敗しました。`)}}function d(){r({type:`classify`})}let f=n.pages.filter(e=>e.keep),p=f.map(e=>we(e.markdown)),m=p.flatMap(e=>e.scrubbed).reduce((e,t)=>e+t.count,0),h=p.reduce((e,t)=>e+t.remaining,0);function g(){a(``);try{let t=He(n,new Date().toISOString());r({type:`draft`,draft:t}),e(``)}catch(n){let r=n instanceof Error?n.message:`パックを作れませんでした。`;r===`Static evaluation failed`||r===`Static evaluation input is required`?(e(``),a({"Static evaluation failed":{ja:`静的検査に合格しませんでした。出典と評価入力を確認してください。`,en:`Static evaluation failed. Check the sources and evaluation inputs.`},"Static evaluation input is required":{ja:`静的検査の入力が必要です。テスト名またはテストコードを入力してください。`,en:`Static evaluation inputs are required. Enter a test name or test code.`}}[r][t])):e(r)}}function _(e,t){r({type:`field`,field:e,value:t})}return{state:n,lang:t,reset:o,load:s,loadSelected:l,drop:u,runClassify:d,kept:f,scrubCount:m,remaining:h,makePack:g,updateField:_,dispatch:r,packError:i}}function Xe({factory:e}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:t=>{e.drop(t)},style:{border:`2px dashed ${s.borderStrong}`,borderRadius:16,padding:`2rem`,background:s.background},children:[(0,Y.jsxs)(`label`,{children:[`GBrain フォルダを選択 `,(0,Y.jsx)(`input`,{style:{display:`block`,maxWidth:`100%`},ref:e=>{e?.setAttribute(`webkitdirectory`,``)},type:`file`,multiple:!0,onChange:t=>{e.loadSelected(Array.from(t.currentTarget.files??[]))}})]}),(0,Y.jsx)(`p`,{children:`ここにフォルダまたは Markdown ファイルをドロップ`}),(0,Y.jsx)(`button`,{type:`button`,style:Z,onClick:()=>e.load(Ke),children:`サンプルの GBrain で試す`})]}),e.state.stage>=1&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:`1. 読み込み`}),(0,Y.jsxs)(`p`,{children:[e.state.pages.length,` ページ`]}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.state.pages.map(e=>(0,Y.jsxs)(`span`,{style:{border:`1px solid ${e.keep?s.greenText:s.borderStrong}`,borderRadius:999,padding:`6px 10px`},children:[e.title,` (`,e.class,`)`]},e.id))}),(0,Y.jsx)(`p`,{children:(0,Y.jsx)(`button`,{type:`button`,style:Z,onClick:e.runClassify,children:`分類する`})})]})]})}function Ze({factory:e}){return e.state.stage<2?null:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:`段落の判定`}),e.state.paragraphs.map(t=>(0,Y.jsx)(`div`,{"data-testid":`paragraph-${t.id}`,style:{border:`1px solid ${s.border}`,borderRadius:10,padding:10,marginTop:8},children:(0,Y.jsxs)(`div`,{"data-testid":t.confidence<.7&&!t.confirmed?`paragraph-review-pending`:void 0,children:[(0,Y.jsx)(`code`,{children:t.id}),` · `,t.reason,(0,Y.jsx)(`p`,{children:t.markdown}),(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":t.keep,onClick:()=>e.dispatch({type:`review`,id:t.id,keep:!0}),children:`残す`}),` `,(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":!t.keep,onClick:()=>e.dispatch({type:`review`,id:t.id,keep:!1}),children:`外す`})]})},t.id)),(0,Y.jsxs)(`p`,{children:[`保持 `,e.state.paragraphs.filter(e=>e.keep).length,` 段落`]}),(0,Y.jsx)(`button`,{type:`button`,style:Z,disabled:!e.state.pruningPassed||!e.state.paragraphs.some(e=>e.keep),onClick:()=>e.dispatch({type:`compile`}),children:`コンパイル&検証`})]})}function Qe({factory:e}){if(e.state.stage<3)return null;let t=e.state.scrub;if(!t)return null;let n=null;try{let{pages:t,input:r}=Ve(e.state,new Date().toISOString());n=Ae(t,r)}catch{}let r=e.lang===`ja`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:r?`秘密情報の除去`:`Redaction review`}),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:r?`出品物の伏せ字 ${n.length} 件`:`${n.length} redactions in the pack`}),(0,Y.jsx)(`ul`,{children:n.map((e,t)=>(0,Y.jsxs)(`li`,{children:[e.location===`summary`?r?`要約`:`Summary`:`${r?`ページ`:`Page`} ${e.location.pageId}`,` · `,(0,Y.jsx)(`code`,{children:e.symbol}),` · `,e.kind,` · `,e.origin===`ambiguous`?r?`既存か生成か判別できません`:`Cannot determine whether existing or generated`:e.origin===`existing`?r?`既存`:`Existing`:r?`生成`:`Generated`]},t))})]}):(0,Y.jsx)(`p`,{role:`status`,children:r?`パックの入力と検査を完了すると伏せ字を確認できます。現在は確認できません。`:`Complete pack inputs and checks to review redactions. Review is currently unavailable.`}),(0,Y.jsx)(`button`,{type:`button`,disabled:n===null||t.result.remaining!==0||t.confirmed,onClick:()=>e.dispatch({type:`confirm-scrub`}),children:r?`確認した`:`Confirm`})]})}function $e({factory:e,ready:t,publish:n}){let{state:r}=e;return r.stage<3?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`パック`}),e.packError&&(0,Y.jsx)(`p`,{role:`alert`,children:e.packError}),(0,Y.jsxs)(`label`,{children:[`パック名 `,(0,Y.jsx)(`input`,{value:r.title,onChange:t=>e.updateField(`title`,t.target.value)})]}),(0,Y.jsx)(`br`,{}),(0,Y.jsxs)(`label`,{children:[`ドメイン `,(0,Y.jsx)(`input`,{value:r.domain,onChange:t=>e.updateField(`domain`,t.target.value)})]}),(0,Y.jsx)(`br`,{}),(0,Y.jsxs)(`label`,{children:[`エラー文の例 `,(0,Y.jsx)(`input`,{value:r.signature,onChange:t=>e.updateField(`signature`,t.target.value)})]}),(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`button`,{type:`button`,style:Z,disabled:!r.pruningPassed||!r.distillationCheck?.passed||!r.scrub?.confirmed||!r.evaluation.static?.passed||!r.evaluation.keyword?.passed||!r.evaluation.problem.trim(),onClick:e.makePack,children:`パックを作る`}),(0,Y.jsx)(Ge,{state:r,lang:e.lang,dispatch:e.dispatch}),r.stage>=4&&r.draft&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{children:[r.draft.title,` · `,r.draft.nodes.length,` ページ`]}),(0,Y.jsx)(`button`,{type:`button`,style:Z,onClick:n,disabled:!t,children:`出品する`})]})]})}function et({factory:e,ready:t,publish:n}){let{state:r,dispatch:i}=e,a=[`symptom`,`cause`,`fix`,`avoid`,`verify`],o={symptom:`症状`,cause:`原因`,fix:`直し方`,avoid:`避けること`,verify:`確認方法`},c=r.evaluation;function l(e){let t={...c,...e};i({type:`evaluation-input`,problem:t.problem,testNames:t.testNames,testCode:t.testCode,keywords:t.keywords})}return(0,Y.jsxs)(`section`,{"aria-labelledby":`factory`,style:{color:s.navy,padding:`28px 24px 48px`,background:s.background},children:[(0,Y.jsx)(`h2`,{id:`factory`,children:`ファクトリー`}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(280px,1fr))`,gap:20},children:[(0,Y.jsxs)(`div`,{style:X,children:[(0,Y.jsx)(Xe,{factory:e}),(0,Y.jsx)(Ze,{factory:e})]}),(0,Y.jsxs)(`div`,{style:X,children:[(0,Y.jsx)(`h3`,{children:`4ゲート`}),(0,Y.jsx)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:8,flexWrap:`wrap`},children:[`枝刈り`,`蒸留`,`秘密除去`,`効果測定`].map((e,t)=>(0,Y.jsxs)(`div`,{style:{textAlign:`center`,flex:`1 1 70px`},children:[(0,Y.jsx)(`div`,{style:{margin:`0 auto 8px`,width:54,height:54,borderRadius:`50%`,display:`grid`,placeItems:`center`,background:[r.pruningPassed,r.distillationCheck?.passed,r.scrub?.confirmed,r.evaluation.static?.passed&&r.evaluation.keyword?.passed][t]?s.green:s.background,color:s.navy},children:t+1}),e]},e))}),(0,Y.jsx)($e,{factory:e,ready:t,publish:n})]}),(0,Y.jsxs)(`div`,{style:{...X,background:e.state.draft?s.navy:s.background,color:e.state.draft?s.white:s.muted},children:[(0,Y.jsx)(`h3`,{children:`Expert brain`}),e.state.draft?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`strong`,{children:e.state.draft.title}),(0,Y.jsxs)(`p`,{children:[e.state.draft.nodes.length,` ページ`]})]}):(0,Y.jsx)(`p`,{children:`パックを作成するとここに表示されます。`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(260px,1fr))`,gap:20,marginTop:20},children:[(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-prune`,"data-status":r.pruningPassed?`passed`:`pending`,children:[(0,Y.jsx)(`h3`,{children:`枝刈り`}),(0,Y.jsx)(`p`,{children:r.unconfirmed?`要確認の段落があります。`:r.pruningPassed?`判定完了`:`分類後に結果を表示します。`})]}),(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-distill`,"data-status":r.distillationCheck?.passed?`passed`:`pending`,children:[(0,Y.jsx)(`h3`,{children:`蒸留`}),r.distilled?(0,Y.jsxs)(Y.Fragment,{children:[!!r.distilled.fallbackCandidates?.length&&(0,Y.jsx)(`p`,{children:`保持した段落から低確信度の候補を表示しています。内容を確認し、5項目を記入してください。`}),a.map(e=>{let t=r.distilled.fields[e],n=r.distilled.fallbackCandidates?.filter(t=>(t.field??`symptom`)===e)??[];return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{style:{display:`block`},children:[e,(0,Y.jsx)(`textarea`,{"data-testid":`distill-${e}`,value:t.map(e=>e.text).join(`
43
97
  `),onChange:n=>i({type:`distill-field`,field:e,entries:[{text:n.target.value,sourceId:t[0]?.sourceId??r.distilled.sourceIds[0]??``}]})}),(0,Y.jsx)(`small`,{children:t.map(e=>e.sourceId).join(`, `)})]}),n.length>0&&(0,Y.jsx)(`div`,{"data-testid":e===`symptom`?`distill-fallback-candidates`:`distill-fallback-${e}`,children:(0,Y.jsx)(`ul`,{children:n.map((t,n)=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`p`,{children:t.text}),(0,Y.jsxs)(`small`,{children:[`出典 `,t.sourceId,` · 確信度 `,t.confidence]}),(0,Y.jsx)(`br`,{}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i({type:`distill-field`,field:e,entries:[{text:t.text,sourceId:t.sourceId}]}),children:[o[e],`に使う`]})]},`${t.sourceId}-${n}`))})})]},e)}),(0,Y.jsxs)(`label`,{children:[`検索語(改行区切り)`,(0,Y.jsx)(`textarea`,{value:r.distilled.errorSignatures.join(`
44
98
  `),onChange:e=>i({type:`signatures`,values:e.target.value.split(`
45
- `).filter(Boolean)})})]})]}):(0,Y.jsx)(`p`,{children:`コンパイル後に結果を表示します。`})]}),(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-scrub`,"data-status":r.scrub?.confirmed&&r.scrub.result.remaining===0?`passed`:`pending`,children:[(0,Y.jsx)(Ze,{factory:e}),!r.scrub&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`秘密情報の除去`}),(0,Y.jsx)(`p`,{children:`コンパイル後に結果を表示します。`})]})]}),(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-evaluation`,"data-status":c.static?.passed&&c.keyword?.passed?`passed`:`pending`,children:[(0,Y.jsx)(`h3`,{children:`効果測定`}),r.distilled&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`label`,{children:[`課題`,(0,Y.jsx)(`textarea`,{"data-testid":`evaluation-problem`,value:c.problem,onChange:e=>l({problem:e.target.value})})]}),(0,Y.jsxs)(`label`,{children:[`テスト名(改行区切り)`,(0,Y.jsx)(`textarea`,{value:c.testNames.join(`
99
+ `).filter(Boolean)})})]})]}):(0,Y.jsx)(`p`,{children:`コンパイル後に結果を表示します。`})]}),(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-scrub`,"data-status":r.scrub?.confirmed&&r.scrub.result.remaining===0?`passed`:`pending`,children:[(0,Y.jsx)(Qe,{factory:e}),!r.scrub&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`秘密情報の除去`}),(0,Y.jsx)(`p`,{children:`コンパイル後に結果を表示します。`})]})]}),(0,Y.jsxs)(`div`,{style:X,"data-testid":`gate-evaluation`,"data-status":c.static?.passed&&c.keyword?.passed?`passed`:`pending`,children:[(0,Y.jsx)(`h3`,{children:`効果測定`}),r.distilled&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`label`,{children:[`課題`,(0,Y.jsx)(`textarea`,{"data-testid":`evaluation-problem`,value:c.problem,onChange:e=>l({problem:e.target.value})})]}),(0,Y.jsxs)(`label`,{children:[`テスト名(改行区切り)`,(0,Y.jsx)(`textarea`,{value:c.testNames.join(`
46
100
  `),onChange:e=>l({testNames:e.target.value.split(`
47
101
  `)})})]}),(0,Y.jsxs)(`label`,{children:[`テストコード`,(0,Y.jsx)(`textarea`,{value:c.testCode.join(`
48
102
  `),onChange:e=>l({testCode:e.target.value.split(`
49
- `)})})]}),(0,Y.jsxs)(`label`,{children:[`合言葉(カンマ区切り)`,(0,Y.jsx)(`input`,{"data-testid":`evaluation-keywords`,value:c.keywords.join(`, `),onChange:e=>l({keywords:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]}),(0,Y.jsxs)(`p`,{"data-testid":`evaluation-stage-0`,"data-status":c.static?.passed?`passed`:`pending`,children:[`静的検査 `,c.static?.passed?`✓`:`未完了`]}),(0,Y.jsxs)(`p`,{"data-testid":`evaluation-stage-1`,"data-status":c.keyword?.passed?`passed`:`pending`,children:[`合言葉 `,c.keyword?.passed?`✓`:`未完了`]})]})]})]})]})}var Q=pe;function et(e){let t=e.getItem(Q);if(t===null)return{store:K(),recovered:!1};try{return{store:xe(t),recovered:!1}}catch{let n=1;for(;e.getItem(`${Q}:backup:${n}`)!==null;)n++;e.setItem(`${Q}:backup:${n}`,t);let r=K();if(e.getItem(Q)!==t)throw Error(`Store changed during recovery`);return e.setItem(Q,Se(r)),{store:r,recovered:!0}}}function tt(e,t,n){if(n!==void 0){let t=e.getItem(Q);if((t===null?0:xe(t).rev)!==n)throw Error(`Store revision conflict`)}e.setItem(Q,Se(t))}function nt(e,t,n){let r=r=>{if(r.key!==Q&&r.key!==null)return;let i;try{if(r.storageArea!==e.localStorage)return;i=et(e.localStorage)}catch(e){n(e);return}t(i)};return e.addEventListener(`storage`,r),()=>e.removeEventListener(`storage`,r)}async function rt(){let e=new AbortController,t;try{let n=await Promise.race([fetch(`http://127.0.0.1:4747/api/health`,{signal:e.signal}),new Promise((n,r)=>{t=setTimeout(()=>{e.abort(),r(Error(`Health check timed out`))},500)})]);if(!n.ok)return`browser`;let r=await Promise.race([n.json(),new Promise((t,n)=>{e.signal.addEventListener(`abort`,()=>n(Error(`Health check timed out`)),{once:!0})})]);return typeof r==`object`&&r&&`ok`in r&&r.ok===!0?`local`:`browser`}catch{return`browser`}finally{clearTimeout(t),e.abort()}}function it(e){let t=new Set(e.packs.filter(e=>e.author===`you`).map(e=>e.id)),n=e.ledger.filter(e=>t.has(e.packId)),r=P(e),i=Math.round(r.authorUsd*100),a=[1,1,2,1,2,2,1,2,1,2,1,1,2,4,1,2,3,5,3,4,6,2,6,3,4,4,5,7,4,4];a[a.length-1]+=n.length;let o=[...n.map(e=>({amountUsd:e.authorUsd,solved:e.result===`solved`,pages:e.pagesUsed})),{amountUsd:.45,solved:!0,pages:[`stripe-webhook-signature`,`raw-body-parsing`]},{amountUsd:.72,solved:!0,pages:[`pg-add-column-safely`]},{amountUsd:.45,solved:!1,pages:[`stripe-webhook-signature`]}],s={"stripe-webhook-signature":41,"pg-add-column-safely":27,"raw-body-parsing":22,"stripe-idempotency":0,"webhook-dedupe":0};for(let e of n)for(let t of e.pagesUsed)s[t]=(s[t]??0)+1;return{balanceUsd:(1336+i)/100,earned30dUsd:(4788+i)/100,uses30d:86+r.uses,solved30d:78+r.solved,dailyUses30d:a,recentUses:o,pageUses:s}}var $={background:s.white,border:`1px solid ${s.border}`,borderRadius:14,padding:22};function at({query:e,setQuery:t,searched:n,search:r,results:i,store:a,ready:l,sessionId:u,buy:d,download:f,markResult:p}){let[m,h]=(0,c.useState)(()=>new Set),[g,_]=(0,c.useState)(``);function v(e){let t=f(e,`brain`);if(!t.ok){_(t.reason);return}_(``);let n=a.ledger.find(t=>t.packId===e);n&&h(e=>new Set(e).add(n.id))}return(0,Y.jsxs)(`section`,{"aria-labelledby":`market`,style:{padding:`28px 24px 48px`,background:s.background,color:s.navy},children:[(0,Y.jsx)(`h2`,{id:`market`,children:`Claude Code`}),(0,Y.jsxs)(`div`,{style:{...$,background:s.navy,color:s.white,fontFamily:`ui-monospace, monospace`},children:[(0,Y.jsx)(`p`,{children:`● ● ● Claude Code`}),(0,Y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),r()},children:[(0,Y.jsxs)(`label`,{children:[`検索 `,(0,Y.jsx)(`input`,{value:e,onChange:e=>t(e.target.value)})]}),` `,(0,Y.jsx)(`button`,{type:`submit`,children:`検索する`})]}),g&&(0,Y.jsx)(`p`,{role:`alert`,children:g}),n&&i.length===0&&(0,Y.jsx)(`p`,{children:`一致するパックはありません。`}),(0,Y.jsx)(`ul`,{children:i.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:e.title}),` · 一致度 `,Math.round(e.score*100),`% · $`,e.priceUsd.toFixed(2),` `,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>d(e),disabled:!l||!u,children:`購入する`}),` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!e.owned,onClick:()=>f(e.id,`skill`),children:`スキルを書き出す`}),` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!e.owned||a.ledger.some(t=>t.packId===e.id&&m.has(t.id)),onClick:()=>v(e.id),children:a.ledger.some(t=>t.packId===e.id&&m.has(t.id))?o(`ja`).importDone:o(`ja`).importBtn}),a.ledger.filter(t=>t.packId===e.id).map(e=>(0,Y.jsxs)(`div`,{"data-testid":`transaction-result`,children:[`利用結果: `,e.result===`solved`?`解決`:e.result===`unsolved`?`未解決`:`実行中`,` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!l,"aria-pressed":e.result===`solved`,onClick:()=>p(e.id,`solved`),children:`解決`}),` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!l,"aria-pressed":e.result===`unsolved`,onClick:()=>p(e.id,`unsolved`),children:`未解決`})]},e.id))]},e.id))}),(0,Y.jsxs)(`p`,{children:[`ローカルでは `,(0,Y.jsx)(`code`,{children:`gbrainx import`}),` を使えます。同名ファイルがある場合は取り込みが止まります。内容を確認してから操作してください。`]})]})]})}function ot({store:e}){let t=it(e);return(0,Y.jsxs)(`section`,{"aria-labelledby":`earnings`,style:{padding:`32px 24px 48px`,background:s.background,color:s.navy},children:[(0,Y.jsx)(`h2`,{id:`earnings`,children:`収益`}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(260px,1fr))`,gap:16},children:[(0,Y.jsxs)(`div`,{style:{...$,background:s.navy,color:s.white},children:[(0,Y.jsxs)(`div`,{"data-testid":`earnings-balance`,children:[`作者収益 `,(0,Y.jsxs)(`strong`,{style:{fontSize:38},children:[`$`,t.balanceUsd.toFixed(2)]})]}),(0,Y.jsxs)(`p`,{children:[`購入者残高 $`,e.wallet.buyerUsd.toFixed(2)]})]}),(0,Y.jsxs)(`div`,{style:$,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,Y.jsxs)(`div`,{children:[`利用回数`,(0,Y.jsx)(`h2`,{children:t.uses30d})]}),(0,Y.jsxs)(`div`,{children:[`解決率`,(0,Y.jsxs)(`h2`,{"data-testid":`earnings-solve-rate`,children:[Math.round(t.solved30d/t.uses30d*100),`%`]})]}),(0,Y.jsxs)(`div`,{children:[`30日間の収益`,(0,Y.jsxs)(`h2`,{children:[`$`,t.earned30dUsd.toFixed(2)]})]})]}),(0,Y.jsx)(`div`,{"aria-label":`30日間の利用回数`,style:{height:66,display:`flex`,alignItems:`end`,gap:3},children:t.dailyUses30d.map((e,n)=>(0,Y.jsx)(`div`,{title:`${e}回`,style:{flex:1,height:Math.max(3,e/Math.max(...t.dailyUses30d)*66),background:n===29?s.blue:s.border,borderRadius:3}},n))})]})]}),(0,Y.jsxs)(`div`,{style:{...$,marginTop:16,overflowX:`auto`},children:[(0,Y.jsx)(`h3`,{children:`出品中の Expert brain`}),(0,Y.jsxs)(`table`,{style:{width:`100%`,textAlign:`left`},children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{children:`パック`}),(0,Y.jsx)(`th`,{children:`価格`}),(0,Y.jsx)(`th`,{children:`利用`}),(0,Y.jsx)(`th`,{children:`解決`}),(0,Y.jsx)(`th`,{children:`収益`})]})}),(0,Y.jsx)(`tbody`,{children:e.packs.map(t=>{let n=e.ledger.filter(e=>e.packId===t.id&&t.author===`you`);return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{children:t.title}),(0,Y.jsxs)(`td`,{children:[`$`,t.priceUsd.toFixed(2)]}),(0,Y.jsx)(`td`,{children:t.author===`you`?n.length:`—`}),(0,Y.jsx)(`td`,{children:t.author===`you`?n.filter(e=>e.result===`solved`).length:`—`}),(0,Y.jsx)(`td`,{children:t.author===`you`?`$${n.reduce((e,t)=>e+t.authorUsd,0).toFixed(2)}`:`—`})]},t.id)})})]})]}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(280px,1fr))`,gap:16,marginTop:16},children:[(0,Y.jsxs)(`div`,{style:$,children:[(0,Y.jsx)(`h3`,{children:`最近の利用`}),t.recentUses.map((e,t)=>(0,Y.jsxs)(`p`,{children:[e.solved?`解決`:`未解決`,` · +$`,e.amountUsd.toFixed(2),(0,Y.jsx)(`br`,{}),e.pages.map(e=>`[[${e}]]`).join(` `)]},t))]}),(0,Y.jsxs)(`div`,{style:$,children:[(0,Y.jsx)(`h3`,{children:`役に立ったページ`}),Object.entries(t.pageUses).map(([e,n])=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{children:[e,` · `,n,`回`]}),(0,Y.jsx)(`div`,{style:{height:6,background:s.border},children:(0,Y.jsx)(`div`,{style:{height:6,width:`${n/Math.max(1,...Object.values(t.pageUses))*100}%`,background:s.blue}})})]},e))]})]}),(0,Y.jsxs)(`div`,{style:{...$,marginTop:16},children:[(0,Y.jsx)(`h3`,{children:`内訳`}),(0,Y.jsxs)(`div`,{style:{display:`flex`,color:s.white},children:[(0,Y.jsx)(`div`,{style:{width:`90%`,padding:10,background:s.navy},children:`あなた 90%`}),(0,Y.jsx)(`div`,{style:{width:`10%`,padding:10,background:s.blue},children:`10%`})]})]})]})}function st(e){let t=0xffffffff;for(let n of e){t^=n;for(let e=0;e<8;e++)t=t>>>1^-(t&1)&0xedb88320}return(t^0xffffffff)>>>0}function ct(e,t){let n=new TextEncoder,r=`packs/${e.id}/`,i=new Set,a=fe(e,t).map(({path:t,markdown:a})=>{if(!t.startsWith(r))throw Error(`Invalid import path`);let o=t.slice(6),s=o.split(`/`);if(s.length!==2||s[0]!==e.id||s.some(e=>!e||e===`.`||e===`..`||e.includes(`\\`)||Array.from(e).some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)))throw Error(`Invalid import path`);let c=o.normalize(`NFC`).toLowerCase();if(i.has(c))throw Error(`Duplicate import path`);i.add(c);let l=n.encode(o),u=n.encode(a);if(l.length>65535||u.length>0xffffffff)throw Error(`Import file is too large for ZIP`);return{name:l,content:u,crc:st(u)}});if(a.length>65535)throw Error(`Too many import files for ZIP`);let o=0,s=0;for(let e of a)o+=30+e.name.length+e.content.length,s+=46+e.name.length;if(o>0xffffffff||s>0xffffffff||o+s+22>0xffffffff)throw Error(`Import is too large for ZIP`);let c=new Uint8Array(o+s+22),l=new DataView(c.buffer),u=(e,t)=>l.setUint16(e,t,!0),d=(e,t)=>l.setUint32(e,t,!0),f=0,p=o;for(let{name:e,content:t,crc:n}of a)d(f,67324752),u(f+4,20),u(f+6,2048),u(f+12,33),d(f+14,n),d(f+18,t.length),d(f+22,t.length),u(f+26,e.length),c.set(e,f+30),c.set(t,f+30+e.length),d(p,33639248),u(p+4,20),u(p+6,20),u(p+8,2048),u(p+14,33),d(p+16,n),d(p+20,t.length),d(p+24,t.length),u(p+28,e.length),d(p+42,f),c.set(e,p+46),f+=30+e.length+t.length,p+=46+e.length;return d(p,0x6054b50),u(p+8,a.length),u(p+10,a.length),d(p+12,s),d(p+16,o),c}function lt(){let[e,t]=(0,c.useState)(()=>K()),[n,r]=(0,c.useState)(!1),[i,a]=(0,c.useState)(`browser`),[o,s]=(0,c.useState)(``),[l,u]=(0,c.useState)(!1),[d,f]=(0,c.useState)(``),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(``);(0,c.useEffect)(()=>{g(crypto.randomUUID());try{let e=et(window.localStorage);t(e.store),r(!0),e.recovered&&f(`以前の保存データを退避し、初期状態から始めました。`)}catch{f(`保存データを読み込めませんでした。保存は停止しています。`)}return rt().then(a),nt(window,e=>{t(e.store),r(!0),e.recovered&&f(`以前の保存データを退避し、初期状態から始めました。`)},()=>{r(!1),f(`保存データを読み込めませんでした。保存は停止しています。`)})},[]);function _(r){if(!n)throw Error(`Store is unavailable`);tt(window.localStorage,r,e.rev),t(r)}function v(t,n){if(t){if(e.packs.some(e=>e.id===t.id))f(`同じ ID のパックが既にあります。別のパック名を指定してください。`);else try{_({...e,rev:e.rev+1,brain:{pages:n},packs:[...e.packs,t]}),f(`パックを出品しました。`)}catch{f(`保存に失敗しました。`)}}}function y(t){let n=M(e,t.id,h,t.score);if(!n.ok){f(`購入できませんでした: ${n.code}`);return}let r=ne(e,t.id,h,`web`,new Date().toISOString(),crypto.randomUUID(),e.rev,t.score);if(!r.ok)f(`購入できませんでした: ${r.code}`);else try{r.alreadyPurchased||_(r.store),f(r.alreadyPurchased?`${t.title} は購入済みです。`:`${t.title} を購入しました。`)}catch{f(`購入を保存できませんでした。再読み込みしてください。`)}}function b(t,n){let r=e.ledger.find(e=>e.packId===t),i=e.packs.find(e=>e.id===t);if(!r||!i||!j(e,t)){let e=`書き出すには購入が必要です。`;return f(e),{ok:!1,reason:e}}try{let a=re(e,t);if(!a.ok){let e=`パックを読み込めませんでした: ${a.code}`;return f(e),{ok:!1,reason:e}}let o=Uint8Array.from(n===`skill`?Le(i):ct(i,r.at)),s=URL.createObjectURL(new Blob([o.buffer],{type:`application/zip`}));try{let e=document.createElement(`a`);e.href=s,e.download=n===`skill`?`${t}.zip`:`${t}-gbrain.zip`,e.click()}finally{URL.revokeObjectURL(s)}return{ok:!0}}catch(e){let t=e instanceof Error?e.message:`書き出しに失敗しました。`;return f(t),{ok:!1,reason:t}}}function x(t,n){let r=N(e,t,n);if(!r.ok)f(`結果を保存できませんでした: ${r.code}`);else try{_(r.store),f(`利用結果を保存しました。`)}catch{f(`結果を保存できませんでした。`)}}function S(){try{return _({...K(),rev:e.rev+1}),m(e),f(`初期状態に戻しました。`),!0}catch{return f(`保存に失敗しました。`),!1}}function C(){if(p)try{_({...p,rev:e.rev+1}),m(null)}catch{f(`保存に失敗しました。`)}}return{store:e,ready:n,mode:i,query:o,setQuery:s,searched:l,setSearched:u,message:d,setMessage:f,previous:p,sessionId:h,results:l?Ne(o,e):[],publish:v,buy:y,download:b,markResult:x,reset:S,undo:C}}function ut(){return[{title:`GBrainX`}]}var dt=t(function(){let e=lt(),[t]=i(),n=Je(e.setMessage,a(t.toString())),[r,o]=(0,c.useState)(`factory`),[l,u]=(0,c.useState)(!1),d=e.store.packs.some(e=>e.author===`you`),f=e.store.ledger.some(e=>e.result===`solved`),p=l?4:f?3:d?2:+!!n.state.draft,m=[[`factory`,`ファクトリー`],[`agent`,`Claude Code`],[`earnings`,`収益`]],h=r===`factory`?n.state.unconfirmed?`要確認の段落を判断してください。`:n.state.stage===0?`GBrain を読み込んでください。`:n.state.draft?`パックを出品できます。`:`分類と各ゲートの結果を確認してください。`:r===`agent`?`Expert brain を検索し、購入して読み込めます。`:`利用と収益を確認できます。`;return(0,Y.jsxs)(`main`,{style:{minHeight:`100vh`,background:s.background,color:s.navy,lineHeight:1.6},children:[(0,Y.jsxs)(`header`,{style:{background:s.navy,color:s.white,padding:`12px 24px`,display:`flex`,alignItems:`center`,gap:20,flexWrap:`wrap`},children:[(0,Y.jsx)(`strong`,{children:`GbrainX`}),(0,Y.jsx)(`span`,{children:e.mode===`local`?`ローカル版`:`ブラウザ版`}),(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":`画面`,style:{display:`flex`,padding:4,background:s.navyRaised,borderRadius:999},children:m.map(([t,n])=>(0,Y.jsx)(`button`,{type:`button`,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-selected":r===t,onClick:()=>{o(t),t===`earnings`&&e.store.ledger.length>0&&u(!0)},style:{border:0,borderRadius:999,padding:`7px 16px`,minHeight:36,cursor:`pointer`,background:r===t?s.white:`transparent`,color:r===t?s.navy:s.textOnNavy},children:n},t))}),(0,Y.jsx)(`div`,{style:{flex:`1 1 auto`}}),(0,Y.jsx)(`div`,{role:`img`,"aria-label":`進行状況`,style:{display:`flex`,gap:6},children:[`コンパイル`,`出品`,`解決`,`収益`].map((e,t)=>(0,Y.jsx)(`span`,{title:e,style:{width:t===p?24:6,height:6,borderRadius:999,background:t<p?s.mint:t===p?s.white:s.navyBorder}},e))}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{e.reset()&&(n.reset(),o(`factory`),u(!1))},disabled:!e.ready,children:`初期状態に戻す`}),e.previous&&(0,Y.jsx)(`button`,{type:`button`,onClick:e.undo,children:`元に戻す`})]}),(0,Y.jsxs)(`div`,{"aria-live":`polite`,style:{background:`#EAF1FA`,padding:`12px 24px`,color:s.navy},children:[(0,Y.jsx)(`strong`,{children:m.find(([e])=>e===r)?.[1]}),` · `,h]}),e.message&&(0,Y.jsx)(`p`,{role:`status`,children:e.message}),(0,Y.jsx)(`div`,{role:`tabpanel`,id:`panel-factory`,"aria-labelledby":`tab-factory`,hidden:r!==`factory`,children:(0,Y.jsx)($e,{factory:n,ready:e.ready,publish:()=>e.publish(n.state.draft,n.state.pages)})}),(0,Y.jsx)(`div`,{role:`tabpanel`,id:`panel-agent`,"aria-labelledby":`tab-agent`,hidden:r!==`agent`,children:(0,Y.jsx)(at,{query:e.query,setQuery:e.setQuery,searched:e.searched,search:()=>e.setSearched(!0),results:e.results,store:e.store,ready:e.ready,sessionId:e.sessionId,buy:e.buy,download:e.download,markResult:e.markResult})}),(0,Y.jsx)(`div`,{role:`tabpanel`,id:`panel-earnings`,"aria-labelledby":`tab-earnings`,hidden:r!==`earnings`,children:(0,Y.jsx)(ot,{store:e.store})})]})});export{dt as default,ut as meta};
103
+ `)})})]}),(0,Y.jsxs)(`label`,{children:[`合言葉(カンマ区切り)`,(0,Y.jsx)(`input`,{"data-testid":`evaluation-keywords`,value:c.keywords.join(`, `),onChange:e=>l({keywords:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]}),(0,Y.jsxs)(`p`,{"data-testid":`evaluation-stage-0`,"data-status":c.static?.passed?`passed`:`pending`,children:[`静的検査 `,c.static?.passed?`✓`:`未完了`]}),(0,Y.jsxs)(`p`,{"data-testid":`evaluation-stage-1`,"data-status":c.keyword?.passed?`passed`:`pending`,children:[`合言葉 `,c.keyword?.passed?`✓`:`未完了`]})]})]})]})]})}var Q=me;function tt(e){let t=e.getItem(Q);if(t===null)return{store:K(),recovered:!1};try{return{store:Se(t),recovered:!1}}catch{let n=1;for(;e.getItem(`${Q}:backup:${n}`)!==null;)n++;e.setItem(`${Q}:backup:${n}`,t);let r=K();if(e.getItem(Q)!==t)throw Error(`Store changed during recovery`);return e.setItem(Q,Ce(r)),{store:r,recovered:!0}}}function nt(e,t,n){if(n!==void 0){let t=e.getItem(Q);if((t===null?0:Se(t).rev)!==n)throw Error(`Store revision conflict`)}e.setItem(Q,Ce(t))}function rt(e,t,n){let r=r=>{if(r.key!==Q&&r.key!==null)return;let i;try{if(r.storageArea!==e.localStorage)return;i=tt(e.localStorage)}catch(e){n(e);return}t(i)};return e.addEventListener(`storage`,r),()=>e.removeEventListener(`storage`,r)}async function it(){let e=new AbortController,t;try{let n=await Promise.race([fetch(`http://127.0.0.1:4747/api/health`,{signal:e.signal}),new Promise((n,r)=>{t=setTimeout(()=>{e.abort(),r(Error(`Health check timed out`))},500)})]);if(!n.ok)return`browser`;let r=await Promise.race([n.json(),new Promise((t,n)=>{e.signal.addEventListener(`abort`,()=>n(Error(`Health check timed out`)),{once:!0})})]);return typeof r==`object`&&r&&`ok`in r&&r.ok===!0?`local`:`browser`}catch{return`browser`}finally{clearTimeout(t),e.abort()}}function at(e){let t=new Set(e.packs.filter(e=>e.author===`you`).map(e=>e.id)),n=e.ledger.filter(e=>t.has(e.packId)),r=P(e),i=Math.round(r.authorUsd*100),a=[1,1,2,1,2,2,1,2,1,2,1,1,2,4,1,2,3,5,3,4,6,2,6,3,4,4,5,7,4,4];a[a.length-1]+=n.length;let o=[...n.map(e=>({amountUsd:e.authorUsd,solved:e.result===`solved`,pages:e.pagesUsed})),{amountUsd:.45,solved:!0,pages:[`stripe-webhook-signature`,`raw-body-parsing`]},{amountUsd:.72,solved:!0,pages:[`pg-add-column-safely`]},{amountUsd:.45,solved:!1,pages:[`stripe-webhook-signature`]}],s={"stripe-webhook-signature":41,"pg-add-column-safely":27,"raw-body-parsing":22,"stripe-idempotency":0,"webhook-dedupe":0};for(let e of n)for(let t of e.pagesUsed)s[t]=(s[t]??0)+1;return{balanceUsd:(1336+i)/100,earned30dUsd:(4788+i)/100,uses30d:86+r.uses,solved30d:78+r.solved,dailyUses30d:a,recentUses:o,pageUses:s}}var $={background:s.white,border:`1px solid ${s.border}`,borderRadius:14,padding:22};function ot({query:e,setQuery:t,searched:n,search:r,results:i,store:a,ready:l,sessionId:u,buy:d,download:f,markResult:p}){let[m,h]=(0,c.useState)(()=>new Set),[g,_]=(0,c.useState)(``);function v(e){let t=f(e,`brain`);if(!t.ok){_(t.reason);return}_(``);let n=a.ledger.find(t=>t.packId===e);n&&h(e=>new Set(e).add(n.id))}return(0,Y.jsxs)(`section`,{"aria-labelledby":`market`,style:{padding:`28px 24px 48px`,background:s.background,color:s.navy},children:[(0,Y.jsx)(`h2`,{id:`market`,children:`Claude Code`}),(0,Y.jsxs)(`div`,{style:{...$,background:s.navy,color:s.white,fontFamily:`ui-monospace, monospace`},children:[(0,Y.jsx)(`p`,{children:`● ● ● Claude Code`}),(0,Y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),r()},children:[(0,Y.jsxs)(`label`,{children:[`検索 `,(0,Y.jsx)(`input`,{value:e,onChange:e=>t(e.target.value)})]}),` `,(0,Y.jsx)(`button`,{type:`submit`,children:`検索する`})]}),g&&(0,Y.jsx)(`p`,{role:`alert`,children:g}),n&&i.length===0&&(0,Y.jsx)(`p`,{children:`一致するパックはありません。`}),(0,Y.jsx)(`ul`,{children:i.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:e.title}),` · 一致度 `,Math.round(e.score*100),`% · $`,e.priceUsd.toFixed(2),` `,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>d(e),disabled:!l||!u,children:`購入する`}),` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!e.owned,onClick:()=>f(e.id,`skill`),children:`スキルを書き出す`}),` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!e.owned||a.ledger.some(t=>t.packId===e.id&&m.has(t.id)),onClick:()=>v(e.id),children:a.ledger.some(t=>t.packId===e.id&&m.has(t.id))?o(`ja`).importDone:o(`ja`).importBtn}),a.ledger.filter(t=>t.packId===e.id).map(e=>(0,Y.jsxs)(`div`,{"data-testid":`transaction-result`,children:[`利用結果: `,e.result===`solved`?`解決`:e.result===`unsolved`?`未解決`:`実行中`,` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!l,"aria-pressed":e.result===`solved`,onClick:()=>p(e.id,`solved`),children:`解決`}),` `,(0,Y.jsx)(`button`,{type:`button`,disabled:!l,"aria-pressed":e.result===`unsolved`,onClick:()=>p(e.id,`unsolved`),children:`未解決`})]},e.id))]},e.id))}),(0,Y.jsxs)(`p`,{children:[`ローカルでは `,(0,Y.jsx)(`code`,{children:`gbrainx import`}),` を使えます。同名ファイルがある場合は取り込みが止まります。内容を確認してから操作してください。`]})]})]})}function st({store:e}){let t=at(e);return(0,Y.jsxs)(`section`,{"aria-labelledby":`earnings`,style:{padding:`32px 24px 48px`,background:s.background,color:s.navy},children:[(0,Y.jsx)(`h2`,{id:`earnings`,children:`収益`}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(260px,1fr))`,gap:16},children:[(0,Y.jsxs)(`div`,{style:{...$,background:s.navy,color:s.white},children:[(0,Y.jsxs)(`div`,{"data-testid":`earnings-balance`,children:[`作者収益 `,(0,Y.jsxs)(`strong`,{style:{fontSize:38},children:[`$`,t.balanceUsd.toFixed(2)]})]}),(0,Y.jsxs)(`p`,{children:[`購入者残高 $`,e.wallet.buyerUsd.toFixed(2)]})]}),(0,Y.jsxs)(`div`,{style:$,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,Y.jsxs)(`div`,{children:[`利用回数`,(0,Y.jsx)(`h2`,{children:t.uses30d})]}),(0,Y.jsxs)(`div`,{children:[`解決率`,(0,Y.jsxs)(`h2`,{"data-testid":`earnings-solve-rate`,children:[Math.round(t.solved30d/t.uses30d*100),`%`]})]}),(0,Y.jsxs)(`div`,{children:[`30日間の収益`,(0,Y.jsxs)(`h2`,{children:[`$`,t.earned30dUsd.toFixed(2)]})]})]}),(0,Y.jsx)(`div`,{"aria-label":`30日間の利用回数`,style:{height:66,display:`flex`,alignItems:`end`,gap:3},children:t.dailyUses30d.map((e,n)=>(0,Y.jsx)(`div`,{title:`${e}回`,style:{flex:1,height:Math.max(3,e/Math.max(...t.dailyUses30d)*66),background:n===29?s.blue:s.border,borderRadius:3}},n))})]})]}),(0,Y.jsxs)(`div`,{style:{...$,marginTop:16,overflowX:`auto`},children:[(0,Y.jsx)(`h3`,{children:`出品中の Expert brain`}),(0,Y.jsxs)(`table`,{style:{width:`100%`,textAlign:`left`},children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{children:`パック`}),(0,Y.jsx)(`th`,{children:`価格`}),(0,Y.jsx)(`th`,{children:`利用`}),(0,Y.jsx)(`th`,{children:`解決`}),(0,Y.jsx)(`th`,{children:`収益`})]})}),(0,Y.jsx)(`tbody`,{children:e.packs.map(t=>{let n=e.ledger.filter(e=>e.packId===t.id&&t.author===`you`);return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{children:t.title}),(0,Y.jsxs)(`td`,{children:[`$`,t.priceUsd.toFixed(2)]}),(0,Y.jsx)(`td`,{children:t.author===`you`?n.length:`—`}),(0,Y.jsx)(`td`,{children:t.author===`you`?n.filter(e=>e.result===`solved`).length:`—`}),(0,Y.jsx)(`td`,{children:t.author===`you`?`$${n.reduce((e,t)=>e+t.authorUsd,0).toFixed(2)}`:`—`})]},t.id)})})]})]}),(0,Y.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(280px,1fr))`,gap:16,marginTop:16},children:[(0,Y.jsxs)(`div`,{style:$,children:[(0,Y.jsx)(`h3`,{children:`最近の利用`}),t.recentUses.map((e,t)=>(0,Y.jsxs)(`p`,{children:[e.solved?`解決`:`未解決`,` · +$`,e.amountUsd.toFixed(2),(0,Y.jsx)(`br`,{}),e.pages.map(e=>`[[${e}]]`).join(` `)]},t))]}),(0,Y.jsxs)(`div`,{style:$,children:[(0,Y.jsx)(`h3`,{children:`役に立ったページ`}),Object.entries(t.pageUses).map(([e,n])=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{children:[e,` · `,n,`回`]}),(0,Y.jsx)(`div`,{style:{height:6,background:s.border},children:(0,Y.jsx)(`div`,{style:{height:6,width:`${n/Math.max(1,...Object.values(t.pageUses))*100}%`,background:s.blue}})})]},e))]})]}),(0,Y.jsxs)(`div`,{style:{...$,marginTop:16},children:[(0,Y.jsx)(`h3`,{children:`内訳`}),(0,Y.jsxs)(`div`,{style:{display:`flex`,color:s.white},children:[(0,Y.jsx)(`div`,{style:{width:`90%`,padding:10,background:s.navy},children:`あなた 90%`}),(0,Y.jsx)(`div`,{style:{width:`10%`,padding:10,background:s.blue},children:`10%`})]})]})]})}function ct(e){let t=0xffffffff;for(let n of e){t^=n;for(let e=0;e<8;e++)t=t>>>1^-(t&1)&0xedb88320}return(t^0xffffffff)>>>0}function lt(e,t){let n=new TextEncoder,r=`packs/${e.id}/`,i=new Set,a=pe(e,t).map(({path:t,markdown:a})=>{if(!t.startsWith(r))throw Error(`Invalid import path`);let o=t.slice(6),s=o.split(`/`);if(s.length!==2||s[0]!==e.id||s.some(e=>!e||e===`.`||e===`..`||e.includes(`\\`)||Array.from(e).some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)))throw Error(`Invalid import path`);let c=o.normalize(`NFC`).toLowerCase();if(i.has(c))throw Error(`Duplicate import path`);i.add(c);let l=n.encode(o),u=n.encode(a);if(l.length>65535||u.length>0xffffffff)throw Error(`Import file is too large for ZIP`);return{name:l,content:u,crc:ct(u)}});if(a.length>65535)throw Error(`Too many import files for ZIP`);let o=0,s=0;for(let e of a)o+=30+e.name.length+e.content.length,s+=46+e.name.length;if(o>0xffffffff||s>0xffffffff||o+s+22>0xffffffff)throw Error(`Import is too large for ZIP`);let c=new Uint8Array(o+s+22),l=new DataView(c.buffer),u=(e,t)=>l.setUint16(e,t,!0),d=(e,t)=>l.setUint32(e,t,!0),f=0,p=o;for(let{name:e,content:t,crc:n}of a)d(f,67324752),u(f+4,20),u(f+6,2048),u(f+12,33),d(f+14,n),d(f+18,t.length),d(f+22,t.length),u(f+26,e.length),c.set(e,f+30),c.set(t,f+30+e.length),d(p,33639248),u(p+4,20),u(p+6,20),u(p+8,2048),u(p+14,33),d(p+16,n),d(p+20,t.length),d(p+24,t.length),u(p+28,e.length),d(p+42,f),c.set(e,p+46),f+=30+e.length+t.length,p+=46+e.length;return d(p,0x6054b50),u(p+8,a.length),u(p+10,a.length),d(p+12,s),d(p+16,o),c}function ut(){let[e,t]=(0,c.useState)(()=>K()),[n,r]=(0,c.useState)(!1),[i,a]=(0,c.useState)(`browser`),[o,s]=(0,c.useState)(``),[l,u]=(0,c.useState)(!1),[d,f]=(0,c.useState)(``),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(``);(0,c.useEffect)(()=>{g(crypto.randomUUID());try{let e=tt(window.localStorage);t(e.store),r(!0),e.recovered&&f(`以前の保存データを退避し、初期状態から始めました。`)}catch{f(`保存データを読み込めませんでした。保存は停止しています。`)}return it().then(a),rt(window,e=>{t(e.store),r(!0),e.recovered&&f(`以前の保存データを退避し、初期状態から始めました。`)},()=>{r(!1),f(`保存データを読み込めませんでした。保存は停止しています。`)})},[]);function _(r){if(!n)throw Error(`Store is unavailable`);nt(window.localStorage,r,e.rev),t(r)}function v(t,n){if(t){if(e.packs.some(e=>e.id===t.id))f(`同じ ID のパックが既にあります。別のパック名を指定してください。`);else try{_({...e,rev:e.rev+1,brain:{pages:n},packs:[...e.packs,t]}),f(`パックを出品しました。`)}catch{f(`保存に失敗しました。`)}}}function y(t){let n=M(e,t.id,h,t.score);if(!n.ok){f(`購入できませんでした: ${n.code}`);return}let r=ne(e,t.id,h,`web`,new Date().toISOString(),crypto.randomUUID(),e.rev,t.score);if(!r.ok)f(`購入できませんでした: ${r.code}`);else try{r.alreadyPurchased||_(r.store),f(r.alreadyPurchased?`${t.title} は購入済みです。`:`${t.title} を購入しました。`)}catch{f(`購入を保存できませんでした。再読み込みしてください。`)}}function b(t,n){let r=e.ledger.find(e=>e.packId===t),i=e.packs.find(e=>e.id===t);if(!r||!i||!j(e,t)){let e=`書き出すには購入が必要です。`;return f(e),{ok:!1,reason:e}}try{let a=re(e,t);if(!a.ok){let e=`パックを読み込めませんでした: ${a.code}`;return f(e),{ok:!1,reason:e}}let o=Uint8Array.from(n===`skill`?Re(i):lt(i,r.at)),s=URL.createObjectURL(new Blob([o.buffer],{type:`application/zip`}));try{let e=document.createElement(`a`);e.href=s,e.download=n===`skill`?`${t}.zip`:`${t}-gbrain.zip`,e.click()}finally{URL.revokeObjectURL(s)}return{ok:!0}}catch(e){let t=e instanceof Error?e.message:`書き出しに失敗しました。`;return f(t),{ok:!1,reason:t}}}function x(t,n){let r=N(e,t,n);if(!r.ok)f(`結果を保存できませんでした: ${r.code}`);else try{_(r.store),f(`利用結果を保存しました。`)}catch{f(`結果を保存できませんでした。`)}}function S(){try{return _({...K(),rev:e.rev+1}),m(e),f(`初期状態に戻しました。`),!0}catch{return f(`保存に失敗しました。`),!1}}function C(){if(p)try{_({...p,rev:e.rev+1}),m(null)}catch{f(`保存に失敗しました。`)}}return{store:e,ready:n,mode:i,query:o,setQuery:s,searched:l,setSearched:u,message:d,setMessage:f,previous:p,sessionId:h,results:l?Pe(o,e):[],publish:v,buy:y,download:b,markResult:x,reset:S,undo:C}}function dt(){return[{title:`GBrainX`}]}var ft=t(function(){let e=ut(),[t]=i(),n=Ye(e.setMessage,a(t.toString())),[r,o]=(0,c.useState)(`factory`),[l,u]=(0,c.useState)(!1),d=e.store.packs.some(e=>e.author===`you`),f=e.store.ledger.some(e=>e.result===`solved`),p=l?4:f?3:d?2:+!!n.state.draft,m=[[`factory`,`ファクトリー`],[`agent`,`Claude Code`],[`earnings`,`収益`]],h=r===`factory`?n.state.unconfirmed?`要確認の段落を判断してください。`:n.state.stage===0?`GBrain を読み込んでください。`:n.state.draft?`パックを出品できます。`:`分類と各ゲートの結果を確認してください。`:r===`agent`?`Expert brain を検索し、購入して読み込めます。`:`利用と収益を確認できます。`;return(0,Y.jsxs)(`main`,{style:{minHeight:`100vh`,background:s.background,color:s.navy,lineHeight:1.6},children:[(0,Y.jsxs)(`header`,{style:{background:s.navy,color:s.white,padding:`12px 24px`,display:`flex`,alignItems:`center`,gap:20,flexWrap:`wrap`},children:[(0,Y.jsx)(`strong`,{children:`GbrainX`}),(0,Y.jsx)(`span`,{children:e.mode===`local`?`ローカル版`:`ブラウザ版`}),(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":`画面`,style:{display:`flex`,padding:4,background:s.navyRaised,borderRadius:999},children:m.map(([t,n])=>(0,Y.jsx)(`button`,{type:`button`,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-selected":r===t,onClick:()=>{o(t),t===`earnings`&&e.store.ledger.length>0&&u(!0)},style:{border:0,borderRadius:999,padding:`7px 16px`,minHeight:36,cursor:`pointer`,background:r===t?s.white:`transparent`,color:r===t?s.navy:s.textOnNavy},children:n},t))}),(0,Y.jsx)(`div`,{style:{flex:`1 1 auto`}}),(0,Y.jsx)(`div`,{role:`img`,"aria-label":`進行状況`,style:{display:`flex`,gap:6},children:[`コンパイル`,`出品`,`解決`,`収益`].map((e,t)=>(0,Y.jsx)(`span`,{title:e,style:{width:t===p?24:6,height:6,borderRadius:999,background:t<p?s.mint:t===p?s.white:s.navyBorder}},e))}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{e.reset()&&(n.reset(),o(`factory`),u(!1))},disabled:!e.ready,children:`初期状態に戻す`}),e.previous&&(0,Y.jsx)(`button`,{type:`button`,onClick:e.undo,children:`元に戻す`})]}),(0,Y.jsxs)(`div`,{"aria-live":`polite`,style:{background:`#EAF1FA`,padding:`12px 24px`,color:s.navy},children:[(0,Y.jsx)(`strong`,{children:m.find(([e])=>e===r)?.[1]}),` · `,h]}),e.message&&(0,Y.jsx)(`p`,{role:`status`,children:e.message}),(0,Y.jsx)(`div`,{role:`tabpanel`,id:`panel-factory`,"aria-labelledby":`tab-factory`,hidden:r!==`factory`,children:(0,Y.jsx)(et,{factory:n,ready:e.ready,publish:()=>e.publish(n.state.draft,n.state.pages)})}),(0,Y.jsx)(`div`,{role:`tabpanel`,id:`panel-agent`,"aria-labelledby":`tab-agent`,hidden:r!==`agent`,children:(0,Y.jsx)(ot,{query:e.query,setQuery:e.setQuery,searched:e.searched,search:()=>e.setSearched(!0),results:e.results,store:e.store,ready:e.ready,sessionId:e.sessionId,buy:e.buy,download:e.download,markResult:e.markResult})}),(0,Y.jsx)(`div`,{role:`tabpanel`,id:`panel-earnings`,"aria-labelledby":`tab-earnings`,hidden:r!==`earnings`,children:(0,Y.jsx)(st,{store:e.store})})]})});export{ft as default,dt as meta};
@@ -1,7 +1,7 @@
1
1
  import{lt as e,o as t,st as n,t as r}from"./jsx-runtime-C8YK_IxR.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./use-lp-language-ij45BzB4.js";import{t as u}from"./lib-C32AnKSP.js";var d=e(n(),1),f=r();function p(){return(0,f.jsxs)(`svg`,{width:`26`,height:`26`,viewBox:`0 0 28 28`,"aria-hidden":`true`,children:[(0,f.jsx)(`rect`,{width:`28`,height:`28`,rx:`8`,fill:`#FFFFFF`}),(0,f.jsx)(`circle`,{cx:`9`,cy:`9`,r:`2.6`,fill:`#062544`}),(0,f.jsx)(`circle`,{cx:`19`,cy:`14`,r:`2.6`,fill:`#062544`}),(0,f.jsx)(`circle`,{cx:`9`,cy:`19`,r:`2.6`,fill:`#062544`}),(0,f.jsx)(`path`,{d:`M9 9L19 14L9 19`,stroke:`#062544`,strokeWidth:`1.6`,fill:`none`,strokeLinejoin:`round`})]})}function m(){return(0,f.jsxs)(`svg`,{width:`150`,height:`120`,viewBox:`0 0 150 120`,role:`img`,"aria-label":`GBrain notes as a linked graph`,children:[(0,f.jsx)(`line`,{x1:`40`,y1:`34`,x2:`104`,y2:`28`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`line`,{x1:`40`,y1:`34`,x2:`62`,y2:`88`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`line`,{x1:`104`,y1:`28`,x2:`112`,y2:`86`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`line`,{x1:`62`,y1:`88`,x2:`112`,y2:`86`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsxs)(`g`,{children:[(0,f.jsx)(`rect`,{x:`20`,y:`20`,width:`40`,height:`28`,rx:`4`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`line`,{x1:`28`,y1:`30`,x2:`52`,y2:`30`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`line`,{x1:`28`,y1:`38`,x2:`44`,y2:`38`,stroke:`#9FB4CC`,strokeWidth:`2`})]}),(0,f.jsxs)(`g`,{children:[(0,f.jsx)(`rect`,{x:`84`,y:`14`,width:`40`,height:`28`,rx:`4`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`line`,{x1:`92`,y1:`24`,x2:`116`,y2:`24`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`line`,{x1:`92`,y1:`32`,x2:`108`,y2:`32`,stroke:`#9FB4CC`,strokeWidth:`2`})]}),(0,f.jsxs)(`g`,{children:[(0,f.jsx)(`rect`,{x:`42`,y:`74`,width:`40`,height:`28`,rx:`4`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`line`,{x1:`50`,y1:`84`,x2:`74`,y2:`84`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`line`,{x1:`50`,y1:`92`,x2:`66`,y2:`92`,stroke:`#9FB4CC`,strokeWidth:`2`})]}),(0,f.jsxs)(`g`,{children:[(0,f.jsx)(`rect`,{x:`92`,y:`72`,width:`40`,height:`28`,rx:`4`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`line`,{x1:`100`,y1:`82`,x2:`124`,y2:`82`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`line`,{x1:`100`,y1:`90`,x2:`116`,y2:`90`,stroke:`#9FB4CC`,strokeWidth:`2`})]})]})}function h(){return(0,f.jsx)(`svg`,{width:`40`,height:`24`,viewBox:`0 0 40 24`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M2 12h30M26 5l7 7-7 7`,fill:`none`,stroke:`#9FC3EA`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function g(){return(0,f.jsxs)(`svg`,{width:`150`,height:`120`,viewBox:`0 0 150 120`,role:`img`,"aria-label":`four checks`,children:[(0,f.jsx)(`line`,{x1:`22`,y1:`60`,x2:`128`,y2:`60`,stroke:`#9FB4CC`,strokeWidth:`2`}),(0,f.jsx)(`circle`,{cx:`22`,cy:`60`,r:`14`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`path`,{d:`M16 60 l4 4 l8 -8`,fill:`none`,stroke:`#16A36A`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,f.jsx)(`circle`,{cx:`57`,cy:`60`,r:`14`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`path`,{d:`M51 60 l4 4 l8 -8`,fill:`none`,stroke:`#16A36A`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,f.jsx)(`circle`,{cx:`93`,cy:`60`,r:`14`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`path`,{d:`M87 60 l4 4 l8 -8`,fill:`none`,stroke:`#16A36A`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,f.jsx)(`circle`,{cx:`128`,cy:`60`,r:`14`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`2.5`}),(0,f.jsx)(`path`,{d:`M122 60 l4 4 l8 -8`,fill:`none`,stroke:`#16A36A`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function _(){return(0,f.jsxs)(`svg`,{width:`130`,height:`130`,viewBox:`0 -10 200 210`,role:`img`,"aria-label":`Claude Code loading an expert brain`,children:[(0,f.jsx)(`rect`,{x:`68`,y:`40`,width:`64`,height:`10`,rx:`3`,fill:`#0B3157`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`74`,y:`-6`,width:`52`,height:`34`,rx:`5`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`g`,{transform:`translate(100 11) scale(0.42) translate(-100 -11)`,children:(0,f.jsx)(`path`,{d:`M100 -11 c-10 0 -22 2 -24 12 c-10 2 -14 14 -8 22 c-4 10 4 20 14 18 c4 6 12 6 18 2 M100 -11 c10 0 22 2 24 12 c10 2 14 14 8 22 c4 10 -4 20 -14 18 c-4 6 -12 6 -18 2 M100 -11 v56`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`4`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,f.jsx)(`line`,{x1:`94.96`,y1:`8.48`,x2:`100.0`,y2:`11.0`,stroke:`#1E5AA8`,strokeWidth:`0.588`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`96.64`,y1:`15.2`,x2:`100.0`,y2:`11.0`,stroke:`#1E5AA8`,strokeWidth:`0.588`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`104.2`,y1:`7.640000000000001`,x2:`100.0`,y2:`11.0`,stroke:`#1E5AA8`,strokeWidth:`0.588`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`105.04`,y1:`14.36`,x2:`100.0`,y2:`11.0`,stroke:`#1E5AA8`,strokeWidth:`0.588`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`94.96`,y1:`8.48`,x2:`96.64`,y2:`15.2`,stroke:`#1E5AA8`,strokeWidth:`0.588`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`104.2`,y1:`7.640000000000001`,x2:`105.04`,y2:`14.36`,stroke:`#1E5AA8`,strokeWidth:`0.588`,opacity:`0.7`}),(0,f.jsx)(`circle`,{cx:`94.96`,cy:`8.48`,r:`1.092`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`96.64`,cy:`15.2`,r:`1.092`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`104.2`,cy:`7.640000000000001`,r:`1.092`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`105.04`,cy:`14.36`,r:`1.092`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`100.0`,cy:`11.0`,r:`1.092`,fill:`#1E5AA8`}),(0,f.jsx)(`path`,{d:`M100 34 v6`,stroke:`#062544`,strokeWidth:`3`,strokeLinecap:`round`}),(0,f.jsx)(`rect`,{x:`48`,y:`50`,width:`104`,height:`62`,rx:`8`,fill:`#1E5AA8`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`60`,y:`68`,width:`80`,height:`20`,rx:`4`,fill:`#062544`}),(0,f.jsx)(`rect`,{x:`66`,y:`75`,width:`68`,height:`6`,rx:`2`,fill:`#7FE3FF`}),(0,f.jsx)(`rect`,{x:`90`,y:`112`,width:`20`,height:`8`,fill:`#0B3157`}),(0,f.jsx)(`rect`,{x:`54`,y:`120`,width:`92`,height:`66`,rx:`8`,fill:`#1E5AA8`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`68`,y:`134`,width:`64`,height:`24`,rx:`3`,fill:`#0B3157`}),(0,f.jsx)(`rect`,{x:`74`,y:`141`,width:`10`,height:`10`,rx:`2`,fill:`#7FE3FF`}),(0,f.jsx)(`rect`,{x:`88`,y:`143`,width:`36`,height:`3`,rx:`1.5`,fill:`#5C82AE`}),(0,f.jsx)(`rect`,{x:`88`,y:`149`,width:`24`,height:`3`,rx:`1.5`,fill:`#5C82AE`}),(0,f.jsx)(`rect`,{x:`32`,y:`124`,width:`16`,height:`50`,rx:`4`,fill:`#0B3157`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`152`,y:`124`,width:`16`,height:`50`,rx:`4`,fill:`#0B3157`,stroke:`#062544`,strokeWidth:`3`})]})}function v(){return(0,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`path`,{d:`M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z`}),(0,f.jsx)(`path`,{d:`M4 19V5`})]})}function y(){return(0,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#16A36A`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,f.jsx)(`path`,{d:`M8 12l3 3 5-6`})]})}function b(){return(0,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#062544`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`rect`,{x:`5`,y:`11`,width:`14`,height:`10`,rx:`2`}),(0,f.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]})}function x(){return(0,f.jsxs)(`svg`,{width:`40`,height:`40`,viewBox:`72 36 56 56`,"aria-hidden":`true`,children:[(0,f.jsx)(`g`,{transform:`translate(100 62) scale(0.9) translate(-100 -62)`,children:(0,f.jsx)(`path`,{d:`M100 40 c-10 0 -22 2 -24 12 c-10 2 -14 14 -8 22 c-4 10 4 20 14 18 c4 6 12 6 18 2 M100 40 c10 0 22 2 24 12 c10 2 14 14 8 22 c4 10 -4 20 -14 18 c-4 6 -12 6 -18 2 M100 40 v56`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,f.jsx)(`line`,{x1:`89.2`,y1:`56.6`,x2:`100.0`,y2:`62.0`,stroke:`#1E5AA8`,strokeWidth:`1.26`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`92.8`,y1:`71.0`,x2:`100.0`,y2:`62.0`,stroke:`#1E5AA8`,strokeWidth:`1.26`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`109.0`,y1:`54.8`,x2:`100.0`,y2:`62.0`,stroke:`#1E5AA8`,strokeWidth:`1.26`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`110.8`,y1:`69.2`,x2:`100.0`,y2:`62.0`,stroke:`#1E5AA8`,strokeWidth:`1.26`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`89.2`,y1:`56.6`,x2:`92.8`,y2:`71.0`,stroke:`#1E5AA8`,strokeWidth:`1.26`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`109.0`,y1:`54.8`,x2:`110.8`,y2:`69.2`,stroke:`#1E5AA8`,strokeWidth:`1.26`,opacity:`0.7`}),(0,f.jsx)(`circle`,{cx:`89.2`,cy:`56.6`,r:`2.3400000000000003`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`92.8`,cy:`71.0`,r:`2.3400000000000003`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`109.0`,cy:`54.8`,r:`2.3400000000000003`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`110.8`,cy:`69.2`,r:`2.3400000000000003`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`100.0`,cy:`62.0`,r:`2.3400000000000003`,fill:`#1E5AA8`})]})}function S(){return(0,f.jsxs)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`path`,{d:`M9 2v6M15 2v6`}),(0,f.jsx)(`path`,{d:`M6 8h12v4a6 6 0 0 1-12 0z`}),(0,f.jsx)(`path`,{d:`M12 18v4`})]})}function C(){return(0,f.jsxs)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`rect`,{x:`3`,y:`6`,width:`18`,height:`13`,rx:`3`}),(0,f.jsx)(`path`,{d:`M3 10h18`}),(0,f.jsx)(`circle`,{cx:`16.5`,cy:`14.5`,r:`1.2`})]})}function w(){return(0,f.jsx)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M13 2L4 14h7l-1 8 9-12h-7l1-8z`})})}function T(){return(0,f.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#16A36A`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,f.jsx)(`path`,{d:`M8 12l3 3 5-6`})]})}function E(){return(0,f.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`path`,{d:`M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z`}),(0,f.jsx)(`path`,{d:`M9 12l2 2 4-4`})]})}function D(){return(0,f.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#062544`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`path`,{d:`M4 18a8 8 0 1 1 16 0`}),(0,f.jsx)(`path`,{d:`M12 18l4-6`})]})}function O(){return(0,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#062544`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,f.jsx)(`path`,{d:`M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18`})]})}function k(){return(0,f.jsxs)(`svg`,{width:`170`,height:`170`,viewBox:`0 -10 200 210`,role:`img`,"aria-label":`Claude Code solved`,children:[(0,f.jsx)(`rect`,{x:`68`,y:`40`,width:`64`,height:`10`,rx:`3`,fill:`#0B3157`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`74`,y:`16`,width:`52`,height:`30`,rx:`5`,fill:`#FFFFFF`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`g`,{transform:`translate(100 31) scale(0.38) translate(-100 -31)`,children:(0,f.jsx)(`path`,{d:`M100 9 c-10 0 -22 2 -24 12 c-10 2 -14 14 -8 22 c-4 10 4 20 14 18 c4 6 12 6 18 2 M100 9 c10 0 22 2 24 12 c10 2 14 14 8 22 c4 10 -4 20 -14 18 c-4 6 -12 6 -18 2 M100 9 v56`,fill:`none`,stroke:`#1E5AA8`,strokeWidth:`4`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,f.jsx)(`line`,{x1:`95.44`,y1:`28.72`,x2:`100.0`,y2:`31.0`,stroke:`#1E5AA8`,strokeWidth:`0.5319999999999999`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`96.96`,y1:`34.8`,x2:`100.0`,y2:`31.0`,stroke:`#1E5AA8`,strokeWidth:`0.5319999999999999`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`103.8`,y1:`27.96`,x2:`100.0`,y2:`31.0`,stroke:`#1E5AA8`,strokeWidth:`0.5319999999999999`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`104.56`,y1:`34.04`,x2:`100.0`,y2:`31.0`,stroke:`#1E5AA8`,strokeWidth:`0.5319999999999999`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`95.44`,y1:`28.72`,x2:`96.96`,y2:`34.8`,stroke:`#1E5AA8`,strokeWidth:`0.5319999999999999`,opacity:`0.7`}),(0,f.jsx)(`line`,{x1:`103.8`,y1:`27.96`,x2:`104.56`,y2:`34.04`,stroke:`#1E5AA8`,strokeWidth:`0.5319999999999999`,opacity:`0.7`}),(0,f.jsx)(`circle`,{cx:`95.44`,cy:`28.72`,r:`0.9880000000000001`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`96.96`,cy:`34.8`,r:`0.9880000000000001`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`103.8`,cy:`27.96`,r:`0.9880000000000001`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`104.56`,cy:`34.04`,r:`0.9880000000000001`,fill:`#1E5AA8`}),(0,f.jsx)(`circle`,{cx:`100.0`,cy:`31.0`,r:`0.9880000000000001`,fill:`#1E5AA8`}),(0,f.jsx)(`rect`,{x:`48`,y:`50`,width:`104`,height:`62`,rx:`8`,fill:`#1E5AA8`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`60`,y:`68`,width:`80`,height:`20`,rx:`4`,fill:`#062544`}),(0,f.jsx)(`rect`,{x:`66`,y:`75`,width:`68`,height:`6`,rx:`2`,fill:`#3DDC97`}),(0,f.jsx)(`rect`,{x:`90`,y:`112`,width:`20`,height:`8`,fill:`#0B3157`}),(0,f.jsx)(`rect`,{x:`54`,y:`120`,width:`92`,height:`66`,rx:`8`,fill:`#1E5AA8`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`68`,y:`134`,width:`64`,height:`24`,rx:`3`,fill:`#0B3157`}),(0,f.jsx)(`rect`,{x:`74`,y:`141`,width:`10`,height:`10`,rx:`2`,fill:`#3DDC97`}),(0,f.jsx)(`rect`,{x:`88`,y:`143`,width:`36`,height:`3`,rx:`1.5`,fill:`#5C82AE`}),(0,f.jsx)(`rect`,{x:`88`,y:`149`,width:`24`,height:`3`,rx:`1.5`,fill:`#5C82AE`}),(0,f.jsx)(`rect`,{x:`32`,y:`124`,width:`16`,height:`50`,rx:`4`,fill:`#0B3157`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`rect`,{x:`152`,y:`124`,width:`16`,height:`50`,rx:`4`,fill:`#0B3157`,stroke:`#062544`,strokeWidth:`3`}),(0,f.jsx)(`circle`,{cx:`168`,cy:`68`,r:`13`,fill:`#3DDC97`}),(0,f.jsx)(`path`,{d:`M162 68 l4.5 4.5 l8 -9`,fill:`none`,stroke:`#062544`,strokeWidth:`3.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function A(){return(0,f.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#062544`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M9 19c-4 1.5-4-2-6-2.5M15 21v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.3 4.3 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12 12 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.3 4.3 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21`})})}var j=`
2
2
  .buyer-end{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:24px}.buyer-end>div{flex:1 1 420px;min-width:0}.buyer-source{display:inline-flex;align-items:center;gap:10px;min-height:46px;padding:0 18px;border:1px solid #DCE5F0;border-radius:999px;color:#062544;font-weight:600}
3
- body{margin:0;background:#F5F8FC}.buyer{--navy:#062544;--muted:#4A6380;--border:#DCE5F0;background:#F5F8FC;color:var(--navy);font-family:Inter,'Noto Sans JP',system-ui,sans-serif;line-height:1.6}.buyer *{box-sizing:border-box}.buyer-wrap{max-width:1184px;margin:auto;padding-left:32px;padding-right:32px}.buyer-mono{font-family:'JetBrains Mono',ui-monospace,monospace}.buyer a{text-decoration:none}.buyer-header,.buyer-hero,.buyer-footer{background:var(--navy);color:white}.buyer-head{display:flex;align-items:center;gap:28px;min-height:64px}.buyer-nav{display:flex;gap:24px}.buyer-nav a{color:#C9D6E6;font-size:14px}.buyer-lang{display:flex;border:1px solid #2B4A6B;border-radius:999px;overflow:hidden}.buyer-lang button{min-width:44px;min-height:44px;border:0;cursor:pointer;font-size:12px}.buyer-pill{display:inline-flex;align-items:center;justify-content:center;min-height:50px;padding:0 26px;border:1px solid #2B4A6B;border-radius:999px;background:transparent;color:white;font-family:inherit;font-size:16px;font-weight:600;cursor:pointer}.buyer-form{border:0;background:white;color:#062544;font-size:16px;font-weight:700}.buyer-hero-inner{display:flex;flex-direction:column;align-items:center;text-align:center;gap:22px;padding-top:72px;padding-bottom:72px}.buyer h1{margin:0;font-size:clamp(34px,6.4vw,78px);line-height:1.12;font-weight:800;letter-spacing:-.025em}.buyer h1,.buyer h2,.buyer h3{word-break:auto-phrase;text-wrap:balance}.buyer h1 span,.buyer-end h2 span{display:block;color:#9FC3EA}.buyer-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:12px}.buyer-flow{display:flex;gap:12px;width:100%;margin-top:32px}.buyer-flow-card{flex:1;min-width:0;background:#0A2E52;border:1px solid #1D4570;border-radius:18px;padding:20px;display:flex;flex-direction:column;align-items:center;gap:10px}.buyer-flow-card p{margin:0;color:#C9D6E6;font-size:14px}.buyer-flow-art{height:130px;display:flex;align-items:center;justify-content:center}.buyer-arrow{align-self:center;color:#9FC3EA;font-size:28px}.buyer-section{padding-top:104px;padding-bottom:8px}.buyer-split{display:flex;flex-wrap:wrap;align-items:center;gap:56px}.buyer-split>div{flex:1 1 380px;min-width:0}.buyer h2{margin:0;font-size:clamp(28px,3.4vw,40px);line-height:1.2;font-weight:800;letter-spacing:-.02em}.buyer p{overflow-wrap:anywhere}.buyer-copy{color:var(--muted);font-size:17px}.buyer-label{font-size:12px;font-weight:600;letter-spacing:.06em}.buyer-terminal{background:#062544;color:#C9D6E6;border-radius:18px;padding:22px}.buyer-terminal-row{background:#0A2E52;border-radius:10px;padding:10px 12px;margin-top:10px;font-size:13px}.buyer-card{background:white;border:1px solid var(--border);border-radius:20px;padding:26px}.buyer-grid{display:flex;flex-wrap:wrap;gap:16px}.buyer-grid>div{flex:1 1 220px;min-width:0}.buyer-step{display:flex;flex-direction:column;gap:12px}.buyer-step p,.buyer-feature p{margin:0;color:var(--muted);font-size:14px}.buyer-feature{display:flex;gap:14px;margin-top:16px}.buyer-icon{flex:none;width:40px;height:40px;border:1px solid var(--border);border-radius:12px;background:white;display:grid;place-items:center;color:#1E5AA8}.buyer-end{background:#062544;color:white;border-radius:24px;padding:40px 48px}.buyer-end h2{font-size:clamp(30px,4vw,46px)}.buyer-footer .buyer-wrap{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;padding-top:28px;padding-bottom:28px;font-size:13px;color:#9FB4CC}@media(max-width:760px){.buyer-wrap{padding-left:20px;padding-right:20px}.buyer-nav{display:none}.buyer-head{gap:12px;flex-wrap:wrap;padding-top:10px;padding-bottom:10px}.buyer-flow{flex-direction:column}.buyer-arrow{transform:rotate(90deg)}.buyer-end{padding:32px 24px}.buyer-section{padding-top:72px}.buyer-terminal{overflow-wrap:anywhere}}
3
+ body{margin:0;background:#F5F8FC}.buyer{--navy:#062544;--muted:#4A6380;--border:#DCE5F0;background:#F5F8FC;color:var(--navy);font-family:Inter,'Noto Sans JP',system-ui,sans-serif;line-height:1.6}.buyer *{box-sizing:border-box}.buyer-wrap{max-width:1184px;margin:auto;padding-left:32px;padding-right:32px}.buyer-mono{font-family:'JetBrains Mono',ui-monospace,monospace}.buyer a{text-decoration:none}.buyer-header,.buyer-hero,.buyer-footer{background:var(--navy);color:white}.buyer-head{display:flex;align-items:center;gap:28px;min-height:64px}.buyer-nav{display:flex;gap:24px}.buyer-nav a{color:#C9D6E6;font-size:14px}.buyer-lang{display:flex;border:1px solid #2B4A6B;border-radius:999px;overflow:hidden}.buyer-lang button{min-width:44px;min-height:44px;border:0;cursor:pointer;font-size:12px}.buyer-pill{display:inline-flex;align-items:center;justify-content:center;min-height:50px;padding:0 26px;border:1px solid #2B4A6B;border-radius:999px;background:transparent;color:white;font-family:inherit;font-size:16px;font-weight:600;cursor:pointer}.buyer-form{border:0;background:white;color:#062544;font-size:16px;font-weight:700}.buyer-hero-inner{display:flex;flex-direction:column;align-items:center;text-align:center;gap:22px;padding-top:72px;padding-bottom:72px}.buyer h1{margin:0;font-size:clamp(34px,6.4vw,78px);line-height:1.12;font-weight:800;letter-spacing:-.025em}.buyer h1,.buyer h2,.buyer h3{word-break:auto-phrase;text-wrap:balance}.buyer h1 span,.buyer-end h2 span{display:block;color:#9FC3EA}.buyer-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:12px}.buyer-flow{display:flex;gap:12px;width:100%;margin-top:32px}.buyer-flow-card{flex:1;min-width:0;background:#0A2E52;border:1px solid #1D4570;border-radius:18px;padding:20px;display:flex;flex-direction:column;align-items:center;gap:10px}.buyer-flow-card p{margin:0;color:#C9D6E6;font-size:14px}.buyer-flow-art{height:130px;display:flex;align-items:center;justify-content:center}.buyer-arrow{align-self:center;color:#9FC3EA;font-size:28px}.buyer-section{padding-top:104px;padding-bottom:8px}.buyer-split{display:flex;flex-wrap:wrap;align-items:center;gap:56px}.buyer-split>div{flex:1 1 380px;min-width:0}.buyer h2{margin:0;font-size:clamp(28px,3.4vw,40px);line-height:1.2;font-weight:800;letter-spacing:-.02em}.buyer p{overflow-wrap:anywhere}.buyer-copy{color:var(--muted);font-size:17px}.buyer-label{font-size:12px;font-weight:600;letter-spacing:.06em}.buyer-terminal{background:#062544;color:#C9D6E6;border-radius:18px;padding:22px}.buyer-terminal-row{background:#0A2E52;border-radius:10px;padding:10px 12px;margin-top:10px;font-size:13px}.buyer-card{background:white;border:1px solid var(--border);border-radius:20px;padding:26px}.buyer-grid{display:flex;flex-wrap:wrap;gap:16px}.buyer-grid>div{flex:1 1 220px;min-width:0}.buyer-step{display:flex;flex-direction:column;gap:12px}.buyer-step p,.buyer-feature p{margin:0;color:var(--muted);font-size:14px}.buyer-feature{display:flex;gap:14px;margin-top:16px}.buyer-icon{flex:none;width:40px;height:40px;border:1px solid var(--border);border-radius:12px;background:white;display:grid;place-items:center;color:#1E5AA8}.buyer-end{background:#062544;color:white;border-radius:24px;padding:40px 48px}.buyer-end h2{font-size:clamp(30px,4vw,46px)}.buyer-footer .buyer-wrap{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;padding-top:28px;padding-bottom:28px;font-size:13px;color:#9FB4CC}@media(max-width:760px){.buyer-wrap{padding-left:20px;padding-right:20px}.buyer-nav{display:none}.buyer-head{gap:12px;flex-wrap:wrap;padding-top:10px;padding-bottom:10px}.buyer-flow{flex-direction:column}.buyer-arrow{transform:rotate(90deg)}.buyer-section{padding-top:72px}.buyer-terminal{overflow-wrap:anywhere}}
4
4
  .buyer-section{padding-top:104px}.buyer-split>div:first-child{display:flex;flex-direction:column;gap:16px}.buyer-split>div:first-child>.buyer-copy{margin:0}.buyer-split>div:nth-child(2){flex-basis:420px}.buyer-feature p{font-size:15px}.buyer-step strong{font-size:17px}.buyer-how{display:flex;flex-direction:column;gap:28px}.buyer-how-intro{display:flex;flex-direction:column;gap:10px;max-width:720px}.buyer-how-intro p{margin:0}.buyer-safety{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:32px;margin-top:32px}.buyer-safety .buyer-feature{margin-top:0}.buyer-safety .buyer-icon{width:48px;height:48px;border-radius:14px}.buyer-safety .buyer-feature strong{font-size:17px}.buyer-safety .buyer-feature p{font-size:15px;margin-top:4px}.buyer-source-copy{display:flex;flex-direction:column;gap:10px}.buyer-source-copy blockquote{margin:0;font-size:clamp(19px,2.2vw,24px);line-height:1.4}.buyer-source-copy p{margin:0;font-size:15px}.buyer-source-copy small{font-size:13px;color:#4A6380}.buyer-source-note{font-size:12px;color:#4A6380}.buyer-end>div{display:flex;flex-direction:column;gap:18px}.buyer-end p{margin:0}.buyer-end h2{line-height:1.08;letter-spacing:-.03em}.buyer-terminal-row:last-child{background:transparent;border:1px dashed #2B4A6B;color:#7E97B3}
5
5
  .buyer-brains{display:flex;flex-direction:column;gap:28px}.buyer-brains-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:12px}.buyer-brains-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:16px}.buyer-brain{display:flex;flex-direction:column;gap:12px;padding:20px}.buyer-command{overflow-wrap:anywhere}@media(max-width:760px){.buyer-head>.buyer-form,.buyer-arrow{display:none}.buyer-command{word-break:break-all;border-radius:14px!important;font-size:12px!important}.buyer-brains-grid{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;gap:12px;padding-bottom:8px}.buyer-brains-grid>.buyer-brain{flex:0 0 82%;scroll-snap-align:start}}
6
6
  .buyer-cta-row{align-items:center;gap:10px}.buyer-cta-row .buyer-pill{gap:8px;padding:0 22px}.buyer-demo-link{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:0 10px;color:#C9D6E6;font-size:15px;font-weight:600}.buyer-cta-row svg{flex:none}@media(max-width:760px){.buyer-head>.buyer-form,.buyer-arrow{display:none}.buyer-cta-row{width:100%}.buyer-cta-row .buyer-pill{flex:1 1 0;padding:0 14px}.buyer-demo-link{flex:1 1 100%}}
7
- `;function M({lang:e,onLang:t}){let n=i(e),[r,s]=(0,d.useState)(!1),l=`/demo?lang=${e}`,M=`/sell?lang=${e}`,N=[[n.f1t,n.f1d],[n.f2t,n.f2d],[n.f3t,n.f3d]],P=[[n.b1t,n.b1d],[n.b2t,n.b2d],[n.b3t,n.b3d]],F=[[n.s1t,n.s1d],[n.s2t,n.s2d],[n.s3t,n.s3d]],I=[[n.k1t,n.k1d],[n.k2t,n.k2d],[n.k3t,n.k3d]],L=[(0,f.jsx)(m,{}),(0,f.jsx)(g,{}),(0,f.jsx)(_,{})],R=[(0,f.jsx)(v,{}),(0,f.jsx)(y,{}),(0,f.jsx)(b,{})],z=[(0,f.jsx)(S,{}),(0,f.jsx)(C,{}),(0,f.jsx)(w,{})],B=[(0,f.jsx)(T,{}),(0,f.jsx)(E,{}),(0,f.jsx)(D,{})],V=(0,f.jsxs)(a,{audience:`buyer`,lang:e,title:n.formNote,className:`buyer-pill buyer-form`,children:[(0,f.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M12 2l2.2 6.3L20.5 10.5l-6.3 2.2L12 19l-2.2-6.3L3.5 10.5l6.3-2.2z`,fill:`currentColor`})}),n.ctaForm]}),H=(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`button`,{type:`button`,className:`buyer-pill`,onClick:()=>s(!0),children:[(0,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`}),(0,f.jsx)(`path`,{d:`M10 8.2v7.6l6-3.8z`,fill:`currentColor`})]}),n.ctaVideo]}),(0,f.jsxs)(u,{className:`buyer-demo-link`,to:l,children:[(0,f.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M5 3l14 7-6 2-2 6z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinejoin:`round`})}),n.ctaDemo]})]});return(0,f.jsxs)(`div`,{className:`buyer`,lang:e,children:[(0,f.jsx)(`style`,{children:j}),(0,f.jsx)(`header`,{className:`buyer-header`,children:(0,f.jsxs)(`div`,{className:`buyer-wrap buyer-head`,children:[(0,f.jsxs)(`a`,{href:`#top`,style:{color:`white`,fontWeight:700,fontSize:17,whiteSpace:`nowrap`,display:`flex`,alignItems:`center`,gap:10},children:[(0,f.jsx)(p,{}),`GbrainX`]}),(0,f.jsxs)(`nav`,{className:`buyer-nav`,"aria-label":n.navLabel,children:[(0,f.jsx)(`a`,{href:`#how`,children:n.navHow}),(0,f.jsx)(`a`,{href:`#safety`,children:n.navSafety}),(0,f.jsx)(u,{to:M,children:n.navOther})]}),(0,f.jsx)(`div`,{style:{flex:1}}),(0,f.jsx)(o,{className:`buyer-lang`,lang:e,onLang:t,buttonStyle:e=>({background:e?`white`:`transparent`,color:e?`#062544`:`#C9D6E6`})}),(0,f.jsx)(a,{audience:`buyer`,lang:e,title:n.formNote,className:`buyer-pill buyer-form`,children:n.ctaForm})]})}),(0,f.jsxs)(`main`,{children:[(0,f.jsx)(`section`,{id:`top`,className:`buyer-hero`,children:(0,f.jsxs)(`div`,{className:`buyer-wrap buyer-hero-inner`,children:[(0,f.jsxs)(`h1`,{children:[n.h1a,(0,f.jsx)(`span`,{children:n.h1b})]}),(0,f.jsxs)(`div`,{className:`buyer-actions buyer-cta-row`,children:[V,H]}),(0,f.jsx)(`span`,{className:`buyer-mono buyer-command`,style:{fontSize:13,color:`#9FB4CC`,background:`#0B3157`,padding:`8px 14px`,borderRadius:999},children:`$ claude mcp add gbrainx -- npx -y @takeokunn/gbrainx-mcp`}),(0,f.jsx)(`div`,{className:`buyer-flow`,children:N.map(([e,t],n)=>(0,f.jsxs)(`div`,{style:{display:`contents`},children:[n>0&&(0,f.jsx)(`span`,{className:`buyer-arrow`,"aria-hidden":`true`,children:(0,f.jsx)(h,{})}),(0,f.jsxs)(`div`,{className:`buyer-flow-card`,children:[(0,f.jsx)(`div`,{className:`buyer-flow-art`,children:L[n]}),(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]})]},e))}),(0,f.jsx)(`small`,{style:{color:`#7E97B3`},children:n.flowNote})]})}),(0,f.jsxs)(`section`,{className:`buyer-wrap buyer-section buyer-split`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#D64545`},children:n.pK}),(0,f.jsx)(`h2`,{children:n.pT}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.pD})]}),(0,f.jsxs)(`div`,{className:`buyer-terminal buyer-mono`,children:[(0,f.jsxs)(`div`,{children:[`claude-code `,(0,f.jsxs)(`span`,{style:{float:`right`,color:`#FF9A9A`},children:[`● `,n.tStuck]})]}),(0,f.jsxs)(`div`,{className:`buyer-terminal-row`,children:[`✗ `,n.tA1,(0,f.jsx)(`br`,{}),`order #1042 · 2 charges`]}),(0,f.jsxs)(`div`,{className:`buyer-terminal-row`,children:[`✗ `,n.tA2,` `,(0,f.jsxs)(`span`,{style:{color:`#F6C343`},children:[`↻ `,n.tLoop]}),(0,f.jsx)(`br`,{}),`order #1042 · 2 charges`]}),(0,f.jsx)(`div`,{className:`buyer-terminal-row`,children:n.tA3})]})]}),(0,f.jsxs)(`section`,{className:`buyer-wrap buyer-section buyer-split`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#16A36A`},children:n.sK}),(0,f.jsx)(`h2`,{children:n.sT}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.sD}),P.map(([e,t],n)=>(0,f.jsxs)(`div`,{className:`buyer-feature`,children:[(0,f.jsx)(`span`,{className:`buyer-icon`,"aria-hidden":`true`,children:R[n]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]})]},e))]}),(0,f.jsxs)(`div`,{className:`buyer-card`,style:{padding:`24px 26px`,borderRadius:18},children:[(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:12},children:[(0,f.jsx)(x,{}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`strong`,{children:`Stripe Double-Charge Prevention`}),(0,f.jsx)(`div`,{className:`buyer-mono`,style:{fontSize:12,color:`#4A6380`},children:`expert brain · from GBrain · $0.50`})]})]}),(0,f.jsxs)(`div`,{className:`buyer-mono`,style:{fontSize:13,lineHeight:2,overflowWrap:`anywhere`},children:[(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`symptom`}),` retries create a second charge`,(0,f.jsx)(`br`,{}),(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`cause`}),` no [[idempotency-key]] on retries`,(0,f.jsx)(`br`,{}),`webhook events arrive twice`,(0,f.jsx)(`br`,{}),(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`fix`}),` `,(0,f.jsxs)(`span`,{style:{color:`#16A36A`},children:[`+ Idempotency-Key per order`,(0,f.jsx)(`br`,{}),`+ skip already-processed event ids`]}),(0,f.jsx)(`br`,{}),(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`avoid`}),` only disabling the pay button`]}),(0,f.jsxs)(`div`,{className:`buyer-mono`,style:{display:`flex`,flexWrap:`wrap`,gap:8,marginTop:12,fontSize:12},children:[(0,f.jsx)(`span`,{style:{padding:`4px 10px`,borderRadius:999,background:`#E3F6EC`,color:`#0E6B45`},children:`eval passed`}),(0,f.jsx)(`span`,{style:{padding:`4px 10px`,borderRadius:999,background:`#DCE8F7`},children:`sources [1][2]`}),(0,f.jsx)(`span`,{style:{padding:`4px 10px`,borderRadius:999,background:`#DCE8F7`},children:`secrets 0`})]})]})]}),(0,f.jsxs)(`section`,{id:`brains`,className:`buyer-wrap buyer-section buyer-brains`,children:[(0,f.jsxs)(`div`,{className:`buyer-brains-head`,children:[(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#1E5AA8`},children:n.brK}),(0,f.jsx)(`h2`,{children:n.brT})]}),(0,f.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:`#B45309`,background:`#FEF3C7`,borderRadius:999,padding:`5px 12px`},children:n.brSub})]}),(0,f.jsx)(`div`,{className:`buyer-brains-grid`,children:n.brains.map(e=>(0,f.jsxs)(`article`,{className:`buyer-card buyer-brain`,children:[(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[(0,f.jsx)(`img`,{src:`/avatars/`+e.name.toLowerCase()+`.svg`,alt:``,width:48,height:48,style:{flex:`0 0 auto`,width:48,height:48,borderRadius:999,display:`block`}}),(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,minWidth:0},children:[(0,f.jsx)(`strong`,{style:{fontSize:16,fontWeight:800},children:e.name}),(0,f.jsx)(`span`,{style:{fontSize:13,color:`#4A6380`},children:e.role})]})]}),(0,f.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6},children:e.tags.map(e=>(0,f.jsx)(`span`,{className:`buyer-mono`,style:{fontSize:12,padding:`2px 10px`,borderRadius:999,background:`#DCE8F7`},children:e.n},e.n))}),(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:[(0,f.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:`#4A6380`},children:n.brQ}),e.qs.map(e=>(0,f.jsxs)(`div`,{style:{display:`flex`,gap:8,fontSize:14,lineHeight:1.45},children:[(0,f.jsx)(`span`,{className:`buyer-mono`,style:{color:`#1E5AA8`,fontWeight:700},children:`Q`}),(0,f.jsx)(`span`,{children:e.q})]},e.q))]}),(0,f.jsx)(`div`,{style:{flex:`1 1 auto`}}),(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,paddingTop:10,borderTop:`1px solid #DCE5F0`},children:[(0,f.jsxs)(`span`,{className:`buyer-mono`,style:{fontSize:15,fontWeight:600},children:[e.price,` `,(0,f.jsx)(`span`,{style:{fontSize:12,color:`#4A6380`},children:n.brPer})]}),(0,f.jsxs)(`span`,{style:{fontSize:11.5,fontWeight:700,padding:`2px 9px`,borderRadius:999,background:`#E3F6EC`,color:`#0E7A4F`},children:[`✓ `,n.brBadge]})]})]},e.name))})]}),(0,f.jsxs)(`section`,{id:`how`,className:`buyer-wrap buyer-section buyer-how`,children:[(0,f.jsxs)(`div`,{className:`buyer-how-intro`,children:[(0,f.jsx)(`h2`,{children:n.howTitle}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.howSub})]}),(0,f.jsx)(`div`,{className:`buyer-grid`,children:F.map(([e,t],n)=>(0,f.jsxs)(`div`,{className:`buyer-card buyer-step`,children:[(0,f.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[z[n],(0,f.jsxs)(`span`,{className:`buyer-mono`,style:{color:`#4A6380`,fontSize:12},children:[`0`,n+1]})]}),(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]},e))})]}),(0,f.jsxs)(`section`,{id:`safety`,className:`buyer-wrap buyer-section`,children:[(0,f.jsx)(`h2`,{children:n.safeTitle}),(0,f.jsx)(`div`,{className:`buyer-safety`,children:I.map(([e,t],n)=>(0,f.jsxs)(`div`,{className:`buyer-feature`,children:[(0,f.jsx)(`span`,{className:`buyer-icon`,"aria-hidden":`true`,children:B[n]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]})]},e))})]}),(0,f.jsx)(`section`,{className:`buyer-wrap buyer-section`,children:(0,f.jsxs)(`div`,{className:`buyer-card`,style:{display:`flex`,flexWrap:`wrap`,gap:28,alignItems:`center`,padding:`32px 36px`},children:[(0,f.jsxs)(`div`,{className:`buyer-source-copy`,style:{flex:`2 1 420px`,minWidth:0},children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#1E5AA8`},children:`BUILT ON GBRAIN`}),(0,f.jsx)(`blockquote`,{lang:`en`,style:{fontWeight:700},children:`“GBrain gives your AI agents shared, cited memory over plain Markdown.”`}),(0,f.jsx)(`small`,{children:n.gbSrc}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.gbBody})]}),(0,f.jsxs)(`div`,{style:{flex:`1 1 220px`,display:`flex`,flexDirection:`column`,gap:10},children:[(0,f.jsxs)(`a`,{href:`https://github.com/garrytan/gbrain`,className:`buyer-source`,children:[(0,f.jsx)(A,{}),`garrytan/gbrain`]}),(0,f.jsxs)(`a`,{href:`https://gbrain.io`,className:`buyer-source`,children:[(0,f.jsx)(O,{}),`gbrain.io`]})]}),(0,f.jsx)(`small`,{className:`buyer-source-note`,style:{flex:`1 1 100%`},children:n.gbNote})]})}),(0,f.jsx)(`section`,{className:`buyer-wrap buyer-section`,style:{paddingBottom:96},children:(0,f.jsxs)(`div`,{className:`buyer-end`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`h2`,{children:[n.h1a,(0,f.jsx)(`span`,{children:n.h1b})]}),(0,f.jsx)(`p`,{style:{color:`#C9D6E6`},children:n.endSub}),(0,f.jsxs)(`div`,{className:`buyer-actions buyer-cta-row`,style:{justifyContent:`start`},children:[V,H]})]}),(0,f.jsx)(k,{})]})})]}),(0,f.jsx)(`footer`,{className:`buyer-footer`,children:(0,f.jsxs)(`div`,{className:`buyer-wrap`,children:[(0,f.jsx)(`span`,{children:n.footer}),(0,f.jsxs)(u,{to:M,style:{color:`white`},children:[n.navOther,` →`]})]})}),(0,f.jsx)(c,{open:r,onClose:()=>s(!1),label:n.ctaVideo})]})}function N({location:e}){let t=i(s(new URLSearchParams(e.search).get(`lang`)));return[{title:`GbrainX | ${t.h1a} ${t.h1b}`},{name:`description`,content:t.pD}]}var P=t(function(){let[e,t]=l();return(0,f.jsx)(M,{lang:e,onLang:t})});export{P as default,N as meta};
7
+ `;function M({lang:e,onLang:t}){let n=i(e),[r,s]=(0,d.useState)(!1),l=`/demo?lang=${e}`,M=`/sell?lang=${e}`,N=[[n.f1t,n.f1d],[n.f2t,n.f2d],[n.f3t,n.f3d]],P=[[n.b1t,n.b1d],[n.b2t,n.b2d],[n.b3t,n.b3d]],F=[[n.s1t,n.s1d],[n.s2t,n.s2d],[n.s3t,n.s3d]],I=[[n.k1t,n.k1d],[n.k2t,n.k2d],[n.k3t,n.k3d]],L=[(0,f.jsx)(m,{}),(0,f.jsx)(g,{}),(0,f.jsx)(_,{})],R=[(0,f.jsx)(v,{}),(0,f.jsx)(y,{}),(0,f.jsx)(b,{})],z=[(0,f.jsx)(S,{}),(0,f.jsx)(C,{}),(0,f.jsx)(w,{})],B=[(0,f.jsx)(T,{}),(0,f.jsx)(E,{}),(0,f.jsx)(D,{})],V=(0,f.jsxs)(a,{audience:`buyer`,lang:e,title:n.formNote,className:`buyer-pill buyer-form`,children:[(0,f.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M12 2l2.2 6.3L20.5 10.5l-6.3 2.2L12 19l-2.2-6.3L3.5 10.5l6.3-2.2z`,fill:`currentColor`})}),n.ctaForm]}),H=(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`button`,{type:`button`,className:`buyer-pill`,onClick:()=>s(!0),children:[(0,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`}),(0,f.jsx)(`path`,{d:`M10 8.2v7.6l6-3.8z`,fill:`currentColor`})]}),n.ctaVideo]}),(0,f.jsxs)(u,{className:`buyer-demo-link`,to:l,children:[(0,f.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M5 3l14 7-6 2-2 6z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinejoin:`round`})}),n.ctaDemo]})]});return(0,f.jsxs)(`div`,{className:`buyer`,lang:e,children:[(0,f.jsx)(`style`,{children:j}),(0,f.jsx)(`header`,{className:`buyer-header`,children:(0,f.jsxs)(`div`,{className:`buyer-wrap buyer-head`,children:[(0,f.jsxs)(`a`,{href:`#top`,style:{color:`white`,fontWeight:700,fontSize:17,whiteSpace:`nowrap`,display:`flex`,alignItems:`center`,gap:10},children:[(0,f.jsx)(p,{}),`GbrainX`]}),(0,f.jsxs)(`nav`,{className:`buyer-nav`,"aria-label":n.navLabel,children:[(0,f.jsx)(`a`,{href:`#how`,children:n.navHow}),(0,f.jsx)(`a`,{href:`#safety`,children:n.navSafety}),(0,f.jsx)(u,{to:M,children:n.navOther})]}),(0,f.jsx)(`div`,{style:{flex:1}}),(0,f.jsx)(o,{className:`buyer-lang`,lang:e,onLang:t,buttonStyle:e=>({background:e?`white`:`transparent`,color:e?`#062544`:`#C9D6E6`})}),(0,f.jsx)(a,{audience:`buyer`,lang:e,title:n.formNote,className:`buyer-pill buyer-form`,children:n.ctaForm})]})}),(0,f.jsxs)(`main`,{children:[(0,f.jsx)(`section`,{id:`top`,className:`buyer-hero`,children:(0,f.jsxs)(`div`,{className:`buyer-wrap buyer-hero-inner`,children:[(0,f.jsxs)(`h1`,{children:[n.h1a,(0,f.jsx)(`span`,{children:n.h1b})]}),(0,f.jsxs)(`div`,{className:`buyer-actions buyer-cta-row`,children:[V,H]}),(0,f.jsx)(`span`,{className:`buyer-mono buyer-command`,style:{fontSize:13,color:`#9FB4CC`,background:`#0B3157`,padding:`8px 14px`,borderRadius:999},children:`$ claude mcp add gbrainx -- npx -y @takeokunn/gbrainx-mcp`}),(0,f.jsx)(`div`,{className:`buyer-flow`,children:N.map(([e,t],n)=>(0,f.jsxs)(`div`,{style:{display:`contents`},children:[n>0&&(0,f.jsx)(`span`,{className:`buyer-arrow`,"aria-hidden":`true`,children:(0,f.jsx)(h,{})}),(0,f.jsxs)(`div`,{className:`buyer-flow-card`,children:[(0,f.jsx)(`div`,{className:`buyer-flow-art`,children:L[n]}),(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]})]},e))}),(0,f.jsx)(`small`,{style:{color:`#7E97B3`},children:n.flowNote})]})}),(0,f.jsxs)(`section`,{className:`buyer-wrap buyer-section buyer-split`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#D64545`},children:n.pK}),(0,f.jsx)(`h2`,{children:n.pT}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.pD})]}),(0,f.jsxs)(`div`,{className:`buyer-terminal buyer-mono`,children:[(0,f.jsxs)(`div`,{children:[`claude-code `,(0,f.jsxs)(`span`,{style:{float:`right`,color:`#FF9A9A`},children:[`● `,n.tStuck]})]}),(0,f.jsxs)(`div`,{className:`buyer-terminal-row`,children:[`✗ `,n.tA1,(0,f.jsx)(`br`,{}),`order #1042 · 2 charges`]}),(0,f.jsxs)(`div`,{className:`buyer-terminal-row`,children:[`✗ `,n.tA2,` `,(0,f.jsxs)(`span`,{style:{color:`#F6C343`},children:[`↻ `,n.tLoop]}),(0,f.jsx)(`br`,{}),`order #1042 · 2 charges`]}),(0,f.jsx)(`div`,{className:`buyer-terminal-row`,children:n.tA3})]})]}),(0,f.jsxs)(`section`,{className:`buyer-wrap buyer-section buyer-split`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#16A36A`},children:n.sK}),(0,f.jsx)(`h2`,{children:n.sT}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.sD}),P.map(([e,t],n)=>(0,f.jsxs)(`div`,{className:`buyer-feature`,children:[(0,f.jsx)(`span`,{className:`buyer-icon`,"aria-hidden":`true`,children:R[n]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]})]},e))]}),(0,f.jsxs)(`div`,{className:`buyer-card`,style:{padding:`24px 26px`,borderRadius:18},children:[(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:12},children:[(0,f.jsx)(x,{}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`strong`,{children:`Stripe Double-Charge Prevention`}),(0,f.jsx)(`div`,{className:`buyer-mono`,style:{fontSize:12,color:`#4A6380`},children:`expert brain · from GBrain · $0.50`})]})]}),(0,f.jsxs)(`div`,{className:`buyer-mono`,style:{fontSize:13,lineHeight:2,overflowWrap:`anywhere`},children:[(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`symptom`}),` retries create a second charge`,(0,f.jsx)(`br`,{}),(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`cause`}),` no [[idempotency-key]] on retries`,(0,f.jsx)(`br`,{}),`webhook events arrive twice`,(0,f.jsx)(`br`,{}),(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`fix`}),` `,(0,f.jsxs)(`span`,{style:{color:`#16A36A`},children:[`+ Idempotency-Key per order`,(0,f.jsx)(`br`,{}),`+ skip already-processed event ids`]}),(0,f.jsx)(`br`,{}),(0,f.jsx)(`span`,{style:{color:`#1E5AA8`},children:`avoid`}),` only disabling the pay button`]}),(0,f.jsxs)(`div`,{className:`buyer-mono`,style:{display:`flex`,flexWrap:`wrap`,gap:8,marginTop:12,fontSize:12},children:[(0,f.jsx)(`span`,{style:{padding:`4px 10px`,borderRadius:999,background:`#E3F6EC`,color:`#0E6B45`},children:`eval passed`}),(0,f.jsx)(`span`,{style:{padding:`4px 10px`,borderRadius:999,background:`#DCE8F7`},children:`sources [1][2]`}),(0,f.jsx)(`span`,{style:{padding:`4px 10px`,borderRadius:999,background:`#DCE8F7`},children:`secrets 0`})]})]})]}),(0,f.jsxs)(`section`,{id:`brains`,className:`buyer-wrap buyer-section buyer-brains`,children:[(0,f.jsxs)(`div`,{className:`buyer-brains-head`,children:[(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#1E5AA8`},children:n.brK}),(0,f.jsx)(`h2`,{children:n.brT})]}),(0,f.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:`#B45309`,background:`#FEF3C7`,borderRadius:999,padding:`5px 12px`},children:n.brSub})]}),(0,f.jsx)(`div`,{className:`buyer-brains-grid`,children:n.brains.map(e=>(0,f.jsxs)(`article`,{className:`buyer-card buyer-brain`,children:[(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[(0,f.jsx)(`img`,{src:`/avatars/`+e.name.toLowerCase()+`.svg`,alt:``,width:48,height:48,style:{flex:`0 0 auto`,width:48,height:48,borderRadius:999,display:`block`}}),(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,minWidth:0},children:[(0,f.jsx)(`strong`,{style:{fontSize:16,fontWeight:800},children:e.name}),(0,f.jsx)(`span`,{style:{fontSize:13,color:`#4A6380`},children:e.role})]})]}),(0,f.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6},children:e.tags.map(e=>(0,f.jsx)(`span`,{className:`buyer-mono`,style:{fontSize:12,padding:`2px 10px`,borderRadius:999,background:`#DCE8F7`},children:e.n},e.n))}),(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:[(0,f.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:`#4A6380`},children:n.brQ}),e.qs.map(e=>(0,f.jsxs)(`div`,{style:{display:`flex`,gap:8,fontSize:14,lineHeight:1.45},children:[(0,f.jsx)(`span`,{className:`buyer-mono`,style:{color:`#1E5AA8`,fontWeight:700},children:`Q`}),(0,f.jsx)(`span`,{children:e.q})]},e.q))]}),(0,f.jsx)(`div`,{style:{flex:`1 1 auto`}}),(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,paddingTop:10,borderTop:`1px solid #DCE5F0`},children:[(0,f.jsxs)(`span`,{className:`buyer-mono`,style:{fontSize:15,fontWeight:600},children:[e.price,` `,(0,f.jsx)(`span`,{style:{fontSize:12,color:`#4A6380`},children:n.brPer})]}),(0,f.jsxs)(`span`,{style:{fontSize:11.5,fontWeight:700,padding:`2px 9px`,borderRadius:999,background:`#E3F6EC`,color:`#0E7A4F`},children:[`✓ `,n.brBadge]})]})]},e.name))})]}),(0,f.jsxs)(`section`,{id:`how`,className:`buyer-wrap buyer-section buyer-how`,children:[(0,f.jsxs)(`div`,{className:`buyer-how-intro`,children:[(0,f.jsx)(`h2`,{children:n.howTitle}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.howSub})]}),(0,f.jsx)(`div`,{className:`buyer-grid`,children:F.map(([e,t],n)=>(0,f.jsxs)(`div`,{className:`buyer-card buyer-step`,children:[(0,f.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[z[n],(0,f.jsxs)(`span`,{className:`buyer-mono`,style:{color:`#4A6380`,fontSize:12},children:[`0`,n+1]})]}),(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]},e))})]}),(0,f.jsxs)(`section`,{id:`safety`,className:`buyer-wrap buyer-section`,children:[(0,f.jsx)(`h2`,{children:n.safeTitle}),(0,f.jsx)(`div`,{className:`buyer-safety`,children:I.map(([e,t],n)=>(0,f.jsxs)(`div`,{className:`buyer-feature`,children:[(0,f.jsx)(`span`,{className:`buyer-icon`,"aria-hidden":`true`,children:B[n]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`strong`,{children:e}),(0,f.jsx)(`p`,{children:t})]})]},e))})]}),(0,f.jsx)(`section`,{className:`buyer-wrap buyer-section`,children:(0,f.jsxs)(`div`,{className:`buyer-card`,style:{display:`flex`,flexWrap:`wrap`,gap:28,alignItems:`center`,padding:`32px 36px`},children:[(0,f.jsxs)(`div`,{className:`buyer-source-copy`,style:{flex:`2 1 420px`,minWidth:0},children:[(0,f.jsx)(`span`,{className:`buyer-mono buyer-label`,style:{color:`#1E5AA8`},children:`BUILT ON GBRAIN`}),(0,f.jsx)(`blockquote`,{lang:`en`,style:{fontWeight:700},children:`“GBrain gives your AI agents shared, cited memory over plain Markdown.”`}),(0,f.jsx)(`small`,{children:n.gbSrc}),(0,f.jsx)(`p`,{className:`buyer-copy`,children:n.gbBody})]}),(0,f.jsxs)(`div`,{style:{flex:`1 1 220px`,display:`flex`,flexDirection:`column`,gap:10},children:[(0,f.jsxs)(`a`,{href:`https://github.com/garrytan/gbrain`,className:`buyer-source`,children:[(0,f.jsx)(A,{}),`garrytan/gbrain`]}),(0,f.jsxs)(`a`,{href:`https://gbrain.io`,className:`buyer-source`,children:[(0,f.jsx)(O,{}),`gbrain.io`]})]}),(0,f.jsx)(`small`,{className:`buyer-source-note`,style:{flex:`1 1 100%`},children:n.gbNote})]})}),(0,f.jsx)(`section`,{className:`buyer-wrap buyer-section`,style:{paddingBottom:96},children:(0,f.jsxs)(`div`,{className:`buyer-end`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`h2`,{children:[(0,f.jsx)(`span`,{style:{color:`inherit`},children:n.h1a}),(0,f.jsx)(`span`,{children:n.h1b})]}),(0,f.jsx)(`p`,{style:{color:`#C9D6E6`},children:n.endSub}),(0,f.jsxs)(`div`,{className:`buyer-actions buyer-cta-row`,style:{justifyContent:`start`},children:[V,H]})]}),(0,f.jsx)(k,{})]})})]}),(0,f.jsx)(`footer`,{className:`buyer-footer`,children:(0,f.jsxs)(`div`,{className:`buyer-wrap`,children:[(0,f.jsx)(`span`,{children:n.footer}),(0,f.jsxs)(u,{to:M,style:{color:`white`},children:[n.navOther,` →`]})]})}),(0,f.jsx)(c,{open:r,onClose:()=>s(!1),label:n.ctaVideo})]})}function N({location:e}){let t=i(s(new URLSearchParams(e.search).get(`lang`)));return[{title:`GbrainX | ${t.h1a} ${t.h1b}`},{name:`description`,content:t.pD}]}var P=t(function(){let[e,t]=l();return(0,f.jsx)(M,{lang:e,onLang:t})});export{P as default,N as meta};
@@ -1 +1 @@
1
- window.__reactRouterManifest={"entry":{"module":"/assets/entry.client-BMJZABtH.js","imports":["/assets/jsx-runtime-C8YK_IxR.js"],"css":[]},"routes":{"root":{"id":"root","path":"","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":true,"module":"/assets/root-C-cLqVHP.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/lib-C32AnKSP.js","/assets/root-i18n-_0Yddpt_.js"],"css":["/assets/root-D4kqIC2S.css"]},"routes/home":{"id":"routes/home","parentId":"root","index":true,"hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/home-DmjYPYzC.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/use-lp-language-ij45BzB4.js","/assets/lib-C32AnKSP.js"],"css":[]},"routes/demo":{"id":"routes/demo","parentId":"root","path":"demo","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/demo-G0WCPBHC.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/lib-C32AnKSP.js","/assets/i18n-CbBRRmtS.js","/assets/root-i18n-_0Yddpt_.js"],"css":[]},"routes/gbrainx":{"id":"routes/gbrainx","parentId":"root","path":"app","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/gbrainx-DfnQgPxe.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/lib-C32AnKSP.js","/assets/root-i18n-_0Yddpt_.js","/assets/i18n-CbBRRmtS.js"],"css":[]},"routes/sell":{"id":"routes/sell","parentId":"root","path":"sell","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/sell-C3y92_D_.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/use-lp-language-ij45BzB4.js","/assets/lib-C32AnKSP.js"],"css":["/assets/sell-ChG4r-W3.css"]},"routes/health":{"id":"routes/health","parentId":"root","path":"health","hasAction":false,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/health-BvRk9kiK.js","imports":[],"css":[]},"routes/api":{"id":"routes/api","parentId":"root","path":"api/*","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api-BvRk9kiK.js","imports":[],"css":[]}},"url":"/assets/manifest-24d3a028.js","version":"24d3a028"};
1
+ window.__reactRouterManifest={"entry":{"module":"/assets/entry.client-BMJZABtH.js","imports":["/assets/jsx-runtime-C8YK_IxR.js"],"css":[]},"routes":{"root":{"id":"root","path":"","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":true,"module":"/assets/root-C-cLqVHP.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/lib-C32AnKSP.js","/assets/root-i18n-_0Yddpt_.js"],"css":["/assets/root-D4kqIC2S.css"]},"routes/home":{"id":"routes/home","parentId":"root","index":true,"hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/home-DSGr2mzJ.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/use-lp-language-ij45BzB4.js","/assets/lib-C32AnKSP.js"],"css":[]},"routes/demo":{"id":"routes/demo","parentId":"root","path":"demo","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/demo-G0WCPBHC.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/lib-C32AnKSP.js","/assets/i18n-CbBRRmtS.js","/assets/root-i18n-_0Yddpt_.js"],"css":[]},"routes/gbrainx":{"id":"routes/gbrainx","parentId":"root","path":"app","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/gbrainx-DHJfi3id.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/lib-C32AnKSP.js","/assets/root-i18n-_0Yddpt_.js","/assets/i18n-CbBRRmtS.js"],"css":[]},"routes/sell":{"id":"routes/sell","parentId":"root","path":"sell","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/sell-DbbNBdAa.js","imports":["/assets/jsx-runtime-C8YK_IxR.js","/assets/use-lp-language-ij45BzB4.js","/assets/lib-C32AnKSP.js"],"css":["/assets/sell-CxnwvqXu.css"]},"routes/health":{"id":"routes/health","parentId":"root","path":"health","hasAction":false,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/health-BvRk9kiK.js","imports":[],"css":[]},"routes/api":{"id":"routes/api","parentId":"root","path":"api/*","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api-BvRk9kiK.js","imports":[],"css":[]}},"url":"/assets/manifest-df2f285a.js","version":"df2f285a"};
@@ -1 +1 @@
1
- .sell{color:#062544;background:#f5f8fc;font-family:Inter,Noto Sans JP,system-ui,sans-serif;line-height:1.6}.sell *{box-sizing:border-box}.sell-wrap{max-width:1120px;margin:0 auto;padding-left:32px;padding-right:32px}.sell-header,.sell-hero,.sell footer{color:#fff;background:#062544}.sell-header-inner{align-items:center;gap:28px;min-height:64px;display:flex}.sell-brand{color:#fff;align-items:center;gap:10px;font-size:17px;font-weight:700;text-decoration:none;display:flex}.sell-header nav{gap:24px;display:flex}.sell-header nav a{color:#c9d6e6;font-size:14px;text-decoration:none}.sell-spacer{flex:1}.sell-languages{border:1px solid #2b4a6b;border-radius:999px;display:flex;overflow:hidden}.sell-languages button{color:#c9d6e6;cursor:pointer;background:0 0;border:0;min-width:44px;min-height:44px}.sell-languages button[aria-pressed=true]{color:#062544;background:#fff}.sell-button{color:#062544;cursor:pointer;background:#fff;border:0;border-radius:999px;justify-content:center;align-items:center;min-height:50px;padding:0 26px;font-family:inherit;font-size:16px;font-weight:700;text-decoration:none;display:inline-flex}.sell-header .sell-button{min-height:44px;padding:0 18px;font-size:14px}.sell-button-outline{color:#fff;background:0 0;border:1px solid #2b4a6b}.sell-hero-inner{text-align:center;flex-direction:column;align-items:center;gap:22px;padding-top:72px;padding-bottom:72px;display:flex}.sell h1,.sell h2,.sell h3,.sell p{margin:0}.sell h1,.sell h2,.sell h3{word-break:auto-phrase;text-wrap:balance}.sell h1{letter-spacing:-.025em;font-size:clamp(34px,6.4vw,78px);font-weight:800;line-height:1.12}.sell h1 span,.sell-final h2 span{color:#9fc3ea;display:block}.sell-actions{flex-wrap:wrap;justify-content:center;gap:12px;display:flex}.sell-flow{gap:52px;width:100%;margin-top:32px;display:flex}.sell-flow-card{background:#0a2e52;border:1px solid #1d4570;border-radius:18px;flex-direction:column;flex:1;align-items:center;gap:10px;min-width:0;padding:20px;display:flex;position:relative}.sell-flow-group{flex:1;min-width:0;display:flex;position:relative}.sell-flow-arrow{position:absolute;top:50%;right:-52px;transform:translateY(-50%)}.sell-flow-icon{align-items:center;height:130px;display:flex}.sell-flow-card strong{font-size:17px}.sell-flow-card span{color:#c9d6e6;font-size:14px}.sell-hero small{color:#7e97b3}.sell-split{flex-wrap:wrap;align-items:center;gap:56px;padding-top:104px;padding-bottom:8px;display:flex}.sell-split>div{flex:380px;min-width:0}.sell h2{letter-spacing:-.02em;font-size:clamp(28px,3.4vw,40px);font-weight:800;line-height:1.2}.sell-split h2{margin:16px 0}.sell-split p,.sell-section>p{color:#4a6380;font-size:17px}.sell-kicker{letter-spacing:.06em;color:#1e5aa8;font-family:monospace;font-size:12px;font-weight:600}.sell-red{color:#d64545}.sell-green{color:#16a36a}.sell-notes{color:#c9d6e6;background:#062544;border-radius:18px;padding:22px}.sell-note-heading{font-size:13px}.sell-note-heading strong{font-family:monospace;font-weight:400}.sell-note-heading,.sell-result-total{justify-content:space-between;gap:12px;display:flex}.sell-note-heading span,.sell-notes small{color:#7e97b3}.sell-chips{flex-wrap:wrap;gap:8px;margin:12px 0;font-size:12px;display:flex}.sell-chips span{background:#0a2e52;border-radius:8px;padding:6px 10px;font-family:monospace}.sell-chips .sell-private{color:#ff9a9a;background:#3a1e28}.sell-result,.sell-steps article,.sell-about{background:#fff;border:1px solid #dce5f0;border-radius:18px;padding:22px 26px}.sell-result-row{border-bottom:1px solid #dce5f0;align-items:center;gap:12px;padding:10px 0;display:flex}.sell-result-row code{color:#4a6380;margin-left:auto;font-size:12px}.sell-result-row strong{font-weight:600}.sell-check{color:#16a36a;background:#e3f6ec;border-radius:50%;place-items:center;width:26px;height:26px;display:grid}.sell-result-total{margin-top:14px}.sell-result-total code{font-size:13px}.sell-result-total b{color:#16a36a;font-weight:600}.sell-section{padding-top:104px;padding-bottom:8px}.sell-section>p{margin-top:10px}.sell-steps{flex-wrap:wrap;gap:16px;margin-top:28px;display:flex}.sell-steps article{flex-direction:column;flex:272px;gap:12px;padding:26px;display:flex}.sell-step-number{color:#1e5aa8;justify-content:space-between;font-size:28px;display:flex}.sell-step-number code{color:#4a6380;font-size:12px}.sell-step-title,.sell-safety-title{font-size:17px;font-weight:700}.sell-step-description{color:#4a6380;font-size:14px}.sell-safety-copy{flex-direction:column;gap:4px;display:flex}.sell-safety-copy span:last-child{color:#4a6380;font-size:15px}.sell-safety{grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr));gap:32px;margin-top:32px;display:grid}.sell-safety>div{gap:14px;display:flex}.sell-safety-icon{background:#fff;border:1px solid #dce5f0;border-radius:14px;flex:0 0 48px;place-items:center;height:48px;font-size:24px;display:grid}.sell-about{flex-direction:column;align-items:flex-start;gap:10px;padding:32px 36px;display:flex}.sell-about blockquote{margin:0;font-size:clamp(19px,2.2vw,24px);font-weight:700;line-height:1.4}.sell-about p,.sell-about small{color:#4a6380}.sell-about-copy p{font-size:15px}.sell-about-note{font-size:12px}.sell-about a{color:#1e5aa8}.sell-last{max-width:1184px;padding-bottom:96px}.sell-final{color:#fff;background:#062544;border-radius:24px;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:24px;padding:40px 48px;display:flex}.sell-final>div{flex:420px;min-width:0}.sell-final h2{letter-spacing:-.03em;font-size:clamp(30px,4vw,46px);line-height:1.08}.sell-final p{color:#c9d6e6;margin:18px 0}.sell-final .sell-actions{justify-content:flex-start;align-items:center}.sell-final-demo{color:#c9d6e6;align-items:center;min-height:44px;padding:0 8px;font-size:15px;font-weight:600;text-decoration:none;display:inline-flex}.sell footer .sell-wrap{color:#9fb4cc;flex-wrap:wrap;justify-content:space-between;gap:12px;padding-top:28px;padding-bottom:28px;font-size:13px;display:flex}.sell footer a{color:#fff;text-decoration:none}@media (width<=760px){.sell-wrap{padding-left:20px;padding-right:20px}.sell-header-inner{gap:12px}.sell-header nav,.sell-header-cta{display:none}.sell-flow{flex-direction:column;gap:36px}.sell-flow-group{flex-direction:column;width:100%}.sell-flow-card{width:100%}.sell-flow-arrow{top:auto;bottom:-30px;right:50%;transform:translate(50%)rotate(90deg)}.sell-result-total{flex-wrap:wrap}}@media (width<=759px){.sell-flow{gap:12px}.sell-flow-arrow{display:none}}.sell-form-note{color:#9fb4cc;font-size:13px}.sell-about{flex-flow:wrap;align-items:center;gap:28px}.sell-about-copy{flex-direction:column;flex:2 420px;gap:10px;min-width:0;display:flex}.sell-about-links{flex-direction:column;flex:220px;gap:10px;display:flex}.sell-about-links a{color:#062544;border:1px solid #dce5f0;border-radius:999px;align-items:center;gap:10px;min-height:46px;padding:0 18px;font-weight:600;text-decoration:none;display:flex}.sell-about-note{flex:100%}.sell-actions{align-items:center;gap:10px}.sell-primary,.sell-video,.sell-final-demo{gap:8px}.sell-video{font-weight:600}@media (width<=760px){.sell-actions{width:100%}.sell-actions .sell-primary,.sell-actions .sell-video{flex:1 1 0;padding:0 14px;font-size:14px}.sell-actions .sell-final-demo{flex:100%;justify-content:center}.sell-final{padding:40px 24px}}
1
+ .sell{color:#062544;background:#f5f8fc;font-family:Inter,Noto Sans JP,system-ui,sans-serif;line-height:1.6}.sell *{box-sizing:border-box}.sell-wrap{max-width:1184px;margin:0 auto;padding-left:32px;padding-right:32px}.sell-header,.sell-hero,.sell footer{color:#fff;background:#062544}.sell-header-inner{align-items:center;gap:28px;min-height:64px;display:flex}.sell-brand{color:#fff;align-items:center;gap:10px;font-size:17px;font-weight:700;text-decoration:none;display:flex}.sell-header nav{gap:24px;display:flex}.sell-header nav a{color:#c9d6e6;font-size:14px;text-decoration:none}.sell-spacer{flex:1}.sell-languages{border:1px solid #2b4a6b;border-radius:999px;display:flex;overflow:hidden}.sell-languages button{color:#c9d6e6;cursor:pointer;background:0 0;border:0;min-width:44px;min-height:44px}.sell-languages button[aria-pressed=true]{color:#062544;background:#fff}.sell-button{color:#062544;cursor:pointer;background:#fff;border:0;border-radius:999px;justify-content:center;align-items:center;min-height:50px;padding:0 26px;font-family:inherit;font-size:16px;font-weight:700;text-decoration:none;display:inline-flex}.sell-header .sell-button{min-height:44px;padding:0 18px;font-size:14px}.sell-button-outline{color:#fff;background:0 0;border:1px solid #2b4a6b}.sell-hero-inner{text-align:center;flex-direction:column;align-items:center;gap:22px;padding-top:72px;padding-bottom:72px;display:flex}.sell h1,.sell h2,.sell h3,.sell p{margin:0}.sell h1,.sell h2,.sell h3{word-break:auto-phrase;text-wrap:balance}.sell h1{letter-spacing:-.025em;font-size:clamp(34px,6.4vw,78px);font-weight:800;line-height:1.12}.sell h1 span,.sell-final h2 span{color:#9fc3ea;display:block}.sell-actions{flex-wrap:wrap;justify-content:center;gap:12px;display:flex}.sell-flow{gap:52px;width:100%;margin-top:32px;display:flex}.sell-flow-card{background:#0a2e52;border:1px solid #1d4570;border-radius:18px;flex-direction:column;flex:1;align-items:center;gap:10px;min-width:0;padding:20px;display:flex;position:relative}.sell-flow-group{flex:1;min-width:0;display:flex;position:relative}.sell-flow-arrow{position:absolute;top:50%;right:-52px;transform:translateY(-50%)}.sell-flow-icon{align-items:center;height:130px;display:flex}.sell-flow-card strong{font-size:17px}.sell-flow-card span{color:#c9d6e6;font-size:14px}.sell-hero small{color:#7e97b3}.sell-split{flex-wrap:wrap;align-items:center;gap:56px;padding-top:104px;padding-bottom:8px;display:flex}.sell-split>div{flex:380px;min-width:0}.sell h2{letter-spacing:-.02em;font-size:clamp(28px,3.4vw,40px);font-weight:800;line-height:1.2}.sell-split h2{margin:16px 0}.sell-split p,.sell-section>p{color:#4a6380;font-size:17px}.sell-kicker{letter-spacing:.06em;color:#1e5aa8;font-family:monospace;font-size:12px;font-weight:600}.sell-red{color:#d64545}.sell-green{color:#16a36a}.sell-notes{color:#c9d6e6;background:#062544;border-radius:18px;padding:22px}.sell-note-heading{font-size:13px}.sell-note-heading strong{font-family:monospace;font-weight:400}.sell-note-heading,.sell-result-total{justify-content:space-between;gap:12px;display:flex}.sell-note-heading span,.sell-notes small{color:#7e97b3}.sell-chips{flex-wrap:wrap;gap:8px;margin:12px 0;font-size:12px;display:flex}.sell-chips span{background:#0a2e52;border-radius:8px;padding:6px 10px;font-family:monospace}.sell-chips .sell-private{color:#ff9a9a;background:#3a1e28}.sell-result,.sell-steps article,.sell-about{background:#fff;border:1px solid #dce5f0;border-radius:18px;padding:22px 26px}.sell-result-row{border-bottom:1px solid #dce5f0;align-items:center;gap:12px;padding:10px 0;display:flex}.sell-result-row code{color:#4a6380;margin-left:auto;font-size:12px}.sell-result-row strong{font-weight:600}.sell-check{color:#16a36a;background:#e3f6ec;border-radius:50%;place-items:center;width:26px;height:26px;display:grid}.sell-result-total{margin-top:14px}.sell-result-total code{font-size:13px}.sell-result-total b{color:#16a36a;font-weight:600}.sell-section{padding-top:104px;padding-bottom:8px}.sell-section>p{margin-top:10px}.sell-steps{flex-wrap:wrap;gap:16px;margin-top:28px;display:flex}.sell-steps article{flex-direction:column;flex:272px;gap:12px;padding:26px;display:flex}.sell-step-number{color:#1e5aa8;justify-content:space-between;font-size:28px;display:flex}.sell-step-number code{color:#4a6380;font-size:12px}.sell-step-title,.sell-safety-title{font-size:17px;font-weight:700}.sell-step-description{color:#4a6380;font-size:14px}.sell-safety-copy{flex-direction:column;gap:4px;display:flex}.sell-safety-copy span:last-child{color:#4a6380;font-size:15px}.sell-safety{grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr));gap:32px;margin-top:32px;display:grid}.sell-safety>div{gap:14px;display:flex}.sell-safety-icon{background:#fff;border:1px solid #dce5f0;border-radius:14px;flex:0 0 48px;place-items:center;height:48px;font-size:24px;display:grid}.sell-about{flex-direction:column;align-items:flex-start;gap:10px;padding:32px 36px;display:flex}.sell-about blockquote{margin:0;font-size:clamp(19px,2.2vw,24px);font-weight:700;line-height:1.4}.sell-about p,.sell-about small{color:#4a6380}.sell-about-copy p{font-size:15px}.sell-about-note{font-size:12px}.sell-about a{color:#1e5aa8}.sell-last{max-width:1184px;padding-bottom:96px}.sell-final{color:#fff;background:#062544;border-radius:24px;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:24px;padding:40px 48px;display:flex}.sell-final>div{flex:420px;min-width:0}.sell-final h2{letter-spacing:-.03em;font-size:clamp(30px,4vw,46px);line-height:1.08}.sell-final p{color:#c9d6e6;margin:18px 0}.sell-final .sell-actions{justify-content:flex-start;align-items:center}.sell-final-demo{color:#c9d6e6;align-items:center;min-height:44px;padding:0 8px;font-size:15px;font-weight:600;text-decoration:none;display:inline-flex}.sell footer .sell-wrap{color:#9fb4cc;flex-wrap:wrap;justify-content:space-between;gap:12px;padding-top:28px;padding-bottom:28px;font-size:13px;display:flex}.sell footer a{color:#fff;text-decoration:none}@media (width<=760px){.sell-wrap{padding-left:20px;padding-right:20px}.sell-header-inner{gap:12px}.sell-header nav,.sell-header-cta{display:none}.sell-flow{flex-direction:column;gap:36px}.sell-flow-group{flex-direction:column;width:100%}.sell-flow-card{width:100%}.sell-flow-arrow{top:auto;bottom:-30px;right:50%;transform:translate(50%)rotate(90deg)}.sell-result-total{flex-wrap:wrap}}@media (width<=759px){.sell-flow{gap:12px}.sell-flow-arrow{display:none}}.sell-form-note{color:#9fb4cc;font-size:13px}.sell-about{flex-flow:wrap;align-items:center;gap:28px}.sell-about-copy{flex-direction:column;flex:2 420px;gap:10px;min-width:0;display:flex}.sell-about-links{flex-direction:column;flex:220px;gap:10px;display:flex}.sell-about-links a{color:#062544;border:1px solid #dce5f0;border-radius:999px;align-items:center;gap:10px;min-height:46px;padding:0 18px;font-weight:600;text-decoration:none;display:flex}.sell-about-note{flex:100%}.sell-actions{align-items:center;gap:10px}.sell-primary,.sell-video,.sell-final-demo{gap:8px}.sell-video{font-weight:600}@media (width<=760px){.sell-actions{width:100%}.sell-actions .sell-primary,.sell-actions .sell-video{flex:1 1 0;padding:0 14px;font-size:14px}.sell-actions .sell-final-demo{flex:100%;justify-content:center}}.sell-split>.sell-notes,.sell-split>.sell-result{flex-basis:420px}.sell-result-total{flex-wrap:nowrap;align-items:center}.sell-result-total strong{min-width:0}.sell-result-total code{margin-left:auto}.sell-final>div{flex-direction:column;gap:18px;display:flex}.sell-final p{margin:0}