1 |
- const I=[["(",")"],[")","("],["<",">"],[">","<"],["[","]"],["]","["],["{","}"],["}","{"],["\xAB","\xBB"],["\xBB","\xAB"],["\u2039","\u203A"],["\u203A","\u2039"],["\u207D","\u207E"],["\u207E","\u207D"],["\u208D","\u208E"],["\u208E","\u208D"],["\u2264","\u2265"],["\u2265","\u2264"],["\u2329","\u232A"],["\u232A","\u2329"],["\uFE59","\uFE5A"],["\uFE5A","\uFE59"],["\uFE5B","\uFE5C"],["\uFE5C","\uFE5B"],["\uFE5D","\uFE5E"],["\uFE5E","\uFE5D"],["\uFE64","\uFE65"],["\uFE65","\uFE64"]],V=["\u0622","\u0623","\u0625","\u0627"],$=["\uFEF5","\uFEF7","\uFEF9","\uFEFB"],tt=["\uFEF6","\uFEF8","\uFEFA","\uFEFC"],k=["\u0627","\u0628","\u062A","\u062B","\u062C","\u062D","\u062E","\u062F","\u0630","\u0631","\u0632","\u0633","\u0634","\u0635","\u0636","\u0637","\u0638","\u0639","\u063A","\u0641","\u0642","\u0643","\u0644","\u0645","\u0646","\u0647","\u0648","\u064A","\u0625","\u0623","\u0622","\u0629","\u0649","\u0644","\u0645","\u0646","\u0647","\u0648","\u064A","\u0625","\u0623","\u0622","\u0629","\u0649","\u06CC","\u0626","\u0624"],rt=["\uFE8D","\uFE8F","\uFE95","\uFE99","\uFE9D","\uFEA1","\uFEA5","\uFEA9","\uFEAB","\uFEAD","\uFEAF","\uFEB1","\uFEB5","\uFEB9","\uFEBD","\uFEC1","\uFEC5","\uFEC9","\uFECD","\uFED1","\uFED5","\uFED9","\uFEDD","\uFEE1","\uFEE5","\uFEE9","\uFEED","\uFEF1","\uFE87","\uFE83","\uFE81","\uFE93","\uFEEF","\uFBFC","\uFE89","\uFE85","\uFE70","\uFE72","\uFE74","\uFE76","\uFE78","\uFE7A","\uFE7C","\uFE7E","\uFE80","\uFE89","\uFE85"],et=["\uFE8E","\uFE90","\uFE96","\uFE9A","\uFE9E","\uFEA2","\uFEA6","\uFEAA","\uFEAC","\uFEAE","\uFEB0","\uFEB2","\uFEB6","\uFEBA","\uFEBE","\uFEC2","\uFEC6","\uFECA","\uFECE","\uFED2","\uFED6","\uFEDA","\uFEDE","\uFEE2","\uFEE6","\uFEEA","\uFEEE","\uFEF2","\uFE88","\uFE84","\uFE82","\uFE94","\uFEF0","\uFBFD","\uFE8A","\uFE86","\uFE70","\uFE72","\uFE74","\uFE76","\uFE78","\uFE7A","\uFE7C","\uFE7E","\uFE80","\uFE8A","\uFE86"],nt=["\uFE8E","\uFE92","\uFE98","\uFE9C","\uFEA0","\uFEA4","\uFEA8","\uFEAA","\uFEAC","\uFEAE","\uFEB0","\uFEB4","\uFEB8","\uFEBC","\uFEC0","\uFEC4","\uFEC8","\uFECC","\uFED0","\uFED4","\uFED8","\uFEDC","\uFEE0","\uFEE4","\uFEE8","\uFEEC","\uFEEE","\uFEF4","\uFE88","\uFE84","\uFE82","\uFE94","\uFEF0","\uFBFF","\uFE8C","\uFE86","\uFE71","\uFE72","\uFE74","\uFE77","\uFE79","\uFE7B","\uFE7D","\uFE7F","\uFE80","\uFE8C","\uFE86"],ot=["\uFE8D","\uFE91","\uFE97","\uFE9B","\uFE9F","\uFEA3","\uFEA7","\uFEA9","\uFEAB","\uFEAD","\uFEAF","\uFEB3","\uFEB7","\uFEBB","\uFEBF","\uFEC3","\uFEC7","\uFECB","\uFECF","\uFED3","\uFED7","\uFEDB","\uFEDF","\uFEE3","\uFEE7","\uFEEB","\uFEED","\uFEF3","\uFE87","\uFE83","\uFE81","\uFE93","\uFEEF","\uFBFE","\uFE8B","\uFE85","\uFE70","\uFE72","\uFE74","\uFE76","\uFE78","\uFE7A","\uFE7C","\uFE7E","\uFE80","\uFE8B","\uFE85"],z=["\u0621","\u0622","\u0623","\u0624","\u0625","\u0627","\u0629","\u062F","\u0630","\u0631","\u0632","\u0648","\u0649"],it=["\u064B","\u064B","\u064C","\u061F","\u064D","\u061F","\u064E","\u064E","\u064F","\u064F","\u0650","\u0650","\u0651","\u0651","\u0652","\u0652","\u0621","\u0622","\u0622","\u0623","\u0623","\u0624","\u0624","\u0625","\u0625","\u0626","\u0626","\u0626","\u0626","\u0627","\u0627","\u0628","\u0628","\u0628","\u0628","\u0629","\u0629","\u062A","\u062A","\u062A","\u062A","\u062B","\u062B","\u062B","\u062B","\u062C","\u062C","\u062C","\u062C","\u062D","\u062D","\u062D","\u062D","\u062E","\u062E","\u062E","\u062E","\u062F","\u062F","\u0630","\u0630","\u0631","\u0631","\u0632","\u0632","\u0633","\u0633","\u0633","\u0633","\u0634","\u0634","\u0634","\u0634","\u0635","\u0635","\u0635","\u0635","\u0636","\u0636","\u0636","\u0636","\u0637","\u0637","\u0637","\u0637","\u0638","\u0638","\u0638","\u0638","\u0639","\u0639","\u0639","\u0639","\u063A","\u063A","\u063A","\u063A","\u0641","\u0641","\u0641","\u0641","\u0642","\u0642","\u0642","\u0642","\u0643","\u0643","\u0643","\u0643","\u0644","\u0644","\u0644","\u0644","\u0645","\u0645","\u0645","\u0645","\u0646","\u0646","\u0646","\u0646","\u0647","\u0647","\u0647","\u0647","\u0648","\u0648","\u0649","\u0649","\u064A","\u064A","\u064A","\u064A","\uFEF5","\uFEF6","\uFEF7","\uFEF8","\uFEF9","\uFEFA","\uFEFB","\uFEFC","\u061F","\u061F","\u061F"],q=["\u0621","\u0641"],ut=["\u063A","\u064A"],st=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],at=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],e=0,s=1,h=2,B=3,t=4,_=5,j=6,r=7,m=8,R=9,b=10,T=11,n=12,ft=13,ct=14,lt=15,ht=16,Tt=17,l=18,At=["UBAT_L","UBAT_R","UBAT_EN","UBAT_AN","UBAT_ON","UBAT_B","UBAT_S","UBAT_AL","UBAT_WS","UBAT_CS","UBAT_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r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,t,t,l],[t,t,t,T,T,T,t,t,t,t,t,b,R,b,R,R,h,h,h,h,h,h,h,h,h,h,R,t,t,t,t,t,t,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,t,t,t,t,t,t,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,t,t,t,t,t,t,t,t,t,t,t,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,t,t,t,e,e,e,e,e,e,t,t,e,e,e,e,e,e,t,t,e,e,e,e,e,e,t,t,e,e,e,t,t,t,T,T,t,t,t,T,T,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t]];class Pt{constructor(){this.inputFormat="ILYNN",this.outputFormat="VLNNN",this.sourceToTarget=[],this.targetToSource=[],this.levels=[]}bidiTransform(o,u,a){if(this.sourceToTarget=[],this.targetToSource=[],!o)return"";if(Ot(this.sourceToTarget,this.targetToSource,o.length),!this.checkParameters(u,a))return o;u=this.inputFormat,a=this.outputFormat;let f=o;const c=It,L=H(u.charAt(1)),A=H(a.charAt(1)),g=(u.charAt(0)==="I"?"L":u.charAt(0))+L,d=(a.charAt(0)==="I"?"L":a.charAt(0))+A,U=u.charAt(2)+a.charAt(2);c.defInFormat=g,c.defOutFormat=d,c.defSwap=U;const w=E(o,g,d,U,c);let N=!1;return a.charAt(1)==="R"?N=!0:a.charAt(1)!=="C"&&a.charAt(1)!=="D"||(N=this.checkContextual(w)==="rtl"),this.sourceToTarget=F,this.targetToSource=xt(this.sourceToTarget),P=this.targetToSource,f=u.charAt(3)===a.charAt(3)?w:a.charAt(3)==="S"?Bt(N,w,!0):Rt(w,N,!0),this.sourceToTarget=F,this.targetToSource=P,this.levels=y,f}_inputFormatSetter(o){if(!J.test(o))throw new Error("dojox/string/BidiEngine: the bidi layout string is wrong!");this.inputFormat=o}_outputFormatSetter(o){if(!J.test(o))throw new Error("dojox/string/BidiEngine: the bidi layout string is wrong!");this.outputFormat=o}checkParameters(o,u){return o?this._inputFormatSetter(o):o=this.inputFormat,u?this._outputFormatSetter(u):u=this.outputFormat,o!==u}checkContextual(o){let u=D(o);if(u!=="ltr"&&u!=="rtl"){try{u=document.dir.toLowerCase()}catch{}u!=="ltr"&&u!=="rtl"&&(u="ltr")}return u}hasBidiChar(o){return Dt.test(o)}}function E(i,o,u,a,f){const c=dt(i,{inFormat:o,outFormat:u,swap:a},f);if(c.inFormat===c.outFormat)return i;o=c.inFormat,u=c.outFormat,a=c.swap;const L=o.substring(0,1),A=o.substring(1,4),g=u.substring(0,1),d=u.substring(1,4);if(f.inFormat=o,f.outFormat=u,f.swap=a,L==="L"&&u==="VLTR"){if(A==="LTR")return f.dir=C,S(i,f);if(A==="RTL")return f.dir=O,S(i,f)}if(L==="V"&&g==="V")return f.dir=A==="RTL"?O:C,Y(i,f);if(L==="L"&&u==="VRTL")return A==="LTR"?(f.dir=C,i=S(i,f)):(f.dir=O,i=S(i,f)),Y(i);if(o==="VLTR"&&u==="LLTR")return f.dir=C,S(i,f);if(L==="V"&&g==="L"&&A!==d)return i=Y(i),A==="RTL"?E(i,"LLTR","VLTR",a,f):E(i,"LRTL","VRTL",a,f);if(o==="VRTL"&&u==="LRTL")return E(i,"LRTL","VRTL",a,f);if(L==="L"&&g==="L"){const U=f.swap;return f.swap=U.substr(0,1)+"N",A==="RTL"?(f.dir=O,i=S(i,f),f.swap="N"+U.substr(1,2),f.dir=C,i=S(i,f)):(f.dir=C,i=S(i,f),f.swap="N"+U.substr(1,2),i=E(i,"VLTR","LRTL",f.swap,f)),i}return i}function dt(i,o,u){if(o.inFormat===void 0&&(o.inFormat=u.defInFormat),o.outFormat===void 0&&(o.outFormat=u.defOutFormat),o.swap===void 0&&(o.swap=u.defSwap),o.inFormat===o.outFormat)return o;const a=o.inFormat.substring(0,1),f=o.outFormat.substring(0,1);let c,L=o.inFormat.substring(1,4),A=o.outFormat.substring(1,4);return L.charAt(0)==="C"&&(c=D(i),L=c==="ltr"||c==="rtl"?c.toUpperCase():o.inFormat.charAt(2)==="L"?"LTR":"RTL",o.inFormat=a+L),A.charAt(0)==="C"&&(c=D(i),c==="rtl"?A="RTL":c==="ltr"?(c=mt(i),A=c.toUpperCase()):A=o.outFormat.charAt(2)==="L"?"LTR":"RTL",o.outFormat=f+A),o}function Bt(i,o,u){if(o.length===0)return"";i===void 0&&(i=!0),u===void 0&&(u=!0);const a=(o=String(o)).split("");let f=0,c=1,L=a.length;i||(f=a.length-1,c=-1,L=1);const A=Ut(a,f,c,L,u);let g="";for(let d=0;d<a.length;d++)u&&_t(A,A.length,d)>-1?(X(P,d,!i,-1),F.splice(d,1)):g+=a[d];return g}function Ut(i,o,u,a,f){let c=0;const L=[];let A=0;for(let g=o;g*u<a;g+=u)if(Q(i[g])||x(i[g])){if(i[g]==="\u0644"&&St(i,g+u,u,a)){i[g]=Et(i[g+u],c===0?$:tt),g+=u,Vt(i,g,u,a),f&&(L[A]=g,A++),c=0;continue}const d=i[g];c===1?i[g]=Z(i,g+u,u,a)?Ct(i[g]):W(i[g],et):Z(i,g+u,u,a)===!0?i[g]=W(i[g],ot):i[g]=W(i[g],rt),x(d)||(c=1),vt(d)===!0&&(c=0)}else c=0;return L}function D(i){const o=/[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(i);return o?o[0]<="z"?"ltr":"rtl":""}function mt(i){const o=i.split("");return o.reverse(),D(o.join(""))}function Rt(i,o,u){if(i.length===0)return"";u===void 0&&(u=!0),o===void 0&&(o=!0);let a="";const f=(i=String(i)).split("");for(let c=0;c<i.length;c++){let L=!1;if(f[c]>="\uFE70"&&f[c]<"\uFEFF"){const A=i.charCodeAt(c);f[c]>="\uFEF5"&&f[c]<="\uFEFC"?(o?(c>0&&u&&f[c-1]===" "?a=a.substring(0,a.length-1)+"\u0644":(a+="\u0644",L=!0),a+=V[(A-65269)/2]):(a+=V[(A-65269)/2],a+="\u0644",c+1<i.length&&u&&f[c+1]===" "?c++:L=!0),L&&(X(P,c,!0,1),F.splice(c,0,F[c]))):a+=it[A-65136]}else a+=f[c]}return a}function S(i,o){const u=i.split(""),a=[];return K(u,a,o),bt(u,a,o),G(2,u,a,o),G(1,u,a,o),y=a,u.join("")}function K(i,o,u){const a=i.length,f=u.dir?at:st;let c=0,L=-1;const A=[],g=[];u.hiLevel=u.dir,u.lastArabic=!1,u.hasUbatAl=!1,u.hasUbatB=!1,u.hasUbatS=!1;for(let d=0;d<a;d++)A[d]=pt(i[d]);for(let d=0;d<a;d++){const U=c,w=wt(i,A,g,d,u);g[d]=w,c=f[U][w];const N=240&c;c&=15;const M=f[c][jt];if(o[d]=M,N>0)if(N===16){for(let v=L;v<d;v++)o[v]=1;L=-1}else L=-1;if(f[c][kt])L===-1&&(L=d);else if(L>-1){for(let v=L;v<d;v++)o[v]=M;L=-1}A[d]===_&&(o[d]=0),u.hiLevel|=M}u.hasUbatS&&Ft(A,o,a,u)}function Ft(i,o,u,a){for(let f=0;f<u;f++)if(i[f]===j){o[f]=a.dir;for(let c=f-1;c>=0&&i[c]===m;c--)o[c]=a.dir}}function bt(i,o,u){if(u.hiLevel!==0&&u.swap.substr(0,1)!==u.swap.substr(1,2))for(let a=0;a<i.length;a++)o[a]===1&&(i[a]=Nt(i[a]))}function pt(i){const o=i.charCodeAt(0),u=Lt[o>>8];return u<p?u:gt[u-p][255&o]}function Y(i,o){const u=i.split("");if(o){const a=[];K(u,a,o),y=a}return u.reverse(),F.reverse(),u.join("")}function _t(i,o,u){for(let a=0;a<o;a++)if(i[a]===u)return a;return-1}function Q(i){for(let o=0;o<q.length;o++)if(i>=q[o]&&i<=ut[o])return!0;return!1}function Z(i,o,u,a){for(;o*u<a&&x(i[o]);)o+=u;return!!(o*u<a&&Q(i[o]))}function St(i,o,u,a){for(;o*u<a&&x(i[o]);)o+=u;let f=" ";if(!(o*u<a))return!1;f=i[o];for(let c=0;c<V.length;c++)if(V[c]===f)return!0;return!1}function G(i,o,u,a){if(a.hiLevel<i)return;if(i===1&&a.dir===O&&!a.hasUbatB)return o.reverse(),void F.reverse();const f=o.length;let c,L,A,g,d,U=0;for(;U<f;){if(u[U]>=i){for(c=U+1;c<f&&u[c]>=i;)c++;for(L=U,A=c-1;L<A;L++,A--)g=o[L],o[L]=o[A],o[A]=g,d=F[L],F[L]=F[A],F[A]=d;U=c}U++}}function wt(i,o,u,a,f){const c=o[a];return{UBAT_L:()=>(f.lastArabic=!1,e),UBAT_R:()=>(f.lastArabic=!1,s),UBAT_ON:()=>t,UBAT_AN:()=>B,UBAT_EN:()=>f.lastArabic?B:h,UBAT_AL:()=>(f.lastArabic=!0,f.hasUbatAl=!0,s),UBAT_WS:()=>t,UBAT_CS:()=>{let L,A;return a<1||a+1>=o.length||(L=u[a-1])!==h&&L!==B||(A=o[a+1])!==h&&A!==B?t:(f.lastArabic&&(A=B),A===L?A:t)},UBAT_ES:()=>(a>0?u[a-1]:_)===h&&a+1<o.length&&o[a+1]===h?h:t,UBAT_ET:()=>{if(a>0&&u[a-1]===h)return h;if(f.lastArabic)return t;let L=a+1;const A=o.length;for(;L<A&&o[L]===T;)L++;return L<A&&o[L]===h?h:t},UBAT_NSM:()=>{if(f.inFormat==="VLTR"){const L=o.length;let A=a+1;for(;A<L&&o[A]===n;)A++;if(A<L){const g=i[a].charCodeAt[0],d=g>=1425&&g<=2303||g===64286,U=o[A];if(d&&(U===s||U===r))return s}}return a<1||o[a-1]===_?t:u[a-1]},UBAT_B:()=>(f.lastArabic=!0,f.hasUbatB=!0,f.dir),UBAT_S:()=>(f.hasUbatS=!0,t),UBAT_LRE:()=>(f.lastArabic=!1,t),UBAT_RLE:()=>(f.lastArabic=!1,t),UBAT_LRO:()=>(f.lastArabic=!1,t),UBAT_RLO:()=>(f.lastArabic=!1,t),UBAT_PDF:()=>(f.lastArabic=!1,t),UBAT_BN:()=>t}[At[c]]()}function Nt(i){let o,u=0,a=I.length-1;for(;u<=a;)if(o=Math.floor((u+a)/2),i<I[o][0])a=o-1;else{if(!(i>I[o][0]))return I[o][1];u=o+1}return i}function vt(i){for(let o=0;o<z.length;o++)if(z[o]===i)return!0;return!1}function Ct(i){for(let o=0;o<k.length;o++)if(i===k[o])return nt[o];return i}function W(i,o){for(let u=0;u<k.length;u++)if(i===k[u])return o[u];return i}function x(i){return i>="\u064B"&&i<="\u0655"}function H(i){return i==="L"?"LTR":i==="R"?"RTL":i==="C"?"CLR":i==="D"?"CRL":""}function Vt(i,o,u,a){for(;o*u<a&&x(i[o]);)o+=u;return o*u<a&&(i[o]=" ",!0)}function Et(i,o){for(let u=0;u<V.length;u++)if(i===V[u])return o[u];return i}function Ot(i,o,u){F=[],y=[];for(let a=0;a<u;a++)i[a]=a,o[a]=a,F[a]=a}function xt(i){const o=new Array(i.length);for(let u=0;u<i.length;u++)o[i[u]]=u;return o}function X(i,o,u,a){for(let f=0;f<i.length;f++)(i[f]>o||!u&&i[f]===o)&&(i[f]+=a)}let F=[],P=[],y=[];const It={dir:0,defInFormat:"LLTR",defoutFormat:"VLTR",defSwap:"YN",inFormat:"LLTR",outFormat:"VLTR",swap:"YN",hiLevel:0,lastArabic:!1,hasUbatAl:!1,hasBlockSep:!1,hasSegSep:!1,defOutFormat:""},jt=5,kt=6,C=0,O=1,J=/^[(I|V)][(L|R|C|D)][(Y|N)][(S|N)][N]$/,Dt=/[\u0591-\u06ff\ufb1d-\ufefc]/;export{Pt as C};
|