page-agent 1.4.4 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/iife/page-agent.demo.js +10 -10
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -49,8 +49,8 @@ Fastest way to try PageAgent with our free Demo LLM:
|
|
|
49
49
|
|
|
50
50
|
| Mirrors | URL |
|
|
51
51
|
| ------- | ---------------------------------------------------------------------------------- |
|
|
52
|
-
| Global | https://cdn.jsdelivr.net/npm/page-agent@1.
|
|
53
|
-
| China | https://registry.npmmirror.com/page-agent/1.
|
|
52
|
+
| Global | https://cdn.jsdelivr.net/npm/page-agent@1.5.1/dist/iife/page-agent.demo.js |
|
|
53
|
+
| China | https://registry.npmmirror.com/page-agent/1.5.1/files/dist/iife/page-agent.demo.js |
|
|
54
54
|
|
|
55
55
|
> **⚠️ For technical evaluation only.** This demo CDN uses our free [testing LLM API](https://alibaba.github.io/page-agent/docs/features/models#free-testing-api). By using it, you agree to its [terms](https://github.com/alibaba/page-agent/blob/main/docs/terms-and-privacy.md).
|
|
56
56
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var Et=Object.defineProperty;var xt=L=>{throw TypeError(L)};var qt=(L,M,V)=>M in L?Et(L,M,{enumerable:!0,configurable:!0,writable:!0,value:V}):L[M]=V;var a=(L,M)=>Et(L,"name",{value:M,configurable:!0});var ne=(L,M,V)=>qt(L,typeof M!="symbol"?M+"":M,V),mt=(L,M,V)=>M.has(L)||xt("Cannot "+V);var p=(L,M,V)=>(mt(L,M,"read from private field"),V?V.call(L):M.get(L)),Z=(L,M,V)=>M.has(L)?xt("Cannot add the same private member more than once"):M instanceof WeakSet?M.add(L):M.set(L,V),S=(L,M,V,De)=>(mt(L,M,"write to private field"),De?De.call(L,V):M.set(L,V),V),b=(L,M,V)=>(mt(L,M,"access private method"),V);(function(){"use strict";var Ue,Oe,ie,$e,Q,C,St,Pe,Me,_t,Tt,It,zt,At,Pt,st,re,je,ae,ye,Re,be,Ce,we,W,Ge,Ee,j,xe,ve,Ze,ee,Be,He,Je,Ye,qe,_,Ot,Rt,Ct,Zt,yt,Nt,Lt,Mt,tt,bt,Ft,Dt,Ut,wt,ot,it,jt,Bt,Wt,Vt,Fe,vt,kt,Gt,Ht,Jt,Y,ce,le,Se,Te,Ne,Yt,$t;var __vite_style__=document.createElement("style");__vite_style__.textContent=`._wrapper_gtdpc_1{position:fixed;bottom:100px;left:50%;transform:translate(-50%) translateY(20px);opacity:0;z-index:2147483642;box-sizing:border-box;overflow:visible;--width: 360px;--height: 40px;--border-radius: 12px;--side-space: 12px;--history-width: calc(var(--width) - var(--side-space) * 2);--color-1: rgb(57, 182, 255);--color-2: rgb(189, 69, 251);--color-3: rgb(255, 87, 51);--color-4: rgb(255, 214, 0);width:var(--width);height:var(--height);transition:all .3s ease-in-out}._wrapper_gtdpc_1 *{box-sizing:border-box}@media(max-width:480px){._wrapper_gtdpc_1{width:calc(100vw - 40px);--width: calc(100vw - 40px) }}._wrapper_gtdpc_1 ._background_gtdpc_39{position:absolute;inset:-2px -8px;border-radius:calc(var(--border-radius) + 4px);filter:blur(16px);overflow:hidden}._wrapper_gtdpc_1 ._background_gtdpc_39:before{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-1),var(--color-2),var(--color-1));animation:_mask-running_gtdpc_1 2s linear infinite}._wrapper_gtdpc_1 ._background_gtdpc_39:after{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-2),var(--color-1),var(--color-2));animation:_mask-running_gtdpc_1 2s linear infinite;animation-delay:1s}@keyframes _mask-running_gtdpc_1{0%{transform:translate(-100%)}to{transform:translate(100%)}}._header_gtdpc_99{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;-webkit-user-select:none;user-select:none;position:absolute;inset:0;cursor:pointer;flex-shrink:0;background:#00000080;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:var(--border-radius);background-clip:padding-box;box-shadow:0 0 0 2px #fff6,0 0 5px 1px #ffffff4d}._header_gtdpc_99 ._statusSection_gtdpc_121{display:flex;align-items:center;gap:8px;flex:1;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128{width:6px;height:6px;border-radius:50%;background:#ffffff80;flex-shrink:0;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._thinking_gtdpc_137{background:#39b6ff;animation:_pulse_gtdpc_1 .8s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._tool_executing_gtdpc_142{background:#bd45fb;animation:_pulse_gtdpc_1 .6s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._retry_gtdpc_147{background:#ffd600;animation:_retryPulse_gtdpc_1 1s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._completed_gtdpc_153,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._input_gtdpc_154,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._output_gtdpc_155{background:#22c55e;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._error_gtdpc_160{background:#ef4444;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166{color:#fff;font-size:12px;line-height:1;font-weight:500;transition:all .3s ease-in-out;position:relative;overflow:hidden;display:flex;align-items:center;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeOut_gtdpc_178{animation:_statusTextFadeOut_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeIn_gtdpc_182{animation:_statusTextFadeIn_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._controls_gtdpc_188{display:flex;align-items:center;gap:4px}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193{width:24px;height:24px;border:none;border-radius:4px;background:#ffffff1a;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:12px;line-height:1}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193:hover{background:#fff3}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212{background:#ef444433;color:#ff2929;font-weight:600}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212:hover{background:#ef44444d}@keyframes _statusTextFadeIn_gtdpc_1{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@keyframes _statusTextFadeOut_gtdpc_1{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-5px)}}._historySectionWrapper_gtdpc_246{position:absolute;width:var(--history-width);bottom:var(--height);left:var(--side-space);z-index:-2;padding-top:0;visibility:collapse;overflow:hidden;transition:all .2s;background:#02001480;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);text-shadow:0 0 1px rgba(0,0,0,.2);border-top-left-radius:calc(var(--border-radius) + 4px);border-top-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.4);box-shadow:0 4px 16px #0009}._expanded_gtdpc_278 ._historySectionWrapper_gtdpc_246{padding-top:8px;visibility:visible}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246{position:relative;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none;max-height:0;padding-inline:8px;transition:max-height .2s}._expanded_gtdpc_278 :is(._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246){max-height:400px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297{padding:8px 10px;margin-bottom:6px;background:linear-gradient(135deg,#ffffff14,#ffffff08);border-radius:8px;border-left:2px solid rgba(57,182,255,.5);font-size:12px;color:#fff;line-height:1.3;position:relative;overflow:hidden;box-shadow:inset 0 1px #ffffff1a,0 1px 3px #0000001a}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:before{content:"";position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,rgba(255,255,255,.2),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:hover{background:linear-gradient(135deg,#ffffff1f,#ffffff0f);box-shadow:inset 0 1px #ffffff26,0 2px 4px #00000026}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:last-child{margin-bottom:10px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._completed_gtdpc_153,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._input_gtdpc_154,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._output_gtdpc_155{border-left-color:#22c55e;background:linear-gradient(135deg,#22c55e1a,#22c55e0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._error_gtdpc_160{border-left-color:#ef4444;background:linear-gradient(135deg,#ef44441a,#ef44440d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._retry_gtdpc_147{border-left-color:#ffd600;background:linear-gradient(135deg,#ffd6001a,#ffd6000d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._observation_gtdpc_355{border-left-color:#9333ea;background:linear-gradient(135deg,#9333ea1a,#9333ea0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._question_gtdpc_360{border-left-color:#ff9f43;background:linear-gradient(135deg,#ff9f4326,#ff9f4314)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366{background:linear-gradient(135deg,#22c55e40,#22c55e26,#22c55e14);border:none;border-left:4px solid rgb(34,197,94);box-shadow:0 4px 12px #22c55e4d,inset 0 1px #fff3,0 0 20px #22c55e1a;font-weight:600;color:#dcfce7;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:before{background:linear-gradient(90deg,transparent,rgba(34,197,94,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:after{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.1),transparent);animation:_shimmer_gtdpc_1 2s ease-in-out infinite}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;animation:_celebrate_gtdpc_1 .8s ease-in-out;filter:drop-shadow(0 2px 4px rgba(34,197,94,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412{background:linear-gradient(135deg,#ef444440,#ef444426,#ef444414);border:none;border-left:4px solid rgb(239,68,68);box-shadow:0 4px 12px #ef44444d,inset 0 1px #fff3,0 0 20px #ef44441a;font-weight:600;color:#fee2e2;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412:before{background:linear-gradient(90deg,transparent,rgba(239,68,68,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;filter:drop-shadow(0 2px 4px rgba(239,68,68,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402{display:flex;align-items:flex-start;gap:8px;word-break:break-all;white-space:pre-wrap}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:12px;flex-shrink:0;line-height:1;transition:all .3s ease}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._reflectionLines_gtdpc_462{display:flex;flex-direction:column;gap:4px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyMeta_gtdpc_469{font-size:10px;color:#fff9;margin-top:8px;line-height:1}@keyframes _pulse_gtdpc_1{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(1.3)}}@keyframes _retryPulse_gtdpc_1{0%,to{opacity:1;transform:scale(1) rotate(0)}25%{opacity:.6;transform:scale(1.2) rotate(90deg)}50%{opacity:.8;transform:scale(1.1) rotate(180deg)}75%{opacity:.6;transform:scale(1.2) rotate(270deg)}}@keyframes _celebrate_gtdpc_1{0%,to{transform:scale(1)}25%{transform:scale(1.2) rotate(-5deg)}75%{transform:scale(1.2) rotate(5deg)}}@keyframes _shimmer_gtdpc_1{0%{left:-100%}to{left:100%}}._inputSectionWrapper_gtdpc_539{position:absolute;width:var(--history-width);top:var(--height);left:var(--side-space);z-index:-1;visibility:visible;overflow:hidden;height:48px;transition:all .2s;background:#bababa33;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-bottom-left-radius:calc(var(--border-radius) + 4px);border-bottom-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.3);box-shadow:0 1px 16px #0006}._inputSectionWrapper_gtdpc_539._hidden_gtdpc_562{visibility:collapse;height:0}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539{display:flex;align-items:center;gap:4px;padding:8px}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573{flex:1;background:#fff6;border:1px solid rgba(255,255,255,.3);border-radius:10px;padding-inline:10px;color:#141414;font-size:12px;height:28px;line-height:1;outline:none;transition:all .2s ease}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573::placeholder{color:#353535}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573:focus{background:#fffc;border-color:#39b6ff99;box-shadow:0 0 0 2px #39b6ff33}._wrapper_gf8tz_1{position:fixed;inset:0;z-index:2147483641;cursor:wait;overflow:hidden;display:none}._cursor_1dgwb_2{position:absolute;width:var(--cursor-size, 75px);height:var(--cursor-size, 75px);pointer-events:none;z-index:10000}._cursorBorder_1dgwb_10{position:absolute;width:100%;height:100%;background:linear-gradient(45deg,#39b6ff,#bd45fb);-webkit-mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorFilling_1dgwb_25{position:absolute;width:100%;height:100%;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");background-size:100% 100%;background-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorRipple_1dgwb_39{position:absolute;width:100%;height:100%;pointer-events:none;margin-left:-50%;margin-top:-50%}._cursorRipple_1dgwb_39:after{content:"";opacity:0;position:absolute;inset:0;border:4px solid rgba(57,182,255,1);border-radius:50%}._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39:after{animation:_cursor-ripple_1dgwb_1 .3s ease-out forwards}@keyframes _cursor-ripple_1dgwb_1{0%{transform:scale(0);opacity:1}to{transform:scale(2);opacity:0}}
|
|
1
|
+
var Et=Object.defineProperty;var xt=L=>{throw TypeError(L)};var qt=(L,M,V)=>M in L?Et(L,M,{enumerable:!0,configurable:!0,writable:!0,value:V}):L[M]=V;var a=(L,M)=>Et(L,"name",{value:M,configurable:!0});var ne=(L,M,V)=>qt(L,typeof M!="symbol"?M+"":M,V),mt=(L,M,V)=>M.has(L)||xt("Cannot "+V);var p=(L,M,V)=>(mt(L,M,"read from private field"),V?V.call(L):M.get(L)),Z=(L,M,V)=>M.has(L)?xt("Cannot add the same private member more than once"):M instanceof WeakSet?M.add(L):M.set(L,V),S=(L,M,V,De)=>(mt(L,M,"write to private field"),De?De.call(L,V):M.set(L,V),V),b=(L,M,V)=>(mt(L,M,"access private method"),V);(function(){"use strict";var Ue,Oe,ie,$e,Q,R,St,Pe,Me,_t,Tt,It,zt,At,Pt,st,re,je,ae,ye,Ce,be,Re,we,W,Ge,Ee,j,xe,ve,Ze,ee,Be,He,Je,Ye,qe,_,Ot,Ct,Rt,Zt,yt,Nt,Lt,Mt,tt,bt,Ft,Dt,Ut,wt,ot,it,jt,Bt,Wt,Vt,Fe,vt,kt,Gt,Ht,Jt,Y,ce,le,Se,Te,Ne,Yt,$t;var __vite_style__=document.createElement("style");__vite_style__.textContent=`._wrapper_gtdpc_1{position:fixed;bottom:100px;left:50%;transform:translate(-50%) translateY(20px);opacity:0;z-index:2147483642;box-sizing:border-box;overflow:visible;--width: 360px;--height: 40px;--border-radius: 12px;--side-space: 12px;--history-width: calc(var(--width) - var(--side-space) * 2);--color-1: rgb(57, 182, 255);--color-2: rgb(189, 69, 251);--color-3: rgb(255, 87, 51);--color-4: rgb(255, 214, 0);width:var(--width);height:var(--height);transition:all .3s ease-in-out}._wrapper_gtdpc_1 *{box-sizing:border-box}@media(max-width:480px){._wrapper_gtdpc_1{width:calc(100vw - 40px);--width: calc(100vw - 40px) }}._wrapper_gtdpc_1 ._background_gtdpc_39{position:absolute;inset:-2px -8px;border-radius:calc(var(--border-radius) + 4px);filter:blur(16px);overflow:hidden}._wrapper_gtdpc_1 ._background_gtdpc_39:before{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-1),var(--color-2),var(--color-1));animation:_mask-running_gtdpc_1 2s linear infinite}._wrapper_gtdpc_1 ._background_gtdpc_39:after{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-2),var(--color-1),var(--color-2));animation:_mask-running_gtdpc_1 2s linear infinite;animation-delay:1s}@keyframes _mask-running_gtdpc_1{0%{transform:translate(-100%)}to{transform:translate(100%)}}._header_gtdpc_99{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;-webkit-user-select:none;user-select:none;position:absolute;inset:0;cursor:pointer;flex-shrink:0;background:#00000080;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:var(--border-radius);background-clip:padding-box;box-shadow:0 0 0 2px #fff6,0 0 5px 1px #ffffff4d}._header_gtdpc_99 ._statusSection_gtdpc_121{display:flex;align-items:center;gap:8px;flex:1;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128{width:6px;height:6px;border-radius:50%;background:#ffffff80;flex-shrink:0;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._thinking_gtdpc_137{background:#39b6ff;animation:_pulse_gtdpc_1 .8s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._tool_executing_gtdpc_142{background:#bd45fb;animation:_pulse_gtdpc_1 .6s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._retry_gtdpc_147{background:#ffd600;animation:_retryPulse_gtdpc_1 1s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._completed_gtdpc_153,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._input_gtdpc_154,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._output_gtdpc_155{background:#22c55e;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._error_gtdpc_160{background:#ef4444;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166{color:#fff;font-size:12px;line-height:1;font-weight:500;transition:all .3s ease-in-out;position:relative;overflow:hidden;display:flex;align-items:center;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeOut_gtdpc_178{animation:_statusTextFadeOut_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeIn_gtdpc_182{animation:_statusTextFadeIn_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._controls_gtdpc_188{display:flex;align-items:center;gap:4px}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193{width:24px;height:24px;border:none;border-radius:4px;background:#ffffff1a;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:12px;line-height:1}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193:hover{background:#fff3}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212{background:#ef444433;color:#ff2929;font-weight:600}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212:hover{background:#ef44444d}@keyframes _statusTextFadeIn_gtdpc_1{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@keyframes _statusTextFadeOut_gtdpc_1{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-5px)}}._historySectionWrapper_gtdpc_246{position:absolute;width:var(--history-width);bottom:var(--height);left:var(--side-space);z-index:-2;padding-top:0;visibility:collapse;overflow:hidden;transition:all .2s;background:#02001480;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);text-shadow:0 0 1px rgba(0,0,0,.2);border-top-left-radius:calc(var(--border-radius) + 4px);border-top-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.4);box-shadow:0 4px 16px #0009}._expanded_gtdpc_278 ._historySectionWrapper_gtdpc_246{padding-top:8px;visibility:visible}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246{position:relative;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none;max-height:0;padding-inline:8px;transition:max-height .2s}._expanded_gtdpc_278 :is(._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246){max-height:400px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297{padding:8px 10px;margin-bottom:6px;background:linear-gradient(135deg,#ffffff14,#ffffff08);border-radius:8px;border-left:2px solid rgba(57,182,255,.5);font-size:12px;color:#fff;line-height:1.3;position:relative;overflow:hidden;box-shadow:inset 0 1px #ffffff1a,0 1px 3px #0000001a}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:before{content:"";position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,rgba(255,255,255,.2),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:hover{background:linear-gradient(135deg,#ffffff1f,#ffffff0f);box-shadow:inset 0 1px #ffffff26,0 2px 4px #00000026}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:last-child{margin-bottom:10px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._completed_gtdpc_153,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._input_gtdpc_154,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._output_gtdpc_155{border-left-color:#22c55e;background:linear-gradient(135deg,#22c55e1a,#22c55e0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._error_gtdpc_160{border-left-color:#ef4444;background:linear-gradient(135deg,#ef44441a,#ef44440d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._retry_gtdpc_147{border-left-color:#ffd600;background:linear-gradient(135deg,#ffd6001a,#ffd6000d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._observation_gtdpc_355{border-left-color:#9333ea;background:linear-gradient(135deg,#9333ea1a,#9333ea0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._question_gtdpc_360{border-left-color:#ff9f43;background:linear-gradient(135deg,#ff9f4326,#ff9f4314)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366{background:linear-gradient(135deg,#22c55e40,#22c55e26,#22c55e14);border:none;border-left:4px solid rgb(34,197,94);box-shadow:0 4px 12px #22c55e4d,inset 0 1px #fff3,0 0 20px #22c55e1a;font-weight:600;color:#dcfce7;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:before{background:linear-gradient(90deg,transparent,rgba(34,197,94,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:after{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.1),transparent);animation:_shimmer_gtdpc_1 2s ease-in-out infinite}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;animation:_celebrate_gtdpc_1 .8s ease-in-out;filter:drop-shadow(0 2px 4px rgba(34,197,94,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412{background:linear-gradient(135deg,#ef444440,#ef444426,#ef444414);border:none;border-left:4px solid rgb(239,68,68);box-shadow:0 4px 12px #ef44444d,inset 0 1px #fff3,0 0 20px #ef44441a;font-weight:600;color:#fee2e2;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412:before{background:linear-gradient(90deg,transparent,rgba(239,68,68,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;filter:drop-shadow(0 2px 4px rgba(239,68,68,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402{display:flex;align-items:flex-start;gap:8px;word-break:break-all;white-space:pre-wrap}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:12px;flex-shrink:0;line-height:1;transition:all .3s ease}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._reflectionLines_gtdpc_462{display:flex;flex-direction:column;gap:4px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyMeta_gtdpc_469{font-size:10px;color:#fff9;margin-top:8px;line-height:1}@keyframes _pulse_gtdpc_1{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(1.3)}}@keyframes _retryPulse_gtdpc_1{0%,to{opacity:1;transform:scale(1) rotate(0)}25%{opacity:.6;transform:scale(1.2) rotate(90deg)}50%{opacity:.8;transform:scale(1.1) rotate(180deg)}75%{opacity:.6;transform:scale(1.2) rotate(270deg)}}@keyframes _celebrate_gtdpc_1{0%,to{transform:scale(1)}25%{transform:scale(1.2) rotate(-5deg)}75%{transform:scale(1.2) rotate(5deg)}}@keyframes _shimmer_gtdpc_1{0%{left:-100%}to{left:100%}}._inputSectionWrapper_gtdpc_539{position:absolute;width:var(--history-width);top:var(--height);left:var(--side-space);z-index:-1;visibility:visible;overflow:hidden;height:48px;transition:all .2s;background:#bababa33;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-bottom-left-radius:calc(var(--border-radius) + 4px);border-bottom-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.3);box-shadow:0 1px 16px #0006}._inputSectionWrapper_gtdpc_539._hidden_gtdpc_562{visibility:collapse;height:0}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539{display:flex;align-items:center;gap:4px;padding:8px}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573{flex:1;background:#fff6;border:1px solid rgba(255,255,255,.3);border-radius:10px;padding-inline:10px;color:#141414;font-size:12px;height:28px;line-height:1;outline:none;transition:all .2s ease}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573::placeholder{color:#353535}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573:focus{background:#fffc;border-color:#39b6ff99;box-shadow:0 0 0 2px #39b6ff33}._wrapper_gf8tz_1{position:fixed;inset:0;z-index:2147483641;cursor:wait;overflow:hidden;display:none}._cursor_1dgwb_2{position:absolute;width:var(--cursor-size, 75px);height:var(--cursor-size, 75px);pointer-events:none;z-index:10000}._cursorBorder_1dgwb_10{position:absolute;width:100%;height:100%;background:linear-gradient(45deg,#39b6ff,#bd45fb);-webkit-mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorFilling_1dgwb_25{position:absolute;width:100%;height:100%;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");background-size:100% 100%;background-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorRipple_1dgwb_39{position:absolute;width:100%;height:100%;pointer-events:none;margin-left:-50%;margin-top:-50%}._cursorRipple_1dgwb_39:after{content:"";opacity:0;position:absolute;inset:0;border:4px solid rgba(57,182,255,1);border-radius:50%}._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39:after{animation:_cursor-ripple_1dgwb_1 .3s ease-out forwards}@keyframes _cursor-ripple_1dgwb_1{0%{transform:scale(0);opacity:1}to{transform:scale(2);opacity:0}}
|
|
2
2
|
/*$vite$:1*/`,document.head.appendChild(__vite_style__);function $constructor(e,t,o){function n(l,d){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:d,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,d);const h=s.prototype,f=Object.keys(h);for(let g=0;g<f.length;g++){const m=f[g];m in l||(l[m]=h[m].bind(l))}}a(n,"init");const r=o?.Parent??Object,c=class c extends r{};a(c,"Definition");let i=c;Object.defineProperty(i,"name",{value:e});function s(l){var d;const h=o?.Parent?new i:this;n(h,l),(d=h._zod).deferred??(d.deferred=[]);for(const f of h._zod.deferred)f();return h}return a(s,"_"),Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a(l=>o?.Parent&&l instanceof o.Parent?!0:l?._zod?.traits?.has(e),"value")}),Object.defineProperty(s,"name",{value:e}),s}a($constructor,"$constructor");const L=class L extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};a(L,"$ZodAsyncError");let $ZodAsyncError=L;const M=class M extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};a(M,"$ZodEncodeError");let $ZodEncodeError=M;const globalConfig={};function config(e){return globalConfig}a(config,"config");function getEnumValues(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}a(getEnumValues,"getEnumValues");function jsonStringifyReplacer(e,t){return typeof t=="bigint"?t.toString():t}a(jsonStringifyReplacer,"jsonStringifyReplacer");function cached(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}a(cached,"cached");function nullish(e){return e==null}a(nullish,"nullish");function cleanRegex(e){const t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}a(cleanRegex,"cleanRegex");function floatSafeRemainder(e,t){const o=(e.toString().split(".")[1]||"").length,n=t.toString();let r=(n.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(r=Number.parseInt(l[1]))}const i=o>r?o:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}a(floatSafeRemainder,"floatSafeRemainder");const EVALUATING=Symbol("evaluating");function defineLazy(e,t,o){let n;Object.defineProperty(e,t,{get(){if(n!==EVALUATING)return n===void 0&&(n=EVALUATING,n=o()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}a(defineLazy,"defineLazy");function assignProp(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}a(assignProp,"assignProp");function mergeDefs(...e){const t={};for(const o of e){const n=Object.getOwnPropertyDescriptors(o);Object.assign(t,n)}return Object.defineProperties({},t)}a(mergeDefs,"mergeDefs");function esc(e){return JSON.stringify(e)}a(esc,"esc");function slugify(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}a(slugify,"slugify");const captureStackTrace="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function isObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(isObject,"isObject");const allowsEval=cached(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function isPlainObject(e){if(isObject(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const o=t.prototype;return!(isObject(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}a(isPlainObject,"isPlainObject");function shallowClone(e){return isPlainObject(e)?{...e}:Array.isArray(e)?[...e]:e}a(shallowClone,"shallowClone");const propertyKeyTypes=new Set(["string","number","symbol"]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(escapeRegex,"escapeRegex");function clone(e,t,o){const n=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(n._zod.parent=e),n}a(clone,"clone");function normalizeParams(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:a(()=>t,"error")};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:a(()=>t.error,"error")}:t}a(normalizeParams,"normalizeParams");function optionalKeys(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}a(optionalKeys,"optionalKeys");const NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pick(e,t){const o=e._zod.def,n=o.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=mergeDefs(e._zod.def,{get shape(){const s={};for(const c in t){if(!(c in o.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(s[c]=o.shape[c])}return assignProp(this,"shape",s),s},checks:[]});return clone(e,i)}a(pick,"pick");function omit(e,t){const o=e._zod.def,n=o.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=mergeDefs(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const c in t){if(!(c in o.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete s[c]}return assignProp(this,"shape",s),s},checks:[]});return clone(e,i)}a(omit,"omit");function extend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to extend: expected a plain object");const o=e._zod.def.checks;if(o&&o.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=mergeDefs(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return assignProp(this,"shape",i),i}});return clone(e,r)}a(extend,"extend");function safeExtend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to safeExtend: expected a plain object");const o=mergeDefs(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return assignProp(this,"shape",n),n}});return clone(e,o)}a(safeExtend,"safeExtend");function merge(e,t){const o=mergeDefs(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return clone(e,o)}a(merge,"merge");function partial(e,t,o){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=mergeDefs(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(o)for(const d in o){if(!(d in c))throw new Error(`Unrecognized key: "${d}"`);o[d]&&(l[d]=e?new e({type:"optional",innerType:c[d]}):c[d])}else for(const d in c)l[d]=e?new e({type:"optional",innerType:c[d]}):c[d];return assignProp(this,"shape",l),l},checks:[]});return clone(t,s)}a(partial,"partial");function required(e,t,o){const n=mergeDefs(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(o)for(const s in o){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);o[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return assignProp(this,"shape",i),i}});return clone(t,n)}a(required,"required");function aborted(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}a(aborted,"aborted");function prefixIssues(e,t){return t.map(o=>{var n;return(n=o).path??(n.path=[]),o.path.unshift(e),o})}a(prefixIssues,"prefixIssues");function unwrapMessage(e){return typeof e=="string"?e:e?.message}a(unwrapMessage,"unwrapMessage");function finalizeIssue(e,t,o){const n={...e,path:e.path??[]};if(!e.message){const r=unwrapMessage(e.inst?._zod.def?.error?.(e))??unwrapMessage(t?.error?.(e))??unwrapMessage(o.customError?.(e))??unwrapMessage(o.localeError?.(e))??"Invalid input";n.message=r}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}a(finalizeIssue,"finalizeIssue");function getLengthableOrigin(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}a(getLengthableOrigin,"getLengthableOrigin");function issue(...e){const[t,o,n]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:n}:{...t}}a(issue,"issue");const initializer$1=a((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,jsonStringifyReplacer,2),Object.defineProperty(e,"toString",{value:a(()=>e.message,"value"),enumerable:!1})},"initializer$1"),$ZodError=$constructor("$ZodError",initializer$1),$ZodRealError=$constructor("$ZodError",initializer$1,{Parent:Error});function flattenError(e,t=o=>o.message){const o={},n=[];for(const r of e.issues)r.path.length>0?(o[r.path[0]]=o[r.path[0]]||[],o[r.path[0]].push(t(r))):n.push(t(r));return{formErrors:n,fieldErrors:o}}a(flattenError,"flattenError");function formatError(e,t=o=>o.message){const o={_errors:[]},n=a(r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>n({issues:s}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)o._errors.push(t(i));else{let s=o,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(t(i))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}},"processError");return n(e),o}a(formatError,"formatError");function toDotPath(e){const t=[],o=e.map(n=>typeof n=="object"?n.key:n);for(const n of o)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}a(toDotPath,"toDotPath");function prettifyError(e){const t=[],o=[...e.issues].sort((n,r)=>(n.path??[]).length-(r.path??[]).length);for(const n of o)t.push(`✖ ${n.message}`),n.path?.length&&t.push(` → at ${toDotPath(n.path)}`);return t.join(`
|
|
3
3
|
`)}a(prettifyError,"prettifyError");const _parse=a(e=>(t,o,n,r)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw new $ZodAsyncError;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(l=>finalizeIssue(l,i,config())));throw captureStackTrace(c,r?.callee),c}return s.value},"_parse"),_parseAsync=a(e=>async(t,o,n,r)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const c=new(r?.Err??e)(s.issues.map(l=>finalizeIssue(l,i,config())));throw captureStackTrace(c,r?.callee),c}return s.value},"_parseAsync"),_safeParse=a(e=>(t,o,n)=>{const r=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},r);if(i instanceof Promise)throw new $ZodAsyncError;return i.issues.length?{success:!1,error:new(e??$ZodError)(i.issues.map(s=>finalizeIssue(s,r,config())))}:{success:!0,data:i.value}},"_safeParse"),safeParse$1=_safeParse($ZodRealError),_safeParseAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:o,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>finalizeIssue(s,r,config())))}:{success:!0,data:i.value}},"_safeParseAsync"),safeParseAsync$1=_safeParseAsync($ZodRealError),_encode=a(e=>(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _parse(e)(t,o,r)},"_encode"),_decode=a(e=>(t,o,n)=>_parse(e)(t,o,n),"_decode"),_encodeAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _parseAsync(e)(t,o,r)},"_encodeAsync"),_decodeAsync=a(e=>async(t,o,n)=>_parseAsync(e)(t,o,n),"_decodeAsync"),_safeEncode=a(e=>(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _safeParse(e)(t,o,r)},"_safeEncode"),_safeDecode=a(e=>(t,o,n)=>_safeParse(e)(t,o,n),"_safeDecode"),_safeEncodeAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _safeParseAsync(e)(t,o,r)},"_safeEncodeAsync"),_safeDecodeAsync=a(e=>async(t,o,n)=>_safeParseAsync(e)(t,o,n),"_safeDecodeAsync"),cuid=/^[cC][^\s-]{8,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/,duration$1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uuid=a(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,"uuid"),email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji$1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function emoji(){return new RegExp(_emoji$1,"u")}a(emoji,"emoji");const ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cidrv4=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,e164=/^\+[1-9]\d{6,14}$/,dateSource="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",date$1=new RegExp(`^${dateSource}$`);function timeSource(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}a(timeSource,"timeSource");function time$1(e){return new RegExp(`^${timeSource(e)}$`)}a(time$1,"time$1");function datetime$1(e){const t=timeSource({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${o.join("|")})`;return new RegExp(`^${dateSource}T(?:${n})$`)}a(datetime$1,"datetime$1");const string$1=a(e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string$1"),integer=/^-?\d+$/,number$1=/^-?\d+(?:\.\d+)?$/,boolean$1=/^(?:true|false)$/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/,$ZodCheck=$constructor("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),numericOriginMap={number:"number",bigint:"bigint",object:"date"},$ZodCheckLessThan=$constructor("$ZodCheckLessThan",(e,t)=>{$ZodCheck.init(e,t);const o=numericOriginMap[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:o,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckGreaterThan=$constructor("$ZodCheckGreaterThan",(e,t)=>{$ZodCheck.init(e,t);const o=numericOriginMap[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:o,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckMultipleOf=$constructor("$ZodCheckMultipleOf",(e,t)=>{$ZodCheck.init(e,t),e._zod.onattach.push(o=>{var n;(n=o._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=o=>{if(typeof o.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):floatSafeRemainder(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),$ZodCheckNumberFormat=$constructor("$ZodCheckNumberFormat",(e,t)=>{$ZodCheck.init(e,t),t.format=t.format||"float64";const o=t.format?.includes("int"),n=o?"int":"number",[r,i]=NUMBER_FORMAT_RANGES[t.format];e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,c.minimum=r,c.maximum=i,o&&(c.pattern=integer)}),e._zod.check=s=>{const c=s.value;if(o){if(!Number.isInteger(c)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<r&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),$ZodCheckMaxLength=$constructor("$ZodCheckMaxLength",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const s=getLengthableOrigin(r);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckMinLength=$constructor("$ZodCheckMinLength",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const s=getLengthableOrigin(r);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckLengthEquals=$constructor("$ZodCheckLengthEquals",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=n=>{const r=n.value,i=r.length;if(i===t.length)return;const s=getLengthableOrigin(r),c=i>t.length;n.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckStringFormat=$constructor("$ZodCheckStringFormat",(e,t)=>{var o,n;$ZodCheck.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(o=e._zod).check??(o.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),$ZodCheckRegex=$constructor("$ZodCheckRegex",(e,t)=>{$ZodCheckStringFormat.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$ZodCheckLowerCase=$constructor("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lowercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckUpperCase=$constructor("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=uppercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckIncludes=$constructor("$ZodCheckIncludes",(e,t)=>{$ZodCheck.init(e,t);const o=escapeRegex(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${o}`:o);t.pattern=n,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckStartsWith=$constructor("$ZodCheckStartsWith",(e,t)=>{$ZodCheck.init(e,t);const o=new RegExp(`^${escapeRegex(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckEndsWith=$constructor("$ZodCheckEndsWith",(e,t)=>{$ZodCheck.init(e,t);const o=new RegExp(`.*${escapeRegex(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckOverwrite=$constructor("$ZodCheckOverwrite",(e,t)=>{$ZodCheck.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}}),V=class V{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
|
|
4
4
|
`).filter(s=>s),r=Math.min(...n.map(s=>s.length-s.trimStart().length)),i=n.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,o=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...o,r.join(`
|
|
5
|
-
`))}};a(V,"Doc");let Doc=V;const version={major:4,minor:3,patch:6},$ZodType=$constructor("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=version;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const r of n)for(const i of r._zod.onattach)i(e);if(n.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=a((s,c,l)=>{let d=aborted(s),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(s))continue}else if(d)continue;const g=s.issues.length,m=f._zod.check(s);if(m instanceof Promise&&l?.async===!1)throw new $ZodAsyncError;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,s.issues.length!==g&&(d||(d=aborted(s,g)))});else{if(s.issues.length===g)continue;d||(d=aborted(s,g))}}return h?h.then(()=>s):s},"runChecks"),i=a((s,c,l)=>{if(aborted(s))return s.aborted=!0,s;const d=r(c,n,l);if(d instanceof Promise){if(l.async===!1)throw new $ZodAsyncError;return d.then(h=>e._zod.parse(h,l))}return e._zod.parse(d,l)},"handleCanaryResult");e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const d=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(h=>i(h,s,c)):i(d,s,c)}const l=e._zod.parse(s,c);if(l instanceof Promise){if(c.async===!1)throw new $ZodAsyncError;return l.then(d=>r(d,n,c))}return r(l,n,c)}}defineLazy(e,"~standard",()=>({validate:a(r=>{try{const i=safeParse$1(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return safeParseAsync$1(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},"validate"),vendor:"zod",version:1}))}),$ZodString=$constructor("$ZodString",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??string$1(e._zod.bag),e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),$ZodStringFormat=$constructor("$ZodStringFormat",(e,t)=>{$ZodCheckStringFormat.init(e,t),$ZodString.init(e,t)}),$ZodGUID=$constructor("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=guid),$ZodStringFormat.init(e,t)}),$ZodUUID=$constructor("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uuid(n))}else t.pattern??(t.pattern=uuid());$ZodStringFormat.init(e,t)}),$ZodEmail=$constructor("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=email),$ZodStringFormat.init(e,t)}),$ZodURL=$constructor("$ZodURL",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{try{const n=o.value.trim(),r=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})),t.normalize?o.value=r.href:o.value=n;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=emoji()),$ZodStringFormat.init(e,t)}),$ZodNanoID=$constructor("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nanoid),$ZodStringFormat.init(e,t)}),$ZodCUID=$constructor("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cuid),$ZodStringFormat.init(e,t)}),$ZodCUID2=$constructor("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cuid2),$ZodStringFormat.init(e,t)}),$ZodULID=$constructor("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ulid),$ZodStringFormat.init(e,t)}),$ZodXID=$constructor("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xid),$ZodStringFormat.init(e,t)}),$ZodKSUID=$constructor("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ksuid),$ZodStringFormat.init(e,t)}),$ZodISODateTime=$constructor("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=datetime$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODate=$constructor("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=date$1),$ZodStringFormat.init(e,t)}),$ZodISOTime=$constructor("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=time$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODuration=$constructor("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=duration$1),$ZodStringFormat.init(e,t)}),$ZodIPv4=$constructor("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ipv4),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv4"}),$ZodIPv6=$constructor("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ipv6),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv6",e._zod.check=o=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cidrv4),$ZodStringFormat.init(e,t)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cidrv6),$ZodStringFormat.init(e,t),e._zod.check=o=>{const n=o.value.split("/");try{if(n.length!==2)throw new Error;const[r,i]=n;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function isValidBase64(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}a(isValidBase64,"isValidBase64");const $ZodBase64=$constructor("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=base64),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=o=>{isValidBase64(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function isValidBase64URL(e){if(!base64url.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return isValidBase64(o)}a(isValidBase64URL,"isValidBase64URL");const $ZodBase64URL=$constructor("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=base64url),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=o=>{isValidBase64URL(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),$ZodE164=$constructor("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e164),$ZodStringFormat.init(e,t)});function isValidJWT(e,t=null){try{const o=e.split(".");if(o.length!==3)return!1;const[n]=o;if(!n)return!1;const r=JSON.parse(atob(n));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}a(isValidJWT,"isValidJWT");const $ZodJWT=$constructor("$ZodJWT",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{isValidJWT(o.value,t.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}}),$ZodNumber=$constructor("$ZodNumber",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=e._zod.bag.pattern??number$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=Number(o.value)}catch{}const r=o.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return o;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),o}}),$ZodNumberFormat=$constructor("$ZodNumberFormat",(e,t)=>{$ZodCheckNumberFormat.init(e,t),$ZodNumber.init(e,t)}),$ZodBoolean=$constructor("$ZodBoolean",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=boolean$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=!!o.value}catch{}const r=o.value;return typeof r=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),o}}),$ZodUnknown=$constructor("$ZodUnknown",(e,t)=>{$ZodType.init(e,t),e._zod.parse=o=>o}),$ZodNever=$constructor("$ZodNever",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function handleArrayResult(e,t,o){e.issues.length&&t.issues.push(...prefixIssues(o,e.issues)),t.value[o]=e.value}a(handleArrayResult,"handleArrayResult");const $ZodArray=$constructor("$ZodArray",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{const r=o.value;if(!Array.isArray(r))return o.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),o;o.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const c=r[s],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?i.push(l.then(d=>handleArrayResult(d,o,s))):handleArrayResult(l,o,s)}return i.length?Promise.all(i).then(()=>o):o}});function handlePropertyResult(e,t,o,n,r){if(e.issues.length){if(r&&!(o in n))return;t.issues.push(...prefixIssues(o,e.issues))}e.value===void 0?o in n&&(t.value[o]=void 0):t.value[o]=e.value}a(handlePropertyResult,"handlePropertyResult");function normalizeDef(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const o=optionalKeys(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}a(normalizeDef,"normalizeDef");function handleCatchall(e,t,o,n,r,i){const s=[],c=r.keySet,l=r.catchall._zod,d=l.def.type,h=l.optout==="optional";for(const f in t){if(c.has(f))continue;if(d==="never"){s.push(f);continue}const g=l.run({value:t[f],issues:[]},n);g instanceof Promise?e.push(g.then(m=>handlePropertyResult(m,o,f,t,h))):handlePropertyResult(g,o,f,t,h)}return s.length&&o.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>o):o}a(handleCatchall,"handleCatchall");const $ZodObject=$constructor("$ZodObject",(e,t)=>{if($ZodType.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:a(()=>{const l={...c};return Object.defineProperty(t,"shape",{value:l}),l},"get")})}const n=cached(()=>normalizeDef(t));defineLazy(e._zod,"propValues",()=>{const c=t.shape,l={};for(const d in c){const h=c[d]._zod;if(h.values){l[d]??(l[d]=new Set);for(const f of h.values)l[d].add(f)}}return l});const r=isObject,i=t.catchall;let s;e._zod.parse=(c,l)=>{s??(s=n.value);const d=c.value;if(!r(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const h=[],f=s.shape;for(const g of s.keys){const m=f[g],T=m._zod.optout==="optional",I=m._zod.run({value:d[g],issues:[]},l);I instanceof Promise?h.push(I.then(A=>handlePropertyResult(A,c,g,d,T))):handlePropertyResult(I,c,g,d,T)}return i?handleCatchall(h,d,c,l,n.value,e):h.length?Promise.all(h).then(()=>c):c}}),$ZodObjectJIT=$constructor("$ZodObjectJIT",(e,t)=>{$ZodObject.init(e,t);const o=e._zod.parse,n=cached(()=>normalizeDef(t)),r=a(g=>{const m=new Doc(["shape","payload","ctx"]),T=n.value,I=a(k=>{const v=esc(k);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`},"parseStr");m.write("const input = payload.value;");const A=Object.create(null);let R=0;for(const k of T.keys)A[k]=`key_${R++}`;m.write("const newResult = {};");for(const k of T.keys){const v=A[k],O=esc(k),B=g[k]?._zod?.optout==="optional";m.write(`const ${v} = ${I(k)};`),B?m.write(`
|
|
5
|
+
`))}};a(V,"Doc");let Doc=V;const version={major:4,minor:3,patch:6},$ZodType=$constructor("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=version;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const r of n)for(const i of r._zod.onattach)i(e);if(n.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=a((s,c,l)=>{let d=aborted(s),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(s))continue}else if(d)continue;const g=s.issues.length,m=f._zod.check(s);if(m instanceof Promise&&l?.async===!1)throw new $ZodAsyncError;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,s.issues.length!==g&&(d||(d=aborted(s,g)))});else{if(s.issues.length===g)continue;d||(d=aborted(s,g))}}return h?h.then(()=>s):s},"runChecks"),i=a((s,c,l)=>{if(aborted(s))return s.aborted=!0,s;const d=r(c,n,l);if(d instanceof Promise){if(l.async===!1)throw new $ZodAsyncError;return d.then(h=>e._zod.parse(h,l))}return e._zod.parse(d,l)},"handleCanaryResult");e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const d=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(h=>i(h,s,c)):i(d,s,c)}const l=e._zod.parse(s,c);if(l instanceof Promise){if(c.async===!1)throw new $ZodAsyncError;return l.then(d=>r(d,n,c))}return r(l,n,c)}}defineLazy(e,"~standard",()=>({validate:a(r=>{try{const i=safeParse$1(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return safeParseAsync$1(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},"validate"),vendor:"zod",version:1}))}),$ZodString=$constructor("$ZodString",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??string$1(e._zod.bag),e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),$ZodStringFormat=$constructor("$ZodStringFormat",(e,t)=>{$ZodCheckStringFormat.init(e,t),$ZodString.init(e,t)}),$ZodGUID=$constructor("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=guid),$ZodStringFormat.init(e,t)}),$ZodUUID=$constructor("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uuid(n))}else t.pattern??(t.pattern=uuid());$ZodStringFormat.init(e,t)}),$ZodEmail=$constructor("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=email),$ZodStringFormat.init(e,t)}),$ZodURL=$constructor("$ZodURL",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{try{const n=o.value.trim(),r=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})),t.normalize?o.value=r.href:o.value=n;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=emoji()),$ZodStringFormat.init(e,t)}),$ZodNanoID=$constructor("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nanoid),$ZodStringFormat.init(e,t)}),$ZodCUID=$constructor("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cuid),$ZodStringFormat.init(e,t)}),$ZodCUID2=$constructor("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cuid2),$ZodStringFormat.init(e,t)}),$ZodULID=$constructor("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ulid),$ZodStringFormat.init(e,t)}),$ZodXID=$constructor("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xid),$ZodStringFormat.init(e,t)}),$ZodKSUID=$constructor("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ksuid),$ZodStringFormat.init(e,t)}),$ZodISODateTime=$constructor("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=datetime$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODate=$constructor("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=date$1),$ZodStringFormat.init(e,t)}),$ZodISOTime=$constructor("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=time$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODuration=$constructor("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=duration$1),$ZodStringFormat.init(e,t)}),$ZodIPv4=$constructor("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ipv4),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv4"}),$ZodIPv6=$constructor("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ipv6),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv6",e._zod.check=o=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cidrv4),$ZodStringFormat.init(e,t)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cidrv6),$ZodStringFormat.init(e,t),e._zod.check=o=>{const n=o.value.split("/");try{if(n.length!==2)throw new Error;const[r,i]=n;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function isValidBase64(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}a(isValidBase64,"isValidBase64");const $ZodBase64=$constructor("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=base64),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=o=>{isValidBase64(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function isValidBase64URL(e){if(!base64url.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return isValidBase64(o)}a(isValidBase64URL,"isValidBase64URL");const $ZodBase64URL=$constructor("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=base64url),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=o=>{isValidBase64URL(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),$ZodE164=$constructor("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e164),$ZodStringFormat.init(e,t)});function isValidJWT(e,t=null){try{const o=e.split(".");if(o.length!==3)return!1;const[n]=o;if(!n)return!1;const r=JSON.parse(atob(n));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}a(isValidJWT,"isValidJWT");const $ZodJWT=$constructor("$ZodJWT",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{isValidJWT(o.value,t.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}}),$ZodNumber=$constructor("$ZodNumber",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=e._zod.bag.pattern??number$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=Number(o.value)}catch{}const r=o.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return o;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),o}}),$ZodNumberFormat=$constructor("$ZodNumberFormat",(e,t)=>{$ZodCheckNumberFormat.init(e,t),$ZodNumber.init(e,t)}),$ZodBoolean=$constructor("$ZodBoolean",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=boolean$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=!!o.value}catch{}const r=o.value;return typeof r=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),o}}),$ZodUnknown=$constructor("$ZodUnknown",(e,t)=>{$ZodType.init(e,t),e._zod.parse=o=>o}),$ZodNever=$constructor("$ZodNever",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function handleArrayResult(e,t,o){e.issues.length&&t.issues.push(...prefixIssues(o,e.issues)),t.value[o]=e.value}a(handleArrayResult,"handleArrayResult");const $ZodArray=$constructor("$ZodArray",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{const r=o.value;if(!Array.isArray(r))return o.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),o;o.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const c=r[s],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?i.push(l.then(d=>handleArrayResult(d,o,s))):handleArrayResult(l,o,s)}return i.length?Promise.all(i).then(()=>o):o}});function handlePropertyResult(e,t,o,n,r){if(e.issues.length){if(r&&!(o in n))return;t.issues.push(...prefixIssues(o,e.issues))}e.value===void 0?o in n&&(t.value[o]=void 0):t.value[o]=e.value}a(handlePropertyResult,"handlePropertyResult");function normalizeDef(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const o=optionalKeys(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}a(normalizeDef,"normalizeDef");function handleCatchall(e,t,o,n,r,i){const s=[],c=r.keySet,l=r.catchall._zod,d=l.def.type,h=l.optout==="optional";for(const f in t){if(c.has(f))continue;if(d==="never"){s.push(f);continue}const g=l.run({value:t[f],issues:[]},n);g instanceof Promise?e.push(g.then(m=>handlePropertyResult(m,o,f,t,h))):handlePropertyResult(g,o,f,t,h)}return s.length&&o.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>o):o}a(handleCatchall,"handleCatchall");const $ZodObject=$constructor("$ZodObject",(e,t)=>{if($ZodType.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:a(()=>{const l={...c};return Object.defineProperty(t,"shape",{value:l}),l},"get")})}const n=cached(()=>normalizeDef(t));defineLazy(e._zod,"propValues",()=>{const c=t.shape,l={};for(const d in c){const h=c[d]._zod;if(h.values){l[d]??(l[d]=new Set);for(const f of h.values)l[d].add(f)}}return l});const r=isObject,i=t.catchall;let s;e._zod.parse=(c,l)=>{s??(s=n.value);const d=c.value;if(!r(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const h=[],f=s.shape;for(const g of s.keys){const m=f[g],T=m._zod.optout==="optional",I=m._zod.run({value:d[g],issues:[]},l);I instanceof Promise?h.push(I.then(A=>handlePropertyResult(A,c,g,d,T))):handlePropertyResult(I,c,g,d,T)}return i?handleCatchall(h,d,c,l,n.value,e):h.length?Promise.all(h).then(()=>c):c}}),$ZodObjectJIT=$constructor("$ZodObjectJIT",(e,t)=>{$ZodObject.init(e,t);const o=e._zod.parse,n=cached(()=>normalizeDef(t)),r=a(g=>{const m=new Doc(["shape","payload","ctx"]),T=n.value,I=a(k=>{const v=esc(k);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`},"parseStr");m.write("const input = payload.value;");const A=Object.create(null);let C=0;for(const k of T.keys)A[k]=`key_${C++}`;m.write("const newResult = {};");for(const k of T.keys){const v=A[k],O=esc(k),B=g[k]?._zod?.optout==="optional";m.write(`const ${v} = ${I(k)};`),B?m.write(`
|
|
6
6
|
if (${v}.issues.length) {
|
|
7
7
|
if (${O} in input) {
|
|
8
8
|
payload.issues = payload.issues.concat(${v}.issues.map(iss => ({
|
|
@@ -42,7 +42,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
42
42
|
`:`
|
|
43
43
|
`)+o,r=n+1,n=e.indexOf(`
|
|
44
44
|
`,r)}while(n!==-1);return i+=e.slice(r),i}a(stringEncaseCRLFWithFirstIndex,"stringEncaseCRLFWithFirstIndex");const{stdout:stdoutColor,stderr:stderrColor}=supportsColor,GENERATOR=Symbol("GENERATOR"),STYLER=Symbol("STYLER"),IS_EMPTY=Symbol("IS_EMPTY"),levelMapping=["ansi","ansi","ansi256","ansi16m"],styles$2=Object.create(null),applyOptions=a((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const o=stdoutColor?stdoutColor.level:0;e.level=t.level===void 0?o:t.level},"applyOptions"),chalkFactory=a(e=>{const t=a((...o)=>o.join(" "),"chalk");return applyOptions(t,e),Object.setPrototypeOf(t,createChalk.prototype),t},"chalkFactory");function createChalk(e){return chalkFactory(e)}a(createChalk,"createChalk"),Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(const[e,t]of Object.entries(ansiStyles))styles$2[e]={get(){const o=createBuilder(this,createStyler(t.open,t.close,this[STYLER]),this[IS_EMPTY]);return Object.defineProperty(this,e,{value:o}),o}};styles$2.visible={get(){const e=createBuilder(this,this[STYLER],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const getModelAnsi=a((e,t,o,...n)=>e==="rgb"?t==="ansi16m"?ansiStyles[o].ansi16m(...n):t==="ansi256"?ansiStyles[o].ansi256(ansiStyles.rgbToAnsi256(...n)):ansiStyles[o].ansi(ansiStyles.rgbToAnsi(...n)):e==="hex"?getModelAnsi("rgb",t,o,...ansiStyles.hexToRgb(...n)):ansiStyles[o][e](...n),"getModelAnsi"),usedModels=["rgb","hex","ansi256"];for(const e of usedModels){styles$2[e]={get(){const{level:o}=this;return function(...n){const r=createStyler(getModelAnsi(e,levelMapping[o],"color",...n),ansiStyles.color.close,this[STYLER]);return createBuilder(this,r,this[IS_EMPTY])}}};const t="bg"+e[0].toUpperCase()+e.slice(1);styles$2[t]={get(){const{level:o}=this;return function(...n){const r=createStyler(getModelAnsi(e,levelMapping[o],"bgColor",...n),ansiStyles.bgColor.close,this[STYLER]);return createBuilder(this,r,this[IS_EMPTY])}}}}const proto=Object.defineProperties(()=>{},{...styles$2,level:{enumerable:!0,get(){return this[GENERATOR].level},set(e){this[GENERATOR].level=e}}}),createStyler=a((e,t,o)=>{let n,r;return o===void 0?(n=e,r=t):(n=o.openAll+e,r=t+o.closeAll),{open:e,close:t,openAll:n,closeAll:r,parent:o}},"createStyler"),createBuilder=a((e,t,o)=>{const n=a((...r)=>applyStyle(n,r.length===1?""+r[0]:r.join(" ")),"builder");return Object.setPrototypeOf(n,proto),n[GENERATOR]=e,n[STYLER]=t,n[IS_EMPTY]=o,n},"createBuilder"),applyStyle=a((e,t)=>{if(e.level<=0||!t)return e[IS_EMPTY]?"":t;let o=e[STYLER];if(o===void 0)return t;const{openAll:n,closeAll:r}=o;if(t.includes("\x1B"))for(;o!==void 0;)t=stringReplaceAll(t,o.close,o.open),o=o.parent;const i=t.indexOf(`
|
|
45
|
-
`);return i!==-1&&(t=stringEncaseCRLFWithFirstIndex(t,r,n,i)),n+t+r},"applyStyle");Object.defineProperties(createChalk.prototype,styles$2);const chalk=createChalk();createChalk({level:stderrColor?stderrColor.level:0});
|
|
45
|
+
`);return i!==-1&&(t=stringEncaseCRLFWithFirstIndex(t,r,n,i)),n+t+r},"applyStyle");Object.defineProperties(createChalk.prototype,styles$2);const chalk=createChalk();createChalk({level:stderrColor?stderrColor.level:0});const debug=console.debug.bind(console,chalk.gray("[LLM]"));function zodToOpenAITool(e,t){return{type:"function",function:{name:e,description:t.description,parameters:toJSONSchema(t.inputSchema,{target:"openapi-3.0"})}}}a(zodToOpenAITool,"zodToOpenAITool");function modelPatch(e){const t=e.model||"";if(!t)return e;const o=normalizeModelName(t);return o.startsWith("qwen")&&(debug("Applying Qwen patch: use higher temperature for auto fixing"),e.temperature=Math.max(e.temperature||0,1),e.enable_thinking=!1),o.startsWith("claude")&&(debug("Applying Claude patch: disable thinking"),e.thinking={type:"disabled"},e.tool_choice==="required"?(debug('Applying Claude patch: convert tool_choice "required" to { type: "any" }'),e.tool_choice={type:"any"}):e.tool_choice?.function?.name&&(debug("Applying Claude patch: convert tool_choice format"),e.tool_choice={type:"tool",name:e.tool_choice.function.name})),o.startsWith("grok")&&(debug("Applying Grok patch: removing tool_choice"),delete e.tool_choice,debug("Applying Grok patch: disable reasoning and thinking"),e.thinking={type:"disabled",effort:"minimal"},e.reasoning={enabled:!1,effort:"low"}),o.startsWith("gpt")&&(debug("Applying GPT patch: set verbosity to low"),e.verbosity="low",o.startsWith("gpt-52")?(debug("Applying GPT-52 patch: disable reasoning"),e.reasoning_effort="none"):o.startsWith("gpt-51")?(debug("Applying GPT-51 patch: disable reasoning"),e.reasoning_effort="none"):o.startsWith("gpt-5-mini")?(debug("Applying GPT-5-mini patch: set reasoning effort to low, temperature to 1"),e.reasoning_effort="low",e.temperature=1):o.startsWith("gpt-5")&&(debug("Applying GPT-5 patch: set reasoning effort to low"),e.reasoning_effort="low")),o.startsWith("gemini")&&(debug("Applying Gemini patch: set reasoning effort to minimal"),e.reasoning_effort="minimal"),e}a(modelPatch,"modelPatch");function normalizeModelName(e){let t=e.toLowerCase();return t.includes("/")&&(t=t.split("/")[1]),t=t.replace(/_/g,""),t=t.replace(/\./g,""),t}a(normalizeModelName,"normalizeModelName");const ct=class ct{config;fetch;constructor(t){this.config=t,this.fetch=t.customFetch}async invoke(t,o,n,r){const i=Object.entries(o).map(([k,v])=>zodToOpenAITool(k,v)),s={model:this.config.model,temperature:this.config.temperature,messages:t,tools:i,parallel_tool_calls:!1,tool_choice:r?.toolChoiceName?{type:"function",function:{name:r.toolChoiceName}}:"required"};modelPatch(s);let c;try{c=await this.fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(s),signal:n})}catch(k){const v=k?.name==="AbortError",O=v?"Network request aborted":"Network request failed";throw v||console.error(k),new InvokeError(InvokeErrorType.NETWORK_ERROR,O,k)}if(!c.ok){const k=await c.json().catch(),v=k.error?.message||c.statusText;throw c.status===401||c.status===403?new InvokeError(InvokeErrorType.AUTH_ERROR,`Authentication failed: ${v}`,k):c.status===429?new InvokeError(InvokeErrorType.RATE_LIMIT,`Rate limit exceeded: ${v}`,k):c.status>=500?new InvokeError(InvokeErrorType.SERVER_ERROR,`Server error: ${v}`,k):new InvokeError(InvokeErrorType.UNKNOWN,`HTTP ${c.status}: ${v}`,k)}const l=await c.json(),d=l.choices?.[0];if(!d)throw new InvokeError(InvokeErrorType.UNKNOWN,"No choices in response",l);switch(d.finish_reason){case"tool_calls":case"function_call":case"stop":break;case"length":throw new InvokeError(InvokeErrorType.CONTEXT_LENGTH,"Response truncated: max tokens reached",void 0,l);case"content_filter":throw new InvokeError(InvokeErrorType.CONTENT_FILTER,"Content filtered by safety system",void 0,l);default:throw new InvokeError(InvokeErrorType.UNKNOWN,`Unexpected finish_reason: ${d.finish_reason}`,void 0,l)}const f=(r?.normalizeResponse?r.normalizeResponse(l):l).choices?.[0],g=f?.message?.tool_calls?.[0]?.function?.name;if(!g)throw new InvokeError(InvokeErrorType.NO_TOOL_CALL,"No tool call found in response",void 0,l);const m=o[g];if(!m)throw new InvokeError(InvokeErrorType.UNKNOWN,`Tool "${g}" not found in tools`,void 0,l);const T=f.message?.tool_calls?.[0]?.function?.arguments;if(!T)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"No tool call arguments found",void 0,l);let I;try{I=JSON.parse(T)}catch(k){throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Failed to parse tool arguments as JSON",k,l)}const A=m.inputSchema.safeParse(I);if(!A.success)throw console.error(prettifyError(A.error)),new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Tool arguments validation failed",A.error,l);const C=A.data;let D;try{D=await m.execute(C)}catch(k){throw new InvokeError(InvokeErrorType.TOOL_EXECUTION_ERROR,`Tool execution failed: ${k.message}`,k,l)}return{toolCall:{name:g,args:C},toolResult:D,usage:{promptTokens:l.usage?.prompt_tokens??0,completionTokens:l.usage?.completion_tokens??0,totalTokens:l.usage?.total_tokens??0,cachedTokens:l.usage?.prompt_tokens_details?.cached_tokens,reasoningTokens:l.usage?.completion_tokens_details?.reasoning_tokens},rawResponse:l,rawRequest:s}}};a(ct,"OpenAIClient");let OpenAIClient=ct;const LLM_MAX_RETRIES=2,DEFAULT_TEMPERATURE=.7;function parseLLMConfig(e){if(!e.baseURL||!e.apiKey||!e.model)throw new Error("[PageAgent] LLM configuration required. Please provide: baseURL, apiKey, model. See: https://alibaba.github.io/page-agent/docs/features/models");return{baseURL:e.baseURL,apiKey:e.apiKey,model:e.model,temperature:e.temperature??DEFAULT_TEMPERATURE,maxRetries:e.maxRetries??LLM_MAX_RETRIES,customFetch:(e.customFetch??fetch).bind(globalThis)}}a(parseLLMConfig,"parseLLMConfig");const lt=class lt extends EventTarget{config;client;constructor(t){super(),this.config=parseLLMConfig(t),this.client=new OpenAIClient(this.config)}async invoke(t,o,n,r){return await withRetry(async()=>{if(n.aborted)throw new Error("AbortError");return await this.client.invoke(t,o,n,r)},{maxRetries:this.config.maxRetries,onRetry:a(i=>{this.dispatchEvent(new CustomEvent("retry",{detail:{attempt:i,maxAttempts:this.config.maxRetries}}))},"onRetry"),onError:a(i=>{this.dispatchEvent(new CustomEvent("error",{detail:{error:i}}))},"onError")})}};a(lt,"LLM");let LLM=lt;async function withRetry(e,t){let o=0,n=null;for(;o<=t.maxRetries;){o>0&&(t.onRetry(o),await new Promise(r=>setTimeout(r,100)));try{return await e()}catch(r){if(r?.rawError?.name==="AbortError"||(console.error(r),t.onError(r),r instanceof InvokeError&&!r.retryable))throw r;n=r,o++,await new Promise(i=>setTimeout(i,100))}}throw n}a(withRetry,"withRetry");const SYSTEM_PROMPT=`You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.
|
|
46
46
|
|
|
47
47
|
<intro>
|
|
48
48
|
You excel at following tasks:
|
|
@@ -195,8 +195,8 @@ Here are examples of good output patterns. Use them as reference but never copy
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
</output>
|
|
198
|
-
`;function normalizeResponse(e,t){let o=null;const n=e.choices?.[0];if(!n)throw new Error("No choices in response");const r=n.message;if(!r)throw new Error("No message in choice");const i=r.tool_calls?.[0];if(i?.function?.arguments)o=safeJsonParse(i.function.arguments),i.function.name&&i.function.name!=="AgentOutput"&&(console.log(chalk.yellow("[normalizeResponse] #1: fixing tool_call")),o={action:safeJsonParse(o)});else if(r.content){const s=r.content.trim(),c=retrieveJsonFromString(s);if(c)o=safeJsonParse(c),o?.name==="AgentOutput"&&(console.log(chalk.yellow("[normalizeResponse] #2: fixing tool_call")),o=safeJsonParse(o.arguments)),o?.type==="function"&&(console.log(chalk.yellow("[normalizeResponse] #3: fixing tool_call")),o=safeJsonParse(o.function.arguments)),!o?.action&&!o?.evaluation_previous_goal&&!o?.memory&&!o?.next_goal&&!o?.thinking&&(console.log(chalk.yellow("[normalizeResponse] #4: fixing tool_call")),o={action:safeJsonParse(o)});else throw new Error("No tool_call and the message content does not contain valid JSON")}else throw new Error("No tool_call nor message content is present");return o=safeJsonParse(o),o.action&&(o.action=safeJsonParse(o.action)),o.action&&t&&(o.action=validateAction(o.action,t)),o.action||(console.log(chalk.yellow("[normalizeResponse] #5: fixing tool_call")),o.action={name:"wait",input:{seconds:1}}),{...e,choices:[{...n,message:{...r,tool_calls:[{...i||{},function:{...i?.function||{},name:"AgentOutput",arguments:JSON.stringify(o)}}]}}]}}a(normalizeResponse,"normalizeResponse");function validateAction(e,t){if(typeof e!="object"||e===null)return e;const o=Object.keys(e)[0];if(!o)return e;const n=t.get(o);if(!n){const c=Array.from(t.keys()).join(", ");throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,`Unknown action "${o}". Available: ${c}`)}let r=e[o];const i=n.inputSchema;if(i instanceof ZodObject&&r!==null&&typeof r!="object"){const c=Object.keys(i.shape).find(l=>!i.shape[l].safeParse(void 0).success);c&&(console.log(chalk.yellow(`[normalizeResponse] coercing primitive action input for "${o}"`)),r={[c]:r})}const s=i.safeParse(r);if(!s.success)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,`Invalid input for action "${o}": ${prettifyError(s.error)}`);return{[o]:s.data}}a(validateAction,"validateAction");function safeJsonParse(e){if(typeof e=="string")try{return JSON.parse(e.trim())}catch{return e}return e}a(safeJsonParse,"safeJsonParse");function retrieveJsonFromString(e){try{const t=/({[\s\S]*})/.exec(e)??[];return t.length===0?null:JSON.parse(t[0])}catch{return null}}a(retrieveJsonFromString,"retrieveJsonFromString");async function waitFor$1(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor$1,"waitFor$1");function randomID(e){let t=Math.random().toString(36).substring(2,11);if(!e)return t;const o=1e3;let n=0;for(;e.includes(t);)if(t=Math.random().toString(36).substring(2,11),n++,n>o)throw new Error("randomID: too many try");return t}a(randomID,"randomID");const _global=globalThis;_global.__PAGE_AGENT_IDS__||(_global.__PAGE_AGENT_IDS__=[]);const ids=_global.__PAGE_AGENT_IDS__;function uid(){const e=randomID(ids);return ids.push(e),e}a(uid,"uid");const llmsTxtCache=new Map;async function fetchLlmsTxt(e){const t=new URL(e).origin;if(llmsTxtCache.has(t))return llmsTxtCache.get(t);const o=`${t}/llms.txt`;let n=null;try{console.log(chalk.gray(`[llms.txt] Fetching ${o}`));const r=await fetch(o,{signal:AbortSignal.timeout(3e3)});r.ok?(n=await r.text(),console.log(chalk.green(`[llms.txt] Found (${n.length} chars)`))):console.log(chalk.gray(`[llms.txt] ${r.status} for ${o}`))}catch(r){console.log(chalk.gray(`[llms.txt] Failed for ${o}`),r)}return llmsTxtCache.set(t,n),n}a(fetchLlmsTxt,"fetchLlmsTxt");function assert(e,t,o){if(!e){const n=t??"Assertion failed";throw console.error(chalk.red(`❌ assert: ${n}`)),new Error(n)}}a(assert,"assert");function tool(e){return e}a(tool,"tool");const tools=new Map;tools.set("done",{description:"Complete task. Text is your final response to the user — keep it concise unless the user explicitly asks for detail.",inputSchema:object({text:string(),success:boolean().default(!0)}),execute:a(async function(e){return Promise.resolve("Task completed")},"execute")}),tools.set("wait",{description:"Wait for x seconds. Can be used to wait until the page or data is fully loaded.",inputSchema:object({seconds:number().min(1).max(10).default(1)}),execute:a(async function(e){const t=await this.pageController.getLastUpdateTime(),o=Math.max(0,e.seconds-(Date.now()-t)/1e3);return console.log(`actualWaitTime: ${o} seconds`),await waitFor$1(o),`✅ Waited for ${e.seconds} seconds.`},"execute")}),tools.set("ask_user",{description:"Ask the user a question and wait for their answer. Use this if you need more information or clarification.",inputSchema:object({question:string()}),execute:a(async function(e){if(!this.onAskUser)throw new Error("ask_user tool requires onAskUser callback to be set");return`User answered: ${await this.onAskUser(e.question)}`},"execute")}),tools.set("click_element_by_index",{description:"Click element by index",inputSchema:object({index:int().min(0)}),execute:a(async function(e){return(await this.pageController.clickElement(e.index)).message},"execute")}),tools.set("input_text",{description:"Click and type text into an interactive input element",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.inputText(e.index,e.text)).message},"execute")}),tools.set("select_dropdown_option",{description:"Select dropdown option for interactive element index by the text of the option you want to select",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.selectOption(e.index,e.text)).message},"execute")}),tools.set("scroll",{description:"Scroll the page vertically. Use index for scroll elements (dropdowns/custom UI).",inputSchema:object({down:boolean().default(!0),num_pages:number().min(0).max(10).optional().default(.1),pixels:number().int().min(0).optional(),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scroll({...e,numPages:e.num_pages})).message},"execute")}),tools.set("scroll_horizontally",{description:"Scroll the page horizontally, or within a specific element by index. Useful for wide tables.",inputSchema:object({right:boolean().default(!0),pixels:number().int().min(0),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scrollHorizontally(e)).message},"execute")}),tools.set("execute_javascript",{description:"Execute JavaScript code on the current page. Supports async/await syntax. Use with caution!",inputSchema:object({script:string()}),execute:a(async function(e){return(await this.pageController.executeJavascript(e.script)).message},"execute")});const ut=class ut extends EventTarget{constructor(o){super();Z(this,C);ne(this,"id",uid());ne(this,"config");ne(this,"tools");ne(this,"pageController");ne(this,"task","");ne(this,"taskId","");ne(this,"history",[]);ne(this,"disposed",!1);ne(this,"onAskUser");Z(this,Ue,"idle");Z(this,Oe);Z(this,ie,new AbortController);Z(this,$e,[]);Z(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});if(this.config={...o,maxSteps:o.maxSteps||20},S(this,Oe,new LLM(this.config)),this.tools=new Map(tools),this.pageController=o.pageController,p(this,Oe).addEventListener("retry",n=>{const{attempt:r,maxAttempts:i}=n.detail;b(this,C,Me).call(this,{type:"retrying",attempt:r,maxAttempts:i}),this.history.push({type:"retry",message:`LLM retry attempt ${r} of ${i}`,attempt:r,maxAttempts:i}),b(this,C,Pe).call(this)}),p(this,Oe).addEventListener("error",n=>{const r=n.detail.error;if(r?.rawError?.name==="AbortError")return;const i=String(r);b(this,C,Me).call(this,{type:"error",message:i}),this.history.push({type:"error",message:i,rawResponse:r.rawResponse}),b(this,C,Pe).call(this)}),this.config.customTools)for(const[n,r]of Object.entries(this.config.customTools)){if(r===null){this.tools.delete(n);continue}this.tools.set(n,r)}this.config.experimentalScriptExecutionTool||this.tools.delete("execute_javascript")}get status(){return p(this,Ue)}pushObservation(o){p(this,$e).push(o)}stop(){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),p(this,ie).abort()}async execute(o){if(this.disposed)throw new Error("PageAgent has been disposed. Create a new instance.");if(!o)throw new Error("Task is required");this.task=o,this.taskId=uid(),this.onAskUser||this.tools.delete("ask_user");const n=this.config.onBeforeStep,r=this.config.onAfterStep,i=this.config.onBeforeTask,s=this.config.onAfterTask;await i?.(this),await this.pageController.showMask(),p(this,ie)&&(p(this,ie).abort(),S(this,ie,new AbortController)),this.history=[],b(this,C,_t).call(this,"running"),b(this,C,Pe).call(this),S(this,$e,[]),S(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});let c=0;for(;;){try{console.group(`step: ${c}`),await n?.(this,c),console.log(chalk.blue.bold("👀 Observing...")),p(this,Q).browserState=await this.pageController.getBrowserState(),await b(this,C,At).call(this,c);const l=[{role:"system",content:b(this,C,It).call(this)},{role:"user",content:await b(this,C,Pt).call(this)}],d={AgentOutput:b(this,C,Tt).call(this)};console.log(chalk.blue.bold("🧠 Thinking...")),b(this,C,Me).call(this,{type:"thinking"});const h=await p(this,Oe).invoke(l,d,p(this,ie).signal,{toolChoiceName:"AgentOutput",normalizeResponse:a(R=>normalizeResponse(R,this.tools),"normalizeResponse")}),f=h.toolResult,g=f.input,m=f.output,T={evaluation_previous_goal:g.evaluation_previous_goal,memory:g.memory,next_goal:g.next_goal},I=Object.keys(g.action)[0],A={name:I,input:g.action[I],output:m};if(this.history.push({type:"step",stepIndex:c,reflection:T,action:A,usage:h.usage,rawResponse:h.rawResponse,rawRequest:h.rawRequest}),b(this,C,Pe).call(this),await r?.(this,this.history),console.groupEnd(),I==="done"){const R=A.input?.success??!1,D=A.input?.text||"no text provided";console.log(chalk.green.bold("Task completed"),R,D),b(this,C,st).call(this,R);const k={success:R,data:D,history:this.history};return await s?.(this,k),k}}catch(l){console.groupEnd();const d=l?.rawError?.name==="AbortError";console.error("Task failed",l);const h=d?"Task stopped":String(l);b(this,C,Me).call(this,{type:"error",message:h}),this.history.push({type:"error",message:h,rawResponse:l}),b(this,C,Pe).call(this),b(this,C,st).call(this,!1);const f={success:!1,data:h,history:this.history};return await s?.(this,f),f}if(c++,c>this.config.maxSteps){const l="Step count exceeded maximum limit";this.history.push({type:"error",message:l}),b(this,C,Pe).call(this),b(this,C,st).call(this,!1);const d={success:!1,data:l,history:this.history};return await s?.(this,d),d}await waitFor$1(.4)}}dispose(){console.log("Disposing PageAgent..."),this.disposed=!0,this.pageController.dispose(),p(this,ie).abort(),this.dispatchEvent(new Event("dispose")),this.config.onDispose?.(this)}};Ue=new WeakMap,Oe=new WeakMap,ie=new WeakMap,$e=new WeakMap,Q=new WeakMap,C=new WeakSet,St=a(function(){this.dispatchEvent(new Event("statuschange"))},"#emitStatusChange"),Pe=a(function(){this.dispatchEvent(new Event("historychange"))},"#emitHistoryChange"),Me=a(function(o){this.dispatchEvent(new CustomEvent("activity",{detail:o}))},"#emitActivity"),_t=a(function(o){p(this,Ue)!==o&&(S(this,Ue,o),b(this,C,St).call(this))},"#setStatus"),Tt=a(function(){const o=this.tools,n=Array.from(o.entries()).map(([s,c])=>object({[s]:c.inputSchema}).describe(c.description)),r=union(n);return{description:"You MUST call this tool every step!",inputSchema:object({evaluation_previous_goal:string().optional(),memory:string().optional(),next_goal:string().optional(),action:r}),execute:a(async s=>{if(p(this,ie).signal.aborted)throw new Error("AbortError");console.log(chalk.blue.bold("MacroTool input"),s);const c=s.action,l=Object.keys(c)[0],d=c[l],h=[];s.evaluation_previous_goal&&h.push(`✅: ${s.evaluation_previous_goal}`),s.memory&&h.push(`💾: ${s.memory}`),s.next_goal&&h.push(`🎯: ${s.next_goal}`);const f=h.length>0?h.join(`
|
|
199
|
-
`):"";f&&console.log(f);const g=o.get(l);assert(g,`Tool ${l} not found`),console.log(chalk.blue.bold(`Executing tool: ${l}`),d),b(this,
|
|
198
|
+
`,log=console.log.bind(console,chalk.yellow("[autoFixer]"));function normalizeResponse(e,t){let o=null;const n=e.choices?.[0];if(!n)throw new Error("No choices in response");const r=n.message;if(!r)throw new Error("No message in choice");const i=r.tool_calls?.[0];if(i?.function?.arguments)o=safeJsonParse(i.function.arguments),i.function.name&&i.function.name!=="AgentOutput"&&(log("#1: fixing tool_call"),o={action:safeJsonParse(o)});else if(r.content){const s=r.content.trim(),c=retrieveJsonFromString(s);if(c)o=safeJsonParse(c),o?.name==="AgentOutput"&&(log("#2: fixing tool_call"),o=safeJsonParse(o.arguments)),o?.type==="function"&&(log("#3: fixing tool_call"),o=safeJsonParse(o.function.arguments)),!o?.action&&!o?.evaluation_previous_goal&&!o?.memory&&!o?.next_goal&&!o?.thinking&&(log("#4: fixing tool_call"),o={action:safeJsonParse(o)});else throw new Error("No tool_call and the message content does not contain valid JSON")}else throw new Error("No tool_call nor message content is present");return o=safeJsonParse(o),o.action&&(o.action=safeJsonParse(o.action)),o.action&&t&&(o.action=validateAction(o.action,t)),o.action||(log("#5: fixing tool_call"),o.action={name:"wait",input:{seconds:1}}),{...e,choices:[{...n,message:{...r,tool_calls:[{...i||{},function:{...i?.function||{},name:"AgentOutput",arguments:JSON.stringify(o)}}]}}]}}a(normalizeResponse,"normalizeResponse");function validateAction(e,t){if(typeof e!="object"||e===null)return e;const o=Object.keys(e)[0];if(!o)return e;const n=t.get(o);if(!n){const c=Array.from(t.keys()).join(", ");throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,`Unknown action "${o}". Available: ${c}`)}let r=e[o];const i=n.inputSchema;if(i instanceof ZodObject&&r!==null&&typeof r!="object"){const c=Object.keys(i.shape).find(l=>!i.shape[l].safeParse(void 0).success);c&&(log(`coercing primitive action input for "${o}"`),r={[c]:r})}const s=i.safeParse(r);if(!s.success)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,`Invalid input for action "${o}": ${prettifyError(s.error)}`);return{[o]:s.data}}a(validateAction,"validateAction");function safeJsonParse(e){if(typeof e=="string")try{return JSON.parse(e.trim())}catch{return e}return e}a(safeJsonParse,"safeJsonParse");function retrieveJsonFromString(e){try{const t=/({[\s\S]*})/.exec(e)??[];return t.length===0?null:JSON.parse(t[0])}catch{return null}}a(retrieveJsonFromString,"retrieveJsonFromString");async function waitFor$1(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor$1,"waitFor$1");function truncate$1(e,t){return e.length>t?e.substring(0,t)+"...":e}a(truncate$1,"truncate$1");function randomID(e){let t=Math.random().toString(36).substring(2,11);if(!e)return t;const o=1e3;let n=0;for(;e.includes(t);)if(t=Math.random().toString(36).substring(2,11),n++,n>o)throw new Error("randomID: too many try");return t}a(randomID,"randomID");const _global=globalThis;_global.__PAGE_AGENT_IDS__||(_global.__PAGE_AGENT_IDS__=[]);const ids=_global.__PAGE_AGENT_IDS__;function uid(){const e=randomID(ids);return ids.push(e),e}a(uid,"uid");const llmsTxtCache=new Map;async function fetchLlmsTxt(e){const t=new URL(e).origin;if(llmsTxtCache.has(t))return llmsTxtCache.get(t);const o=`${t}/llms.txt`;let n=null;try{console.log(chalk.gray(`[llms.txt] Fetching ${o}`));const r=await fetch(o,{signal:AbortSignal.timeout(3e3)});r.ok?(n=await r.text(),console.log(chalk.green(`[llms.txt] Found (${n.length} chars)`)),n.length>1e3&&(console.log(chalk.yellow("[llms.txt] Truncating to 1000 chars")),n=truncate$1(n,1e3))):console.debug(chalk.gray(`[llms.txt] ${r.status} for ${o}`))}catch(r){console.debug(chalk.gray(`[llms.txt] not found for ${o}`),r)}return llmsTxtCache.set(t,n),n}a(fetchLlmsTxt,"fetchLlmsTxt");function assert(e,t,o){if(!e){const n=t??"Assertion failed";throw console.error(chalk.red(`❌ assert: ${n}`)),new Error(n)}}a(assert,"assert");function tool(e){return e}a(tool,"tool");const tools=new Map;tools.set("done",{description:"Complete task. Text is your final response to the user — keep it concise unless the user explicitly asks for detail.",inputSchema:object({text:string(),success:boolean().default(!0)}),execute:a(async function(e){return Promise.resolve("Task completed")},"execute")}),tools.set("wait",{description:"Wait for x seconds. Can be used to wait until the page or data is fully loaded.",inputSchema:object({seconds:number().min(1).max(10).default(1)}),execute:a(async function(e){const t=await this.pageController.getLastUpdateTime(),o=Math.max(0,e.seconds-(Date.now()-t)/1e3);return console.log(`actualWaitTime: ${o} seconds`),await waitFor$1(o),`✅ Waited for ${e.seconds} seconds.`},"execute")}),tools.set("ask_user",{description:"Ask the user a question and wait for their answer. Use this if you need more information or clarification.",inputSchema:object({question:string()}),execute:a(async function(e){if(!this.onAskUser)throw new Error("ask_user tool requires onAskUser callback to be set");return`User answered: ${await this.onAskUser(e.question)}`},"execute")}),tools.set("click_element_by_index",{description:"Click element by index",inputSchema:object({index:int().min(0)}),execute:a(async function(e){return(await this.pageController.clickElement(e.index)).message},"execute")}),tools.set("input_text",{description:"Click and type text into an interactive input element",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.inputText(e.index,e.text)).message},"execute")}),tools.set("select_dropdown_option",{description:"Select dropdown option for interactive element index by the text of the option you want to select",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.selectOption(e.index,e.text)).message},"execute")}),tools.set("scroll",{description:"Scroll the page vertically. Use index for scroll elements (dropdowns/custom UI).",inputSchema:object({down:boolean().default(!0),num_pages:number().min(0).max(10).optional().default(.1),pixels:number().int().min(0).optional(),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scroll({...e,numPages:e.num_pages})).message},"execute")}),tools.set("scroll_horizontally",{description:"Scroll the page horizontally, or within a specific element by index. Useful for wide tables.",inputSchema:object({right:boolean().default(!0),pixels:number().int().min(0),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scrollHorizontally(e)).message},"execute")}),tools.set("execute_javascript",{description:"Execute JavaScript code on the current page. Supports async/await syntax. Use with caution!",inputSchema:object({script:string()}),execute:a(async function(e){return(await this.pageController.executeJavascript(e.script)).message},"execute")});const ut=class ut extends EventTarget{constructor(o){super();Z(this,R);ne(this,"id",uid());ne(this,"config");ne(this,"tools");ne(this,"pageController");ne(this,"task","");ne(this,"taskId","");ne(this,"history",[]);ne(this,"disposed",!1);ne(this,"onAskUser");Z(this,Ue,"idle");Z(this,Oe);Z(this,ie,new AbortController);Z(this,$e,[]);Z(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});if(this.config={...o,maxSteps:o.maxSteps||40},S(this,Oe,new LLM(this.config)),this.tools=new Map(tools),this.pageController=o.pageController,p(this,Oe).addEventListener("retry",n=>{const{attempt:r,maxAttempts:i}=n.detail;b(this,R,Me).call(this,{type:"retrying",attempt:r,maxAttempts:i}),this.history.push({type:"retry",message:`LLM retry attempt ${r} of ${i}`,attempt:r,maxAttempts:i}),b(this,R,Pe).call(this)}),p(this,Oe).addEventListener("error",n=>{const r=n.detail.error;if(r?.rawError?.name==="AbortError")return;const i=String(r);b(this,R,Me).call(this,{type:"error",message:i}),this.history.push({type:"error",message:i,rawResponse:r.rawResponse}),b(this,R,Pe).call(this)}),this.config.customTools)for(const[n,r]of Object.entries(this.config.customTools)){if(r===null){this.tools.delete(n);continue}this.tools.set(n,r)}this.config.experimentalScriptExecutionTool||this.tools.delete("execute_javascript")}get status(){return p(this,Ue)}pushObservation(o){p(this,$e).push(o)}stop(){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),p(this,ie).abort()}async execute(o){if(this.disposed)throw new Error("PageAgent has been disposed. Create a new instance.");if(!o)throw new Error("Task is required");this.task=o,this.taskId=uid(),this.onAskUser||this.tools.delete("ask_user");const n=this.config.onBeforeStep,r=this.config.onAfterStep,i=this.config.onBeforeTask,s=this.config.onAfterTask;await i?.(this),await this.pageController.showMask(),p(this,ie)&&(p(this,ie).abort(),S(this,ie,new AbortController)),this.history=[],b(this,R,_t).call(this,"running"),b(this,R,Pe).call(this),S(this,$e,[]),S(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});let c=0;for(;;){try{console.group(`step: ${c}`),await n?.(this,c),console.log(chalk.blue.bold("👀 Observing...")),p(this,Q).browserState=await this.pageController.getBrowserState(),await b(this,R,At).call(this,c);const l=[{role:"system",content:b(this,R,It).call(this)},{role:"user",content:await b(this,R,Pt).call(this)}],d={AgentOutput:b(this,R,Tt).call(this)};console.log(chalk.blue.bold("🧠 Thinking...")),b(this,R,Me).call(this,{type:"thinking"});const h=await p(this,Oe).invoke(l,d,p(this,ie).signal,{toolChoiceName:"AgentOutput",normalizeResponse:a(C=>normalizeResponse(C,this.tools),"normalizeResponse")}),f=h.toolResult,g=f.input,m=f.output,T={evaluation_previous_goal:g.evaluation_previous_goal,memory:g.memory,next_goal:g.next_goal},I=Object.keys(g.action)[0],A={name:I,input:g.action[I],output:m};if(this.history.push({type:"step",stepIndex:c,reflection:T,action:A,usage:h.usage,rawResponse:h.rawResponse,rawRequest:h.rawRequest}),b(this,R,Pe).call(this),await r?.(this,this.history),console.groupEnd(),I==="done"){const C=A.input?.success??!1,D=A.input?.text||"no text provided";console.log(chalk.green.bold("Task completed"),C,D),b(this,R,st).call(this,C);const k={success:C,data:D,history:this.history};return await s?.(this,k),k}}catch(l){console.groupEnd();const d=l?.rawError?.name==="AbortError";console.error("Task failed",l);const h=d?"Task stopped":String(l);b(this,R,Me).call(this,{type:"error",message:h}),this.history.push({type:"error",message:h,rawResponse:l}),b(this,R,Pe).call(this),b(this,R,st).call(this,!1);const f={success:!1,data:h,history:this.history};return await s?.(this,f),f}if(c++,c>this.config.maxSteps){const l="Step count exceeded maximum limit";this.history.push({type:"error",message:l}),b(this,R,Pe).call(this),b(this,R,st).call(this,!1);const d={success:!1,data:l,history:this.history};return await s?.(this,d),d}await waitFor$1(.4)}}dispose(){console.log("Disposing PageAgent..."),this.disposed=!0,this.pageController.dispose(),p(this,ie).abort(),this.dispatchEvent(new Event("dispose")),this.config.onDispose?.(this)}};Ue=new WeakMap,Oe=new WeakMap,ie=new WeakMap,$e=new WeakMap,Q=new WeakMap,R=new WeakSet,St=a(function(){this.dispatchEvent(new Event("statuschange"))},"#emitStatusChange"),Pe=a(function(){this.dispatchEvent(new Event("historychange"))},"#emitHistoryChange"),Me=a(function(o){this.dispatchEvent(new CustomEvent("activity",{detail:o}))},"#emitActivity"),_t=a(function(o){p(this,Ue)!==o&&(S(this,Ue,o),b(this,R,St).call(this))},"#setStatus"),Tt=a(function(){const o=this.tools,n=Array.from(o.entries()).map(([s,c])=>object({[s]:c.inputSchema}).describe(c.description)),r=union(n);return{description:"You MUST call this tool every step!",inputSchema:object({evaluation_previous_goal:string().optional(),memory:string().optional(),next_goal:string().optional(),action:r}),execute:a(async s=>{if(p(this,ie).signal.aborted)throw new Error("AbortError");console.log(chalk.blue.bold("MacroTool input"),s);const c=s.action,l=Object.keys(c)[0],d=c[l],h=[];s.evaluation_previous_goal&&h.push(`✅: ${s.evaluation_previous_goal}`),s.memory&&h.push(`💾: ${s.memory}`),s.next_goal&&h.push(`🎯: ${s.next_goal}`);const f=h.length>0?h.join(`
|
|
199
|
+
`):"";f&&console.log(f);const g=o.get(l);assert(g,`Tool ${l} not found`),console.log(chalk.blue.bold(`Executing tool: ${l}`),d),b(this,R,Me).call(this,{type:"executing",tool:l,input:d});const m=Date.now(),T=await g.execute.bind(this)(d),I=Date.now()-m;return console.log(chalk.green.bold(`Tool (${l}) executed for ${I}ms`),T),b(this,R,Me).call(this,{type:"executed",tool:l,input:d,output:T,duration:I}),l==="wait"?p(this,Q).totalWaitTime+=d?.seconds||0:p(this,Q).totalWaitTime=0,{input:s,output:T}},"execute")}},"#packMacroTool"),It=a(function(){if(this.config.customSystemPrompt)return this.config.customSystemPrompt;const o=this.config.language==="zh-CN"?"中文":"English";return SYSTEM_PROMPT.replace(/Default working language: \*\*.*?\*\*/,`Default working language: **${o}**`)},"#getSystemPrompt"),zt=a(async function(){const{instructions:o,experimentalLlmsTxt:n}=this.config,r=o?.system?.trim();let i;const s=p(this,Q).browserState?.url||"";if(o?.getPageInstructions&&s)try{i=o.getPageInstructions(s)?.trim()}catch(d){console.error(chalk.red("[PageAgent] Failed to execute getPageInstructions callback:"),d)}const c=n&&s?await fetchLlmsTxt(s):void 0;if(!r&&!i&&!c)return"";let l=`<instructions>
|
|
200
200
|
`;return r&&(l+=`<system_instructions>
|
|
201
201
|
${r}
|
|
202
202
|
</system_instructions>
|
|
@@ -208,7 +208,7 @@ ${c}
|
|
|
208
208
|
</llms_txt>
|
|
209
209
|
`),l+=`</instructions>
|
|
210
210
|
|
|
211
|
-
`,l},"#getInstructions"),At=a(async function(o){p(this,Q).totalWaitTime>=3&&this.pushObservation(`You have waited ${p(this,Q).totalWaitTime} seconds accumulatively. DO NOT wait any longer unless you have a good reason.`);const n=p(this,Q).browserState?.url||"";n!==p(this,Q).lastURL&&(this.pushObservation(`Page navigated to → ${n}`),p(this,Q).lastURL=n,await waitFor$1(.5));const r=this.config.maxSteps-o;if(r===5?this.pushObservation(`⚠️ Only ${r} steps remaining. Consider wrapping up or calling done with partial results.`):r===2&&this.pushObservation(`⚠️ Critical: Only ${r} steps left! You must finish the task or call done immediately.`),p(this,$e).length>0){for(const i of p(this,$e))this.history.push({type:"observation",content:i}),console.log(chalk.cyan("Observation:"),i);S(this,$e,[]),b(this,
|
|
211
|
+
`,l},"#getInstructions"),At=a(async function(o){p(this,Q).totalWaitTime>=3&&this.pushObservation(`You have waited ${p(this,Q).totalWaitTime} seconds accumulatively. DO NOT wait any longer unless you have a good reason.`);const n=p(this,Q).browserState?.url||"";n!==p(this,Q).lastURL&&(this.pushObservation(`Page navigated to → ${n}`),p(this,Q).lastURL=n,await waitFor$1(.5));const r=this.config.maxSteps-o;if(r===5?this.pushObservation(`⚠️ Only ${r} steps remaining. Consider wrapping up or calling done with partial results.`):r===2&&this.pushObservation(`⚠️ Critical: Only ${r} steps left! You must finish the task or call done immediately.`),p(this,$e).length>0){for(const i of p(this,$e))this.history.push({type:"observation",content:i}),console.log(chalk.cyan("Observation:"),i);S(this,$e,[]),b(this,R,Pe).call(this)}},"#handleObservations"),Pt=a(async function(){const o=p(this,Q).browserState;let n="";n+=await b(this,R,zt).call(this);const r=this.history.filter(c=>c.type==="step").length;n+=`<agent_state>
|
|
212
212
|
`,n+=`<user_request>
|
|
213
213
|
`,n+=`${this.task}
|
|
214
214
|
`,n+=`</user_request>
|
|
@@ -236,7 +236,7 @@ ${c}
|
|
|
236
236
|
|
|
237
237
|
`,n+=`</browser_state>
|
|
238
238
|
|
|
239
|
-
`,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,C,_t).call(this,o?"completed":"error"),p(this,ie).abort()},"#onDone"),a(ut,"PageAgentCore");let PageAgentCore=ut;async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),o=t.left+t.width/2,n=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:o,y:n}})),await waitFor(.3)}a(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const o=e.get(t);if(!o)throw new Error(`No interactive element found at index ${t}`);const n=o.ref;if(!n)throw new Error(`Element at index ${t} does not have a reference`);if(!(n instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return n}a(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}a(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.2)}a(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element is not an input or textarea");await clickElement(e),e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t);const o=new Event("input",{bubbles:!0});e.dispatchEvent(o),await waitFor(.1),blurLastClickedElement()}a(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const n=Array.from(e.options).find(r=>r.textContent?.trim()===t.trim());if(!n)throw new Error(`Option with text "${t}" not found in select element`);e.value=n.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}a(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}a(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowY),A=l.scrollHeight>l.clientHeight;if(I&&A){const R=l.scrollTop,D=l.scrollHeight-l.clientHeight;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollTop=R+k;const O=l.scrollTop-R;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) by ${f}px`:`No scrollable container found for element (${c.tagName})`}const n=t,r=a(c=>c.clientHeight>=window.innerHeight*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,n);const d=window.scrollY,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the bottom of the page.`:g?`✅ Scrolled page by ${h}px. Reached the top of the page.`:`✅ Scrolled page by ${h}px.`}else{const c=s.scrollTop,l=s.scrollHeight-s.clientHeight;s.scrollBy({top:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollTop,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the bottom of container (${s.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${s.tagName}), cannot scroll up further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the bottom.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the top.`:`✅ Scrolled container (${s.tagName}) by ${h}px.`}}a(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowX),A=l.scrollWidth>l.clientWidth;if(I&&A){const R=l.scrollLeft,D=l.scrollWidth-l.clientWidth;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollLeft=R+k;const O=l.scrollLeft-R;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) horizontally by ${f}px`:`No horizontally scrollable container found for element (${c.tagName})`}const n=e?t:-t,r=a(c=>c.clientWidth>=window.innerWidth*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowX)&&c.scrollWidth>c.clientWidth&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(n,0);const d=window.scrollX,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the right edge of the page.`:g?`✅ Scrolled page by ${h}px. Reached the left edge of the page.`:`✅ Scrolled page horizontally by ${h}px.`}else{const c=s.scrollLeft,l=s.scrollWidth-s.clientWidth;s.scrollBy({left:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollLeft,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the right edge of container (${s.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${s.tagName}), cannot scroll left further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the right edge.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the left edge.`:`✅ Scrolled container (${s.tagName}) horizontally by ${h}px.`}}a(scrollHorizontally,"scrollHorizontally");const VIEWPORT_EXPANSION=-1,domTree=a((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:n,highlightLabelOpacity:r}=e,{doHighlightElements:i,focusHighlightIndex:s,viewportExpansion:c,debugMode:l}=e;let d=0;const h=new WeakMap;function f(u,y){!u||u.nodeType!==Node.ELEMENT_NODE||h.set(u,{...h.get(u),...y})}a(f,"addExtraData");const g={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:a(()=>{g.boundingRects=new WeakMap,g.clientRects=new WeakMap,g.computedStyles=new WeakMap},"clearCache")};function m(u){if(!u)return null;if(g.boundingRects.has(u))return g.boundingRects.get(u);const y=u.getBoundingClientRect();return y&&g.boundingRects.set(u,y),y}a(m,"getCachedBoundingRect");function T(u){if(!u)return null;if(g.computedStyles.has(u))return g.computedStyles.get(u);const y=window.getComputedStyle(u);return y&&g.computedStyles.set(u,y),y}a(T,"getCachedComputedStyle");function I(u){if(!u)return null;if(g.clientRects.has(u))return g.clientRects.get(u);const y=u.getClientRects();return y&&g.clientRects.set(u,y),y}a(I,"getCachedClientRects");const A={},R={current:0},D="playwright-highlight-container";function k(u,y,P=null){if(!u)return y;const w=[];let $=null,N=20,E=16,z=null;try{let x=document.getElementById(D);x||(x=document.createElement("div"),x.id=D,x.style.position="fixed",x.style.pointerEvents="none",x.style.top="0",x.style.left="0",x.style.width="100%",x.style.height="100%",x.style.zIndex="2147483640",x.style.backgroundColor="transparent",document.body.appendChild(x));const F=u.getClientRects();if(!F||F.length===0)return y;const X=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],J=y%X.length;let ze=X[J];const te=ze+Math.floor(n*255).toString(16).padStart(2,"0");ze=ze+Math.floor(r*255).toString(16).padStart(2,"0");let se={x:0,y:0};if(P){const G=P.getBoundingClientRect();se.x=G.left,se.y=G.top}const ge=document.createDocumentFragment();for(const G of F){if(G.width===0||G.height===0)continue;const H=document.createElement("div");H.style.position="fixed",H.style.border=`2px solid ${ze}`,H.style.backgroundColor=te,H.style.pointerEvents="none",H.style.boxSizing="border-box";const U=G.top+se.y,ke=G.left+se.x;H.style.top=`${U}px`,H.style.left=`${ke}px`,H.style.width=`${G.width}px`,H.style.height=`${G.height}px`,ge.appendChild(H),w.push({element:H,initialRect:G})}const me=F[0];$=document.createElement("div"),$.className="playwright-highlight-label",$.style.position="fixed",$.style.background=ze,$.style.color="white",$.style.padding="1px 4px",$.style.borderRadius="4px",$.style.fontSize=`${Math.min(12,Math.max(8,me.height/2))}px`,$.textContent=y.toString(),N=$.offsetWidth>0?$.offsetWidth:N,E=$.offsetHeight>0?$.offsetHeight:E;const Le=me.top+se.y,et=me.left+se.x;let nt=Le+2,We=et+me.width-N-2;(me.width<N+4||me.height<E+4)&&(nt=Le-E-2,We=et+me.width-N,We<se.x&&(We=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-E)),We=Math.max(0,Math.min(We,window.innerWidth-N)),$.style.top=`${nt}px`,$.style.left=`${We}px`,ge.appendChild($);const rt=a((G,H)=>{let U=0;return(...ke)=>{const oe=performance.now();if(!(oe-U<H))return U=oe,G(...ke)}},"throttleFunction")(a(()=>{const G=u.getClientRects();let H={x:0,y:0};if(P){const U=P.getBoundingClientRect();H.x=U.left,H.y=U.top}if(w.forEach((U,ke)=>{if(ke<G.length){const oe=G[ke],Ve=oe.top+H.y,Ae=oe.left+H.x;U.element.style.top=`${Ve}px`,U.element.style.left=`${Ae}px`,U.element.style.width=`${oe.width}px`,U.element.style.height=`${oe.height}px`,U.element.style.display=oe.width===0||oe.height===0?"none":"block"}else U.element.style.display="none"}),G.length<w.length)for(let U=G.length;U<w.length;U++)w[U].element.style.display="none";if($&&G.length>0){const U=G[0],ke=U.top+H.y,oe=U.left+H.x;let Ve=ke+2,Ae=oe+U.width-N-2;(U.width<N+4||U.height<E+4)&&(Ve=ke-E-2,Ae=oe+U.width-N,Ae<H.x&&(Ae=oe)),Ve=Math.max(0,Math.min(Ve,window.innerHeight-E)),Ae=Math.max(0,Math.min(Ae,window.innerWidth-N)),$.style.top=`${Ve}px`,$.style.left=`${Ae}px`,$.style.display="block"}else $&&($.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",rt,!0),window.addEventListener("resize",rt),z=a(()=>{window.removeEventListener("scroll",rt,!0),window.removeEventListener("resize",rt),w.forEach(G=>G.element.remove()),$&&$.remove()},"cleanupFn"),x.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(k,"highlightElement");function v(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=T(u);if(!y)return null;const P=y.display;if(P==="inline"||P==="inline-block")return null;const w=y.overflowX,$=y.overflowY,N=w==="auto"||w==="scroll",E=$==="auto"||$==="scroll";if(!N&&!E)return null;const z=u.scrollWidth-u.clientWidth,x=u.scrollHeight-u.clientHeight,F=4;if(z<F&&x<F||!E&&z<F||!N&&x<F)return null;const X=u.scrollTop,J=u.scrollLeft,ze=u.scrollWidth-u.clientWidth-u.scrollLeft,te=u.scrollHeight-u.clientHeight-u.scrollTop,se={top:X,right:ze,bottom:te,left:J};return f(u,{scrollable:!0,scrollData:se}),se}a(v,"isScrollableElement");function O(u){try{if(c===-1){const E=u.parentElement;if(!E)return!1;try{return E.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const x=window.getComputedStyle(E);return x.display!=="none"&&x.visibility!=="hidden"&&x.opacity!=="0"}}const y=document.createRange();y.selectNodeContents(u);const P=y.getClientRects();if(!P||P.length===0)return!1;let w=!1,$=!1;for(const E of P)if(E.width>0&&E.height>0&&(w=!0,!(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))){$=!0;break}if(!w||!$)return!1;const N=u.parentElement;if(!N)return!1;try{return N.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const z=window.getComputedStyle(N);return z.display!=="none"&&z.visibility!=="hidden"&&z.opacity!=="0"}}catch(y){return console.warn("Error checking text node visibility:",y),!1}}a(O,"isTextNodeVisible");function Ie(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),P=u.tagName.toLowerCase();return y.has(P)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(P)}a(Ie,"isElementAccepted");function B(u){const y=T(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(B,"isElementVisible");function q(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),P=T(u),w=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),$=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function N(te){return te.tagName.toLowerCase()==="html"?!1:!!(P?.cursor&&w.has(P.cursor))}if(a(N,"doesElementHaveInteractivePointer"),N(u))return!0;const z=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),x=new Set(["disabled","readonly"]);if(z.has(y)){if(P?.cursor&&$.has(P.cursor))return!1;for(const te of x)if(u.hasAttribute(te)||u.getAttribute(te)==="true"||u.getAttribute(te)==="")return!1;return!(u.disabled||u.readOnly||u.inert)}const F=u.getAttribute("role"),X=u.getAttribute("aria-role");if(u.getAttribute("contenteditable")==="true"||u.isContentEditable||u.classList&&(u.classList.contains("button")||u.classList.contains("dropdown-toggle")||u.getAttribute("data-index")||u.getAttribute("data-toggle")==="dropdown"||u.getAttribute("aria-haspopup")==="true"))return!0;const J=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(z.has(y)||F&&J.has(F)||X&&J.has(X))return!0;try{if(typeof getEventListeners=="function"){const ge=getEventListeners(u),me=["click","mousedown","mouseup","dblclick"];for(const Le of me)if(ge[Le]&&ge[Le].length>0)return!0}const te=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof te=="function"){const ge=te(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Le of me)for(const et of ge)if(et.type===Le)return!0}const se=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of se)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!v(u)}a(q,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=I(u);if(!y||y.length===0)return!1;let P=!1;for(const x of y)if(x.width>0&&x.height>0&&!(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c)){P=!0;break}if(!P)return!1;if(u.ownerDocument!==window.document)return!0;let $=Array.from(y).find(x=>x.width>0&&x.height>0);if(!$)return!1;const N=u.getRootNode();if(N instanceof ShadowRoot){const x=$.left+$.width/2,F=$.top+$.height/2;try{const X=N.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==N;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}}const E=5;return[{x:$.left+$.width/2,y:$.top+$.height/2},{x:$.left+E,y:$.top+E},{x:$.right-E,y:$.bottom-E}].some(({x,y:F})=>{try{const X=document.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==document.documentElement;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}})}a(ue,"isTopElement");function K(u,y){if(y===-1)return!0;const P=u.getClientRects();if(!P||P.length===0){const w=m(u);return!w||w.width===0||w.height===0?!1:!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y)}for(const w of P)if(!(w.width===0||w.height===0)&&!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y))return!0;return!1}a(K,"isInExpandedViewport");function de(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(y)?!0:u.hasAttribute("onclick")||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("aria-")||u.hasAttribute("data-action")||u.getAttribute("contenteditable")==="true"}a(de,"isInteractiveCandidate");const pe=new Set(["a","button","input","select","textarea","summary","details","label","option"]),Ke=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function he(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||!B(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",P=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),w=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),$=[...u.children].some(B),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(q(u)||y||P)&&$&&w&&!N}a(he,"isHeuristicallyInteractive");function Xe(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),P=u.getAttribute("role");if(y==="iframe"||pe.has(y)||P&&Ke.has(P)||u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.hasAttribute("data-testid")||u.hasAttribute("data-cy")||u.hasAttribute("data-test")||u.hasAttribute("onclick")||typeof u.onclick=="function")return!0;try{const w=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof w=="function"){const N=w(u),E=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const z of E)for(const x of N)if(x.type===z)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(N=>u.hasAttribute(N)))return!0}catch{}return!!he(u)}a(Xe,"isElementDistinctInteraction");function Qe(u,y,P,w){if(!u.isInteractive)return!1;let $=!1;return w?Xe(y)?$=!0:$=!1:$=!0,$&&(u.isInViewport=K(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&k(y,u.highlightIndex,P):k(y,u.highlightIndex,P),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,P=!1){if(!u||u.id===D||u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE||!u||u.id===D||u.dataset?.browserUseIgnore==="true"||u.dataset?.pageAgentIgnore==="true"||u.getAttribute&&u.getAttribute("aria-hidden")==="true")return null;if(u===document.body){const E={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const x of u.childNodes){const F=_e(x,y,!1);F&&E.children.push(F)}const z=`${R.current++}`;return A[z]=E,z}if(u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE)return null;if(u.nodeType===Node.TEXT_NODE){const E=u.textContent?.trim();if(!E)return null;const z=u.parentElement;if(!z||z.tagName.toLowerCase()==="script")return null;const x=`${R.current++}`;return A[x]={type:"TEXT_NODE",text:E,isVisible:O(u)},x}if(u.nodeType===Node.ELEMENT_NODE&&!Ie(u))return null;if(c!==-1&&!u.shadowRoot){const E=m(u),z=T(u),x=z&&(z.position==="fixed"||z.position==="sticky"),F=u.offsetWidth>0||u.offsetHeight>0;if(!E||!x&&!F&&(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))return null}const w={tagName:u.tagName.toLowerCase(),attributes:{},children:[]};if(de(u)||u.tagName.toLowerCase()==="iframe"||u.tagName.toLowerCase()==="body"){const E=u.getAttributeNames?.()||[];for(const z of E){const x=u.getAttribute(z);w.attributes[z]=x}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(w.attributes.checked=u.checked?"true":"false")}let $=!1;if(u.nodeType===Node.ELEMENT_NODE&&(w.isVisible=B(u),w.isVisible)){w.isTopElement=ue(u);const E=u.getAttribute("role"),z=E==="menu"||E==="menubar"||E==="listbox";(w.isTopElement||z)&&(w.isInteractive=q(u),$=Qe(w,u,y,P),w.ref=u)}if(u.tagName){const E=u.tagName.toLowerCase();if(E==="iframe")try{const z=u.contentDocument||u.contentWindow?.document;if(z)for(const x of z.childNodes){const F=_e(x,u,!1);F&&w.children.push(F)}}catch(z){console.warn("Unable to access iframe:",z)}else if(u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.id==="tinymce"||u.classList.contains("mce-content-body")||E==="body"&&u.getAttribute("data-id")?.startsWith("mce_"))for(const z of u.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}else{if(u.shadowRoot){w.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}}for(const z of u.childNodes){const F=_e(z,y,$||P);F&&w.children.push(F)}}}if(w.tagName==="a"&&w.children.length===0&&!w.attributes.href){const E=m(u);if(!(E&&E.width>0&&E.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}w.extra=h.get(u)||null;const N=`${R.current++}`;return A[N]=w,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:A}},"domTree"),newElementsCache=new WeakMap;function getFlatTree(e){const t=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?t.push(i()):t.push(i);const o=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?o.push(i()):o.push(i);const n=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:VIEWPORT_EXPANSION,interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),r=window.location.href;for(const i in n.map){const s=n.map[i];if(s.isInteractive&&s.ref){const c=s.ref;newElementsCache.has(c)||(newElementsCache.set(c,r),s.isNew=!0)}}return n}a(getFlatTree,"getFlatTree");function flatTreeToString(e,t){const o=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns"],n=[...t||[],...o],r=a((f,g)=>f.length>g?f.substring(0,g)+"...":f,"capTextLength"),i=a(f=>{const g=e.map[f];if(!g)return null;if(g.type==="TEXT_NODE"){const m=g;return{type:"text",text:m.text,isVisible:m.isVisible,parent:null,children:[]}}else{const m=g,T=[];if(m.children)for(const I of m.children){const A=i(I);A&&(A.parent=null,T.push(A))}return{type:"element",tagName:m.tagName,attributes:m.attributes??{},isVisible:m.isVisible??!1,isInteractive:m.isInteractive??!1,isTopElement:m.isTopElement??!1,isNew:m.isNew??!1,highlightIndex:m.highlightIndex,parent:null,children:T,extra:m.extra??{}}}},"buildTreeNode"),s=a((f,g=null)=>{f.parent=g;for(const m of f.children)s(m,f)},"setParentReferences"),c=i(e.rootId);if(!c)return"";s(c);const l=a(f=>{let g=f.parent;for(;g;){if(g.type==="element"&&g.highlightIndex!==void 0)return!0;g=g.parent}return!1},"hasParentWithHighlightIndex"),d=a((f,g,m)=>{let T=g;const I=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){T+=1;const A=getAllTextTillNextClickableElement(f);let R="";if(n.length>0&&f.attributes){const v={};for(const B of n){const q=f.attributes[B];q&&q.trim()!==""&&(v[B]=q.trim())}const O=n.filter(B=>B in v);if(O.length>1){const B=new Set,q={};for(const ue of O){const K=v[ue];K.length>5&&(K in q?B.add(ue):q[K]=ue)}for(const ue of B)delete v[ue]}v.role===f.tagName&&delete v.role;const Ie=["aria-label","placeholder","title"];for(const B of Ie)v[B]&&v[B].toLowerCase().trim()===A.toLowerCase().trim()&&delete v[B];Object.keys(v).length>0&&(R=Object.entries(v).map(([B,q])=>`${B}=${r(q,20)}`).join(" "))}const D=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let k=`${I}${D}<${f.tagName??""}`;if(R&&(k+=` ${R}`),f.extra&&f.extra.scrollable){let v="";f.extra.scrollData?.left&&(v+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(v+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(v+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(v+=`bottom=${f.extra.scrollData.bottom}`),k+=` data-scrollable="${v}"`}if(A){const v=A.trim();R||(k+=" "),k+=`>${v}`}else R||(k+=" ");k+=" />",m.push(k)}for(const A of f.children)d(A,T,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${I}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
|
|
239
|
+
`,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,R,_t).call(this,o?"completed":"error"),p(this,ie).abort()},"#onDone"),a(ut,"PageAgentCore");let PageAgentCore=ut;async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),o=t.left+t.width/2,n=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:o,y:n}})),await waitFor(.3)}a(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const o=e.get(t);if(!o)throw new Error(`No interactive element found at index ${t}`);const n=o.ref;if(!n)throw new Error(`Element at index ${t} does not have a reference`);if(!(n instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return n}a(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}a(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.2)}a(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element is not an input or textarea");await clickElement(e),e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t);const o=new Event("input",{bubbles:!0});e.dispatchEvent(o),await waitFor(.1),blurLastClickedElement()}a(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const n=Array.from(e.options).find(r=>r.textContent?.trim()===t.trim());if(!n)throw new Error(`Option with text "${t}" not found in select element`);e.value=n.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}a(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}a(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowY),A=l.scrollHeight>l.clientHeight;if(I&&A){const C=l.scrollTop,D=l.scrollHeight-l.clientHeight;let k=m/3;k>0?k=Math.min(k,D-C):k=Math.max(k,-C),l.scrollTop=C+k;const O=l.scrollTop-C;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) by ${f}px`:`No scrollable container found for element (${c.tagName})`}const n=t,r=a(c=>c.clientHeight>=window.innerHeight*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,n);const d=window.scrollY,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the bottom of the page.`:g?`✅ Scrolled page by ${h}px. Reached the top of the page.`:`✅ Scrolled page by ${h}px.`}else{const c=s.scrollTop,l=s.scrollHeight-s.clientHeight;s.scrollBy({top:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollTop,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the bottom of container (${s.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${s.tagName}), cannot scroll up further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the bottom.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the top.`:`✅ Scrolled container (${s.tagName}) by ${h}px.`}}a(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowX),A=l.scrollWidth>l.clientWidth;if(I&&A){const C=l.scrollLeft,D=l.scrollWidth-l.clientWidth;let k=m/3;k>0?k=Math.min(k,D-C):k=Math.max(k,-C),l.scrollLeft=C+k;const O=l.scrollLeft-C;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) horizontally by ${f}px`:`No horizontally scrollable container found for element (${c.tagName})`}const n=e?t:-t,r=a(c=>c.clientWidth>=window.innerWidth*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowX)&&c.scrollWidth>c.clientWidth&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(n,0);const d=window.scrollX,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the right edge of the page.`:g?`✅ Scrolled page by ${h}px. Reached the left edge of the page.`:`✅ Scrolled page horizontally by ${h}px.`}else{const c=s.scrollLeft,l=s.scrollWidth-s.clientWidth;s.scrollBy({left:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollLeft,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the right edge of container (${s.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${s.tagName}), cannot scroll left further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the right edge.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the left edge.`:`✅ Scrolled container (${s.tagName}) horizontally by ${h}px.`}}a(scrollHorizontally,"scrollHorizontally");const VIEWPORT_EXPANSION=-1,domTree=a((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:n,highlightLabelOpacity:r}=e,{doHighlightElements:i,focusHighlightIndex:s,viewportExpansion:c,debugMode:l}=e;let d=0;const h=new WeakMap;function f(u,y){!u||u.nodeType!==Node.ELEMENT_NODE||h.set(u,{...h.get(u),...y})}a(f,"addExtraData");const g={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:a(()=>{g.boundingRects=new WeakMap,g.clientRects=new WeakMap,g.computedStyles=new WeakMap},"clearCache")};function m(u){if(!u)return null;if(g.boundingRects.has(u))return g.boundingRects.get(u);const y=u.getBoundingClientRect();return y&&g.boundingRects.set(u,y),y}a(m,"getCachedBoundingRect");function T(u){if(!u)return null;if(g.computedStyles.has(u))return g.computedStyles.get(u);const y=window.getComputedStyle(u);return y&&g.computedStyles.set(u,y),y}a(T,"getCachedComputedStyle");function I(u){if(!u)return null;if(g.clientRects.has(u))return g.clientRects.get(u);const y=u.getClientRects();return y&&g.clientRects.set(u,y),y}a(I,"getCachedClientRects");const A={},C={current:0},D="playwright-highlight-container";function k(u,y,P=null){if(!u)return y;const w=[];let $=null,N=20,E=16,z=null;try{let x=document.getElementById(D);x||(x=document.createElement("div"),x.id=D,x.style.position="fixed",x.style.pointerEvents="none",x.style.top="0",x.style.left="0",x.style.width="100%",x.style.height="100%",x.style.zIndex="2147483640",x.style.backgroundColor="transparent",document.body.appendChild(x));const F=u.getClientRects();if(!F||F.length===0)return y;const X=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],J=y%X.length;let ze=X[J];const te=ze+Math.floor(n*255).toString(16).padStart(2,"0");ze=ze+Math.floor(r*255).toString(16).padStart(2,"0");let se={x:0,y:0};if(P){const G=P.getBoundingClientRect();se.x=G.left,se.y=G.top}const ge=document.createDocumentFragment();for(const G of F){if(G.width===0||G.height===0)continue;const H=document.createElement("div");H.style.position="fixed",H.style.border=`2px solid ${ze}`,H.style.backgroundColor=te,H.style.pointerEvents="none",H.style.boxSizing="border-box";const U=G.top+se.y,ke=G.left+se.x;H.style.top=`${U}px`,H.style.left=`${ke}px`,H.style.width=`${G.width}px`,H.style.height=`${G.height}px`,ge.appendChild(H),w.push({element:H,initialRect:G})}const me=F[0];$=document.createElement("div"),$.className="playwright-highlight-label",$.style.position="fixed",$.style.background=ze,$.style.color="white",$.style.padding="1px 4px",$.style.borderRadius="4px",$.style.fontSize=`${Math.min(12,Math.max(8,me.height/2))}px`,$.textContent=y.toString(),N=$.offsetWidth>0?$.offsetWidth:N,E=$.offsetHeight>0?$.offsetHeight:E;const Le=me.top+se.y,et=me.left+se.x;let nt=Le+2,We=et+me.width-N-2;(me.width<N+4||me.height<E+4)&&(nt=Le-E-2,We=et+me.width-N,We<se.x&&(We=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-E)),We=Math.max(0,Math.min(We,window.innerWidth-N)),$.style.top=`${nt}px`,$.style.left=`${We}px`,ge.appendChild($);const rt=a((G,H)=>{let U=0;return(...ke)=>{const oe=performance.now();if(!(oe-U<H))return U=oe,G(...ke)}},"throttleFunction")(a(()=>{const G=u.getClientRects();let H={x:0,y:0};if(P){const U=P.getBoundingClientRect();H.x=U.left,H.y=U.top}if(w.forEach((U,ke)=>{if(ke<G.length){const oe=G[ke],Ve=oe.top+H.y,Ae=oe.left+H.x;U.element.style.top=`${Ve}px`,U.element.style.left=`${Ae}px`,U.element.style.width=`${oe.width}px`,U.element.style.height=`${oe.height}px`,U.element.style.display=oe.width===0||oe.height===0?"none":"block"}else U.element.style.display="none"}),G.length<w.length)for(let U=G.length;U<w.length;U++)w[U].element.style.display="none";if($&&G.length>0){const U=G[0],ke=U.top+H.y,oe=U.left+H.x;let Ve=ke+2,Ae=oe+U.width-N-2;(U.width<N+4||U.height<E+4)&&(Ve=ke-E-2,Ae=oe+U.width-N,Ae<H.x&&(Ae=oe)),Ve=Math.max(0,Math.min(Ve,window.innerHeight-E)),Ae=Math.max(0,Math.min(Ae,window.innerWidth-N)),$.style.top=`${Ve}px`,$.style.left=`${Ae}px`,$.style.display="block"}else $&&($.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",rt,!0),window.addEventListener("resize",rt),z=a(()=>{window.removeEventListener("scroll",rt,!0),window.removeEventListener("resize",rt),w.forEach(G=>G.element.remove()),$&&$.remove()},"cleanupFn"),x.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(k,"highlightElement");function v(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=T(u);if(!y)return null;const P=y.display;if(P==="inline"||P==="inline-block")return null;const w=y.overflowX,$=y.overflowY,N=w==="auto"||w==="scroll",E=$==="auto"||$==="scroll";if(!N&&!E)return null;const z=u.scrollWidth-u.clientWidth,x=u.scrollHeight-u.clientHeight,F=4;if(z<F&&x<F||!E&&z<F||!N&&x<F)return null;const X=u.scrollTop,J=u.scrollLeft,ze=u.scrollWidth-u.clientWidth-u.scrollLeft,te=u.scrollHeight-u.clientHeight-u.scrollTop,se={top:X,right:ze,bottom:te,left:J};return f(u,{scrollable:!0,scrollData:se}),se}a(v,"isScrollableElement");function O(u){try{if(c===-1){const E=u.parentElement;if(!E)return!1;try{return E.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const x=window.getComputedStyle(E);return x.display!=="none"&&x.visibility!=="hidden"&&x.opacity!=="0"}}const y=document.createRange();y.selectNodeContents(u);const P=y.getClientRects();if(!P||P.length===0)return!1;let w=!1,$=!1;for(const E of P)if(E.width>0&&E.height>0&&(w=!0,!(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))){$=!0;break}if(!w||!$)return!1;const N=u.parentElement;if(!N)return!1;try{return N.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const z=window.getComputedStyle(N);return z.display!=="none"&&z.visibility!=="hidden"&&z.opacity!=="0"}}catch(y){return console.warn("Error checking text node visibility:",y),!1}}a(O,"isTextNodeVisible");function Ie(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),P=u.tagName.toLowerCase();return y.has(P)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(P)}a(Ie,"isElementAccepted");function B(u){const y=T(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(B,"isElementVisible");function q(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),P=T(u),w=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),$=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function N(te){return te.tagName.toLowerCase()==="html"?!1:!!(P?.cursor&&w.has(P.cursor))}if(a(N,"doesElementHaveInteractivePointer"),N(u))return!0;const z=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),x=new Set(["disabled","readonly"]);if(z.has(y)){if(P?.cursor&&$.has(P.cursor))return!1;for(const te of x)if(u.hasAttribute(te)||u.getAttribute(te)==="true"||u.getAttribute(te)==="")return!1;return!(u.disabled||u.readOnly||u.inert)}const F=u.getAttribute("role"),X=u.getAttribute("aria-role");if(u.getAttribute("contenteditable")==="true"||u.isContentEditable||u.classList&&(u.classList.contains("button")||u.classList.contains("dropdown-toggle")||u.getAttribute("data-index")||u.getAttribute("data-toggle")==="dropdown"||u.getAttribute("aria-haspopup")==="true"))return!0;const J=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(z.has(y)||F&&J.has(F)||X&&J.has(X))return!0;try{if(typeof getEventListeners=="function"){const ge=getEventListeners(u),me=["click","mousedown","mouseup","dblclick"];for(const Le of me)if(ge[Le]&&ge[Le].length>0)return!0}const te=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof te=="function"){const ge=te(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Le of me)for(const et of ge)if(et.type===Le)return!0}const se=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of se)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!v(u)}a(q,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=I(u);if(!y||y.length===0)return!1;let P=!1;for(const x of y)if(x.width>0&&x.height>0&&!(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c)){P=!0;break}if(!P)return!1;if(u.ownerDocument!==window.document)return!0;let $=Array.from(y).find(x=>x.width>0&&x.height>0);if(!$)return!1;const N=u.getRootNode();if(N instanceof ShadowRoot){const x=$.left+$.width/2,F=$.top+$.height/2;try{const X=N.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==N;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}}const E=5;return[{x:$.left+$.width/2,y:$.top+$.height/2},{x:$.left+E,y:$.top+E},{x:$.right-E,y:$.bottom-E}].some(({x,y:F})=>{try{const X=document.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==document.documentElement;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}})}a(ue,"isTopElement");function K(u,y){if(y===-1)return!0;const P=u.getClientRects();if(!P||P.length===0){const w=m(u);return!w||w.width===0||w.height===0?!1:!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y)}for(const w of P)if(!(w.width===0||w.height===0)&&!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y))return!0;return!1}a(K,"isInExpandedViewport");function de(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(y)?!0:u.hasAttribute("onclick")||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("aria-")||u.hasAttribute("data-action")||u.getAttribute("contenteditable")==="true"}a(de,"isInteractiveCandidate");const pe=new Set(["a","button","input","select","textarea","summary","details","label","option"]),Ke=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function he(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||!B(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",P=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),w=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),$=[...u.children].some(B),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(q(u)||y||P)&&$&&w&&!N}a(he,"isHeuristicallyInteractive");function Xe(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),P=u.getAttribute("role");if(y==="iframe"||pe.has(y)||P&&Ke.has(P)||u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.hasAttribute("data-testid")||u.hasAttribute("data-cy")||u.hasAttribute("data-test")||u.hasAttribute("onclick")||typeof u.onclick=="function")return!0;try{const w=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof w=="function"){const N=w(u),E=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const z of E)for(const x of N)if(x.type===z)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(N=>u.hasAttribute(N)))return!0}catch{}return!!he(u)}a(Xe,"isElementDistinctInteraction");function Qe(u,y,P,w){if(!u.isInteractive)return!1;let $=!1;return w?Xe(y)?$=!0:$=!1:$=!0,$&&(u.isInViewport=K(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&k(y,u.highlightIndex,P):k(y,u.highlightIndex,P),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,P=!1){if(!u||u.id===D||u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE||!u||u.id===D||u.dataset?.browserUseIgnore==="true"||u.dataset?.pageAgentIgnore==="true"||u.getAttribute&&u.getAttribute("aria-hidden")==="true")return null;if(u===document.body){const E={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const x of u.childNodes){const F=_e(x,y,!1);F&&E.children.push(F)}const z=`${C.current++}`;return A[z]=E,z}if(u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE)return null;if(u.nodeType===Node.TEXT_NODE){const E=u.textContent?.trim();if(!E)return null;const z=u.parentElement;if(!z||z.tagName.toLowerCase()==="script")return null;const x=`${C.current++}`;return A[x]={type:"TEXT_NODE",text:E,isVisible:O(u)},x}if(u.nodeType===Node.ELEMENT_NODE&&!Ie(u))return null;if(c!==-1&&!u.shadowRoot){const E=m(u),z=T(u),x=z&&(z.position==="fixed"||z.position==="sticky"),F=u.offsetWidth>0||u.offsetHeight>0;if(!E||!x&&!F&&(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))return null}const w={tagName:u.tagName.toLowerCase(),attributes:{},children:[]};if(de(u)||u.tagName.toLowerCase()==="iframe"||u.tagName.toLowerCase()==="body"){const E=u.getAttributeNames?.()||[];for(const z of E){const x=u.getAttribute(z);w.attributes[z]=x}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(w.attributes.checked=u.checked?"true":"false")}let $=!1;if(u.nodeType===Node.ELEMENT_NODE&&(w.isVisible=B(u),w.isVisible)){w.isTopElement=ue(u);const E=u.getAttribute("role"),z=E==="menu"||E==="menubar"||E==="listbox";(w.isTopElement||z)&&(w.isInteractive=q(u),$=Qe(w,u,y,P),w.ref=u)}if(u.tagName){const E=u.tagName.toLowerCase();if(E==="iframe")try{const z=u.contentDocument||u.contentWindow?.document;if(z)for(const x of z.childNodes){const F=_e(x,u,!1);F&&w.children.push(F)}}catch(z){console.warn("Unable to access iframe:",z)}else if(u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.id==="tinymce"||u.classList.contains("mce-content-body")||E==="body"&&u.getAttribute("data-id")?.startsWith("mce_"))for(const z of u.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}else{if(u.shadowRoot){w.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}}for(const z of u.childNodes){const F=_e(z,y,$||P);F&&w.children.push(F)}}}if(w.tagName==="a"&&w.children.length===0&&!w.attributes.href){const E=m(u);if(!(E&&E.width>0&&E.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}w.extra=h.get(u)||null;const N=`${C.current++}`;return A[N]=w,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:A}},"domTree"),newElementsCache=new WeakMap;function getFlatTree(e){const t=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?t.push(i()):t.push(i);const o=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?o.push(i()):o.push(i);const n=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:VIEWPORT_EXPANSION,interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),r=window.location.href;for(const i in n.map){const s=n.map[i];if(s.isInteractive&&s.ref){const c=s.ref;newElementsCache.has(c)||(newElementsCache.set(c,r),s.isNew=!0)}}return n}a(getFlatTree,"getFlatTree");function flatTreeToString(e,t){const o=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns"],n=[...t||[],...o],r=a((f,g)=>f.length>g?f.substring(0,g)+"...":f,"capTextLength"),i=a(f=>{const g=e.map[f];if(!g)return null;if(g.type==="TEXT_NODE"){const m=g;return{type:"text",text:m.text,isVisible:m.isVisible,parent:null,children:[]}}else{const m=g,T=[];if(m.children)for(const I of m.children){const A=i(I);A&&(A.parent=null,T.push(A))}return{type:"element",tagName:m.tagName,attributes:m.attributes??{},isVisible:m.isVisible??!1,isInteractive:m.isInteractive??!1,isTopElement:m.isTopElement??!1,isNew:m.isNew??!1,highlightIndex:m.highlightIndex,parent:null,children:T,extra:m.extra??{}}}},"buildTreeNode"),s=a((f,g=null)=>{f.parent=g;for(const m of f.children)s(m,f)},"setParentReferences"),c=i(e.rootId);if(!c)return"";s(c);const l=a(f=>{let g=f.parent;for(;g;){if(g.type==="element"&&g.highlightIndex!==void 0)return!0;g=g.parent}return!1},"hasParentWithHighlightIndex"),d=a((f,g,m)=>{let T=g;const I=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){T+=1;const A=getAllTextTillNextClickableElement(f);let C="";if(n.length>0&&f.attributes){const v={};for(const B of n){const q=f.attributes[B];q&&q.trim()!==""&&(v[B]=q.trim())}const O=n.filter(B=>B in v);if(O.length>1){const B=new Set,q={};for(const ue of O){const K=v[ue];K.length>5&&(K in q?B.add(ue):q[K]=ue)}for(const ue of B)delete v[ue]}v.role===f.tagName&&delete v.role;const Ie=["aria-label","placeholder","title"];for(const B of Ie)v[B]&&v[B].toLowerCase().trim()===A.toLowerCase().trim()&&delete v[B];Object.keys(v).length>0&&(C=Object.entries(v).map(([B,q])=>`${B}=${r(q,20)}`).join(" "))}const D=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let k=`${I}${D}<${f.tagName??""}`;if(C&&(k+=` ${C}`),f.extra&&f.extra.scrollable){let v="";f.extra.scrollData?.left&&(v+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(v+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(v+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(v+=`bottom=${f.extra.scrollData.bottom}`),k+=` data-scrollable="${v}"`}if(A){const v=A.trim();C||(k+=" "),k+=`>${v}`}else C||(k+=" ");k+=" />",m.push(k)}for(const A of f.children)d(A,T,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${I}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
|
|
240
240
|
`)}a(flatTreeToString,"flatTreeToString");const getAllTextTillNextClickableElement=a((e,t=-1)=>{const o=[],n=a((r,i)=>{if(!(t!==-1&&i>t)&&!(r.type==="element"&&r!==e&&r.highlightIndex!==void 0)){if(r.type==="text"&&r.text)o.push(r.text);else if(r.type==="element")for(const s of r.children)n(s,i+1)}},"collectText");return n(e,0),o.join(`
|
|
241
241
|
`).trim()},"getAllTextTillNextClickableElement");function getSelectorMap(e){const t=new Map,o=Object.keys(e.map);for(const n of o){const r=e.map[n];r.isInteractive&&typeof r.highlightIndex=="number"&&t.set(r.highlightIndex,r)}return t}a(getSelectorMap,"getSelectorMap");function getElementTextMap(e){const t=e.split(`
|
|
242
242
|
`).map(n=>n.trim()).filter(n=>n.length>0),o=new Map;for(const n of t){const i=/^\[(\d+)\]<[^>]+>([^<]*)/.exec(n);if(i){const s=parseInt(i[1],10);o.set(s,n)}}return o}a(getElementTextMap,"getElementTextMap");function cleanUpHighlights(){const e=window._highlightCleanupFunctions||[];for(const t of e)typeof t=="function"&&t();window._highlightCleanupFunctions=[]}a(cleanUpHighlights,"cleanUpHighlights"),window.addEventListener("popstate",()=>{cleanUpHighlights()}),window.addEventListener("hashchange",()=>{cleanUpHighlights()}),window.addEventListener("beforeunload",()=>{cleanUpHighlights()});const navigation=window.navigation;if(navigation&&typeof navigation.addEventListener=="function")navigation.addEventListener("navigate",()=>{cleanUpHighlights()});else{let e=window.location.href;setInterval(()=>{window.location.href!==e&&(e=window.location.href,cleanUpHighlights())},500)}function getPageInfo(){const e=window.innerWidth,t=window.innerHeight,o=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth||0),n=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight||0),r=window.scrollX||window.pageXOffset||document.documentElement.scrollLeft||0,i=window.scrollY||window.pageYOffset||document.documentElement.scrollTop||0,s=Math.max(0,n-(window.innerHeight+i)),c=Math.max(0,o-(window.innerWidth+r));return{viewport_width:e,viewport_height:t,page_width:o,page_height:n,scroll_x:r,scroll_y:i,pixels_above:i,pixels_below:s,pages_above:t>0?i/t:0,pages_below:t>0?s/t:0,total_pages:t>0?n/t:0,current_page_position:i/Math.max(1,n-t),pixels_left:r,pixels_right:c}}a(getPageInfo,"getPageInfo");function patchReact(e){const t=document.querySelectorAll('[data-reactroot], [data-reactid], [data-react-checksum], #root, #app, [id^="root-"], [id^="app-"], #adex-wrapper, #adex-root');for(const o of t)o.setAttribute("data-page-agent-not-interactive","true")}a(patchReact,"patchReact");const _PageController=class _PageController extends EventTarget{config;flatTree=null;selectorMap=new Map;elementTextMap=new Map;simplifiedHTML="<EMPTY>";lastTimeUpdate=0;isIndexed=!1;mask=null;maskReady=null;constructor(e={}){super(),this.config=e,patchReact(),e.enableMask&&this.initMask()}initMask(){this.maskReady===null&&(this.maskReady=(async()=>{const{SimulatorMask:e}=await Promise.resolve().then(()=>SimulatorMask$1);this.mask=new e})())}async getCurrentUrl(){return window.location.href}async getLastUpdateTime(){return this.lastTimeUpdate}async getBrowserState(){const e=window.location.href,t=document.title,o=getPageInfo(),n=this.config.viewportExpansion??VIEWPORT_EXPANSION;await this.updateTree();const r=this.simplifiedHTML,i=`Current Page: [${t}](${e})`,s=`Page info: ${o.viewport_width}x${o.viewport_height}px viewport, ${o.page_width}x${o.page_height}px total page size, ${o.pages_above.toFixed(1)} pages above, ${o.pages_below.toFixed(1)} pages below, ${o.total_pages.toFixed(1)} total pages, at ${(o.current_page_position*100).toFixed(0)}% of page`,c=n===-1?"Interactive elements from top layer of the current page (full page):":"Interactive elements from top layer of the current page inside the viewport:",d=o.pixels_above>4&&n!==-1?`... ${o.pixels_above} pixels above (${o.pages_above.toFixed(1)} pages) - scroll to see more ...`:"[Start of page]",h=`${i}
|
|
@@ -252,7 +252,7 @@ ${d}`,g=o.pixels_below>4&&n!==-1?`... ${o.pixels_below} pixels below (${o.pages_
|
|
|
252
252
|
</div>
|
|
253
253
|
${o?`<div class="${styles$1.historyMeta}">${o}</div>`:""}
|
|
254
254
|
</div>
|
|
255
|
-
`}a(createCard,"createCard");function createReflectionLines(e){const t=[];return e.evaluation_previous_goal&&t.push(`<div>🔍 ${escapeHtml(e.evaluation_previous_goal)}</div>`),e.memory&&t.push(`<div>💾 ${escapeHtml(e.memory)}</div>`),e.next_goal&&t.push(`<div>🎯 ${escapeHtml(e.next_goal)}</div>`),t}a(createReflectionLines,"createReflectionLines");const pt=class pt{constructor(t,o={}){Z(this,_);Z(this,re);Z(this,je);Z(this,ae);Z(this,ye);Z(this,
|
|
255
|
+
`}a(createCard,"createCard");function createReflectionLines(e){const t=[];return e.evaluation_previous_goal&&t.push(`<div>🔍 ${escapeHtml(e.evaluation_previous_goal)}</div>`),e.memory&&t.push(`<div>💾 ${escapeHtml(e.memory)}</div>`),e.next_goal&&t.push(`<div>🎯 ${escapeHtml(e.next_goal)}</div>`),t}a(createReflectionLines,"createReflectionLines");const pt=class pt{constructor(t,o={}){Z(this,_);Z(this,re);Z(this,je);Z(this,ae);Z(this,ye);Z(this,Ce);Z(this,be);Z(this,Re);Z(this,we);Z(this,W);Z(this,Ge);Z(this,Ee,!1);Z(this,j);Z(this,xe,null);Z(this,ve,!1);Z(this,Ze,null);Z(this,ee,null);Z(this,Be,!1);Z(this,He,a(()=>b(this,_,Ot).call(this),"#onStatusChange"));Z(this,Je,a(()=>b(this,_,Ct).call(this),"#onHistoryChange"));Z(this,Ye,a(t=>b(this,_,Rt).call(this,t.detail),"#onActivity"));Z(this,qe,a(()=>this.dispose(),"#onAgentDispose"));S(this,W,t),S(this,Ge,o),S(this,j,new I18n(o.language??"en-US")),p(this,W).onAskUser=n=>b(this,_,Zt).call(this,n),S(this,re,b(this,_,Dt).call(this)),S(this,je,p(this,re).querySelector(`.${styles$1.indicator}`)),S(this,ae,p(this,re).querySelector(`.${styles$1.statusText}`)),S(this,ye,p(this,re).querySelector(`.${styles$1.historySection}`)),S(this,Ce,p(this,re).querySelector(`.${styles$1.expandButton}`)),S(this,be,p(this,re).querySelector(`.${styles$1.stopButton}`)),S(this,Re,p(this,re).querySelector(`.${styles$1.inputSectionWrapper}`)),S(this,we,p(this,re).querySelector(`.${styles$1.taskInput}`)),p(this,W).addEventListener("statuschange",p(this,He)),p(this,W).addEventListener("historychange",p(this,Je)),p(this,W).addEventListener("activity",p(this,Ye)),p(this,W).addEventListener("dispose",p(this,qe)),b(this,_,Ut).call(this),b(this,_,jt).call(this),b(this,_,tt).call(this),this.hide()}get wrapper(){return p(this,re)}show(){this.wrapper.style.display="block",this.wrapper.offsetHeight,this.wrapper.style.opacity="1",this.wrapper.style.transform="translateX(-50%) translateY(0)"}hide(){this.wrapper.style.opacity="0",this.wrapper.style.transform="translateX(-50%) translateY(20px)",this.wrapper.style.display="none"}reset(){p(this,ae).textContent=p(this,j).t("ui.panel.ready"),b(this,_,Fe).call(this,"thinking"),b(this,_,kt).call(this),b(this,_,it).call(this),S(this,ve,!1),S(this,xe,null),b(this,_,tt).call(this)}expand(){b(this,_,ot).call(this)}collapse(){b(this,_,it).call(this)}dispose(){p(this,W).removeEventListener("statuschange",p(this,He)),p(this,W).removeEventListener("historychange",p(this,Je)),p(this,W).removeEventListener("activity",p(this,Ye)),p(this,W).removeEventListener("dispose",p(this,qe)),S(this,ve,!1),b(this,_,Bt).call(this),this.wrapper.remove()}};re=new WeakMap,je=new WeakMap,ae=new WeakMap,ye=new WeakMap,Ce=new WeakMap,be=new WeakMap,Re=new WeakMap,we=new WeakMap,W=new WeakMap,Ge=new WeakMap,Ee=new WeakMap,j=new WeakMap,xe=new WeakMap,ve=new WeakMap,Ze=new WeakMap,ee=new WeakMap,Be=new WeakMap,He=new WeakMap,Je=new WeakMap,Ye=new WeakMap,qe=new WeakMap,_=new WeakSet,Ot=a(function(){const t=p(this,W).status,o=t==="running"||t==="idle"?"thinking":t;b(this,_,Fe).call(this,o),t==="running"?(p(this,be).textContent="■",p(this,be).title=p(this,j).t("ui.panel.stop")):(p(this,be).textContent="X",p(this,be).title=p(this,j).t("ui.panel.close")),t==="running"&&(this.show(),b(this,_,bt).call(this)),(t==="completed"||t==="error")&&(p(this,Ee)||b(this,_,ot).call(this),b(this,_,Ft).call(this)&&b(this,_,tt).call(this))},"#handleStatusChange"),Ct=a(function(){b(this,_,kt).call(this)},"#handleHistoryChange"),Rt=a(function(t){switch(t.type){case"thinking":S(this,ee,p(this,j).t("ui.panel.thinking")),b(this,_,Fe).call(this,"thinking");break;case"executing":S(this,ee,b(this,_,yt).call(this,t.tool,t.input)),b(this,_,Fe).call(this,"executing");break;case"executed":S(this,ee,truncate(t.output,50));break;case"retrying":S(this,ee,`Retrying (${t.attempt}/${t.maxAttempts})`),b(this,_,Fe).call(this,"retrying");break;case"error":S(this,ee,truncate(t.message,50)),b(this,_,Fe).call(this,"error");break}},"#handleActivity"),Zt=a(function(t){return new Promise(o=>{S(this,ve,!0),S(this,xe,o),p(this,Ee)||b(this,_,ot).call(this);const n=document.createElement("div");n.innerHTML=createCard({icon:"❓",content:`Question: ${t}`,type:"question"});const r=n.firstElementChild;r.setAttribute("data-temp-card","true"),p(this,ye).appendChild(r),b(this,_,vt).call(this),b(this,_,tt).call(this,p(this,j).t("ui.panel.userAnswerPrompt"))})},"#askUser"),yt=a(function(t,o){const n=o;switch(t){case"click_element_by_index":return p(this,j).t("ui.tools.clicking",{index:n.index});case"input_text":return p(this,j).t("ui.tools.inputting",{index:n.index});case"select_dropdown_option":return p(this,j).t("ui.tools.selecting",{text:n.text});case"scroll":return p(this,j).t("ui.tools.scrolling");case"wait":return p(this,j).t("ui.tools.waiting",{seconds:n.seconds});case"ask_user":return p(this,j).t("ui.tools.askingUser");case"done":return p(this,j).t("ui.tools.done");default:return p(this,j).t("ui.tools.executing",{toolName:t})}},"#getToolExecutingText"),Nt=a(function(){p(this,W).status==="running"?p(this,W).stop():p(this,W).dispose()},"#handleActionButton"),Lt=a(function(){const t=p(this,we).value.trim();t&&(b(this,_,bt).call(this),p(this,ve)?b(this,_,Mt).call(this,t):p(this,W).execute(t))},"#submitTask"),Mt=a(function(t){Array.from(p(this,ye).children).forEach(o=>{o.getAttribute("data-temp-card")==="true"&&o.remove()}),S(this,ve,!1),p(this,xe)&&(p(this,xe).call(this,t),S(this,xe,null))},"#handleUserAnswer"),tt=a(function(t){p(this,we).value="",p(this,we).placeholder=t||p(this,j).t("ui.panel.taskInput"),p(this,Re).classList.remove(styles$1.hidden),setTimeout(()=>{p(this,we).focus()},100)},"#showInputArea"),bt=a(function(){p(this,Re).classList.add(styles$1.hidden)},"#hideInputArea"),Ft=a(function(){if(p(this,ve)||p(this,W).history.length===0)return!0;const o=p(this,W).status;return o==="completed"||o==="error"?p(this,Ge).promptForNextTask??!0:!1},"#shouldShowInputArea"),Dt=a(function(){const t=document.createElement("div");return t.id="page-agent-runtime_agent-panel",t.className=styles$1.wrapper,t.setAttribute("data-browser-use-ignore","true"),t.setAttribute("data-page-agent-ignore","true"),t.innerHTML=`
|
|
256
256
|
<div class="${styles$1.background}"></div>
|
|
257
257
|
<div class="${styles$1.historySectionWrapper}">
|
|
258
258
|
<div class="${styles$1.historySection}">
|
|
@@ -287,7 +287,7 @@ ${d}`,g=o.pixels_below>4&&n!==-1?`... ${o.pixels_below} pixels below (${o.pages_
|
|
|
287
287
|
/>
|
|
288
288
|
</div>
|
|
289
289
|
</div>
|
|
290
|
-
`,document.body.appendChild(t),t},"#createWrapper"),Ut=a(function(){this.wrapper.querySelector(`.${styles$1.header}`).addEventListener("click",o=>{o.target.closest(`.${styles$1.controlButton}`)||b(this,_,wt).call(this)}),p(this,
|
|
290
|
+
`,document.body.appendChild(t),t},"#createWrapper"),Ut=a(function(){this.wrapper.querySelector(`.${styles$1.header}`).addEventListener("click",o=>{o.target.closest(`.${styles$1.controlButton}`)||b(this,_,wt).call(this)}),p(this,Ce).addEventListener("click",o=>{o.stopPropagation(),b(this,_,wt).call(this)}),p(this,be).addEventListener("click",o=>{o.stopPropagation(),b(this,_,Nt).call(this)}),p(this,we).addEventListener("keydown",o=>{o.isComposing||o.key==="Enter"&&(o.preventDefault(),b(this,_,Lt).call(this))}),p(this,Re).addEventListener("click",o=>{o.stopPropagation()})},"#setupEventListeners"),wt=a(function(){p(this,Ee)?b(this,_,it).call(this):b(this,_,ot).call(this)},"#toggle"),ot=a(function(){S(this,Ee,!0),this.wrapper.classList.add(styles$1.expanded),p(this,Ce).textContent="▲"},"#expand"),it=a(function(){S(this,Ee,!1),this.wrapper.classList.remove(styles$1.expanded),p(this,Ce).textContent="▼"},"#collapse"),jt=a(function(){S(this,Ze,setInterval(()=>{b(this,_,Wt).call(this)},450))},"#startHeaderUpdateLoop"),Bt=a(function(){p(this,Ze)&&(clearInterval(p(this,Ze)),S(this,Ze,null))},"#stopHeaderUpdateLoop"),Wt=a(function(){if(!p(this,ee)||p(this,Be))return;if(p(this,ae).textContent===p(this,ee)){S(this,ee,null);return}const t=p(this,ee);S(this,ee,null),b(this,_,Vt).call(this,t)},"#checkAndUpdateHeader"),Vt=a(function(t){S(this,Be,!0),p(this,ae).classList.add(styles$1.fadeOut),setTimeout(()=>{p(this,ae).textContent=t,p(this,ae).classList.remove(styles$1.fadeOut),p(this,ae).classList.add(styles$1.fadeIn),setTimeout(()=>{p(this,ae).classList.remove(styles$1.fadeIn),S(this,Be,!1)},300)},150)},"#animateTextChange"),Fe=a(function(t){p(this,je).className=styles$1.indicator,p(this,je).classList.add(styles$1[t])},"#updateStatusIndicator"),vt=a(function(){setTimeout(()=>{p(this,ye).scrollTop=p(this,ye).scrollHeight},0)},"#scrollToBottom"),kt=a(function(){const t=[],o=p(this,W).task;o&&t.push(b(this,_,Gt).call(this,o));const n=p(this,W).history;for(const r of n)t.push(...b(this,_,Ht).call(this,r));p(this,ye).innerHTML=t.join(""),b(this,_,vt).call(this)},"#renderHistory"),Gt=a(function(t){return createCard({icon:"🎯",content:t,type:"input"})},"#createTaskCard"),Ht=a(function(t){const o=[],n=t.type==="step"&&t.stepIndex!==void 0?p(this,j).t("ui.panel.step",{number:(t.stepIndex+1).toString()}):void 0;if(t.type==="step"){if(t.reflection){const i=createReflectionLines(t.reflection);i.length>0&&o.push(createCard({icon:"🧠",content:i,meta:n}))}const r=t.action;r&&o.push(...b(this,_,Jt).call(this,r,n))}else if(t.type==="observation")o.push(createCard({icon:"👁️",content:t.content||"",meta:n,type:"observation"}));else if(t.type==="user_takeover")o.push(createCard({icon:"👤",content:"User takeover",meta:n,type:"input"}));else if(t.type==="retry"){const r=`${t.message||"Retrying"} (${t.attempt}/${t.maxAttempts})`;o.push(createCard({icon:"🔄",content:r,meta:n,type:"observation"}))}else t.type==="error"&&o.push(createCard({icon:"❌",content:t.message||"Error",meta:n,type:"observation"}));return o},"#createHistoryCards"),Jt=a(function(t,o){const n=[];if(t.name==="done"){const i=t.input.text||t.output||"";i&&n.push(createCard({icon:"🤖",content:i,meta:o,type:"output"}))}else if(t.name==="ask_user"){const r=t.input,i=t.output.replace(/^User answered:\s*/i,"");n.push(createCard({icon:"❓",content:`Question: ${r.question||""}`,meta:o,type:"question"})),n.push(createCard({icon:"💬",content:`Answer: ${i}`,meta:o,type:"input"}))}else{const r=b(this,_,yt).call(this,t.name,t.input);n.push(createCard({icon:"🔨",content:r,meta:o})),t.output?.length>0&&n.push(createCard({icon:"🔨",content:t.output,meta:o,type:"output"}))}return n},"#createActionCards"),a(pt,"Panel");let Panel=pt;const ht=class ht extends PageAgentCore{panel;constructor(t){const o=new PageController({...t,enableMask:t.enableMask??!0});super({...t,pageController:o}),this.panel=new Panel(this,{language:t.language})}};a(ht,"PageAgent");let PageAgent=ht;window.pageAgent&&window.pageAgent.dispose(),window.PageAgent=PageAgent,console.log("🚀 page-agent.js loaded!");const DEMO_MODEL="qwen3.5-plus",DEMO_BASE_URL="https://page-ag-testing-ohftxirgbn.cn-shanghai.fcapp.run",DEMO_API_KEY="NA";setTimeout(()=>{const e=document.currentScript;let t;if(e){console.log("🚀 page-agent.js detected current script:",e.src);const o=new URL(e.src),n=o.searchParams.get("model")||DEMO_MODEL,r=o.searchParams.get("baseURL")||DEMO_BASE_URL,i=o.searchParams.get("apiKey")||DEMO_API_KEY,s=o.searchParams.get("lang")||"zh-CN";t={model:n,baseURL:r,apiKey:i,language:s}}else console.log("🚀 page-agent.js no current script detected, using default demo config"),t={model:DEMO_MODEL,baseURL:DEMO_BASE_URL,apiKey:DEMO_API_KEY};window.pageAgent=new PageAgent(t),window.pageAgent.panel.show(),console.log("🚀 page-agent.js initialized with config:",window.pageAgent.config)});function computeBorderGeometry(e,t,o,n){const r=Math.max(1,Math.min(e,t)),i=Math.min(o,20),c=Math.min(i+n,r),l=Math.min(c,Math.floor(e/2)),d=Math.min(c,Math.floor(t/2)),h=a(w=>w/e*2-1,"toClipX"),f=a(w=>w/t*2-1,"toClipY"),g=0,m=e,T=0,I=t,A=l,C=e-l,D=d,k=t-d,v=h(g),O=h(m),Ie=f(T),B=f(I),q=h(A),ue=h(C),K=f(D),de=f(k),pe=0,Ke=0,he=1,Xe=1,Qe=l/e,_e=1-l/e,fe=d/t,u=1-d/t,y=new Float32Array([v,Ie,O,Ie,v,K,v,K,O,Ie,O,K,v,de,O,de,v,B,v,B,O,de,O,B,v,K,q,K,v,de,v,de,q,K,q,de,ue,K,O,K,ue,de,ue,de,O,K,O,de]),P=new Float32Array([pe,Ke,he,Ke,pe,fe,pe,fe,he,Ke,he,fe,pe,u,he,u,pe,Xe,pe,Xe,he,u,he,Xe,pe,fe,Qe,fe,pe,u,pe,u,Qe,fe,Qe,u,_e,fe,he,fe,_e,u,_e,u,he,fe,he,u]);return{positions:y,uvs:P}}a(computeBorderGeometry,"computeBorderGeometry");function compileShader(e,t,o){const n=e.createShader(t);if(!n)throw new Error("Failed to create shader");if(e.shaderSource(n,o),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){const r=e.getShaderInfoLog(n)||"Unknown shader error";throw e.deleteShader(n),new Error(r)}return n}a(compileShader,"compileShader");function createProgram(e,t,o){const n=compileShader(e,e.VERTEX_SHADER,t),r=compileShader(e,e.FRAGMENT_SHADER,o),i=e.createProgram();if(!i)throw new Error("Failed to create program");if(e.attachShader(i,n),e.attachShader(i,r),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS)){const s=e.getProgramInfoLog(i)||"Unknown link error";throw e.deleteProgram(i),e.deleteShader(n),e.deleteShader(r),new Error(s)}return e.deleteShader(n),e.deleteShader(r),i}a(createProgram,"createProgram");const fragmentShaderSource=`#version 300 es
|
|
291
291
|
precision lowp float;
|
|
292
292
|
in vec2 vUV;
|
|
293
293
|
out vec4 outColor;
|
|
@@ -397,4 +397,4 @@ out vec2 vUV;
|
|
|
397
397
|
void main() {
|
|
398
398
|
vUV = aUV;
|
|
399
399
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
400
|
-
}`;const DEFAULT_COLORS=["rgb(57, 182, 255)","rgb(189, 69, 251)","rgb(255, 87, 51)","rgb(255, 214, 0)"];function parseColor(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!t)throw new Error(`Invalid color format: ${e}`);const[,o,n,r]=t;return[parseInt(o)/255,parseInt(n)/255,parseInt(r)/255]}a(parseColor,"parseColor");const ft=class ft{element;canvas;options;running=!1;disposed=!1;startTime=0;lastTime=0;rafId=null;glr;observer;constructor(t={}){this.options={width:t.width??600,height:t.height??600,ratio:t.ratio??window.devicePixelRatio??1,borderWidth:t.borderWidth??8,glowWidth:t.glowWidth??200,borderRadius:t.borderRadius??8,mode:t.mode??"light",...t},this.canvas=document.createElement("canvas"),this.options.classNames&&(this.canvas.className=this.options.classNames),this.options.styles&&Object.assign(this.canvas.style,this.options.styles),this.canvas.style.display="block",this.canvas.style.transformOrigin="center",this.canvas.style.pointerEvents="none",this.element=this.canvas,this.setupGL(),this.options.skipGreeting||this.greet()}start(){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.running)return;if(!this.glr){console.error("WebGL resources are not initialized.");return}this.running=!0,this.startTime=performance.now(),this.resize(this.options.width??600,this.options.height??600,this.options.ratio),this.glr.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.glr.gl.useProgram(this.glr.program),this.glr.gl.uniform2f(this.glr.uResolution,this.canvas.width,this.canvas.height),this.checkGLError(this.glr.gl,"start: after initial setup");const t=a(()=>{if(!this.running||!this.glr)return;this.rafId=requestAnimationFrame(t);const o=performance.now();if(o-this.lastTime<1e3/32)return;this.lastTime=o;const r=(o-this.startTime)*.001;this.render(r)},"loop");this.rafId=requestAnimationFrame(t)}pause(){if(this.disposed)throw new Error("Motion instance has been disposed.");this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId)}dispose(){if(this.disposed)return;this.disposed=!0,this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId);const{gl:t,vao:o,positionBuffer:n,uvBuffer:r,program:i}=this.glr;o&&t.deleteVertexArray(o),n&&t.deleteBuffer(n),r&&t.deleteBuffer(r),t.deleteProgram(i),this.observer&&this.observer.disconnect(),this.canvas.remove()}resize(t,o,n){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.options.width=t,this.options.height=o,n&&(this.options.ratio=n),!this.running)return;const{gl:r,program:i,vao:s,positionBuffer:c,uvBuffer:l,uResolution:d}=this.glr,h=n??this.options.ratio??window.devicePixelRatio??1,f=Math.max(1,Math.floor(t*h)),g=Math.max(1,Math.floor(o*h));this.canvas.style.width=`${t}px`,this.canvas.style.height=`${o}px`,(this.canvas.width!==f||this.canvas.height!==g)&&(this.canvas.width=f,this.canvas.height=g),r.viewport(0,0,this.canvas.width,this.canvas.height),this.checkGLError(r,"resize: after viewport setup");const{positions:m,uvs:T}=computeBorderGeometry(this.canvas.width,this.canvas.height,this.options.borderWidth*h,this.options.glowWidth*h);r.bindVertexArray(s),r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,m,r.STATIC_DRAW);const I=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(I),r.vertexAttribPointer(I,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after position buffer update"),r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,T,r.STATIC_DRAW);const A=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(A),r.vertexAttribPointer(A,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after UV buffer update"),r.useProgram(i),r.uniform2f(d,this.canvas.width,this.canvas.height),r.uniform1f(this.glr.uBorderWidth,this.options.borderWidth*h),r.uniform1f(this.glr.uGlowWidth,this.options.glowWidth*h),r.uniform1f(this.glr.uBorderRadius,this.options.borderRadius*h),this.checkGLError(r,"resize: after uniform updates");const R=performance.now();this.lastTime=R;const D=(R-this.startTime)*.001;this.render(D)}autoResize(t){this.observer&&this.observer.disconnect(),this.observer=new ResizeObserver(()=>{const o=t.getBoundingClientRect();this.resize(o.width,o.height)}),this.observer.observe(t)}fadeIn(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:0,transform:"scale(1.2)"},{opacity:1,transform:"scale(1)"}],{duration:300,easing:"ease-out",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}fadeOut(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(1.2)"}],{duration:300,easing:"ease-in",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}checkGLError(t,o){let n=t.getError();if(n!==t.NO_ERROR){for(console.group(`🔴 WebGL Error in ${o}`);n!==t.NO_ERROR;){const r=this.getGLErrorName(t,n);console.error(`${r} (0x${n.toString(16)})`),n=t.getError()}console.groupEnd()}}getGLErrorName(t,o){switch(o){case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"UNKNOWN_ERROR"}}setupGL(){const t=this.canvas.getContext("webgl2",{antialias:!1,alpha:!0});if(!t)throw new Error("WebGL2 is required but not available.");const o=createProgram(t,vertexShaderSource,fragmentShaderSource);this.checkGLError(t,"setupGL: after createProgram");const n=t.createVertexArray();t.bindVertexArray(n),this.checkGLError(t,"setupGL: after VAO creation");const r=this.canvas.width||2,i=this.canvas.height||2,{positions:s,uvs:c}=computeBorderGeometry(r,i,this.options.borderWidth,this.options.glowWidth),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const d=t.getAttribLocation(o,"aPosition");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after position buffer setup");const h=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,h),t.bufferData(t.ARRAY_BUFFER,c,t.STATIC_DRAW);const f=t.getAttribLocation(o,"aUV");t.enableVertexAttribArray(f),t.vertexAttribPointer(f,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after UV buffer setup");const g=t.getUniformLocation(o,"uResolution"),m=t.getUniformLocation(o,"uTime"),T=t.getUniformLocation(o,"uBorderWidth"),I=t.getUniformLocation(o,"uGlowWidth"),A=t.getUniformLocation(o,"uBorderRadius"),R=t.getUniformLocation(o,"uColors"),D=t.getUniformLocation(o,"uGlowExponent"),k=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(T,this.options.borderWidth),t.uniform1f(I,this.options.glowWidth),t.uniform1f(A,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(D,2),t.uniform1f(k,1.8)):(t.uniform1f(D,1),t.uniform1f(k,1));const v=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let O=0;O<v.length;O++)t.uniform3f(t.getUniformLocation(o,`uColors[${O}]`),...v[O]);this.checkGLError(t,"setupGL: after uniform setup"),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this.glr={gl:t,program:o,vao:n,positionBuffer:l,uvBuffer:h,uResolution:g,uTime:m,uBorderWidth:T,uGlowWidth:I,uBorderRadius:A,uColors:R}}render(t){if(!this.glr)return;const{gl:o,program:n,vao:r,uTime:i}=this.glr;o.useProgram(n),o.bindVertexArray(r),o.uniform1f(i,t),o.disable(o.DEPTH_TEST),o.disable(o.CULL_FACE),o.disable(o.BLEND),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLES,0,24),this.checkGLError(o,"render: after draw call"),o.bindVertexArray(null)}greet(){console.log("%c🌈 ai-motion 0.4.8 🌈","background: linear-gradient(90deg, #39b6ff, #bd45fb, #ff5733, #ffd600); color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); font-weight: bold; font-size: 1em; padding: 2px 12px; border-radius: 6px;")}};a(ft,"Motion");let Motion=ft;function hasDarkModeClass(){const e=["dark","dark-mode","theme-dark","night","night-mode"],t=document.documentElement,o=document.body||document.documentElement;for(const r of e)if(t.classList.contains(r)||o?.classList.contains(r))return!0;return!!t.getAttribute("data-theme")?.toLowerCase().includes("dark")}a(hasDarkModeClass,"hasDarkModeClass");function parseRgbColor(e){const t=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(e);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}a(parseRgbColor,"parseRgbColor");function isColorDark(e,t=128){if(!e||e==="transparent"||e.startsWith("rgba(0, 0, 0, 0)"))return!1;const o=parseRgbColor(e);return o?.299*o.r+.587*o.g+.114*o.b<t:!1}a(isColorDark,"isColorDark");function isBackgroundDark(){const e=window.getComputedStyle(document.documentElement),t=window.getComputedStyle(document.body||document.documentElement),o=e.backgroundColor,n=t.backgroundColor;return isColorDark(n)?!0:n==="transparent"||n.startsWith("rgba(0, 0, 0, 0)")?isColorDark(o):!1}a(isBackgroundDark,"isBackgroundDark");function isPageDark(){try{return!!(hasDarkModeClass()||isBackgroundDark())}catch(e){return console.warn("Error determining if page is dark:",e),!1}}a(isPageDark,"isPageDark");const wrapper="_wrapper_gf8tz_1",styles={wrapper},cursor="_cursor_1dgwb_2",cursorBorder="_cursorBorder_1dgwb_10",cursorFilling="_cursorFilling_1dgwb_25",cursorRipple="_cursorRipple_1dgwb_39",clicking="_clicking_1dgwb_57",cursorStyles={cursor,cursorBorder,cursorFilling,cursorRipple,clicking},gt=class gt{constructor(){Z(this,Ne);ne(this,"shown",!1);ne(this,"wrapper",document.createElement("div"));ne(this,"motion",new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}}));Z(this,Y,document.createElement("div"));Z(this,ce,0);Z(this,le,0);Z(this,Se,0);Z(this,Te,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.setAttribute("data-page-agent-ignore","true"),this.wrapper.appendChild(this.motion.element),this.motion.autoResize(this.wrapper),this.wrapper.addEventListener("click",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mouseup",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousemove",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("wheel",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keydown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keyup",t=>{t.stopPropagation(),t.preventDefault()}),b(this,Ne,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Ne,$t).call(this),window.addEventListener("PageAgent::MovePointerTo",t=>{const{x:o,y:n}=t.detail;this.setCursorPosition(o,n)}),window.addEventListener("PageAgent::ClickPointer",t=>{this.triggerClickAnimation()})}setCursorPosition(t,o){S(this,Se,t),S(this,Te,o)}triggerClickAnimation(){p(this,Y).classList.remove(cursorStyles.clicking),p(this,Y).offsetHeight,p(this,Y).classList.add(cursorStyles.clicking)}show(){this.shown||(this.shown=!0,this.motion.start(),this.motion.fadeIn(),this.wrapper.style.display="block",S(this,ce,window.innerWidth/2),S(this,le,window.innerHeight/2),S(this,Se,p(this,ce)),S(this,Te,p(this,le)),p(this,Y).style.left=`${p(this,ce)}px`,p(this,Y).style.top=`${p(this,le)}px`)}hide(){this.shown&&(this.shown=!1,this.motion.fadeOut(),this.motion.pause(),p(this,Y).classList.remove(cursorStyles.clicking),setTimeout(()=>{this.wrapper.style.display="none"},800))}dispose(){this.motion.dispose(),this.wrapper.remove()}};Y=new WeakMap,ce=new WeakMap,le=new WeakMap,Se=new WeakMap,Te=new WeakMap,Ne=new WeakSet,Yt=a(function(){p(this,Y).className=cursorStyles.cursor;const t=document.createElement("div");t.className=cursorStyles.cursorRipple,p(this,Y).appendChild(t);const o=document.createElement("div");o.className=cursorStyles.cursorFilling,p(this,Y).appendChild(o);const n=document.createElement("div");n.className=cursorStyles.cursorBorder,p(this,Y).appendChild(n),this.wrapper.appendChild(p(this,Y))},"#createCursor"),$t=a(function(){const t=p(this,ce)+(p(this,Se)-p(this,ce))*.2,o=p(this,le)+(p(this,Te)-p(this,le))*.2,n=Math.abs(t-p(this,Se));n>0&&(n<2?S(this,ce,p(this,Se)):S(this,ce,t),p(this,Y).style.left=`${p(this,ce)}px`);const r=Math.abs(o-p(this,Te));r>0&&(r<2?S(this,le,p(this,Te)):S(this,le,o),p(this,Y).style.top=`${p(this,le)}px`),requestAnimationFrame(()=>b(this,Ne,$t).call(this))},"#moveCursorToTarget"),a(gt,"SimulatorMask");let SimulatorMask=gt;const SimulatorMask$1=Object.freeze(Object.defineProperty({__proto__:null,SimulatorMask},Symbol.toStringTag,{value:"Module"}))})();
|
|
400
|
+
}`;const DEFAULT_COLORS=["rgb(57, 182, 255)","rgb(189, 69, 251)","rgb(255, 87, 51)","rgb(255, 214, 0)"];function parseColor(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!t)throw new Error(`Invalid color format: ${e}`);const[,o,n,r]=t;return[parseInt(o)/255,parseInt(n)/255,parseInt(r)/255]}a(parseColor,"parseColor");const ft=class ft{element;canvas;options;running=!1;disposed=!1;startTime=0;lastTime=0;rafId=null;glr;observer;constructor(t={}){this.options={width:t.width??600,height:t.height??600,ratio:t.ratio??window.devicePixelRatio??1,borderWidth:t.borderWidth??8,glowWidth:t.glowWidth??200,borderRadius:t.borderRadius??8,mode:t.mode??"light",...t},this.canvas=document.createElement("canvas"),this.options.classNames&&(this.canvas.className=this.options.classNames),this.options.styles&&Object.assign(this.canvas.style,this.options.styles),this.canvas.style.display="block",this.canvas.style.transformOrigin="center",this.canvas.style.pointerEvents="none",this.element=this.canvas,this.setupGL(),this.options.skipGreeting||this.greet()}start(){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.running)return;if(!this.glr){console.error("WebGL resources are not initialized.");return}this.running=!0,this.startTime=performance.now(),this.resize(this.options.width??600,this.options.height??600,this.options.ratio),this.glr.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.glr.gl.useProgram(this.glr.program),this.glr.gl.uniform2f(this.glr.uResolution,this.canvas.width,this.canvas.height),this.checkGLError(this.glr.gl,"start: after initial setup");const t=a(()=>{if(!this.running||!this.glr)return;this.rafId=requestAnimationFrame(t);const o=performance.now();if(o-this.lastTime<1e3/32)return;this.lastTime=o;const r=(o-this.startTime)*.001;this.render(r)},"loop");this.rafId=requestAnimationFrame(t)}pause(){if(this.disposed)throw new Error("Motion instance has been disposed.");this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId)}dispose(){if(this.disposed)return;this.disposed=!0,this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId);const{gl:t,vao:o,positionBuffer:n,uvBuffer:r,program:i}=this.glr;o&&t.deleteVertexArray(o),n&&t.deleteBuffer(n),r&&t.deleteBuffer(r),t.deleteProgram(i),this.observer&&this.observer.disconnect(),this.canvas.remove()}resize(t,o,n){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.options.width=t,this.options.height=o,n&&(this.options.ratio=n),!this.running)return;const{gl:r,program:i,vao:s,positionBuffer:c,uvBuffer:l,uResolution:d}=this.glr,h=n??this.options.ratio??window.devicePixelRatio??1,f=Math.max(1,Math.floor(t*h)),g=Math.max(1,Math.floor(o*h));this.canvas.style.width=`${t}px`,this.canvas.style.height=`${o}px`,(this.canvas.width!==f||this.canvas.height!==g)&&(this.canvas.width=f,this.canvas.height=g),r.viewport(0,0,this.canvas.width,this.canvas.height),this.checkGLError(r,"resize: after viewport setup");const{positions:m,uvs:T}=computeBorderGeometry(this.canvas.width,this.canvas.height,this.options.borderWidth*h,this.options.glowWidth*h);r.bindVertexArray(s),r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,m,r.STATIC_DRAW);const I=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(I),r.vertexAttribPointer(I,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after position buffer update"),r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,T,r.STATIC_DRAW);const A=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(A),r.vertexAttribPointer(A,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after UV buffer update"),r.useProgram(i),r.uniform2f(d,this.canvas.width,this.canvas.height),r.uniform1f(this.glr.uBorderWidth,this.options.borderWidth*h),r.uniform1f(this.glr.uGlowWidth,this.options.glowWidth*h),r.uniform1f(this.glr.uBorderRadius,this.options.borderRadius*h),this.checkGLError(r,"resize: after uniform updates");const C=performance.now();this.lastTime=C;const D=(C-this.startTime)*.001;this.render(D)}autoResize(t){this.observer&&this.observer.disconnect(),this.observer=new ResizeObserver(()=>{const o=t.getBoundingClientRect();this.resize(o.width,o.height)}),this.observer.observe(t)}fadeIn(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:0,transform:"scale(1.2)"},{opacity:1,transform:"scale(1)"}],{duration:300,easing:"ease-out",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}fadeOut(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(1.2)"}],{duration:300,easing:"ease-in",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}checkGLError(t,o){let n=t.getError();if(n!==t.NO_ERROR){for(console.group(`🔴 WebGL Error in ${o}`);n!==t.NO_ERROR;){const r=this.getGLErrorName(t,n);console.error(`${r} (0x${n.toString(16)})`),n=t.getError()}console.groupEnd()}}getGLErrorName(t,o){switch(o){case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"UNKNOWN_ERROR"}}setupGL(){const t=this.canvas.getContext("webgl2",{antialias:!1,alpha:!0});if(!t)throw new Error("WebGL2 is required but not available.");const o=createProgram(t,vertexShaderSource,fragmentShaderSource);this.checkGLError(t,"setupGL: after createProgram");const n=t.createVertexArray();t.bindVertexArray(n),this.checkGLError(t,"setupGL: after VAO creation");const r=this.canvas.width||2,i=this.canvas.height||2,{positions:s,uvs:c}=computeBorderGeometry(r,i,this.options.borderWidth,this.options.glowWidth),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const d=t.getAttribLocation(o,"aPosition");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after position buffer setup");const h=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,h),t.bufferData(t.ARRAY_BUFFER,c,t.STATIC_DRAW);const f=t.getAttribLocation(o,"aUV");t.enableVertexAttribArray(f),t.vertexAttribPointer(f,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after UV buffer setup");const g=t.getUniformLocation(o,"uResolution"),m=t.getUniformLocation(o,"uTime"),T=t.getUniformLocation(o,"uBorderWidth"),I=t.getUniformLocation(o,"uGlowWidth"),A=t.getUniformLocation(o,"uBorderRadius"),C=t.getUniformLocation(o,"uColors"),D=t.getUniformLocation(o,"uGlowExponent"),k=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(T,this.options.borderWidth),t.uniform1f(I,this.options.glowWidth),t.uniform1f(A,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(D,2),t.uniform1f(k,1.8)):(t.uniform1f(D,1),t.uniform1f(k,1));const v=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let O=0;O<v.length;O++)t.uniform3f(t.getUniformLocation(o,`uColors[${O}]`),...v[O]);this.checkGLError(t,"setupGL: after uniform setup"),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this.glr={gl:t,program:o,vao:n,positionBuffer:l,uvBuffer:h,uResolution:g,uTime:m,uBorderWidth:T,uGlowWidth:I,uBorderRadius:A,uColors:C}}render(t){if(!this.glr)return;const{gl:o,program:n,vao:r,uTime:i}=this.glr;o.useProgram(n),o.bindVertexArray(r),o.uniform1f(i,t),o.disable(o.DEPTH_TEST),o.disable(o.CULL_FACE),o.disable(o.BLEND),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLES,0,24),this.checkGLError(o,"render: after draw call"),o.bindVertexArray(null)}greet(){console.log("%c🌈 ai-motion 0.4.8 🌈","background: linear-gradient(90deg, #39b6ff, #bd45fb, #ff5733, #ffd600); color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); font-weight: bold; font-size: 1em; padding: 2px 12px; border-radius: 6px;")}};a(ft,"Motion");let Motion=ft;function hasDarkModeClass(){const e=["dark","dark-mode","theme-dark","night","night-mode"],t=document.documentElement,o=document.body||document.documentElement;for(const r of e)if(t.classList.contains(r)||o?.classList.contains(r))return!0;return!!t.getAttribute("data-theme")?.toLowerCase().includes("dark")}a(hasDarkModeClass,"hasDarkModeClass");function parseRgbColor(e){const t=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(e);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}a(parseRgbColor,"parseRgbColor");function isColorDark(e,t=128){if(!e||e==="transparent"||e.startsWith("rgba(0, 0, 0, 0)"))return!1;const o=parseRgbColor(e);return o?.299*o.r+.587*o.g+.114*o.b<t:!1}a(isColorDark,"isColorDark");function isBackgroundDark(){const e=window.getComputedStyle(document.documentElement),t=window.getComputedStyle(document.body||document.documentElement),o=e.backgroundColor,n=t.backgroundColor;return isColorDark(n)?!0:n==="transparent"||n.startsWith("rgba(0, 0, 0, 0)")?isColorDark(o):!1}a(isBackgroundDark,"isBackgroundDark");function isPageDark(){try{return!!(hasDarkModeClass()||isBackgroundDark())}catch(e){return console.warn("Error determining if page is dark:",e),!1}}a(isPageDark,"isPageDark");const wrapper="_wrapper_gf8tz_1",styles={wrapper},cursor="_cursor_1dgwb_2",cursorBorder="_cursorBorder_1dgwb_10",cursorFilling="_cursorFilling_1dgwb_25",cursorRipple="_cursorRipple_1dgwb_39",clicking="_clicking_1dgwb_57",cursorStyles={cursor,cursorBorder,cursorFilling,cursorRipple,clicking},gt=class gt{constructor(){Z(this,Ne);ne(this,"shown",!1);ne(this,"wrapper",document.createElement("div"));ne(this,"motion",new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}}));Z(this,Y,document.createElement("div"));Z(this,ce,0);Z(this,le,0);Z(this,Se,0);Z(this,Te,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.setAttribute("data-page-agent-ignore","true"),this.wrapper.appendChild(this.motion.element),this.motion.autoResize(this.wrapper),this.wrapper.addEventListener("click",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mouseup",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousemove",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("wheel",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keydown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keyup",t=>{t.stopPropagation(),t.preventDefault()}),b(this,Ne,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Ne,$t).call(this),window.addEventListener("PageAgent::MovePointerTo",t=>{const{x:o,y:n}=t.detail;this.setCursorPosition(o,n)}),window.addEventListener("PageAgent::ClickPointer",t=>{this.triggerClickAnimation()})}setCursorPosition(t,o){S(this,Se,t),S(this,Te,o)}triggerClickAnimation(){p(this,Y).classList.remove(cursorStyles.clicking),p(this,Y).offsetHeight,p(this,Y).classList.add(cursorStyles.clicking)}show(){this.shown||(this.shown=!0,this.motion.start(),this.motion.fadeIn(),this.wrapper.style.display="block",S(this,ce,window.innerWidth/2),S(this,le,window.innerHeight/2),S(this,Se,p(this,ce)),S(this,Te,p(this,le)),p(this,Y).style.left=`${p(this,ce)}px`,p(this,Y).style.top=`${p(this,le)}px`)}hide(){this.shown&&(this.shown=!1,this.motion.fadeOut(),this.motion.pause(),p(this,Y).classList.remove(cursorStyles.clicking),setTimeout(()=>{this.wrapper.style.display="none"},800))}dispose(){this.motion.dispose(),this.wrapper.remove()}};Y=new WeakMap,ce=new WeakMap,le=new WeakMap,Se=new WeakMap,Te=new WeakMap,Ne=new WeakSet,Yt=a(function(){p(this,Y).className=cursorStyles.cursor;const t=document.createElement("div");t.className=cursorStyles.cursorRipple,p(this,Y).appendChild(t);const o=document.createElement("div");o.className=cursorStyles.cursorFilling,p(this,Y).appendChild(o);const n=document.createElement("div");n.className=cursorStyles.cursorBorder,p(this,Y).appendChild(n),this.wrapper.appendChild(p(this,Y))},"#createCursor"),$t=a(function(){const t=p(this,ce)+(p(this,Se)-p(this,ce))*.2,o=p(this,le)+(p(this,Te)-p(this,le))*.2,n=Math.abs(t-p(this,Se));n>0&&(n<2?S(this,ce,p(this,Se)):S(this,ce,t),p(this,Y).style.left=`${p(this,ce)}px`);const r=Math.abs(o-p(this,Te));r>0&&(r<2?S(this,le,p(this,Te)):S(this,le,o),p(this,Y).style.top=`${p(this,le)}px`),requestAnimationFrame(()=>b(this,Ne,$t).call(this))},"#moveCursorToTarget"),a(gt,"SimulatorMask");let SimulatorMask=gt;const SimulatorMask$1=Object.freeze(Object.defineProperty({__proto__:null,SimulatorMask},Symbol.toStringTag,{value:"Module"}))})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/page-agent.js",
|
|
7
7
|
"module": "./dist/esm/page-agent.js",
|
|
@@ -44,11 +44,16 @@
|
|
|
44
44
|
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@page-agent/core": "1.
|
|
48
|
-
"@page-agent/llms": "1.
|
|
49
|
-
"@page-agent/page-controller": "1.
|
|
50
|
-
"@page-agent/ui": "1.
|
|
51
|
-
"chalk": "^5.6.2"
|
|
47
|
+
"@page-agent/core": "1.5.1",
|
|
48
|
+
"@page-agent/llms": "1.5.1",
|
|
49
|
+
"@page-agent/page-controller": "1.5.1",
|
|
50
|
+
"@page-agent/ui": "1.5.1",
|
|
51
|
+
"chalk": "^5.6.2"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
52
57
|
"zod": "^4.3.5"
|
|
53
58
|
}
|
|
54
59
|
}
|