@sv-print/plugin-cloud 0.0.0-stage → 0.1.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/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";var Kn=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnPropertyDescriptors;var Ut=Object.getOwnPropertySymbols;var Wn=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable;var vt=(n,e,t)=>e in n?Kn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ge=(n,e)=>{for(var t in e||(e={}))Wn.call(e,t)&&vt(n,t,e[t]);if(Ut)for(var t of Ut(e))Yn.call(e,t)&&vt(n,t,e[t]);return n},Xe=(n,e)=>Gn(n,Vn(e));var te=(n,e,t)=>vt(n,typeof e!="symbol"?e+"":e,t);var X=(n,e,t)=>new Promise((l,s)=>{var i=p=>{try{o(t.next(p))}catch(f){s(f)}},c=p=>{try{o(t.throw(p))}catch(f){s(f)}},o=p=>p.done?l(p.value):Promise.resolve(p.value).then(i,c);o((t=t.apply(n,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Bl=require("sv-print");function yt(n,e){!n||n.__cloudExtended||(n.serverRender=function(t={}){var l,s;return e.render(Xe(Ge({},t),{template:(s=t.template)!=null?s:(l=n.getJson)==null?void 0:l.call(n)}))},n.cloudPrint=function(t){var l,s;return e.cloudPrint(Xe(Ge({},t),{template_data:(s=t.template_data)!=null?s:(l=n.getJson)==null?void 0:l.call(n)}))},n.transitPrint=function(t={}){var l,s;return e.transitPrint(Xe(Ge({},t),{template:(s=t.template)!=null?s:(l=n.getJson)==null?void 0:l.call(n)}))},n.restoreCloud=function(){delete n.serverRender,delete n.cloudPrint,delete n.transitPrint,delete n.restoreCloud,delete n.__cloudExtended},n.__cloudExtended=!0)}const Nt="cloud-template-center";function Xn(n,e,t){const l=e.templateCenter||{};if(l.enable===!1)return;const s=n==null?void 0:n.header;if(!(s!=null&&s.updateMenuList))return;const i={cloudMenu:Nt,icon:l.icon||"sv-templates",title:l.menuTitle||"模板中心",click:()=>t()};s.updateMenuList(c=>{var f;if(c.some(_=>_&&_.cloudMenu===Nt))return;const o=(f=l.menuOrder)!=null?f:0,p=o<0?Math.max(0,c.length+1+o):Math.min(o,c.length);c.splice(p,0,i)})}class jl{constructor(e){te(this,"host");te(this,"tokenGetter");te(this,"onUnauthorizedCb");te(this,"adapter");this.host=(e.host||"").replace(/\/+$/,""),this.adapter=e.requestAdapter}setTokenGetter(e){this.tokenGetter=e}setOnUnauthorized(e){this.onUnauthorizedCb=e}notifyUnauthorized(){var e;try{(e=this.onUnauthorizedCb)==null||e.call(this)}catch(t){}}apiUrl(e){if(/^https?:\/\//i.test(e))return e;const t=e.startsWith("/")?e:`/${e}`;return`${this.host}/api${t}`}absUrl(e){return/^https?:\/\//i.test(e)?e:`${this.host}${e.startsWith("/")?e:`/${e}`}`}buildUrl(e,t){let l=this.apiUrl(e);if(t){const s=new URLSearchParams;Object.keys(t).forEach(c=>{const o=t[c];o==null||o===""||(Array.isArray(o)?o.forEach(p=>s.append(c,String(p))):s.append(c,String(o)))});const i=s.toString();i&&(l+=(l.includes("?")?"&":"?")+i)}return l}buildHeaders(e,t=!0){var s;const l=Ge({"Content-Type":"application/json"},e||{});if(t){const i=(s=this.tokenGetter)==null?void 0:s.call(this);i&&(l.Authorization=`Bearer ${i}`)}return l}request(s,i){return X(this,arguments,function*(e,t,l={}){const c=this.buildUrl(t,l.params),o=this.buildHeaders(l.headers,l.auth!==!1);if(this.adapter){const f=yield this.adapter({url:c,method:e.toUpperCase(),headers:o,body:l.body});return this.unwrap(f)}const p=yield fetch(c,{method:e.toUpperCase(),headers:o,body:l.body===void 0?void 0:JSON.stringify(l.body)});return this.parseResponse(p)})}parseResponse(e){return X(this,null,function*(){const t=yield e.text();let l;try{l=t?JSON.parse(t):void 0}catch(s){l=void 0}if(!e.ok){e.status===401&&this.notifyUnauthorized();const s=(l==null?void 0:l.msg)||(l==null?void 0:l.message)||`HTTP ${e.status}`;throw new Error(s)}if(l!==void 0)return this.unwrap(l)})}unwrap(e){if(e&&typeof e=="object"&&"code"in e){if(!(e.code===1||e.isOk===!0))throw(e.code===401||e.statusCode===401)&&this.notifyUnauthorized(),new Error(e.msg||e.message||"请求失败");return e.data!==void 0?e.data:e}return e}get(e,t){return this.request("GET",e,t)}post(e,t){return this.request("POST",e,t)}patch(e,t){return this.request("PATCH",e,t)}del(e,t){return this.request("DELETE",e,t)}}const Fl="sv-print-oauth",Kl="sv_print_cloud_auth",Gl=`${Kl}_active`,Qn="sv_print_cloud_oauth_state_",Zn="sv_print_cloud_oauth_code_";function Vl(n,e){var p;let t;try{t=new URL(n,((p=globalThis.location)==null?void 0:p.origin)||"http://localhost")}catch(f){return null}const l=t.hash.replace(/^#\/?/,""),s=f=>t.searchParams.get(f)||new URLSearchParams(l).get(f),i=s("state")||void 0;if(e&&i&&i!==e)return null;const c=s("error")||s("error_description");if(c)return{state:i,error:c};const o=s("code");return o?{state:i,code:o}:null}function wt(n){return`${Zn}${n}`}function $n(n){var e;try{return((e=globalThis.localStorage)==null?void 0:e.getItem(wt(n)))||null}catch(t){return null}}function xn(n){var e;try{(e=globalThis.localStorage)==null||e.removeItem(wt(n))}catch(t){}}function Wl(){var l,s;const n=Vl(((l=globalThis.location)==null?void 0:l.href)||"");if(!(n!=null&&n.code))return!1;const e=globalThis.opener;if(!e)return!1;const t=n.state||"";try{(s=globalThis.localStorage)==null||s.setItem(wt(t),n.code)}catch(i){}try{e.postMessage({type:Fl,code:n.code,state:t},"*")}catch(i){}try{history.replaceState(null,"",globalThis.location.pathname+globalThis.location.hash)}catch(i){}try{globalThis.close()}catch(i){}return!0}class Yl{constructor(e){te(this,"id","oauth");te(this,"label","授权登录");te(this,"autoLogin");this.oauth=e}canLogin(){var e,t;return!!((e=this.oauth)!=null&&e.clientId&&((t=this.oauth)!=null&&t.authorizeOrigin))}get stateKey(){var e;return`${Qn}${((e=this.oauth)==null?void 0:e.clientId)||"default"}`}redirectUri(){var e,t;return((e=this.oauth)==null?void 0:e.redirectUri)||((t=globalThis.location)==null?void 0:t.origin)||""}scopeStr(){var t;const e=(t=this.oauth)==null?void 0:t.scope;return e?Array.isArray(e)?e.join(","):e:""}randomState(){const e=globalThis.crypto;return e!=null&&e.randomUUID?e.randomUUID():`svp-${Date.now()}-${Math.random().toString(36).slice(2)}`}authorizeBase(){var e;return(((e=this.oauth)==null?void 0:e.authorizeOrigin)||"").replace(/\/+$/,"")}isAbsoluteAuthorize(){return/^https?:\/\//i.test(this.authorizeBase())}expectedMessageOrigin(){var t;const e=this.authorizeBase();if(!this.isAbsoluteAuthorize())return((t=globalThis.location)==null?void 0:t.origin)||"";try{return new URL(e).origin}catch(l){return e}}buildAuthorizeUrl(e){var s;const t=new URLSearchParams({client_id:((s=this.oauth)==null?void 0:s.clientId)||"",redirect_uri:this.redirectUri(),state:e}),l=this.scopeStr();return l&&t.set("scope",l),`${this.authorizeBase()}/oauth/authorize?${t.toString()}`}parseMessage(e,t){const l=this.expectedMessageOrigin();if(l&&e.origin!==l)return null;const s=e.data;return!s||s.type!==Fl||s.state!==t?null:{code:s.code,error:s.error}}waitInIframe(e,t){return new Promise((l,s)=>{let i=!1,c=null;const o=document.createElement("div");o.className="svp-cloud-oauth-overlay",o.innerHTML=`
2
+ <div class="svp-cloud-oauth-box">
3
+ <div class="svp-cloud-oauth-head">
4
+ <span>登录 sv-print-cloud</span>
5
+ <button type="button" class="svp-cloud-oauth-close" aria-label="关闭">×</button>
6
+ </div>
7
+ <iframe class="svp-cloud-oauth-frame" allow="clipboard-write"></iframe>
8
+ </div>`;const p=o.querySelector("iframe");p.src=e;const f=o.querySelector(".svp-cloud-oauth-close"),_=()=>{window.removeEventListener("message",v),c&&clearTimeout(c),o.remove()},u=m=>{i||(i=!0,_(),m())},v=m=>{const P=this.parseMessage(m,t);P&&(P.error?u(()=>s(new Error(`授权被拒绝:${P.error}`))):P.code&&u(()=>l(P.code)))};f.onclick=()=>u(()=>s(new Error("已取消授权"))),o.onclick=m=>{m.target===o&&u(()=>s(new Error("已取消授权")))},window.addEventListener("message",v),c=setTimeout(()=>u(()=>s(new Error("授权超时,请重试"))),5*60*1e3),document.body.appendChild(o)})}waitInWindow(e,t,l){return new Promise((s,i)=>{const c=`svp-cloud-oauth-${this.id}`,o=l?window.open(e,c,l):window.open(e,c);if(!o){i(new Error("授权窗口被浏览器拦截,请允许弹窗后重试"));return}let p=!1,f=null,_=null;const u=()=>{window.removeEventListener("message",m),f&&clearTimeout(f),_&&clearInterval(_),xn(t)},v=P=>{if(!p){p=!0,u();try{o.close()}catch(C){}P()}},m=P=>{const C=this.parseMessage(P,t);C&&(C.error?v(()=>i(new Error(`授权被拒绝:${C.error}`))):C.code&&v(()=>s(C.code)))};window.addEventListener("message",m),_=setInterval(()=>{const P=$n(t);if(P){v(()=>s(P));return}try{const C=Vl(o.location.href,t);if(C!=null&&C.error){v(()=>i(new Error(`授权被拒绝:${C.error}`)));return}if(C!=null&&C.code){v(()=>s(C.code));return}}catch(C){}o.closed&&v(()=>i(new Error("已取消授权")))},300),f=setTimeout(()=>v(()=>i(new Error("授权超时,请重试"))),5*60*1e3)})}waitForCode(e){var s,i;const t=this.buildAuthorizeUrl(e),l=((s=this.oauth)==null?void 0:s.mode)||"iframe";if(l==="custom"){const c=(i=this.oauth)==null?void 0:i.authorize;return c?Promise.resolve(c(t,e)).then(o=>{if(!o)throw new Error("自定义授权未返回 code");return o}):Promise.reject(new Error("mode=custom 需配置 authorize 回调"))}return l==="popup"?this.waitInWindow(t,e,"width=520,height=720,menubar=no,toolbar=no,location=yes,status=no,resizable=yes,scrollbars=yes"):l==="page"?this.waitInWindow(t,e,""):this.waitInIframe(t,e)}exchangeToken(e,t,l){return X(this,null,function*(){var i,c,o;if((i=this.oauth)!=null&&i.exchangeToken)return this.oauth.exchangeToken(t,l);const s=(c=this.oauth)==null?void 0:c.clientSecret;if(!s)throw new Error("未配置 clientSecret 或 exchangeToken,无法换取 token");return e.client.post("/auth/member/oauth/token",{auth:!1,body:{code:t,client_id:(o=this.oauth)==null?void 0:o.clientId,client_secret:s}})})}login(e){return X(this,null,function*(){var s;if(!this.canLogin())throw new Error("未配置 OAuth(缺少 clientId 或 authorizeOrigin)");const t=this.randomState();try{(s=globalThis.sessionStorage)==null||s.setItem(this.stateKey,t)}catch(i){}const l=yield this.waitForCode(t);return this.exchangeToken(e,l,t)})}logout(e){return X(this,null,function*(){try{yield e.client.post("/auth/member/oauth/revoke",{auth:!0})}catch(t){}})}getUser(e){return X(this,null,function*(){var l;const t=((l=this.oauth)==null?void 0:l.getProfileUrl)||"/auth/member/profile";return e.client.get(t,{auth:!0})})}getClientInfo(e){return X(this,null,function*(){var t;return(t=this.oauth)!=null&&t.clientId?e.client.get(`/auth/member/oauth/client/${this.oauth.clientId}`,{auth:!1}):null})}}class Xl{constructor(e){te(this,"id","token");te(this,"label","访问令牌");te(this,"token");this.token=e.token}canLogin(){return!0}init(e){var l;const t=(l=this.token)==null?void 0:l.trim();t&&e.emit({accessToken:t})}login(){return X(this,null,function*(){var t;const e=(t=this.token)==null?void 0:t.trim();if(!e)throw new Error("请先填写访问令牌");return{accessToken:e}})}renderLogin(e,t){e.innerHTML=`
9
+ <div class="svp-cloud-auth-form">
10
+ <p class="svp-cloud-auth-hint">粘贴访问令牌(accessToken),保存后立即生效。</p>
11
+ <textarea class="svp-cloud-auth-input svp-cloud-auth-textarea" rows="3" placeholder="accessToken"></textarea>
12
+ <div class="svp-cloud-auth-error"></div>
13
+ <div class="svp-cloud-auth-actions">
14
+ <button type="button" class="svp-btn svp-btn-primary svp-btn-sm svp-cloud-auth-submit">保存并登录</button>
15
+ </div>
16
+ </div>`;const l=e.querySelector("textarea"),s=e.querySelector(".svp-cloud-auth-error"),i=e.querySelector(".svp-cloud-auth-submit");this.token&&(l.value=this.token),i.onclick=()=>{const c=l.value.trim();if(!c){s.textContent="请输入访问令牌";return}s.textContent="",this.token=c,t.emit({accessToken:c})}}destroyLogin(e){e.innerHTML=""}}class Ql{constructor(e){te(this,"id","host");te(this,"label","宿主托管");te(this,"getUser");te(this,"getClientInfo");this.cfg=e,e.getUser&&(this.getUser=()=>e.getUser()),e.getClientInfo&&(this.getClientInfo=()=>e.getClientInfo())}canLogin(){var e;return typeof((e=this.cfg)==null?void 0:e.getToken)=="function"}init(e){return X(this,null,function*(){try{const t=yield this.cfg.getToken();t!=null&&t.accessToken&&e.emit(t)}catch(t){}})}login(){return X(this,null,function*(){const e=yield this.cfg.getToken();if(!(e!=null&&e.accessToken))throw new Error("宿主未返回有效令牌");return e})}logout(){return X(this,null,function*(){var e,t;yield(t=(e=this.cfg).logout)==null?void 0:t.call(e)})}}class Zl{constructor(e){te(this,"id","local");te(this,"label","本地账号");te(this,"getUser");this.cfg=e,e.getUser&&(this.getUser=()=>e.getUser())}canLogin(){var e;return typeof((e=this.cfg)==null?void 0:e.login)=="function"}login(){return X(this,null,function*(){throw new Error("请在设置面板的账户中登录")})}logout(){return X(this,null,function*(){var e,t;yield(t=(e=this.cfg).logout)==null?void 0:t.call(e)})}renderLogin(e,t){const l=this.cfg.title||"账号登录";e.innerHTML=`
17
+ <div class="svp-cloud-auth-form">
18
+ <p class="svp-cloud-auth-hint">${l}</p>
19
+ <input class="svp-cloud-auth-input svp-cloud-auth-user" type="text" autocomplete="username" placeholder="账号" />
20
+ <input class="svp-cloud-auth-input svp-cloud-auth-pass" type="password" autocomplete="current-password" placeholder="密码" />
21
+ <div class="svp-cloud-auth-error"></div>
22
+ <div class="svp-cloud-auth-actions">
23
+ <button type="button" class="svp-btn svp-btn-primary svp-btn-sm svp-cloud-auth-submit">登录</button>
24
+ </div>
25
+ </div>`;const s=e.querySelector(".svp-cloud-auth-user"),i=e.querySelector(".svp-cloud-auth-pass"),c=e.querySelector(".svp-cloud-auth-error"),o=e.querySelector(".svp-cloud-auth-submit");o&&(o.onclick=()=>X(this,null,function*(){const p=s.value.trim(),f=i.value;if(!p||!f){c.textContent="请输入账号与密码";return}c.textContent="",o.disabled=!0;const _=o.textContent;o.textContent="登录中...";try{const u=yield this.cfg.login(p,f);if(!(u!=null&&u.accessToken))throw new Error("登录返回的凭据无效");t.emit(u)}catch(u){c.textContent=(u==null?void 0:u.message)||"登录失败"}finally{o.disabled=!1,o.textContent=_}}))}destroyLogin(e){e.innerHTML=""}}class Tt{constructor(){te(this,"id","none");te(this,"label","未配置")}canLogin(){return!1}login(){return X(this,null,function*(){throw new Error("未配置登录方式")})}}function $l(n){if(!n)return[];const e=Array.isArray(n)?n:[n],t=new Set,l=[];for(const s of e){const i=s==null?void 0:s.type;if(i){if(t.has(i)){console.warn(`[cloud] 重复的登录方式已忽略:${i}`);continue}t.add(i),l.push(s)}}return l}function xl(n,e=!1){let t;switch(n.type){case"oauth":t=new Yl(n);break;case"token":t=new Xl(n);break;case"host":t=new Ql(n);break;case"local":t=new Zl(n);break;default:return new Tt}return e&&n.type!=="local"&&(t.autoLogin=!0),t}function en(n){return`${Kl}_${n||"default"}`}function tn(){return ln(Gl,null)||null}function dt(n){nn(Gl,n)}function ln(n,e){var l;const t=globalThis;return(l=t.SVPrint)!=null&&l.getPreferences?t.SVPrint.getPreferences(n,e):Bl.getPreferences(n,e)}function nn(n,e){var l;const t=globalThis;if((l=t.SVPrint)!=null&&l.setPreferences){t.SVPrint.setPreferences(n,e);return}Bl.setPreferences(n,e)}class es{constructor(e){this.key=e}get(){return ln(this.key,null)||null}set(e){nn(this.key,e)}}class ts{constructor(e){this.key=e}get(){var e;try{const t=(e=globalThis.sessionStorage)==null?void 0:e.getItem(this.key);return t?JSON.parse(t):null}catch(t){return null}}set(e){var t,l;try{e?(t=globalThis.sessionStorage)==null||t.setItem(this.key,JSON.stringify(e)):(l=globalThis.sessionStorage)==null||l.removeItem(this.key)}catch(s){}}}class ls{constructor(){te(this,"token",null)}get(){return this.token}set(e){this.token=e}}function sn(n){return new es(n)}function ns(n){return new ts(n)}function ss(){return new ls}function Ct(n,e,t=!1){return n.storageKey?t?`${n.storageKey}_${e}`:n.storageKey:en(e)}function rn(n,e,t=!1){return n.storage?n.storage:sn(Ct(n,e,t))}class on{constructor(e,t){te(this,"client");te(this,"config");te(this,"entries",[]);te(this,"storages",new Map);te(this,"active");te(this,"multi");te(this,"token",null);te(this,"listeners",[]);te(this,"loginEl");this.config=e,this.client=t,this.entries=$l(e.auth).map(s=>({cfg:s,provider:xl(s,!!e.autoLogin)})),this.entries.length||(this.entries=[{cfg:null,provider:new Tt}]),this.multi=this.entries.length>1,this.active=this.pickInitial(),this.token=this.storageOf(this.active).get(),this.client.setTokenGetter(()=>{var s;return((s=this.token)==null?void 0:s.accessToken)||null}),this.client.setOnUnauthorized(()=>this.onUnauthorized());const l=Wl();this.runInit(!l)}pickInitial(){const e=tn(),t=e?this.entries.find(c=>c.provider.id===e):void 0;if(t)return t;const l=this.config.defaultAuth?this.entries.find(c=>c.provider.id===this.config.defaultAuth):void 0;if(l)return dt(l.provider.id),l;const i=this.entries.find(c=>{var o;return(o=this.storageOf(c).get())==null?void 0:o.accessToken})||this.entries[0];return dt(i.provider.id),i}storageOf(e){const t=e.provider.id;let l=this.storages.get(t);return l||(l=rn(this.config,t,this.multi),this.storages.set(t,l)),l}ctx(){return{client:this.client,config:this.config,storage:this.storageOf(this.active),emit:e=>this.writeToken(e)}}runInit(e=!1){var t,l;try{const s=(l=(t=this.active.provider).init)==null?void 0:l.call(t,this.ctx());s&&typeof s.then=="function"&&s.catch(()=>{})}catch(s){}e&&this.maybeAutoLogin()}maybeAutoLogin(){this.active.provider.autoLogin&&(this.isLoggedIn()||!this.canLogin()||this.login().catch(e=>console.warn("[cloud] 自动登录失败:",(e==null?void 0:e.message)||e)))}writeToken(e){this.token=e,this.storageOf(this.active).set(e),this.notify()}notify(){this.listeners.forEach(e=>e(this.token))}onUnauthorized(){this.token&&this.writeToken(null)}get type(){return this.active.provider.id}get label(){return this.active.provider.label}get activeId(){return this.active.provider.id}get providers(){return this.entries.map(e=>({id:e.provider.id,label:e.provider.label,canLogin:e.provider.canLogin()}))}get providerConfig(){return this.active.cfg}get storageKey(){return Ct(this.config,this.active.provider.id,this.multi)}get hasCustomLoginUI(){return typeof this.active.provider.renderLogin=="function"}renderLogin(e){var t,l;this.loginEl=e,(l=(t=this.active.provider).renderLogin)==null||l.call(t,e,this.ctx())}destroyLogin(e){var t,l;(l=(t=this.active.provider).destroyLogin)==null||l.call(t,e),this.loginEl===e&&(this.loginEl=void 0)}switchProvider(e){return X(this,null,function*(){var l,s;const t=this.entries.find(i=>i.provider.id===e);if(!(!t||t===this.active)){if(this.loginEl)try{(s=(l=this.active.provider).destroyLogin)==null||s.call(l,this.loginEl)}catch(i){}this.active=t,dt(e),this.token=this.storageOf(t).get(),this.notify(),this.runInit()}})}canLogin(){return this.active.provider.canLogin()}isLoggedIn(){var e;return!!((e=this.token)!=null&&e.accessToken)}getToken(){var e;return((e=this.token)==null?void 0:e.accessToken)||null}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}login(){return X(this,null,function*(){if(!this.canLogin())throw new Error("未配置登录方式");const e=yield this.active.provider.login(this.ctx());if(!(e!=null&&e.accessToken))throw new Error("登录返回的凭据无效");return this.writeToken(e),e})}logout(){return X(this,null,function*(){var e,t;try{yield(t=(e=this.active.provider).logout)==null?void 0:t.call(e,this.ctx())}catch(l){}this.writeToken(null)})}getUser(){return X(this,null,function*(){const e=this.active.provider.getUser;return e?e(this.ctx()):this.client.get(this.profileUrl(),{auth:!0})})}getClientInfo(){return X(this,null,function*(){const e=this.active.provider.getClientInfo;if(e)return e(this.ctx());const t=this.clientId();return t?this.client.get(`/auth/member/oauth/client/${t}`,{auth:!1}):null})}oauthCfg(){const e=this.active.cfg;return e&&e.type==="oauth"?e:null}profileUrl(){var e;return((e=this.oauthCfg())==null?void 0:e.getProfileUrl)||"/auth/member/profile"}clientId(){var e;return(e=this.oauthCfg())==null?void 0:e.clientId}}const is="/api/socket.io",Jt="/socket.io";class cn{constructor(e){te(this,"host");te(this,"socket",null);te(this,"connecting",null);te(this,"generation",0);te(this,"printing",!1);te(this,"pending",new Set);te(this,"stateListeners",new Set);te(this,"handlers",new Map);this.host=(e.host||"").replace(/\/+$/,"")}onConnectionChange(e){return this.stateListeners.add(e),e(this.isConnected()),()=>this.stateListeners.delete(e)}notifyState(){for(const e of this.stateListeners)e(this.isConnected())}failPending(e){for(const t of[...this.pending])t(e)}getIo(){const e=globalThis.io;if(!e)throw new Error("未检测到 socket.io(window.io),无法连接中转服务");return e}resolveBase(){var t;const e=((t=globalThis.location)==null?void 0:t.origin)||"";if(!this.host)return{origin:e,path:is};if(/^https?:\/\//i.test(this.host)){const l=new URL(this.host);return{origin:l.origin,path:`${l.pathname.replace(/\/+$/,"")}${Jt}`}}return{origin:e,path:`${this.host.replace(/\/+$/,"")}${Jt}`}}ensureNetworkPermission(){return X(this,null,function*(){try{const e=globalThis.hiwebSocket;if(e!=null&&e.requestNetworkPermission){const t=yield e.requestNetworkPermission();if(t&&t.granted===!1)throw new Error(t.msg||"本地网络访问权限被拒绝")}}catch(e){if(e!=null&&e.message)throw e}})}attachHandlers(e){for(const[t,l]of this.handlers)for(const s of l)e.on(t,s)}on(e,t){var l,s;this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t),(s=(l=this.socket)==null?void 0:l.on)==null||s.call(l,e,t)}off(e,t){var l,s,i,c,o;t?((l=this.handlers.get(e))==null||l.delete(t),(i=(s=this.socket)==null?void 0:s.off)==null||i.call(s,e,t)):(this.handlers.delete(e),(o=(c=this.socket)==null?void 0:c.off)==null||o.call(c,e))}waitFor(e,t=15e3){return new Promise((l,s)=>{const i=()=>{clearTimeout(p),this.off(e,o),this.pending.delete(c)},c=f=>{i(),s(f)},o=f=>{i(),l(f)},p=setTimeout(()=>c(new Error(`等待中转事件 ${e} 超时`)),t);this.pending.add(c),this.on(e,o)})}emit(e,t={}){var l;return(l=this.socket)!=null&&l.connected?(this.socket.emit(e,t),!0):!1}connect(e){return X(this,null,function*(){var s;if((s=this.socket)!=null&&s.connected)return this.socket;if(this.connecting)return this.connecting;this.disconnect();const t=this.generation,l=X(this,null,function*(){if(yield this.ensureNetworkPermission(),t!==this.generation)throw new Error("中转连接已取消");const i=this.getIo(),c=`/${(e.namespace||"transit").replace(/^\/+/,"")}`,{origin:o,path:p}=this.resolveBase();return new Promise((f,_)=>{const u=i(`${o}${c}`,{auth:{token:e.ticket,clientType:"web"},path:p,transports:["websocket","polling"],reconnection:!0});this.socket=u;const v=()=>{clearTimeout(C),u.off("connect",P),this.pending.delete(m)},m=w=>{v(),this.socket===u&&this.disconnect(),_(w)},P=()=>{v(),f(u)},C=setTimeout(()=>m(new Error("连接中转服务超时")),1e4);this.pending.add(m),this.attachHandlers(u),u.on("connect",P),u.on("connect",()=>this.notifyState()),u.on("disconnect",()=>{this.notifyState(),this.failPending(new Error("中转连接已断开,打印结果可能未知,请勿自动重试"))}),u.on("connect_error",w=>{m(new Error((w==null?void 0:w.message)||"连接中转服务失败"))})})});this.connecting=l;try{return yield l}finally{this.connecting===l&&(this.connecting=null)}})}getClients(e=8e3){return X(this,null,function*(){if(!this.isConnected())throw new Error("中转服务未连接");const t=this.waitFor("clients",e);this.emit("getClients",{});const l=yield t;return Array.isArray(l)?l:l&&typeof l=="object"?Object.values(l):[]})}getPrinters(e,t=6e3){return X(this,null,function*(){const l=Date.now()+t;let s=yield this.getClients(Math.max(1,t)),i=e?s.find(o=>o.clientId===e):s.find(o=>o.clientType==="electron");if(!i)throw new Error("目标中转客户端已离线");if(Array.isArray(i.printerList))return i.printerList;const c=i.clientId;if(!this.emit("refreshPrinterList",{client:c}))throw new Error("中转服务未连接");for(;Date.now()<l;){if(yield new Promise(o=>setTimeout(o,Math.min(250,l-Date.now()))),s=yield this.getClients(Math.max(1,l-Date.now())),i=s.find(o=>o.clientId===c),!i)throw new Error("目标中转客户端已离线");if(Array.isArray(i.printerList))return i.printerList}throw new Error("获取中转打印机列表超时")})}print(e,t=6e4){return X(this,null,function*(){var l;if(!(e!=null&&e.client))throw new Error("缺少目标客户端 client");if(!((l=this.socket)!=null&&l.connected))throw new Error("中转服务未连接");if(this.printing)throw new Error("已有中转打印等待回执,请稍后再试");this.printing=!0;try{return yield new Promise((s,i)=>{const c=()=>{clearTimeout(_),this.off("success",p),this.off("error",f),this.pending.delete(o)},o=u=>{c(),i(u)},p=u=>{c(),s(u||{})},f=u=>o(new Error((u==null?void 0:u.msg)||"客户端打印失败")),_=setTimeout(()=>{o(new Error("等待打印回执超时,打印结果未知,请勿自动重试")),this.disconnect()},t);this.pending.add(o),this.on("success",p),this.on("error",f);try{this.socket.emit("print",e)}catch(u){o(u instanceof Error?u:new Error(String(u)))}})}finally{this.printing=!1}})}isConnected(){var e;return!!((e=this.socket)!=null&&e.connected)}disconnect(){var e,t,l,s;this.generation++,this.connecting=null,this.failPending(new Error("中转连接已断开,打印结果可能未知,请勿自动重试"));try{(t=(e=this.socket)==null?void 0:e.removeAllListeners)==null||t.call(e),(s=(l=this.socket)==null?void 0:l.disconnect)==null||s.call(l)}catch(i){}this.socket=null,this.notifyState()}}class an{constructor(e,t,l,s){te(this,"client");te(this,"transit");te(this,"auth");te(this,"config");this.config=e,this.client=t,this.transit=l,this.auth=s}requireLogin(){var e;if(!((e=this.auth)!=null&&e.canLogin()))throw new Error("未配置登录方式");if(!this.auth.isLoggedIn())throw new Error("请先登录后再使用模板")}render(){return X(this,arguments,function*(e={}){var s,i,c,o;const t=this.du(),l={template:(c=e.template)!=null?c:(i=(s=t==null?void 0:t.printTemplate)==null?void 0:s.getJson)==null?void 0:i.call(s),print_data:(o=e.print_data)!=null?o:t==null?void 0:t.printData,options:e.options,renderer_id:e.renderer_id,type:e.type};return e.template_id!==void 0&&(delete l.template,l.template_id=e.template_id),this.client.post(e.sync?"/print/render/sync":"/print/render",{body:l})})}getRenderTask(e){return this.client.get(`/print/render/tasks/${e}`)}waitRender(l){return X(this,arguments,function*(e,t={}){var o,p;const s=(o=t.interval)!=null?o:1500,i=(p=t.timeout)!=null?p:6e4,c=Date.now();for(;;){const f=yield this.getRenderTask(e),_=Number(f.status);if(_===2)return f;if(_===3||_===4||_===5)throw new Error(f.error_message||`渲染失败(status=${_})`);if(Date.now()-c>i)throw new Error("渲染超时");yield new Promise(u=>setTimeout(u,s))}})}cloudPrint(e){var i,c,o,p;const t=this.du(),l=f=>typeof f=="string"?f:JSON.stringify(f),s={device_id:e.device_id,template_id:e.template_id,template_data:l((o=e.template_data)!=null?o:(c=(i=t==null?void 0:t.printTemplate)==null?void 0:i.getJson)==null?void 0:c.call(i)),preview_data:l((p=e.preview_data)!=null?p:t==null?void 0:t.printData),print_type:e.print_type,print_options:l(e.print_options),remark:e.remark};return this.client.post("/member/cloud/print/submit",{body:s})}getDevices(){return this.client.get("/member/cloud/device")}getDevicePrinters(e){return this.client.get(`/member/cloud/device/${encodeURIComponent(e)}/printers`)}getJobs(e){return this.client.get("/member/cloud/print/jobs",{params:e})}cancelJob(e){return this.client.post(`/member/cloud/print/jobs/${e}/cancel`)}retryJob(e){return this.client.post(`/member/cloud/print/jobs/${e}/retry`)}getTransitTicket(){return this.client.post("/member/transit/ticket",{body:{}})}onTransitConnectionChange(e){return this.transit.onConnectionChange(e)}ensureTransitConnected(){return X(this,null,function*(){if(!this.transit.isConnected()){const e=yield this.getTransitTicket();yield this.transit.connect(e)}return this.transit})}getTransitClients(){return X(this,null,function*(){return(yield this.ensureTransitConnected()).getClients()})}getTransitPrinters(e){return X(this,null,function*(){return(yield this.ensureTransitConnected()).getPrinters(e)})}transitPrint(){return X(this,arguments,function*(e={}){var o,p,f,_,u;if(!e.clientId)throw new Error("请选择目标中转客户端");if(!e.printer)throw new Error("请选择打印机");const t=yield this.ensureTransitConnected(),l=this.du(),s=(f=e.template)!=null?f:(p=(o=l==null?void 0:l.printTemplate)==null?void 0:o.getJson)==null?void 0:p.call(o),i=typeof s=="string"?s:JSON.stringify(s!=null?s:null),c=typeof e.print_options=="string"?e.print_options:e.print_options?JSON.stringify(e.print_options):void 0;return t.print({client:e.clientId,template:i,printer:e.printer,template_snapshot:i,preview_data:(u=(_=e.preview_data)!=null?_:l==null?void 0:l.printData)!=null?u:null,print_type:e.print_type||"template",print_options:c})})}disconnectTransit(){this.transit.disconnect()}listTemplates(e={}){var t,l,s;return this.client.get("/print/template",{auth:!1,params:{keyword:e.keyword,category_id:e.category_id,industry_id:e.industry_id,template_type:e.template_type,is_free:e.is_free,is_recommend:e.is_recommend,page:(t=e.page)!=null?t:1,pageSize:(s=(l=e.pageSize)!=null?l:this.config.templateCenterPageSize)!=null?s:12}})}getTemplateData(e){return this.client.get(`/print/template/${e}/data`)}applyTemplate(e){return X(this,null,function*(){var c,o;this.requireLogin();const t=yield this.getTemplateData(e.template_id),l=this.parseMaybeJson((c=t==null?void 0:t.template_data)!=null?c:t),s=this.parseMaybeJson(t==null?void 0:t.preview_data),i=this.du();if(!((o=i==null?void 0:i.printTemplate)!=null&&o.update))throw new Error("设计器未就绪");return i.printTemplate.update(l),s!=null&&(i.printData=s),this.useTemplate(e.template_id).catch(()=>{}),{template_data:l,preview_data:s}})}useRandomTemplate(){return X(this,arguments,function*(e={}){var _;this.requireLogin();const t=(_=e.pageSize)!=null?_:20,l=yield this.listTemplates(Xe(Ge({},e),{page:1,pageSize:t})),s=l.total||0;if(!s&&!(l.list||[]).length)throw new Error("没有可用模板");const i=Math.max(1,Math.ceil(s/t)),c=Math.floor(Math.random()*i)+1,p=((c===1?l:yield this.listTemplates(Xe(Ge({},e),{page:c,pageSize:t}))).list||[]).slice();for(let u=p.length-1;u>0;u--){const v=Math.floor(Math.random()*(u+1));[p[u],p[v]]=[p[v],p[u]]}let f=null;for(const u of p.slice(0,5))try{return yield this.applyTemplate(u),u}catch(v){f=v}throw f||new Error("没有可用模板")})}parseMaybeJson(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}useTemplate(e){return this.client.post(`/print/template/use/${e}`)}getCategories(){return this.client.get("/print/category",{auth:!1})}getIndustries(){return this.client.get("/print/industry",{auth:!1})}du(){return globalThis.__cloudDesignerUtils}}let st;function rs(n){st=n,typeof globalThis!="undefined"&&(globalThis.__cloudDesignerUtils=n)}function Rt(){return st||(typeof globalThis!="undefined"&&globalThis.__cloudDesignerUtils&&(st=globalThis.__cloudDesignerUtils),st)}let lt;function os(n){lt=n}function cs(){return lt}function un(n){if((lt==null?void 0:lt.config)===n)return lt;const e=new jl(n),t=new on(n,e),l=new cn(n),s=new an(n,e,l,t),i={config:n,client:e,auth:t,transit:l,service:s};return os(i),i}const as=n=>({hook:"onDesigned",name:"cloudOnDesigned",description:"云打印插件 - 挂载模板中心/API/菜单",priority:1,run:({designerUtils:e})=>{const t=globalThis,{auth:l,service:s}=un(n);rs(e),setTimeout(()=>{const i=t.$("#SVPrint");if(!i||!i.length){console.warn("[cloud] #SVPrint not found");return}Promise.resolve().then(()=>Us).then(({default:c})=>{var _;let o=null;try{o=new c({target:i[0],props:{auth:l,service:s,designerUtils:e,pageSize:(_=n.templateCenterPageSize)!=null?_:12}})}catch(u){console.error("[cloud] template center mount error:",u)}const f={render:u=>s.render(u),getRenderTask:u=>s.getRenderTask(u),cloudPrint:u=>s.cloudPrint(u),getDevices:()=>s.getDevices(),getDevicePrinters:u=>s.getDevicePrinters(u),getJobs:u=>s.getJobs(u),cancelJob:u=>s.cancelJob(u),retryJob:u=>s.retryJob(u),transitPrint:u=>s.transitPrint(u),getTransitClients:()=>s.getTransitClients(),getTransitPrinters:u=>s.getTransitPrinters(u),applyTemplate:u=>s.applyTemplate(u),useRandomTemplate:u=>s.useRandomTemplate(u),templateCenter:{show:()=>{var u;return(u=o==null?void 0:o.show)==null?void 0:u.call(o)},hide:()=>{var u;return(u=o==null?void 0:o.hide)==null?void 0:u.call(o)},toggle:()=>{var u;return(u=o==null?void 0:o.toggle)==null?void 0:u.call(o)},isOpen:()=>{var u;return!!((u=o==null?void 0:o.isOpen)!=null&&u.call(o))},list:u=>s.listTemplates(u)},auth:{type:l.type,label:l.label,providers:l.providers,activeId:l.activeId,switchProvider:u=>l.switchProvider(u),canLogin:()=>l.canLogin(),isLoggedIn:()=>l.isLoggedIn(),getToken:()=>l.getToken(),login:()=>l.login(),logout:()=>l.logout(),getUser:()=>l.getUser(),getClientInfo:()=>l.getClientInfo(),onChange:u=>l.onChange(u)},config:n};e.cloud=f,Xn(e,n,()=>{var u;return(u=o==null?void 0:o.show)==null?void 0:u.call(o)}),e.printTemplate&&yt(e.printTemplate,s)}).catch(c=>{console.error("[cloud] component init error:",c)})},200)}}),mt=new WeakMap,us=n=>({hook:"onSettings",name:"cloudOnSettings",description:"云打印插件 - 设置面板 tab",priority:1,run:e=>{if((e==null?void 0:e.type)==="tabs"&&n.enableSettingsTab!==!1)return{key:"cloud",label:"云打印",icon:"sv-cloud",sort:n.settingsTabSort||2,render:t=>{const l=cs();if(!l){t.innerHTML='<div class="settings-empty">云打印插件未初始化</div>';return}Promise.resolve().then(()=>Hi).then(({default:s})=>{const i=new s({target:t,props:{config:l.config,auth:l.auth,service:l.service}});mt.set(t,i)})},destroy:t=>{var s;const l=mt.get(t);(s=l==null?void 0:l.$destroy)==null||s.call(l),mt.delete(t)}}}}),fs=n=>({hook:"newPrintTemplate",name:"cloudNewPrintTemplate",description:"云打印插件 - 模板扩展",priority:1,run:({template:e})=>{if(!e)return;const t=un(n);yt(e,t.service)}});function ds(n={}){return{name:"cloud",description:"sv-print plugin: cloud",hooks:[as(n),us(n),fs(n)],leastHiprintVersion:"0.3.42"}}function fe(){}function fn(n){return n()}function Ht(){return Object.create(null)}function ze(n){n.forEach(fn)}function dn(n){return typeof n=="function"}function ps(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}let ft;function Ue(n,e){return ft||(ft=document.createElement("a")),ft.href=e,n===ft.href}function zt(n,e){return n!=n?e==e:n!==e}function _s(n){return Object.keys(n).length===0}function Ke(n){return n==null?"":n}function r(n,e){n.appendChild(e)}function k(n,e,t){n.insertBefore(e,t||null)}function g(n){n.parentNode&&n.parentNode.removeChild(n)}function hs(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function d(n){return document.createElement(n)}function E(n){return document.createTextNode(n)}function T(){return E(" ")}function $e(){return E("")}function Y(n,e,t,l){return n.addEventListener(e,t,l),()=>n.removeEventListener(e,t,l)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function vs(n){let e;return{p(...t){e=t,e.forEach(l=>n.push(l))},r(){e.forEach(t=>n.splice(n.indexOf(t),1))}}}function Fe(n){return n===""?null:+n}function ms(n){return Array.from(n.childNodes)}function V(n,e){e=""+e,n.data!==e&&(n.data=e)}function Ee(n,e){n.value=e==null?"":e}function Oe(n,e,t,l){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}function Ie(n,e,t){for(let l=0;l<n.options.length;l+=1){const s=n.options[l];if(s.__value===e){s.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function We(n){const e=n.querySelector(":checked");return e&&e.__value}function qe(n,e,t){n.classList[t?"add":"remove"](e)}let rt;function it(n){rt=n}function bs(){if(!rt)throw new Error("Function called outside component initialization");return rt}function gs(n){bs().$$.on_mount.push(n)}const tt=[],ot=[];let nt=[];const gt=[],ks=Promise.resolve();let kt=!1;function ys(){kt||(kt=!0,ks.then(_n))}function Je(n){nt.push(n)}function pn(n){gt.push(n)}const bt=new Set;let et=0;function _n(){if(et!==0)return;const n=rt;do{try{for(;et<tt.length;){const e=tt[et];et++,it(e),ws(e.$$)}}catch(e){throw tt.length=0,et=0,e}for(it(null),tt.length=0,et=0;ot.length;)ot.pop()();for(let e=0;e<nt.length;e+=1){const t=nt[e];bt.has(t)||(bt.add(t),t())}nt.length=0}while(tt.length);for(;gt.length;)gt.pop()();kt=!1,bt.clear(),it(n)}function ws(n){if(n.fragment!==null){n.update(),ze(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Je)}}function Ts(n){const e=[],t=[];nt.forEach(l=>n.indexOf(l)===-1?e.push(l):t.push(l)),t.forEach(l=>l()),nt=e}const pt=new Set;let Qe;function St(){Qe={r:0,c:[],p:Qe}}function Pt(){Qe.r||ze(Qe.c),Qe=Qe.p}function De(n,e){n&&n.i&&(pt.delete(n),n.i(e))}function Ye(n,e,t,l){if(n&&n.o){if(pt.has(n))return;pt.add(n),Qe.c.push(()=>{pt.delete(n),l&&(t&&n.d(1),l())}),n.o(e)}else l&&l()}function Re(n,e){n.d(1),e.delete(n.key)}function He(n,e,t,l,s,i,c,o,p,f,_,u){let v=n.length,m=i.length,P=v;const C={};for(;P--;)C[n[P].key]=P;const w=[],b=new Map,h=new Map,z=[];for(P=m;P--;){const y=u(s,i,P),L=t(y);let M=c.get(L);M?z.push(()=>M.p(y,e)):(M=f(L,y),M.c()),b.set(L,w[P]=M),L in C&&h.set(L,Math.abs(P-C[L]))}const D=new Set,J=new Set;function H(y){De(y,1),y.m(o,_),c.set(y.key,y),_=y.first,m--}for(;v&&m;){const y=w[m-1],L=n[v-1],M=y.key,A=L.key;y===L?(_=y.first,v--,m--):b.has(A)?!c.has(M)||D.has(M)?H(y):J.has(A)?v--:h.get(M)>h.get(A)?(J.add(M),H(y)):(D.add(A),v--):(p(L,c),v--)}for(;v--;){const y=n[v];b.has(y.key)||p(y,c)}for(;m;)H(w[m-1]);return ze(z),w}function hn(n,e,t){const l=n.$$.props[e];l!==void 0&&(n.$$.bound[l]=t,t(n.$$.ctx[l]))}function vn(n){n&&n.c()}function Et(n,e,t,l){const{fragment:s,after_update:i}=n.$$;s&&s.m(e,t),l||Je(()=>{const c=n.$$.on_mount.map(fn).filter(dn);n.$$.on_destroy?n.$$.on_destroy.push(...c):ze(c),n.$$.on_mount=[]}),i.forEach(Je)}function Lt(n,e){const t=n.$$;t.fragment!==null&&(Ts(t.after_update),ze(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Cs(n,e){n.$$.dirty[0]===-1&&(tt.push(n),ys(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function It(n,e,t,l,s,i,c,o=[-1]){const p=rt;it(n);const f=n.$$={fragment:null,ctx:[],props:i,update:fe,not_equal:s,bound:Ht(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(p?p.$$.context:[])),callbacks:Ht(),dirty:o,skip_bound:!1,root:e.target||(p?p.$$.root:null)};c&&c(f.root);let _=!1;if(f.ctx=t?t(n,e.props||{},(u,v,...m)=>{const P=m.length?m[0]:v;return f.ctx&&s(f.ctx[u],f.ctx[u]=P)&&(!f.skip_bound&&f.bound[u]&&f.bound[u](P),_&&Cs(n,u)),v}):[],f.update(),_=!0,ze(f.before_update),f.fragment=l?l(f.ctx):!1,e.target){if(e.hydrate){const u=ms(e.target);f.fragment&&f.fragment.l(u),u.forEach(g)}else f.fragment&&f.fragment.c();e.intro&&De(n.$$.fragment),Et(n,e.target,e.anchor,e.customElement),_n()}it(p)}class qt{$destroy(){Lt(this,1),this.$destroy=fe}$on(e,t){if(!dn(t))return fe;const l=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return l.push(t),()=>{const s=l.indexOf(t);s!==-1&&l.splice(s,1)}}$set(e){this.$$set&&!_s(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function Bt(n,e,t){const l=n.slice();return l[46]=e[t],l}function jt(n,e,t){const l=n.slice();return l[49]=e[t],l}function Ft(n,e,t){const l=n.slice();return l[52]=e[t],l}function Kt(n){let e,t,l;return{c(){e=d("button"),e.textContent="×",a(e,"class","tc-search-clear svelte-1qg2qyu"),a(e,"aria-label","清空搜索")},m(s,i){k(s,e,i),t||(l=Y(e,"click",n[17]),t=!0)},p:fe,d(s){s&&g(e),t=!1,l()}}}function Gt(n,e){let t,l=e[52].industry_name+"",s,i,c;function o(){return e[33](e[52])}return{key:n,first:null,c(){t=d("button"),s=E(l),a(t,"class","tc-chip svelte-1qg2qyu"),qe(t,"active",e[2]===e[52].industry_id),this.first=t},m(p,f){k(p,t,f),r(t,s),i||(c=Y(t,"click",o),i=!0)},p(p,f){e=p,f[0]&2048&&l!==(l=e[52].industry_name+"")&&V(s,l),f[0]&2052&&qe(t,"active",e[2]===e[52].industry_id)},d(p){p&&g(t),i=!1,c()}}}function Vt(n,e){let t,l=e[49].category_name+"",s,i,c;function o(){return e[35](e[49])}return{key:n,first:null,c(){t=d("button"),s=E(l),a(t,"class","tc-chip svelte-1qg2qyu"),qe(t,"active",e[10]===e[49].category_id),this.first=t},m(p,f){k(p,t,f),r(t,s),i||(c=Y(t,"click",o),i=!0)},p(p,f){e=p,f[0]&8192&&l!==(l=e[49].category_name+"")&&V(s,l),f[0]&9216&&qe(t,"active",e[10]===e[49].category_id)},d(p){p&&g(t),i=!1,c()}}}function zs(n){let e;return{c(){e=d("div"),e.textContent="暂无模板",a(e,"class","settings-empty")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function Ss(n){let e;return{c(){e=d("div"),e.textContent="加载中...",a(e,"class","settings-empty")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function Ps(n){let e,t;return{c(){e=d("div"),t=E(n[6]),a(e,"class","settings-empty")},m(l,s){k(l,e,s),r(e,t)},p(l,s){s[0]&64&&V(t,l[6])},d(l){l&&g(e)}}}function Es(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-preview"></i>',a(e,"class","tc-noimg svelte-1qg2qyu")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function Ls(n){let e,t,l;return{c(){e=d("img"),Ue(e.src,t=n[46].preview_img)||a(e,"src",t),a(e,"alt",l=n[46].template_name),a(e,"loading","lazy"),a(e,"class","svelte-1qg2qyu")},m(s,i){k(s,e,i)},p(s,i){i[0]&128&&!Ue(e.src,t=s[46].preview_img)&&a(e,"src",t),i[0]&128&&l!==(l=s[46].template_name)&&a(e,"alt",l)},d(s){s&&g(e)}}}function Wt(n){let e;return{c(){e=d("span"),e.textContent="查看大图",a(e,"class","tc-zoom svelte-1qg2qyu")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function Is(n){var i;let e,t=((i=n[46].price)!=null?i:0)+"",l,s;return{c(){e=d("span"),l=E(t),s=E(" 积分"),a(e,"class","tc-tag paid svelte-1qg2qyu")},m(c,o){k(c,e,o),r(e,l),r(e,s)},p(c,o){var p;o[0]&128&&t!==(t=((p=c[46].price)!=null?p:0)+"")&&V(l,t)},d(c){c&&g(e)}}}function qs(n){let e;return{c(){e=d("span"),e.textContent="免费",a(e,"class","tc-tag svelte-1qg2qyu")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function Yt(n){let e;return{c(){e=d("span"),e.textContent="推荐",a(e,"class","tc-tag rec svelte-1qg2qyu")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function Xt(n){let e,t=n[46].industry_name+"",l;return{c(){e=d("span"),l=E(t),a(e,"class","tc-tag plain svelte-1qg2qyu")},m(s,i){k(s,e,i),r(e,l)},p(s,i){i[0]&128&&t!==(t=s[46].industry_name+"")&&V(l,t)},d(s){s&&g(e)}}}function Qt(n){let e,t=n[46].category_name+"",l;return{c(){e=d("span"),l=E(t),a(e,"class","tc-tag plain svelte-1qg2qyu")},m(s,i){k(s,e,i),r(e,l)},p(s,i){i[0]&128&&t!==(t=s[46].category_name+"")&&V(l,t)},d(s){s&&g(e)}}}function Zt(n,e){var ke,Se;let t,l,s,i,c,o,p=e[46].template_name+"",f,_,u,v,m,P,C,w,b,h,z,D,J=((ke=e[46].use_cnt)!=null?ke:0)+"",H,y,L,M,A=((Se=e[46].share_cnt)!=null?Se:0)+"",j,K,I,N,O,U,ee;function he(ve,F){return ve[46].preview_img?Ls:Es}let W=he(e),B=W(e),Q=e[46].preview_img&&Wt();function q(){return e[36](e[46])}function G(ve,F){return ve[46].is_free?qs:Is}let x=G(e),de=x(e),pe=e[46].is_recommend&&Yt(),re=e[46].industry_name&&Xt(e),le=e[46].category_name&&Qt(e);function me(){return e[37](e[46])}return{key:n,first:null,c(){t=d("div"),l=d("div"),B.c(),s=T(),Q&&Q.c(),i=T(),c=d("div"),o=d("div"),f=E(p),u=T(),v=d("div"),de.c(),m=T(),pe&&pe.c(),P=T(),re&&re.c(),C=T(),le&&le.c(),w=T(),b=d("div"),h=d("div"),z=d("span"),D=E("使用 "),H=E(J),y=T(),L=d("span"),M=E("分享 "),j=E(A),K=T(),I=d("button"),N=E("去使用"),O=T(),a(l,"class","tc-thumb svelte-1qg2qyu"),a(o,"class","tc-name svelte-1qg2qyu"),a(o,"title",_=e[46].template_name),a(v,"class","tc-tags svelte-1qg2qyu"),a(c,"class","tc-meta svelte-1qg2qyu"),a(z,"title","使用量"),a(L,"title","分享量"),a(h,"class","tc-stats svelte-1qg2qyu"),a(I,"class","svp-btn svp-btn-xs svp-btn-primary tc-use svelte-1qg2qyu"),I.disabled=e[5],a(b,"class","tc-actions svelte-1qg2qyu"),a(t,"class","tc-card svelte-1qg2qyu"),this.first=t},m(ve,F){k(ve,t,F),r(t,l),B.m(l,null),r(l,s),Q&&Q.m(l,null),r(t,i),r(t,c),r(c,o),r(o,f),r(c,u),r(c,v),de.m(v,null),r(v,m),pe&&pe.m(v,null),r(v,P),re&&re.m(v,null),r(v,C),le&&le.m(v,null),r(t,w),r(t,b),r(b,h),r(h,z),r(z,D),r(z,H),r(h,y),r(h,L),r(L,M),r(L,j),r(b,K),r(b,I),r(I,N),r(t,O),U||(ee=[Y(l,"click",q),Y(I,"click",me)],U=!0)},p(ve,F){var _e,ie;e=ve,W===(W=he(e))&&B?B.p(e,F):(B.d(1),B=W(e),B&&(B.c(),B.m(l,s))),e[46].preview_img?Q||(Q=Wt(),Q.c(),Q.m(l,null)):Q&&(Q.d(1),Q=null),F[0]&128&&p!==(p=e[46].template_name+"")&&V(f,p),F[0]&128&&_!==(_=e[46].template_name)&&a(o,"title",_),x===(x=G(e))&&de?de.p(e,F):(de.d(1),de=x(e),de&&(de.c(),de.m(v,m))),e[46].is_recommend?pe||(pe=Yt(),pe.c(),pe.m(v,P)):pe&&(pe.d(1),pe=null),e[46].industry_name?re?re.p(e,F):(re=Xt(e),re.c(),re.m(v,C)):re&&(re.d(1),re=null),e[46].category_name?le?le.p(e,F):(le=Qt(e),le.c(),le.m(v,null)):le&&(le.d(1),le=null),F[0]&128&&J!==(J=((_e=e[46].use_cnt)!=null?_e:0)+"")&&V(H,J),F[0]&128&&A!==(A=((ie=e[46].share_cnt)!=null?ie:0)+"")&&V(j,A),F[0]&32&&(I.disabled=e[5])},d(ve){ve&&g(t),B.d(),Q&&Q.d(),de.d(),pe&&pe.d(),re&&re.d(),le&&le.d(),U=!1,ze(ee)}}}function $t(n){let e,t,l,s,i,c,o;return{c(){e=d("div"),t=d("img"),s=T(),i=d("button"),i.innerHTML='<i class="svicon sv-close"></i>',Ue(t.src,l=n[12])||a(t,"src",l),a(t,"alt","模板预览"),a(t,"class","svelte-1qg2qyu"),a(i,"class","svp-cloud-tc-preview-close svelte-1qg2qyu"),a(i,"aria-label","关闭"),a(e,"class","svp-cloud-tc-preview svelte-1qg2qyu")},m(p,f){k(p,e,f),r(e,t),r(e,s),r(e,i),c||(o=[Y(i,"click",n[40]),Y(e,"click",n[41])],c=!0)},p(p,f){f[0]&4096&&!Ue(t.src,l=p[12])&&a(t,"src",l)},d(p){p&&g(e),c=!1,ze(o)}}}function Ms(n){let e,t,l,s,i,c,o,p,f,_,u,v,m,P,C,w,b,h=[],z=new Map,D,J,H,y,L,M,A=[],j=new Map,K,I,N,O,U=[],ee=new Map,he,W,B,Q,q,G,x,de,pe,re,le,me,ke,Se,ve,F,_e,ie,oe,ue,be,ce,ge=n[9]&&Kt(n),Pe=n[11];const Me=R=>R[52].industry_id;for(let R=0;R<Pe.length;R+=1){let Z=Ft(n,Pe,R),ne=Me(Z);z.set(ne,h[R]=Gt(ne,Z))}let Be=n[13];const Ne=R=>R[49].category_id;for(let R=0;R<Be.length;R+=1){let Z=jt(n,Be,R),ne=Ne(Z);j.set(ne,A[R]=Vt(ne,Z))}function je(R,Z){if(R[6])return Ps;if(R[4]&&R[7].length===0)return Ss;if(R[7].length===0)return zs}let ye=je(n),we=ye&&ye(n),Ae=n[7];const Ve=R=>R[46].template_id;for(let R=0;R<Ae.length;R+=1){let Z=Bt(n,Ae,R),ne=Ve(Z);ee.set(ne,U[R]=Zt(ne,Z))}let Ce=n[12]&&$t(n);return{c(){e=d("div"),t=d("div"),l=d("div"),s=d("div"),s.textContent="模板中心",i=T(),c=d("div"),o=d("input"),p=T(),ge&&ge.c(),f=T(),_=d("button"),_.innerHTML='<i class="svicon sv-close"></i>',u=T(),v=d("div"),m=d("div"),P=d("span"),P.textContent="行业",C=T(),w=d("button"),w.textContent="全部",b=T();for(let R=0;R<h.length;R+=1)h[R].c();D=T(),J=d("div"),H=d("span"),H.textContent="分类",y=T(),L=d("button"),L.textContent="全部",M=T();for(let R=0;R<A.length;R+=1)A[R].c();K=T(),I=d("div"),we&&we.c(),N=T(),O=d("div");for(let R=0;R<U.length;R+=1)U[R].c();he=T(),W=d("div"),B=d("button"),Q=E("上一页"),G=T(),x=d("span"),de=E(n[8]),pe=E(" / "),re=E(n[14]),le=E("(共 "),me=E(n[1]),ke=E(")"),Se=T(),ve=d("button"),F=E("下一页"),oe=T(),Ce&&Ce.c(),ue=$e(),a(s,"class","svp-cloud-tc-title svelte-1qg2qyu"),a(o,"class","svp-input svp-cloud-tc-search svelte-1qg2qyu"),a(o,"placeholder","搜索模板名称"),a(c,"class","tc-search-wrap svelte-1qg2qyu"),a(_,"class","svp-btn svp-btn-xs svp-btn-outline"),a(_,"aria-label","关闭"),a(l,"class","svp-cloud-tc-head svelte-1qg2qyu"),a(P,"class","tc-filter-label svelte-1qg2qyu"),a(w,"class","tc-chip svelte-1qg2qyu"),qe(w,"active",n[2]===""),a(m,"class","tc-filter svelte-1qg2qyu"),a(H,"class","tc-filter-label svelte-1qg2qyu"),a(L,"class","tc-chip svelte-1qg2qyu"),qe(L,"active",n[10]===""),a(J,"class","tc-filter svelte-1qg2qyu"),a(v,"class","svp-cloud-tc-filters svelte-1qg2qyu"),a(O,"class","svp-cloud-tc-grid svelte-1qg2qyu"),a(I,"class","svp-cloud-tc-body svelte-1qg2qyu"),a(B,"class","svp-btn svp-btn-xs svp-btn-outline"),B.disabled=q=n[8]<=1||n[4],a(x,"class","tc-page svelte-1qg2qyu"),a(ve,"class","svp-btn svp-btn-xs svp-btn-outline"),ve.disabled=_e=n[8]>=n[14]||n[4],a(W,"class","svp-cloud-tc-foot svelte-1qg2qyu"),a(t,"class","svp-modal-box svp-cloud-tc-box svelte-1qg2qyu"),a(t,"role","dialog"),a(t,"aria-modal","true"),a(e,"class",ie=Ke(`svp-modal svp-cloud-tc ${n[3]?"svp-modal-open modal-open":""}`)+" svelte-1qg2qyu")},m(R,Z){k(R,e,Z),r(e,t),r(t,l),r(l,s),r(l,i),r(l,c),r(c,o),Ee(o,n[9]),r(c,p),ge&&ge.m(c,null),r(l,f),r(l,_),r(t,u),r(t,v),r(v,m),r(m,P),r(m,C),r(m,w),r(m,b);for(let ne=0;ne<h.length;ne+=1)h[ne]&&h[ne].m(m,null);r(v,D),r(v,J),r(J,H),r(J,y),r(J,L),r(J,M);for(let ne=0;ne<A.length;ne+=1)A[ne]&&A[ne].m(J,null);r(t,K),r(t,I),we&&we.m(I,null),r(I,N),r(I,O);for(let ne=0;ne<U.length;ne+=1)U[ne]&&U[ne].m(O,null);r(t,he),r(t,W),r(W,B),r(B,Q),r(W,G),r(W,x),r(x,de),r(x,pe),r(x,re),r(x,le),r(x,me),r(x,ke),r(W,Se),r(W,ve),r(ve,F),k(R,oe,Z),Ce&&Ce.m(R,Z),k(R,ue,Z),be||(ce=[Y(o,"input",n[31]),Y(o,"input",n[16]),Y(_,"click",n[0]),Y(w,"click",n[32]),Y(L,"click",n[34]),Y(B,"click",n[38]),Y(ve,"click",n[39]),Y(t,"click",As),Y(e,"click",n[22])],be=!0)},p(R,Z){Z[0]&512&&o.value!==R[9]&&Ee(o,R[9]),R[9]?ge?ge.p(R,Z):(ge=Kt(R),ge.c(),ge.m(c,null)):ge&&(ge.d(1),ge=null),Z[0]&4&&qe(w,"active",R[2]===""),Z[0]&526340&&(Pe=R[11],h=He(h,Z,Me,1,R,Pe,z,m,Re,Gt,null,Ft)),Z[0]&1024&&qe(L,"active",R[10]===""),Z[0]&271360&&(Be=R[13],A=He(A,Z,Ne,1,R,Be,j,J,Re,Vt,null,jt)),ye===(ye=je(R))&&we?we.p(R,Z):(we&&we.d(1),we=ye&&ye(R),we&&(we.c(),we.m(I,N))),Z[0]&3145888&&(Ae=R[7],U=He(U,Z,Ve,1,R,Ae,ee,O,Re,Zt,null,Bt)),Z[0]&272&&q!==(q=R[8]<=1||R[4])&&(B.disabled=q),Z[0]&256&&V(de,R[8]),Z[0]&16384&&V(re,R[14]),Z[0]&2&&V(me,R[1]),Z[0]&16656&&_e!==(_e=R[8]>=R[14]||R[4])&&(ve.disabled=_e),Z[0]&8&&ie!==(ie=Ke(`svp-modal svp-cloud-tc ${R[3]?"svp-modal-open modal-open":""}`)+" svelte-1qg2qyu")&&a(e,"class",ie),R[12]?Ce?Ce.p(R,Z):(Ce=$t(R),Ce.c(),Ce.m(ue.parentNode,ue)):Ce&&(Ce.d(1),Ce=null)},i:fe,o:fe,d(R){R&&g(e),ge&&ge.d();for(let Z=0;Z<h.length;Z+=1)h[Z].d();for(let Z=0;Z<A.length;Z+=1)A[Z].d();we&&we.d();for(let Z=0;Z<U.length;Z+=1)U[Z].d();R&&g(oe),Ce&&Ce.d(R),R&&g(ue),be=!1,ze(ce)}}}function As(n){n.stopPropagation()}function Os(n,e,t){let l,s,{auth:i}=e,{service:c}=e,{designerUtils:o}=e,{pageSize:p=12}=e,f=!1,_=!1,u=!1,v="",m=[],P=0,C=1,w="",b="",h="",z=[],D=[],J="",H=!1,y=null;function L(){t(3,f=!0),H||K(),I(1)}function M(){t(3,f=!1),t(12,J="")}function A(){f?M():L()}function j(){return f}function K(){return X(this,null,function*(){H=!0;try{const[F,_e]=yield Promise.all([c.getCategories().catch(()=>[]),c.getIndustries().catch(()=>[])]);t(30,z=F||[]),t(11,D=_e||[])}catch(F){}})}function I(F=1){return X(this,null,function*(){var _e;t(4,_=!0),t(6,v="");try{const ie=yield c.listTemplates({keyword:w,category_id:b===""?void 0:b,industry_id:h===""?void 0:h,page:F,pageSize:p}),oe=(ie==null?void 0:ie.list)||(ie==null?void 0:ie.items)||(Array.isArray(ie)?ie:[]);t(7,m=oe),t(1,P=(_e=ie==null?void 0:ie.total)!=null?_e:oe.length),t(8,C=F)}catch(ie){t(6,v=(ie==null?void 0:ie.message)||"加载模板失败"),t(7,m=[]),t(1,P=0)}finally{t(4,_=!1)}})}function N(){clearTimeout(y),y=setTimeout(()=>I(1),350)}function O(){t(9,w=""),I(1)}function U(F){t(10,b=b===F?"":F),I(1)}function ee(F){h!==F&&t(10,b=""),t(2,h=h===F?"":F),I(1)}function he(F){F.preview_img&&t(12,J=F.preview_img)}function W(){return X(this,null,function*(){var F;return i.isLoggedIn()?!0:((F=o==null?void 0:o.showModal)==null||F.call(o,{title:"需要登录",content:"使用模板中心模板需要先登录 sv-print 账号。",showCancel:!0,submitText:"去登录",submit:()=>X(this,null,function*(){var _e;try{yield i.login(),yield I(C)}catch(ie){(_e=o==null?void 0:o.showToast)==null||_e.call(o,(ie==null?void 0:ie.message)||"登录失败",{type:"error"})}})}),!1)})}function B(F){return X(this,null,function*(){var _e;(yield W())&&((_e=o==null?void 0:o.showModal)==null||_e.call(o,{title:"使用模板",content:`确定使用「${F.template_name}」?将覆盖当前设计内容与打印数据。`,submitText:"覆盖使用",submit:()=>X(this,null,function*(){var ie,oe;t(5,u=!0);try{yield c.applyTemplate(F),(ie=o==null?void 0:o.showToast)==null||ie.call(o,"模板已应用",{type:"success"}),M()}catch(ue){(oe=o==null?void 0:o.showToast)==null||oe.call(o,(ue==null?void 0:ue.message)||"模板应用失败",{type:"error"})}finally{t(5,u=!1)}})}))})}function Q(){M()}function q(){w=this.value,t(9,w)}const G=()=>{t(2,h=""),I(1)},x=F=>ee(F.industry_id),de=()=>{t(10,b=""),I(1)},pe=F=>U(F.category_id),re=F=>he(F),le=F=>B(F),me=()=>I(C-1),ke=()=>I(C+1),Se=()=>t(12,J=""),ve=()=>t(12,J="");return n.$$set=F=>{"auth"in F&&t(23,i=F.auth),"service"in F&&t(24,c=F.service),"designerUtils"in F&&t(25,o=F.designerUtils),"pageSize"in F&&t(26,p=F.pageSize)},n.$$.update=()=>{n.$$.dirty[0]&67108866&&t(14,l=Math.max(1,Math.ceil(P/p))),n.$$.dirty[0]&1073741828&&t(13,s=h===""?z:z.filter(F=>F.industry_id==null||F.industry_id===h))},[M,P,h,f,_,u,v,m,C,w,b,D,J,s,l,I,N,O,U,ee,he,B,Q,i,c,o,p,L,A,j,z,q,G,x,de,pe,re,le,me,ke,Se,ve]}class Ds extends qt{constructor(e){super(),It(this,e,Os,Ms,zt,{auth:23,service:24,designerUtils:25,pageSize:26,show:27,hide:0,toggle:28,isOpen:29},null,[-1,-1])}get show(){return this.$$.ctx[27]}get hide(){return this.$$.ctx[0]}get toggle(){return this.$$.ctx[28]}get isOpen(){return this.$$.ctx[29]}}const Us=Object.freeze(Object.defineProperty({__proto__:null,default:Ds},Symbol.toStringTag,{value:"Module"}));function Ns(n,e,t){const l=n.slice();return l[15]=e[t],l}function Js(n){let e,t;return{c(){e=d("option"),t=E(n[15]),e.__value=["Letter","Legal","Tabloid"].includes(n[15])?n[15].toLowerCase():n[15],e.value=e.__value},m(l,s){k(l,e,s),r(e,t)},p:fe,d(l){l&&g(e)}}}function xt(n){let e,t,l,s,i,c,o,p,f;return{c(){e=d("label"),t=E("宽度(mm)"),l=d("input"),s=T(),i=d("label"),c=E("高度(mm)"),o=d("input"),a(l,"class","svp-input svp-input-sm svelte-ye0rpk"),a(l,"type","number"),a(l,"min","1"),a(l,"max","2000"),a(l,"step","0.1"),a(e,"class","svelte-ye0rpk"),a(o,"class","svp-input svp-input-sm svelte-ye0rpk"),a(o,"type","number"),a(o,"min","1"),a(o,"max","2000"),a(o,"step","0.1"),a(i,"class","svelte-ye0rpk")},m(_,u){k(_,e,u),r(e,t),r(e,l),Ee(l,n[0].width),k(_,s,u),k(_,i,u),r(i,c),r(i,o),Ee(o,n[0].height),p||(f=[Y(l,"input",n[4]),Y(o,"input",n[5])],p=!0)},p(_,u){u&1&&Fe(l.value)!==_[0].width&&Ee(l,_[0].width),u&1&&Fe(o.value)!==_[0].height&&Ee(o,_[0].height)},d(_){_&&g(e),_&&g(s),_&&g(i),p=!1,ze(f)}}}function Rs(n){let e,t,l,s,i,c,o,p,f,_,u,v,m,P,C,w,b,h,z,D,J,H,y,L,M,A,j,K,I,N,O,U,ee,he,W,B,Q,q,G,x,de,pe,re,le,me,ke,Se,ve,F,_e,ie,oe,ue,be,ce,ge,Pe,Me,Be,Ne,je,ye,we,Ae,Ve,Ce,R=["A4","A3","A5","B4","B5","Letter","Legal","Tabloid"],Z=[];for(let ae=0;ae<8;ae+=1)Z[ae]=Js(Ns(n,R,ae));let ne=n[0].pageSize==="custom"&&xt(n);return{c(){e=d("fieldset"),t=d("legend"),t.textContent="打印参数",l=T(),s=d("div"),i=d("label"),c=E(`纸张
26
+ `),o=d("select"),p=d("option"),p.textContent="使用模板 / 客户端设置";for(let ae=0;ae<8;ae+=1)Z[ae].c();f=d("option"),f.textContent="自定义尺寸",_=T(),u=d("label"),v=E("份数"),m=d("input"),P=T(),ne&&ne.c(),C=T(),w=d("label"),b=E("方向"),h=d("select"),z=d("option"),z.textContent="纵向",D=d("option"),D.textContent="横向",J=T(),H=d("label"),y=E("双面"),L=d("select"),M=d("option"),M.textContent="单面",A=d("option"),A.textContent="长边翻转",j=d("option"),j.textContent="短边翻转",K=T(),I=d("label"),N=E("缩放(%)"),O=d("input"),U=T(),ee=d("label"),he=E("每张纸页数"),W=d("input"),B=T(),Q=d("label"),q=E("边距"),G=d("select"),x=d("option"),x.textContent="无边距",de=d("option"),de.textContent="默认",pe=d("option"),pe.textContent="最小",re=T(),le=d("div"),me=d("label"),ke=d("input"),Se=E(" 彩色"),ve=T(),F=d("label"),_e=d("input"),ie=E(" 打印背景"),oe=T(),ue=d("label"),be=d("input"),ce=E(" 静默打印"),ge=T(),Pe=d("details"),Me=d("summary"),Me.textContent="附加打印选项(JSON)",Be=T(),Ne=d("label"),je=E(`附加参数
27
+ `),ye=d("textarea"),we=T(),Ae=d("p"),Ae.textContent="填写 JSON 对象,可覆盖同名常规参数;打印机和双面方式以当前选择为准。",a(t,"class","svelte-ye0rpk"),p.__value="",p.value=p.__value,f.__value="custom",f.value=f.__value,a(o,"class","svp-select svp-select-sm svelte-ye0rpk"),n[0].pageSize===void 0&&Je(()=>n[2].call(o)),a(i,"class","svelte-ye0rpk"),a(m,"class","svp-input svp-input-sm svelte-ye0rpk"),a(m,"type","number"),a(m,"min","1"),a(m,"max","99"),a(m,"step","1"),a(u,"class","svelte-ye0rpk"),z.__value=!1,z.value=z.__value,D.__value=!0,D.value=D.__value,a(h,"class","svp-select svp-select-sm svelte-ye0rpk"),n[0].landscape===void 0&&Je(()=>n[6].call(h)),a(w,"class","svelte-ye0rpk"),M.__value="simplex",M.value=M.__value,A.__value="longEdge",A.value=A.__value,j.__value="shortEdge",j.value=j.__value,a(L,"class","svp-select svp-select-sm svelte-ye0rpk"),n[0].duplexMode===void 0&&Je(()=>n[7].call(L)),a(H,"class","svelte-ye0rpk"),a(O,"class","svp-input svp-input-sm svelte-ye0rpk"),a(O,"type","number"),a(O,"min","10"),a(O,"max","200"),a(I,"class","svelte-ye0rpk"),a(W,"class","svp-input svp-input-sm svelte-ye0rpk"),a(W,"type","number"),a(W,"min","1"),a(W,"max","16"),a(W,"step","1"),a(ee,"class","svelte-ye0rpk"),x.__value="none",x.value=x.__value,de.__value="default",de.value=de.__value,pe.__value="minimum",pe.value=pe.__value,a(G,"class","svp-select svp-select-sm svelte-ye0rpk"),n[0].marginType===void 0&&Je(()=>n[10].call(G)),a(Q,"class","svelte-ye0rpk"),a(s,"class","options-grid svelte-ye0rpk"),a(ke,"type","checkbox"),a(me,"class","svelte-ye0rpk"),a(_e,"type","checkbox"),a(F,"class","svelte-ye0rpk"),a(be,"type","checkbox"),a(ue,"class","svelte-ye0rpk"),a(le,"class","options-checks svelte-ye0rpk"),a(Me,"class","svelte-ye0rpk"),a(ye,"class","svp-textarea svp-w-full"),a(ye,"rows","3"),a(ye,"placeholder",'例如:{"collate":true}'),a(Ne,"class","extra-label svelte-ye0rpk"),a(Ae,"class","svelte-ye0rpk"),a(e,"class","print-options svelte-ye0rpk"),e.disabled=n[1]},m(ae,Le){k(ae,e,Le),r(e,t),r(e,l),r(e,s),r(s,i),r(i,c),r(i,o),r(o,p);for(let xe=0;xe<8;xe+=1)Z[xe]&&Z[xe].m(o,null);r(o,f),Ie(o,n[0].pageSize,!0),r(s,_),r(s,u),r(u,v),r(u,m),Ee(m,n[0].copies),r(s,P),ne&&ne.m(s,null),r(s,C),r(s,w),r(w,b),r(w,h),r(h,z),r(h,D),Ie(h,n[0].landscape,!0),r(s,J),r(s,H),r(H,y),r(H,L),r(L,M),r(L,A),r(L,j),Ie(L,n[0].duplexMode,!0),r(s,K),r(s,I),r(I,N),r(I,O),Ee(O,n[0].scaleFactor),r(s,U),r(s,ee),r(ee,he),r(ee,W),Ee(W,n[0].pagesPerSheet),r(s,B),r(s,Q),r(Q,q),r(Q,G),r(G,x),r(G,de),r(G,pe),Ie(G,n[0].marginType,!0),r(e,re),r(e,le),r(le,me),r(me,ke),ke.checked=n[0].color,r(me,Se),r(le,ve),r(le,F),r(F,_e),_e.checked=n[0].printBackground,r(F,ie),r(le,oe),r(le,ue),r(ue,be),be.checked=n[0].silent,r(ue,ce),r(e,ge),r(e,Pe),r(Pe,Me),r(Pe,Be),r(Pe,Ne),r(Ne,je),r(Ne,ye),Ee(ye,n[0].extra),r(Pe,we),r(Pe,Ae),Ve||(Ce=[Y(o,"change",n[2]),Y(m,"input",n[3]),Y(h,"change",n[6]),Y(L,"change",n[7]),Y(O,"input",n[8]),Y(W,"input",n[9]),Y(G,"change",n[10]),Y(ke,"change",n[11]),Y(_e,"change",n[12]),Y(be,"change",n[13]),Y(ye,"input",n[14])],Ve=!0)},p(ae,[Le]){Le&1&&Ie(o,ae[0].pageSize),Le&1&&Fe(m.value)!==ae[0].copies&&Ee(m,ae[0].copies),ae[0].pageSize==="custom"?ne?ne.p(ae,Le):(ne=xt(ae),ne.c(),ne.m(s,C)):ne&&(ne.d(1),ne=null),Le&1&&Ie(h,ae[0].landscape),Le&1&&Ie(L,ae[0].duplexMode),Le&1&&Fe(O.value)!==ae[0].scaleFactor&&Ee(O,ae[0].scaleFactor),Le&1&&Fe(W.value)!==ae[0].pagesPerSheet&&Ee(W,ae[0].pagesPerSheet),Le&1&&Ie(G,ae[0].marginType),Le&1&&(ke.checked=ae[0].color),Le&1&&(_e.checked=ae[0].printBackground),Le&1&&(be.checked=ae[0].silent),Le&1&&Ee(ye,ae[0].extra),Le&2&&(e.disabled=ae[1])},i:fe,o:fe,d(ae){ae&&g(e),hs(Z,ae),ne&&ne.d(),Ve=!1,ze(Ce)}}}function Hs(n,e,t){let{value:l}=e,{disabled:s=!1}=e;function i(){l.pageSize=We(this),t(0,l)}function c(){l.copies=Fe(this.value),t(0,l)}function o(){l.width=Fe(this.value),t(0,l)}function p(){l.height=Fe(this.value),t(0,l)}function f(){l.landscape=We(this),t(0,l)}function _(){l.duplexMode=We(this),t(0,l)}function u(){l.scaleFactor=Fe(this.value),t(0,l)}function v(){l.pagesPerSheet=Fe(this.value),t(0,l)}function m(){l.marginType=We(this),t(0,l)}function P(){l.color=this.checked,t(0,l)}function C(){l.printBackground=this.checked,t(0,l)}function w(){l.silent=this.checked,t(0,l)}function b(){l.extra=this.value,t(0,l)}return n.$$set=h=>{"value"in h&&t(0,l=h.value),"disabled"in h&&t(1,s=h.disabled)},[l,s,i,c,o,p,f,_,u,v,m,P,C,w,b]}class mn extends qt{constructor(e){super(),It(this,e,Hs,Rs,ps,{value:0,disabled:1})}}function el(){return{pageSize:"",width:210,height:297,copies:1,landscape:!1,duplexMode:"simplex",color:!0,silent:!0,printBackground:!0,scaleFactor:100,pagesPerSheet:1,marginType:"none",extra:""}}function tl(n,e){if(!e.trim())throw new Error("请选择打印机");let t={};if(n.extra.trim()){try{t=JSON.parse(n.extra)}catch(i){throw new Error("附加打印选项不是合法的 JSON")}if(!t||typeof t!="object"||Array.isArray(t))throw new Error("附加打印选项 JSON 顶层必须是对象")}const l=(i,c,o,p,f=!1)=>{if(!Number.isFinite(i)||i<o||i>p||f&&!Number.isInteger(i))throw new Error(`${c}必须为 ${o}–${p} 范围内的${f?"整数":"数值"}`);return i},s={copies:l(n.copies,"份数",1,99,!0),landscape:n.landscape,color:n.color,silent:n.silent,printBackground:n.printBackground,scaleFactor:l(n.scaleFactor,"缩放比例",10,200),pagesPerSheet:l(n.pagesPerSheet,"每张纸页数",1,16,!0),margins:{marginType:n.marginType}};return n.pageSize==="custom"?s.pageSize={width:Math.round(l(n.width,"纸张宽度",1,2e3)*1e3),height:Math.round(l(n.height,"纸张高度",1,2e3)*1e3)}:n.pageSize&&(s.pageSize=n.pageSize),Xe(Ge(Ge({},s),t),{printer:e,duplexMode:n.duplexMode})}function ll(n,e,t){const l=n.slice();return l[103]=e[t],l}function nl(n,e,t){const l=n.slice();return l[119]=e[t],l}function sl(n,e,t){const l=n.slice();return l[109]=e[t],l}function il(n,e,t){const l=n.slice();return l[103]=e[t],l}function rl(n,e,t){const l=n.slice();return l[114]=e[t],l}function ol(n,e,t){const l=n.slice();return l[106]=e[t],l}function cl(n,e,t){const l=n.slice();return l[103]=e[t],l}function al(n,e,t){const l=n.slice();return l[122]=e[t],l}function ul(n,e){let t,l,s,i=e[122].label+"",c,o,p,f,_;function u(){return e[72](e[122])}return{key:n,first:null,c(){t=d("button"),l=d("i"),s=T(),c=E(i),o=T(),a(l,"class","svicon "+e[122].icon+" svelte-1v5czrr"),a(t,"class",p=Ke(`cloud-nav-item ${e[6]===e[122].key?"cloud-nav-active":""}`)+" svelte-1v5czrr"),this.first=t},m(v,m){k(v,t,m),r(t,l),r(t,s),r(t,c),r(t,o),f||(_=Y(t,"click",u),f=!0)},p(v,m){e=v,m[0]&64&&p!==(p=Ke(`cloud-nav-item ${e[6]===e[122].key?"cloud-nav-active":""}`)+" svelte-1v5czrr")&&a(t,"class",p)},d(v){v&&g(t),f=!1,_()}}}function Bs(n){let e,t,l,s,i,c,o=(n[0].host||"/api")+"",p,f,_,u,v,m,P,C,w,b,h,z,D,J,H,y=n[5]&&fl(n);return{c(){e=d("div"),t=d("div"),t.textContent="连接配置",l=T(),s=d("div"),i=d("span"),i.textContent="服务端 host",c=d("code"),p=E(o),f=T(),_=d("span"),_.textContent="登录方式",u=d("code"),v=E(n[45]),m=E("("),P=E(n[2]),C=E(")"),w=T(),b=d("span"),b.textContent="存储 key",h=d("code"),z=E(n[44]),D=T(),y&&y.c(),J=T(),H=d("div"),H.textContent="以上为插件初始化时的只读配置;实际使用时请通过插件设置修改。",a(t,"class","settings-subtitle"),a(i,"class","svelte-1v5czrr"),a(c,"class","svelte-1v5czrr"),a(_,"class","svelte-1v5czrr"),a(u,"class","svelte-1v5czrr"),a(b,"class","svelte-1v5czrr"),a(h,"class","svelte-1v5czrr"),a(s,"class","cloud-kv svelte-1v5czrr"),a(H,"class","settings-hint"),a(e,"class","settings-section")},m(L,M){k(L,e,M),r(e,t),r(e,l),r(e,s),r(s,i),r(s,c),r(c,p),r(s,f),r(s,_),r(s,u),r(u,v),r(u,m),r(u,P),r(u,C),r(s,w),r(s,b),r(s,h),r(h,z),r(s,D),y&&y.m(s,null),r(e,J),r(e,H)},p(L,M){M[0]&1&&o!==(o=(L[0].host||"/api")+"")&&V(p,o),M[1]&16384&&V(v,L[45]),M[0]&4&&V(P,L[2]),M[1]&8192&&V(z,L[44]),L[5]?y?y.p(L,M):(y=fl(L),y.c(),y.m(s,null)):y&&(y.d(1),y=null)},i:fe,o:fe,d(L){L&&g(e),y&&y.d()}}}function js(n){let e,t,l,s,i,c=n[36]?"已连接":"未连接",o,p,f,_,u,v,m,P;function C(z,D){return z[36]?Ys:Ws}let w=C(n),b=w(n),h=n[36]&&dl(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="中转打印",s=T(),i=d("span"),o=E(c),f=T(),_=d("p"),_.textContent=`通过短期 ticket
28
+ 直连中转服务(socket.io),打印指令实时送达本地客户端,不产生云打印任务记录。`,u=T(),v=d("div"),b.c(),m=T(),h&&h.c(),a(l,"class","settings-subtitle"),Oe(l,"margin","0"),a(i,"class",p=Ke(`svp-badge svp-badge-sm ${n[36]?"badge-on":""}`)+" svelte-1v5czrr"),a(t,"class","svp-flex-row svp-justify-between"),Oe(t,"margin-bottom","10px"),a(_,"class","settings-hint"),a(v,"class","form-actions"),a(e,"class","settings-section")},m(z,D){k(z,e,D),r(e,t),r(t,l),r(t,s),r(t,i),r(i,o),r(e,f),r(e,_),r(e,u),r(e,v),b.m(v,null),r(e,m),h&&h.m(e,null),P=!0},p(z,D){(!P||D[1]&32)&&c!==(c=z[36]?"已连接":"未连接")&&V(o,c),(!P||D[1]&32&&p!==(p=Ke(`svp-badge svp-badge-sm ${z[36]?"badge-on":""}`)+" svelte-1v5czrr"))&&a(i,"class",p),w===(w=C(z))&&b?b.p(z,D):(b.d(1),b=w(z),b&&(b.c(),b.m(v,null))),z[36]?h?(h.p(z,D),D[1]&32&&De(h,1)):(h=dl(z),h.c(),De(h,1),h.m(e,null)):h&&(St(),Ye(h,1,1,()=>{h=null}),Pt())},i(z){P||(De(h),P=!0)},o(z){Ye(h),P=!1},d(z){z&&g(e),b.d(),h&&h.d()}}}function Fs(n){let e,t,l,s,i,c,o,p,f,_,u,v,m,P,C,w,b,h,z,D,J,H,y,L,M,A,j,K;function I(B,Q){return B[21]?ni:B[20].length===0?li:ti}let N=I(n),O=N(n),U=n[23]&&bl(n);function ee(B,Q){return B[30]?ci:B[29].length===0?oi:ri}let he=ee(n),W=he(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="云设备",s=T(),i=d("button"),c=d("i"),o=E(" 刷新"),p=T(),O.c(),f=T(),U&&U.c(),_=T(),u=d("div"),v=d("button"),m=d("i"),P=E(" 下发云打印"),w=T(),b=d("div"),h=T(),z=d("div"),D=d("div"),D.textContent="打印任务",J=T(),H=d("button"),y=d("i"),L=E(" 刷新"),M=T(),W.c(),a(l,"class","settings-subtitle"),Oe(l,"margin","0"),a(c,"class","svicon sv-refresh"),a(i,"class","svp-btn svp-btn-ghost svp-btn-xs"),i.disabled=n[21],a(t,"class","svp-flex-row svp-justify-between"),Oe(t,"margin-bottom","10px"),a(m,"class","svicon sv-print"),a(v,"class","svp-btn svp-btn-primary svp-btn-sm"),v.disabled=C=n[10]||n[21]||n[26]||!n[23]||!n[25].trim(),a(u,"class","form-actions"),a(b,"class","settings-divider"),a(D,"class","settings-subtitle"),Oe(D,"margin","0"),a(y,"class","svicon sv-refresh"),a(H,"class","svp-btn svp-btn-ghost svp-btn-xs"),H.disabled=n[30],a(z,"class","svp-flex-row svp-justify-between"),Oe(z,"margin-bottom","10px"),a(e,"class","settings-section")},m(B,Q){k(B,e,Q),r(e,t),r(t,l),r(t,s),r(t,i),r(i,c),r(i,o),r(e,p),O.m(e,null),r(e,f),U&&U.m(e,null),r(e,_),r(e,u),r(u,v),r(v,m),r(v,P),r(e,w),r(e,b),r(e,h),r(e,z),r(z,D),r(z,J),r(z,H),r(H,y),r(H,L),r(e,M),W.m(e,null),A=!0,j||(K=[Y(i,"click",n[57]),Y(v,"click",n[61]),Y(H,"click",n[60])],j=!0)},p(B,Q){(!A||Q[0]&2097152)&&(i.disabled=B[21]),N===(N=I(B))&&O?O.p(B,Q):(O.d(1),O=N(B),O&&(O.c(),O.m(e,f))),B[23]?U?(U.p(B,Q),Q[0]&8388608&&De(U,1)):(U=bl(B),U.c(),De(U,1),U.m(e,_)):U&&(St(),Ye(U,1,1,()=>{U=null}),Pt()),(!A||Q[0]&127927296&&C!==(C=B[10]||B[21]||B[26]||!B[23]||!B[25].trim()))&&(v.disabled=C),(!A||Q[0]&1073741824)&&(H.disabled=B[30]),he===(he=ee(B))&&W?W.p(B,Q):(W.d(1),W=he(B),W&&(W.c(),W.m(e,null)))},i(B){A||(De(U),A=!0)},o(B){Ye(U),A=!1},d(B){B&&g(e),O.d(),U&&U.d(),W.d(),j=!1,ze(K)}}}function Ks(n){let e,t,l,s,i,c,o,p,f,_,u,v,m,P,C,w,b,h,z,D,J,H,y;function L(I,N){return I[10]?ui:ai}let M=L(n),A=M(n),j=n[19]&&Tl(),K=n[4]&&Cl(n);return{c(){e=d("div"),t=d("div"),t.textContent="服务端渲染",l=T(),s=d("p"),s.textContent="使用当前设计器模板与打印数据提交服务端渲染。",i=T(),c=d("div"),o=d("label"),o.textContent="输出类型",p=T(),f=d("select"),_=d("option"),_.textContent="pdf",u=d("option"),u.textContent="img",v=d("option"),v.textContent="html",m=T(),P=d("label"),C=d("input"),w=E(`
29
+ 同步返回`),b=T(),h=d("div"),z=d("button"),A.c(),D=T(),j&&j.c(),J=T(),K&&K.c(),a(t,"class","settings-subtitle"),a(s,"class","settings-hint"),a(o,"class","form-label"),_.__value="pdf",_.value=_.__value,u.__value="img",u.value=u.__value,v.__value="html",v.value=v.__value,a(f,"class","svp-select svp-select-sm"),n[17]===void 0&&Je(()=>n[79].call(f)),a(c,"class","form-row"),a(C,"type","checkbox"),a(C,"class","svp-checkbox svp-checkbox-sm svp-checkbox-primary"),a(P,"class","cloud-checkbox-label svelte-1v5czrr"),a(z,"class","svp-btn svp-btn-primary svp-btn-sm"),z.disabled=n[10],a(h,"class","form-actions"),a(e,"class","settings-section")},m(I,N){k(I,e,N),r(e,t),r(e,l),r(e,s),r(e,i),r(e,c),r(c,o),r(c,p),r(c,f),r(f,_),r(f,u),r(f,v),Ie(f,n[17],!0),r(e,m),r(e,P),r(P,C),C.checked=n[18],r(P,w),r(e,b),r(e,h),r(h,z),A.m(z,null),r(e,D),j&&j.m(e,null),r(e,J),K&&K.m(e,null),H||(y=[Y(f,"change",n[79]),Y(C,"change",n[80]),Y(z,"click",n[56])],H=!0)},p(I,N){N[0]&131072&&Ie(f,I[17]),N[0]&262144&&(C.checked=I[18]),M!==(M=L(I))&&(A.d(1),A=M(I),A&&(A.c(),A.m(z,null))),N[0]&1024&&(z.disabled=I[10]),I[19]?j||(j=Tl(),j.c(),j.m(e,J)):j&&(j.d(1),j=null),I[4]?K?K.p(I,N):(K=Cl(I),K.c(),K.m(e,null)):K&&(K.d(1),K=null)},i:fe,o:fe,d(I){I&&g(e),A.d(),j&&j.d(),K&&K.d(),H=!1,ze(y)}}}function Gs(n){let e,t,l,s,i,c,o,p,f,_,u,v,m,P,C,w,b,h,z,D,J,H;function y(A,j){return A[16]?gi:A[15].length===0?bi:mi}let L=y(n),M=L(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="模板中心",s=T(),i=d("button"),c=d("i"),o=E(" 随机使用模板"),_=T(),u=d("p"),u.textContent="一键更新当前设计器的模板 JSON 与打印数据(需登录)。列表浏览免登录。",v=T(),m=d("div"),P=d("input"),C=T(),w=d("button"),b=E("搜索"),h=T(),z=d("button"),z.textContent="弹窗浏览",D=T(),M.c(),a(l,"class","settings-subtitle"),Oe(l,"margin","0"),a(c,"class","svicon sv-refresh"),a(i,"class","svp-btn svp-btn-primary svp-btn-xs"),i.disabled=p=n[10]||!n[7],a(i,"title",f=n[7]?"随机取一个模板并覆盖当前设计内容与打印数据":"请先登录"),a(t,"class","svp-flex-row svp-justify-between"),Oe(t,"margin-bottom","10px"),a(u,"class","settings-hint"),a(P,"class","svp-input svp-input-sm svp-w-full"),a(P,"placeholder","搜索模板名称"),a(w,"class","svp-btn svp-btn-outline svp-btn-sm"),w.disabled=n[16],a(z,"class","svp-btn svp-btn-ghost svp-btn-sm"),a(z,"title","打开模板中心弹窗"),a(m,"class","cloud-search-row svelte-1v5czrr"),a(e,"class","settings-section")},m(A,j){k(A,e,j),r(e,t),r(t,l),r(t,s),r(t,i),r(i,c),r(i,o),r(e,_),r(e,u),r(e,v),r(e,m),r(m,P),Ee(P,n[14]),r(m,C),r(m,w),r(w,b),r(m,h),r(m,z),r(e,D),M.m(e,null),J||(H=[Y(i,"click",n[54]),Y(P,"input",n[75]),Y(P,"keydown",n[76]),Y(w,"click",n[53]),Y(z,"click",n[77])],J=!0)},p(A,j){j[0]&1152&&p!==(p=A[10]||!A[7])&&(i.disabled=p),j[0]&128&&f!==(f=A[7]?"随机取一个模板并覆盖当前设计内容与打印数据":"请先登录")&&a(i,"title",f),j[0]&16384&&P.value!==A[14]&&Ee(P,A[14]),j[0]&65536&&(w.disabled=A[16]),L===(L=y(A))&&M?M.p(A,j):(M.d(1),M=L(A),M&&(M.c(),M.m(e,null)))},i:fe,o:fe,d(A){A&&g(e),M.d(),J=!1,ze(H)}}}function Vs(n){let e,t,l,s,i,c,o,p,f,_=n[46]&&Ll(n);function u(b,h){return b[9]?Si:zi}let v=u(n),m=v(n);function P(b,h){return b[7]?Li:b[2]==="none"?Ei:Pi}let C=P(n),w=C(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="账户",s=T(),i=d("span"),c=E(n[45]),o=T(),_&&_.c(),p=T(),m.c(),f=T(),w.c(),a(l,"class","settings-subtitle"),Oe(l,"margin","0"),a(i,"class","svp-badge svp-badge-sm"),a(t,"class","svp-flex-row svp-justify-between"),Oe(t,"margin-bottom","10px"),a(e,"class","settings-section")},m(b,h){k(b,e,h),r(e,t),r(t,l),r(t,s),r(t,i),r(i,c),r(e,o),_&&_.m(e,null),r(e,p),m.m(e,null),r(e,f),w.m(e,null)},p(b,h){h[1]&16384&&V(c,b[45]),b[46]?_?_.p(b,h):(_=Ll(b),_.c(),_.m(e,p)):_&&(_.d(1),_=null),v===(v=u(b))&&m?m.p(b,h):(m.d(1),m=v(b),m&&(m.c(),m.m(e,f))),C===(C=P(b))&&w?w.p(b,h):(w.d(1),w=C(b),w&&(w.c(),w.m(e,null)))},i:fe,o:fe,d(b){b&&g(e),_&&_.d(),m.d(),w.d()}}}function fl(n){let e,t,l=(n[5].authorizeOrigin||"未配置")+"",s,i,c,o,p,f,_,u,v=(n[5].clientId||"未配置")+"",m,P,C,w,b;return{c(){e=d("span"),e.textContent="授权页源",t=d("code"),s=E(l),i=T(),c=d("span"),c.textContent="授权方式",o=d("code"),p=E(n[41]),f=T(),_=d("span"),_.textContent="client_id",u=d("code"),m=E(v),P=T(),C=d("span"),C.textContent="scope",w=d("code"),b=E(n[42]),a(e,"class","svelte-1v5czrr"),a(t,"class","svelte-1v5czrr"),a(c,"class","svelte-1v5czrr"),a(o,"class","svelte-1v5czrr"),a(_,"class","svelte-1v5czrr"),a(u,"class","svelte-1v5czrr"),a(C,"class","svelte-1v5czrr"),a(w,"class","svelte-1v5czrr")},m(h,z){k(h,e,z),k(h,t,z),r(t,s),k(h,i,z),k(h,c,z),k(h,o,z),r(o,p),k(h,f,z),k(h,_,z),k(h,u,z),r(u,m),k(h,P,z),k(h,C,z),k(h,w,z),r(w,b)},p(h,z){z[0]&32&&l!==(l=(h[5].authorizeOrigin||"未配置")+"")&&V(s,l),z[1]&1024&&V(p,h[41]),z[0]&32&&v!==(v=(h[5].clientId||"未配置")+"")&&V(m,v),z[1]&2048&&V(b,h[42])},d(h){h&&g(e),h&&g(t),h&&g(i),h&&g(c),h&&g(o),h&&g(f),h&&g(_),h&&g(u),h&&g(P),h&&g(C),h&&g(w)}}}function Ws(n){let e,t,l;function s(o,p){return o[10]?Qs:Xs}let i=s(n),c=i(n);return{c(){e=d("button"),c.c(),a(e,"class","svp-btn svp-btn-primary svp-btn-sm"),e.disabled=n[10]},m(o,p){k(o,e,p),c.m(e,null),t||(l=Y(e,"click",n[64]),t=!0)},p(o,p){i!==(i=s(o))&&(c.d(1),c=i(o),c&&(c.c(),c.m(e,null))),p[0]&1024&&(e.disabled=o[10])},d(o){o&&g(e),c.d(),t=!1,l()}}}function Ys(n){let e,t,l,s,i,c,o;return{c(){e=d("button"),e.textContent="断开连接",t=T(),l=d("button"),s=d("i"),i=E(" 刷新客户端"),a(e,"class","svp-btn svp-btn-ghost svp-btn-sm"),a(s,"class","svicon sv-refresh"),a(l,"class","svp-btn svp-btn-outline svp-btn-sm"),l.disabled=n[10]},m(p,f){k(p,e,f),k(p,t,f),k(p,l,f),r(l,s),r(l,i),c||(o=[Y(e,"click",n[65]),Y(l,"click",n[64])],c=!0)},p(p,f){f[0]&1024&&(l.disabled=p[10])},d(p){p&&g(e),p&&g(t),p&&g(l),c=!1,ze(o)}}}function Xs(n){let e,t;return{c(){e=d("i"),t=E(" 连接中转服务"),a(e,"class","svicon sv-flow")},m(l,s){k(l,e,s),k(l,t,s)},d(l){l&&g(e),l&&g(t)}}}function Qs(n){let e,t;return{c(){e=d("i"),t=E(" 连接中..."),a(e,"class","svicon sv-refresh svp-spin svelte-1v5czrr")},m(l,s){k(l,e,s),k(l,t,s)},d(l){l&&g(e),l&&g(t)}}}function dl(n){let e,t,l,s,i,c,o,p,f=[],_=new Map,u,v,m,P,C,w,b,h,z,D,J,H,y,L,M,A;function j(q,G){return q[31].length===0?$s:Zs}let K=j(n),I=K(n),N=n[33];const O=q=>q[103].name;for(let q=0;q<N.length;q+=1){let G=ll(n,N,q),x=O(G);_.set(x,f[q]=_l(x,G))}let U=n[32]&&!n[10]&&!n[33].length&&hl();function ee(q){n[93](q)}let he={disabled:n[10]||!n[32]};n[35]!==void 0&&(he.value=n[35]),h=new mn({props:he}),ot.push(()=>hn(h,"value",ee));function W(q,G){return q[10]?ei:xs}let B=W(n),Q=B(n);return{c(){e=d("div"),t=T(),I.c(),l=T(),s=d("div"),i=d("label"),i.textContent="打印机",c=T(),o=d("select"),p=d("option"),p.textContent="请选择打印机";for(let q=0;q<f.length;q+=1)f[q].c();v=T(),m=d("button"),P=d("i"),w=T(),U&&U.c(),b=T(),vn(h.$$.fragment),D=T(),J=d("div"),H=d("button"),Q.c(),a(e,"class","settings-divider"),a(i,"class","form-label"),a(i,"for","transit-printer"),p.__value="",p.value=p.__value,a(o,"id","transit-printer"),a(o,"class","svp-select svp-select-sm svp-w-full"),o.disabled=u=n[10]||!n[32]||!n[33].length,n[34]===void 0&&Je(()=>n[91].call(o)),a(P,"class","svicon sv-refresh"),a(m,"class","svp-btn svp-btn-ghost svp-btn-xs"),m.disabled=C=n[10]||!n[32],a(s,"class","form-row"),a(H,"class","svp-btn svp-btn-primary svp-btn-sm"),H.disabled=y=n[10]||!n[32]||!n[34],a(J,"class","form-actions")},m(q,G){k(q,e,G),k(q,t,G),I.m(q,G),k(q,l,G),k(q,s,G),r(s,i),r(s,c),r(s,o),r(o,p);for(let x=0;x<f.length;x+=1)f[x]&&f[x].m(o,null);Ie(o,n[34],!0),r(s,v),r(s,m),r(m,P),k(q,w,G),U&&U.m(q,G),k(q,b,G),Et(h,q,G),k(q,D,G),k(q,J,G),r(J,H),Q.m(H,null),L=!0,M||(A=[Y(o,"change",n[91]),Y(m,"click",n[92]),Y(H,"click",n[68])],M=!0)},p(q,G){K===(K=j(q))&&I?I.p(q,G):(I.d(1),I=K(q),I&&(I.c(),I.m(l.parentNode,l))),G[1]&4&&(N=q[33],f=He(f,G,O,1,q,N,_,o,Re,_l,null,ll)),(!L||G[0]&1024|G[1]&7&&u!==(u=q[10]||!q[32]||!q[33].length))&&(o.disabled=u),G[1]&12&&Ie(o,q[34]),(!L||G[0]&1024|G[1]&3&&C!==(C=q[10]||!q[32]))&&(m.disabled=C),q[32]&&!q[10]&&!q[33].length?U||(U=hl(),U.c(),U.m(b.parentNode,b)):U&&(U.d(1),U=null);const x={};G[0]&1024|G[1]&2&&(x.disabled=q[10]||!q[32]),!z&&G[1]&16&&(z=!0,x.value=q[35],pn(()=>z=!1)),h.$set(x),B!==(B=W(q))&&(Q.d(1),Q=B(q),Q&&(Q.c(),Q.m(H,null))),(!L||G[0]&1024|G[1]&15&&y!==(y=q[10]||!q[32]||!q[34]))&&(H.disabled=y)},i(q){L||(De(h.$$.fragment,q),L=!0)},o(q){Ye(h.$$.fragment,q),L=!1},d(q){q&&g(e),q&&g(t),I.d(q),q&&g(l),q&&g(s);for(let G=0;G<f.length;G+=1)f[G].d();q&&g(w),U&&U.d(q),q&&g(b),Lt(h,q),q&&g(D),q&&g(J),Q.d(),M=!1,ze(A)}}}function Zs(n){let e,t,l,s,i=[],c=new Map,o,p,f=n[31];const _=u=>u[119].clientId;for(let u=0;u<f.length;u+=1){let v=nl(n,f,u),m=_(v);c.set(m,i[u]=pl(m,v))}return{c(){e=d("div"),t=d("label"),t.textContent="客户端",l=T(),s=d("select");for(let u=0;u<i.length;u+=1)i[u].c();a(t,"class","form-label"),a(t,"for","transit-client"),a(s,"id","transit-client"),a(s,"class","svp-select svp-select-sm svp-w-full"),s.disabled=n[10],n[32]===void 0&&Je(()=>n[89].call(s)),a(e,"class","form-row")},m(u,v){k(u,e,v),r(e,t),r(e,l),r(e,s);for(let m=0;m<i.length;m+=1)i[m]&&i[m].m(s,null);Ie(s,n[32],!0),o||(p=[Y(s,"change",n[89]),Y(s,"change",n[90])],o=!0)},p(u,v){v[1]&1&&(f=u[31],i=He(i,v,_,1,u,f,c,s,Re,pl,null,nl)),v[0]&1024&&(s.disabled=u[10]),v[1]&3&&Ie(s,u[32])},d(u){u&&g(e);for(let v=0;v<i.length;v+=1)i[v].d();o=!1,ze(p)}}}function $s(n){let e;return{c(){e=d("div"),e.textContent="暂无在线客户端(需桌面客户端 sv-print-client 在线)",a(e,"class","settings-empty"),Oe(e,"margin-bottom","10px")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function pl(n,e){let t,l=(e[119].hostname||e[119].clientId)+"",s,i=e[119].platform?` · ${e[119].platform}`:"",c,o,p;return{key:n,first:null,c(){t=d("option"),s=E(l),c=E(i),o=T(),t.__value=p=e[119].clientId,t.value=t.__value,this.first=t},m(f,_){k(f,t,_),r(t,s),r(t,c),r(t,o)},p(f,_){e=f,_[1]&1&&l!==(l=(e[119].hostname||e[119].clientId)+"")&&V(s,l),_[1]&1&&i!==(i=e[119].platform?` · ${e[119].platform}`:"")&&V(c,i),_[1]&1&&p!==(p=e[119].clientId)&&(t.__value=p,t.value=t.__value)},d(f){f&&g(t)}}}function _l(n,e){let t,l=_t(e[103])+"",s,i,c;return{key:n,first:null,c(){t=d("option"),s=E(l),t.__value=i=e[103].name,t.value=t.__value,t.disabled=c=e[103].disabled===!0,this.first=t},m(o,p){k(o,t,p),r(t,s)},p(o,p){e=o,p[1]&4&&l!==(l=_t(e[103])+"")&&V(s,l),p[1]&4&&i!==(i=e[103].name)&&(t.__value=i,t.value=t.__value),p[1]&4&&c!==(c=e[103].disabled===!0)&&(t.disabled=c)},d(o){o&&g(t)}}}function hl(n){let e;return{c(){e=d("p"),e.textContent="该客户端暂无可用打印机,请检查桌面客户端后刷新。",a(e,"class","settings-hint")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function xs(n){let e,t;return{c(){e=d("i"),t=E(" 直发打印"),a(e,"class","svicon sv-print")},m(l,s){k(l,e,s),k(l,t,s)},d(l){l&&g(e),l&&g(t)}}}function ei(n){let e,t;return{c(){e=d("i"),t=E(" 发送中..."),a(e,"class","svicon sv-refresh svp-spin svelte-1v5czrr")},m(l,s){k(l,e,s),k(l,t,s)},d(l){l&&g(e),l&&g(t)}}}function ti(n){let e,t,l=n[20].length+"",s,i,c=n[20].filter(Ze).length+"",o,p,f,_,u=[],v=new Map,m=n[20];const P=C=>C[114].device_id||C[114].id;for(let C=0;C<m.length;C+=1){let w=rl(n,m,C),b=P(w);v.set(b,u[C]=ml(b,w))}return{c(){e=d("div"),t=E("共 "),s=E(l),i=E(" 台设备 · "),o=E(c),p=E(" 台在线"),f=T(),_=d("div");for(let C=0;C<u.length;C+=1)u[C].c();a(e,"class","cloud-device-summary svelte-1v5czrr"),a(_,"class","cloud-device-list svelte-1v5czrr"),a(_,"role","radiogroup"),a(_,"aria-label","选择云打印设备")},m(C,w){k(C,e,w),r(e,t),r(e,s),r(e,i),r(e,o),r(e,p),k(C,f,w),k(C,_,w);for(let b=0;b<u.length;b+=1)u[b]&&u[b].m(_,null)},p(C,w){w[0]&1048576&&l!==(l=C[20].length+"")&&V(s,l),w[0]&1048576&&c!==(c=C[20].filter(Ze).length+"")&&V(o,c),w[0]&9438208|w[1]&134217728&&(m=C[20],u=He(u,w,P,1,C,m,v,_,Re,ml,null,rl))},d(C){C&&g(e),C&&g(f),C&&g(_);for(let w=0;w<u.length;w+=1)u[w].d()}}}function li(n){let e,t=n[22]?"暂无云设备,请在桌面客户端登录当前账户后刷新":"点击刷新获取云设备",l;return{c(){e=d("div"),l=E(t),a(e,"class","settings-empty")},m(s,i){k(s,e,i),r(e,l)},p(s,i){i[0]&4194304&&t!==(t=s[22]?"暂无云设备,请在桌面客户端登录当前账户后刷新":"点击刷新获取云设备")&&V(l,t)},d(s){s&&g(e)}}}function ni(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-refresh svp-spin svelte-1v5czrr"></i> 正在获取云设备...',a(e,"class","cloud-loading svelte-1v5czrr"),a(e,"role","status")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function vl(n){let e,t,l=n[114].client_version+"",s;return{c(){e=d("span"),t=E("v"),s=E(l)},m(i,c){k(i,e,c),r(e,t),r(e,s)},p(i,c){c[0]&1048576&&l!==(l=i[114].client_version+"")&&V(s,l)},d(i){i&&g(e)}}}function ml(n,e){var ue;let t,l,s,i=!1,c,o,p,f,_,u,v=(e[114].device_name||e[114].device_id||"未命名设备")+"",m,P,C,w,b,h=Ze(e[114])?"在线":"离线",z,D,J,H,y=Rl(e[114])+"",L,M,A,j,K=((ue=e[114].printer_count)!=null?ue:"-")+"",I,N,O,U,ee,he,W=(e[114].device_id||e[114].id)+"",B,Q,q,G,x,de=(e[114].last_ip||"-")+"",pe,re,le,me,ke=(e[114].last_heartbeat_time||"-")+"",Se,ve,F,_e,ie,oe=e[114].client_version&&vl(e);return F=vs(e[82][0]),{key:n,first:null,c(){t=d("label"),l=d("input"),c=T(),o=d("span"),o.innerHTML='<i class="svicon sv-client"></i>',p=T(),f=d("span"),_=d("span"),u=d("span"),m=E(v),C=T(),w=d("span"),b=d("span"),z=E(h),D=T(),J=d("span"),H=d("span"),L=E(y),M=T(),oe&&oe.c(),A=T(),j=d("span"),I=E(K),N=E(" 台打印机"),O=T(),U=d("span"),ee=E("设备 ID:"),he=d("span"),B=E(W),Q=T(),q=d("span"),G=d("span"),x=E("最近 IP:"),pe=E(de),re=T(),le=d("span"),me=E("最近心跳:"),Se=E(ke),ve=T(),a(l,"type","radio"),a(l,"name","cloudDevice"),l.__value=s=String(e[114].device_id||e[114].id),l.value=l.__value,l.disabled=e[10],a(l,"class","svelte-1v5czrr"),a(o,"class","cloud-device-icon svelte-1v5czrr"),a(o,"aria-hidden","true"),a(u,"class","cloud-device-name svelte-1v5czrr"),a(u,"title",P=e[114].device_name||e[114].device_id),a(b,"class","cloud-device-dot svelte-1v5czrr"),a(w,"class","cloud-device-status svelte-1v5czrr"),qe(w,"online",Ze(e[114])),a(_,"class","cloud-device-heading svelte-1v5czrr"),a(j,"class","svelte-1v5czrr"),qe(j,"cloud-device-no-printers",e[114].printer_count===0),a(J,"class","cloud-device-meta svelte-1v5czrr"),a(he,"class","svelte-1v5czrr"),a(U,"class","cloud-device-detail svelte-1v5czrr"),a(q,"class","cloud-device-meta svelte-1v5czrr"),a(f,"class","cloud-device-info svelte-1v5czrr"),a(t,"class","cloud-device-item svelte-1v5czrr"),qe(t,"active",e[23]===String(e[114].device_id||e[114].id)),F.p(l),this.first=t},m(be,ce){k(be,t,ce),r(t,l),l.checked=l.__value===e[23],r(t,c),r(t,o),r(t,p),r(t,f),r(f,_),r(_,u),r(u,m),r(_,C),r(_,w),r(w,b),r(w,z),r(f,D),r(f,J),r(J,H),r(H,L),r(J,M),oe&&oe.m(J,null),r(J,A),r(J,j),r(j,I),r(j,N),r(f,O),r(f,U),r(U,ee),r(U,he),r(he,B),r(f,Q),r(f,q),r(q,G),r(G,x),r(G,pe),r(q,re),r(q,le),r(le,me),r(le,Se),r(t,ve),_e||(ie=[Y(l,"change",e[81]),Y(l,"change",e[83])],_e=!0)},p(be,ce){var ge;e=be,ce[0]&1048576&&s!==(s=String(e[114].device_id||e[114].id))&&(l.__value=s,l.value=l.__value,i=!0),ce[0]&1024&&(l.disabled=e[10]),(i||ce[0]&9437184)&&(l.checked=l.__value===e[23]),ce[0]&1048576&&v!==(v=(e[114].device_name||e[114].device_id||"未命名设备")+"")&&V(m,v),ce[0]&1048576&&P!==(P=e[114].device_name||e[114].device_id)&&a(u,"title",P),ce[0]&1048576&&h!==(h=Ze(e[114])?"在线":"离线")&&V(z,h),ce[0]&1048576&&qe(w,"online",Ze(e[114])),ce[0]&1048576&&y!==(y=Rl(e[114])+"")&&V(L,y),e[114].client_version?oe?oe.p(e,ce):(oe=vl(e),oe.c(),oe.m(J,A)):oe&&(oe.d(1),oe=null),ce[0]&1048576&&K!==(K=((ge=e[114].printer_count)!=null?ge:"-")+"")&&V(I,K),ce[0]&1048576&&qe(j,"cloud-device-no-printers",e[114].printer_count===0),ce[0]&1048576&&W!==(W=(e[114].device_id||e[114].id)+"")&&V(B,W),ce[0]&1048576&&de!==(de=(e[114].last_ip||"-")+"")&&V(pe,de),ce[0]&1048576&&ke!==(ke=(e[114].last_heartbeat_time||"-")+"")&&V(Se,ke),ce[0]&9437184&&qe(t,"active",e[23]===String(e[114].device_id||e[114].id))},d(be){be&&g(t),oe&&oe.d(),F.r(),_e=!1,ze(ie)}}}function bl(n){let e,t,l,s,i,c,o,p,f,_,u,v,m,P,C;function w(y,L){return y[24].length?ii:si}let b=w(n),h=b(n),z=n[27]&&kl(n),D=!n[26]&&!n[24].length&&yl();function J(y){n[86](y)}let H={disabled:n[10]||n[21]||n[26]};return n[28]!==void 0&&(H.value=n[28]),u=new mn({props:H}),ot.push(()=>hn(u,"value",J)),{c(){e=d("div"),t=d("label"),t.textContent="打印机",l=T(),h.c(),s=T(),i=d("button"),c=d("i"),p=T(),z&&z.c(),f=T(),D&&D.c(),_=T(),vn(u.$$.fragment),a(t,"class","form-label"),a(t,"for","cloud-printer"),a(c,"class","svicon sv-refresh svelte-1v5czrr"),qe(c,"svp-spin",n[26]),a(i,"class","svp-btn svp-btn-ghost svp-btn-xs"),i.disabled=o=n[10]||n[21]||n[26],a(i,"aria-label","刷新云设备打印机"),a(e,"class","form-row"),Oe(e,"margin-top","10px")},m(y,L){k(y,e,L),r(e,t),r(e,l),h.m(e,null),r(e,s),r(e,i),r(i,c),k(y,p,L),z&&z.m(y,L),k(y,f,L),D&&D.m(y,L),k(y,_,L),Et(u,y,L),m=!0,P||(C=Y(i,"click",n[59]),P=!0)},p(y,L){b===(b=w(y))&&h?h.p(y,L):(h.d(1),h=b(y),h&&(h.c(),h.m(e,s))),(!m||L[0]&67108864)&&qe(c,"svp-spin",y[26]),(!m||L[0]&69207040&&o!==(o=y[10]||y[21]||y[26]))&&(i.disabled=o),y[27]?z?z.p(y,L):(z=kl(y),z.c(),z.m(f.parentNode,f)):z&&(z.d(1),z=null),!y[26]&&!y[24].length?D||(D=yl(),D.c(),D.m(_.parentNode,_)):D&&(D.d(1),D=null);const M={};L[0]&69207040&&(M.disabled=y[10]||y[21]||y[26]),!v&&L[0]&268435456&&(v=!0,M.value=y[28],pn(()=>v=!1)),u.$set(M)},i(y){m||(De(u.$$.fragment,y),m=!0)},o(y){Ye(u.$$.fragment,y),m=!1},d(y){y&&g(e),h.d(),y&&g(p),z&&z.d(y),y&&g(f),D&&D.d(y),y&&g(_),Lt(u,y),P=!1,C()}}}function si(n){let e,t,l,s,i;return{c(){e=d("input"),a(e,"id","cloud-printer"),a(e,"class","svp-input svp-input-sm svp-w-full"),e.disabled=t=n[10]||n[26],a(e,"placeholder",l=n[26]?"正在获取打印机...":"输入设备上的系统打印机名称")},m(c,o){k(c,e,o),Ee(e,n[25]),s||(i=Y(e,"input",n[85]),s=!0)},p(c,o){o[0]&67109888&&t!==(t=c[10]||c[26])&&(e.disabled=t),o[0]&67108864&&l!==(l=c[26]?"正在获取打印机...":"输入设备上的系统打印机名称")&&a(e,"placeholder",l),o[0]&50331648&&e.value!==c[25]&&Ee(e,c[25])},d(c){c&&g(e),s=!1,i()}}}function ii(n){let e,t,l=[],s=new Map,i,c,o,p=n[24];const f=_=>_[103].name;for(let _=0;_<p.length;_+=1){let u=il(n,p,_),v=f(u);s.set(v,l[_]=gl(v,u))}return{c(){e=d("select"),t=d("option"),t.textContent="请选择打印机";for(let _=0;_<l.length;_+=1)l[_].c();t.__value="",t.value=t.__value,a(e,"id","cloud-printer"),a(e,"class","svp-select svp-select-sm svp-w-full"),e.disabled=i=n[10]||n[26],n[25]===void 0&&Je(()=>n[84].call(e))},m(_,u){k(_,e,u),r(e,t);for(let v=0;v<l.length;v+=1)l[v]&&l[v].m(e,null);Ie(e,n[25],!0),c||(o=Y(e,"change",n[84]),c=!0)},p(_,u){u[0]&16777216&&(p=_[24],l=He(l,u,f,1,_,p,s,e,Re,gl,null,il)),u[0]&67109888&&i!==(i=_[10]||_[26])&&(e.disabled=i),u[0]&50331648&&Ie(e,_[25])},d(_){_&&g(e);for(let u=0;u<l.length;u+=1)l[u].d();c=!1,o()}}}function gl(n,e){let t,l=_t(e[103])+"",s,i,c;return{key:n,first:null,c(){t=d("option"),s=E(l),t.__value=i=e[103].name,t.value=t.__value,t.disabled=c=e[103].disabled===!0,this.first=t},m(o,p){k(o,t,p),r(t,s)},p(o,p){e=o,p[0]&16777216&&l!==(l=_t(e[103])+"")&&V(s,l),p[0]&16777216&&i!==(i=e[103].name)&&(t.__value=i,t.value=t.__value),p[0]&16777216&&c!==(c=e[103].disabled===!0)&&(t.disabled=c)},d(o){o&&g(t)}}}function kl(n){let e,t;return{c(){e=d("p"),t=E(n[27]),a(e,"class","settings-hint")},m(l,s){k(l,e,s),r(e,t)},p(l,s){s[0]&134217728&&V(t,l[27])},d(l){l&&g(e)}}}function yl(n){let e;return{c(){e=d("p"),e.textContent="暂无可选打印机,可输入系统打印机名称;离线设备的任务将在上线后投递。",a(e,"class","settings-hint")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function ri(n){let e,t,l,s,i=[],c=new Map,o=n[29];const p=f=>f[109].id||f[109].job_id;for(let f=0;f<o.length;f+=1){let _=sl(n,o,f),u=p(_);c.set(u,i[f]=wl(u,_))}return{c(){e=d("table"),t=d("thead"),t.innerHTML='<tr><th class="svelte-1v5czrr">ID</th><th class="svelte-1v5czrr">设备</th><th class="svelte-1v5czrr">状态</th><th class="svelte-1v5czrr">操作</th></tr>',l=T(),s=d("tbody");for(let f=0;f<i.length;f+=1)i[f].c();a(e,"class","cloud-table svelte-1v5czrr")},m(f,_){k(f,e,_),r(e,t),r(e,l),r(e,s);for(let u=0;u<i.length;u+=1)i[u]&&i[u].m(s,null)},p(f,_){_[0]&536870912|_[2]&3&&(o=f[29],i=He(i,_,p,1,f,o,c,s,Re,wl,null,sl))},d(f){f&&g(e);for(let _=0;_<i.length;_+=1)i[_].d()}}}function oi(n){let e;return{c(){e=d("div"),e.textContent="暂无打印任务",a(e,"class","settings-empty")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function ci(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-refresh svp-spin svelte-1v5czrr"></i> 查询中...',a(e,"class","cloud-loading svelte-1v5czrr")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function wl(n,e){var L;let t,l,s=(e[109].id||e[109].job_id||"-")+"",i,c,o,p=(e[109].device_id||"-")+"",f,_,u,v=((L=e[109].status)!=null?L:"-")+"",m,P,C,w,b,h,z,D,J;function H(){return e[87](e[109])}function y(){return e[88](e[109])}return{key:n,first:null,c(){t=d("tr"),l=d("td"),i=E(s),c=T(),o=d("td"),f=E(p),_=T(),u=d("td"),m=E(v),P=T(),C=d("td"),w=d("button"),w.textContent="重试",b=T(),h=d("button"),h.textContent="取消",z=T(),a(l,"class","svelte-1v5czrr"),a(o,"class","cloud-cell-ellipsis svelte-1v5czrr"),a(u,"class","svelte-1v5czrr"),a(w,"class","svp-btn svp-btn-ghost svp-btn-xs"),a(h,"class","svp-btn svp-btn-ghost svp-btn-xs"),a(C,"class","cloud-cell-actions svelte-1v5czrr"),this.first=t},m(M,A){k(M,t,A),r(t,l),r(l,i),r(t,c),r(t,o),r(o,f),r(t,_),r(t,u),r(u,m),r(t,P),r(t,C),r(C,w),r(C,b),r(C,h),r(t,z),D||(J=[Y(w,"click",H),Y(h,"click",y)],D=!0)},p(M,A){var j;e=M,A[0]&536870912&&s!==(s=(e[109].id||e[109].job_id||"-")+"")&&V(i,s),A[0]&536870912&&p!==(p=(e[109].device_id||"-")+"")&&V(f,p),A[0]&536870912&&v!==(v=((j=e[109].status)!=null?j:"-")+"")&&V(m,v)},d(M){M&&g(t),D=!1,ze(J)}}}function ai(n){let e,t;return{c(){e=d("i"),t=E(" 执行渲染"),a(e,"class","svicon sv-cloud-disk")},m(l,s){k(l,e,s),k(l,t,s)},d(l){l&&g(e),l&&g(t)}}}function ui(n){let e,t;return{c(){e=d("i"),t=E(" 渲染中..."),a(e,"class","svicon sv-refresh svp-spin svelte-1v5czrr")},m(l,s){k(l,e,s),k(l,t,s)},d(l){l&&g(e),l&&g(t)}}}function Tl(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-refresh svp-spin svelte-1v5czrr"></i> 渲染中,等待任务完成...',a(e,"class","cloud-loading svelte-1v5czrr")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function Cl(n){let e,t,l,s,i;function c(f,_){return f[38]?di:fi}let o=c(n),p=o(n);return{c(){e=d("div"),t=T(),l=d("div"),l.textContent="渲染结果",s=T(),p.c(),i=$e(),a(e,"class","settings-divider"),a(l,"class","settings-subtitle")},m(f,_){k(f,e,_),k(f,t,_),k(f,l,_),k(f,s,_),p.m(f,_),k(f,i,_)},p(f,_){o===(o=c(f))&&p?p.p(f,_):(p.d(1),p=o(f),p&&(p.c(),p.m(i.parentNode,i)))},d(f){f&&g(e),f&&g(t),f&&g(l),f&&g(s),p.d(f),f&&g(i)}}}function fi(n){var H;let e,t,l,s=((H=n[4].task_id)!=null?H:"-")+"",i,c,o,p,f=(n[4].file_path||"-")+"",_,u,v,m,P,C,w=n[4].file_size&&zl(n),b=n[4].file_url&&Sl(n),h=n[4].render_ms&&Pl(n);function z(y,L){return y[39]?_i:pi}let D=z(n),J=D(n);return{c(){e=d("div"),t=d("span"),t.textContent="任务 ID",l=d("code"),i=E(s),c=T(),o=d("span"),o.textContent="文件路径",p=d("code"),_=E(f),u=T(),w&&w.c(),v=T(),b&&b.c(),m=T(),h&&h.c(),P=T(),J.c(),C=$e(),a(t,"class","svelte-1v5czrr"),a(l,"class","svelte-1v5czrr"),a(o,"class","svelte-1v5czrr"),a(p,"class","svelte-1v5czrr"),a(e,"class","cloud-kv svelte-1v5czrr")},m(y,L){k(y,e,L),r(e,t),r(e,l),r(l,i),r(e,c),r(e,o),r(e,p),r(p,_),r(e,u),w&&w.m(e,null),r(e,v),b&&b.m(e,null),r(e,m),h&&h.m(e,null),k(y,P,L),J.m(y,L),k(y,C,L)},p(y,L){var M;L[0]&16&&s!==(s=((M=y[4].task_id)!=null?M:"-")+"")&&V(i,s),L[0]&16&&f!==(f=(y[4].file_path||"-")+"")&&V(_,f),y[4].file_size?w?w.p(y,L):(w=zl(y),w.c(),w.m(e,v)):w&&(w.d(1),w=null),y[4].file_url?b?b.p(y,L):(b=Sl(y),b.c(),b.m(e,m)):b&&(b.d(1),b=null),y[4].render_ms?h?h.p(y,L):(h=Pl(y),h.c(),h.m(e,null)):h&&(h.d(1),h=null),D===(D=z(y))&&J?J.p(y,L):(J.d(1),J=D(y),J&&(J.c(),J.m(C.parentNode,C)))},d(y){y&&g(e),w&&w.d(),b&&b.d(),h&&h.d(),y&&g(P),J.d(y),y&&g(C)}}}function di(n){let e,t,l,s=(n[4].error_message||"渲染失败")+"",i;return{c(){e=d("div"),t=d("i"),l=T(),i=E(s),a(t,"class","svicon sv-close"),a(e,"class","cloud-msg msg-error svelte-1v5czrr")},m(c,o){k(c,e,o),r(e,t),r(e,l),r(e,i)},p(c,o){o[0]&16&&s!==(s=(c[4].error_message||"渲染失败")+"")&&V(i,s)},d(c){c&&g(e)}}}function zl(n){let e,t,l;return{c(){e=d("span"),e.textContent="文件大小",t=d("code"),l=E(n[37]),a(e,"class","svelte-1v5czrr"),a(t,"class","svelte-1v5czrr")},m(s,i){k(s,e,i),k(s,t,i),r(t,l)},p(s,i){i[1]&64&&V(l,s[37])},d(s){s&&g(e),s&&g(t)}}}function Sl(n){let e,t,l=n[4].file_url+"",s;return{c(){e=d("span"),e.textContent="文件地址",t=d("code"),s=E(l),a(e,"class","svelte-1v5czrr"),a(t,"class","svelte-1v5czrr")},m(i,c){k(i,e,c),k(i,t,c),r(t,s)},p(i,c){c[0]&16&&l!==(l=i[4].file_url+"")&&V(s,l)},d(i){i&&g(e),i&&g(t)}}}function Pl(n){let e,t,l=n[4].render_ms+"",s,i;return{c(){e=d("span"),e.textContent="渲染耗时",t=d("code"),s=E(l),i=E(" ms"),a(e,"class","svelte-1v5czrr"),a(t,"class","svelte-1v5czrr")},m(c,o){k(c,e,o),k(c,t,o),r(t,s),r(t,i)},p(c,o){o[0]&16&&l!==(l=c[4].render_ms+"")&&V(s,l)},d(c){c&&g(e),c&&g(t)}}}function pi(n){let e;return{c(){e=d("div"),e.textContent="任务未返回文件地址(同步渲染可能只返回文件内容)。",a(e,"class","settings-hint")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function _i(n){let e,t,l,s,i,c;function o(_,u){return _[17]==="img"?vi:hi}let p=o(n),f=p(n);return{c(){e=d("div"),t=d("a"),l=d("i"),s=E(" 下载文件"),i=T(),f.c(),c=$e(),a(l,"class","svicon sv-cloud-disk"),a(t,"class","svp-btn svp-btn-outline svp-btn-sm"),a(t,"href",n[39]),a(t,"target","_blank"),a(t,"rel","noopener"),a(e,"class","form-actions")},m(_,u){k(_,e,u),r(e,t),r(t,l),r(t,s),k(_,i,u),f.m(_,u),k(_,c,u)},p(_,u){u[1]&256&&a(t,"href",_[39]),p===(p=o(_))&&f?f.p(_,u):(f.d(1),f=p(_),f&&(f.c(),f.m(c.parentNode,c)))},d(_){_&&g(e),_&&g(i),f.d(_),_&&g(c)}}}function hi(n){let e,t;return{c(){e=d("iframe"),a(e,"class","cloud-render-frame svelte-1v5czrr"),Ue(e.src,t=n[39])||a(e,"src",t),a(e,"title","渲染结果预览")},m(l,s){k(l,e,s)},p(l,s){s[1]&256&&!Ue(e.src,t=l[39])&&a(e,"src",t)},d(l){l&&g(e)}}}function vi(n){let e,t;return{c(){e=d("img"),a(e,"class","cloud-render-img svelte-1v5czrr"),Oe(e,"object-fit","contain"),Ue(e.src,t=n[39])||a(e,"src",t),a(e,"alt","渲染结果")},m(l,s){k(l,e,s)},p(l,s){s[1]&256&&!Ue(e.src,t=l[39])&&a(e,"src",t)},d(l){l&&g(e)}}}function mi(n){let e,t=[],l=new Map,s=n[15];const i=c=>c[106].template_id;for(let c=0;c<s.length;c+=1){let o=ol(n,s,c),p=i(o);l.set(p,t[c]=El(p,o))}return{c(){e=d("div");for(let c=0;c<t.length;c+=1)t[c].c();a(e,"class","cloud-tpl-list svelte-1v5czrr")},m(c,o){k(c,e,o);for(let p=0;p<t.length;p+=1)t[p]&&t[p].m(e,null)},p(c,o){o[0]&33920|o[1]&16777216&&(s=c[15],t=He(t,o,i,1,c,s,l,e,Re,El,null,ol))},d(c){c&&g(e);for(let o=0;o<t.length;o+=1)t[o].d()}}}function bi(n){let e;return{c(){e=d("div"),e.textContent="暂无模板",a(e,"class","settings-empty")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function gi(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-refresh svp-spin svelte-1v5czrr"></i> 加载中...',a(e,"class","cloud-loading svelte-1v5czrr")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function ki(n){let e;return{c(){e=d("i"),a(e,"class","svicon sv-preview")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function yi(n){let e,t,l;return{c(){e=d("img"),Ue(e.src,t=n[106].preview_img)||a(e,"src",t),a(e,"alt",l=n[106].template_name),a(e,"loading","lazy"),a(e,"class","svelte-1v5czrr")},m(s,i){k(s,e,i)},p(s,i){i[0]&32768&&!Ue(e.src,t=s[106].preview_img)&&a(e,"src",t),i[0]&32768&&l!==(l=s[106].template_name)&&a(e,"alt",l)},d(s){s&&g(e)}}}function wi(n){var i;let e,t=((i=n[106].price)!=null?i:0)+"",l,s;return{c(){e=E("· "),l=E(t),s=E(" 积分")},m(c,o){k(c,e,o),k(c,l,o),k(c,s,o)},p(c,o){var p;o[0]&32768&&t!==(t=((p=c[106].price)!=null?p:0)+"")&&V(l,t)},d(c){c&&g(e),c&&g(l),c&&g(s)}}}function Ti(n){let e;return{c(){e=E("· 免费")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function El(n,e){var ee,he;let t,l,s,i,c,o=e[106].template_name+"",p,f,_,u,v,m=((ee=e[106].use_cnt)!=null?ee:0)+"",P,C,w=((he=e[106].share_cnt)!=null?he:0)+"",b,h,z,D,J,H,y,L,M;function A(W,B){return W[106].preview_img?yi:ki}let j=A(e),K=j(e);function I(W,B){return W[106].is_free?Ti:wi}let N=I(e),O=N(e);function U(){return e[78](e[106])}return{key:n,first:null,c(){t=d("div"),l=d("div"),K.c(),s=T(),i=d("div"),c=d("span"),p=E(o),_=T(),u=d("span"),v=E("使用 "),P=E(m),C=E(" · 分享 "),b=E(w),h=T(),O.c(),z=T(),D=d("button"),J=E("使用"),y=T(),a(l,"class","cloud-tpl-thumb svelte-1v5czrr"),a(c,"class","cloud-tpl-name svelte-1v5czrr"),a(c,"title",f=e[106].template_name),a(u,"class","cloud-tpl-meta svelte-1v5czrr"),a(i,"class","cloud-tpl-info svelte-1v5czrr"),a(D,"class","svp-btn svp-btn-primary svp-btn-xs"),D.disabled=H=e[10]||!e[7],a(t,"class","cloud-tpl-item svelte-1v5czrr"),this.first=t},m(W,B){k(W,t,B),r(t,l),K.m(l,null),r(t,s),r(t,i),r(i,c),r(c,p),r(i,_),r(i,u),r(u,v),r(u,P),r(u,C),r(u,b),r(u,h),O.m(u,null),r(t,z),r(t,D),r(D,J),r(t,y),L||(M=Y(D,"click",U),L=!0)},p(W,B){var Q,q;e=W,j===(j=A(e))&&K?K.p(e,B):(K.d(1),K=j(e),K&&(K.c(),K.m(l,null))),B[0]&32768&&o!==(o=e[106].template_name+"")&&V(p,o),B[0]&32768&&f!==(f=e[106].template_name)&&a(c,"title",f),B[0]&32768&&m!==(m=((Q=e[106].use_cnt)!=null?Q:0)+"")&&V(P,m),B[0]&32768&&w!==(w=((q=e[106].share_cnt)!=null?q:0)+"")&&V(b,w),N===(N=I(e))&&O?O.p(e,B):(O.d(1),O=N(e),O&&(O.c(),O.m(u,null))),B[0]&1152&&H!==(H=e[10]||!e[7])&&(D.disabled=H)},d(W){W&&g(t),K.d(),O.d(),L=!1,M()}}}function Ll(n){let e,t=[],l=new Map,s=n[48];const i=c=>c[103].id;for(let c=0;c<s.length;c+=1){let o=cl(n,s,c),p=i(o);l.set(p,t[c]=Il(p,o))}return{c(){e=d("div");for(let c=0;c<t.length;c+=1)t[c].c();a(e,"class","cloud-provider-tabs svelte-1v5czrr")},m(c,o){k(c,e,o);for(let p=0;p<t.length;p+=1)t[p]&&t[p].m(e,null)},p(c,o){o[0]&1028|o[1]&393216&&(s=c[48],t=He(t,o,i,1,c,s,l,e,Re,Il,null,cl))},d(c){c&&g(e);for(let o=0;o<t.length;o+=1)t[o].d()}}}function Ci(n){let e;return{c(){e=d("span"),e.textContent="!",a(e,"class","cloud-provider-warn svelte-1v5czrr")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function Il(n,e){let t,l=e[103].label+"",s,i,c,o,p,f,_=!e[103].canLogin&&Ci();function u(){return e[73](e[103])}return{key:n,first:null,c(){t=d("button"),s=E(l),i=T(),_&&_.c(),c=T(),a(t,"class",o=Ke(`cloud-provider-tab ${e[103].id===e[2]?"active":""}`)+" svelte-1v5czrr"),t.disabled=e[10],a(t,"title",e[103].canLogin?e[103].label:`${e[103].label}(配置不完整)`),this.first=t},m(v,m){k(v,t,m),r(t,s),r(t,i),_&&_.m(t,null),r(t,c),p||(f=Y(t,"click",u),p=!0)},p(v,m){e=v,m[0]&4&&o!==(o=Ke(`cloud-provider-tab ${e[103].id===e[2]?"active":""}`)+" svelte-1v5czrr")&&a(t,"class",o),m[0]&1024&&(t.disabled=e[10])},d(v){v&&g(t),_&&_.d(),p=!1,f()}}}function zi(n){let e,t,l,s,i=n[5]&&ql(n);return{c(){e=d("p"),t=E(n[40]),l=T(),i&&i.c(),s=$e(),a(e,"class","settings-hint"),Oe(e,"margin","0 0 8px")},m(c,o){k(c,e,o),r(e,t),k(c,l,o),i&&i.m(c,o),k(c,s,o)},p(c,o){o[1]&512&&V(t,c[40]),c[5]?i?i.p(c,o):(i=ql(c),i.c(),i.m(s.parentNode,s)):i&&(i.d(1),i=null)},d(c){c&&g(e),c&&g(l),i&&i.d(c),c&&g(s)}}}function Si(n){let e,t,l,s,i,c=(n[9].client_name||n[9].client_id)+"",o,p,f,_=n[9].client_id+"",u,v,m=n[9].client_type===2&&Ml();return{c(){e=d("div"),t=d("i"),l=T(),s=d("div"),i=d("span"),o=E(c),p=T(),f=d("span"),u=E(_),v=T(),m&&m.c(),a(t,"class","svicon sv-cloud svelte-1v5czrr"),a(i,"class","cloud-client-name svelte-1v5czrr"),a(f,"class","cloud-client-id svelte-1v5czrr"),a(s,"class","cloud-client-info svelte-1v5czrr"),a(e,"class","cloud-client-box svelte-1v5czrr")},m(P,C){k(P,e,C),r(e,t),r(e,l),r(e,s),r(s,i),r(i,o),r(s,p),r(s,f),r(f,u),r(e,v),m&&m.m(e,null)},p(P,C){C[0]&512&&c!==(c=(P[9].client_name||P[9].client_id)+"")&&V(o,c),C[0]&512&&_!==(_=P[9].client_id+"")&&V(u,_),P[9].client_type===2?m||(m=Ml(),m.c(),m.m(e,null)):m&&(m.d(1),m=null)},d(P){P&&g(e),m&&m.d()}}}function ql(n){let e,t,l,s=(n[5].clientId||"未配置")+"",i;return{c(){e=d("div"),t=d("span"),t.textContent="接入方",l=d("code"),i=E(s),a(t,"class","svelte-1v5czrr"),a(l,"class","svelte-1v5czrr"),a(e,"class","cloud-kv svelte-1v5czrr")},m(c,o){k(c,e,o),r(e,t),r(e,l),r(l,i)},p(c,o){o[0]&32&&s!==(s=(c[5].clientId||"未配置")+"")&&V(i,s)},d(c){c&&g(e)}}}function Ml(n){let e;return{c(){e=d("span"),e.textContent="匿名接入",a(e,"class","svp-badge svp-badge-sm")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function Pi(n){let e;function t(i,c){return i[1].hasCustomLoginUI?qi:Ii}let l=t(n),s=l(n);return{c(){e=d("div"),s.c(),a(e,"class","cloud-login-box svelte-1v5czrr")},m(i,c){k(i,e,c),s.m(e,null)},p(i,c){l===(l=t(i))&&s?s.p(i,c):(s.d(1),s=l(i),s&&(s.c(),s.m(e,null)))},d(i){i&&g(e),s.d()}}}function Ei(n){let e;return{c(){e=d("div"),e.innerHTML='<div class="settings-hint">未配置登录方式,仅可浏览模板中心。</div>',a(e,"class","cloud-login-box svelte-1v5czrr")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function Li(n){var J,H,y,L;let e,t,l,s,i=(((J=n[8])==null?void 0:J.member_name)||((H=n[8])==null?void 0:H.member_account)||"已登录")+"",c,o,p,f=(((y=n[8])==null?void 0:y.member_account)||"")+"",_,u,v,m,P,C,w;function b(M,A){var j;return(j=M[8])!=null&&j.member_avatar?Di:Oi}let h=b(n),z=h(n),D=typeof((L=n[8])==null?void 0:L.points)=="number"&&Dl(n);return{c(){e=d("div"),z.c(),t=T(),l=d("div"),s=d("span"),c=E(i),o=T(),p=d("span"),_=E(f),u=T(),D&&D.c(),v=T(),m=d("button"),P=E("退出登录"),a(s,"class","cloud-user-name svelte-1v5czrr"),a(p,"class","cloud-user-sub svelte-1v5czrr"),a(l,"class","cloud-user-info svelte-1v5czrr"),a(m,"class","svp-btn svp-btn-outline svp-btn-sm"),m.disabled=n[10],a(e,"class","cloud-user-box svelte-1v5czrr")},m(M,A){k(M,e,A),z.m(e,null),r(e,t),r(e,l),r(l,s),r(s,c),r(l,o),r(l,p),r(p,_),r(p,u),D&&D.m(p,null),r(e,v),r(e,m),r(m,P),C||(w=Y(m,"click",n[52]),C=!0)},p(M,A){var j,K,I,N;h===(h=b(M))&&z?z.p(M,A):(z.d(1),z=h(M),z&&(z.c(),z.m(e,t))),A[0]&256&&i!==(i=(((j=M[8])==null?void 0:j.member_name)||((K=M[8])==null?void 0:K.member_account)||"已登录")+"")&&V(c,i),A[0]&256&&f!==(f=(((I=M[8])==null?void 0:I.member_account)||"")+"")&&V(_,f),typeof((N=M[8])==null?void 0:N.points)=="number"?D?D.p(M,A):(D=Dl(M),D.c(),D.m(p,null)):D&&(D.d(1),D=null),A[0]&1024&&(m.disabled=M[10])},d(M){M&&g(e),z.d(),D&&D.d(),C=!1,w()}}}function Ii(n){let e,t,l,s,i,c;function o(u,v){return u[10]?Ai:Mi}let p=o(n),f=p(n),_=!n[43]&&Al();return{c(){e=d("button"),f.c(),l=T(),_&&_.c(),s=$e(),a(e,"class","svp-btn svp-btn-primary svp-btn-sm"),e.disabled=t=n[10]||!n[43]},m(u,v){k(u,e,v),f.m(e,null),k(u,l,v),_&&_.m(u,v),k(u,s,v),i||(c=Y(e,"click",n[51]),i=!0)},p(u,v){p===(p=o(u))&&f?f.p(u,v):(f.d(1),f=p(u),f&&(f.c(),f.m(e,null))),v[0]&1024|v[1]&4096&&t!==(t=u[10]||!u[43])&&(e.disabled=t),u[43]?_&&(_.d(1),_=null):_||(_=Al(),_.c(),_.m(s.parentNode,s))},d(u){u&&g(e),f.d(),u&&g(l),_&&_.d(u),u&&g(s),i=!1,c()}}}function qi(n){let e=n[2],t,l=Ol(n);return{c(){l.c(),t=$e()},m(s,i){l.m(s,i),k(s,t,i)},p(s,i){i[0]&4&&zt(e,e=s[2])?(l.d(1),l=Ol(s),l.c(),l.m(t.parentNode,t)):l.p(s,i)},d(s){s&&g(t),l.d(s)}}}function Mi(n){let e,t,l=n[2]==="oauth"?"去授权登录":"登录",s;return{c(){e=d("i"),t=T(),s=E(l),a(e,"class","svicon sv-cloud")},m(i,c){k(i,e,c),k(i,t,c),k(i,s,c)},p(i,c){c[0]&4&&l!==(l=i[2]==="oauth"?"去授权登录":"登录")&&V(s,l)},d(i){i&&g(e),i&&g(t),i&&g(s)}}}function Ai(n){let e,t;return{c(){e=d("i"),t=E(" 登录中..."),a(e,"class","svicon sv-refresh svp-spin svelte-1v5czrr")},m(l,s){k(l,e,s),k(l,t,s)},p:fe,d(l){l&&g(e),l&&g(t)}}}function Al(n){let e;return{c(){e=d("div"),e.textContent="登录方式配置不完整,请检查插件配置。",a(e,"class","settings-hint")},m(t,l){k(t,e,l)},d(t){t&&g(e)}}}function Ol(n){let e;return{c(){e=d("div"),a(e,"class","cloud-auth-custom")},m(t,l){k(t,e,l),n[74](e)},p:fe,d(t){t&&g(e),n[74](null)}}}function Oi(n){let e;return{c(){e=d("i"),a(e,"class","svicon sv-client cloud-avatar-icon svelte-1v5czrr")},m(t,l){k(t,e,l)},p:fe,d(t){t&&g(e)}}}function Di(n){let e,t;return{c(){e=d("img"),a(e,"class","cloud-avatar svelte-1v5czrr"),Ue(e.src,t=n[8].member_avatar)||a(e,"src",t),a(e,"alt","avatar")},m(l,s){k(l,e,s)},p(l,s){s[0]&256&&!Ue(e.src,t=l[8].member_avatar)&&a(e,"src",t)},d(l){l&&g(e)}}}function Dl(n){let e,t=n[8].points+"",l;return{c(){e=E("· 积分 "),l=E(t)},m(s,i){k(s,e,i),k(s,l,i)},p(s,i){i[0]&256&&t!==(t=s[8].points+"")&&V(l,t)},d(s){s&&g(e),s&&g(l)}}}function Ul(n){let e,t,l,s;return{c(){e=d("div"),t=d("i"),l=T(),s=E(n[13]),a(t,"class","svicon sv-print"),a(e,"class","cloud-msg msg-success svelte-1v5czrr")},m(i,c){k(i,e,c),r(e,t),r(e,l),r(e,s)},p(i,c){c[0]&8192&&V(s,i[13])},d(i){i&&g(e)}}}function Nl(n){let e,t,l,s;return{c(){e=d("div"),t=d("i"),l=T(),s=E(n[11]),a(t,"class","svicon sv-close"),a(e,"class","cloud-msg msg-error svelte-1v5czrr")},m(i,c){k(i,e,c),r(e,t),r(e,l),r(e,s)},p(i,c){c[0]&2048&&V(s,i[11])},d(i){i&&g(e)}}}function Jl(n){let e,t;return{c(){e=d("pre"),t=E(n[12]),a(e,"class","cloud-output svelte-1v5czrr")},m(l,s){k(l,e,s),r(e,t)},p(l,s){s[0]&4096&&V(t,l[12])},d(l){l&&g(e)}}}function Ui(n){let e,t,l,s,i,c,o,p,f,_=n[7]?"已登录":"未登录",u,v,m=[],P=new Map,C,w,b,h,z,D,J,H,y=n[47];const L=O=>O[122].key;for(let O=0;O<y.length;O+=1){let U=al(n,y,O),ee=L(U);P.set(ee,m[O]=ul(ee,U))}const M=[Vs,Gs,Ks,Fs,js,Bs],A=[];function j(O,U){return O[6]==="account"?0:O[6]==="template"?1:O[6]==="render"?2:O[6]==="cloudPrint"?3:O[6]==="transit"?4:O[6]==="config"?5:-1}~(b=j(n))&&(h=A[b]=M[b](n));let K=n[13]&&Ul(n),I=n[11]&&Nl(n),N=n[12]&&Jl(n);return{c(){e=d("p"),e.textContent="通过 sv-print-cloud 云服务进行服务端渲染、云打印与中转打印。首次使用请在「账户」中登录。",t=T(),l=d("div"),s=d("div"),i=d("div"),c=d("span"),p=T(),f=d("span"),u=E(_),v=T();for(let O=0;O<m.length;O+=1)m[O].c();C=T(),w=d("div"),h&&h.c(),z=T(),K&&K.c(),D=T(),I&&I.c(),J=T(),N&&N.c(),a(e,"class","settings-hint"),a(c,"class",o=Ke(`cloud-status-dot ${n[7]?"dot-on":"dot-off"}`)+" svelte-1v5czrr"),a(f,"class","cloud-status-text svelte-1v5czrr"),a(i,"class","cloud-status-bar svelte-1v5czrr"),a(s,"class","cloud-sidebar svelte-1v5czrr"),a(w,"class","cloud-content svelte-1v5czrr"),a(l,"class","cloud-layout svelte-1v5czrr")},m(O,U){k(O,e,U),k(O,t,U),k(O,l,U),r(l,s),r(s,i),r(i,c),r(i,p),r(i,f),r(f,u),r(s,v);for(let ee=0;ee<m.length;ee+=1)m[ee]&&m[ee].m(s,null);r(l,C),r(l,w),~b&&A[b].m(w,null),r(w,z),K&&K.m(w,null),r(w,D),I&&I.m(w,null),r(w,J),N&&N.m(w,null),H=!0},p(O,U){(!H||U[0]&128&&o!==(o=Ke(`cloud-status-dot ${O[7]?"dot-on":"dot-off"}`)+" svelte-1v5czrr"))&&a(c,"class",o),(!H||U[0]&128)&&_!==(_=O[7]?"已登录":"未登录")&&V(u,_),U[0]&64|U[1]&589824&&(y=O[47],m=He(m,U,L,1,O,y,P,s,Re,ul,null,al));let ee=b;b=j(O),b===ee?~b&&A[b].p(O,U):(h&&(St(),Ye(A[ee],1,1,()=>{A[ee]=null}),Pt()),~b?(h=A[b],h?h.p(O,U):(h=A[b]=M[b](O),h.c()),De(h,1),h.m(w,z)):h=null),O[13]?K?K.p(O,U):(K=Ul(O),K.c(),K.m(w,D)):K&&(K.d(1),K=null),O[11]?I?I.p(O,U):(I=Nl(O),I.c(),I.m(w,J)):I&&(I.d(1),I=null),O[12]?N?N.p(O,U):(N=Jl(O),N.c(),N.m(w,null)):N&&(N.d(1),N=null)},i(O){H||(De(h),H=!0)},o(O){Ye(h),H=!1},d(O){O&&g(e),O&&g(t),O&&g(l);for(let U=0;U<m.length;U+=1)m[U].d();~b&&A[b].d(),K&&K.d(),I&&I.d(),N&&N.d()}}}function Ni(n,e=1){if(!Number.isFinite(n)||n<0)return"—";if(n<1024)return`${n} B`;const t=["KB","MB","GB","TB","PB"];let l=n,s=-1;do l/=1024,s++;while(l>=1024&&s<t.length-1);return`${l.toFixed(e).replace(/\.0+$/,"")} ${t[s]}`}function Ze(n){var e,t;return(t=(e=n.online)!=null?e:n.socket_online)!=null?t:!1}function Rl(n){return[{darwin:"macOS",win32:"Windows",linux:"Linux"}[n.platform||""]||n.platform,n.arch].filter(Boolean).join(" · ")||"未知平台"}function Hl(n){var e;return((e=n.find(t=>t.isDefault&&!t.disabled)||n.find(t=>!t.disabled))==null?void 0:e.name)||""}function _t(n){return`${n.displayName||n.name}${n.isDefault?"(默认)":""}${n.disabled?"(已禁用)":n.isOk===!1?"(状态异常)":""}`}function Ji(n,e,t){let l,s,i,c,o,p,f,_,u,v,m,P,C,{config:w}=e,{auth:b}=e,{service:h}=e;const z=[{key:"account",label:"账户",icon:"sv-client"},{key:"template",label:"模板中心",icon:"sv-templates"},{key:"render",label:"服务端渲染",icon:"sv-cloud-disk"},{key:"cloudPrint",label:"云打印",icon:"sv-printer"},{key:"transit",label:"中转打印",icon:"sv-flow"}];w.settingsTabShowConfig!=!1&&z.push({key:"config",label:"连接配置",icon:"sv-setting"});const D={iframe:"设计器内弹层",popup:"独立弹窗",page:"新标签页",custom:"自定义"},J={oauth:"跳转 sv-print 授权页完成授权后获取访问令牌,令牌失效需重新授权。",token:"直接使用访问令牌接入,无需授权流程;令牌由接入方自行提供与维护。",host:"访问令牌由宿主系统提供,插件不参与认证,登录态跟随宿主。",local:"使用宿主账号密码登录,由宿主校验通过后返回访问令牌。",none:"未配置登录方式,仅可浏览模板中心,写操作需先配置登录方式。"};let H="account",y=b.activeId,L=b.providers,M=b.isLoggedIn(),A,j=null,K=null,I=!1,N="",O="",U="",ee="",he=[],W=!1,B="pdf",Q=!0,q=null,G=!1,x=[],de=!1,pe=!1,re="",le=[],me="",ke=!1,Se="",ve=0,F=el(),_e=[],ie=!1,oe=[],ue="",be=[],ce="",ge=el(),Pe=!1,Me=0;gs(()=>{const S=h.onTransitConnectionChange(se=>{t(36,Pe=se),se||(t(10,I=!1),Me++,t(31,oe=[]),t(33,be=[]),t(32,ue=""),t(34,ce=""))}),$=b.onChange(se=>{const Te=!!(se!=null&&se.accessToken),ut=Te!==M;t(7,M=Te),Te||t(8,j=null),Te&&ut&&Ae()});return Be(),M&&Ae(),()=>{$==null||$(),S()}});function Be(){b.getClientInfo().then(S=>t(9,K=S)).catch(()=>t(9,K=null))}function Ne(S){return X(this,null,function*(){if(!(S===y||I)){t(10,I=!0),t(11,N="");try{yield b.switchProvider(S),t(2,y=b.activeId),t(7,M=b.isLoggedIn()),t(8,j=null),t(9,K=null),Be(),M&&(yield Ae())}catch($){t(11,N=($==null?void 0:$.message)||"切换登录方式失败")}finally{t(10,I=!1)}}})}function je(S,$="success"){var se,Te;(Te=(se=Rt())==null?void 0:se.showToast)==null||Te.call(se,S,{type:$})}function ye(S){t(13,U=S),setTimeout(()=>t(13,U=""),3e3)}function we(S){t(6,H=S),t(11,N=""),t(12,O=""),S==="template"&&he.length===0&&R()}function Ae(){return X(this,null,function*(){try{t(8,j=yield b.getUser())}catch(S){t(8,j=null)}})}function Ve(){return X(this,null,function*(){t(10,I=!0),t(11,N="");try{yield b.login(),yield Ae()}catch(S){t(11,N=(S==null?void 0:S.message)||"登录失败")}finally{t(10,I=!1)}})}function Ce(){return X(this,null,function*(){t(10,I=!0),t(11,N="");try{yield b.logout(),t(8,j=null)}finally{t(10,I=!1)}})}function R(){return X(this,null,function*(){t(16,W=!0),t(11,N="");try{const S=yield h.listTemplates({keyword:ee,page:1,pageSize:5});t(15,he=(S==null?void 0:S.list)||[])}catch(S){t(11,N=(S==null?void 0:S.message)||"加载模板失败")}finally{t(16,W=!1)}})}function Z(){return X(this,null,function*(){t(10,I=!0),t(11,N="");try{const S=yield h.useRandomTemplate({keyword:ee||void 0});ye(`已随机应用模板:${S.template_name}`),je(`已应用模板:${S.template_name}`)}catch(S){t(11,N=(S==null?void 0:S.message)||"随机使用模板失败")}finally{t(10,I=!1)}})}function ne(S){return X(this,null,function*(){t(10,I=!0),t(11,N="");try{yield h.applyTemplate(S),ye(`已应用模板:${S.template_name}`),je(`已应用模板:${S.template_name}`)}catch($){t(11,N=($==null?void 0:$.message)||"应用模板失败")}finally{t(10,I=!1)}})}function ae(S,$){return X(this,null,function*(){t(10,I=!0),t(11,N=""),t(12,O=`${S} 调用中...`);try{const se=yield $();t(12,O=`// ${S}
30
+ ${JSON.stringify(se,null,2)}`)}catch(se){t(11,N=`${S} 失败:${(se==null?void 0:se.message)||se}`),t(12,O="")}finally{t(10,I=!1)}})}function Le(){return X(this,null,function*(){t(10,I=!0),t(11,N=""),t(12,O=""),t(4,q=null),t(19,G=!1);try{const S=yield h.render({sync:Q,type:B});if(t(4,q=S),!Q&&(S==null?void 0:S.task_id)!==void 0){t(19,G=!0);try{t(4,q=yield h.waitRender(S.task_id))}finally{t(19,G=!1)}}(Number(q==null?void 0:q.status)===2||!!(q!=null&&q.file_url))&&(ye("渲染成功"),je("渲染成功"))}catch(S){t(11,N=`服务端渲染失败:${(S==null?void 0:S.message)||S}`),t(4,q=null)}finally{t(10,I=!1)}})}function xe(){return X(this,null,function*(){t(21,de=!0),t(11,N="");try{const S=yield h.getDevices();if(t(20,x=(S==null?void 0:S.list)||S||[]),t(22,pe=!0),!x.some($=>String($.device_id||$.id)===re)){const $=x.find(Ze)||x[0];t(23,re=$?String($.device_id||$.id):"")}yield ht(),ye(`已获取 ${x.length} 个云设备`)}catch(S){t(11,N=(S==null?void 0:S.message)||"获取云设备失败")}finally{t(21,de=!1)}})}function Mt(S){t(23,re=S),t(25,me=""),ht()}function ht(){return X(this,null,function*(){const S=re,$=me,se=++ve;if(t(24,le=[]),t(25,me=""),t(27,Se=""),t(26,ke=!!S),!!S)try{const Te=yield h.getDevicePrinters(S);if(se!==ve||re!==S)return;t(24,le=Array.isArray(Te)?Te:[]),t(25,me=le.some(ut=>ut.name===$&&!ut.disabled)?$:Hl(le))}catch(Te){se===ve&&t(27,Se=(Te==null?void 0:Te.message)||"获取打印机失败")}finally{se===ve&&t(26,ke=!1)}})}function ct(){return X(this,null,function*(){t(30,ie=!0),t(11,N="");try{const S=yield h.getJobs({page:1,pageSize:10});t(29,_e=(S==null?void 0:S.list)||[])}catch(S){t(11,N=(S==null?void 0:S.message)||"获取云任务失败")}finally{t(30,ie=!1)}})}function bn(){return X(this,null,function*(){if(!re){t(11,N="请先选择云设备");return}let S;try{S=tl(F,me)}catch($){t(11,N=$.message);return}yield ae("云打印下发",()=>h.cloudPrint({device_id:re,print_type:"template",print_options:S})),ct()})}function At(S){return X(this,null,function*(){yield ae("取消云任务",()=>h.cancelJob(S)),ct()})}function Ot(S){return X(this,null,function*(){yield ae("重试云任务",()=>h.retryJob(S)),ct()})}function gn(){return X(this,null,function*(){var S;t(10,I=!0),t(11,N="");try{const $=yield h.getTransitClients();t(31,oe=$.filter(se=>se.clientType==="electron")),t(36,Pe=!0),oe.some(se=>se.clientId===ue)||(Me++,t(32,ue=((S=oe[0])==null?void 0:S.clientId)||""),t(33,be=[]),t(34,ce="")),ye(`已连接,${oe.length} 个在线客户端`),ue&&(yield at(ue))}catch($){t(36,Pe=!1),t(11,N=($==null?void 0:$.message)||"获取中转客户端失败")}finally{t(10,I=!1)}})}function kn(){Me++,h.disconnectTransit(),t(36,Pe=!1),t(31,oe=[]),t(33,be=[]),t(32,ue=""),t(34,ce="")}function at(){return X(this,arguments,function*(S=ue){const $=++Me;if(!S){t(11,N="请先选择中转客户端");return}t(10,I=!0),t(11,N="");try{const se=yield h.getTransitPrinters(S);if($!==Me||S!==ue)return;t(33,be=Array.isArray(se)?se:(se==null?void 0:se.list)||[]),be.some(Te=>Te.name===ce&&!Te.disabled)||t(34,ce=Hl(be)),ye(`已获取 ${be.length} 台打印机`)}catch(se){$===Me&&S===ue&&t(11,N=(se==null?void 0:se.message)||"获取中转打印机失败")}finally{$===Me&&t(10,I=!1)}})}function Dt(S){t(32,ue=S),t(34,ce=""),t(33,be=[]),at(S)}function yn(){return X(this,null,function*(){if(!ue){t(11,N="请选择目标中转客户端");return}if(!ce){t(11,N="请选择打印机");return}let S;try{S=tl(ge,ce)}catch($){t(11,N=$.message);return}t(10,I=!0),t(11,N=""),t(13,U="");try{const $=yield h.transitPrint({clientId:ue,printer:ce,print_options:S});t(13,U=`客户端打印成功${$!=null&&$.msg?`:${$.msg}`:""}`),je(U)}catch($){t(11,N=`中转打印失败:${($==null?void 0:$.message)||$}`)}finally{t(10,I=!1)}})}const wn=[[]],Tn=S=>we(S.key),Cn=S=>Ne(S.id);function zn(S){ot[S?"unshift":"push"](()=>{A=S,t(3,A)})}function Sn(){ee=this.value,t(14,ee)}const Pn=S=>S.key==="Enter"&&R(),En=()=>{var S,$,se,Te;return(Te=(se=($=(S=Rt())==null?void 0:S.cloud)==null?void 0:$.templateCenter)==null?void 0:se.show)==null?void 0:Te.call(se)},Ln=S=>ne(S);function In(){B=We(this),t(17,B)}function qn(){Q=this.checked,t(18,Q)}function Mn(){re=this.__value,t(23,re)}const An=S=>Mt(S.currentTarget.value);function On(){me=We(this),t(25,me),t(24,le)}function Dn(){me=this.value,t(25,me),t(24,le)}function Un(S){F=S,t(28,F)}const Nn=S=>Ot(S.id||S.job_id),Jn=S=>At(S.id||S.job_id);function Rn(){ue=We(this),t(32,ue),t(31,oe)}const Hn=S=>Dt(S.currentTarget.value);function Bn(){ce=We(this),t(34,ce),t(33,be)}const jn=()=>at();function Fn(S){ge=S,t(35,ge)}return n.$$set=S=>{"config"in S&&t(0,w=S.config),"auth"in S&&t(1,b=S.auth),"service"in S&&t(69,h=S.service)},n.$$.update=()=>{n.$$.dirty[0]&4&&t(71,s=L.find(S=>S.id===y)),n.$$.dirty[0]&6&&t(70,i=y?b.providerConfig:null),n.$$.dirty[0]&2|n.$$.dirty[2]&512&&t(45,c=(s==null?void 0:s.label)||b.label),n.$$.dirty[0]&6&&t(44,o=y?b.storageKey:""),n.$$.dirty[2]&512&&t(43,p=!!(s!=null&&s.canLogin)),n.$$.dirty[2]&256&&t(5,f=i&&i.type==="oauth"?i:null),n.$$.dirty[0]&32&&t(42,_=Array.isArray(f==null?void 0:f.scope)?f==null?void 0:f.scope.join(", "):(f==null?void 0:f.scope)||"(默认全部)"),n.$$.dirty[0]&32&&t(41,u=D[(f==null?void 0:f.mode)||"iframe"]||"设计器内弹层"),n.$$.dirty[0]&4&&t(40,v=J[y]||""),n.$$.dirty[0]&14&&A&&y&&b.renderLogin(A),n.$$.dirty[0]&16&&t(39,m=(q==null?void 0:q.file_url)||""),n.$$.dirty[0]&16&&t(38,P=Number(q==null?void 0:q.status)===3),n.$$.dirty[0]&16&&t(37,C=Ni((q==null?void 0:q.file_size)||0))},t(46,l=L.length>1),[w,b,y,A,q,f,H,M,j,K,I,N,O,U,ee,he,W,B,Q,G,x,de,pe,re,le,me,ke,Se,F,_e,ie,oe,ue,be,ce,ge,Pe,C,P,m,v,u,_,p,o,c,l,z,L,Ne,we,Ve,Ce,R,Z,ne,Le,xe,Mt,ht,ct,bn,At,Ot,gn,kn,at,Dt,yn,h,i,s,Tn,Cn,zn,Sn,Pn,En,Ln,In,qn,Mn,wn,An,On,Dn,Un,Nn,Jn,Rn,Hn,Bn,jn,Fn]}class Ri extends qt{constructor(e){super(),It(this,e,Ji,Ui,zt,{config:0,auth:1,service:69},null,[-1,-1,-1,-1,-1])}}const Hi=Object.freeze(Object.defineProperty({__proto__:null,default:Ri},Symbol.toStringTag,{value:"Module"}));exports.AuthManager=on;exports.CloudClient=jl;exports.CloudService=an;exports.HostAuthProvider=Ql;exports.LocalAuthProvider=Zl;exports.NoneAuthProvider=Tt;exports.OAuthAuthProvider=Yl;exports.TokenAuthProvider=Xl;exports.TransitClient=cn;exports.createAuthProvider=xl;exports.default=ds;exports.defaultStorageKey=en;exports.extendTemplate=yt;exports.memoryStorageToken=ss;exports.normalizeAuthConfig=$l;exports.preferencesTokenStorage=sn;exports.readActiveProvider=tn;exports.relayOAuthCallback=Wl;exports.resolveStorage=rn;exports.resolveStorageKey=Ct;exports.sessionStorageToken=ns;exports.writeActiveProvider=dt;